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.
24 #include <QPushButton>
31 #include <kiconloader.h>
33 #include <kactioncollection.h>
34 #include <kstandardaction.h>
35 #include <kstandardgameaction.h>
37 #include <kstatusbar.h>
39 #include "mainwin.moc"
40 #include "gamelogic.h"
47 MainWindow::MainWindow()
49 setCaption( i18n("Galactic Conquest") );
56 m_statusBarText
= new QLabel(i18n("Galactic Conquest"));
57 statusBar()->addWidget(m_statusBarText
);
62 MainWindow::~MainWindow()
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);
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);
102 addToolBar ( Qt::LeftToolBarArea
, toolBar() );
103 toolBar()->setMovable(false);
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
&,
117 m_gameView
, SLOT( gameMsg(const KLocalizedString
&,
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
) ) );
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()));