summaryrefslogtreecommitdiffstats
path: root/ksirtet/ksirtet/field.cpp
blob: e74b43e644a82c1646c2c1b7d5e4d09104236e62 (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
#include "field.h"
#include "field.moc"

#include <tqwhatsthis.h>

#include <tdelocale.h>
#include <kgamelcd.h>

#include "board.h"
#include "prefs.h"
#include "piece.h"

//-----------------------------------------------------------------------------
KSField::KSField(TQWidget *parent)
    : Field(parent)
{
    const Board *b = static_cast<Board *>(board);
    TQWhatsThis::add(b->giftPool(), i18n("Indicate the number of garbage lines you received from your opponent."));
}

void KSField::removedUpdated()
{
    KGameLCD *lcd = static_cast<KGameLCD *>(removedList->lcd(0));
    lcd->displayInt(board->nbRemoved());
    if ( board->nbRemoved() ) lcd->highlight();
    if ( Prefs::showDetailedRemoved() ) {
      const KSBoard *ksb = static_cast<const KSBoard *>(board);
      for (uint i=0; i<4; i++) {
        if ( !(ksb->lastRemoved() & (2<<i)) ) continue;
        lcd = static_cast<KGameLCD *>(removedList->lcd(i+1));
        lcd->displayInt(ksb->nbRemovedLines(i));
        if ( ksb->nbRemovedLines(i) ) lcd->highlight();
      }
    }
}

void KSField::settingsChanged()
{
    Field::settingsChanged();
    bool b = Prefs::oldRotationStyle();
    static_cast<KSPieceInfo &>(Piece::info()).setOldRotationStyle(b);

    removedList->clear();
    TQWhatsThis::remove(removedList);
    KGameLCD *lcd = new KGameLCD(5, removedList);
    TQString s = (Prefs::showDetailedRemoved() ? i18n("Total:") : TQString());
    removedList->append(s, lcd);
    lcd->displayInt( board->nbRemoved() );
    lcd->show();

    if ( Prefs::showDetailedRemoved() ) {
        for (uint i=0; i<4; i++) {
            KGameLCD *lcd = new KGameLCD(5, removedList);
            TQString s = i18n("1 Line:", "%n Lines:", i+1);
            removedList->append(s, lcd);
            uint nb = static_cast<const KSBoard *>(board)->nbRemovedLines(i);
            lcd->displayInt(nb);
            lcd->show();
        }
    }
}