| 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 <http://www.gnu.org/licenses/> * |
| 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 GAMEDIALOG_H |
| 24 | #define GAMEDIALOG_H |
| 25 | |
| 26 | #include "ui_gamedialog.h" |
| 27 | #include "defines.h" |
| 28 | #include <QtWidgets> |
| 29 | |
| 30 | class NetworkConnection; |
| 31 | class PlayerListing; |
| 32 | |
| 33 | class GameDialog : public QDialog,/*public NewGameDialog,*/public Ui::GameDialog //, public Misc<QString> |
| 34 | { |
| 35 | Q_OBJECT |
| 36 | |
| 37 | public: |
| 38 | GameDialog(NetworkConnection * conn, const PlayerListing * opp);//QWidget* parent = 0, const char* name = 0, bool modal = true, WFlags fl = 0); |
| 39 | ~GameDialog(); |
| 40 | void set_oppRk(QString &rk) { oppRk = rk; qDebug("oppRk: %s", rk.toLatin1().constData()); } |
| 41 | void set_myRk(QString &rk) { myRk = rk; qDebug("myRk: %s", rk.toLatin1().constData()); } |
| 42 | void set_myName(QString &name) { myName = name; } |
| 43 | void set_is_nmatch (bool b) { is_nmatch = b; } |
| 44 | Ui::GameDialog getUi() {return ui;} |
| 45 | void recvRequest(class MatchRequest * mr, unsigned long flags = 0); |
| 46 | void recvRefuseMatch(int motive = 0); |
| 47 | class MatchRequest * getMatchRequest(void); |
| 48 | protected: |
| 49 | void closeEvent(QCloseEvent *e); |
| 50 | |
| 51 | signals: |
| 52 | void signal_sendCommand(const QString &cmd, bool localecho); |
| 53 | void signal_matchSettings(const QString&, const QString&, const QString&, assessType); |
| 54 | void signal_removeDialog(GameDialog *);//const QString&); |
| 55 | |
| 56 | public: |
| 57 | void slot_play_black_button(void); |
| 58 | void slot_play_white_button(void); |
| 59 | void slot_play_nigiri_button(void); |
| 60 | void ratedCB_changed(bool checked); |
| 61 | void slot_boardSizeSpin(int); |
| 62 | void slot_handicapSpin(int); |
| 63 | void slot_komiSpin(int); |
| 64 | void slot_timeTab(int); |
| 65 | void slot_timeSpin(const QTime &); |
| 66 | void slot_stonesTimeSpin(const QTime &); |
| 67 | void slot_stonesSpin(int); |
| 68 | void slot_BYTimeSpin(const QTime &); |
| 69 | void slot_BYPeriodTimeSpin(const QTime &); |
| 70 | void slot_BYPeriodsSpin(int); |
| 71 | void slot_ASIATimeSpin(const QTime &); |
| 72 | void slot_ASIAPeriodTimeSpin(const QTime &); |
| 73 | void slot_ASIAPeriodsSpin(int); |
| 74 | // pushbuttons |
| 75 | // void slot_swapcolors(); |
| 76 | // void slot_pbsuggest(); |
| 77 | void slot_offer(bool); |
| 78 | void slot_decline(); |
| 79 | void slot_changed(); |
| 80 | void slot_cancel(); |
| 81 | // parser |
| 82 | // void slot_suggest(const QString&, const QString&, const QString&, const QString&, int); |
| 83 | // void slot_matchCreate(const QString&, const QString&); |
| 84 | |
| 85 | void slot_komiRequest(const QString&, int, int, bool); |
| 86 | // void slot_opponentopen(const QString&); |
| 87 | //void slot_dispute(const QString&, const QString&); |
| 88 | |
| 89 | private: |
| 90 | void save_to_preferences(void); |
| 91 | QTime qtimeFromSeconds(int); |
| 92 | unsigned int timeToSeconds(QString time); //duplicated in connect code FIXME |
| 93 | unsigned int timeToSeconds(const QTime & t); |
| 94 | void clearChangedFlags(void); |
| 95 | bool getProperKomiHandicap(QString rankA, QString rankB, float * komi, unsigned int * handicap); |
| 96 | bool we_are_challenger; //FIXME, do we need this? |
| 97 | Ui::GameDialog ui; |
| 98 | bool have_suggestdata; |
| 99 | int dialog_changed; |
| 100 | bool color_request_changed; |
| 101 | bool ratedchanged; |
| 102 | bool boardSizechanged; |
| 103 | bool handicapchanged; |
| 104 | bool komichanged; |
| 105 | bool ttchanged; |
| 106 | bool timechanged; |
| 107 | bool stonesTimechanged; |
| 108 | bool stoneschanged; |
| 109 | bool BYPeriodTimechanged; |
| 110 | bool BYPeriodschanged; |
| 111 | bool ASIATimechanged; |
| 112 | bool ASIAPeriodTimechanged; |
| 113 | bool ASIAPeriodschanged; |
| 114 | QString pwhite; |
| 115 | QString pblack; |
| 116 | QString h19, h13, h9; |
| 117 | QString k19, k13, k9; |
| 118 | QString oppRk; |
| 119 | QString myRk; |
| 120 | QString myName; |
| 121 | bool komi_request; |
| 122 | bool is_nmatch; |
| 123 | NetworkConnection * connection; |
| 124 | class MatchRequest * current_match_request; |
| 125 | const PlayerListing * opponent; |
| 126 | class Sound * gameSound; |
| 127 | bool offered_and_unrefused; |
| 128 | unsigned long flags; |
| 129 | }; |
| 130 | |
| 131 | #endif |