SVN_SILENT made messages (.desktop file)
[kdegames.git] / konquest / mainwin.cc
blob4d481ce8f4120cc1a65e688a6e8c723d743df45b
1 /*
2 Copyright Russell Steffen <rsteffen@bayarea.net>
3 Copyright Stephan Zehetner <s.zehetner@nevox.org>
4 Copyright Dmitry Suzdalev <dimsuz@gmail.com>
5 Copyright Inge Wallin <inge@lysator.liu.se>
6 Copyright Pierre Ducroquet <pinaraf@gmail.com>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include "mainwin.h"
24 #include <QPushButton>
25 #include <QLabel>
27 #include <klocale.h>
28 #include <kglobal.h>
29 #include <kmenubar.h>
30 #include <ktoolbar.h>
31 #include <kiconloader.h>
32 #include <kaction.h>
33 #include <kactioncollection.h>
34 #include <kstandardaction.h>
35 #include <kstandardgameaction.h>
36 #include <kicon.h>
37 #include <kstatusbar.h>
39 #include "mainwin.moc"
40 #include "gamelogic.h"
41 #include "gameview.h"
44 // KonquestMainWindow
47 MainWindow::MainWindow()
49 setCaption( i18n("Galactic Conquest") );
51 setupGameView();
52 setupActions();
53 setupGUI();
55 // The status bar.
56 m_statusBarText = new QLabel(i18n("Galactic Conquest"));
57 statusBar()->addWidget(m_statusBarText);
59 resize(600, 650);
62 MainWindow::~MainWindow()
67 void
68 MainWindow::setupActions()
70 KStandardGameAction::gameNew( m_gameView, SLOT( startNewGame() ), actionCollection() );
71 KStandardGameAction::quit( this, SLOT( close() ), actionCollection() );
73 m_endAction = KStandardGameAction::end( m_gameView, SLOT( shutdownGame() ), actionCollection() );
74 m_endAction->setEnabled(false);
76 //AB: there is no icon for disabled - KToolBar::insertButton shows the
77 //different state - KAction not :-(
78 m_measureAction = actionCollection()->addAction( "game_measure" );
79 m_measureAction->setIcon( KIcon("go-jump") );
80 m_measureAction->setText( i18n("&Measure Distance") );
81 connect(m_measureAction, SIGNAL(triggered(bool)),
82 m_gameView, SLOT( measureDistance() ));
83 m_measureAction->setEnabled(false);
85 // Show standings
86 m_standingAction = actionCollection()->addAction( "game_scores" );
87 m_standingAction->setIcon( KIcon("help-contents") );
88 m_standingAction->setText( i18n("&Show Standings") );
89 connect(m_standingAction, SIGNAL(triggered(bool)),
90 m_gameView, SLOT( showScores() ));
91 m_standingAction->setEnabled(false);
93 // Show fleet overview
94 m_fleetAction = actionCollection()->addAction( "game_fleets" );
95 m_fleetAction->setIcon( KIcon("fork") );
96 m_fleetAction->setText( i18n("&Fleet Overview") );
97 connect(m_fleetAction, SIGNAL(triggered(bool)),
98 m_gameView, SLOT( showFleets() ));
99 m_fleetAction->setEnabled(false);
101 // Toolbar
102 addToolBar ( Qt::LeftToolBarArea, toolBar() );
103 toolBar()->setMovable(false);
107 void
108 MainWindow::setupGameView()
110 m_gameLogic = new GameLogic( this );
111 m_gameView = new GameView( this, m_gameLogic );
112 setCentralWidget( m_gameView );
114 connect ( m_gameLogic, SIGNAL( gameMsg(const KLocalizedString &,
115 Player *, Planet *,
116 Player * ) ),
117 m_gameView, SLOT( gameMsg(const KLocalizedString &,
118 Player *, Planet *,
119 Player * ) ) );
120 connect (m_gameLogic, SIGNAL( beginTurn()), m_gameView, SLOT(beginTurn()));
121 connect (m_gameLogic, SIGNAL( endTurn()), m_gameView, SLOT(endTurn()));
122 connect( m_gameView, SIGNAL( newGUIState( GUIState )),
123 this, SLOT( guiStateChange( GUIState ) ) );
127 void
128 MainWindow::guiStateChange( GUIState newState )
130 m_endAction ->setEnabled( m_gameView->isGameInProgress() );
131 m_measureAction ->setEnabled( newState == SOURCE_PLANET );
132 m_standingAction->setEnabled( newState == SOURCE_PLANET );
133 m_fleetAction ->setEnabled( newState == SOURCE_PLANET );
135 m_statusBarText->setText(i18n("Turn # %1", m_gameLogic->turnNumber()));