summaryrefslogtreecommitdiffstats
path: root/klickety/piece.cpp
blob: a24702fc0ab00ae1c18f9dae93351924b1fe7f43 (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
#include "piece.h"

#include <tqpainter.h>
#include <tdelocale.h>
#include "base/board.h"


const char *KLPieceInfo::DEFAULT_COLORS[NB_BLOCK_TYPES] = {
    "#C86464", "#64C864", "#6464C8", "#C8C864", "#C864C8"
};

TQColor KLPieceInfo::defaultColor(uint i) const
{
  if ( i>=nbColors() ) return TQColor();
  return TQColor(DEFAULT_COLORS[i]);
}

TQString KLPieceInfo::colorLabel(uint i) const
{
    return i18n("Color #%1:").arg(i+1);
}

void KLPieceInfo::draw(TQPixmap *pixmap, uint blockType, uint bMode,
                       bool lighted) const
{
	TQColor col = color(blockType);
    if (lighted) col = col.light();
    pixmap->fill(col);

	TQPainter p(pixmap);
    TQRect r = pixmap->rect();

    p.setPen(col.dark());
    if ( !(bMode & BaseBoard::Up) )
        p.drawLine(r.topLeft(), r.topRight());
    if ( !(bMode & BaseBoard::Down) )
        p.drawLine(r.bottomLeft(), r.bottomRight());
    if ( !(bMode & BaseBoard::Left) )
        p.drawLine(r.topLeft(), r.bottomLeft());
    if ( !(bMode & BaseBoard::Right) )
        p.drawLine(r.topRight(),r.bottomRight());

    p.setPen(col.dark(110));
    if (bMode & BaseBoard::Up)
        p.drawLine(r.topLeft()+TQPoint(1,0), r.topRight()+TQPoint(-1,0));
    if (bMode & BaseBoard::Down)
        p.drawLine(r.bottomLeft()+TQPoint(1,0), r.bottomRight()+TQPoint(-1,0));
    if (bMode & BaseBoard::Left)
        p.drawLine(r.topLeft()+TQPoint(0,1), r.bottomLeft()+TQPoint(0,-1));
    if (bMode & BaseBoard::Right)
        p.drawLine(r.topRight()+TQPoint(0,1), r.bottomRight()+TQPoint(0,-1));
}