4 // Copyright (C) 2003 Ricardo Cruz <rick2@aeiou.pt>
5 // Copyright (C) 2003 Tobias Glaesser <tobi.web@gmx.de>
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 /* leveleditor.h - A built-in level editor for SuperTux */
23 #ifndef SUPERTUX_LEVELEDITOR_H
24 #define SUPERTUX_LEVELEDITOR_H
26 #include "screen/drawing_context.h"
27 #include "game_object.h"
28 #include "screen/texture.h"
39 int run(char* filename = NULL);
45 void selectlevel(void);
49 void checkevents(void);
52 /* own declerations */
53 /* crutial ones (main loop) */
55 int load_level_subset(char *filename);
56 void drawlevel(DrawingContext& context);
57 void drawinterface(DrawingContext& context);
58 void change(float x, float y, int tm, unsigned int c);
60 void set_defaults(void);
61 void activate_bad_guys(void);
62 void goto_level(int levelnb);
63 void highlight_selection();
67 void apply_level_settings_menu();
68 void update_subset_settings_menu();
69 void save_subset_settings_menu();
70 void update_level_settings_menu();
71 void change_object_properties(GameObject *pobj);
76 TileOrObject() : tile(0), obj(NULL) { is_tile = true; };
78 void Tile(unsigned int set_to) { tile = set_to; is_tile = true; }
79 void Object(GameObject* pobj) { obj = pobj; is_tile = false; }
80 //Returns true for a tile
81 bool IsTile() { return is_tile; };
82 //Returns true for a GameObject
83 bool IsObject() { return !is_tile; };
86 void Init() { tile = 0; obj = NULL; is_tile = true; };
88 bool is_tile; //true for tile (false for object)
99 enum SelectionMode { CURSOR, SQUARE, NONE };
102 /* leveleditor internals */
103 string_list_type level_subsets;
104 bool le_level_changed; /* if changes, ask for saving, when quiting*/
106 bool show_selections;
108 int pos_x, pos_y, cursor_x, cursor_y;
111 LevelSubset* le_level_subset;
114 Surface* le_selection;
116 TileOrObject le_current;
117 bool le_mouse_pressed[2];
118 bool le_mouse_clicked[2];
119 Button* le_save_level_bt;
121 Button* le_test_level_bt;
122 Button* le_next_level_bt;
123 Button* le_previous_level_bt;
124 Button* le_move_right_bt;
125 Button* le_move_left_bt;
126 Button* le_move_up_bt;
127 Button* le_move_down_bt;
128 Button* le_rubber_bt;
129 Button* le_select_mode_one_bt;
130 Button* le_select_mode_two_bt;
131 Button* le_settings_bt;
132 Button* le_tilegroup_bt;
133 Button* le_objects_bt;
134 Button* le_object_select_bt;
135 Button* le_object_properties_bt;
136 ButtonPanel* le_tilemap_panel;
138 Menu* leveleditor_menu;
139 Menu* subset_load_menu;
140 Menu* subset_new_menu;
141 Menu* subset_settings_menu;
142 Menu* level_settings_menu;
143 Menu* select_tilegroup_menu;
144 Menu* select_objects_menu;
145 Timer select_tilegroup_menu_effect;
146 Timer select_objects_menu_effect;
147 Timer display_level_info;
148 typedef std::map<std::string, ButtonPanel*> ButtonPanelMap;
149 ButtonPanelMap tilegroups_map;
150 ButtonPanelMap objects_map;
151 std::string cur_tilegroup;
152 std::string cur_objects;
153 MouseCursor* mouse_select_object;
154 MovingObject* selected_game_object;
157 SelectionMode le_selection_mode;
161 #endif /*SUPERTUX_LEVELEDITOR_H*/