summaryrefslogtreecommitdiffstats
path: root/konquest/mainwin.cc
blob: 866cd936a8cc9558cb9a598aa135badb2ed0b25f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <config.h>

#include <tqpushbutton.h>

#include <kapplication.h>
#include <klocale.h>
#include <kglobal.h>
#include <kmenubar.h>
#include <ktoolbar.h>
#include <kiconloader.h>
#include <kaction.h>
#include <kstdaction.h>
#include <kstdgameaction.h>

#include "version.h"
#include "gamecore.h"
#include "mainwin.h"
#include "mainwin.moc"
#include "gameboard.h"

// KonquestMainWindow


MainWindow::MainWindow()
{
    setCaption( i18n("Galactic Conquest") );

    setupGameBoard();
    setupKAction();
    setupGUI();
}

MainWindow::~MainWindow()
{
}

void
MainWindow::setupKAction()
{
    KStdGameAction::gameNew( gameBoard, TQT_SLOT( startNewGame() ), actionCollection() );
    KStdGameAction::quit( this, TQT_SLOT( close() ), actionCollection() );
    endAction = KStdGameAction::end( gameBoard, TQT_SLOT( shutdownGame() ), actionCollection() );
    endAction->setEnabled(false);

    //AB: there is no icon for disabled - KToolBar::insertButton shows the
    //different state - KAction not :-(
    measureAction = new KAction( i18n("&Measure Distance"), "ruler", 0, gameBoard, TQT_SLOT( measureDistance() ), actionCollection(), "game_measure" );
    measureAction->setEnabled(false);
    standingAction = new KAction( i18n("&Show Standings"), "help", 0, gameBoard, TQT_SLOT( showScores() ), actionCollection(), "game_scores" );
    standingAction->setEnabled(false);
    fleetAction = new KAction( i18n("&Fleet Overview"), "launch", 0, gameBoard, TQT_SLOT( showFleets() ), actionCollection(), "game_fleets" );
    fleetAction->setEnabled(false);
    toolBar()->setBarPos( KToolBar::Left );
    toolBar()->setMovingEnabled( false );
}

void
MainWindow::setupGameBoard()
{
    gameBoard = new GameBoard( this );
    setCentralWidget(gameBoard);

    connect( gameBoard, TQT_SIGNAL( newGameState( GameState )), this, TQT_SLOT( gameStateChange( GameState ) ) );
}


void
MainWindow::gameStateChange( GameState newState )
{
    endAction->setEnabled( gameBoard->isGameInProgress() );
    measureAction->setEnabled( newState==SOURCE_PLANET );
    standingAction->setEnabled( newState==SOURCE_PLANET );
    fleetAction->setEnabled( newState==SOURCE_PLANET );
}