summaryrefslogtreecommitdiffstats
path: root/konquest/gameenddlg.cc
blob: 2295acd90322343645848a52d098bcb03ec077ce (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
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqslider.h>
#include <tqvbox.h>

#include <kapplication.h>
#include <kconfig.h>
#include <klocale.h>
#include <kstdguiitem.h>

#include "gameenddlg.h"
#include "gameenddlg.moc"

GameEndDlg::GameEndDlg( TQWidget *parent )
    : KDialogBase( i18n("Out of Turns"), 
      KDialogBase::Yes|KDialogBase::No, KDialogBase::Yes, KDialogBase::No,
      parent, "end_game_dialog", true, true )
{
    TQVBox *page = makeVBoxMainWidget();

    // Create controls
    TQLabel *label1 = new TQLabel( i18n("This is the last turn.\nDo you wish to add extra turns?")+"\n\n", page );
    label1->setAlignment( AlignCenter );
    
    turnCountLbl = new TQLabel( page );
    turnCount = new TQSlider( 1, 40, 1, 5, Qt::Horizontal, page );

    KGuiItem addTurns(i18n("&Add Turns"), TQString::null, TQString::null,
                      i18n("Add the specified number of turns to the game and continue playing."));
    KGuiItem gameOver(i18n("&Game Over"), TQString::null, TQString::null,
                      i18n("Terminate the current game."));
    
    setButtonGuiItem(KDialogBase::Yes, addTurns);
    setButtonGuiItem(KDialogBase::No, gameOver);

    init();

    connect( turnCount, TQT_SIGNAL(valueChanged( int )), this, TQT_SLOT(turnCountChange( int )) );
}

GameEndDlg::~GameEndDlg()
{
}

void
GameEndDlg::init()
{
    KConfig *config = kapp->config();
    config->setGroup("Game");
    int turns = config->readNumEntry("ExtraTurns", 10);
    turnCount->setValue(turns);
    turnCountChange(turns);
}

void
GameEndDlg::slotYes()
{
    KConfig *config = kapp->config();
    config->setGroup("Game");
    config->writeEntry("ExtraTurns", extraTurns());
    config->sync();
    KDialogBase::slotYes();
}

int
GameEndDlg::extraTurns()
{
    return turnCount->value();
}

void
GameEndDlg::turnCountChange( int newTurnCount )
{
    TQString newLbl = i18n("Extra turns: %1").arg( newTurnCount );
    turnCountLbl->setText( newLbl);
}