Debian Codegraph @

engine/include/cursor.h

raw
1 // ____ _ __
2 // / __ )____ _____ | | / /___ ___________
3 // / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
4 // / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
5 // /_____/\____/____/ |__/|__/\__,_/_/ /____/
6 //
7 // A futuristic real-time strategy game.
8 // This file is part of Bos Wars.
9 //
10 /**@name cursor.h - The cursors header file. */
11 //
12 // (c) Copyright 1998-2007 by Lutz Sammer
13 //
14 // This program is free software; you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation; only version 2 of the License.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 // 02111-1307, USA.
27
28 #ifndef __CURSOR_H__
29 #define __CURSOR_H__
30
31 //@{
32
33 /*----------------------------------------------------------------------------
34 -- Documentation
35 ----------------------------------------------------------------------------*/
36
37 /**
38 ** @class CCursor cursor.h
39 **
40 ** \#include "cursor.h"
41 **
42 ** This structure contains all informations about a cursor.
43 ** The cursor changes depending of the current user input state.
44 ** A cursor can have transparent areas and color cycle animated.
45 **
46 ** The cursor-type structure members:
47 **
48 ** CCursor::Ident
49 **
50 ** Unique identifier of the cursor, used to reference it in config
51 ** files and during startup. Don't use this in game, use instead
52 ** the pointer to this structure.
53 **
54 ** CCursor::HotX CCursor::HotY
55 **
56 ** Hot spot of the cursor in pixels. Relative to the sprite origin
57 ** (0,0). The hot spot of a cursor is the point to which Stratagus
58 ** refers in tracking the cursor's position.
59 **
60 ** CCursor::SpriteFrame
61 **
62 ** Current displayed cursor frame.
63 ** From 0 to CCursor::G::NumFrames.
64 **
65 ** CCursor::FrameRate
66 **
67 ** Rate of changing the frames. The "rate" tells the engine how
68 ** many milliseconds to hold each frame of the animation.
69 **
70 ** @note This is the first time that for timing ms are used! I would
71 ** change it to display frames.
72 **
73 ** CCursor::G
74 **
75 ** Contains the sprite of the cursor, loaded from CCursor::File.
76 ** This can be a multicolor image with alpha or transparency.
77 */
78
79 /**
80 ** @class CursorConfig cursor.h
81 **
82 ** \#include "cursor.h"
83 **
84 ** This structure contains all information to reference/use a cursor.
85 ** It is normally used in other config structures.
86 **
87 ** CursorConfig::Name
88 **
89 ** Name to reference this cursor-type. Used while initialization.
90 ** (See CCursor::Ident)
91 **
92 ** CursorConfig::Cursor
93 **
94 ** Pointer to this cursor-type. Used while runtime.
95 */
96
97 /*----------------------------------------------------------------------------
98 -- Includes
99 ----------------------------------------------------------------------------*/
100
101 #include <vector>
102
103 /*----------------------------------------------------------------------------
104 -- Declarations
105 ----------------------------------------------------------------------------*/
106
107 class CGraphic;
108 class CUnitType;
109
110 /*----------------------------------------------------------------------------
111 -- Definitions
112 ----------------------------------------------------------------------------*/
113
114 /// Private type which specifies the cursor-type
115 class CCursor {
116 public:
117 CCursor() : HotX(0), HotY(0),
118 SpriteFrame(0), FrameRate(0), G(NULL) {}
119
120 std::string Ident; /// Identifier to reference it
121
122 int HotX; /// Hot point x
123 int HotY; /// Hot point y
124
125 int SpriteFrame; /// Current displayed cursor frame
126 int FrameRate; /// Rate of changing the frames
127
128 // --- FILLED UP ---
129
130 CGraphic *G; /// Cursor sprite image
131 };
132
133 /// Cursor config reference
134 class CursorConfig {
135 public:
136 CursorConfig() : Cursor(NULL) {}
137
138 void Load();
139
140 std::string Name; /// Config cursor-type name
141 CCursor *Cursor; /// Cursor-type pointer
142 };
143
144 /// Cursor state
145 enum CursorStates {
146 CursorStatePoint, /// Normal cursor
147 CursorStateSelect, /// Select position
148 CursorStateRectangle, /// Rectangle selecting
149 CursorStatePieMenu, /// Displaying Pie Menu
150 };
151
152 /*----------------------------------------------------------------------------
153 -- Variables
154 ----------------------------------------------------------------------------*/
155
156 extern std::vector<CCursor> AllCursors;/// cursor-types description
157
158 extern CursorStates CursorState; /// current cursor state (point,...)
159 extern int CursorAction; /// action for selection
160 extern int CursorValue; /// value for action (spell type f.e.)
161 extern CUnitType *CursorBuilding; /// building cursor
162
163 extern CCursor *GameCursor; /// cursor-type
164 extern int CursorX; /// cursor position on screen X
165 extern int CursorY; /// cursor position on screen Y
166 extern int CursorStartX; /// rectangle started on screen X
167 extern int CursorStartY; /// rectangle started on screen Y
168 extern int CursorStartScrMapX; /// the same in screen map coordinate system
169 extern int CursorStartScrMapY; /// the same in screen map coordinate system
170
171 /*----------------------------------------------------------------------------
172 -- Functions
173 ----------------------------------------------------------------------------*/
174
175 /// Load all cursors
176 extern void LoadCursors();
177
178 /// Cursor by identifier
179 extern CCursor *CursorByIdent(const std::string &ident);
180
181 /// Draw any cursor
182 extern void DrawCursor(void);
183 /// Hide the cursor
184 extern void HideCursor(void);
185 /// Animate the cursor
186 extern void CursorAnimate(unsigned ticks);
187
188 /// Initialize the cursor module
189 extern void InitVideoCursors(void);
190 /// Cleanup the cursor module
191 extern void CleanCursors(void);
192
193 //@}
194
195 #endif // !__CURSOR_H__