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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
/***************************************************************************
* editor.h - header for the corresponding cpp file
*
* Copyright (C) 2006 - 2008 Florian Richter
***************************************************************************/
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SMC_EDITOR_H
#define SMC_EDITOR_H
#include "../core/globals.h"
#include "../objects/sprite.h"
#include "../gui/hud.h"
#include "../video/img_settings.h"
/* *** *** *** *** *** *** *** cEditor_Object_Settings_Item *** *** *** *** *** *** *** *** *** *** */
class cEditor_Object_Settings_Item
{
public:
cEditor_Object_Settings_Item( void );
~cEditor_Object_Settings_Item( void );
// name
CEGUI::Window *window_name;
// settings
CEGUI::Window *window_setting;
// if set start new row
bool advance_row;
};
/* *** *** *** *** *** *** *** *** cEditor_Item_Object *** *** *** *** *** *** *** *** *** */
class cEditor_Item_Object : public CEGUI::ListboxItem
{
public:
cEditor_Item_Object( string text );
virtual ~cEditor_Item_Object( void );
// Initialize
void Init( void );
/*!
\brief
Return the rendered pixel size of this list box item.
\return
Size object describing the size of the list box item in pixels.
*/
virtual CEGUI::Size getPixelSize( void ) const;
// draw
void draw( const CEGUI::Vector3 &position, float alpha, const CEGUI::Rect &clipper ) const;
void draw( CEGUI::RenderCache &cache, const CEGUI::Rect &targetRect, float zBase, float alpha, const CEGUI::Rect *clipper) const;
// draw image
void Draw_Image( void );
// Text
CEGUI::ListboxTextItem *list_text;
// sprite
cSprite *sprite_obj;
// preview image scale
float preview_scale;
};
/* *** *** *** *** *** *** *** *** cEditor_Menu_Object *** *** *** *** *** *** *** *** *** */
class cEditor_Menu_Object : public CEGUI::ListboxTextItem
{
public:
cEditor_Menu_Object( string text );
virtual ~cEditor_Menu_Object( void );
// Initialize
void Init( void );
// Name
string name;
// tags or function name if function
string tags;
// if type is a function
bool bfunction;
// if Object is an Header
bool header;
};
/* *** *** *** *** *** *** *** cEditor *** *** *** *** *** *** *** *** *** *** */
class cEditor : public CEGUI::XMLHandler
{
public:
cEditor( void );
virtual ~cEditor( void );
// Initialize Editor
virtual void Init( void );
// Unload Editor
virtual void Unload( void );
// Toggle
void Toggle( void );
// Enable
virtual void Enable( void );
/* Disable
* native_mode : if unset the current game mode isn't altered
*/
virtual void Disable( bool native_mode = 1 );
// Update Editor
virtual void Update( void );
// Draw the Editor Menus
virtual void Draw( void );
// Function : Process_Input
// static input handler
void Process_Input( void );
// Handle Input event
virtual bool Handle_Event( SDL_Event *ev );
/* handle key down event
* returns true if processed
*/
virtual bool Key_Down( SDLKey key );
/* handle mouse button down event
* returns true if processed
*/
virtual bool Mouse_Down( Uint8 button );
/* handle mouse button up event
* returns true if processed
*/
virtual bool Mouse_Up( Uint8 button );
// ##### Main Menu
// Add Menu Entry
void Add_Menu_Object( string name, string tags, CEGUI::colour normal_color = CEGUI::colour( 1, 1, 1 ) );
// Set Active Menu Entry
virtual void Activate_Menu_Item( cEditor_Menu_Object *entry );
// ##### Item Menu
// Load an defined Menu
virtual bool Load_Item_Menu( string item_tag );
// Unload the Menu
void Unload_Item_Menu( void );
/* Add an Object to the Item list
* if nName is set it will not use the object name
* if image is set the default object image is not used
*/
void Add_Item_Object( cSprite *sprite, string new_name = "", cGL_Surface *image = NULL );
// Loads all Image Items
void Load_Image_Items( string dir );
// Active Item Entry
virtual void Activate_Item( cEditor_Item_Object *entry );
// #### Editor Functions
// push the object into the front or back
void Change_Draw_Position( cSprite *obj, bool push_back );
/* copy the given object(s) next to itself into the given direction
* if offset is given it will be used instead of the auto calculated direction size
* returns the new object(s)
*/
SpriteList Copy_Direction( SpriteList objects, ObjectDirection dir );
cSprite *Copy_Direction( cSprite *obj, ObjectDirection dir, int offset = 0 );
// CEGUI events
bool Editor_Mouse_Enter( const CEGUI::EventArgs &event ); // Mouse entered Window
bool Menu_Select( const CEGUI::EventArgs &event ); // Menu selected item
bool Item_Select( const CEGUI::EventArgs &event ); // Item selected item
// Menu functions
void Function_Exit( void );
virtual bool Function_New( void ) { return 0; };
virtual void Function_Load( void ) {};
virtual void Function_Save( bool with_dialog = 0 ) {};
virtual void Function_Save_as( void ) {};
virtual void Function_Delete( void ) {};
virtual void Function_Reload( void ) {};
virtual void Function_Clear( void ) {};
virtual void Function_Settings( void ) {};
// true if editor is active
bool enabled;
// Editor filenames
string menu_filename;
string items_filename;
// Required item tag
string editor_item_tag;
// editor Camera speed
float camera_speed;
// Timer until the Menu will be minimized
float menu_timer;
// Objects with tags
typedef vector<cImage_settings_data *> TaggedItemImageSettingsList;
TaggedItemImageSettingsList tagged_item_images;
typedef vector<cSprite *> TaggedItemObjectsList;
TaggedItemObjectsList tagged_item_objects;
// CEGUI window
CEGUI::Window *editor_window;
protected:
// Check if the given tag is available in the string
bool Is_Tag_Available( string str, string tag, unsigned int search_pos = 0 );
// Draw Editor Help Box
void Draw_Editor_Help( void );
/* Add a Help Text Line to the Help Box
* spacing : can be used f.e. a header
* pos_x : the line start position x
*/
void Add_Help_Line( string key_text, string text = "", float spacing = 0, float pos_x = 60 );
// if true show the editor help
bool show_editor_help;
// help sprites
HudSpriteList help_sprites;
private:
// XML element start
virtual void elementStart( const CEGUI::String &element, const CEGUI::XMLAttributes &attributes );
// XML element end
virtual void elementEnd( const CEGUI::String &element );
void Handle_Item( const CEGUI::XMLAttributes &attributes );
void Handle_Menu( const CEGUI::XMLAttributes &attributes );
// XML element Item Tag list
CEGUI::XMLAttributes xml_attributes;
};
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
#endif
|