summaryrefslogtreecommitdiffstats
path: root/kmahjongg/Tileset.h
blob: 93fc08324ecba05a6934f603a8a718ec37700c02 (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#ifndef _TILE_SET_H_
#define _TILE_SET_H_


#include <tqbitmap.h>

class Tileset {
   public:
     Tileset(bool scaled=false);	     
     ~Tileset();	

     bool loadTileset(const TQString &filesetPath, const bool isPreview = false);
     TQRgb *createTile(short x, short y, TQRgb *dst, TQImage &src , TQRgb *face);
     TQRgb *copyTileImage(short tileX, short tileY, TQRgb *to, TQImage &from);  

     void setScaled(bool sc) {isScaled = sc; divisor = (sc) ? 2 : 1;}


     TQRgb *tile(short tnum);
     TQRgb *selectedTile(short tnum);
     short width() {return w/divisor;}
     short height() {return h/divisor;}
     short shadowSize() {return ss/divisor;}
     short size() {return s;}
     short qWidth() {return qw/divisor;}
     short qHeight() {return qh/divisor;}


     TQPixmap *selectedPixmaps(int num) {
	if (!isScaled) 
		return &(selectedPix[num]);
	else
		return &(selectedMiniPix[num]);
	}

     TQPixmap *unselectedPixmaps(int num) {
	if (!isScaled)
		return &(unselectedPix[num]);
	else
		return &(unselectedMiniPix[num]);
	}

     TQPixmap *selectedShadowPixmaps(int num) {
	if (!isScaled) 
		return &(selectedShadowPix[num]);
	else
		return &(selectedShadowMiniPix[num]);
	}

     TQPixmap *unselectedShadowPixmaps(int num) {
	if (!isScaled)
		return &(unselectedShadowPix[num]);
	else
		return &(unselectedShadowMiniPix[num]);
	}

  protected:

     enum { maxTiles=45 };
  	void  createPixmap(TQRgb *src, TQPixmap &dest, bool scale, bool shadow);
  

  private:
    TQBitmap maskBits;    // xbm mask for the tile
    TQBitmap maskBitsMini;    // xbm mask for the tile
    TQRgb* tiles;         // Buffer containing all tiles (unselected glyphs)
    TQRgb* selectedTiles; // Buffer containing all tiles (selected glyphs)


    // in version 0.5 we have moved ftom using images and calculating
    // masks etc, to using pixmaps and letting the blt do the hard work,
    // in hardware. 
    TQPixmap selectedPix[maxTiles]; // selected tiles
    TQPixmap unselectedPix[maxTiles]; // unselected tiles
    TQPixmap selectedMiniPix[maxTiles]; // selected tiles
    TQPixmap unselectedMiniPix[maxTiles]; // unselected tiles

    TQPixmap selectedShadowPix[maxTiles]; // selected tiles as above in shadow
    TQPixmap unselectedShadowPix[maxTiles]; // unselected tiles
    TQPixmap selectedShadowMiniPix[maxTiles]; // selected tiles
    TQPixmap unselectedShadowMiniPix[maxTiles]; // unselected tiles




    TQRgb* selectedFace;  // The tile background face for a selected tile
    TQRgb* unselectedFace;// The tile background face for an unselected tile

    TQRgb  tr;    // transparenct color for tile bg

    short ss;   // left/bottom shadow width
    short bs;   // width of the border around a tile
    short w;    // tile width ( +border +shadow)
    short h;    // tile height ( +border +shadow)
    short qw;   // quarter tile width used in 3d rendering
    short qh;   // quarter tile height used in 3d rendering
    short s;	// buffer size for tile (width*height)

    TQString filename;  // cache the last file loaded to save reloading it
    bool isScaled;
    int divisor;
};


#endif