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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
#ifndef KOLF_CANVASITEM_H
#define KOLF_CANVASITEM_H
#include <tqcanvas.h>
#include "config.h"
class Ball;
class KConfig;
class StateDB;
class KolfGame;
class CanvasItem
{
public:
CanvasItem() { game = 0; }
virtual ~CanvasItem() {}
/**
* load your settings from the KConfig, which represents a course.
*/
virtual void load(KConfig *) {}
/**
* load a point if you wish. Rarely necessary.
*/
virtual void loadState(StateDB * /*db*/) {}
/**
* returns a bool that is true if your item needs to load after other items
*/
virtual bool loadLast() const { return false; }
/**
* called if the item is made by user while editing, with the item that was selected on the hole;
*/
virtual void selectedItem(TQCanvasItem * /*item*/) {}
/**
* called after the item is moved the very first time by the game
*/
virtual void firstMove(int /*x*/, int /*y*/) {}
/**
* save your settings.
*/
virtual void save(KConfig *cfg);
/**
* save a point if you wish. Rarely necessary.
*/
virtual void saveState(StateDB * /*db*/) {}
/**
* called for information when shot started
*/
virtual void shotStarted() {}
/**
* called right before any items are saved.
*/
virtual void aboutToSave() {}
/**
* called right after all items are saved.
*/
virtual void savingDone() {}
/**
* called when the edit mode has been changed.
*/
virtual void editModeChanged(bool /*editing*/) {}
/**
* the item should delete any other objects it's created.
* DO NOT DO THIS KIND OF STUFF IN THE DESTRUCTOR!
*/
virtual void aboutToDie() {}
/**
* returns the object to get rid of when the delete button is pressed on this item. Some sub-objects will return something other than this.
*/
virtual CanvasItem *itemToDelete() { return this; }
/**
* called when user presses delete key while editing. This is very rarely reimplemented, and generally shouldn't be.
*/
virtual void aboutToDelete() {}
/**
* returns whether this item should be able to be deleted by user while editing.
*/
virtual bool deleteable() const { return true; }
/**
* returns whether this item should get doAdvance called -- it is called in sync with ball advancing (which is twice as fast as the advance() calling rate)
*/
virtual bool fastAdvance() const { return false; }
/**
* called when all items have had their chance at a doAdvance
*/
virtual void fastAdvanceDone() {}
/**
* called if fastAdvance is enabled
*/
virtual void doAdvance() {}
/**
* if all items of this type of item (based on rtti()) that are "colliding" (ie, in the same spot) with ball should get collision() called.
*/
virtual bool terrainCollisions() const { return false; }
/**
* returns whether or not this item lifts items on top of it.
*/
virtual bool vStrut() const { return false; }
/**
* show extra item info
*/
virtual void showInfo() {};
/**
* hide extra item info
*/
virtual void hideInfo() {};
/**
* update your Z value (this is called by various things when perhaps the value should change) if this is called by a vStrut, it will pass 'this'.
*/
virtual void updateZ(TQCanvasRectangle * /*vStrut*/ = 0) {};
/**
* clean up for prettyness
*/
virtual void clean() {};
/**
* scale factor changed (game->scaleFactor(), the world matrix is game->worldMatrix())
* NOTE: not used in Kolf 1.1, which comes with KDE 3.1.
*/
virtual void scaleChanged() {};
/**
* returns whether this item can be moved by others (if you want to move an item, you should honor this!)
*/
virtual bool canBeMovedByOthers() const { return false; }
/**
* returns a Config that can be used to configure this item by the user.
* The default implementation returns one that says 'No configuration options'.
*/
virtual Config *config(TQWidget *parent) { return new DefaultConfig(parent); }
/**
* returns other items that should be moveable (besides this one of course).
*/
virtual TQPtrList<TQCanvasItem> moveableItems() const { return TQPtrList<TQCanvasItem>(); }
/**
* returns whether this can be moved by the user while editing.
*/
virtual bool moveable() const { return true; }
void setId(int newId) { id = newId; }
int curId() const { return id; }
/**
* call to play sound (ie, playSound("wall") plays tdedir/share/apps/kolf/sounds/wall.wav).
* optionally, specify vol to be between 0-1, for no sound to full volume, respectively.
*/
void playSound(TQString file, double vol = 1);
/**
* called on ball's collision. Return if terrain collisions should be processed.
*/
virtual bool collision(Ball * /*ball*/, long int /*id*/) { return true; }
/**
* reimplement if you want extra items to have access to the game object.
* playSound() relies on having this.
*/
virtual void setGame(KolfGame *game) { this->game = game; }
/**
* returns whether this is a corner resizer
*/
virtual bool cornerResize() const { return false; }
TQString name() const { return m_name; }
void setName(const TQString &newname) { m_name = newname; }
protected:
/**
* pointer to main KolfGame
*/
KolfGame *game;
/**
* returns the highest vertical strut the item is on
*/
TQCanvasRectangle *onVStrut();
private:
TQString m_name;
int id;
};
#endif
|