File indexing completed on 2024-03-24 04:06:23

0001 /*
0002     SPDX-FileCopyrightText: 2003 Russell Steffen <rsteffen@bayarea.net>
0003     SPDX-FileCopyrightText: 2003 Stephan Zehetner <s.zehetner@nevox.org>
0004     SPDX-FileCopyrightText: 2006 Dmitry Suzdalev <dimsuz@gmail.com>
0005     SPDX-FileCopyrightText: 2006 Inge Wallin <inge@lysator.liu.se>
0006     SPDX-FileCopyrightText: 2006 Pierre Ducroquet <pinaraf@gmail.com>
0007     SPDX-FileCopyrightText: 2011 Jeffrey Kelling <overlordapophis@gmail.com>
0008 
0009     SPDX-License-Identifier: GPL-2.0-or-later
0010 */
0011 
0012 #include "gameview.h"
0013 
0014 #include <QCheckBox>
0015 #include <QDockWidget>
0016 #include <QLabel>
0017 #include <QPushButton>
0018 #include <QLineEdit>
0019 #include <QTextEdit>
0020 #include <QPixmap>
0021 #include <QKeyEvent>
0022 #include <QIntValidator>
0023 #include <QDebug>
0024 
0025 #include <KMessageBox>
0026 
0027 #include "players/player.h"
0028 #include "players/localplayer.h"
0029 #include "images.h"
0030 #include "map/mapview.h"
0031 #include "map/mapscene.h"
0032 
0033 #include "dialogs/newgamedlg.h"
0034 #include "dialogs/scoredlg.h"
0035 #include "dialogs/fleetdlg.h"
0036 
0037 #include "view/standingswidget.h"
0038 
0039 #include <cmath>
0040 
0041 /*********************************************************************
0042  Game Board
0043 *********************************************************************/
0044 
0045 GameView::GameView(QWidget *parent, Game *game, QDockWidget *messagesDock, QDockWidget *standingsDock)
0046   : QWidget( parent ),
0047     m_msgWidgetLastTurn(0),
0048     m_messagesDock(messagesDock),
0049     m_standingsDock(standingsDock),
0050     m_game( game ),
0051     m_queueMessages(false),
0052     m_messageQueue(),
0053     m_showInformations(false),
0054     m_initCompleted( false ),
0055     m_cleanupNeeded( false ),
0056     m_guiState( NONE )
0057 {
0058     QPalette blackPal;
0059     blackPal.setColor( backgroundRole(), Qt::black );
0060     setPalette( blackPal );
0061     setAutoFillBackground( true );
0062 
0063     QColor col(Qt::green);
0064     QPalette palette;
0065     palette.setColorGroup( QPalette::Active,    Qt::white,          Qt::black,
0066                            col.lighter(),       col.darker(),       col,
0067                            col.lighter(125),    col.lighter(125),   col.darker(),
0068                            Qt::black );
0069     palette.setColorGroup( QPalette::Inactive,  Qt::white,          Qt::black,
0070                            col.lighter(),       col.darker(),       col,
0071                            col.lighter(125),    col.lighter(125),   col.darker(),
0072                            Qt::black );
0073     palette.setColorGroup( QPalette::Disabled,  Qt::white,          QColor(Qt::darkGray).darker(),
0074                            col.lighter(),       col.darker(),       col,
0075                            col.darker(150),     col.lighter(125),   Qt::black,
0076                            Qt::black );
0077 
0078     blackPal.setColor( QPalette::Base, Qt::black );
0079     blackPal.setColor( QPalette::Window, Qt::black );
0080     blackPal.setColor( QPalette::Button, QColor(Qt::darkGray).darker() );
0081     blackPal.setColor( QPalette::Text, Qt::white );
0082     blackPal.setColor( QPalette::ButtonText, Qt::white );
0083     blackPal.setColor( QPalette::WindowText, Qt::white );
0084 
0085     //********************************************************************
0086     // Create the widgets in the main window
0087     //********************************************************************
0088     m_mapScene  = new MapScene(m_game);
0089     m_mapWidget = new MapView( m_mapScene, this );
0090     m_mapWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
0091     m_mapWidget->setFrameShape(QFrame::NoFrame);
0092 
0093     m_msgWidget = new QTextEdit();
0094     m_msgWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
0095     m_msgWidget->setReadOnly(true);
0096     m_msgWidget->setPalette( blackPal );
0097     m_msgWidget->setAutoFillBackground( true );
0098 
0099     m_messagesDock->setWidget(m_msgWidget);
0100 
0101     m_standingsWidget = new StandingsWidget(nullptr);
0102     m_standingsDock->setWidget(m_standingsWidget);
0103 
0104     m_gameMessage = new QLabel( this );
0105     m_gameMessage->setPalette( palette );
0106 
0107     m_endTurnBtn = new QPushButton( i18n("End Turn"), this );
0108     m_endTurnBtn->setFixedSize( m_endTurnBtn->sizeHint() );
0109     m_endTurnBtn->setPalette( palette );
0110 
0111     m_shipCountEdit = new QLineEdit( this );
0112     m_shipValidator = new QIntValidator(1, 32767, this );
0113     m_shipCountEdit->setValidator( m_shipValidator );
0114     m_shipCountEdit->setMinimumSize( 40, 0 );
0115     m_shipCountEdit->setMaximumSize( 32767, 40 );
0116     m_shipCountEdit->setEnabled(false);
0117     m_shipCountEdit->setPalette( palette );
0118     m_shipCountEdit->setEchoMode( QLineEdit::Password );
0119 
0120     m_standingOrder = new QCheckBox(i18n("Standing order"), this);
0121     m_standingOrder->setEnabled(false);
0122     m_standingOrder->setPalette( palette );
0123     m_standingOrder->setCheckState(Qt::Unchecked);
0124 
0125     m_splashScreen = new QLabel( this );
0126     m_splashScreen->setPixmap(QPixmap(IMAGE_SPLASH));
0127     m_splashScreen->setScaledContents(true);
0128 
0129     setMouseTracking( true );
0130     setFocusPolicy( Qt::StrongFocus );
0131     setFocus();
0132 
0133     //********************************************************************
0134     // Layout the main window
0135     //********************************************************************
0136     QVBoxLayout  *mainLayout    = new QVBoxLayout( this );
0137     QHBoxLayout  *topLineLayout = new QHBoxLayout;
0138 
0139     topLineLayout->addSpacing( 5 );
0140     topLineLayout->addWidget( m_gameMessage, 10 );
0141     topLineLayout->addWidget( m_standingOrder, 1 );
0142     topLineLayout->addWidget( m_shipCountEdit, 1 );
0143     topLineLayout->addWidget( m_endTurnBtn, 1 );
0144 
0145     mainLayout->addLayout( topLineLayout );
0146     mainLayout->addWidget( m_mapWidget );
0147 
0148     //**********************************************************************
0149     // Set up signal/slot connections
0150     //**********************************************************************
0151     connect(m_mapScene, &MapScene::planetSelected, this, &GameView::planetSelected);
0152     connect(m_shipCountEdit, &QLineEdit::returnPressed, this, &GameView::newShipCount);
0153     connect(m_standingOrder, &QCheckBox::clicked, this, &GameView::standingOrdersClicked);
0154     connect(m_endTurnBtn, &QPushButton::clicked, this, &GameView::nextPlayer);
0155 
0156     changeGameView();
0157 }
0158 
0159 //**********************************************************************
0160 // Destructor
0161 //**********************************************************************
0162 GameView::~GameView()
0163 {
0164     // Nothing much to do yet
0165 }
0166 
0167 //************************************************************************
0168 // Event handlers
0169 //************************************************************************
0170 void GameView::standingOrdersClicked() {
0171     m_shipCountEdit->setFocus();
0172     if(m_standingOrder->checkState() == Qt::Checked)
0173         m_shipValidator->setTop(INT_MAX);
0174     else
0175         m_shipValidator->setTop(sourcePlanet->fleet().shipCount());
0176 }
0177 
0178 void
0179 GameView::resizeEvent ( QResizeEvent * ) {
0180     m_splashScreen->setGeometry( 0, 0, width(), height() );
0181 }
0182 
0183 void
0184 GameView::keyPressEvent( QKeyEvent *e )
0185 {
0186     // Check for the escape key
0187     if( e->key() == Qt::Key_Escape ) {
0188         switch( m_guiState ) {
0189         case DEST_PLANET:
0190         case SHIP_COUNT:
0191         case RULER_SOURCE:
0192         case RULER_DEST:
0193             m_guiState = SOURCE_PLANET;
0194             haveSourcePlanet = false;
0195             haveDestPlanet   = false;
0196             turn();
0197             break;
0198         default:
0199             break;
0200         }
0201         m_mapScene->displayPlanetInfo( nullptr );
0202         m_mapScene->unselectPlanet();
0203         m_showInformations = false;
0204         return;
0205     }
0206 
0207     if( e->text().isEmpty() || e->text().at(0).isSpace() ) {
0208         e->ignore();
0209         return;
0210     }
0211     
0212     if ( e->text() == QLatin1String("?") ) {
0213         // Switch the information key info...
0214         m_showInformations = !m_showInformations;
0215         return;
0216     }
0217 
0218     QString planetName;
0219 
0220     planetName += e->text().toUpper();
0221     
0222     for (Planet *p : m_game->planets()) {
0223         if( p->name() == planetName ) {
0224             if ( m_showInformations ) {
0225                 m_mapScene->selectPlanet(p);
0226                 m_mapScene->displayPlanetInfo( p );
0227                 m_showInformations = false;
0228             } else {
0229                 m_mapScene->displayPlanetInfo( nullptr );
0230                 m_mapScene->selectPlanet(p);
0231                 planetSelected( p );
0232             }
0233             break;
0234         }
0235     }
0236 
0237 }
0238 
0239 
0240 //************************************************************************
0241 // Game engine/state machine
0242 //************************************************************************
0243 
0244 /**
0245  * Prepare the turn for a local player by updating the informational widgets.
0246  */
0247 
0248 void
0249 GameView::turnPreparation()
0250 {
0251     m_standingsWidget->update(m_game->players());
0252 
0253     turn();
0254 }
0255 
0256 
0257 void
0258 GameView::turn()
0259 {
0260     switch( m_guiState ) {
0261     case NONE :
0262         // The standby state, waiting for clicking on a planet or starting
0263         // to measure a distance..
0264         m_guiState      = SOURCE_PLANET;
0265         haveSourcePlanet = false;
0266         haveDestPlanet   = false;
0267         haveShipCount    = false;
0268         standingOrder    = false;
0269         shipCount        = 0;
0270         m_mapScene->unselectPlanet();
0271 
0272         turn();
0273         setFocus();
0274         break;
0275 
0276     case SOURCE_PLANET :
0277         // The user has clicked on a source planet for moving some fleets.
0278         if( haveSourcePlanet ) {
0279             m_guiState = DEST_PLANET;
0280 
0281             m_mapScene->selectPlanet(sourcePlanet);
0282             turn();
0283 
0284         } else {
0285             m_shipCountEdit->setEnabled(false);
0286             m_shipCountEdit->setText( QString() );
0287             m_standingOrder->setEnabled(false);
0288             m_standingOrder->setCheckState(Qt::Unchecked);
0289             m_mapScene->unselectPlanet();
0290             m_gameMessage->setText( i18n("%1: Select source planet...", m_game->currentPlayer()->coloredName()) );
0291             setFocus();
0292         }
0293 
0294         break;
0295 
0296     case DEST_PLANET :
0297         // The user has chosen a destination planet and should now
0298         // specify a number of ships.
0299         if( haveDestPlanet ) {
0300             m_mapScene->unselectPlanet();
0301             m_guiState = SHIP_COUNT;
0302             turn();
0303         } else {
0304             m_shipCountEdit->setEnabled(false);
0305             m_standingOrder->setEnabled(false);
0306             m_mapScene->selectPlanet(sourcePlanet);
0307             m_gameMessage->setText( i18n("%1: Select destination planet...", m_game->currentPlayer()->coloredName()) );
0308             setFocus();
0309         }
0310 
0311         break;
0312 
0313     case SHIP_COUNT:
0314         // The user has selected, source, distance, ship count.
0315         if( haveShipCount ) {
0316             // We now have a complete fleet to send, so send it
0317             if( !m_game->attack(sourcePlanet, destPlanet, shipCount, standingOrder) ) {
0318                 KMessageBox::error( this, i18n("Not enough ships to send.") );
0319             }
0320 
0321             m_shipCountEdit->setEnabled(false);
0322             m_standingOrder->setEnabled(false);
0323 
0324             m_guiState = NONE;
0325             turn();
0326 
0327             m_endTurnBtn->setFocus();
0328 
0329         } else {
0330             m_gameMessage->setText( i18n("%1: How many ships?", m_game->currentPlayer()->coloredName()) );
0331 
0332             m_shipCountEdit->setEnabled(true);
0333             m_standingOrder->setEnabled(true);
0334             m_shipCountEdit->setFocus();
0335 
0336             m_mapScene->unselectPlanet();
0337         }
0338 
0339         break;
0340 
0341     case RULER_SOURCE:
0342         // The user has selected to measure a distance with the ruler.
0343         if( haveSourcePlanet ) {
0344             m_guiState = RULER_DEST;
0345             m_mapScene->selectPlanet(sourcePlanet);
0346             turn();
0347         } else {
0348             m_shipCountEdit->setEnabled(false);
0349             m_mapScene->unselectPlanet();
0350 
0351             m_gameMessage->setText( i18n("Ruler: Select starting planet.") );
0352             setFocus();
0353         }
0354         break;
0355 
0356     case RULER_DEST:
0357         if( haveDestPlanet ) {
0358             m_mapScene->unselectPlanet();
0359 
0360             // Display the distance between the two planets
0361             double dist = m_game->map()->distance( sourcePlanet,
0362                                                         destPlanet );
0363 
0364             QString msg;
0365             msg = i18n("The distance from Planet %1 to Planet %2 is %3 light years.\n"
0366                        "A ship leaving this turn will arrive on turn %4",
0367                    sourcePlanet->name(),
0368                    destPlanet->name(),
0369                    QString::number(dist, 'f', 1),
0370                    m_game->turnCounter() + (int)std::ceil(dist));
0371             KMessageBox::information( this, msg, i18n("Distance"));
0372 
0373             m_guiState = NONE;
0374             turn();
0375         } else {
0376             m_gameMessage->setText( i18n("Ruler: Select ending planet.") );
0377             m_shipCountEdit->setEnabled(false);
0378             m_mapScene->selectPlanet(sourcePlanet);
0379 
0380             setFocus();
0381         }
0382         break;
0383 
0384     default:
0385         break;
0386     }
0387 
0388     m_endTurnBtn->setEnabled(m_guiState == SOURCE_PLANET);
0389 
0390     Q_EMIT newGUIState( m_guiState );
0391 }
0392 
0393 void
0394 GameView::gameMsg(const KLocalizedString &msg, Player *player, Planet *planet, 
0395         Player *planetPlayer)
0396 {
0397     bool isHumanInvolved = false;
0398 
0399     QString           color    = QStringLiteral("white");
0400     KLocalizedString  colorMsg = msg;
0401     KLocalizedString  plainMsg = msg;
0402 
0403     if (player) {
0404        if (!player->isAiPlayer())
0405           isHumanInvolved = true;
0406        colorMsg = colorMsg.subs(player->coloredName());
0407        plainMsg = plainMsg.subs(player->name());
0408     }
0409 
0410     if (planet) {
0411        if (!planetPlayer)
0412           planetPlayer = planet->player();
0413        if (!planetPlayer->isAiPlayer() && !planetPlayer->isNeutral())
0414           isHumanInvolved = true;
0415 
0416        QString  color = planetPlayer->color().name();
0417        colorMsg = colorMsg.subs(QStringLiteral("<font color=\"%1\">%2</font>")
0418                                 .arg(color, planet->name()));
0419        plainMsg = plainMsg.subs(planet->name());
0420     }
0421 
0422     if (m_msgWidgetLastTurn < m_game->turnCounter()) {
0423         m_msgWidgetLastTurn = m_game->turnCounter();
0424 
0425         m_msgWidget->append(QLatin1String("<font color=\"gray\">")
0426                         + i18n("Turn %1:", m_game->turnCounter())
0427                         + QLatin1String("</font>"));
0428     }
0429 
0430     m_msgWidget->append(QLatin1String("- <font color=\"") + color + QLatin1String("\">")
0431                         + colorMsg.toString()+QLatin1String("</font>"));
0432     m_msgWidget->moveCursor(QTextCursor::End);
0433 
0434     if (isHumanInvolved) {
0435         if ( m_queueMessages ) {
0436             GameMessage msg;
0437 
0438             msg.text     = colorMsg.toString();
0439             msg.sender   = player;
0440             msg.receiver = planetPlayer;
0441             m_messageQueue.append(msg);
0442         } else {
0443             KMessageBox::information(this, plainMsg.toString());
0444         }
0445     }
0446 }
0447 
0448 //************************************************************************
0449 // Confirm aborting existing game
0450 //************************************************************************
0451 bool GameView::confirmNewGame()
0452 {
0453   if( m_game->isRunning() )
0454         return shutdownGame();
0455 
0456   return true;
0457 }
0458 
0459 //************************************************************************
0460 // Set up the game board for a new game
0461 //************************************************************************
0462 void
0463 GameView::startNewGame()
0464 {
0465     NewGameDlg *newGame = new NewGameDlg( this, m_game );
0466 
0467     if( !newGame->exec() ) {
0468         delete newGame;
0469         return;
0470     }
0471 
0472     newGame->save(); // Save settings for next time
0473 
0474     delete newGame;
0475 
0476     for (Player *player : m_game->players()) {
0477         if (player->isSpectator()) {
0478 
0479             // All planets a spectator player has assigned are turned into
0480             // neutral planets so that a spectator player starts without
0481             // any planet.
0482 
0483             m_game->map()->turnOverPlayerPlanets(player, m_game->neutral());
0484         }
0485 
0486         LocalPlayer *local = qobject_cast<LocalPlayer*>(player);
0487         if (local)
0488             connect(local, &LocalPlayer::canPlay, this, &GameView::turnPreparation);
0489     }
0490 
0491     connect(m_game, &Game::finished, this, &GameView::gameOver);
0492     m_game->start();
0493 
0494     // Fix all the widgets to run a new game.
0495     changeGameView();
0496 
0497     // setup the map scene
0498     m_mapScene->mapUpdate();
0499 
0500     // Set up the base GUI for a new game.
0501     m_msgWidget->clear();
0502     m_msgWidgetLastTurn = 0;
0503     m_shipCountEdit->setEnabled(false);
0504     m_initCompleted = true;
0505 
0506     //call GameView::gameOver now if needed happens if the game ends immediately after starting.
0507     if(m_cleanupNeeded)
0508         gameOver();
0509 }
0510 
0511 
0512 //************************************************************************
0513 // Shut down the current game
0514 //************************************************************************
0515 bool
0516 GameView::shutdownGame()
0517 {
0518     if (!m_game->isRunning())
0519         return true;
0520 
0521     int choice = KMessageBox::warningContinueCancel
0522       ( this,
0523         i18n("Do you wish to retire this game?"),
0524         i18nc("@title:window", "End Game"),
0525         KStandardGuiItem::ok() );
0526 
0527     if( choice == KMessageBox::Cancel )
0528         return false;
0529 
0530     gameOver();
0531     return true;
0532 }
0533 
0534 
0535 void
0536 GameView::gameOver()
0537 {
0538     if (m_initCompleted) {
0539         //qDebug() << "Game over";
0540 
0541         /**
0542          * @todo This is an attempt to remove duplicate information from screen.
0543          * It is not a final solution, but only the best we came up with. The
0544          * problem is that the messages cannot be seen anymore, so the player
0545          * cannot check what happened last. Furthermore, this sudden change of
0546          * the GUI setup can be confusing for players.
0547          */
0548 
0549         m_messagesDock->hide();
0550         m_standingsDock->hide();
0551 
0552         ScoreDlg *scoreDlg = new ScoreDlg(this, i18nc("@title:window", "Final Standings"), m_game->players());
0553         scoreDlg->exec();
0554         scoreDlg->deleteLater();
0555 
0556         cleanupGame();
0557     }
0558     else
0559         m_cleanupNeeded = true;
0560 }
0561 
0562 
0563 void
0564 GameView::cleanupGame()
0565 {
0566     m_mapScene->clearMap();
0567     m_game->stop();
0568 
0569     m_endTurnBtn->setEnabled( false );
0570 
0571     changeGameView();
0572     m_guiState = NONE;
0573 
0574     //m_game->cleanupGame();
0575 
0576     m_initCompleted = false;
0577     m_cleanupNeeded = false;
0578     Q_EMIT newGUIState(m_guiState);
0579 }
0580 
0581 
0582 //************************************************************************
0583 // Player selected a planet
0584 //************************************************************************
0585 void
0586 GameView::planetSelected( Planet *planet )
0587 {
0588     //qDebug() << "planetSelected with " << m_guiState;
0589     switch( m_guiState ) {
0590         case SOURCE_PLANET:
0591             if( planet->player() == m_game->currentPlayer() ) {
0592                 // got a match
0593                 m_shipValidator->setRange(1, planet->fleet().shipCount());
0594                 haveSourcePlanet = true;
0595                 sourcePlanet = planet;
0596     
0597                 turn();
0598                 return;
0599             }
0600             break;
0601         case RULER_SOURCE:
0602             haveSourcePlanet = true;
0603             sourcePlanet     = planet;
0604             turn();
0605             return;
0606         case DEST_PLANET:
0607         case RULER_DEST:
0608             if( planet != sourcePlanet ) {
0609                 // got a match
0610                 haveDestPlanet = true;
0611                 destPlanet     = planet;
0612     
0613                 turn();
0614             }
0615             return;
0616         default:
0617             break;
0618     }
0619 
0620     // The selected planet just cannot be selected, cancel it.
0621     m_mapScene->unselectPlanet();
0622 }
0623 
0624 
0625 //************************************************************************
0626 // Player hit return in the ship count edit box
0627 //************************************************************************
0628 void
0629 GameView::newShipCount()
0630 {
0631     bool ok;
0632 
0633     switch (m_guiState) {
0634     case SHIP_COUNT:
0635         shipCount = m_shipCountEdit->text().toInt(&ok);
0636         standingOrder = m_standingOrder->checkState() == Qt::Checked;
0637         if (ok)
0638             haveShipCount = true;
0639         m_shipCountEdit->setText( QString() );
0640         m_standingOrder->setCheckState(Qt::Unchecked);
0641         turn();
0642         break;
0643 
0644     default:
0645         break;
0646     };
0647 }
0648 
0649 //**********************************************************************
0650 // transition board from play to non-play
0651 //**********************************************************************
0652 void
0653 GameView::changeGameView()
0654 {
0655     bool isRunning = m_game->isRunning();
0656 
0657     //qDebug() << "Calling GameView::changeGameView" << isRunning;
0658 
0659     m_messagesDock->setVisible(isRunning);
0660 
0661     if (!isRunning) {
0662 
0663         // Only hide the standings dock if the game is not running, but do not
0664         // automatically show it as soon as the game is running.
0665 
0666         m_standingsDock->hide();
0667     }
0668 
0669     m_mapWidget->setVisible(isRunning);
0670     m_gameMessage->setVisible(isRunning);
0671     m_standingOrder->setVisible(isRunning);
0672     m_shipCountEdit->setVisible(isRunning);
0673     m_endTurnBtn->setVisible(isRunning);
0674     m_splashScreen->setVisible(!isRunning); // negation
0675 }
0676 
0677 
0678 //************************************************************************
0679 // Player clicked the 'End Turn' button
0680 //************************************************************************
0681 void
0682 GameView::nextPlayer()
0683 {
0684     // Hum, this should be straightforward
0685     Player *currentPlayer = m_game->currentPlayer();
0686     LocalPlayer *humanPlayer = qobject_cast<LocalPlayer*>(currentPlayer);
0687     if (humanPlayer)
0688         humanPlayer->done();
0689     /*
0690     if(m_game->options().BlindMap && m_game->humanPlayerCount() > 1) {
0691         QString name = m_gameLogic->currentPlayer()->name();
0692         m_gameLogic->setBlindBreak(true);
0693         m_mapScene->update();
0694         KMessageBox::information(this, "Blind Map " + name + " Turn done");
0695         m_gameLogic->setBlindBreak(false);
0696     }
0697     */
0698 }
0699 
0700 //************************************************************************
0701 // Toolbar items
0702 //************************************************************************
0703 void
0704 GameView::measureDistance()
0705 {
0706     switch( m_guiState ) {
0707     case SOURCE_PLANET:
0708         m_guiState = RULER_SOURCE;
0709         turn();
0710     default:
0711         break;
0712     }
0713 }
0714 
0715 
0716 void
0717 GameView::showFleets()
0718 {
0719     Player *current = m_game->currentPlayer();
0720     FleetDlg  *fleetDlg = new FleetDlg( this, current->attackList(),
0721                                         current->newAttacks(), current->standingOrders());
0722     if (fleetDlg->exec()) {
0723         const AttackFleetList *deleteAttacks = fleetDlg->uncheckedFleets();
0724         for (AttackFleet *curFleet : *deleteAttacks) {
0725             current->cancelNewAttack(curFleet);
0726         }
0727         delete deleteAttacks;
0728         m_mapScene->update();
0729     }
0730     fleetDlg->deleteLater();
0731 }
0732 
0733 #include "moc_gameview.cpp"