| 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 | #include <QtWidgets> |
| 24 | #include "../network/messages.h"cxx . . $ `<file>/src/network/messages.h`/ |
| 25 | #include "resultdialog.h"cxx . . $ `<file>/src/game_interfaces/resultdialog.h`/ |
| 26 | #include "../network/boarddispatch.h"cxx . . $ `<file>/src/network/boarddispatch.h`/ |
| 27 | |
| 28 | ResultDialogcxx . . $ ResultDialog#::ResultDialogcxx . . $ ResultDialog#ResultDialog(8247bc9e6e961c84).(QWidgetcxx . . $ QWidget# * parent, BoardDispatchcxx . . $ BoardDispatch# * dis, unsigned int game_id, GameResultcxx . . $ GameResult# * gr) : QDialogcxx . . $ QDialog#QDialog(872e7b0c281abd8d).(parent), dispatchcxx . . $ ResultDialog#dispatch.(dis) |
| 29 | { |
| 30 | if(!dispatchcxx . . $ ResultDialog#dispatch.) |
| 31 | { |
| 32 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("ResultDialog called without board dispatch"); |
| 33 | deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).(); |
| 34 | return; |
| 35 | } |
| 36 | if(!gr) |
| 37 | { |
| 38 | // This was created by the board dispatch in response |
| 39 | // to a rematch request |
| 40 | |
| 41 | mainlabelcxx . . $ ResultDialog#mainlabel. = new QLabelcxx . . $ QLabel#(dispatchcxx . . $ ResultDialog#dispatch.->getOpponentNamecxx . . $ BoardDispatch#getOpponentName(4365c3963150523e).() +cxx . . $ operator+(fab9b4f80031f353). trcxx . . $ ResultDialog#tr(75d9f1c324b4579d).(" requests rematch")); |
| 42 | secondscxx . . $ ResultDialog#seconds. = 20; |
| 43 | okayButtoncxx . . $ ResultDialog#okayButton. = new QPushButtoncxx . . $ QPushButton#QPushButton(90d5708627041e22).(trcxx . . $ ResultDialog#tr(75d9f1c324b4579d).("&Accept?")); |
| 44 | acceptingcxx . . $ ResultDialog#accepting. = true; |
| 45 | } |
| 46 | else |
| 47 | { |
| 48 | acceptingcxx . . $ ResultDialog#accepting. = false; |
| 49 | if(dispatchcxx . . $ ResultDialog#dispatch.->supportsRematchcxx . . $ BoardDispatch#supportsRematch(c9857a73d68e59ba).()) |
| 50 | { |
| 51 | secondscxx . . $ ResultDialog#seconds. = 20; |
| 52 | /* We make them stare at message for 20 seconds */ |
| 53 | okayButtoncxx . . $ ResultDialog#okayButton. = new QPushButtoncxx . . $ QPushButton#QPushButton(90d5708627041e22).(trcxx . . $ ResultDialog#tr(75d9f1c324b4579d).("&Rematch?")); |
| 54 | dispatchcxx . . $ ResultDialog#dispatch.->setRematchDialogcxx . . $ BoardDispatch#setRematchDialog(916b84551040fc84).(this); |
| 55 | } |
| 56 | else |
| 57 | { |
| 58 | secondscxx . . $ ResultDialog#seconds. = 0; |
| 59 | okayButtoncxx . . $ ResultDialog#okayButton. = new QPushButtoncxx . . $ QPushButton#QPushButton(90d5708627041e22).(trcxx . . $ ResultDialog#tr(75d9f1c324b4579d).("&Okay")); |
| 60 | okayButtoncxx . . $ ResultDialog#okayButton.->setDefaultcxx . . $ QPushButton#setDefault(b45ddcbc8423892c).(true); |
| 61 | } |
| 62 | mainlabelcxx . . $ ResultDialog#mainlabel. = new QLabelcxx . . $ QLabel#(gr->longMessagecxx . . $ GameResult#longMessage(4365c3963150523e).()); |
| 63 | } |
| 64 | connectcxx . . $ QObject#connect(835f87066c895669).(okayButtoncxx . . $ ResultDialog#okayButton., &QPushButtoncxx . . $ QPushButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, &ResultDialogcxx . . $ ResultDialog#::slot_okaycxx . . $ ResultDialog#slot_okay(49f6e7a06ebc5aa8).); |
| 65 | |
| 66 | QGridLayoutcxx . . $ QGridLayout# * mainLayout = new QGridLayoutcxx . . $ QGridLayout#; |
| 67 | /*mainLayout->setSizeConstraint(QLayout::SetFixedSize);*/ |
| 68 | mainLayout->addWidgetcxx . . $ QGridLayout#addWidget(17d1465fab362e2d).(mainlabelcxx . . $ ResultDialog#mainlabel., 0, 0); |
| 69 | mainLayout->addWidgetcxx . . $ QGridLayout#addWidget(17d1465fab362e2d).(okayButtoncxx . . $ ResultDialog#okayButton., 1, 0); |
| 70 | setLayoutcxx . . $ QWidget#setLayout(23396b1058755fec).(mainLayout); |
| 71 | |
| 72 | |
| 73 | setWindowTitlecxx . . $ QWidget#setWindowTitle(3520e46b33348bf6).(trcxx . . $ ResultDialog#tr(75d9f1c324b4579d).("Game ") +cxx . . $ operator+(fab9b4f80031f353). QStringcxx . . $ QString#::numbercxx . . $ QString#number(da83c6b4fd8c0e98).(game_id)); |
| 74 | //setSizePolicy(QSizePolicy::Minimum); |
| 75 | // FIXME size? |
| 76 | resizecxx . . $ QWidget#resize(3e454b8ccf442868).(200, 100); |
| 77 | //setMinimumSize(QSize(300, 150)); |
| 78 | if(dispatchcxx . . $ ResultDialog#dispatch.->supportsRematchcxx . . $ BoardDispatch#supportsRematch(c9857a73d68e59ba).()) |
| 79 | startTimercxx . . $ QObject#startTimer(cf5d4a693bb15cf1).(1000); |
| 80 | } |
| 81 | |
| 82 | void ResultDialogcxx . . $ ResultDialog#::recvRematchRequestcxx . . $ ResultDialog#recvRematchRequest(49f6e7a06ebc5aa8).(void) |
| 83 | { |
| 84 | mainlabelcxx . . $ ResultDialog#mainlabel.->setTextcxx . . $ QLabel#setText(3520e46b33348bf6).(dispatchcxx . . $ ResultDialog#dispatch.->getOpponentNamecxx . . $ BoardDispatch#getOpponentName(4365c3963150523e).() +cxx . . $ operator+(fab9b4f80031f353). trcxx . . $ ResultDialog#tr(75d9f1c324b4579d).(" requests rematch")); |
| 85 | secondscxx . . $ ResultDialog#seconds. = 20; |
| 86 | okayButtoncxx . . $ ResultDialog#okayButton.->setTextcxx . . $ QAbstractButton#setText(3520e46b33348bf6).(trcxx . . $ ResultDialog#tr(75d9f1c324b4579d).("&Accept?")); |
| 87 | acceptingcxx . . $ ResultDialog#accepting. = true; |
| 88 | } |
| 89 | |
| 90 | void ResultDialogcxx . . $ ResultDialog#::timerEventcxx . . $ ResultDialog#timerEvent(b9e57d1150f23bf5).(QTimerEventcxx . . $ QTimerEvent#*) |
| 91 | { |
| 92 | // in case we need this? |
| 93 | if(secondscxx . . $ ResultDialog#seconds. == 1) |
| 94 | { |
| 95 | //what about sending a declineRematch?? if(accepting)?? |
| 96 | hidecxx . . $ QWidget#hide(49f6e7a06ebc5aa8).(); |
| 97 | deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).(); |
| 98 | } |
| 99 | else |
| 100 | secondscxx . . $ ResultDialog#seconds.--; |
| 101 | } |
| 102 | |
| 103 | void ResultDialogcxx . . $ ResultDialog#::closeEventcxx . . $ ResultDialog#closeEvent(642e80679aeb34f8).(QCloseEventcxx . . $ QCloseEvent# *) |
| 104 | { |
| 105 | /*if(dispatch) |
| 106 | dispatch->setRematchDialog(0);*/ |
| 107 | } |
| 108 | |
| 109 | ResultDialogcxx . . $ ResultDialog#::~cxx . . $ ResultDialog#`~ResultDialog`(ced63f7c635d850d).ResultDialogcxx . . $ ResultDialog#() |
| 110 | { |
| 111 | if(dispatchcxx . . $ ResultDialog#dispatch.) //here also in case no "closeEvent" |
| 112 | dispatchcxx . . $ ResultDialog#dispatch.->setRematchDialogcxx . . $ BoardDispatch#setRematchDialog(916b84551040fc84).(0); |
| 113 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("deleting result dialog"); |
| 114 | delete okayButtoncxx . . $ ResultDialog#okayButton.; |
| 115 | delete mainlabelcxx . . $ ResultDialog#mainlabel.; |
| 116 | } |
| 117 | |
| 118 | /* I'm assuming here that a close by time returns 0 */ |
| 119 | void ResultDialogcxx . . $ ResultDialog#::slot_okaycxx . . $ ResultDialog#slot_okay(49f6e7a06ebc5aa8).(void) |
| 120 | { |
| 121 | if(dispatchcxx . . $ ResultDialog#dispatch.->supportsRematchcxx . . $ BoardDispatch#supportsRematch(c9857a73d68e59ba).()) |
| 122 | { |
| 123 | if(acceptingcxx . . $ ResultDialog#accepting.) |
| 124 | dispatchcxx . . $ ResultDialog#dispatch.->sendRematchAcceptcxx . . $ BoardDispatch#sendRematchAccept(49f6e7a06ebc5aa8).(); |
| 125 | else |
| 126 | dispatchcxx . . $ ResultDialog#dispatch.->sendRematchRequestcxx . . $ BoardDispatch#sendRematchRequest(49f6e7a06ebc5aa8).(); |
| 127 | dispatchcxx . . $ ResultDialog#dispatch.->setRematchDialogcxx . . $ BoardDispatch#setRematchDialog(916b84551040fc84).(0); |
| 128 | qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("rematch slot okay"); |
| 129 | dispatchcxx . . $ ResultDialog#dispatch. = 0; |
| 130 | } |
| 131 | hidecxx . . $ QWidget#hide(49f6e7a06ebc5aa8).(); |
| 132 | deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).(); |
| 133 | // or should this be just done() |
| 134 | } |