blob: 4bd8c21093948bd1b314ce2864db27c7258ce853 (
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
|
/* -------------------------------------------------------------
KDE Tuberling
Play ground widget
mailto:[email protected]
------------------------------------------------------------- */
#ifndef _PLAYGROUND_H_
#define _PLAYGROUND_H_
#include <kprinter.h>
#include <tqwidget.h>
#include <tqbitmap.h>
#include <tqptrlist.h>
#include "todraw.h"
#include "action.h"
class TQDomDocument;
class TopLevel;
class PlayGround : public TQWidget
{
Q_OBJECT
TQ_OBJECT
public:
PlayGround(TopLevel *parent, const char *name, uint selectedGameboard);
~PlayGround();
void reset();
void change(uint selectedGameboard);
void repaintAll();
bool undo();
bool redo();
bool loadFrom(const TQString &name);
bool saveAs(const TQString &name);
bool printPicture(KPrinter &printer) const;
TQPixmap getPicture() const;
inline bool isFirstAction() const { return currentAction == 0; }
inline bool isLastAction() const { return currentAction >= history.count(); }
protected:
virtual void paintEvent(TQPaintEvent *event);
virtual void mousePressEvent(TQMouseEvent *event);
virtual void mouseReleaseEvent(TQMouseEvent *event);
private:
bool registerPlayGrounds(TQDomDocument &layoutDocument);
bool loadPlayGround(TQDomDocument &layoutDocument, uint toLoad);
void loadFailure();
void setupGeometry();
bool zone(TQPoint &position);
void drawText(TQPainter &artist, TQRect &area, TQString &textId) const;
void drawGameboard(TQPainter &artist, const TQRect &area) const;
private:
TQPixmap gameboard; // Picture of the game board
TQBitmap masks; // Pictures of the objects' tqshapes
TQRect editableArea; // Part of the gameboard where the player can lay down objects
TQString menuItem, // Menu item describing describing this gameboard
editableSound; // Sound associated with this area
int texts, // Number of categories of objects names
decorations; // Number of draggable objects on the right side of the gameboard
TQRect *textsLayout, // Positions of the categories names
*objectsLayout; // Position of the draggable objects on right side of the gameboard
TQString *textsList, // List of the message numbers associated with categories
*soundsList; // List of sounds associated with each object
TQCursor *draggedCursor; // Cursor's tqshape for currently dragged object
ToDraw draggedObject; // Object currently dragged
int draggedZOrder; // Z-order (in to-draw buffer) of this object
TQPtrList<ToDraw> toDraw; // List of objects in z-order
TQPtrList<Action> history; // List of actions in chronological order
unsigned int currentAction; // Number of current action (not the last one if used "undo" button!)
TopLevel *topLevel; // Top-level window
};
#endif
|