1 /* This file is part of KsirK.
2 Copyright (C) 2001-2007 Gael de Chalendar (aka Kleag) <kleag@free.fr>
3
4 KsirK is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public
6 License as published by the Free Software Foundation, either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA
18 */
19
20 // application specific includes
21 #include "kgamewin.h"
22 #include "ksirksettings.h"
23 #include "newgamesetup.h"
24 #include "Sprites/backgnd.h"
25 #include "Sprites/arrowsprite.h"
26 #include "Dialogs/newGameSummaryWidget.h"
27 #include "GameLogic/newplayerdata.h"
28
29 #include <KAboutApplicationDialog>
30 #include <KToolBar>
31
32 #include "GameLogic/KMessageParts.h"
33 #include "GameLogic/gameautomaton.h"
34 #include "GameLogic/country.h"
35 #include "GameLogic/onu.h"
36 #include "GameLogic/goal.h"
37 #include "SaveLoad/ksirkgamexmlloader.h"
38 #include "Sprites/animspritesgroup.h"
39 #include "Dialogs/jabbergameui.h"
40 #include "Dialogs/kplayersetupwidget.h"
41 #include "Jabber/kmessagejabber.h"
42
43 #define USE_UNSTABLE_LIBKDEGAMESPRIVATE_API
44 #include <libkdegamesprivate/kgame/kmessageserver.h>
45
46 // STL include files
47 #include <fstream>
48
49 // include files for QT
50 #include <QCursor>
51 #include <QScrollBar>
52 #include <QUuid>
53 #include <QTextStream>
54 #include <QInputDialog>
55 #include <QFileDialog>
56 #include <QUrl>
57
58 // include files for KDE
59 #include <KLocalizedString>
60 #include <KConfig>
61 #include "ksirk_debug.h"
62 #include <KMessageBox>
63 #include <KGamePopupItem>
64 #include <KPasswordDialog>
65 #include <tcpconnectwidget.h>
66
67 namespace Ksirk
68 {
69 using namespace GameLogic;
70
71 // void KGameWindow::slotTimerEvent()
mouseMoveEvent(QMouseEvent * event)72 void KGameWindow::mouseMoveEvent ( QMouseEvent * event )
73 {
74 // qCDebug(KSIRK_LOG);
75 QString countryName;
76 QPoint mousePos;
77 QPoint mousePosGlobal;
78 QPointF mousePosition;
79 Country *mouseLocalisation;
80
81 if (m_frame == 0 || m_reinitializingGame)
82 {
83 return;
84 }
85 mousePosGlobal = event->globalPos();
86 mousePos = m_frame->mapFromGlobal(mousePosGlobal);
87 mousePosition = m_frame->mapToScene(mousePos);
88 mouseLocalisation = clickIn(mousePosition);
89 countryName = (mouseLocalisation) ? mouseLocalisation->name() : "";
90 if (mouseLocalisation)
91 {
92 if (m_mouseLocalisation && m_mouseLocalisation!=mouseLocalisation)
93 {
94 m_mouseLocalisation->clearHighlighting();
95 m_mouseLocalisation = mouseLocalisation;
96 mouseLocalisation->highlight(Qt::white, 0.5);
97 }
98 else if (m_mouseLocalisation == 0)
99 {
100 m_mouseLocalisation = mouseLocalisation;
101 mouseLocalisation->highlight(Qt::white, 0.5);
102 }
103 if (!countryName.isEmpty())
104 {
105 QString status1Text = "";
106 const Player* player = mouseLocalisation-> owner();
107 if (player)
108 {
109 status1Text = i18np("%2 belongs to %3. 1 army.","%2 belongs to %3. %1 armies.",mouseLocalisation->nbArmies(),i18n(countryName.toUtf8().data()),player->name());
110 }
111
112 //QT5 statusBar()-> changeItem(status1Text, ID_STATUS_MSG);
113 }
114 }
115 else
116 {
117 if (m_mouseLocalisation!=0)
118 {
119 m_mouseLocalisation->clearHighlighting();
120 m_mouseLocalisation = 0;
121 }
122 //QT5 statusBar()-> changeItem("", ID_STATUS_MSG); // Reset
123 }
124 int borderScrollSize = 50;
125 if ( (!m_timer.isActive())
126 && ( ((mousePos.x() < borderScrollSize) && (mousePos.x() >= 0)
127 && (mousePos.y() >= 0) && (mousePos.y() <= m_frame-> viewport()->height()))
128 || ((mousePos.x() > m_frame->viewport()->width() -borderScrollSize) &&
129 (mousePos.x() <= m_frame-> viewport()->width())
130 && (mousePos.y() >= 0) && (mousePos.y() <= m_frame-> viewport()->height()))
131 || ((mousePos.y() < borderScrollSize) && (mousePos.y() >= 0)
132 && (mousePos.x() >= 0) && (mousePos.x() <= m_frame-> viewport()->width()))
133 || ((mousePos.y() > m_frame-> viewport()->height() -borderScrollSize) &&
134 (mousePos.y() <= m_frame-> viewport()->height())
135 && (mousePos.x() >= 0) && (mousePos.x() <= m_frame-> viewport()->width()))
136 )
137 )
138 // safety check for NULL arrow pointers, can happen with Qt 4.5
139 if (m_uparrow == 0 || m_downarrow == 0 || m_leftarrow == 0 || m_rightarrow == 0)
140 {
141 return;
142 }
143 if (currentWidget() != 0)
144 {
145 m_timer.start(200);
146 if ((mousePos.y() < borderScrollSize) && (mousePos.y() >= 0)
147 && (mousePos.x() >= 0) && (mousePos.x() <= m_frame-> viewport()->width()))
148 {
149 QPointF pos = currentWidget()->mapToScene(QPoint(m_frame->viewport()->width()/2,0));
150 pos = pos + QPointF(-(m_uparrow->boundingRect().width()/2),m_uparrow->boundingRect().height());
151 m_uparrow->setPos(pos);
152 m_uparrow->setActive(true);
153 }
154 if ((mousePos.y() > m_frame->viewport()->height() -borderScrollSize) &&
155 (mousePos.y() <= m_frame->viewport()->height())
156 && (mousePos.x() >= 0) && (mousePos.x() <= m_frame-> viewport()->width()))
157 {
158 QPointF pos = currentWidget()->mapToScene(QPoint(m_frame->viewport()->width()/2,m_frame->viewport()->height()));
159 pos = pos - QPointF(m_downarrow->boundingRect().width()/2,m_downarrow->boundingRect().height());
160 m_downarrow->setPos(pos);
161 m_downarrow->setActive(true);
162 }
163 if ((mousePos.x() < borderScrollSize) && (mousePos.x() >= 0)
164 && (mousePos.y() >= 0) && (mousePos.y() <= m_frame-> viewport()->height()))
165 {
166 QPointF pos = currentWidget()->mapToScene(QPoint(0,m_frame->viewport()->height()/2));
167 pos = pos + QPointF(m_leftarrow->boundingRect().width(),-(m_leftarrow->boundingRect().height()/2));
168 m_leftarrow->setPos(pos);
169 m_leftarrow->setActive(true);
170 }
171 if ((mousePos.x() > m_frame->viewport()->width() -borderScrollSize) &&
172 (mousePos.x() <= m_frame-> viewport()->width())
173 && (mousePos.y() >= 0) && (mousePos.y() <= m_frame-> viewport()->height()))
174 {
175 QPointF pos = currentWidget()->mapToScene(QPoint(m_frame->viewport()->width(),m_frame->viewport()->height()/2));
176 pos = pos - QPointF(m_rightarrow->boundingRect().width(),m_rightarrow->boundingRect().height()/2);
177 m_rightarrow->setPos(pos);
178 m_rightarrow->setActive(true);
179 m_rightarrow->update();
180 }
181 }
182 if (m_frame && m_frame->horizontalScrollBar()->value() == m_frame->horizontalScrollBar()->maximum())
183 {
184 m_rightarrow->hide();
185 }
186 else
187 {
188 m_rightarrow->show();
189 }
190 if (m_frame && m_frame->verticalScrollBar()->value() == m_frame->verticalScrollBar()->maximum())
191 {
192 m_downarrow->hide();
193 }
194 else
195 {
196 m_downarrow->show();
197 }
198 if (m_frame && m_frame->verticalScrollBar()->value() == m_frame->verticalScrollBar()->minimum())
199 {
200 m_uparrow->hide();
201 }
202 else
203 {
204 m_uparrow->show();
205 }
206 }
207
evenementTimer()208 void KGameWindow::evenementTimer()
209 { //Appel du Timer toutes les 50 ms
210 QPoint mousePos;
211 QPointF mousePosition;
212
213 // qCDebug(KSIRK_LOG) << "KGameWindow::evenementTimer";
214 mousePos = QCursor::pos();
215 mousePosition = m_frame-> mapFromGlobal(mousePos);
216 // qCDebug(KSIRK_LOG) << "mousePosition = ( " << mousePosition.x() << " , " << mousePosition.y() << " )";
217 // qCDebug(KSIRK_LOG) << "m_frame = ( " << m_frame-> viewport()->width() << " , " << m_frame-> viewport()->height() << " )";
218
219 bool restart = false;
220 int borderScrollSize = 50;
221 int borderScrollSpeed = 40;
222 if ((mousePosition.x() < borderScrollSize) && (mousePosition.x() >= 0)
223 && (mousePosition.y() >= 0) && (mousePosition.y() <= m_frame-> viewport()->height()))
224 {
225 // qCDebug(KSIRK_LOG) << "scrollRight";
226 m_frame->horizontalScrollBar()->setValue(m_frame->horizontalScrollBar()->value() - borderScrollSpeed);
227 if (m_frame->horizontalScrollBar()->value() == m_frame->horizontalScrollBar()->minimum())
228 {
229 m_leftarrow->hide();
230 }
231 else
232 {
233 m_leftarrow->show();
234 }
235 m_leftarrow->setActive(true);
236 restart = true;
237 }
238 else
239 {
240 m_leftarrow->setActive(false);
241 }
242 QPointF pos = currentWidget()->mapToScene(QPoint(0,m_frame->viewport()->height()/2));
243 pos = pos + QPointF(m_leftarrow->boundingRect().width(),-(m_leftarrow->boundingRect().height()/2));
244 m_leftarrow->setPos(pos);
245
246 if ((mousePosition.x() > m_frame-> viewport()->width() -borderScrollSize) &&
247 (mousePosition.x() <= m_frame-> viewport()->width())
248 && (mousePosition.y() >= 0) && (mousePosition.y() <= m_frame-> viewport()->height()))
249 {
250 // qCDebug(KSIRK_LOG) << "scrollLeft";
251 m_frame-> horizontalScrollBar()->setValue ( m_frame-> horizontalScrollBar()->value() + borderScrollSpeed);
252 m_rightarrow->setActive(true);
253 m_rightarrow->update();
254 restart = true;
255 }
256 else
257 {
258 m_rightarrow->setActive(false);
259 }
260 pos = currentWidget()->mapToScene(QPoint(m_frame->viewport()->width(),m_frame->viewport()->height()/2));
261 pos = pos - QPointF(m_rightarrow->boundingRect().width(),m_rightarrow->boundingRect().height()/2);
262 m_rightarrow->setPos(pos);
263
264 if ((mousePosition.y() < borderScrollSize) && (mousePosition.y() >= 0)
265 && (mousePosition.x() >= 0) && (mousePosition.x() <= m_frame-> viewport()->width()))
266 {
267 // qCDebug(KSIRK_LOG) << "scrollDown";
268 m_frame-> verticalScrollBar()->setValue ( m_frame-> verticalScrollBar()->value() - borderScrollSpeed);
269 m_uparrow->setActive(true);
270 restart = true;
271 }
272 else
273 {
274 m_uparrow->setActive(false);
275 }
276 pos = currentWidget()->mapToScene(QPoint(m_frame->viewport()->width()/2,0));
277 pos = pos + QPointF(-(m_uparrow->boundingRect().width()/2),m_uparrow->boundingRect().height());
278 m_uparrow->setPos(pos);
279
280 if ((mousePosition.y() > m_frame-> viewport()->height() -borderScrollSize) &&
281 (mousePosition.y() <= m_frame-> viewport()->height())
282 && (mousePosition.x() >= 0) && (mousePosition.x() <= m_frame-> viewport()->width()))
283 {
284 // qCDebug(KSIRK_LOG) << "scrollUp " << m_frame-> verticalScrollBar()->value()
285 // << "("<< m_frame-> verticalScrollBar()->minimum()
286 // << ", " << m_frame-> verticalScrollBar()->maximum() << ")";
287 m_frame-> verticalScrollBar()->setValue ( m_frame-> verticalScrollBar()->value() + borderScrollSpeed);
288 m_downarrow->setActive(true);
289 restart = true;
290 }
291 else
292 {
293 m_downarrow->setActive(false);
294 }
295 pos = currentWidget()->mapToScene(QPoint(m_frame->viewport()->width()/2,m_frame->viewport()->height()));
296 pos = pos - QPointF(m_downarrow->boundingRect().width()/2,m_downarrow->boundingRect().height());
297 m_downarrow->setPos(pos);
298
299 if ( m_animFighters->isEmpty() )
300 {
301 if ( m_secondCountry && !( m_secondCountry-> owner() ) )
302 qCCritical(KSIRK_LOG) << m_secondCountry-> name() << " does not belong to anybody !";
303 // handling of the AI player actions
304 /*if ( !( ( ( currentPlayer() && currentPlayer()-> isAI() )
305 || ( ( isMyState(GameLogic::GameAutomaton::WAITDEFENSE) ) && ( m_secondCountry ) && (m_secondCountry->owner())
306 && ( m_secondCountry->owner()->isAI() ) ) ) ) ) {
307 toolBar("gameActionsToolBar")-> show();
308 }*/
309 }
310
311 if (m_frame->horizontalScrollBar()->value() == m_frame->horizontalScrollBar()->minimum())
312 {
313 m_leftarrow->hide();
314 }
315 else
316 {
317 m_leftarrow->show();
318 }
319 if (m_frame->horizontalScrollBar()->value() == m_frame->horizontalScrollBar()->maximum())
320 {
321 m_rightarrow->hide();
322 }
323 else
324 {
325 m_rightarrow->show();
326 }
327 if (m_frame->verticalScrollBar()->value() == m_frame->verticalScrollBar()->maximum())
328 {
329 m_downarrow->hide();
330 }
331 else
332 {
333 m_downarrow->show();
334 }
335 if (m_frame->verticalScrollBar()->value() == m_frame->verticalScrollBar()->minimum())
336 {
337 m_uparrow->hide();
338 }
339 else
340 {
341 m_uparrow->show();
342 }
343
344 // qCDebug(KSIRK_LOG) << "OUT KGameWindow::evenementTimer";
345 if (restart)
346 {
347 // qCDebug(KSIRK_LOG) << "restarting timer";
348 m_timer.start(200);
349 }
350 }
351
slotLeftButtonDown(const QPointF & point)352 void KGameWindow::slotLeftButtonDown(const QPointF& point)
353 {
354 // qCDebug(KSIRK_LOG) << "slotLeftButtonDown";
355 // if (currentPlayer() && !(currentPlayer()-> isAI()) )
356 m_automaton->gameEvent("actionLButtonDown", point);
357 }
358
slotLeftButtonUp(const QPointF & point)359 void KGameWindow::slotLeftButtonUp(const QPointF& point)
360 {
361 // qCDebug(KSIRK_LOG) << "slotLeftButtonUp";
362 // if (currentPlayer() && ! (currentPlayer()-> isAI()) )
363 m_automaton->gameEvent("actionLButtonUp", point);
364 }
365
slotRightButtonDown(const QPointF & point)366 void KGameWindow::slotRightButtonDown(const QPointF& point)
367 {
368 qCDebug(KSIRK_LOG);
369 // if (currentPlayer() && ! (currentPlayer()-> isAI()) )
370 m_automaton->gameEvent("actionRButtonDown", point);
371 return;
372 }
373
slotRightButtonUp(const QPointF & point)374 void KGameWindow::slotRightButtonUp(const QPointF& point)
375 {
376 qCDebug(KSIRK_LOG);
377 // if (currentPlayer() && ! (currentPlayer()-> isAI()) )
378 m_automaton->gameEvent("actionRButtonUp", point);
379 return;
380 }
381
slotArena(bool isCheck)382 void KGameWindow::slotArena(bool isCheck)
383 {
384 if (isCheck)
385 {
386 m_useArena = true;
387 qCDebug(KSIRK_LOG) << "*******Arena On******" << m_useArena;
388 }
389 else
390 {
391 m_useArena = false;
392 qCDebug(KSIRK_LOG) << "*******Arena Off******" << m_useArena;
393 }
394 }
395
slotJabberGame()396 void KGameWindow::slotJabberGame()
397 {
398 m_jabberGameWidget->init(m_automaton);
399 m_jabberGameWidget->setPreviousGuiIndex(m_centralWidget->currentIndex());
400 m_centralWidget->setCurrentIndex(JABBERGAME_INDEX);
401 }
402
slotNewGame()403 void KGameWindow::slotNewGame()
404 {
405 // qCDebug(KSIRK_LOG) << "Slot new game: posting event actionNewGame";
406 actionNewGame(GameAutomaton::None);
407 }
408
slotNewJabberGame()409 void KGameWindow::slotNewJabberGame()
410 {
411 actionNewGame(GameAutomaton::Jabber);
412 }
413
slotNewSocketGame()414 void KGameWindow::slotNewSocketGame()
415 {
416 // qCDebug(KSIRK_LOG) << "Slot new game: posting event actionNewGame";
417 // QPoint point;
418 actionNewGame(GameAutomaton::Socket);
419
420 /// @TODO set the state to init when new game is started
421 /* if (actionNewGame())
422 {
423 m_automaton->state(GameAutomaton::INIT);
424 }*/
425 // m_automaton->gameEvent("actionNewGame", point);
426 }
427
slotOpenGame()428 void KGameWindow::slotOpenGame()
429 {
430 qCDebug(KSIRK_LOG) << "Slot open game: posting event actionOpenGame";
431 QPoint point;
432 m_automaton->gameEvent("actionOpenGame", point);
433 // actionOpenGame();
434 }
435
slotSaveGame()436 void KGameWindow::slotSaveGame()
437 {
438 if (m_message == 0)
439 {
440 setupPopupMessage();
441 }
442 if (m_automaton->isAdmin())
443 {
444 if (isMyState(GameLogic::GameAutomaton::WAITDEFENSE))
445 {
446 m_message->setMessageTimeout(3000);
447 m_message->showMessage(i18n("Cannot save when waiting for a defense."),
448 KGamePopupItem::TopLeft,
449 KGamePopupItem::ReplacePrevious);
450 return;
451 }
452 if (m_fileName.isEmpty())
453 {
454 QString fileName = QFileDialog::getSaveFileName (this, i18nc("@title:window", "KsirK - Save Game"), QString(), "*.xml");
455 if ( QFile::exists(fileName)
456 && (KMessageBox::questionYesNo (this,
457 i18n("%1 exists.\nDo you really want to overwrite it?",fileName),
458 i18n("Overwrite file?")) == KMessageBox::No) )
459 {
460 m_message->setMessageTimeout(3000);
461 m_message->showMessage(i18n("Saving canceled"), KGamePopupItem::TopLeft,
462 KGamePopupItem::ReplacePrevious);
463 return;
464 }
465 m_fileName = fileName;
466 }
467 if (!m_fileName.isEmpty())
468 {
469 QFile file(m_fileName);
470 file.open(QIODevice::WriteOnly);
471 QTextStream ofs(&file);
472 ofs.setCodec("UTF-8");
473 saveXml(ofs);
474 m_message->setMessageTimeout(3000);
475 m_message->showMessage(i18n("Game saved to %1",m_fileName),
476 KGamePopupItem::TopLeft, KGamePopupItem::ReplacePrevious);
477 }
478 }
479 else
480 {
481 m_message->setMessageTimeout(3000);
482 m_message->showMessage(
483 i18n("Only game master can save the game in network playing."),
484 KGamePopupItem::TopLeft, KGamePopupItem::ReplacePrevious);
485 }
486 }
487
slotRecycling()488 void KGameWindow::slotRecycling()
489 {
490 qCDebug(KSIRK_LOG);
491 QPoint point;
492 m_automaton->gameEvent("actionRecycling", point);
493 }
494
slotRecyclingFinished()495 void KGameWindow::slotRecyclingFinished()
496 {
497 qCDebug(KSIRK_LOG);
498 QPoint point;
499 m_rightDock->hide();
500 m_automaton->gameEvent("actionRecyclingFinished", point);
501 }
502
slotNextPlayer()503 void KGameWindow::slotNextPlayer()
504 {
505 qCDebug(KSIRK_LOG);
506 QPoint point;
507 m_automaton->gameEvent("actionNextPlayer", point);
508 }
509
slotAttack1()510 void KGameWindow::slotAttack1()
511 {
512 QPoint point;
513 m_automaton->gameEvent("actionAttack1", point);
514 }
515
slotAttack2()516 void KGameWindow::slotAttack2()
517 {
518 QPoint point;
519 m_automaton->gameEvent("actionAttack2", point);
520 }
521
slotAttack3()522 void KGameWindow::slotAttack3()
523 {
524 QPoint point;
525 m_automaton->gameEvent("actionAttack3", point);
526 }
527
slotDefense1()528 void KGameWindow::slotDefense1()
529 {
530 QPoint point;
531 m_automaton->gameEvent("actionDefense1", point);
532 }
533
slotDefense2()534 void KGameWindow::slotDefense2()
535 {
536 QPoint point;
537 m_automaton->gameEvent("actionDefense2", point);
538 }
539
slotInvade1()540 void KGameWindow::slotInvade1()
541 {
542 QPoint point;
543 m_automaton->gameEvent("actionInvade1", point);
544 }
545
slotInvade5()546 void KGameWindow::slotInvade5()
547 {
548 QPoint point;
549 m_automaton->gameEvent("actionInvade5", point);
550 }
551
slotInvade10()552 void KGameWindow::slotInvade10()
553 {
554 QPoint point;
555 m_automaton->gameEvent("actionInvade10", point);
556 }
557
slotInvasionFinished()558 void KGameWindow::slotInvasionFinished()
559 {
560 QPoint point;
561 m_automaton->gameEvent("actionInvasionFinished", point);
562 }
563
slotRetreat1()564 void KGameWindow::slotRetreat1()
565 {
566 QPoint point;
567 m_automaton->gameEvent("actionRetreat1", point);
568 }
569
slotRetreat5()570 void KGameWindow::slotRetreat5()
571 {
572 QPoint point;
573 m_automaton->gameEvent("actionRetreat5", point);
574 }
575
slotRetreat10()576 void KGameWindow::slotRetreat10()
577 {
578 QPoint point;
579 m_automaton->gameEvent("actionRetreat10", point);
580 }
581
slotMove()582 void KGameWindow::slotMove()
583 {
584 QPoint point;
585 m_automaton->gameEvent("actionMove", point);
586 }
587
slotCancel()588 void KGameWindow::slotCancel()
589 {
590 QPoint point;
591 m_automaton->gameEvent("actionCancel", point);
592 }
593
slotDumpGameInformations()594 void KGameWindow::slotDumpGameInformations()
595 {
596 // qCDebug(KSIRK_LOG) << "Game information : ";
597 // qCDebug(KSIRK_LOG) << " state : " << GameStateNames[getState()];
598 // qCDebug(KSIRK_LOG) << " current player : "
599 // << ((currentPlayer()) ? currentPlayer()-> name() : "nobody");
600 }
601
slotFinishMoves()602 void KGameWindow::slotFinishMoves()
603 {
604 qCDebug(KSIRK_LOG);
605 QByteArray buffer;
606 QDataStream stream(&buffer, QIODevice::WriteOnly);
607 m_automaton->sendMessage(buffer,FinishMoves);
608 }
609
slotShowAboutApplication()610 void KGameWindow::slotShowAboutApplication()
611 {
612 //qCDebug(KSIRK_LOG) << "Dans mon About !";
613
614 /* KAboutApplication kAA;
615 kAA.exec();*/
616 #if 0 //QT5
617 KAboutApplicationDialog dialog(KGlobal::mainComponent().aboutData(), this);
618 dialog.exec();
619 #endif
620 }
621
slotJoinNetworkGame()622 void KGameWindow::slotJoinNetworkGame()
623 {
624 qCDebug(KSIRK_LOG);
625 QPoint point;
626 m_automaton->gameEvent("actionJoinNetworkGame", point);
627 }
628
slotConnectToServer()629 void KGameWindow::slotConnectToServer()
630 {
631 qCDebug(KSIRK_LOG);
632 m_newGameSetup->setHost(m_tcpConnectWidget->hostEdit->text());
633 m_newGameSetup->setTcpPort(m_tcpConnectWidget->portEdit->value());
634 m_automaton->setGameStatus(KGame::End);
635 m_reinitializingGame = true;
636
637 if (!(m_automaton->playerList()->isEmpty()))
638 {
639 m_automaton->playerList()->clear();
640 m_automaton->currentPlayer(0);
641 qCDebug(KSIRK_LOG) << " playerList size = " << m_automaton->playerList()->count();
642 }
643 theWorld()->reset();
644
645 m_automaton->connectToServ();
646 }
647
slotShowGoal()648 void KGameWindow::slotShowGoal()
649 {
650 qCDebug(KSIRK_LOG);
651 if (currentPlayer() && !currentPlayer()->isVirtual()
652 && !currentPlayer()->isAI())
653 {
654 currentPlayer()->goal().show(GameLogic::Goal::GoalDesc|GameLogic::Goal::GoalAdvance);
655 }
656 }
657
slotChatMessage()658 void KGameWindow::slotChatMessage()
659 {
660 setFocus();
661 }
662
slotChatFloatButtonPressed()663 void KGameWindow::slotChatFloatButtonPressed()
664 {
665 // change the floating state
666 m_bottomDock->setFloating(!m_bottomDock->isFloating());
667 }
668
slotChatFloatChanged(bool)669 void KGameWindow::slotChatFloatChanged(bool /*value*/)
670 {
671 // change the float button image
672 if (!m_bottomDock->isFloating())
673 {
674 m_floatChatButton->setIcon(m_upChatFloatPix);
675 }
676 else
677 {
678 m_floatChatButton->setIcon(m_downChatFloatPix);
679 }
680 }
681
slotChatReduceButton()682 void KGameWindow::slotChatReduceButton()
683 {
684 qCDebug(KSIRK_LOG);
685
686 // change the reduce button image, hide or show the chat and the short last message
687 if (!m_chatIsReduced)
688 {
689 reduceChat();
690 }
691 else
692 {
693 unreduceChat();
694 }
695 }
696
slotMovingFightersArrived(AnimSpritesGroup * sprites)697 void KGameWindow::slotMovingFightersArrived(AnimSpritesGroup* sprites)
698 {
699 Q_UNUSED(sprites)
700 qCDebug(KSIRK_LOG);
701 m_automaton->movingFigthersArrived();
702 }
703
slotMovingArmiesArrived(AnimSpritesGroup * sprites)704 void KGameWindow::slotMovingArmiesArrived(AnimSpritesGroup* sprites)
705 {
706 qCDebug(KSIRK_LOG);
707 AnimSpritesGroup::iterator it, it_end;
708 it = sprites->begin(); it_end = sprites->end();
709 for (; it != it_end; it++)
710 {
711 (*it)->hide();
712 (*it)->deleteLater();
713 }
714 sprites->clear();
715 int index = m_animSpritesGroups.indexOf(sprites);
716 if (index != -1)
717 {
718 m_animSpritesGroups.removeAt(index);
719 }
720 sprites->deleteLater();
721 KMessageParts messageParts;
722 broadcastChangeItem(messageParts, ID_STATUS_MSG2, false);
723 }
724
slotBring(AnimSprite *)725 void KGameWindow::slotBring(AnimSprite* /*sprite*/)
726 {
727 m_automaton->game()->stopExplosion();
728 }
729
slotMovingArmyArrived(AnimSprite * sprite)730 void KGameWindow::slotMovingArmyArrived(AnimSprite* sprite)
731 {
732 qCDebug(KSIRK_LOG);
733 sprite->setStatic();
734 sprite->hide();
735 m_automaton->movingArmyArrived(sprite->getDestination(),
736 ((ArmySprite*)sprite)->nbArmies());
737 }
738
slotFiringFinished(AnimSpritesGroup * sprites)739 void KGameWindow::slotFiringFinished(AnimSpritesGroup* sprites)
740 {
741 Q_UNUSED(sprites)
742 qCDebug(KSIRK_LOG);
743 m_automaton->firingFinished();
744 }
745
slotExplosionFinished(AnimSpritesGroup * sprites)746 void KGameWindow::slotExplosionFinished(AnimSpritesGroup* sprites)
747 {
748 qCDebug(KSIRK_LOG);
749 while (!sprites->empty())
750 {
751 AnimSprite* sprite = sprites->front();
752 sprites->pop_front();
753 sprite->setStatic();
754 sprite->deleteLater();
755 }
756
757 if (backGnd()->bgIsArena())
758 {
759 m_automaton->game()->initCombatBringBackForArena(m_automaton->game()->firstCountry(), m_automaton->game()->secondCountry());
760 }
761
762 m_automaton->explosionFinished();
763 qCDebug(KSIRK_LOG)<<"DONE";
764 }
765
slotZoomIn()766 void KGameWindow::slotZoomIn()
767 {
768 qCDebug(KSIRK_LOG);
769 m_theWorld->applyZoomFactorFast(1.1); //Call to the fast method (benj)
770 m_frame->setMaximumSize(m_theWorld->width(),m_theWorld->height());
771 m_scene_world->setSceneRect ( QRectF() );
772 m_frame->updateGeometry();
773 m_backGnd_world->setPixmap(m_theWorld->map());
774
775 }
776
slotZoomOut()777 void KGameWindow::slotZoomOut()
778 {
779 qCDebug(KSIRK_LOG);
780 m_theWorld->applyZoomFactorFast(1.0/1.1); //call to the fast method
781 m_frame->setMaximumSize(m_theWorld->width(),m_theWorld->height());
782 m_scene_world->setSceneRect ( QRectF() );
783 m_frame->updateGeometry();
784 m_backGnd_world->setPixmap(m_theWorld->map());
785 }
786
slotRemoveMessage()787 void KGameWindow::slotRemoveMessage()
788 {
789 qCDebug(KSIRK_LOG);
790 if (m_message != 0)
791 {
792 qCDebug(KSIRK_LOG) << "hiding and deleting";
793 m_message->hide();
794 delete m_message;
795 m_message = 0;
796 }
797 }
798
slotContextualHelp()799 void KGameWindow::slotContextualHelp()
800 {
801 qCDebug(KSIRK_LOG);
802 if (currentPlayer() == 0 || currentPlayer()->isAI())
803 {
804 return;
805 }
806 switch (m_automaton->state())
807 {
808 case GameLogic::GameAutomaton::WAIT:
809 showMessage(i18n("Attack by drag & drop between countries<br>Move armies the same way (last action of a turn)."), 5);
810 break;
811 case GameLogic::GameAutomaton::NEWARMIES:
812 case GameLogic::GameAutomaton::INTERLUDE:
813 showMessage(i18n("Now, place your armies in your countries<br>by clicking in the target countries."));
814 break;
815 default:;
816 }
817 }
818
slotDisableHelp(const QString & link)819 void KGameWindow::slotDisableHelp(const QString & link)
820 {
821 qCDebug(KSIRK_LOG) << link;
822 KsirkSettings::setHelpEnabled(false);
823 }
824
slotArmiesNumberChanged(int checked)825 void KGameWindow::slotArmiesNumberChanged(int checked)
826 {
827 qCDebug(KSIRK_LOG) << checked;
828 KsirkSettings::setShowArmiesNumbers(checked);
829
830 foreach (Country* country, m_theWorld->getCountries())
831 {
832 country->createArmiesSprites();
833 }
834 }
835
slotDefAuto()836 void KGameWindow::slotDefAuto()
837 {
838 QPoint point;
839 qCDebug(KSIRK_LOG)<<"Recept signal defense auto";
840 m_automaton->setDefenseAuto(true);
841 if (this->firstCountry()->owner()->getNbAttack() == 1)
842 m_automaton->gameEvent("actionDefense1", point);
843 else
844 m_automaton->gameEvent("actionDefense2", point);
845 m_defenseDialog->close();
846 }
847
slotWindowDef1()848 void KGameWindow::slotWindowDef1()
849 {
850 QPoint point;
851 qCDebug(KSIRK_LOG)<<"Recept signal defense with one army";
852 m_automaton->gameEvent("actionDefense1", point);
853 m_defenseDialog->close();
854 }
855
slotWindowDef2()856 void KGameWindow::slotWindowDef2()
857 {
858 QPoint point;
859 qCDebug(KSIRK_LOG)<<"Recept signal defense with two army";
860 m_automaton->gameEvent("actionDefense2", point);
861 m_defenseDialog->close();
862 }
863
slotNewGameNext()864 void KGameWindow::slotNewGameNext()
865 {
866 qCDebug(KSIRK_LOG);
867 m_automaton->newGameNext();
868 m_reinitializingGame = false;
869
870 if (m_automaton->networkGameType()==GameAutomaton::Jabber && m_jabberClient && m_jabberClient->isConnected())
871 {
872 sendGameInfoToJabber();
873 }
874 }
875
876 // void KGameWindow::slotNewGameOK(unsigned int nbPlayers, const QString& skin, unsigned int nbNetworkPlayers, bool useGoals)
877 // {
878 // qCDebug(KSIRK_LOG) << nbPlayers << skin << nbNetworkPlayers << useGoals;
879 // m_automaton->setGameStatus(KGame::End);
880 // m_reinitializingGame = true;
881 // m_automaton->removeAllPlayers();
882 //
883 // showMap();
884 // m_newPlayersNumber = nbPlayers;
885 // m_automaton->setUseGoals(useGoals);
886 // m_automaton->state(GameLogic::GameAutomaton::INIT);
887 // m_automaton->savedState(GameLogic::GameAutomaton::INVALID);
888 // m_automaton->setNetworkPlayersNumber(m_automaton->networkGameType()==GameAutomaton::None?0:nbNetworkPlayers);
889 // m_automaton->finishSetupPlayersNumberAndSkin(skin, nbPlayers);
890 // m_reinitializingGame = false;
891 //
892 // if (m_automaton->networkGameType()==GameAutomaton::Jabber && m_jabberClient && m_jabberClient->isConnected())
893 // {
894 // sendGameInfoToJabber();
895 // }
896 // }
897
slotNewGameKO()898 void KGameWindow::slotNewGameKO()
899 {
900 qCDebug(KSIRK_LOG) << m_stateBeforeNewGame << m_stackWidgetBeforeNewGame;
901 m_automaton->state(m_stateBeforeNewGame);
902 m_centralWidget->setCurrentIndex(m_stackWidgetBeforeNewGame);
903 m_automaton->setGameStatus(KGame::Run);
904 }
905
slotConnected()906 void KGameWindow::slotConnected()
907 {
908 qCDebug(KSIRK_LOG) << "Connected to Jabber server.";
909
910 qCDebug(KSIRK_LOG) << "Requesting roster...";
911 m_jabberClient->requestRoster ();
912 }
913
slotRosterRequestFinished(bool success)914 void KGameWindow::slotRosterRequestFinished ( bool success )
915 {
916 qCDebug(KSIRK_LOG) << success;
917
918 /* Since we are online now, set initial presence. Don't do this
919 * before the roster request or we will receive presence
920 * information before we have updated our roster with actual
921 * contacts from the server! (Iris won't forward presence
922 * information in that case either). */
923 qCDebug(KSIRK_LOG) << "Setting initial presence...";
924 setPresence ( m_initialPresence );
925 }
926
slotCSDisconnected()927 void KGameWindow::slotCSDisconnected ()
928 {
929 qCDebug(KSIRK_LOG) << "Disconnected from Jabber server.";
930
931 /*
932 * We should delete the JabberClient instance here,
933 * but timers etc prevent us from doing so. Iris does
934 * not like to be deleted from a slot.
935 */
936
937 /* It seems that we don't get offline notifications when going offline
938 * with the protocol, so clear all resources manually. */
939 // resourcePool()->clear();
940
941 }
942
slotReceivedMessage(const XMPP::Message & message)943 void KGameWindow::slotReceivedMessage (const XMPP::Message & message)
944 {
945 qCDebug(KSIRK_LOG) << "New " << message.type() << " message from " << message.from().full () << ": " << message.body();
946
947 QString body = message.body();
948 QString nick = message.from().full();
949
950 if ( message.type() == "groupchat" )
951 {
952 qCDebug(KSIRK_LOG) << "my jid:" << m_groupchatRoom+'@'+m_groupchatHost+'/'+m_groupchatNick;
953 XMPP::Jid jid ( message.from().domain() );
954 if (body.startsWith(QLatin1String("I'm starting a game with skin"))
955 && m_presents.contains(message.from().full ())
956 && message.from().full() != m_groupchatRoom+'@'+m_groupchatHost+'/'+m_groupchatNick)
957 {
958 qCDebug(KSIRK_LOG) << "start game message";
959 QRegExp rxlen("I'm starting a game with skin '([^']*)' and '(\\d+)' players");
960 // int pos = rxlen.indexIn(body);
961 QString skin = rxlen.cap(1); // "189"
962 int nbPlayers = rxlen.cap(2).toInt(); // "cm"
963 qCDebug(KSIRK_LOG) << "emiting newJabberGame" << nick << nbPlayers << skin;
964 emit newJabberGame(nick, nbPlayers, skin);
965 }
966 else if (body.startsWith(QLatin1String("Who propose online KsirK games here?")))
967 {
968 qCDebug(KSIRK_LOG) << "online games question" << m_automaton->stateName();
969 if (m_automaton->startingGame())
970 {
971 sendGameInfoToJabber();
972 }
973 }
974 }
975 else if ( message.type() == "ksirkgame" )
976 {
977 XMPP::Jid jid ( message.from() );
978 if (body == "connect")
979 {
980 qCDebug(KSIRK_LOG) << "received connect from" << jid.full();
981 KMessageJabber* messageIO = new KMessageJabber(jid.full(), m_jabberClient, this);
982 if (m_automaton->messageServer())
983 {
984 m_automaton->messageServer()->addClient(messageIO);
985 }
986 }
987 else
988 {
989 qCDebug(KSIRK_LOG) << "non connect ksirkgame message";
990 }
991 }
992 }
slotHandleTLSWarning(QCA::TLS::IdentityResult identityResult,QCA::Validity validityResult)993 void KGameWindow::slotHandleTLSWarning (QCA::TLS::IdentityResult identityResult, QCA::Validity validityResult )
994 {
995 qCDebug(KSIRK_LOG) << "Handling TLS warning..." << identityResult << validityResult;
996 }
997
slotClientError(JabberClient::ErrorCode errorCode)998 void KGameWindow::slotClientError ( JabberClient::ErrorCode errorCode )
999 {
1000 qCDebug(KSIRK_LOG) << "Handling client error...";
1001
1002 switch ( errorCode )
1003 {
1004 case JabberClient::NoTLS:
1005 default:
1006 #if 0 //QT5
1007 KMessageBox::queuedMessageBox ( 0, KMessageBox::Error,
1008 i18n ("An encrypted connection with the Jabber server could not be established."),
1009 i18n ("Jabber Connection Error"));
1010 // disconnect ( 0/*Kopete::Account::Manual*/ );
1011 #endif
1012 break;
1013 }
1014 }
1015
slotCSError(int error)1016 void KGameWindow::slotCSError ( int error )
1017 {
1018 qCDebug(KSIRK_LOG) << "Error in stream signalled.";
1019
1020 if ( ( error == XMPP::ClientStream::ErrAuth )
1021 && ( m_jabberClient->clientStream()->errorCondition () == XMPP::ClientStream::NotAuthorized ) )
1022 {
1023 qCDebug(KSIRK_LOG) << "Incorrect password, retrying.";
1024 // disconnect(/*Kopete::Account::BadPassword*/0);
1025 }
1026 else
1027 {
1028 // int errorClass = 0;
1029
1030 qCDebug(KSIRK_LOG) << "Disconnecting.";
1031
1032 // display message to user
1033 // if(!m_removing) //when removing the account, connection errors are normal.
1034 // handleStreamError (error, m_jabberClient->clientStream()->errorCondition (), m_jabberClient->clientConnector()->errorCode (), server (), errorClass, m_jabberClient->clientStream()->errorText());
1035 //
1036 // disconnect ( errorClass );
1037
1038 /* slotCSDisconnected will not be called*/
1039 // resourcePool()->clear();
1040 }
1041
1042 }
1043
slotClientDebugMessage(const QString & msg)1044 void KGameWindow::slotClientDebugMessage ( const QString &msg )
1045 {
1046 qCDebug(KSIRK_LOG) << msg;
1047 }
1048
slotGroupChatJoined(const XMPP::Jid & jid)1049 void KGameWindow::slotGroupChatJoined (const XMPP::Jid & jid)
1050 {
1051 qCDebug(KSIRK_LOG) << "Joined groupchat " << jid.full ();
1052
1053 /* <message type="chat" to="kleag@localhost" id="aabca" >
1054 <body>hello</body>
1055 </message>*/
1056 XMPP::Message message(QString(m_groupchatRoom+'@'+m_groupchatHost));
1057 message.setType("groupchat");
1058 message.setId(QUuid::createUuid().toString().remove('{').remove('}').remove('-'));
1059 message.setBody("Hello, I'm a KsirK Game");
1060 m_jabberClient->sendMessage(message);
1061
1062 askForJabberGames();
1063 }
1064
slotGroupChatLeft(const XMPP::Jid & jid)1065 void KGameWindow::slotGroupChatLeft (const XMPP::Jid & jid)
1066 {
1067 qCDebug(KSIRK_LOG) << "Left groupchat " << jid.full ();
1068 }
1069
slotGroupChatPresence(const XMPP::Jid & jid,const XMPP::Status & status)1070 void KGameWindow::slotGroupChatPresence (const XMPP::Jid & jid, const XMPP::Status & status)
1071 {
1072 qCDebug(KSIRK_LOG) << "Received groupchat presence for room " << jid.full() << status.isAvailable();
1073
1074 if (status.isAvailable())
1075 {
1076 XMPP::Message message(jid);
1077 message.setType("ksirkgame");
1078 message.setId(QUuid::createUuid().toString().remove('{').remove('}').remove('-'));
1079 message.setBody(QString("Hello, ")+jid.full());
1080 m_jabberClient->sendMessage(message);
1081 m_presents.insert(jid.full());
1082 }
1083 else
1084 {
1085 m_presents.remove(jid.full());
1086 }
1087 }
1088
slotGroupChatError(const XMPP::Jid & jid,int error,const QString & reason)1089 void KGameWindow::slotGroupChatError (const XMPP::Jid &jid, int error, const QString &reason)
1090 {
1091 qCDebug(KSIRK_LOG) << "Group chat error - room " << jid.full () << " had error " << error << " (" << reason << ")";
1092
1093 switch (error)
1094 {
1095 case JabberClient::InvalidPasswordForMUC:
1096 {
1097 KPasswordDialog dlg(0);
1098 dlg.setPrompt(i18n("A password is required to join the room %1.", jid.node()));
1099 if (dlg.exec() == KPasswordDialog::Accepted)
1100 m_jabberClient->joinGroupChat(jid.domain(), jid.node(), jid.resource(), dlg.password());
1101 }
1102 break;
1103
1104 case JabberClient::NicknameConflict:
1105 {
1106 bool ok;
1107 QString nickname = QInputDialog::getText(this, i18n("Error trying to join %1: nickname %2 is already in use", jid.node(), jid.resource()), i18n("Provide your nickname"), QLineEdit::Normal, QString(), &ok);
1108 if (ok)
1109 {
1110 m_jabberClient->joinGroupChat(jid.domain(), jid.node(), nickname);
1111 }
1112 }
1113 break;
1114
1115 case JabberClient::BannedFromThisMUC:
1116 //QT5 KMessageBox::queuedMessageBox ( 0, KMessageBox::Error, i18n ("You cannot join the room %1 because you have been banned", jid.node()), i18n ("Jabber Group Chat") );
1117 break;
1118
1119 case JabberClient::MaxUsersReachedForThisMuc:
1120 //QT5 KMessageBox::queuedMessageBox ( 0, KMessageBox::Error, i18n ("You cannot join the room %1 because the maximum number of users has been reached", jid.node()), i18n ("Jabber Group Chat") );
1121 break;
1122
1123 default:
1124 {
1125 QString detailedReason = reason.isEmpty () ? i18n ( "No reason given by the server" ) : reason;
1126
1127 //QT5 KMessageBox::queuedMessageBox ( 0, KMessageBox::Error, i18n ("There was an error processing your request for groupchat %1. (Reason: %2, Code %3)", jid.full (), detailedReason, error ), i18n ("Jabber Group Chat") );
1128 }
1129 }
1130 }
1131
slotJabberGameCanceled(int previousIndex)1132 void KGameWindow::slotJabberGameCanceled(int previousIndex)
1133 {
1134 qCDebug(KSIRK_LOG) << previousIndex;
1135 m_centralWidget->setCurrentIndex(previousIndex);
1136 }
1137
slotExit()1138 void KGameWindow::slotExit()
1139 {
1140 // hide();
1141 // delete m_automaton;
1142 close();
1143 }
1144
slotNewPlayerNext()1145 void KGameWindow::slotNewPlayerNext()
1146 {
1147 qCDebug(KSIRK_LOG) << m_newGameSetup->nbLocalPlayers() << m_newGameSetup->nbPlayers() << m_newGameSetup->nbNetworkPlayers();
1148 if (m_automaton->isAdmin() && m_newGameSetup->nbLocalPlayers() >= m_newGameSetup->nbPlayers()-m_newGameSetup->nbNetworkPlayers())
1149 {
1150 m_newGameSummaryWidget->show(this);
1151 m_centralWidget->setCurrentIndex(NEWGAMESUMMARY_INDEX);
1152 }
1153 else if (!m_automaton->isAdmin())
1154 {
1155 NewPlayerData* pd = m_newGameSetup->players().back();
1156 addPlayer(pd->name(), 0, 0, pd->nation(), pd->computer());
1157 }
1158 }
1159
slotNewPlayerPrevious()1160 void KGameWindow::slotNewPlayerPrevious()
1161 {
1162 qCDebug(KSIRK_LOG);
1163 if (m_newGameSetup->players().empty())
1164 {
1165 m_centralWidget->setCurrentIndex(NEWGAME_INDEX);
1166 }
1167 else
1168 {
1169 NewPlayerData* player = m_newGameSetup->players().back();
1170 m_newGameSetup->players().pop_back();
1171 m_newPlayerWidget->init(player);
1172 delete player;
1173 m_centralWidget->setCurrentIndex(NEWPLAYER_INDEX);
1174 }
1175 }
1176
slotNewPlayerCancel()1177 void KGameWindow::slotNewPlayerCancel()
1178 {
1179 qCDebug(KSIRK_LOG);
1180 /// @TODO other uninits to do
1181 qDeleteAll(m_newGameSetup->players());
1182 m_newGameSetup->players().clear();
1183 m_centralWidget->setCurrentIndex(m_stackWidgetBeforeNewGame);
1184 }
1185
slotStartNewGame()1186 void KGameWindow::slotStartNewGame()
1187 {
1188 qCDebug(KSIRK_LOG) << m_newGameSetup->nbPlayers() << m_newGameSetup->nbPlayers() << m_newGameSetup->players().size();
1189 m_automaton->setGameStatus(KGame::End);
1190 m_reinitializingGame = true;
1191
1192 // delete remainings animations from previous game
1193 m_animFighters->clear();
1194 foreach(AnimSpritesGroup* sprites, m_animSpritesGroups)
1195 {
1196 sprites->clear();
1197 delete sprites;
1198 }
1199 m_animSpritesGroups.clear();
1200
1201 // for network games, remote players are already created, should not remove them
1202 // TODO the players will not be in the orderd showed in the interface.
1203 if (!(m_automaton->playerList()->isEmpty()) && m_automaton->networkGameType() == GameAutomaton::None)
1204 {
1205 qCDebug(KSIRK_LOG) << "There was " << m_automaton->playerList()->count() << "players";
1206 m_automaton->playerList()->clear();
1207 m_automaton->currentPlayer(0);
1208 qCDebug(KSIRK_LOG) << " playerList size = " << m_automaton->playerList()->count();
1209 }
1210 theWorld()->reset();
1211
1212 m_automaton->finishSetupPlayersNumberAndSkin();
1213 m_reinitializingGame = false;
1214
1215 unsigned int nbAvailArmies = (unsigned int)(m_theWorld->getNbCountries() * 2.5 / m_newGameSetup->players().size());
1216 foreach (const NewPlayerData* player, m_newGameSetup->players())
1217 {
1218 if (!player->network())
1219 {
1220 // this has to be done locally
1221 addPlayer(player->name(), nbAvailArmies, 0, player->nation(), player->computer());
1222 }
1223 }
1224
1225 if (m_newGameSetup->players().size() == m_newGameSetup->nbPlayers())
1226 {
1227 showMap();
1228 m_frame->setFocus();
1229 m_newGameSummaryWidget->finishButton->setEnabled(true);
1230 }
1231 else
1232 {
1233 m_newGameSummaryWidget->finishButton->setDisabled(true);
1234 m_newGameSummaryWidget->previousButton->setDisabled(true);
1235 }
1236 }
1237
slotTcpConnectCancel()1238 void KGameWindow::slotTcpConnectCancel()
1239 {
1240 showMainMenu();
1241 }
1242
slotTcpConnectPrevious()1243 void KGameWindow::slotTcpConnectPrevious()
1244 {
1245 showMainMenu();
1246 }
1247
1248
1249 } // closing namespace Ksirk
1250