Debian Codegraph @

src/game_interfaces/countdialog.cpp

raw symbols SCIP
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 "countdialog.h"cxx . . $ `<file>/src/game_interfaces/countdialog.h`/
26 #include "board/boardwindow.h"cxx . . $ `<file>/src/board/boardwindow.h`/
27 #include "../network/boarddispatch.h"cxx . . $ `<file>/src/network/boarddispatch.h`/
28 #include "tree.h"cxx . . $ `<file>/src/game_tree/tree.h`/
29 #include "qgoboard.h"cxx . . $ `<file>/src/game_interfaces/qgoboard.h`/
30
31 CountDialogcxx . . $ CountDialog#::CountDialogcxx . . $ CountDialog#CountDialog(71dd77c1ddb961da).(BoardWindowcxx . . $ BoardWindow# * parent, BoardDispatchcxx . . $ BoardDispatch# * dis, unsigned int game_id)
32 : QDialogcxx . . $ QDialog#QDialog(872e7b0c281abd8d).((QDialogcxx . . $ QDialog# *)parent), dispatchcxx . . $ CountDialog#dispatch.(dis), boardcxx . . $ CountDialog#board.(parent)
33 {
34 oppAcceptsCountcxx . . $ CountDialog#oppAcceptsCount. = 0;
35 oppRejectsCountcxx . . $ CountDialog#oppRejectsCount. = 0;
36 weAcceptCountcxx . . $ CountDialog#weAcceptCount. = 0;
37 weRejectCountcxx . . $ CountDialog#weRejectCount. = 0;
38
39 acceptButtoncxx . . $ CountDialog#acceptButton. = new QPushButtoncxx . . $ QPushButton#QPushButton(90d5708627041e22).(trcxx . . $ CountDialog#tr(75d9f1c324b4579d).("&Accept"));
40 //acceptButton->setDefault(true);
41 rejectButtoncxx . . $ CountDialog#rejectButton. = new QPushButtoncxx . . $ QPushButton#QPushButton(90d5708627041e22).(trcxx . . $ CountDialog#tr(75d9f1c324b4579d).("&Reject"));
42
43 if(!dispatchcxx . . $ CountDialog#dispatch.)
44 {
45 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("CountDialog called without board dispatch");
46 deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).();
47 return;
48 }
49 resultcxx . . $ CountDialog#result. = new GameResultcxx . . $ GameResult#(boardcxx . . $ CountDialog#board.->getTreecxx . . $ BoardWindow#getTree(b74f38e721d67691).()->retrieveScorecxx . . $ Tree#retrieveScore(ba5abcee0082dfc2).());
50 GameDatacxx . . $ GameData# * gamedata = boardcxx . . $ CountDialog#board.->getGameDatacxx . . $ BoardWindow#getGameData(f917540193955ea7).();
51 if(resultcxx . . $ CountDialog#result.->winner_colorcxx . . $ GameResult#winner_color. == stoneWhitecxx . . $ stoneWhite.)
52 {
53 resultcxx . . $ CountDialog#result.->winner_namecxx . . $ GameResult#winner_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). gamedata->white_namecxx . . $ GameData#white_name.;
54 resultcxx . . $ CountDialog#result.->loser_namecxx . . $ GameResult#loser_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). gamedata->black_namecxx . . $ GameData#black_name.;
55 }
56 else
57 {
58 resultcxx . . $ CountDialog#result.->winner_namecxx . . $ GameResult#winner_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). gamedata->black_namecxx . . $ GameData#black_name.;
59 resultcxx . . $ CountDialog#result.->loser_namecxx . . $ GameResult#loser_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). gamedata->white_namecxx . . $ GameData#white_name.;
60 }
61
62 mainlabelcxx . . $ CountDialog#mainlabel. = new QLabelcxx . . $ QLabel#(resultcxx . . $ CountDialog#result.->longMessagecxx . . $ GameResult#longMessage(4365c3963150523e).() +cxx . . $ operator+(3d22f08efddf8107).
63 "\nWhite has " +cxx . . $ operator+(fab9b4f80031f353). QStringcxx . . $ QString#::numbercxx . . $ QString#number(da83c6b4fd8c0e98).(gamedata->white_prisonerscxx . . $ GameData#white_prisoners.)
64 +cxx . . $ operator+(3d22f08efddf8107). " captures\nBlack has " +cxx . . $ operator+(fab9b4f80031f353).
65 QStringcxx . . $ QString#::numbercxx . . $ QString#number(da83c6b4fd8c0e98).(gamedata->black_prisonerscxx . . $ GameData#black_prisoners.) +cxx . . $ operator+(3d22f08efddf8107). " captures");
66 /* These needs to also post black and white captures and ultimate score
67 * FIXME */
68
69 buttonBoxcxx . . $ CountDialog#buttonBox. = new QDialogButtonBoxcxx . . $ QDialogButtonBox#(Qtcxx . . $ Qt/::Horizontalcxx . . $ Qt/Horizontal.);
70 buttonBoxcxx . . $ CountDialog#buttonBox.->addButtoncxx . . $ QDialogButtonBox#addButton(7ed195453ac96140).(acceptButtoncxx . . $ CountDialog#acceptButton., QDialogButtonBoxcxx . . $ QDialogButtonBox#::ActionRolecxx . . $ QDialogButtonBox#ActionRole.);
71 buttonBoxcxx . . $ CountDialog#buttonBox.->addButtoncxx . . $ QDialogButtonBox#addButton(7ed195453ac96140).(rejectButtoncxx . . $ CountDialog#rejectButton., QDialogButtonBoxcxx . . $ QDialogButtonBox#::ActionRolecxx . . $ QDialogButtonBox#ActionRole.);
72
73 connectcxx . . $ QObject#connect(835f87066c895669).(acceptButtoncxx . . $ CountDialog#acceptButton., &QPushButtoncxx . . $ QPushButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, &CountDialogcxx . . $ CountDialog#::slot_acceptcxx . . $ CountDialog#slot_accept(49f6e7a06ebc5aa8).);
74 connectcxx . . $ QObject#connect(835f87066c895669).(rejectButtoncxx . . $ CountDialog#rejectButton., &QPushButtoncxx . . $ QPushButton#::clickedcxx . . $ QAbstractButton#clicked(b45ddcbc8423892c)., this, &CountDialogcxx . . $ CountDialog#::slot_rejectcxx . . $ CountDialog#slot_reject(49f6e7a06ebc5aa8).);
75
76 QGridLayoutcxx . . $ QGridLayout# * mainLayout = new QGridLayoutcxx . . $ QGridLayout#;
77 /*mainLayout->setSizeConstraint(QLayout::SetFixedSize);*/
78 mainLayout->addWidgetcxx . . $ QGridLayout#addWidget(17d1465fab362e2d).(mainlabelcxx . . $ CountDialog#mainlabel., 0, 0);
79 mainLayout->addWidgetcxx . . $ QGridLayout#addWidget(17d1465fab362e2d).(buttonBoxcxx . . $ CountDialog#buttonBox., 1, 0);
80 setLayoutcxx . . $ QWidget#setLayout(23396b1058755fec).(mainLayout);
81
82
83 setWindowTitlecxx . . $ QWidget#setWindowTitle(3520e46b33348bf6).(QStringcxx . . $ QString#::numbercxx . . $ QString#number(da83c6b4fd8c0e98).(game_id) +cxx . . $ operator+(fab9b4f80031f353). trcxx . . $ CountDialog#tr(75d9f1c324b4579d).(": Accept result?"));
84 //setSizePolicy(QSizePolicy::Minimum);
85 // FIXME size?
86 resizecxx . . $ QWidget#resize(3e454b8ccf442868).(200, 100);
87 //setMinimumSize(QSize(300, 150));
88 showcxx . . $ QWidget#show(49f6e7a06ebc5aa8).();
89 }
90
91 CountDialogcxx . . $ CountDialog#::~cxx . . $ CountDialog#`~CountDialog`(ced63f7c635d850d).CountDialogcxx . . $ CountDialog#()
92 {
93 dispatchcxx . . $ CountDialog#dispatch.->clearCountDialogcxx . . $ BoardDispatch#clearCountDialog(49f6e7a06ebc5aa8).();
94 delete acceptButtoncxx . . $ CountDialog#acceptButton.;
95 delete rejectButtoncxx . . $ CountDialog#rejectButton.;
96 delete mainlabelcxx . . $ CountDialog#mainlabel.;
97 delete buttonBoxcxx . . $ CountDialog#buttonBox.;
98 delete resultcxx . . $ CountDialog#result.;
99 }
100
101 void CountDialogcxx . . $ CountDialog#::recvRejectCountcxx . . $ CountDialog#recvRejectCount(49f6e7a06ebc5aa8).()
102 {
103 oppRejectsCountcxx . . $ CountDialog#oppRejectsCount. = 1;
104 if(weRejectCountcxx . . $ CountDialog#weRejectCount. || weAcceptCountcxx . . $ CountDialog#weAcceptCount.)
105 {
106 /* Regardless of what happens, I think
107 * we have to restart the game, get back into it
108 * this may require sending clear stone messages
109 * or some other messsage and it definitely
110 * requires leaving score mode and starting
111 * any timers that may have stopped in addition
112 * to possibly deleting "pass" moves from the tree
113 * FIXME */
114 boardcxx . . $ CountDialog#board.->qgoboardcxx . . $ BoardWindow#qgoboard.->leaveScoreModecxx . . $ qGoBoard#leaveScoreMode(49f6e7a06ebc5aa8).();
115 deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).();
116 }
117 }
118
119 void CountDialogcxx . . $ CountDialog#::recvAcceptCountcxx . . $ CountDialog#recvAcceptCount(49f6e7a06ebc5aa8).()
120 {
121 oppAcceptsCountcxx . . $ CountDialog#oppAcceptsCount. = 1;
122 if(weRejectCountcxx . . $ CountDialog#weRejectCount.)
123 {
124 /* See above comment FIXME */
125 boardcxx . . $ CountDialog#board.->qgoboardcxx . . $ BoardWindow#qgoboard.->leaveScoreModecxx . . $ qGoBoard#leaveScoreMode(49f6e7a06ebc5aa8).();
126 deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).();
127 }
128 else if(weAcceptCountcxx . . $ CountDialog#weAcceptCount.)
129 {
130 /* This means we notify network connection
131 * to send any necessary game result messages FIXME */
132 dispatchcxx . . $ CountDialog#dispatch.->recvResultcxx . . $ BoardDispatch#recvResult(c72a8b5aed169521).(resultcxx . . $ CountDialog#result.);
133 dispatchcxx . . $ CountDialog#dispatch.->sendResultcxx . . $ BoardDispatch#sendResult(c72a8b5aed169521).(resultcxx . . $ CountDialog#result.);
134 //board->qgoboard->setResult(*result);
135 deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).();
136 }
137 }
138
139 /* We're not going to delete the countdialog immediately
140 * but instead let it keep track of things... I don't
141 * really know why... I guess because this is a dialog
142 * for counting and its light so why not have it do
143 * something besides displaying info and a couple
144 * buttons */
145 void CountDialogcxx . . $ CountDialog#::slot_acceptcxx . . $ CountDialog#slot_accept(49f6e7a06ebc5aa8).(void)
146 {
147 weAcceptCountcxx . . $ CountDialog#weAcceptCount. = 1;
148 dispatchcxx . . $ CountDialog#dispatch.->sendAcceptCountcxx . . $ BoardDispatch#sendAcceptCount(49f6e7a06ebc5aa8).();
149 hidecxx . . $ QWidget#hide(49f6e7a06ebc5aa8).();
150 if(oppRejectsCountcxx . . $ CountDialog#oppRejectsCount.)
151 {
152 /* See above comment FIXME */
153 boardcxx . . $ CountDialog#board.->qgoboardcxx . . $ BoardWindow#qgoboard.->leaveScoreModecxx . . $ qGoBoard#leaveScoreMode(49f6e7a06ebc5aa8).();
154 deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).();
155 }
156 else if(oppAcceptsCountcxx . . $ CountDialog#oppAcceptsCount.)
157 {
158 /* See above comment FIXME */
159 dispatchcxx . . $ CountDialog#dispatch.->recvResultcxx . . $ BoardDispatch#recvResult(c72a8b5aed169521).(resultcxx . . $ CountDialog#result.);
160 dispatchcxx . . $ CountDialog#dispatch.->sendResultcxx . . $ BoardDispatch#sendResult(c72a8b5aed169521).(resultcxx . . $ CountDialog#result.);
161 //board->qgoboard->setResult(*result);
162 deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).();
163 }
164 }
165
166 void CountDialogcxx . . $ CountDialog#::slot_rejectcxx . . $ CountDialog#slot_reject(49f6e7a06ebc5aa8).(void)
167 {
168 weRejectCountcxx . . $ CountDialog#weRejectCount. = 1;
169 dispatchcxx . . $ CountDialog#dispatch.->sendRejectCountcxx . . $ BoardDispatch#sendRejectCount(49f6e7a06ebc5aa8).();
170 hidecxx . . $ QWidget#hide(49f6e7a06ebc5aa8).();
171 if(oppRejectsCountcxx . . $ CountDialog#oppRejectsCount. || oppAcceptsCountcxx . . $ CountDialog#oppAcceptsCount.)
172 {
173 /* See above comment FIXME */
174 boardcxx . . $ CountDialog#board.->qgoboardcxx . . $ BoardWindow#qgoboard.->leaveScoreModecxx . . $ qGoBoard#leaveScoreMode(49f6e7a06ebc5aa8).();
175 deleteLatercxx . . $ QObject#deleteLater(49f6e7a06ebc5aa8).();
176 }
177 }