├── .gitignore ├── AUTHORS ├── COPYING ├── README.md ├── qgo.iss └── src ├── application.qrc ├── audio ├── audio.cpp └── audio.h ├── board ├── board.cpp ├── board.h ├── board.qrc ├── boardwindow.cpp ├── boardwindow.h ├── boardwindow.ui ├── clockdisplay.cpp ├── clockdisplay.h ├── gameinfo.cpp ├── gameinfo.h ├── gameinfo.ui ├── gatter.cpp ├── gatter.h ├── graphicsitemstypes.h ├── imagehandler.cpp ├── imagehandler.h ├── mark.cpp ├── mark.h ├── resources │ └── pics │ │ ├── 1downarrow.png │ │ ├── 1leftarrow.png │ │ ├── 1rightarrow.png │ │ ├── 1uparrow.png │ │ ├── 2downarrow.png │ │ ├── 2leftarrow.png │ │ ├── 2rightarrow.png │ │ ├── 2uparrow.png │ │ ├── alt_ghost_black.png │ │ ├── alt_ghost_white.png │ │ ├── back.png │ │ ├── barcelona_cherry.png │ │ ├── bottom.png │ │ ├── contexthelp.png │ │ ├── coord.png │ │ ├── coord2.png │ │ ├── down.png │ │ ├── duplicate.png │ │ ├── duplicate_move.png │ │ ├── editcut.png │ │ ├── empty_branch.png │ │ ├── eraser.png │ │ ├── eurobeech.png │ │ ├── exit.png │ │ ├── exit2.png │ │ ├── export.png │ │ ├── export2.png │ │ ├── fileexport.png │ │ ├── filesave.png │ │ ├── filesaveas.png │ │ ├── forward.png │ │ ├── goldenbeech.png │ │ ├── goto_move.png │ │ ├── idea.png │ │ ├── import.png │ │ ├── import2.png │ │ ├── insert_move.png │ │ ├── lemontree.png │ │ ├── manitoba.png │ │ ├── maple.png │ │ ├── next.png │ │ ├── next_comment.png │ │ ├── paper.png │ │ ├── paste.png │ │ ├── paste_as_var.png │ │ ├── plain.png │ │ ├── player_pause.png │ │ ├── player_play.png │ │ ├── previous.png │ │ ├── previous_comment.png │ │ ├── reload.png │ │ ├── sound_off.png │ │ ├── sound_on.png │ │ ├── start.png │ │ ├── stone_add.png │ │ ├── stone_black.png │ │ ├── stone_circle.png │ │ ├── stone_color.png │ │ ├── stone_cross.png │ │ ├── stone_letter.png │ │ ├── stone_number.png │ │ ├── stone_plain.png │ │ ├── stone_square.png │ │ ├── stone_triangle.png │ │ ├── stone_white.png │ │ ├── stop.png │ │ ├── swap_variations.png │ │ ├── table.png │ │ ├── top.png │ │ ├── up.png │ │ ├── view_tree.png │ │ ├── wood.png │ │ ├── wood3.png │ │ ├── wood4.png │ │ └── wood5.png ├── stone.cpp └── stone.h ├── connectionwidget.cpp ├── connectionwidget.h ├── connectionwidget.ui ├── defines.h ├── displayboard.cpp ├── displayboard.h ├── game_interfaces ├── countdialog.cpp ├── countdialog.h ├── qgoboard.cpp ├── qgoboard.h ├── qgoboard_match.cpp ├── qgoboard_net.h ├── qgoboard_network.cpp ├── qgoboard_observe.cpp ├── qgoboard_review.cpp ├── qgoboardlocalinterface.cpp ├── qgoboardlocalinterface.h ├── resultdialog.cpp ├── resultdialog.h ├── undoprompt.cpp └── undoprompt.h ├── game_tree ├── group.cpp ├── group.h ├── matrix.cpp ├── matrix.h ├── move.cpp ├── move.h ├── tree.cpp └── tree.h ├── gamedata.h ├── gtp ├── qgtp.cpp └── qgtp.h ├── host.cpp ├── host.h ├── listviews.cpp ├── listviews.h ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── network ├── boarddispatch.cpp ├── boarddispatch.h ├── codecwarndialog.cpp ├── codecwarndialog.h ├── consoledispatch.cpp ├── consoledispatch.h ├── createroomdialog.cpp ├── createroomdialog.h ├── createroomdialog.ui ├── cyberoroconnection.cpp ├── cyberoroconnection.h ├── cyberoroprotocol.h ├── eweiqiconnection.cpp ├── eweiqiconnection.h ├── friendslistdialog.cpp ├── friendslistdialog.h ├── friendslistdialog.ui ├── gamedialog.cpp ├── gamedialog.h ├── gamedialog.ui ├── gamedialogflags.h ├── igsconnection.cpp ├── igsconnection.h ├── lgs.cpp ├── lgs.h ├── login.cpp ├── login.h ├── login.ui ├── matchinvitedialog.cpp ├── matchinvitedialog.h ├── matchnegotiationstate.cpp ├── matchnegotiationstate.h ├── messages.h ├── networkconnection.cpp ├── networkconnection.h ├── orosetphrasechat.cpp ├── orosetphrasechat.h ├── parser.cpp ├── parser.h ├── playergamelistings.h ├── protocol.h ├── quickconnection.cpp ├── quickconnection.h ├── room.cpp ├── room.h ├── serverlistdialog.cpp ├── serverlistdialog.h ├── setphrasepalette.cpp ├── setphrasepalette.h ├── talk.cpp ├── talk.h ├── talk_gui.ui ├── tomconnection.cpp ├── tomconnection.h ├── tygemconnection.cpp ├── tygemconnection.h ├── tygemprotocol.h ├── wing.cpp └── wing.h ├── newgamedialog.cpp ├── newgamedialog.h ├── newgamedialog.ui ├── preferences.cpp ├── preferences.h ├── preferences.ui ├── qgo.desktop ├── qgo.rc ├── resources ├── pics │ ├── Bowl.ico │ ├── Bowl.png │ ├── close.png │ ├── connect_no2.png │ ├── connected.png │ ├── not_seeking.png │ ├── qgo.png │ ├── qgo_16x16.xpm │ ├── qgo_32x32.xpm │ ├── qgo_48x48.png │ ├── qgo_48x48.xpm │ ├── refresh_games.png │ ├── refresh_players.png │ ├── seeking1.png │ ├── seeking2.png │ ├── seeking3.png │ ├── seeking4.png │ ├── toolbar_1.png │ ├── toolbar_2.png │ ├── toolbar_3.png │ ├── toolbar_4.png │ └── toolbar_5.png └── sounds │ ├── blip.wav │ ├── buzzer.wav │ ├── doorbell.wav │ ├── ns.wav │ ├── pop.wav │ ├── static.wav │ ├── stone.wav │ └── timer.wav ├── sgf ├── sgfparser.cpp └── sgfparser.h ├── sgfpreview.cpp ├── sgfpreview.h ├── sgfpreview.ui ├── src.pro └── translations ├── qgo_cz.ts ├── qgo_de.ts ├── qgo_dk.ts ├── qgo_fr.ts ├── qgo_it.ts ├── qgo_la.ts ├── qgo_nl.ts ├── qgo_pt.ts ├── qgo_ru.ts ├── qgo_tr.ts ├── qgo_zh.ts └── qgo_zh_cn.ts /.gitignore: -------------------------------------------------------------------------------- 1 | *.pro.user* 2 | *.qmlproject.user* 3 | *.qm 4 | Makefile 5 | bin/* 6 | build/* 7 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | qGo 0.x - 1.x Developers 2 | ----------- 3 | Johannes Mesa 4 | Emmanuel Beranger 5 | Peter Strempel 6 | Neil Stevens 7 | 8 | qGo 2.0 Developers 9 | ----------- 10 | Peter Van Bohning 11 | Emmanuel Beranger 12 | 13 | qGo 2.1 Developers 14 | ----------- 15 | Pavel Zorin-Kranich 16 | 17 | Contributors 18 | ----------- 19 | Marin Ferecatu 20 | Wenzhi Liang 21 | Radek Valasek 22 | 23 | Translators 24 | ----------- 25 | Barkin Turkish 26 | Tim Fooy Dutch 27 | Johannes Mesa German 28 | Loic Martin French 29 | Emmanuel Beranger French 30 | Davide Italian 31 | Finn Jensen Danish 32 | Ales Chejn Czech 33 | Wex Taliro Chinese 34 | Felipe Castro Portugese 35 | Robert Polish 36 | Denis Artamanov Russian 37 | 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## qGo 2 | 3 | qGo is a Go Client based on Qt 5. 4 | It supports playing online at IGS-compatible servers (including some special tweaks for WING and LGS, also NNGS was reported to work) and locally against gnugo (or other GTP-compliant engines). 5 | It also has rudimentary support for editing SGF files and parital support for CyberORO/WBaduk, Tygem, Tom, and eWeiqi (developers of these backends are currently inactive, everybody is welcome to take them over). 6 | 7 | Go is an ancient Chinese board game. It's called "圍棋(Wei Qi)" in Chinese, "囲碁(Yi Go)" in Japanese, "바둑(Baduk)" in Korean. 8 | 9 | 10 | Installation 11 | ------------ 12 | Qt 5.7 is or newer is required to build qgo. 13 | 14 | ```sh 15 | git clone https://github.com/pzorin/qgo.git 16 | cd qgo 17 | qmake -qt=5 src 18 | make 19 | sudo make install 20 | ``` 21 | -------------------------------------------------------------------------------- /src/application.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | resources/pics/Bowl.ico 4 | resources/pics/Bowl.png 5 | resources/pics/close.png 6 | resources/pics/connect_no2.png 7 | resources/pics/connected.png 8 | resources/pics/not_seeking.png 9 | resources/pics/qgo_16x16.xpm 10 | resources/pics/qgo_32x32.xpm 11 | resources/pics/qgo_48x48.png 12 | resources/pics/qgo_48x48.xpm 13 | resources/pics/qgo.png 14 | resources/pics/refresh_games.png 15 | resources/pics/refresh_players.png 16 | resources/pics/seeking1.png 17 | resources/pics/seeking2.png 18 | resources/pics/seeking3.png 19 | resources/pics/seeking4.png 20 | resources/pics/toolbar_1.png 21 | resources/pics/toolbar_2.png 22 | resources/pics/toolbar_3.png 23 | resources/pics/toolbar_4.png 24 | resources/pics/toolbar_5.png 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/audio/audio.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include "audio/audio.h" 24 | #include 25 | #include 26 | #include 27 | 28 | Sound::Sound(const QString &filename, QObject *parent, int delay_msec) 29 | : QObject(parent), delay(delay_msec) 30 | { 31 | player = new QMediaPlayer; 32 | if (QDir().exists(SOUND_PATH_PREFIX + filename)) 33 | player->setMedia(QMediaContent(QUrl::fromLocalFile(QDir().absoluteFilePath(SOUND_PATH_PREFIX + filename)))); 34 | nextSound = QTime::currentTime(); 35 | } 36 | 37 | Sound::~Sound() 38 | { 39 | delete player; 40 | } 41 | 42 | void Sound::play(void) 43 | { 44 | // Do not play the same sound too often (by default every 250 ms) 45 | if (QTime::currentTime() < nextSound) 46 | return; 47 | 48 | nextSound = QTime::currentTime(); 49 | nextSound = nextSound.addMSecs(delay); 50 | player->play(); 51 | } 52 | -------------------------------------------------------------------------------- /src/audio/audio.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef _AUDIO_H_ 24 | #define _AUDIO_H_ 25 | 26 | #include 27 | #include 28 | 29 | class QMediaPlayer; 30 | 31 | class Sound : public QObject 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | Sound(const QString& filename, QObject* parent=0, int delay_msec=250); 37 | ~Sound(); 38 | 39 | void play(void); 40 | private: 41 | QMediaPlayer *player; 42 | QTime nextSound; 43 | int delay; 44 | }; 45 | 46 | #endif // _AUDIO_H_ 47 | -------------------------------------------------------------------------------- /src/board/board.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | resources/pics/1downarrow.png 4 | resources/pics/1leftarrow.png 5 | resources/pics/1rightarrow.png 6 | resources/pics/1uparrow.png 7 | resources/pics/2downarrow.png 8 | resources/pics/2leftarrow.png 9 | resources/pics/2rightarrow.png 10 | resources/pics/2uparrow.png 11 | resources/pics/alt_ghost_black.png 12 | resources/pics/alt_ghost_white.png 13 | resources/pics/back.png 14 | resources/pics/barcelona_cherry.png 15 | resources/pics/bottom.png 16 | resources/pics/contexthelp.png 17 | resources/pics/coord.png 18 | resources/pics/coord2.png 19 | resources/pics/down.png 20 | resources/pics/duplicate_move.png 21 | resources/pics/duplicate.png 22 | resources/pics/editcut.png 23 | resources/pics/empty_branch.png 24 | resources/pics/eraser.png 25 | resources/pics/eurobeech.png 26 | resources/pics/exit.png 27 | resources/pics/exit2.png 28 | resources/pics/export.png 29 | resources/pics/export2.png 30 | resources/pics/fileexport.png 31 | resources/pics/filesave.png 32 | resources/pics/filesaveas.png 33 | resources/pics/forward.png 34 | resources/pics/goldenbeech.png 35 | resources/pics/goto_move.png 36 | resources/pics/idea.png 37 | resources/pics/import.png 38 | resources/pics/import2.png 39 | resources/pics/insert_move.png 40 | resources/pics/lemontree.png 41 | resources/pics/manitoba.png 42 | resources/pics/maple.png 43 | resources/pics/next_comment.png 44 | resources/pics/next.png 45 | resources/pics/paper.png 46 | resources/pics/paste_as_var.png 47 | resources/pics/paste.png 48 | resources/pics/plain.png 49 | resources/pics/player_pause.png 50 | resources/pics/player_play.png 51 | resources/pics/previous_comment.png 52 | resources/pics/previous.png 53 | resources/pics/reload.png 54 | resources/pics/sound_off.png 55 | resources/pics/sound_on.png 56 | resources/pics/start.png 57 | resources/pics/stone_add.png 58 | resources/pics/stone_black.png 59 | resources/pics/stone_circle.png 60 | resources/pics/stone_color.png 61 | resources/pics/stone_cross.png 62 | resources/pics/stone_letter.png 63 | resources/pics/stone_number.png 64 | resources/pics/stone_plain.png 65 | resources/pics/stone_square.png 66 | resources/pics/stone_triangle.png 67 | resources/pics/stone_white.png 68 | resources/pics/stop.png 69 | resources/pics/swap_variations.png 70 | resources/pics/table.png 71 | resources/pics/top.png 72 | resources/pics/up.png 73 | resources/pics/view_tree.png 74 | resources/pics/wood.png 75 | resources/pics/wood3.png 76 | resources/pics/wood4.png 77 | resources/pics/wood5.png 78 | 79 | 80 | -------------------------------------------------------------------------------- /src/board/clockdisplay.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef CLOCK_H 24 | #define CLOCK_H 25 | 26 | #include "defines.h" 27 | #include 28 | 29 | class BoardWindow; 30 | class Sound; 31 | 32 | class ClockDisplay : public QObject 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | ClockDisplay(BoardWindow *bw, TimeSystem s, int _maintime, int _period, int _periodtime); 38 | ~ClockDisplay() {} 39 | void setTime( bool black, int secs); 40 | void setTimeStep(bool black); 41 | void rerackTime(bool black); 42 | void makeMove(bool black); 43 | class TimeRecord getTimeRecord(bool black); 44 | void setTimeSettings(TimeSystem s, int m, int p, int o); 45 | void setTimeInfo(int btime, int bstones_periods, int wtime, int wstones_periods); 46 | void updateTimers(); 47 | bool warning(bool black); 48 | private : 49 | BoardWindow *boardwindow; 50 | TimeSystem timeSystem; 51 | int w_time, b_time; 52 | int w_stones_periods, b_stones_periods; 53 | int maintime, periods, periodtime; 54 | Sound *warningSound; 55 | int warningSecs; 56 | bool playWarningSound; 57 | bool outOfMainTime; 58 | bool last_black; 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /src/board/gameinfo.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include "ui_gameinfo.h" 24 | #include 25 | 26 | class BoardWindow; 27 | 28 | class GameInfo : public QDialog, public Ui::GameinfoDialog 29 | { 30 | Q_OBJECT 31 | 32 | public: 33 | GameInfo(BoardWindow * bw); 34 | virtual ~GameInfo(); 35 | 36 | public: 37 | void slotGameInfoButton(QAbstractButton *); 38 | void slotGameInfoTextEdited(const QString &); 39 | 40 | private: 41 | Ui::GameinfoDialog ui; 42 | BoardWindow * boardwindow; 43 | }; 44 | -------------------------------------------------------------------------------- /src/board/gatter.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef GATTER_H 24 | #define GATTER_H 25 | 26 | #include 27 | #include 28 | 29 | class Gatter 30 | { 31 | public: 32 | Gatter(QGraphicsScene *canvas, int board_size); 33 | ~Gatter(); 34 | void hide (int x, int y); 35 | void show (int x, int y); 36 | void resize(int offsetX, int offsetY, int square_size); 37 | void showAll(); 38 | 39 | private: 40 | int board_size; 41 | inline int indexOf(int x, int y) { return (x-1)*board_size + y-1; } 42 | QGraphicsScene *canvas; 43 | QList VGatter, HGatter ; 44 | QMap hoshisList ; 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/board/graphicsitemstypes.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | /* 23 | * GraphicsItems types for the board class 24 | */ 25 | #define RTTI_STONE 1001 26 | #define RTTI_MARK_SQUARE 1002 27 | #define RTTI_MARK_CIRCLE 1003 28 | #define RTTI_MARK_TRIANGLE 1004 29 | #define RTTI_MARK_CROSS 1005 30 | #define RTTI_MARK_TEXT 1006 31 | #define RTTI_MARK_NUMBER 1007 32 | #define RTTI_MARK_TERR 1008 33 | #define RTTI_MARK_OTHERLINE 1009 34 | -------------------------------------------------------------------------------- /src/board/imagehandler.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef IMAGEDATA_H 24 | #define IMAGEDATA_H 25 | 26 | #include 27 | #include 28 | 29 | /* DONTREDRAWSTONES lets Qt do the scaling rather than redrawing them 30 | * to scale. I'm not convinced it improves the speed all that much 31 | * but I do know that it removes the border on the white stones in 2d 32 | * mode so until that's fixed or until another solution is found, I'll 33 | * comment this out */ 34 | 35 | //#define DONTREDRAWSTONES 36 | struct WhiteDesc { 37 | double cosTheta, sinTheta; 38 | double stripeWidth, xAdd; 39 | double stripeMul, zMul; 40 | }; 41 | 42 | class ImageHandler 43 | { 44 | public: 45 | ImageHandler(); 46 | ~ImageHandler(); 47 | 48 | void setDisplay(bool isDisplay = false); 49 | void setSquareSize(int size); 50 | static QPixmap *getBoardPixmap(QString ) ; 51 | static QPixmap *getTablePixmap(QString ) ; 52 | #ifdef DONTREDRAWSTONES 53 | QList *getStonePixmaps() const { return stonePixmapsScaled; } 54 | QList *getSmallStonePixmaps() const { return smallStonePixmapsScaled; } 55 | QList *getGhostPixmaps() const { return ghostPixmapsScaled; } 56 | #else 57 | QList *getStonePixmaps() const { return stonePixmaps; } 58 | QList *getSmallStonePixmaps() const { return smallStonePixmaps; } 59 | QList *getGhostPixmaps() const { return ghostPixmaps; } 60 | #endif //DONTREDRAWSTONES 61 | static QList * getAlternateGhostPixmaps() { return altGhostPixmaps; } 62 | void ghostImage(QImage *img); 63 | 64 | void icopy(int *im, QImage &qim, int w, int h); 65 | void decideAppearance(WhiteDesc *desc, int size); 66 | double getStripe(WhiteDesc &white, double bright, double z, int x, int y); 67 | 68 | 69 | protected: 70 | void scaleBoardPixmap(QPixmap *pix, int size); 71 | 72 | private: 73 | 74 | #ifdef DONTREDRAWSTONES 75 | void generateStonePixmaps(int size); 76 | QList *stonePixmapsScaled, *ghostPixmapsScaled, *smallStonePixmapsScaled; 77 | #endif //DONTREDRAWSTONES 78 | void paintBlackStone (QImage &bi, int d, int stone_render); 79 | void paintShadowStone (QImage &si, int d); 80 | void paintWhiteStone (QImage &wi, int d, int stone_render); 81 | int * painting_buffer; 82 | 83 | bool isDisplayBoard; 84 | QList *stonePixmaps, *ghostPixmaps, *smallStonePixmaps; 85 | static QList *altGhostPixmaps; 86 | static QPixmap *tablePixmap; 87 | static QPixmap *woodPixmap1; 88 | static int classCounter; 89 | }; 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /src/board/resources/pics/1downarrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/1downarrow.png -------------------------------------------------------------------------------- /src/board/resources/pics/1leftarrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/1leftarrow.png -------------------------------------------------------------------------------- /src/board/resources/pics/1rightarrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/1rightarrow.png -------------------------------------------------------------------------------- /src/board/resources/pics/1uparrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/1uparrow.png -------------------------------------------------------------------------------- /src/board/resources/pics/2downarrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/2downarrow.png -------------------------------------------------------------------------------- /src/board/resources/pics/2leftarrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/2leftarrow.png -------------------------------------------------------------------------------- /src/board/resources/pics/2rightarrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/2rightarrow.png -------------------------------------------------------------------------------- /src/board/resources/pics/2uparrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/2uparrow.png -------------------------------------------------------------------------------- /src/board/resources/pics/alt_ghost_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/alt_ghost_black.png -------------------------------------------------------------------------------- /src/board/resources/pics/alt_ghost_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/alt_ghost_white.png -------------------------------------------------------------------------------- /src/board/resources/pics/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/back.png -------------------------------------------------------------------------------- /src/board/resources/pics/barcelona_cherry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/barcelona_cherry.png -------------------------------------------------------------------------------- /src/board/resources/pics/bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/bottom.png -------------------------------------------------------------------------------- /src/board/resources/pics/contexthelp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/contexthelp.png -------------------------------------------------------------------------------- /src/board/resources/pics/coord.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/coord.png -------------------------------------------------------------------------------- /src/board/resources/pics/coord2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/coord2.png -------------------------------------------------------------------------------- /src/board/resources/pics/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/down.png -------------------------------------------------------------------------------- /src/board/resources/pics/duplicate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/duplicate.png -------------------------------------------------------------------------------- /src/board/resources/pics/duplicate_move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/duplicate_move.png -------------------------------------------------------------------------------- /src/board/resources/pics/editcut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/editcut.png -------------------------------------------------------------------------------- /src/board/resources/pics/empty_branch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/empty_branch.png -------------------------------------------------------------------------------- /src/board/resources/pics/eraser.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/eraser.png -------------------------------------------------------------------------------- /src/board/resources/pics/eurobeech.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/eurobeech.png -------------------------------------------------------------------------------- /src/board/resources/pics/exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/exit.png -------------------------------------------------------------------------------- /src/board/resources/pics/exit2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/exit2.png -------------------------------------------------------------------------------- /src/board/resources/pics/export.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/export.png -------------------------------------------------------------------------------- /src/board/resources/pics/export2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/export2.png -------------------------------------------------------------------------------- /src/board/resources/pics/fileexport.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/fileexport.png -------------------------------------------------------------------------------- /src/board/resources/pics/filesave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/filesave.png -------------------------------------------------------------------------------- /src/board/resources/pics/filesaveas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/filesaveas.png -------------------------------------------------------------------------------- /src/board/resources/pics/forward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/forward.png -------------------------------------------------------------------------------- /src/board/resources/pics/goldenbeech.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/goldenbeech.png -------------------------------------------------------------------------------- /src/board/resources/pics/goto_move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/goto_move.png -------------------------------------------------------------------------------- /src/board/resources/pics/idea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/idea.png -------------------------------------------------------------------------------- /src/board/resources/pics/import.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/import.png -------------------------------------------------------------------------------- /src/board/resources/pics/import2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/import2.png -------------------------------------------------------------------------------- /src/board/resources/pics/insert_move.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/insert_move.png -------------------------------------------------------------------------------- /src/board/resources/pics/lemontree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/lemontree.png -------------------------------------------------------------------------------- /src/board/resources/pics/manitoba.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/manitoba.png -------------------------------------------------------------------------------- /src/board/resources/pics/maple.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/maple.png -------------------------------------------------------------------------------- /src/board/resources/pics/next.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/next.png -------------------------------------------------------------------------------- /src/board/resources/pics/next_comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/next_comment.png -------------------------------------------------------------------------------- /src/board/resources/pics/paper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/paper.png -------------------------------------------------------------------------------- /src/board/resources/pics/paste.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/paste.png -------------------------------------------------------------------------------- /src/board/resources/pics/paste_as_var.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/paste_as_var.png -------------------------------------------------------------------------------- /src/board/resources/pics/plain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/plain.png -------------------------------------------------------------------------------- /src/board/resources/pics/player_pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/player_pause.png -------------------------------------------------------------------------------- /src/board/resources/pics/player_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/player_play.png -------------------------------------------------------------------------------- /src/board/resources/pics/previous.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/previous.png -------------------------------------------------------------------------------- /src/board/resources/pics/previous_comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/previous_comment.png -------------------------------------------------------------------------------- /src/board/resources/pics/reload.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/reload.png -------------------------------------------------------------------------------- /src/board/resources/pics/sound_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/sound_off.png -------------------------------------------------------------------------------- /src/board/resources/pics/sound_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/sound_on.png -------------------------------------------------------------------------------- /src/board/resources/pics/start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/start.png -------------------------------------------------------------------------------- /src/board/resources/pics/stone_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/stone_add.png -------------------------------------------------------------------------------- /src/board/resources/pics/stone_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/stone_black.png -------------------------------------------------------------------------------- /src/board/resources/pics/stone_circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/stone_circle.png -------------------------------------------------------------------------------- /src/board/resources/pics/stone_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/stone_color.png -------------------------------------------------------------------------------- /src/board/resources/pics/stone_cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/stone_cross.png -------------------------------------------------------------------------------- /src/board/resources/pics/stone_letter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/stone_letter.png -------------------------------------------------------------------------------- /src/board/resources/pics/stone_number.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/stone_number.png -------------------------------------------------------------------------------- /src/board/resources/pics/stone_plain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/stone_plain.png -------------------------------------------------------------------------------- /src/board/resources/pics/stone_square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/stone_square.png -------------------------------------------------------------------------------- /src/board/resources/pics/stone_triangle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/stone_triangle.png -------------------------------------------------------------------------------- /src/board/resources/pics/stone_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/stone_white.png -------------------------------------------------------------------------------- /src/board/resources/pics/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/stop.png -------------------------------------------------------------------------------- /src/board/resources/pics/swap_variations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/swap_variations.png -------------------------------------------------------------------------------- /src/board/resources/pics/table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/table.png -------------------------------------------------------------------------------- /src/board/resources/pics/top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/top.png -------------------------------------------------------------------------------- /src/board/resources/pics/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/up.png -------------------------------------------------------------------------------- /src/board/resources/pics/view_tree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/view_tree.png -------------------------------------------------------------------------------- /src/board/resources/pics/wood.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/wood.png -------------------------------------------------------------------------------- /src/board/resources/pics/wood3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/wood3.png -------------------------------------------------------------------------------- /src/board/resources/pics/wood4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/wood4.png -------------------------------------------------------------------------------- /src/board/resources/pics/wood5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/board/resources/pics/wood5.png -------------------------------------------------------------------------------- /src/board/stone.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef STONE_H 24 | #define STONE_H 25 | 26 | #include "graphicsitemstypes.h" 27 | 28 | #include 29 | #include 30 | 31 | class Stone : public QGraphicsPixmapItem 32 | { 33 | public: 34 | Stone(QList *a, QGraphicsScene *canvas, StoneColor c, int x, int y, bool has_shadow=false); 35 | ~Stone() ; 36 | 37 | StoneColor getColor() const { return color; } 38 | void setColor(StoneColor c=stoneBlack); 39 | void toggleOneColorGo(bool oneColor) ; 40 | int type() const { return RTTI_STONE; } 41 | int posX() const { return myX; } 42 | int posY() const { return myY; } 43 | QGraphicsSimpleTextItem * getNum() {return moveNum;} 44 | void setCoord(int x, int y) { myX = x; myY = y; } 45 | void togglePixmap(QList *a, bool showShadow = true); 46 | 47 | bool isDead() const { return dead; } 48 | void setDead(bool b=true) { dead = b; seki = false;} 49 | bool isSeki() const { return seki; } 50 | void setSeki(bool b=true) { seki = b; dead = false; } 51 | 52 | void setPos(double x, double y); 53 | void show(); 54 | void hide(); 55 | 56 | bool checked; 57 | 58 | 59 | 60 | private: 61 | StoneColor color; 62 | int myX, myY; 63 | bool dead, seki; 64 | QList *pixmapList; 65 | QGraphicsSimpleTextItem *moveNum; 66 | QGraphicsPixmapItem *shadow; 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/displayboard.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include "displayboard.h" 24 | #include "stone.h" 25 | #include "mark.h" 26 | #include "board.h" 27 | #include "imagehandler.h" 28 | 29 | #include 30 | 31 | DisplayBoard::DisplayBoard(QWidget *parent, QGraphicsScene *c) 32 | : Board(parent,c) 33 | { 34 | isDisplayBoard = true; 35 | showCoords = false; 36 | imageHandler->setDisplay(true); 37 | } 38 | 39 | DisplayBoard::~DisplayBoard() 40 | { 41 | } 42 | 43 | /* Used by file browse display */ 44 | void DisplayBoard::displayHandicap(int handicap) 45 | { 46 | int size = 19; 47 | int edge_dist = (size > 12 ? 4 : 3); 48 | int low = edge_dist; 49 | int middle = (size + 1) / 2; 50 | int high = size + 1 - edge_dist; 51 | 52 | 53 | switch (handicap) 54 | { 55 | case 9: 56 | updateStone(stoneBlack, middle, middle); 57 | case 8: 58 | case 7: 59 | if (handicap >= 8) 60 | { 61 | updateStone(stoneBlack, middle, low); 62 | updateStone(stoneBlack, middle, high); 63 | } 64 | else 65 | updateStone(stoneBlack, middle, middle); 66 | case 6: 67 | case 5: 68 | if (handicap >= 6) 69 | { 70 | updateStone(stoneBlack, low, middle); 71 | updateStone(stoneBlack, high, middle); 72 | } 73 | else 74 | updateStone(stoneBlack, middle, middle); 75 | case 4: 76 | updateStone(stoneBlack, high, high); 77 | case 3: 78 | updateStone(stoneBlack, low, low); 79 | case 2: 80 | updateStone(stoneBlack, high, low); 81 | updateStone(stoneBlack, low, high); 82 | default: 83 | break; 84 | } 85 | 86 | 87 | } 88 | 89 | -------------------------------------------------------------------------------- /src/displayboard.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef DISPLAYBOARD_H 24 | #define DISPLAYBOARD_H 25 | 26 | #include "board.h" 27 | 28 | class QGraphicsScene; 29 | class QWidget; 30 | 31 | class DisplayBoard : public Board 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | DisplayBoard(QWidget *parent=0, QGraphicsScene *c=0 ); 37 | ~DisplayBoard(); 38 | 39 | void displayHandicap(int h); 40 | }; 41 | 42 | #endif 43 | 44 | -------------------------------------------------------------------------------- /src/game_interfaces/countdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | 25 | class QLabel; 26 | class QDialogButtonBox; 27 | class GameResult; 28 | class BoardDispatch; 29 | class BoardWindow; 30 | 31 | class CountDialog : public QDialog 32 | { 33 | Q_OBJECT 34 | public: 35 | CountDialog(BoardWindow * parent, BoardDispatch * dis, unsigned int game_id); 36 | ~CountDialog(); 37 | //virtual QSize minimumSize(void) const { return QSize(300, 150); }; 38 | void recvRejectCount(void); 39 | void recvAcceptCount(void); 40 | public: 41 | void slot_accept(void); 42 | void slot_reject(void); 43 | private: 44 | QLabel * mainlabel; 45 | QPushButton * acceptButton; 46 | QPushButton * rejectButton; 47 | QDialogButtonBox * buttonBox; 48 | BoardDispatch * dispatch; 49 | BoardWindow * board; 50 | GameResult * result; 51 | bool oppAcceptsCount; 52 | bool oppRejectsCount; 53 | bool weAcceptCount; 54 | bool weRejectCount; 55 | }; 56 | -------------------------------------------------------------------------------- /src/game_interfaces/qgoboard_net.h: -------------------------------------------------------------------------------- 1 | #ifndef QGOBOARD_NET_H 2 | #define QGOBOARD_NET_H 3 | 4 | #include "defines.h" 5 | #include "qgoboard.h" 6 | 7 | class NetworkConnection; 8 | class BoardDispatch; 9 | 10 | class qGoBoardNetworkInterface : public qGoBoard 11 | { 12 | Q_OBJECT 13 | public: 14 | virtual ~qGoBoardNetworkInterface() {} 15 | virtual void slotUndoPressed(); 16 | virtual void slotDonePressed(); 17 | virtual void slotResignPressed(); 18 | virtual void slotReviewPressed() {} //should FIXME these two 19 | virtual void slotAdjournPressed() {} 20 | virtual void passRequest(); 21 | protected: 22 | qGoBoardNetworkInterface(BoardWindow *boardWindow, Tree * tree, GameData *gameData); 23 | virtual void sendMoveToInterface(StoneColor c,int x, int y); 24 | virtual void handleMove(MoveRecord * m); 25 | virtual void moveControl(QString & player) { controlling_player = player; } 26 | virtual void adjournGame(void); 27 | virtual void startGame(void) {} 28 | virtual void stopTime(void); 29 | virtual void onFirstMove(void) {} 30 | 31 | QString game_Id; 32 | bool dontsend; 33 | QString controlling_player; 34 | Move * reviewCurrent; 35 | virtual Move *doMove(StoneColor c, int x, int y); 36 | BoardDispatch *dispatch; 37 | NetworkConnection *connection; 38 | }; 39 | 40 | class qGoBoardObserveInterface : public qGoBoardNetworkInterface 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | qGoBoardObserveInterface(BoardWindow *boardWindow, Tree * tree, GameData *gameData); 46 | ~qGoBoardObserveInterface() {} 47 | 48 | void setModified(bool) {} //we don't modify an observed game 49 | void slotUpdateComment() {} //what is this ?!?!? 50 | virtual void slotUndoPressed(void){} 51 | virtual void slotDonePressed(void){} 52 | virtual void slotResignPressed(void){} 53 | virtual void slotAdjournPressed(void){} 54 | 55 | signals: 56 | void signal_sendCommandFromBoard(const QString&, bool); 57 | 58 | private: 59 | // bool doMove(StoneColor c, int x, int y); 60 | virtual void onFirstMove(void); 61 | 62 | 63 | 64 | }; 65 | 66 | class qGoBoardMatchInterface : public qGoBoardNetworkInterface 67 | { 68 | Q_OBJECT 69 | 70 | public: 71 | qGoBoardMatchInterface(BoardWindow *boardWindow, Tree * tree, GameData *gameData); 72 | ~qGoBoardMatchInterface() {} 73 | 74 | void setModified(bool) {} //we don't modify a match game 75 | void setTimerInfo(const QString&, const QString&, const QString&, const QString&); 76 | void enterScoreMode(); 77 | void leaveScoreMode(); 78 | void timerEvent(QTimerEvent*); 79 | virtual void requestAdjournDialog(void); 80 | virtual void requestCountDialog(void); 81 | virtual void requestMatchModeDialog(void); 82 | virtual void requestDrawDialog(void); 83 | virtual void recvRefuseAdjourn(void); 84 | virtual void recvRefuseCount(void); 85 | virtual void recvRefuseMatchMode(void); 86 | virtual void recvRefuseDraw(void); 87 | void slotUpdateComment() {} 88 | virtual void slotReviewPressed(); 89 | virtual void slotDrawPressed(); 90 | virtual void slotCountPressed(); 91 | virtual void slotAdjournPressed(); 92 | 93 | signals: 94 | void signal_sendCommandFromBoard(const QString&, bool); 95 | 96 | private: 97 | void localMoveRequest(StoneColor c, int x, int y); 98 | void localMarkDeadRequest(int x, int y); 99 | virtual void startGame(void); 100 | virtual void onFirstMove(void); 101 | // bool warningSound; 102 | // int warningSecs; 103 | 104 | }; 105 | 106 | class qGoBoardReviewInterface : public qGoBoardNetworkInterface 107 | { 108 | Q_OBJECT 109 | 110 | public: 111 | qGoBoardReviewInterface(BoardWindow *boardWindow, Tree * tree, GameData *gameData); 112 | ~qGoBoardReviewInterface() {} 113 | 114 | // void setModified(bool) {} //we don't modify an game 115 | // void setResult(QString res, QString xt_res); 116 | // void setTimerInfo(const QString&, const QString&, const QString&, const QString&); 117 | //void set_move(StoneColor sc, QString pt, QString mv_nr); 118 | void setNode(int move_nr, StoneColor c, int x, int y); 119 | void slotUpdateComment() {} 120 | // void slotDonePressed(); 121 | void slotUndoPressed() ; 122 | 123 | signals: 124 | void signal_sendCommandFromBoard(const QString&, bool); 125 | 126 | private: 127 | void localMoveRequest(StoneColor c, int x, int y); 128 | 129 | }; 130 | 131 | 132 | #endif // QGOBOARD_NET_H 133 | -------------------------------------------------------------------------------- /src/game_interfaces/qgoboard_observe.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | #include "qgoboard_net.h" 23 | #include "qgtp.h" 24 | #include "tree.h" 25 | #include "move.h" 26 | #include "network/boarddispatch.h" 27 | #include "network/messages.h" 28 | #include "boardwindow.h" 29 | #include "networkconnection.h" 30 | 31 | qGoBoardObserveInterface::qGoBoardObserveInterface(BoardWindow *bw, Tree * t, GameData *gd) : qGoBoardNetworkInterface(bw, t, gd) //, QObject(bw) 32 | { 33 | if(connection->startTimerOnOpen() && connection->clientCountsTime()) 34 | boardTimerId = startTimer(1000); 35 | dispatch->requestGameInfo(); 36 | 37 | QSettings settings; 38 | playSound = (settings.value("SOUND_OTHERGAMES").toBool()); 39 | } 40 | 41 | void qGoBoardObserveInterface::onFirstMove(void) 42 | { 43 | //we can now start the timer 44 | if(!connection->startTimerOnOpen() && connection->clientCountsTime()) 45 | boardTimerId = startTimer(1000); 46 | } 47 | -------------------------------------------------------------------------------- /src/game_interfaces/qgoboard_review.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2006 by EB * 3 | * * 4 | * * 5 | * This program is free software; you can redistribute it and/or modify * 6 | * it under the terms of the GNU General Public License as published by * 7 | * the Free Software Foundation; either version 2 of the License, or * 8 | * (at your option) any later version. * 9 | * * 10 | * This program is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 13 | * GNU General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program; if not, write to the * 17 | * Free Software Foundation, Inc., * 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 19 | ***************************************************************************/ 20 | 21 | 22 | #include "qgoboard_net.h" 23 | #include "tree.h" 24 | #include "move.h" 25 | #include "gamedata.h" 26 | #include "boardwindow.h" 27 | #include "board.h" 28 | 29 | #include 30 | 31 | qGoBoardReviewInterface::qGoBoardReviewInterface(BoardWindow *bw, Tree * t, GameData *gd) : qGoBoardNetworkInterface(bw, t, gd) //, QObject(bw) 32 | { 33 | game_Id = QString::number(gd->number); 34 | 35 | boardwindow->clearData(); 36 | 37 | QSettings settings; 38 | // value 1 = no sound, 0 all games, 2 my games 39 | playSound = (settings.value("SOUND") != 1); 40 | 41 | tree->slotNavFirst(); 42 | } 43 | 44 | 45 | /* 46 | * local move request to be sent to the server 47 | */ 48 | void qGoBoardReviewInterface::localMoveRequest(StoneColor c, int x, int y) 49 | { 50 | // if (doMove(c,x,y)) 51 | // FIXME : this should be made in a better way : wait for the interface to acknowledge before adding the move to the tree 52 | // { 53 | // boardwindow->getBoardHandler()->updateMove(tree->getCurrent()); 54 | sendMoveToInterface(c,x,y); 55 | // } 56 | 57 | } 58 | 59 | /* This is like a special set_move and should be more clear */ 60 | /* 61 | * A node is incoming from the interface (server) 62 | */ 63 | void qGoBoardReviewInterface::setNode(int node_nr, StoneColor sc, int x, int y) 64 | { 65 | Move *m = tree->findNode(tree->getRoot(), node_nr); 66 | 67 | if (m) 68 | //node found, we go there 69 | tree->setCurrent(m); 70 | else 71 | // no node found, we create one from the current move 72 | { 73 | if (doMove(sc, x,y)) 74 | tree->getCurrent()->setNodeIndex(node_nr); 75 | else 76 | QMessageBox::warning(boardwindow, tr("Invalid Move"), tr("The incoming move %1,%2 seems to be invalid").arg(x).arg(y)); 77 | } 78 | } 79 | 80 | 81 | 82 | #ifdef OLD 83 | /* 84 | * A move string is incoming from the interface (server) 85 | * TODO : code duplicate : make sure we can't send this to qgoboard 86 | */ 87 | void qGoBoardReviewInterface::set_move(StoneColor sc, QString pt, QString mv_nr) 88 | { 89 | 90 | } 91 | 92 | /* 93 | * sends a "pass" move to the server 94 | */ 95 | void qGoBoardReviewInterface::sendPassToInterface(StoneColor /*c*/) 96 | { 97 | /* What really is this doing in the review interface ??? */ 98 | emit signal_sendCommandFromBoard("pass", false); 99 | boardwindow->getBoardDispatch()->sendMove(new MoveRecord(MoveRecord::PASS)); 100 | } 101 | #endif //OLD 102 | 103 | /* 104 | * sends a move to the server 105 | */ 106 | #ifdef OLD 107 | void qGoBoardReviewInterface::sendMoveToInterface(StoneColor c, int x, int y) 108 | { 109 | 110 | if (x > 8) 111 | x++; 112 | 113 | char c1 = x - 1 + 'A'; 114 | //int c2 = gd.size + 1 - y; 115 | int c2 = boardwindow->getBoardSize() + 1 - y; 116 | 117 | // if (ExtendedTeachingGame && IamPupil) 118 | // emit signal_sendcommand("kibitz " + QString::number(id) + " " + QString(c1) + QString::number(c2), false); 119 | QString id = ""; 120 | 121 | // if (gsName == IGS) 122 | id = game_Id; 123 | /* Where and why would we get the number here, is 0 okay for now ??? FIXME */ 124 | 125 | boardwindow->getBoardDispatch()->sendMove(new MoveRecord(0, x, y, c)); 126 | 127 | emit signal_sendCommandFromBoard(QString(c1) + QString::number(c2) + " " + id, false); 128 | 129 | 130 | 131 | } 132 | #endif //OLD 133 | 134 | /* 135 | * 'undo' button pressed 136 | */ 137 | void qGoBoardReviewInterface::slotUndoPressed() 138 | { 139 | 140 | } 141 | -------------------------------------------------------------------------------- /src/game_interfaces/qgoboardlocalinterface.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009-2014 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | #ifndef QGOBOARDLOCALINTERFACE_H 23 | #define QGOBOARDLOCALINTERFACE_H 24 | 25 | #include "defines.h" 26 | #include "qgoboard.h" 27 | 28 | class BoardWindow; 29 | class Tree; 30 | class GameData; 31 | class Move; 32 | class QGtp; 33 | class Sound; 34 | 35 | class qGoBoardLocalInterface : public qGoBoard 36 | { 37 | Q_OBJECT 38 | public: 39 | qGoBoardLocalInterface(BoardWindow *boardWindow, Tree * tree, GameData *gameData); 40 | ~qGoBoardLocalInterface(); 41 | 42 | void checkComputersTurn(bool force = false); 43 | void feedPositionThroughGtp(); 44 | 45 | virtual void localMoveRequest(StoneColor c, int x, int y); 46 | void slot_playComputer(int x, int y); 47 | void slot_resignComputer(); 48 | void slot_passComputer(); 49 | virtual void slotDonePressed(); 50 | virtual void slotUndoPressed(); 51 | void slotToggleInsertStones(bool val); 52 | virtual void passRequest(); 53 | 54 | private: 55 | virtual void sendMoveToInterface(StoneColor c,int x, int y); 56 | 57 | void startGame() {} 58 | // void enterScoreMode() {} 59 | void leaveScoreMode() {} 60 | 61 | QGtp *gtp; 62 | Move *currentEngine; 63 | bool insertStoneFlag; 64 | }; 65 | 66 | #endif // QGOBOARDLOCALINTERFACE_H 67 | -------------------------------------------------------------------------------- /src/game_interfaces/resultdialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | #include "../network/messages.h" 25 | #include "resultdialog.h" 26 | #include "../network/boarddispatch.h" 27 | 28 | ResultDialog::ResultDialog(QWidget * parent, BoardDispatch * dis, unsigned int game_id, GameResult * gr) : QDialog(parent), dispatch(dis) 29 | { 30 | if(!dispatch) 31 | { 32 | qDebug("ResultDialog called without board dispatch"); 33 | deleteLater(); 34 | return; 35 | } 36 | if(!gr) 37 | { 38 | // This was created by the board dispatch in response 39 | // to a rematch request 40 | 41 | mainlabel = new QLabel(dispatch->getOpponentName() + tr(" requests rematch")); 42 | seconds = 20; 43 | okayButton = new QPushButton(tr("&Accept?")); 44 | accepting = true; 45 | } 46 | else 47 | { 48 | accepting = false; 49 | if(dispatch->supportsRematch()) 50 | { 51 | seconds = 20; 52 | /* We make them stare at message for 20 seconds */ 53 | okayButton = new QPushButton(tr("&Rematch?")); 54 | dispatch->setRematchDialog(this); 55 | } 56 | else 57 | { 58 | seconds = 0; 59 | okayButton = new QPushButton(tr("&Okay")); 60 | okayButton->setDefault(true); 61 | } 62 | mainlabel = new QLabel(gr->longMessage()); 63 | } 64 | connect(okayButton, &QPushButton::clicked, this, &ResultDialog::slot_okay); 65 | 66 | QGridLayout * mainLayout = new QGridLayout; 67 | /*mainLayout->setSizeConstraint(QLayout::SetFixedSize);*/ 68 | mainLayout->addWidget(mainlabel, 0, 0); 69 | mainLayout->addWidget(okayButton, 1, 0); 70 | setLayout(mainLayout); 71 | 72 | 73 | setWindowTitle(tr("Game ") + QString::number(game_id)); 74 | //setSizePolicy(QSizePolicy::Minimum); 75 | // FIXME size? 76 | resize(200, 100); 77 | //setMinimumSize(QSize(300, 150)); 78 | if(dispatch->supportsRematch()) 79 | startTimer(1000); 80 | } 81 | 82 | void ResultDialog::recvRematchRequest(void) 83 | { 84 | mainlabel->setText(dispatch->getOpponentName() + tr(" requests rematch")); 85 | seconds = 20; 86 | okayButton->setText(tr("&Accept?")); 87 | accepting = true; 88 | } 89 | 90 | void ResultDialog::timerEvent(QTimerEvent*) 91 | { 92 | // in case we need this? 93 | if(seconds == 1) 94 | { 95 | //what about sending a declineRematch?? if(accepting)?? 96 | hide(); 97 | deleteLater(); 98 | } 99 | else 100 | seconds--; 101 | } 102 | 103 | void ResultDialog::closeEvent(QCloseEvent *) 104 | { 105 | /*if(dispatch) 106 | dispatch->setRematchDialog(0);*/ 107 | } 108 | 109 | ResultDialog::~ResultDialog() 110 | { 111 | if(dispatch) //here also in case no "closeEvent" 112 | dispatch->setRematchDialog(0); 113 | qDebug("deleting result dialog"); 114 | delete okayButton; 115 | delete mainlabel; 116 | } 117 | 118 | /* I'm assuming here that a close by time returns 0 */ 119 | void ResultDialog::slot_okay(void) 120 | { 121 | if(dispatch->supportsRematch()) 122 | { 123 | if(accepting) 124 | dispatch->sendRematchAccept(); 125 | else 126 | dispatch->sendRematchRequest(); 127 | dispatch->setRematchDialog(0); 128 | qDebug("rematch slot okay"); 129 | dispatch = 0; 130 | } 131 | hide(); 132 | deleteLater(); 133 | // or should this be just done() 134 | } 135 | -------------------------------------------------------------------------------- /src/game_interfaces/resultdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | 25 | class QLabel; 26 | class GameResult; 27 | class BoardDispatch; 28 | 29 | class ResultDialog : public QDialog 30 | { 31 | Q_OBJECT 32 | public: 33 | ResultDialog(QWidget * parent, BoardDispatch * dis, unsigned int game_id, GameResult * gr); 34 | ~ResultDialog(); 35 | void recvRematchRequest(void); 36 | virtual void timerEvent(QTimerEvent*); 37 | //virtual QSize minimumSize(void) const { return QSize(300, 150); }; 38 | void slot_okay(void); 39 | private: 40 | void closeEvent(QCloseEvent *); 41 | 42 | QLabel * mainlabel; 43 | QPushButton * okayButton; 44 | BoardDispatch * dispatch; 45 | int seconds; 46 | bool accepting; 47 | }; 48 | -------------------------------------------------------------------------------- /src/game_interfaces/undoprompt.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | #include "undoprompt.h" 25 | 26 | UndoPrompt::UndoPrompt(const QString * _name, bool multiple, int _moves) : name(_name), moves(_moves) 27 | { 28 | movesSpin = 0; 29 | 30 | if(name) 31 | { 32 | if(!multiple) 33 | mainlabel = new QLabel(tr("%1 wants to undo the last move").arg(*name)); 34 | else 35 | mainlabel = new QLabel(tr("%1 wants to undo to move %2").arg(*name).arg(moves)); 36 | } 37 | else 38 | { 39 | if(!multiple) 40 | mainlabel = new QLabel(tr("Undo the last move?").arg(*name)); 41 | else 42 | { 43 | mainlabel = new QLabel(tr("Undo to what move?")); 44 | movesSpin = new QSpinBox(); 45 | movesSpin->setValue(moves); // really shouldn't this be moves -1? 46 | movesSpin->setRange(0, moves); 47 | } 48 | } 49 | 50 | if(!movesSpin) 51 | { 52 | acceptButton = new QPushButton(tr("&Accept")); 53 | acceptButton->setDefault(true); 54 | 55 | declineButton = new QPushButton(tr("&Decline")); 56 | } 57 | else 58 | { 59 | acceptButton = new QPushButton(tr("&Request")); 60 | acceptButton->setDefault(true); 61 | 62 | declineButton = new QPushButton(tr("&Cancel")); 63 | } 64 | buttonBox = new QDialogButtonBox(Qt::Horizontal); 65 | buttonBox->addButton(acceptButton, QDialogButtonBox::ActionRole); 66 | buttonBox->addButton(declineButton, QDialogButtonBox::ActionRole); 67 | 68 | connect(acceptButton, &QPushButton::clicked, this, &UndoPrompt::slot_accept); 69 | connect(declineButton, &QPushButton::clicked, this, &UndoPrompt::slot_decline); 70 | 71 | QGridLayout * mainLayout = new QGridLayout; 72 | mainLayout->setSizeConstraint(QLayout::SetFixedSize); 73 | mainLayout->addWidget(mainlabel, 0, 0); 74 | if(movesSpin) 75 | mainLayout->addWidget(movesSpin, 1, 0); 76 | mainLayout->addWidget(buttonBox, (movesSpin ? 2 : 1), 0); 77 | setLayout(mainLayout); 78 | 79 | if(name) 80 | setWindowTitle(tr("Undo requested")); 81 | else 82 | setWindowTitle(tr("Request undo?")); 83 | 84 | 85 | // we might want to set modality here 86 | //startTimer(1000); 87 | } 88 | 89 | void UndoPrompt::timerEvent(QTimerEvent*) 90 | { 91 | // in case we need this? 92 | } 93 | 94 | UndoPrompt::~UndoPrompt() 95 | { 96 | delete acceptButton; 97 | delete declineButton; 98 | delete mainlabel; 99 | delete movesSpin; 100 | delete buttonBox; 101 | } 102 | 103 | /* I'm assuming here that a close by time returns 0 */ 104 | void UndoPrompt::slot_accept(void) 105 | { 106 | if(!movesSpin) 107 | done(moves); 108 | else 109 | done(movesSpin->value()); 110 | } 111 | 112 | void UndoPrompt::slot_decline(void) 113 | { 114 | done(-1); 115 | } 116 | -------------------------------------------------------------------------------- /src/game_interfaces/undoprompt.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | 25 | class QLabel; 26 | class QSpinBox; 27 | class QDialogButtonBox; 28 | 29 | class UndoPrompt : public QDialog 30 | { 31 | Q_OBJECT 32 | public: 33 | UndoPrompt(const QString * _name, bool multiple, int _moves); 34 | ~UndoPrompt(); 35 | virtual void timerEvent(QTimerEvent*); 36 | void slot_accept(void); 37 | void slot_decline(void); 38 | private: 39 | QLabel * mainlabel; 40 | QSpinBox * movesSpin; 41 | QPushButton * acceptButton; 42 | QPushButton * declineButton; 43 | QDialogButtonBox * buttonBox; 44 | const QString * name; 45 | int moves; 46 | }; 47 | -------------------------------------------------------------------------------- /src/game_tree/group.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include "group.h" 24 | 25 | void Group::remove(int key) 26 | { 27 | int i = indexOf(key); 28 | if (i != -1) 29 | removeAt(i); 30 | } 31 | -------------------------------------------------------------------------------- /src/game_tree/group.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef GROUP_H 24 | #define GROUP_H 25 | 26 | #include 27 | #include "defines.h" 28 | 29 | class Group : public QList 30 | { 31 | public: 32 | Group(StoneColor _c) : QList(), c(_c), liberties(0) {} 33 | ~Group() {} 34 | const StoneColor c; 35 | 36 | void remove(int key); 37 | int liberties; 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/game_tree/matrix.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef MATRIX_H 24 | #define MATRIX_H 25 | 26 | #include "defines.h" 27 | 28 | /* 29 | * Marks used in editing a game 30 | */ 31 | #define MARK_TERRITORY_VISITED 0x1000 32 | 33 | //first nibble is for stone color/erase 34 | #define MX_STONEDEAD 0x8000 35 | #define MX_STONEEDIT 0x4000 36 | 37 | #define MX_VISITED 0x2000 38 | 39 | class Group; 40 | 41 | struct ASCII_Import 42 | { 43 | char blackStone, whiteStone, starPoint, emptyPoint, hBorder, vBorder; 44 | }; 45 | 46 | class Matrix 47 | { 48 | public: 49 | Matrix(int s=DEFAULT_BOARD_SIZE); 50 | Matrix(const Matrix &m, bool cleanup = false); 51 | ~Matrix(); 52 | int getSize() const { return size; } 53 | void insertStone(int x, int y, StoneColor c, bool fEdit = false); 54 | StoneColor getStoneAt(int x, int y); 55 | bool isStoneDead(int x, int y); 56 | MarkType getMarkAt(int x, int y); 57 | QString getFirstTextAvailable(MarkType t); 58 | 59 | void insertMark(int x, int y, MarkType t); 60 | void removeMark(int x, int y); 61 | void setMarkText(int x, int y, const QString &txt); 62 | const QString getMarkText(int x, int y); 63 | void clearAllMarks(); 64 | void clearTerritoryMarks(); 65 | void absMatrix(); 66 | const QString saveMarks(); 67 | const QString saveEditedMoves(Matrix *parent=0); 68 | const QString printMe(ASCII_Import *charset); 69 | 70 | int checkStoneCaptures(StoneColor ourColor, int x, int y, std::vector &visited) const; 71 | void removeGroup(Group * g); 72 | 73 | void toggleGroupAt( int x, int y ); 74 | void toggleStoneAt(int x, int y); 75 | void markStoneDead(int x, int y); 76 | void markGroupDead(int x, int y); 77 | void markGroupAlive(int x, int y); 78 | void toggleAreaAt( int x, int y ); 79 | void markAreaDead(int x, int y); 80 | void markAreaAlive(int x, int y); 81 | void markTerritory(); 82 | void count(int & terrBlack, int & terrWhite, int & deadBlack, int & deadWhite); 83 | 84 | static const QString coordsToString(int x, int y) 85 | { return QString(QChar(static_cast('a' + x))).append(QChar(static_cast('a' + y))); } 86 | 87 | int makeMove(int x, int y, StoneColor c); 88 | bool addHandicapStones(int handicap); 89 | 90 | private: 91 | int internalCoordsToKey(int i, int j) const { return i*size + j; } 92 | int coordsToKey(int x, int y) const { return internalCoordsToKey(x-1,y-1); } 93 | void keyToCoords(int key, int &x, int &y) const 94 | { x = key / size; y = key - (x++)*size + 1; } 95 | 96 | StoneColor getStoneAt(int key) const; 97 | MarkType getMarkAt(int key) const; 98 | void insertStone(int key, StoneColor c, bool fEdit = false); 99 | Group* assembleGroup(int key, StoneColor c) const; 100 | void toggleStoneAt(int key); 101 | 102 | void checkNeighbour(int key, StoneColor color, Group *group, std::vector * libertyList = NULL) const; 103 | int countLiberties(Group *group, unsigned short mask = stoneBlack|stoneWhite); 104 | Group* assembleAreaGroups(int key, StoneColor c); 105 | // This function returns a list of keys of points adjacent to the point "key". 106 | std::vector getNeighbors(int key) const; 107 | void floodTerritory(unsigned short mark, int key); 108 | 109 | unsigned short * matrix; 110 | const int size; 111 | QHash markTexts; 112 | }; 113 | 114 | #endif 115 | -------------------------------------------------------------------------------- /src/game_tree/tree.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef TREE_H 24 | #define TREE_H 25 | 26 | #include "defines.h" 27 | 28 | #include 29 | 30 | class Move; 31 | class Group; 32 | class Matrix; 33 | class GameResult; 34 | class GameData; 35 | 36 | class Tree : public QObject 37 | { 38 | Q_OBJECT 39 | public: 40 | Tree(int board_size, float komi); 41 | ~Tree(); 42 | void init(); 43 | Move* getCurrent() const { return current; } 44 | void setCurrent(Move *m); 45 | Move* getRoot() const { return root; } 46 | Move * findMoveInMainBranch(int x, int y) { return findMove(root, x, y, false); } 47 | Move * findMoveInCurrentBranch(int x, int y) { return findMove(root, x, y, true); } 48 | Move * findLastMoveInMainBranch(); 49 | Move * findLastMoveInCurrentBranch(); 50 | Move * findNode(Move *m, int node); 51 | /* 52 | * Former Boardhandler functions called by SGF parser 53 | */ 54 | 55 | void addEmptyMove(); 56 | void doPass(bool sgf, bool fastLoad = false); 57 | 58 | void deleteNode(); 59 | 60 | /* 61 | * Former Stonehandler functions called by addStoneSGF 62 | * Those functions are used when adding a stone, and check all Go issues : libertes, death, ... 63 | */ 64 | void setLoadingSGF(bool b) { loadingSGF = b; } 65 | 66 | void findMoveByPos(int x,int y); 67 | 68 | // Do these functiones belong here? FIXME 69 | void countScore(); 70 | void countMarked(Move * mv); 71 | class GameResult retrieveScore(void); 72 | void exitScore(); 73 | 74 | // Import SGF (from file or string) 75 | // FIXME: read handicap from SGF 76 | bool importSGFFile(QString filename); 77 | bool importSGFString(QString SGF); 78 | QString exportSGFString(GameData * gameData); 79 | 80 | void slotNavBackward(); 81 | void slotNavForward(); 82 | void slotNavFirst(); 83 | void slotNavLast(); 84 | void slotNavPrevComment(); 85 | void slotNavNextComment(); 86 | void slotNavPrevVar(); 87 | void slotNavNextVar(); 88 | void slotNavStartVar(); 89 | void slotNavMainBranch(); 90 | void slotNavNextBranch(); 91 | void slotNthMove(int n); 92 | 93 | signals: 94 | void currentMoveChanged(Move*); 95 | void scoreChanged(int,int,int,int,int,int); 96 | 97 | protected: 98 | Move* findMove(Move *start, int x, int y, bool checkmarker); 99 | 100 | public: 101 | Move *lastMoveInMainBranch; 102 | 103 | private: 104 | const int boardSize; 105 | 106 | Move *root, *current; 107 | 108 | bool loadingSGF; 109 | int deadWhite, deadBlack; 110 | int terrWhite, terrBlack; 111 | int capturesBlack, capturesWhite; 112 | float komi; 113 | }; 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /src/host.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009- by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | #include "host.h" 22 | -------------------------------------------------------------------------------- /src/host.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009- by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | #ifndef HOST_H 22 | #define HOST_H 23 | 24 | #include 25 | 26 | class Host 27 | { 28 | public: 29 | Host(const QString&, const QString&, const QString&); 30 | ~Host() {}; 31 | QString host() const { return h; }; 32 | QString loginName() const { return lg; }; 33 | QString password() const { return pw; }; 34 | int operator== (Host h) 35 | { return (this->host() == h.host() && this->loginName() == h.loginName()); }; 36 | int operator== (Host *h) 37 | { return (this->host() == h->host() && this->loginName() == h->loginName()); }; 38 | 39 | private: 40 | QString h; 41 | QString lg; 42 | QString pw; 43 | }; 44 | 45 | #endif // HOST_H 46 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | 25 | #include "mainwindow.h" 26 | #include "defines.h" 27 | 28 | 29 | struct _preferences preferences; 30 | MainWindow * mainwindow = 0; 31 | ConnectionWidget * connectionWidget = 0; 32 | 33 | void startqGo(void) 34 | { 35 | QSettings settings; 36 | bool restarting = false; 37 | 38 | if(mainwindow) 39 | { 40 | restarting = true; 41 | mainwindow->deleteLater(); 42 | } 43 | mainwindow = new MainWindow(0,0); 44 | if(restarting) 45 | mainwindow->show(); 46 | 47 | QVariant main_window_size_x = settings.value("MAIN_WINDOW_SIZE_X"); 48 | if(main_window_size_x != QVariant()) 49 | { 50 | mainwindow->resize(main_window_size_x.toInt(), settings.value("MAIN_WINDOW_SIZE_Y").toInt()); 51 | mainwindow->move(settings.value("MAIN_WINDOW_POS_X").toInt(), settings.value("MAIN_WINDOW_POS_Y").toInt()); 52 | } 53 | } 54 | 55 | int main(int argc, char *argv[]) 56 | { 57 | Q_INIT_RESOURCE(application); 58 | QApplication * app = new QApplication(argc, argv); 59 | 60 | QTranslator qtTranslator; 61 | if (qtTranslator.load(QLocale(), "qt", "_", 62 | QLibraryInfo::location(QLibraryInfo::TranslationsPath))) 63 | app->installTranslator(&qtTranslator); 64 | else 65 | qDebug() << "qgo translation file for locale " << QLocale() << " not found in " << QLibraryInfo::location(QLibraryInfo::TranslationsPath)+"/translations"; 66 | 67 | QTranslator qgoTranslator; 68 | if (qgoTranslator.load(QLocale(), "qgo", "_", 69 | QCoreApplication::applicationDirPath()+"/translations")) 70 | app->installTranslator(&qgoTranslator); 71 | else 72 | qDebug() << "qgo translation file for locale " << QLocale() << " not found in " << QCoreApplication::applicationDirPath()+"/translations"; 73 | 74 | app->setOrganizationName("qGo"); 75 | app->setApplicationName("qGo"); 76 | 77 | QCommandLineParser parser; 78 | parser.process(*app); 79 | const QStringList args = parser.positionalArguments(); 80 | 81 | startqGo(); 82 | mainwindow->show(); 83 | 84 | QStringList::const_iterator filename; 85 | for ( filename = args.begin(); filename != args.end(); ++filename ) 86 | { 87 | mainwindow->openSGF(*filename); 88 | } 89 | 90 | srand(time(NULL)); 91 | 92 | return app->exec(); 93 | } 94 | -------------------------------------------------------------------------------- /src/mainwindow.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef MAINWINDOW_H 24 | #define MAINWINDOW_H 25 | 26 | #include "defines.h" 27 | 28 | #include 29 | 30 | class RoomListing; 31 | class LoginDialog; 32 | class NetworkConnection; 33 | class GameDialog; 34 | class BoardWindow; 35 | class GameData; 36 | class Sound; 37 | namespace Ui { 38 | class MainWindow; 39 | } 40 | 41 | class MainWindow : public QMainWindow 42 | { 43 | Q_OBJECT 44 | 45 | public: 46 | MainWindow( QWidget *parent = 0 , Qt::WindowFlags flags = 0 ); 47 | ~MainWindow(); 48 | 49 | void addBoardWindow(BoardWindow *); 50 | int checkForOpenBoards(void); 51 | 52 | void removeBoardWindow(QObject *); 53 | 54 | void slot_fileNew(); 55 | void slot_fileOpen(); 56 | void openPreferences(); 57 | void openSGF(QString path); 58 | 59 | void openConnectDialog(void); 60 | 61 | protected: 62 | void closeEvent(QCloseEvent *e); 63 | 64 | private: 65 | Ui::MainWindow * ui; 66 | Sound *connectSound, *gameSound; 67 | 68 | QList boardWindowList; 69 | 70 | LoginDialog * logindialog; 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /src/network/codecwarndialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | #include "codecwarndialog.h" 25 | #include "../defines.h" 26 | 27 | CodecWarnDialog::CodecWarnDialog(const char * encoding) 28 | { 29 | if(!preferences.warn_about_codecs) 30 | { 31 | deleteLater(); 32 | done(0); 33 | } 34 | /* FIXME okayButton should be on lower right and window should be slightly 35 | * larger, more warning like, maybe with padding around text, some kind of 36 | * layout. */ 37 | okayButton = new QPushButton(tr("Okay")); 38 | okayButton->setMaximumWidth(80); 39 | okayButton->setDefault(true); 40 | 41 | dontwarnCB = new QCheckBox(tr("Don't warn me again")); 42 | 43 | textLabel = new QLabel(tr("Can't find font codec \"%1\"\nUsing default").arg(encoding)); 44 | 45 | connect(okayButton, &QPushButton::clicked, this, &CodecWarnDialog::slot_okay); 46 | 47 | QGridLayout * mainLayout = new QGridLayout; 48 | //mainLayout->setSizeConstraint(QLayout::SetFixedSize); 49 | mainLayout->addWidget(textLabel, 0, 0); 50 | mainLayout->addWidget(dontwarnCB, 1, 0); 51 | mainLayout->addWidget(okayButton, 2, 0); 52 | setLayout(mainLayout); 53 | 54 | setWindowTitle(tr("Missing Codec!")); 55 | show(); 56 | } 57 | 58 | CodecWarnDialog::~CodecWarnDialog() 59 | { 60 | if(dontwarnCB->isChecked()) 61 | preferences.warn_about_codecs = 0; 62 | delete okayButton; 63 | delete dontwarnCB; 64 | } 65 | 66 | void CodecWarnDialog::slot_okay(void) 67 | { 68 | /* Why does this need to be here as well as above? FIXME, 69 | * why doesn't it suffice solely in deconstructor */ 70 | if(dontwarnCB->isChecked()) 71 | preferences.warn_about_codecs = 0; 72 | deleteLater(); 73 | done(0); 74 | } 75 | -------------------------------------------------------------------------------- /src/network/codecwarndialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | 25 | class QLabel; 26 | class QCheckBox; 27 | 28 | class CodecWarnDialog : public QDialog 29 | { 30 | Q_OBJECT 31 | public: 32 | CodecWarnDialog(const char * encoding); 33 | ~CodecWarnDialog(); 34 | private: 35 | void slot_okay(); 36 | 37 | QLabel * textLabel; 38 | QPushButton * okayButton; 39 | QCheckBox * dontwarnCB; 40 | }; 41 | -------------------------------------------------------------------------------- /src/network/consoledispatch.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include "consoledispatch.h" 24 | #include "../mainwindow.h" 25 | #include "networkconnection.h" 26 | #include "connectionwidget.h" 27 | /* Probably want to just remove this file FIXME*/ 28 | 29 | /* All consoles need somewhere to write to... so... MainWindow */ 30 | ConsoleDispatch::ConsoleDispatch(NetworkConnection * conn) 31 | { 32 | connection = conn; 33 | } 34 | 35 | ConsoleDispatch::~ConsoleDispatch() 36 | { 37 | connection->setConsoleDispatch(0); 38 | } 39 | 40 | void ConsoleDispatch::recvText(const char * text) 41 | { 42 | connectionWidget->slot_message(text); 43 | } 44 | 45 | void ConsoleDispatch::recvText(QString text) 46 | { 47 | connectionWidget->slot_message(text); 48 | } 49 | 50 | /* This is going to be a problem. The \r\n is for IGS, but if 51 | * want to use it as chat... FIXME */ 52 | void ConsoleDispatch::sendText(const char * text) 53 | { 54 | if(connection) 55 | connection->sendText(QString(text) + "\r\n"); 56 | else 57 | qDebug("No connection set for console!\n"); 58 | } 59 | -------------------------------------------------------------------------------- /src/network/consoledispatch.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef CONSOLEDISPATCH_H 24 | #define CONSOLEDISPATCH_H 25 | 26 | class QString; 27 | class NetworkConnection; 28 | 29 | class ConsoleDispatch 30 | { 31 | public: 32 | ConsoleDispatch(NetworkConnection * conn); 33 | ~ConsoleDispatch(); 34 | void recvText(const char * text); 35 | void recvText(QString text); 36 | void sendText(const char * text); 37 | private: 38 | NetworkConnection * connection; 39 | }; 40 | #endif //CONSOLEDISPATCH_H 41 | -------------------------------------------------------------------------------- /src/network/createroomdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | #include "ui_createroomdialog.h" 25 | 26 | class QLabel; 27 | class QDialogButtonBox; 28 | class NetworkConnection; 29 | 30 | class CreateRoomDialog : public QDialog, public Ui::CreateRoomDialog 31 | { 32 | Q_OBJECT 33 | public: 34 | CreateRoomDialog(NetworkConnection * conn); 35 | ~CreateRoomDialog(); 36 | void slot_create(void); 37 | void slot_cancel(void); 38 | 39 | void slot_privateCB(bool); 40 | 41 | void slot_roomTypeTab(void); 42 | void slot_opponentStrongerRB(void); 43 | void slot_opponentEvenRB(void); 44 | void slot_opponentWeakerRB(void); 45 | void slot_opponentAnyRB(void); 46 | 47 | void slot_timeQuickRB(void); 48 | void slot_timeNormalRB(void); 49 | void slot_timePonderousRB(void); 50 | void slot_timeAnyRB(void); 51 | void slot_oneOnOneRB(void); 52 | void slot_pairRB(void); 53 | void slot_teachingRB(void); 54 | void slot_liveRB(void); 55 | private: 56 | NetworkConnection * connection; 57 | //Ui::CreateRoomDialog ui; 58 | }; 59 | 60 | class RoomCreate 61 | { 62 | public: 63 | unsigned char * title; 64 | unsigned char * password; 65 | enum roomType { GAME = 0, GOMOKU, CHAT, REVIEW, MULTI, VARIATION } type; 66 | enum OpponentStrength { STRONGER = 0, EVEN, WEAKER, ANYBODY } opponentStrength; 67 | enum TimeLimit { QUICK = 0, NORMAL, PONDEROUS, ANYTIME } timeLimit; 68 | enum Topic { BADUK = 0, MOVIES, MUSIC, SPORTS, GAMES, MANGA, HUMOR, CURRENTAFFAIRS, 69 | LITERATURE, HOBBIES, TRAVEL, CLIMBING, ENTERTAINMENT, COMPUTING, INTERNET, MISC } topic; 70 | enum Age { ALL=0, _9, _10_19, _20_29, _30_39, _40_49, _50_59, _60_69, _70 } age; 71 | enum Location { KOREA = 0, CHINA, JAPAN, THAI, US, EUROPE, AUSTRALIA, FOREIGN, OTHER } location; 72 | }; 73 | -------------------------------------------------------------------------------- /src/network/cyberoroprotocol.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #define ORO_CODETABLE 0x00fa 24 | #define ORO_ROOMLIST 0xc661 25 | #define ORO_PLAYERLIST 0xd061 26 | #define ORO_GAMELIST 0xda61 27 | #define ORO_BROADCASTLIST 0xf861 28 | 29 | #define ORO_PLAYERROOMJOIN 0x0e56 30 | #define ORO_CREATEROOM 0xca5d 31 | 32 | #define ORO_MOVE 0xdcaf 33 | #define ORO_BROADCASTMOVE 0x42f4 34 | #define ORO_UNDO 0xe6af 35 | #define ORO_DECLINEUNDO 0xf0af 36 | #define ORO_ACCEPTUNDO 0xebaf 37 | #define ORO_MOVELIST 0xd7af 38 | #define ORO_BROADCASTMOVELIST 0x4cf4 39 | 40 | #define ORO_ENTERSCORING 0xc9b3 41 | #define ORO_REMOVESTONES 0xe2b3 42 | #define ORO_STONESDONE 0xf1b3 43 | #define ORO_RESIGN 0xb0b3 44 | #define ORO_TIMELOSS 0xf6b3 45 | #define ORO_ADJOURNREQUEST 0xb5b3 46 | #define ORO_ADJOURNDECLINE 0xbfb3 47 | #define ORO_ADJOURN 0xbab3 48 | 49 | #define ORO_SETPHRASECHAT 0x55c3 50 | #define ORO_LOBBYCHAT 0x0a5a 51 | #define ORO_ROOMCHAT 0xec59 52 | #define ORO_PERSONALCHAT 0xe259 53 | #define ORO_SERVERANNOUNCE 0xf659 54 | #define ORO_SERVERANNOUNCELINK 0x645a 55 | 56 | #define ORO_MATCHOFFER 0xc8af 57 | 58 | /* We need a subclass of a packet structure 59 | * with a send method that does necessary 60 | * encoding and a different subclass for 61 | * each message type so we can just fill 62 | * it out and make the code clean. 63 | * doublecheck sizeof() stuff */ 64 | -------------------------------------------------------------------------------- /src/network/eweiqiconnection.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include "tygemconnection.h" 24 | 25 | class EWeiQiConnection : public TygemConnection 26 | { 27 | public: 28 | EWeiQiConnection(const ConnectionCredentials credentials); 29 | //~EWeiQiConnection(); 30 | virtual const char * getCodecString(void); 31 | virtual QString getPlaceString(void); 32 | private: 33 | virtual int requestServerInfo(void); 34 | virtual QByteArray getTygemGameRecordQByteArray(class GameData *); 35 | }; 36 | -------------------------------------------------------------------------------- /src/network/friendslistdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef FRIENDSLISTDIALOG_H 24 | #define FRIENDSLISTDIALOG_H 25 | 26 | #include "ui_friendslistdialog.h" 27 | #include 28 | 29 | class NetworkConnection; 30 | class Room; 31 | 32 | class FriendsListDialog : public QDialog, Ui::FriendsListDialog 33 | { 34 | Q_OBJECT 35 | public: 36 | FriendsListDialog(NetworkConnection * c, Room * r); 37 | ~FriendsListDialog(); 38 | private: 39 | void populateLists(void); 40 | Ui::FriendsListDialog ui; 41 | NetworkConnection * connection; 42 | Room * room; 43 | 44 | QModelIndex popup_item; 45 | class PlayerListing * popup_playerlisting; 46 | class SimplePlayerListModel * friendsListModel; 47 | class SimplePlayerListModel * watchesListModel; 48 | class SimplePlayerListModel * blockedListModel; 49 | 50 | void slot_showPopupFriends(const QPoint & iPoint); 51 | void slot_showPopupWatches(const QPoint & iPoint); 52 | void slot_showPopupBlocked(const QPoint & iPoint); 53 | void slot_addFriend(void); 54 | void slot_removeFriend(void); 55 | void slot_addWatch(void); 56 | void slot_removeWatch(void); 57 | void slot_addBlock(void); 58 | void slot_removeBlock(void); 59 | void slot_playersDoubleClickedFriends(const QModelIndex & index); 60 | void slot_playersDoubleClickedWatches(const QModelIndex & index); 61 | void slot_popupMatch(void); 62 | void slot_popupTalk(void); 63 | }; 64 | #endif //FRIENDSLISTDIALOG_H 65 | -------------------------------------------------------------------------------- /src/network/gamedialogflags.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef GAMEDIALOGFLAGS_H 24 | #define GAMEDIALOGFLAGS_H 25 | 26 | #define GDF_CANADIAN 0x00000001 27 | #define GDF_BYOYOMI 0x00000002 28 | #define GDF_TVASIA 0x00000004 29 | #define GDF_STONES25_FIXED 0x00000008 30 | #define GDF_FREE_RATED_CHOICE 0x00000010 31 | #define GDF_RATED_SIZE_FIXED 0x00000020 32 | #define GDF_RATED_HANDICAP_FIXED 0x00000040 33 | #define GDF_RATED_NO_HANDICAP 0x00000080 34 | #define GDF_NIGIRI_EVEN 0x00000100 // is this even needed? 35 | #define GDF_ONLY_DISPUTE_TIME 0x00000200 36 | #define GDF_BY_CAN_MAIN_MIN 0x00000400 37 | #define GDF_HANDICAP1 0x00000800 38 | #define GDF_CANADIAN300 0x00001000 //canadian time must be over 300 39 | #define GDF_KOMI_FIXED6 0x00002000 //must be 6.5 komi or .5, etc 40 | 41 | #endif //GAMEDIALOGFLAGS_H 42 | -------------------------------------------------------------------------------- /src/network/lgs.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | #include "igsconnection.h" 25 | 26 | class LGSConnection : public IGSConnection 27 | { 28 | public: 29 | LGSConnection(const ConnectionCredentials credentials); 30 | virtual QString getPlaceString(void); 31 | virtual void sendPlayersRequest(void); 32 | virtual void sendToggle(const QString & param, bool val); 33 | virtual void onReady(void); 34 | virtual unsigned long getRoomStructureFlags(void) { return RS_NOROOMLIST; }; 35 | virtual void requestGameInfo(unsigned int game_id); 36 | private: 37 | virtual void handle_info(QString); 38 | }; 39 | -------------------------------------------------------------------------------- /src/network/login.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | #ifndef LOGIN_H 22 | #define LOGIN_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "ui_login.h" 30 | #include "defines.h" 31 | #include "networkconnection.h" 32 | 33 | class NetworkConnection; 34 | class QMessageBox; 35 | 36 | class CredentialTableModel : public QAbstractTableModel 37 | { 38 | Q_OBJECT 39 | public: 40 | CredentialTableModel(QObject * parent = 0); 41 | ~CredentialTableModel(); 42 | int rowCount(const QModelIndex & parent = QModelIndex()) const; 43 | int columnCount(const QModelIndex & parent = QModelIndex()) const; 44 | QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const; 45 | QVariant data(const QModelIndex & index, int role) const; 46 | QVariant headerData(int section, Qt::Orientation orientation, int role) const; 47 | Qt::ItemFlags flags(const QModelIndex & index) const; 48 | bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); 49 | bool removeRows(int row, int count, const QModelIndex &parent); 50 | 51 | void addCredential(ConnectionCredentials cred); 52 | void loadCredentials(void); 53 | void saveCredentials(void); 54 | public: 55 | QList credentials; 56 | bool editable; 57 | }; 58 | 59 | class ComboBoxDelegate : public QStyledItemDelegate 60 | { 61 | Q_OBJECT 62 | public: 63 | ComboBoxDelegate(QObject *parent = 0); 64 | 65 | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, 66 | const QModelIndex &index) const; 67 | 68 | void setEditorData(QWidget *editor, const QModelIndex &index) const; 69 | void setModelData(QWidget *editor, QAbstractItemModel *model, 70 | const QModelIndex &index) const; 71 | 72 | void updateEditorGeometry(QWidget *editor, 73 | const QStyleOptionViewItem &option, const QModelIndex &index) const; 74 | }; 75 | 76 | class NewCredentialsAction : public QAction 77 | { 78 | Q_OBJECT 79 | public: 80 | NewCredentialsAction(const QString &text, ConnectionCredentials c, QObject * parent = 0) : QAction(text,parent), cred(c) {}; 81 | ConnectionCredentials cred; 82 | }; 83 | 84 | class LoginDialog : public QDialog, Ui::LoginDialog 85 | { 86 | Q_OBJECT 87 | public: 88 | LoginDialog(QWidget *parent = 0); 89 | ~LoginDialog(); 90 | private: 91 | void slot_cancel(void); 92 | void slot_connect(QModelIndex); 93 | void slot_newCredential(QAction *action); 94 | void slot_deleteCredential(void); 95 | void slot_receiveConnectionState(ConnectionState newState); 96 | void slot_showPopup(const QPoint & iPoint); 97 | void slot_toggleEditable(void); 98 | 99 | ConnectionType serverStringToConnectionType(const QString & s); 100 | NetworkConnection * newConnection(ConnectionCredentials cred); 101 | Ui::LoginDialog ui; 102 | NetworkConnection * connection; 103 | CredentialTableModel * credModel; 104 | QMenu * newCredMenu; 105 | QModelIndex popup_item; 106 | }; 107 | 108 | #endif 109 | -------------------------------------------------------------------------------- /src/network/login.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | LoginDialog 4 | 5 | 6 | Qt::WindowModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 488 13 | 339 14 | 15 | 16 | 17 | Connect... 18 | 19 | 20 | true 21 | 22 | 23 | 24 | 25 | 26 | QAbstractItemView::SingleSelection 27 | 28 | 29 | QAbstractItemView::SelectRows 30 | 31 | 32 | true 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | Qt::Horizontal 52 | 53 | 54 | 55 | 40 56 | 20 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | Qt::CustomContextMenu 65 | 66 | 67 | &Cancel 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | cancelPB 79 | clicked() 80 | LoginDialog 81 | reject() 82 | 83 | 84 | 436 85 | 314 86 | 87 | 88 | 243 89 | 169 90 | 91 | 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /src/network/matchinvitedialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | #include "matchinvitedialog.h" 25 | 26 | MatchInviteDialog::MatchInviteDialog(QString name, QString rank, bool canRefuseFuture) 27 | { 28 | int horiz_pos = 0; 29 | seconds = 20; //does it? 30 | 31 | /* FIXME, we need to center this text, make the font larger, or 32 | * bold, etc.. */ 33 | namelabel = new QLabel(tr("%1 %2").arg(name).arg(rank)); 34 | dialoglabel = new QLabel(tr("wants to play a match...")); 35 | timelabel = new QLabel(tr("%1 seconds").arg(seconds)); 36 | 37 | acceptButton = new QPushButton(tr("&Accept")); 38 | acceptButton->setDefault(true); 39 | 40 | declineButton = new QPushButton(tr("&Decline")); 41 | if(canRefuseFuture) 42 | refuseFutureCB = new QCheckBox(tr("Refuse Invites from %1").arg(name)); 43 | else 44 | refuseFutureCB = 0; 45 | buttonBox = new QDialogButtonBox(Qt::Horizontal); 46 | buttonBox->addButton(acceptButton, QDialogButtonBox::ActionRole); 47 | buttonBox->addButton(declineButton, QDialogButtonBox::ActionRole); 48 | 49 | connect(acceptButton, &QPushButton::clicked, this, &MatchInviteDialog::slot_accept); 50 | connect(declineButton, &QPushButton::clicked, this, &MatchInviteDialog::slot_decline); 51 | if(refuseFutureCB) 52 | connect(refuseFutureCB, &QCheckBox::clicked, this, &MatchInviteDialog::slot_refuseFutureCB); 53 | 54 | QGridLayout * mainLayout = new QGridLayout; 55 | mainLayout->setSizeConstraint(QLayout::SetFixedSize); 56 | mainLayout->addWidget(namelabel, horiz_pos++, 0); 57 | mainLayout->addWidget(dialoglabel, horiz_pos++, 0); 58 | mainLayout->addWidget(timelabel, horiz_pos++, 0); 59 | if(refuseFutureCB) 60 | mainLayout->addWidget(refuseFutureCB, horiz_pos++, 0); 61 | mainLayout->addWidget(buttonBox, horiz_pos++, 0); 62 | setLayout(mainLayout); 63 | 64 | setWindowTitle(tr("Match Invite!")); 65 | 66 | startTimer(1000); 67 | } 68 | 69 | void MatchInviteDialog::timerEvent(QTimerEvent*) 70 | { 71 | seconds--; 72 | if(seconds == -1) 73 | done(-1); //does this return 0? 74 | timelabel->setText(tr("%1 seconds").arg(seconds)); 75 | } 76 | 77 | MatchInviteDialog::~MatchInviteDialog() 78 | { 79 | delete acceptButton; 80 | delete declineButton; 81 | delete refuseFutureCB; 82 | delete buttonBox; 83 | } 84 | 85 | /* I'm assuming here that a close by time returns 0 */ 86 | void MatchInviteDialog::slot_accept(void) 87 | { 88 | done(1); 89 | } 90 | 91 | void MatchInviteDialog::slot_decline(void) 92 | { 93 | if(refuseFutureCB && refuseFutureCB->isChecked()) 94 | done(-2); 95 | else 96 | done(-1); 97 | } 98 | 99 | void MatchInviteDialog::slot_refuseFutureCB(bool b) 100 | { 101 | if(b) 102 | { 103 | acceptButton->setEnabled(false); 104 | } 105 | else 106 | acceptButton->setEnabled(true); 107 | } 108 | -------------------------------------------------------------------------------- /src/network/matchinvitedialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | 25 | class QLabel; 26 | class QCheckBox; 27 | class QDialogButtonBox; 28 | 29 | class MatchInviteDialog : public QDialog 30 | { 31 | Q_OBJECT 32 | public: 33 | MatchInviteDialog(QString name, QString rank, bool canRefuseFuture = false); 34 | ~MatchInviteDialog(); 35 | virtual void timerEvent(QTimerEvent*); 36 | 37 | void slot_accept(void); 38 | void slot_decline(void); 39 | void slot_refuseFutureCB(bool b); 40 | private: 41 | QLabel * namelabel, * dialoglabel, * timelabel; 42 | QPushButton * acceptButton; 43 | QPushButton * declineButton; 44 | QCheckBox * refuseFutureCB; 45 | QDialogButtonBox * buttonBox; 46 | int seconds; 47 | }; 48 | -------------------------------------------------------------------------------- /src/network/orosetphrasechat.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef OROSETPHRASECHAT_H 24 | #define OROSETPHRASECHAT_H 25 | 26 | #include 27 | #include 28 | 29 | //ea 30 | #define OROSP_HELLO 0xea60 31 | #define OROSP_WELCOME 0xea61 32 | #define OROSP_HELLOEXC 0xea62 33 | #define OROSP_NICETOMEETYOU 0xea63 34 | #define OROSP_GLADTOKNOWYOU 0xea64 35 | 36 | #define OROSP_DOYOUWANTQUICKGAME 0xeac5 37 | #define OROSP_DOYOUWANTGAME 0xeac4 38 | #define OROSP_ILLCREATEMULTROOM 0xeac6 39 | #define OROSP_ENTERFORPAIR 0xeac7 40 | #define OROSP_REQUESTMEFORREGGAME 0xeac8 41 | //eb 42 | #define OROSP_ALRIGHTNOPROBLEM 0xeb28 43 | #define OROSP_YESYOUARERIGHT 0xeb29 44 | #define OROSP_AGREEWITHYOU 0xeb2a 45 | #define OROSP_IAGREE 0xeb2b 46 | #define OROSP_SUITYOURSELF 0xeb2c 47 | 48 | #define OROSP_IMSORRY 0xeb8c 49 | #define OROSP_SORRYIWASCHATTING 0xeb8d 50 | #define OROSP_IJUSTPLAYEDAGAME 0xeb8e 51 | #define OROSP_ITSTIMETOGONOW 0xeb8f 52 | #define OROSP_SHALLWEPLAYNEXTTIME 0xeb90 53 | 54 | #define OROSP_YOUAREDOINGVERYWELL 0xebf0 55 | #define OROSP_THATISANICEMOVE 0xebf1 56 | #define OROSP_YOUAREWELLMANNERED 0xebf2 57 | #define OROSP_THANKYOU 0xebf3 58 | #define OROSP_THANKS 0xebf4 59 | //ec 60 | #define OROSP_NOSWEARINGPLEASE 0xec54 61 | #define OROSP_LETSBEPOLITE 0xec55 62 | #define OROSP_SWEARINGNOTTOLERATED 0xec56 63 | #define OROSP_NOFLOODINGPLEASE 0xec57 64 | #define OROSP_DONTBEESCAPER 0xec58 65 | 66 | #define OROSP_PLEASETEACHMEALOT 0xecb8 67 | #define OROSP_ILLDOMYBEST 0xecb9 68 | #define OROSP_THANKSFOROPPORTUNITY 0xecba 69 | #define OROSP_HOPEGAMEISFANTASTIC 0xecbb 70 | #define OROSP_GAMEHELLO 0xecbc 71 | //ed 72 | #define OROSP_IENJOYEDGAME 0xed1c 73 | #define OROSP_CANYOUPLAYONEMORE 0xed1d 74 | #define OROSP_YOULETMEWIN 0xed1e 75 | #define OROSP_ILEARNEDALOTFROMYOU 0xed1f 76 | #define OROSP_YOUAREPLAYINGVERYWELL 0xed20 77 | 78 | #define OROSP_WHEREDOYOULIVE 0xed80 79 | #define OROSP_HOWOLDAREYOU 0xed81 80 | #define OROSP_HOWAREYOUTODAY 0xed82 81 | #define OROSP_HOWLONGHAVEYOUPLAYED 0xed83 82 | #define OROSP_HAVEYOUEATENSOMETHING 0xed84 83 | 84 | #define OROSP_GOODBYE 0xede4 85 | #define OROSP_SEEYOULATER 0xede5 86 | #define OROSP_SEEYOUNEXTTIME 0xede6 87 | #define OROSP_HAVEAGOODTIME 0xede7 88 | #define OROSP_IMLEAVINGNOW 0xede8 89 | 90 | #define OROSP_HOWDOYOUDO 0x2713 91 | #define OROSP_NICETOMEETEVERYONE 0x2716 92 | #define OROSP_HOWAREYOUEVERYONE 0x2718 93 | #define OROSP_ANYONEFORQUICKGAME 0x2775 94 | #define OROSP_LOOKINGFORFRIENDLY 0x2779 95 | #define OROSP_STRONGPLAYERSHANDICAP 0x277a 96 | #define OROSP_ANYONEWANTSTOPLAYWITHME 0x2774 97 | #define OROSP_DONTMINDANYGAME 0x277c 98 | 99 | //61b0 is directed "Thank you" //FIXME 100 | 101 | extern std::map ORO_setphrase; 102 | 103 | void ORO_setup_setphrases(void); 104 | #endif //OROSETPHRASECHAT_H 105 | -------------------------------------------------------------------------------- /src/network/parser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * parser.h 3 | */ 4 | 5 | #ifndef PARSER_H 6 | #define PARSER_H 7 | 8 | #include "defines.h" 9 | //#include" 10 | 11 | //class Player; 12 | //class Game; 13 | //class GameInfo; 14 | 15 | class Parser : public QObject//, public Misc 16 | { 17 | Q_OBJECT 18 | public: 19 | Parser(); 20 | ~Parser(); 21 | InfoType put_line(const QString&, class NetworkConnection *, GSName); 22 | Player get_player(); 23 | //Player *get_statsPlayer() {return statsPlayer ;} 24 | Game get_game(); 25 | 26 | void set_gsname(const GSName); 27 | GSName get_gsname(); 28 | void set_myName(const QString &n) { myname = n; } 29 | QString get_buffer(); 30 | InfoType cmdsent(const QString&); 31 | 32 | signals: 33 | //new signals 34 | void signal_gameRestored(Game*); 35 | // void signal_matchResult(int,QString&,QString&); 36 | void signal_result(Game*); 37 | void signal_playerConnected(Player*); 38 | void signal_connexionClosed(); 39 | void signal_enterScoreMode(); 40 | void signal_removeStones(const QString&, const QString&); 41 | // void signal_gameFinished(Game*); 42 | // emit if info is found 43 | void signal_player(Player*, bool); 44 | void signal_statsPlayer(Player*); 45 | void signal_game(Game*); 46 | void signal_gameInfo(Game*); 47 | void signal_observedGameClosed(int); 48 | void signal_requestDialog(const QString&, const QString&, const QString&, const QString&); 49 | void signal_undo(const QString&, const QString&, const QString&); 50 | void signal_msgBox(const QString&); 51 | void signal_gameReview(Game*); 52 | void signal_reviewInvite(const QString&, const QString&); 53 | void signal_reviewNode(int, int, StoneColor, int, int); 54 | 55 | // void signal_move(Game*); 56 | void signal_move(GameInfo*); 57 | void signal_message(QString); 58 | void signal_svname(GSName&); 59 | void signal_accname(QString&); 60 | void signal_status(Status); 61 | void signal_talk(const QString&, const QString&, bool); 62 | void signal_checkbox(int, bool); 63 | void signal_channelinfo(int, const QString&); 64 | void signal_kibitz(int, const QString&, const QString&); 65 | void signal_observers(int , const QString&, const QString&); 66 | void signal_clearObservers(int); 67 | void signal_title(const QString&); 68 | void signal_komi(const QString&, const QString&, bool); 69 | void signal_freegame(bool); 70 | void signal_suggest(const QString&, const QString&, const QString&, const QString&, int); 71 | void signal_matchRequest(const QString&, bool); 72 | void signal_matchCanceled(const QString&); 73 | void signal_matchCreate(const QString& , const QString&); 74 | void signal_notOpen(const QString&, int); 75 | void signal_komirequest(const QString&, int, int, bool); 76 | void signal_opponentopen(const QString&); 77 | void signal_score(const QString&, const QString&, bool, const QString&); 78 | void signal_addToObservationList(int); 79 | void signal_shout(const QString&, const QString&); 80 | void signal_timeAdded(int, bool); 81 | void signal_room(const QString&, bool ); 82 | void signal_addSeekCondition(const QString&, const QString&, const QString&, const QString&, const QString&); 83 | void signal_clearSeekCondition(); 84 | void signal_cancelSeek(); 85 | void signal_seekList(const QString&, const QString&); 86 | void signal_refresh(int); 87 | void signal_dispute(const QString&, const QString&); 88 | void signal_set_observe(const QString&); 89 | void signal_restoreScore(); 90 | //void signal_undoRequest(const QString&); 91 | 92 | 93 | 94 | private: 95 | QString myname; 96 | 97 | GSName gsName; 98 | class PlayerListing * aPlayer; 99 | class PlayerListing * statsPlayer; 100 | class GameResult * aGameResult; 101 | class GameRecord * aGameRecord; 102 | class TimeRecord * aTime; 103 | class MoveRecord * aMove; 104 | class MatchRequest * created_match_request; 105 | QString buffer; 106 | int memory; 107 | QString memory_str; 108 | int scoring_game_id; 109 | QString element(const QString &line, int index, const QString &del1, const QString &del2="", bool killblanks = FALSE); 110 | 111 | QList * gameListA; 112 | QList * gameListB; 113 | 114 | 115 | }; 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /src/network/protocol.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef PROTOCOL_H 24 | #define PROTOCOL_H 25 | 26 | class ProtocolPacket 27 | { 28 | public: 29 | ProtocolPacket() {}; 30 | 31 | }; 32 | 33 | /* This is a huge pain in the ass and probably just 34 | * a waste of time. Its like, if I don't want to allocate 35 | * the records and copy the data to them because that's a 36 | * waste, then its like I have to override an accessor 37 | * function. So then I guess its like a RecordShell that 38 | * returns a record offset by the index * sizeof the record. 39 | * and then maybe a type case */ 40 | 41 | class PacketRecord 42 | { 43 | public: 44 | virtual unsigned int size() = 0; 45 | }; 46 | 47 | class RecordShell 48 | { 49 | public: 50 | RecordShell(class PacketRecord & p, void * d) : records(p), data(d) {}; 51 | class PacketRecord & operator[](int i) { return *(PacketRecord *)((char *)data + (i * records.size())); }; 52 | private: 53 | class PacketRecord & records; 54 | void * data; 55 | }; 56 | 57 | class ZeroPaddedString 58 | { 59 | public: 60 | ZeroPaddedString(int s, char * d) : size(s), data(d) {}; 61 | unsigned char operator[] (int index) { }; 62 | void operator=(char *) {}; 63 | private: 64 | unsigned int size; 65 | char * data; 66 | }; 67 | 68 | //test 69 | class OROPlayerListPacket : public ProtocolPacket 70 | { 71 | public: 72 | OROPlayerListPacket(char * p) : data(p), playerRecord(pr, p) { }; 73 | void * data; 74 | unsigned short unknown(void) { return *(unsigned short * )data; }; 75 | unsigned char playerRecords(void) { return (unsigned char )((char *)data)[2]; }; 76 | /* Need to pass it data pointer, but then offset by RecordShell ? 77 | * or RecordShell does all offsets, data */ 78 | class PlayerRecord : public PacketRecord 79 | { 80 | public: 81 | PlayerRecord(void) : name(10) {}; 82 | unsigned int size(void) { return 0x28; }; 83 | ZeroPaddedString name; 84 | unsigned short id(void) { return (unsigned short)*((char *)this + 0x0a); }; 85 | unsigned char specialIdByte(void) { return (unsigned char)*((char *)this + 0xc); }; 86 | unsigned char rankByte(void) { return (unsigned char)*((char *)this + 0xd); }; 87 | unsigned char unknown2; 88 | unsigned char countryCode; 89 | unsigned char inviteByte; 90 | unsigned char unknown3; 91 | unsigned short rankScore; 92 | unsigned short wins; 93 | unsigned short losses; 94 | unsigned short unknown4; 95 | unsigned short unknown5; 96 | } pr; 97 | const class RecordShell playerRecord; 98 | }; 99 | 100 | #endif //PROTOCOL_H 101 | -------------------------------------------------------------------------------- /src/network/quickconnection.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef QUICKCONNECTION_H 24 | #define QUICKCONNECTION_H 25 | #include 26 | #include 27 | 28 | class NetworkConnection; 29 | 30 | class QuickConnection : public QObject 31 | { 32 | Q_OBJECT 33 | public: 34 | enum QuickConnectionType { sendRequestAccountInfo, sendAddFriend, sendRemoveFriend, sendAddBlock, sendRemoveBlock }; 35 | QuickConnection(QString hostname, qint16 port, void * m, NetworkConnection * c, QuickConnectionType t); 36 | QuickConnection(QTcpSocket * q, void * m, NetworkConnection * c, QuickConnectionType t); 37 | int checkSuccess(void); 38 | ~QuickConnection(); 39 | 40 | void OnConnected(void); 41 | void OnReadyRead(void); 42 | void OnError(QAbstractSocket::SocketError err); 43 | 44 | private: 45 | QTcpSocket * qsocket; 46 | int success; 47 | void * msginfo; 48 | NetworkConnection * connection; 49 | QuickConnectionType type; 50 | }; 51 | #endif //QUICKCONNECTION_H 52 | -------------------------------------------------------------------------------- /src/network/room.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef ROOM_H 24 | #define ROOM_H 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | class NetworkConnection; 31 | class BoardDispatch; 32 | class PlayerListing; 33 | class GameListing; 34 | class FilteredView; 35 | class PlayerListModel; 36 | class GamesListModel; 37 | class Talk; 38 | 39 | /* The main purpose of this class is to manage player and game listings. 40 | * Listings must be created and retrieved using get...() methods of this class. 41 | * After modification of a listing, the corresponding recv...() method should be called 42 | * (this can be done asynchronously using Qt's signal/slot mechanism). 43 | * In the current implementation listings are never removed, so other objects may rely 44 | * on pointers to listings remaining valid (until the connection is destroyed). */ 45 | 46 | class Room : public QObject 47 | { 48 | Q_OBJECT 49 | 50 | public: 51 | Room(NetworkConnection * c); 52 | void setConnection(NetworkConnection * c); 53 | virtual ~Room(); 54 | void onError(void); 55 | void recvToggle(int type, bool val); 56 | 57 | // These functions create a listing if it does not exist 58 | PlayerListing * getPlayerListing(const QString & name); 59 | PlayerListing * getPlayerListing(const unsigned int id); 60 | PlayerListing * getPlayerListingByNotNickname(const QString & notnickname); 61 | GameListing * getGameListing(unsigned int key); 62 | 63 | BoardDispatch * getNewBoardDispatch(unsigned int key); 64 | 65 | // This function creates a Talk if it does not exist 66 | Talk * getTalk(PlayerListing *opponent); 67 | // This function returns NULL if no Talk exists 68 | Talk * getIfTalk(const PlayerListing *opponent); 69 | void closeTalk(const PlayerListing *opponent); 70 | 71 | void slot_refreshGames(void); 72 | void slot_refreshPlayers(void); 73 | void recvPlayerListing(PlayerListing *g); 74 | void recvGameListing(GameListing *g); 75 | protected: 76 | unsigned int players; 77 | unsigned int games; 78 | private: 79 | PlayerListModel * playerListModel; 80 | GamesListModel * gamesListModel; 81 | 82 | QTableView * playerView, * gamesView; 83 | NetworkConnection * connection; 84 | QModelIndex popup_item; 85 | 86 | GameListing * popup_gamelisting; 87 | PlayerListing * popup_playerlisting; 88 | 89 | QAction *statsAct, *matchAct, *talkAct, *removeFriendAct, *addFriendAct, *removeWatchAct, *addWatchAct, *blockAct; 90 | QAction *joinObserveAct, *observeOutsideAct; 91 | 92 | QMap talkMap; 93 | 94 | // These functions expect QModelIndex from the proxy models 95 | void slot_playerOpenTalk(const QModelIndex &); 96 | void slot_gamesDoubleClicked(const QModelIndex &); 97 | void slot_showPopup(const QPoint & iPoint); 98 | void slot_showGamesPopup(const QPoint & iPoint); 99 | private: 100 | void openTalk(PlayerListing * listing); 101 | }; 102 | 103 | #endif //ROOM_H 104 | -------------------------------------------------------------------------------- /src/network/serverlistdialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | #include "serverlistdialog.h" 25 | 26 | ServerListDialog::ServerListDialog(std::vector serverlist, int current) 27 | { 28 | current_server = current; 29 | serverListView = constructTreeWidget(serverlist); 30 | 31 | connectButton = new QPushButton(tr("Connect")); 32 | connectButton->setDefault(true); 33 | 34 | cancelButton = new QPushButton(tr("&Cancel")); 35 | cancelButton->setAutoDefault(false); 36 | 37 | buttonBox = new QDialogButtonBox(Qt::Horizontal); 38 | buttonBox->addButton(cancelButton, QDialogButtonBox::ActionRole); 39 | buttonBox->addButton(connectButton, QDialogButtonBox::ActionRole); 40 | 41 | connect(serverListView, &QTreeWidget::itemDoubleClicked, this, &ServerListDialog::slot_listDoubleClicked); 42 | 43 | connect(connectButton, &QPushButton::clicked, this, &ServerListDialog::slot_connect); 44 | connect(cancelButton, &QPushButton::clicked, this, &ServerListDialog::slot_cancel); 45 | 46 | QGridLayout * mainLayout = new QGridLayout; 47 | mainLayout->setSizeConstraint(QLayout::SetFixedSize); 48 | mainLayout->addWidget(serverListView, 0, 0); 49 | mainLayout->addWidget(buttonBox, 1, 0); 50 | setLayout(mainLayout); 51 | 52 | setWindowTitle(tr("Choose server...")); 53 | } 54 | 55 | ServerListDialog::~ServerListDialog() 56 | { 57 | delete serverListView; 58 | delete connectButton; 59 | delete cancelButton; 60 | delete buttonBox; 61 | } 62 | 63 | QTreeWidget * ServerListDialog::constructTreeWidget(std::vector serverlist) 64 | { 65 | QTreeWidget * treeWidget = new QTreeWidget(this); 66 | QTreeWidgetItem * i; 67 | QStringList stringList; 68 | int index = 0; 69 | 70 | treeWidget->setRootIsDecorated(false); 71 | treeWidget->setColumnCount(2); 72 | stringList << "Name" << "IP Address"; 73 | treeWidget->setHeaderLabels(stringList); 74 | stringList.clear(); 75 | 76 | std::vector::iterator it; 77 | for(it = serverlist.begin(); it != serverlist.end(); it++) 78 | { 79 | stringList << (*it)->name << (*it)->ipaddress; 80 | i = new QTreeWidgetItem(treeWidget, stringList); 81 | if(index == current_server) 82 | i->setDisabled(true); 83 | if(it == serverlist.begin()) //ugly but its a short list 84 | treeWidget->setCurrentItem(i); 85 | stringList.clear(); 86 | index++; 87 | } 88 | return treeWidget; 89 | } 90 | 91 | void ServerListDialog::slot_listDoubleClicked(QTreeWidgetItem * i, int) 92 | { 93 | int index = serverListView->indexOfTopLevelItem(i); 94 | if(index < 0 || index == current_server) 95 | return; 96 | done(index + 1); 97 | } 98 | 99 | void ServerListDialog::slot_connect(void) 100 | { 101 | QTreeWidgetItem * i = serverListView->currentItem(); 102 | if(!i) 103 | { 104 | //FIXME error message necessary? 105 | return; 106 | } 107 | int index = serverListView->indexOfTopLevelItem(i); 108 | done(index + 1); 109 | } 110 | 111 | void ServerListDialog::slot_cancel(void) 112 | { 113 | qDebug("Cancel"); 114 | deleteLater(); 115 | done(QDialog::Rejected); 116 | } 117 | -------------------------------------------------------------------------------- /src/network/serverlistdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | #include 25 | 26 | class QTreeWidget; 27 | class QTreeWidgetItem; 28 | class QDialogButtonBox; 29 | 30 | class ServerItem 31 | { 32 | public: 33 | char ipaddress[16]; 34 | QString name; 35 | char * codec; 36 | }; 37 | 38 | class ServerListDialog : public QDialog 39 | { 40 | Q_OBJECT 41 | public: 42 | ServerListDialog(std::vector serverlist, int current = -1); 43 | ~ServerListDialog(); 44 | 45 | void slot_listDoubleClicked(QTreeWidgetItem *, int); 46 | void slot_connect(); 47 | void slot_cancel(); 48 | private: 49 | QTreeWidget * constructTreeWidget(std::vector serverlist); 50 | 51 | int current_server; 52 | QTreeWidget * serverListView; 53 | QPushButton * connectButton; 54 | QPushButton * cancelButton; 55 | QDialogButtonBox * buttonBox; 56 | }; 57 | -------------------------------------------------------------------------------- /src/network/setphrasepalette.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | 25 | class QAction; 26 | class CyberOroConnection; 27 | class QPushButton; 28 | 29 | class SetPhrasePalette : public QToolBar 30 | { 31 | Q_OBJECT 32 | public: 33 | SetPhrasePalette(CyberOroConnection *); 34 | ~SetPhrasePalette(); 35 | 36 | void slot_triggered(QAction *); 37 | private: 38 | QPushButton * button0; 39 | QPushButton * button1; 40 | QPushButton * button2; 41 | QPushButton * button3; 42 | QPushButton * button4; 43 | QPushButton * button5; 44 | QPushButton * button6; 45 | QPushButton * button7; 46 | QPushButton * button8; 47 | QPushButton * button9; 48 | std::vector actions; 49 | CyberOroConnection * connection; 50 | }; 51 | -------------------------------------------------------------------------------- /src/network/talk.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include "talk.h" 24 | #include "networkconnection.h" 25 | #include "gamedialog.h" 26 | #include "messages.h" 27 | #include "playergamelistings.h" 28 | #include "connectionwidget.h" 29 | #include "room.h" 30 | /* I wonder if we could somehow generalize this class to handle 31 | * all message/windows even if they're part of larger windows. 32 | * We could even do it for the console, specifying a special 33 | * "opponent" and for the room, with the room name as the 34 | * opponent. And then it could handle all the sendText 35 | * messages that would otherwise be spread around all 36 | * the dispatches, cluttering up their otherwise 37 | * specific calls.*/ 38 | 39 | Talk::Talk(NetworkConnection * conn, PlayerListing *player, Room * r) : TalkGui(), connection(conn), opponent(player), room(r) 40 | { 41 | qDebug("Creating Talk for %s", opponent->name.toLatin1().constData()); 42 | ui.setupUi(this); 43 | opponent->dialog_opened = true; 44 | conversationOpened = false; 45 | 46 | /* 47 | // do not add a button for shouts* or channels tab 48 | if ( (name.find('*') != -1) || (!isplayer)) 49 | { 50 | delete pb_releaseTalkTab; 51 | delete pb_match; 52 | delete stats_layout; 53 | } 54 | */ 55 | connect(ui.pb_releaseTalkTab, &QPushButton::pressed, this, &Talk::slot_pbRelTab); 56 | connect(ui.pb_match, &QPushButton::pressed, this, &Talk::slot_match); 57 | connect(ui.LineEdit1, &QLineEdit::returnPressed, this, &Talk::slot_returnPressed); 58 | } 59 | 60 | Talk::~Talk() 61 | { 62 | qDebug("Talk destroyed"); 63 | opponent->dialog_opened = false; 64 | } 65 | 66 | void Talk::closeEvent(QCloseEvent *) 67 | { 68 | if(room) 69 | room->closeTalk(opponent); 70 | } 71 | 72 | QString Talk::get_name() const 73 | { return opponent->name; } 74 | 75 | // release current Tab 76 | void Talk::slot_pbRelTab() 77 | { 78 | room->closeTalk(opponent); 79 | } 80 | 81 | void Talk::slot_returnPressed() 82 | { 83 | // read tab 84 | QString txt = ui.LineEdit1->text(); 85 | connection->sendMsg(opponent, txt); 86 | ui.MultiLineEdit1->append(connection->getUsername() + ": " + txt); 87 | ui.LineEdit1->clear(); 88 | } 89 | 90 | void Talk::slot_match() 91 | { 92 | connection->sendMatchInvite(opponent); 93 | } 94 | 95 | void Talk::recvTalk(QString text) 96 | { 97 | ui.MultiLineEdit1->append(opponent->name + ": " + text); 98 | } 99 | 100 | void Talk::updatePlayerListing(void) 101 | { 102 | if (opponent == NULL) 103 | return; 104 | 105 | ui.stats_rating->setText(opponent->rank); 106 | ui.stats_info->setText(opponent->info); 107 | ui.stats_default->setText(opponent->extInfo); 108 | ui.stats_wins->setText(QString::number(opponent->wins) + " /"); 109 | ui.stats_loss->setText(QString::number(opponent->losses) ); 110 | ui.stats_country->setText(opponent->country); 111 | ui.stats_playing->setText(QString::number(opponent->playing)); 112 | //ui.stats_rated->setText(p->rated); 113 | ui.stats_address->setText(opponent->email_address); 114 | 115 | // stored either idle time or last access 116 | ui.stats_idle->setText(opponent->idletime); 117 | if (!opponent->idletime.isEmpty()) 118 | ui.Label_Idle->setText(opponent->idletime.at(0).isDigit() ? "Idle :": "Last log :"); 119 | } 120 | -------------------------------------------------------------------------------- /src/network/talk.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef TALK_H 24 | #define TALK_H 25 | 26 | #include "ui_talk_gui.h" 27 | #include 28 | 29 | class NetworkConnection; 30 | class PlayerListing; 31 | class Room; 32 | 33 | class Talk : public QDialog, public Ui::TalkGui 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | Talk(NetworkConnection * conn, PlayerListing *player, Room * r); 39 | virtual ~Talk(); 40 | QString get_name() const; 41 | bool getConversationOpened(void) const { return conversationOpened; } 42 | void setConversationOpened(bool c) { conversationOpened = c; } 43 | void recvTalk(QString text); 44 | 45 | void slot_returnPressed(); 46 | void slot_pbRelTab(); 47 | void slot_match(); 48 | void updatePlayerListing(); 49 | 50 | private: 51 | void closeEvent(QCloseEvent *e); 52 | Ui::TalkGui ui; 53 | NetworkConnection * connection; 54 | PlayerListing * opponent; 55 | bool conversationOpened; 56 | Room * room; 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/network/tomconnection.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include "tygemconnection.h" 24 | 25 | class TomConnection : public TygemConnection 26 | { 27 | public: 28 | TomConnection(const ConnectionCredentials credentials); 29 | //~TomConnection(); 30 | virtual const char * getCodecString(void); 31 | virtual QString getPlaceString(void); 32 | private: 33 | virtual int requestServerInfo(void); 34 | virtual void handleServerInfo(unsigned char *, unsigned int); 35 | virtual QByteArray getTygemGameRecordQByteArray(class GameData *); 36 | }; 37 | -------------------------------------------------------------------------------- /src/network/tygemprotocol.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | #define TYGEM_PROTOCOL_VERSION 0x13 //was 06 23 | 24 | #define TYGEM_GAMESINIT 0x12 25 | #define TYGEM_GAMESUPDATE 0x13 26 | #define TYGEM_PLAYERSINIT 0x15 27 | #define TYGEM_PLAYERSUPDATE 0x16 28 | 29 | #define TYGEM_ROOMCREATED 0x37 30 | #define TYGEM_BOARDOPENED 0x39 31 | #define TYGEM_SERVERPING 0x4d 32 | #define TYGEM_SERVERPLAYERCOUNTS 0x54 33 | #define TYGEM_OBSERVERSINIT 0x66 34 | #define TYGEM_OBSERVERSUPDATE 0x67 35 | #define TYGEM_MOVE 0x68 36 | #define TYGEM_TIME 0x7d 37 | 38 | #define TYGEM_MATCHINVITE 0x43 39 | #define TYGEM_MATCHINVITERESPONSE 0x44 40 | #define TYGEM_MATCHOFFER 0x45 41 | #define TYGEM_MATCHOFFERRESPONSE 0x46 42 | 43 | #define TYGEM_SERVERDISCONNECT 0x51 44 | 45 | //#define TYGEM_REQUESTCOUNT 0x6b 46 | //#define TYGEM_MATCHRESULT 0x72 47 | #define TYGEM_ENDGAMEMSG 0x7b 48 | 49 | #define TYGEM_OPENCONVERSATION 0x33 50 | #define TYGEM_CONVERSATIONREPLY 0x34 51 | #define TYGEM_CONVERSATIONMSG 0x35 52 | #define TYGEM_GAMECHAT 0x61 53 | #define TYGEM_MATCH 0x71 54 | #define TYGEM_MATCHRESULT 0x72 55 | 56 | #define TYGEM_RESUMEBROKENMATCH 0x8e 57 | 58 | #define TYGEM_FRIENDSBLOCKSLIST 0x96 59 | #define TYGEM_PERSONALCHAT 0x9f 60 | 61 | #define TPC(x) (TYGEM_PROTOCOL_VERSION << 8) + x 62 | 63 | -------------------------------------------------------------------------------- /src/network/wing.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #include 24 | #include "igsconnection.h" 25 | 26 | class WingConnection : public IGSConnection 27 | { 28 | public: 29 | WingConnection(const ConnectionCredentials credentials); 30 | virtual QString getPlaceString(void); 31 | virtual void sendPlayersRequest(void); 32 | virtual void sendMatchRequest(class MatchRequest * mr); 33 | virtual void sendMove(unsigned int game_id, class MoveRecord * move); 34 | virtual void onReady(void); 35 | virtual void requestGameInfo(unsigned int game_id); 36 | private: 37 | virtual void handle_info(QString); 38 | virtual void handle_kibitz(QString); 39 | }; 40 | -------------------------------------------------------------------------------- /src/newgamedialog.cpp: -------------------------------------------------------------------------------- 1 | #include "newgamedialog.h" 2 | #include "ui_newgamedialog.h" 3 | 4 | #include 5 | #include "mainwindow.h" 6 | #include "boardwindow.h" 7 | 8 | NewGameDialog::NewGameDialog(MainWindow *parent) : 9 | QDialog(parent), 10 | ui(new Ui::NewGameDialog) 11 | { 12 | mw = parent; 13 | ui->setupUi(this); 14 | 15 | QSettings settings; 16 | QVariant var; 17 | //SGF edition tab default values 18 | if((var = settings.value("EDIT_SIZE")) == QVariant()) 19 | var = 19; 20 | ui->newFile_Size->setValue(var.toInt()); 21 | handicap = settings.value("EDIT_HANDICAP").toInt(); 22 | ui->newFile_Handicap->setValue(handicap); 23 | if((var = settings.value("EDIT_KOMI")) == QVariant()) 24 | var = 5.5; 25 | ui->newFile_Komi->setValue(var.toDouble()); 26 | 27 | ui->computerPlaysWhite->setChecked(settings.value("COMPUTER_PLAYS_WHITE").toBool()); 28 | ui->computerPlaysBlack->setChecked(settings.value("COMPUTER_PLAYS_BLACK").toBool()); 29 | 30 | connect(ui->newFile_Handicap, QOverload::of(&QSpinBox::valueChanged), this, &NewGameDialog::slot_newFile_HandicapChange); 31 | } 32 | 33 | NewGameDialog::~NewGameDialog() 34 | { 35 | QSettings settings; 36 | //SGF edition tab default values 37 | settings.setValue("EDIT_SIZE",ui->newFile_Size->value()); 38 | settings.setValue("EDIT_HANDICAP",ui->newFile_Handicap->value()); 39 | settings.setValue("EDIT_KOMI",ui->newFile_Komi->value()); 40 | 41 | settings.setValue("COMPUTER_PLAYS_WHITE", ui->computerPlaysWhite->isChecked()); 42 | settings.setValue("COMPUTER_PLAYS_BLACK", ui->computerPlaysBlack->isChecked()); 43 | delete ui; 44 | } 45 | 46 | void NewGameDialog::slot_newFile_HandicapChange(int a) 47 | { 48 | if(a == 1) 49 | { 50 | handicap = (handicap < 1 ? 2 : 0); 51 | ui->newFile_Handicap->setValue(handicap); 52 | } else 53 | handicap = a; 54 | } 55 | 56 | void NewGameDialog::accept() 57 | { 58 | GameData *gd = new GameData(); 59 | gd->gameMode = modeLocal; 60 | 61 | gd->board_size = ui->newFile_Size->value(); 62 | gd->handicap = ui->newFile_Handicap->value(); 63 | gd->black_name = ui->newFile_BlackPlayer->text(); 64 | gd->white_name = ui->newFile_WhitePlayer->text(); 65 | gd->komi = ui->newFile_Komi->value(); 66 | 67 | BoardWindow * bw = new BoardWindow(gd, !(ui->computerPlaysBlack->isChecked()), 68 | !(ui->computerPlaysWhite->isChecked())); 69 | if(bw) 70 | mw->addBoardWindow(bw); 71 | 72 | QDialog::accept(); 73 | } 74 | -------------------------------------------------------------------------------- /src/newgamedialog.h: -------------------------------------------------------------------------------- 1 | #ifndef NEWGAMEDIALOG_H 2 | #define NEWGAMEDIALOG_H 3 | 4 | #include 5 | class MainWindow; 6 | 7 | namespace Ui { 8 | class NewGameDialog; 9 | } 10 | 11 | class NewGameDialog : public QDialog 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit NewGameDialog(MainWindow *parent); 17 | ~NewGameDialog(); 18 | 19 | void slot_newFile_HandicapChange(int); 20 | virtual void accept(); 21 | 22 | private: 23 | Ui::NewGameDialog *ui; 24 | MainWindow *mw; 25 | int handicap; 26 | }; 27 | 28 | #endif // NEWGAMEDIALOG_H 29 | -------------------------------------------------------------------------------- /src/preferences.h: -------------------------------------------------------------------------------- 1 | #ifndef PREFERENCES_H 2 | #define PREFERENCES_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Ui { 9 | class Preferences; 10 | } 11 | 12 | class Engine 13 | { 14 | public: 15 | Engine(QString p, QString a) : 16 | path(p), arguments(a) {} 17 | QString path; 18 | QString arguments; 19 | }; 20 | 21 | class EngineTableModel : public QAbstractTableModel 22 | { 23 | Q_OBJECT 24 | 25 | public: 26 | enum EngineTableColumn { ENGINE_DEFAULT, ENGINE_PATH, ENGINE_ARGUMENTS, ENGINE_NUMITEMS }; 27 | 28 | EngineTableModel(QObject * parent = 0); 29 | ~EngineTableModel(); 30 | int rowCount(const QModelIndex & parent = QModelIndex()) const; 31 | int columnCount(const QModelIndex & parent = QModelIndex()) const; 32 | QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const; 33 | QVariant data(const QModelIndex & index, int role) const; 34 | QVariant headerData(int section, Qt::Orientation orientation, int role) const; 35 | Qt::ItemFlags flags(const QModelIndex & index) const; 36 | bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); 37 | bool removeRows(int row, int count, const QModelIndex &parent); 38 | 39 | void addEngine(Engine e); 40 | void loadEngines(void); 41 | void saveEngines(void); 42 | public: 43 | QList engines; 44 | int selected_engine; 45 | }; 46 | 47 | class Preferences : public QDialog 48 | { 49 | Q_OBJECT 50 | 51 | public: 52 | explicit Preferences(QWidget *parent = 0); 53 | ~Preferences(); 54 | 55 | void addEngine(); 56 | void removeEngine(); 57 | void saveSettings(); 58 | void loadSettings(); 59 | void slot_getGobanPath(); 60 | void slot_getTablePath(); 61 | 62 | private: 63 | Ui::Preferences *ui; 64 | QSettings settings; 65 | EngineTableModel * engineTableModel; 66 | QString currentWorkingDir; 67 | }; 68 | 69 | #endif // PREFERENCES_H 70 | -------------------------------------------------------------------------------- /src/qgo.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Version=1.0 4 | Name=qGo 5 | GenericName=Go Client 6 | Comment=Play Go online and against computer, view and edit SGF files 7 | Icon=qgo 8 | Exec=qgo %F 9 | Terminal=false 10 | MimeType=application/x-go-sgf; 11 | Categories=Qt;Game;BoardGame; 12 | 13 | -------------------------------------------------------------------------------- /src/qgo.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "resources/pics/Bowl.ico" 2 | -------------------------------------------------------------------------------- /src/resources/pics/Bowl.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/Bowl.ico -------------------------------------------------------------------------------- /src/resources/pics/Bowl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/Bowl.png -------------------------------------------------------------------------------- /src/resources/pics/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/close.png -------------------------------------------------------------------------------- /src/resources/pics/connect_no2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/connect_no2.png -------------------------------------------------------------------------------- /src/resources/pics/connected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/connected.png -------------------------------------------------------------------------------- /src/resources/pics/not_seeking.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/not_seeking.png -------------------------------------------------------------------------------- /src/resources/pics/qgo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/qgo.png -------------------------------------------------------------------------------- /src/resources/pics/qgo_16x16.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static char * qgo_16x16_xpm[] = { 3 | "16 16 124 2", 4 | " c None", 5 | ". c #A6654B", 6 | "+ c #AF6D4B", 7 | "@ c #A7603C", 8 | "# c #944B2F", 9 | "$ c #9C5432", 10 | "% c #9C5539", 11 | "& c #9E6047", 12 | "* c #9C5C43", 13 | "= c #A15A38", 14 | "- c #A86D5B", 15 | "; c #EDE6E7", 16 | "> c #FEFFFF", 17 | ", c #E6D9D7", 18 | "' c #DDD2D1", 19 | ") c #A6796E", 20 | "! c #9C5E4C", 21 | "~ c #883928", 22 | "{ c #E3D4D0", 23 | "] c #FFFFFF", 24 | "^ c #FFFFFD", 25 | "/ c #E8E3E1", 26 | "( c #B45F46", 27 | "_ c #9E5236", 28 | ": c #754339", 29 | "< c #8C4331", 30 | "[ c #792921", 31 | "} c #BC8476", 32 | "| c #C89E98", 33 | "1 c #CEADAA", 34 | "2 c #D8C6C8", 35 | "3 c #DECBD0", 36 | "4 c #B77C76", 37 | "5 c #A24632", 38 | "6 c #943B25", 39 | "7 c #7F4A33", 40 | "8 c #6C2B1E", 41 | "9 c #813523", 42 | "0 c #903E2A", 43 | "a c #915352", 44 | "b c #924D4A", 45 | "c c #B46454", 46 | "d c #A45548", 47 | "e c #9A3922", 48 | "f c #983921", 49 | "g c #803120", 50 | "h c #7C3C26", 51 | "i c #844023", 52 | "j c #6F261B", 53 | "k c #6F271B", 54 | "l c #9F452A", 55 | "m c #873020", 56 | "n c #8D3320", 57 | "o c #903626", 58 | "p c #8A3320", 59 | "q c #773829", 60 | "r c #63392A", 61 | "s c #87422B", 62 | "t c #743221", 63 | "u c #833C25", 64 | "v c #782F22", 65 | "w c #7C2B1D", 66 | "x c #7D281D", 67 | "y c #76261A", 68 | "z c #7F4130", 69 | "A c #5F3625", 70 | "B c #6B3221", 71 | "C c #803B26", 72 | "D c #7B3726", 73 | "E c #6C2A1F", 74 | "F c #5A261D", 75 | "G c #663C33", 76 | "H c #A65039", 77 | "I c #C87B68", 78 | "J c #D5937D", 79 | "K c #CB7C63", 80 | "L c #C46E4B", 81 | "M c #994331", 82 | "N c #732C1F", 83 | "O c #AD5336", 84 | "P c #BC644A", 85 | "Q c #BA6449", 86 | "R c #C25E39", 87 | "S c #BD5733", 88 | "T c #A7442D", 89 | "U c #9E442E", 90 | "V c #973F2B", 91 | "W c #792F23", 92 | "X c #97422F", 93 | "Y c #C4643D", 94 | "Z c #BB5936", 95 | "` c #AD5032", 96 | " . c #A7482E", 97 | ".. c #923C29", 98 | "+. c #A2452A", 99 | "@. c #9C4029", 100 | "#. c #712A1E", 101 | "$. c #8B3D2E", 102 | "%. c #903E2B", 103 | "&. c #B75437", 104 | "*. c #C15F38", 105 | "=. c #B75935", 106 | "-. c #A64F31", 107 | ";. c #973F2A", 108 | ">. c #A54628", 109 | ",. c #9E3F27", 110 | "'. c #883525", 111 | "). c #843E2F", 112 | "!. c #854030", 113 | "~. c #863725", 114 | "{. c #A84C34", 115 | "]. c #B95334", 116 | "^. c #9F432D", 117 | "/. c #9F4129", 118 | "(. c #9F452F", 119 | "_. c #944130", 120 | ":. c #8D4132", 121 | "<. c #7B3D2C", 122 | "[. c #7F3927", 123 | "}. c #943F2E", 124 | "|. c #8A392B", 125 | "1. c #8B3D34", 126 | "2. c #8C483B", 127 | "3. c #834439", 128 | " ", 129 | " . + @ # $ % & ", 130 | " * = - ; > , ' ) ! ", 131 | " ~ { ] ] ^ ] ] / ( _ ", 132 | ": < [ } | 1 2 3 4 5 6 ", 133 | "7 8 9 0 a b c d e f g ", 134 | " h i j k l m n o p q ", 135 | " r s t u v w x y z ", 136 | " A B C D E F G ", 137 | " H I J K L M N ", 138 | " O P Q R S T U V W ", 139 | " X Y Z ` ...+.@.#.$.", 140 | " %.&.*.=.-.;.>.,.'.).", 141 | " !.~.{.].^./.(._.:. ", 142 | " <.[.}.|.1.2.3. ", 143 | " "}; 144 | -------------------------------------------------------------------------------- /src/resources/pics/qgo_48x48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/qgo_48x48.png -------------------------------------------------------------------------------- /src/resources/pics/refresh_games.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/refresh_games.png -------------------------------------------------------------------------------- /src/resources/pics/refresh_players.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/refresh_players.png -------------------------------------------------------------------------------- /src/resources/pics/seeking1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/seeking1.png -------------------------------------------------------------------------------- /src/resources/pics/seeking2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/seeking2.png -------------------------------------------------------------------------------- /src/resources/pics/seeking3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/seeking3.png -------------------------------------------------------------------------------- /src/resources/pics/seeking4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/seeking4.png -------------------------------------------------------------------------------- /src/resources/pics/toolbar_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/toolbar_1.png -------------------------------------------------------------------------------- /src/resources/pics/toolbar_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/toolbar_2.png -------------------------------------------------------------------------------- /src/resources/pics/toolbar_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/toolbar_3.png -------------------------------------------------------------------------------- /src/resources/pics/toolbar_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/toolbar_4.png -------------------------------------------------------------------------------- /src/resources/pics/toolbar_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/pics/toolbar_5.png -------------------------------------------------------------------------------- /src/resources/sounds/blip.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/sounds/blip.wav -------------------------------------------------------------------------------- /src/resources/sounds/buzzer.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/sounds/buzzer.wav -------------------------------------------------------------------------------- /src/resources/sounds/doorbell.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/sounds/doorbell.wav -------------------------------------------------------------------------------- /src/resources/sounds/ns.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/sounds/ns.wav -------------------------------------------------------------------------------- /src/resources/sounds/pop.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/sounds/pop.wav -------------------------------------------------------------------------------- /src/resources/sounds/static.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/sounds/static.wav -------------------------------------------------------------------------------- /src/resources/sounds/stone.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/sounds/stone.wav -------------------------------------------------------------------------------- /src/resources/sounds/timer.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pzorin/qgo/2a4212d473372bb531fdc5c919a20dd96819f9b0/src/resources/sounds/timer.wav -------------------------------------------------------------------------------- /src/sgf/sgfparser.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | * Copyright (C) 2009 by The qGo Project * 3 | * * 4 | * This file is part of qGo. * 5 | * * 6 | * qGo is free software: you can redistribute it and/or modify * 7 | * it under the terms of the GNU General Public License as published by * 8 | * the Free Software Foundation; either version 2 of the License, or * 9 | * (at your option) any later version. * 10 | * * 11 | * This program is distributed in the hope that it will be useful, * 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 14 | * GNU General Public License for more details. * 15 | * * 16 | * You should have received a copy of the GNU General Public License * 17 | * along with this program; if not, see * 18 | * or write to the Free Software Foundation, Inc., * 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 20 | ***************************************************************************/ 21 | 22 | 23 | #ifndef SGFPARSER_H 24 | #define SGFPARSER_H 25 | 26 | #include "../defines.h" 27 | #include "tree.h" 28 | 29 | #include 30 | 31 | class GameData; 32 | 33 | class SGFParser 34 | { 35 | public: 36 | SGFParser(Tree *tree); 37 | ~SGFParser(); 38 | QString loadFile(const QString &fileName); 39 | GameData * initGame(const QString &toParse, const QString &fileName); 40 | 41 | bool parse(const QString &fileName, const QString &filter=0); 42 | 43 | bool doParse(const QString &toParseStr); 44 | bool doWrite(const QString &fileName, Tree *tree, GameData *gameData); 45 | bool exportSGFtoClipB(QString *str, Tree *tree, GameData *gameData); 46 | 47 | protected: 48 | int minPos(int n1, int n2, int n3); 49 | bool corruptSgf(int where=0, QString reason=QString::null); 50 | 51 | bool parseProperty(const QString &toParse, const QString &prop, QString &result); 52 | 53 | void traverse(Move *t, GameData *gameData); 54 | void writeGameHeader(GameData *gameData); 55 | bool writeStream(Tree *tree, GameData *gameData); 56 | 57 | private: 58 | bool setCodec(QString c = QString()); 59 | 60 | QTextStream *stream; 61 | QTextCodec * readCodec; 62 | bool isRoot; 63 | Tree *tree; 64 | bool loadedfromfile; 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /src/sgfpreview.cpp: -------------------------------------------------------------------------------- 1 | #include "sgfpreview.h" 2 | #include "ui_sgfpreview.h" 3 | #include "displayboard.h" 4 | #include "sgfparser.h" 5 | #include "gamedata.h" 6 | #include "defines.h" 7 | #include "mainwindow.h" 8 | #include "boardwindow.h" 9 | 10 | SGFPreview::SGFPreview(QWidget *parent) : 11 | QWidget(parent), 12 | ui(new Ui::SGFPreview) 13 | { 14 | MW_SGFparser = new SGFParser(NULL); 15 | GameLoaded = NULL; 16 | ui->setupUi(this); 17 | } 18 | 19 | SGFPreview::~SGFPreview() 20 | { 21 | if (GameLoaded != NULL) 22 | { 23 | delete GameLoaded; 24 | GameLoaded = NULL; 25 | } 26 | delete ui; 27 | delete MW_SGFparser; 28 | } 29 | 30 | void SGFPreview::clearData() 31 | { 32 | if (GameLoaded != NULL) 33 | { 34 | delete GameLoaded; 35 | GameLoaded = NULL; 36 | } 37 | ui->displayBoard->clearData(); 38 | 39 | ui->File_WhitePlayer->setText(""); 40 | ui->File_BlackPlayer->setText(""); 41 | ui->File_Date->setText(""); 42 | ui->File_Handicap->setText(""); 43 | ui->File_Result->setText(""); 44 | ui->File_Komi->setText(""); 45 | ui->File_Size->setText(""); 46 | } 47 | 48 | void SGFPreview::setPath(QString path) 49 | { 50 | //if (QFileInfo("path").isFile() == false) 51 | // return; 52 | clearData(); 53 | 54 | //fileLoaded = path.toLatin1().constData(); 55 | SGFloaded = MW_SGFparser->loadFile(path); 56 | if (SGFloaded == NULL) 57 | { 58 | emit isValidSGF(false); 59 | return; 60 | } 61 | 62 | GameLoaded = MW_SGFparser->initGame(SGFloaded, path); 63 | if (GameLoaded == NULL) 64 | { 65 | emit isValidSGF(false); 66 | return; 67 | } 68 | 69 | GameLoaded->gameMode = modeEdit; 70 | 71 | QString komi, hcp, sz; 72 | komi.setNum(GameLoaded->komi); 73 | hcp.setNum(GameLoaded->handicap); 74 | sz.setNum(GameLoaded->board_size); 75 | 76 | ui->File_WhitePlayer->setText(GameLoaded->white_name); 77 | ui->File_BlackPlayer->setText(GameLoaded->black_name); 78 | ui->File_Date->setText(GameLoaded->date); 79 | ui->File_Handicap->setText(hcp); 80 | ui->File_Result->setText(GameLoaded->result); 81 | ui->File_Komi->setText(komi); 82 | ui->File_Size->setText(sz); 83 | 84 | DisplayBoard* board = ui->displayBoard; 85 | board->clearData(); 86 | if (board->getSize() != GameLoaded->board_size) 87 | board->init(GameLoaded->board_size); 88 | 89 | board->displayHandicap(GameLoaded->handicap); 90 | 91 | QString s = SGFloaded.trimmed(); 92 | int end_main = s.indexOf(")("); 93 | if (end_main == -1) 94 | end_main = s.size(); 95 | int a_offset = QChar::fromLatin1('a').unicode() - 1 ; 96 | int cursor = 0; 97 | int x,y; 98 | int nb_displayed = 20; 99 | QString coords; 100 | 101 | cursor = s.indexOf(";B["); 102 | 103 | while ((cursor >0) && (cursor < end_main) && (nb_displayed--) ) 104 | { 105 | x = s.at(cursor+3).unicode() - a_offset; 106 | y = s.at(cursor+4).unicode() - a_offset; 107 | board->updateStone(stoneBlack,x,y); 108 | cursor = s.indexOf(";B[",cursor +1); 109 | 110 | } 111 | 112 | cursor = s.indexOf(";W["); 113 | nb_displayed = 20; 114 | 115 | while ( (cursor >0) && (cursor < end_main) && (nb_displayed--) ) 116 | { 117 | x = s.at(cursor+3).unicode() - a_offset; 118 | y = s.at(cursor+4).unicode() - a_offset; 119 | board->updateStone(stoneWhite,x,y); 120 | cursor = s.indexOf(";W[",cursor +1); 121 | 122 | } 123 | emit isValidSGF(true); 124 | } 125 | 126 | // Maybe handle computer games separately. 127 | // Here is the old code that was supposed to do that. 128 | /*void MainWindow::slot_loadComputerFile(const QModelIndex & topLeft, const QModelIndex & bottomRight ) 129 | { 130 | QVariant v = topLeft.data(QDirModel::FilePathRole); 131 | 132 | if (!selectFile(topLeft)) 133 | { 134 | ui.button_loadComputerGame->setDisabled(true); 135 | } else { 136 | GameLoaded->gameMode = modeComputer; 137 | ui.button_loadComputerGame->setEnabled(true); 138 | 139 | QString komi, hcp, sz; 140 | komi.setNum(GameLoaded->komi); 141 | hcp.setNum(GameLoaded->handicap); 142 | sz.setNum(GameLoaded->board_size); 143 | 144 | ui.File_WhitePlayer->setText(GameLoaded->white_name); 145 | ui.File_BlackPlayer->setText(GameLoaded->black_name); 146 | ui.File_Date->setText(GameLoaded->date); 147 | ui.File_Handicap->setText(hcp); 148 | ui.File_Result->setText(GameLoaded->result); 149 | ui.File_Komi->setText(komi); 150 | ui.File_Size->setText(sz); 151 | 152 | displayGame(ui.displayBoard); 153 | } 154 | }*/ 155 | -------------------------------------------------------------------------------- /src/sgfpreview.h: -------------------------------------------------------------------------------- 1 | #ifndef SGFPREVIEW_H 2 | #define SGFPREVIEW_H 3 | 4 | #include 5 | 6 | class SGFParser; 7 | class GameData; 8 | 9 | namespace Ui { 10 | class SGFPreview; 11 | } 12 | 13 | class SGFPreview : public QWidget 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit SGFPreview(QWidget *parent = 0); 19 | ~SGFPreview(); 20 | void clearData(); 21 | 22 | void setPath(QString path); 23 | 24 | signals: 25 | void isValidSGF(bool); 26 | // This class should decide if the path contains a valid SGF file. 27 | // As far as I can tell, this is not checked at the moment. 28 | // It is implicitly assumed that the file is valid SGF. 29 | 30 | private: 31 | Ui::SGFPreview *ui; 32 | GameData * GameLoaded; 33 | SGFParser * MW_SGFparser; 34 | QString SGFloaded; 35 | }; 36 | 37 | #endif // SGFPREVIEW_H 38 | -------------------------------------------------------------------------------- /src/sgfpreview.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | SGFPreview 4 | 5 | 6 | 7 | 0 8 | 0 9 | 204 10 | 367 11 | 12 | 13 | 14 | 15 | 200 16 | 0 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 0 25 | 0 26 | 27 | 28 | 29 | 30 | 150 31 | 150 32 | 33 | 34 | 35 | Board preview 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | White player 45 | 46 | 47 | 48 | 49 | 50 | 51 | White 52 | 53 | 54 | 55 | 56 | 57 | 58 | Black player 59 | 60 | 61 | 62 | 63 | 64 | 65 | Black 66 | 67 | 68 | 69 | 70 | 71 | 72 | Date 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 19 93 | 94 | 95 | 96 | 97 | 98 | 99 | Handicap 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | Size 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | Komi 125 | 126 | 127 | 128 | 129 | 130 | 131 | 6.5 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | Result 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | DisplayBoard 158 | QWidget 159 |
displayboard.h
160 |
161 |
162 | 163 | 164 |
165 | --------------------------------------------------------------------------------