X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fleveleditor.h;h=6598994e9a71e74c1068760220e077bb02fafb76;hb=828b5e1ef1cb89d830735f24dd79bbd9b09d5b32;hp=a22be9af143c7c0a3872daa617086ba9d2c12707;hpb=6d9952207d28e19d3448c9e0f8859be19d3acc88;p=supertux.git diff --git a/src/leveleditor.h b/src/leveleditor.h index a22be9af1..6598994e9 100644 --- a/src/leveleditor.h +++ b/src/leveleditor.h @@ -1,5 +1,161 @@ +// $Id$ +// +// SuperTux +// Copyright (C) 2003 Ricardo Cruz +// Copyright (C) 2003 Tobias Glaesser +// +// 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 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -int level_editor_started; -int leveleditor(); +/* leveleditor.h - A built-in level editor for SuperTux */ + +#ifndef SUPERTUX_LEVELEDITOR_H +#define SUPERTUX_LEVELEDITOR_H + +#include "screen/drawing_context.h" +#include "game_object.h" +#include "screen/texture.h" +#include "level.h" +#include "button.h" +#include "menu.h" + +class LevelEditor +{ +public: + LevelEditor(); + ~LevelEditor(); + + int run(char* filename = NULL); + +private: + +// Functions void newlevel(void); void selectlevel(void); +void savelevel(); +void editlevel(void); +void testlevel(void); +void checkevents(void); +void unload_level(); + +/* own declerations */ +/* crutial ones (main loop) */ +void init_menus(); +int load_level_subset(char *filename); +void drawlevel(DrawingContext& context); +void drawinterface(DrawingContext& context); +void change(float x, float y, int tm, unsigned int c); +void showhelp(); +void set_defaults(void); +void activate_bad_guys(void); +void goto_level(int levelnb); +void highlight_selection(); + +void drawminimap(); + +void apply_level_settings_menu(); +void update_subset_settings_menu(); +void save_subset_settings_menu(); +void update_level_settings_menu(); +void change_object_properties(GameObject *pobj); + +// structs +struct TileOrObject +{ + TileOrObject() : tile(0), obj(NULL) { is_tile = true; }; + + void Tile(unsigned int set_to) { tile = set_to; is_tile = true; } + void Object(GameObject* pobj) { obj = pobj; is_tile = false; } + //Returns true for a tile + bool IsTile() { return is_tile; }; + //Returns true for a GameObject + bool IsObject() { return !is_tile; }; + + + void Init() { tile = 0; obj = NULL; is_tile = true; }; + + bool is_tile; //true for tile (false for object) + unsigned int tile; + GameObject* obj; +}; + +struct square +{ + int x1, y1, x2, y2; +}; + +/* selection modes */ +enum SelectionMode { CURSOR, SQUARE, NONE }; + +// variables +/* leveleditor internals */ +string_list_type level_subsets; +bool le_level_changed; /* if changes, ask for saving, when quiting*/ +bool show_minimap; +bool show_selections; +bool le_help_shown; +int pos_x, pos_y, cursor_x, cursor_y; +int le_levelnb; +Level* le_level; +LevelSubset* le_level_subset; +int le_show_grid; +int le_frame; +Surface* le_selection; +int done; +TileOrObject le_current; +bool le_mouse_pressed[2]; +bool le_mouse_clicked[2]; +Button* le_save_level_bt; +Button* le_exit_bt; +Button* le_test_level_bt; +Button* le_next_level_bt; +Button* le_previous_level_bt; +Button* le_move_right_bt; +Button* le_move_left_bt; +Button* le_move_up_bt; +Button* le_move_down_bt; +Button* le_rubber_bt; +Button* le_select_mode_one_bt; +Button* le_select_mode_two_bt; +Button* le_settings_bt; +Button* le_tilegroup_bt; +Button* le_objects_bt; +Button* le_object_select_bt; +Button* le_object_properties_bt; +ButtonPanel* le_tilemap_panel; +int active_tm; +Menu* leveleditor_menu; +Menu* subset_load_menu; +Menu* subset_new_menu; +Menu* subset_settings_menu; +Menu* level_settings_menu; +Menu* select_tilegroup_menu; +Menu* select_objects_menu; +Timer select_tilegroup_menu_effect; +Timer select_objects_menu_effect; +Timer display_level_info; +typedef std::map ButtonPanelMap; +ButtonPanelMap tilegroups_map; +ButtonPanelMap objects_map; +std::string cur_tilegroup; +std::string cur_objects; +MouseCursor* mouse_select_object; +MovingObject* selected_game_object; + +square selection; +SelectionMode le_selection_mode; +SDL_Event event; +}; + +#endif /*SUPERTUX_LEVELEDITOR_H*/