X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fleveleditor.h;h=912f8ea33c4b1255647fac42c0bc72203819809a;hb=9599042661b468aae7bd34dca05441c0ebc93ad7;hp=4ded83fbc5636b656c87cab46e61f8564e81b93b;hpb=c79b901309bf5e0544fef1e92d264f51402f4370;p=supertux.git diff --git a/src/leveleditor.h b/src/leveleditor.h index 4ded83fbc..912f8ea33 100644 --- a/src/leveleditor.h +++ b/src/leveleditor.h @@ -1,34 +1,77 @@ -// $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. - -/* leveleditor.h - A built-in level editor for SuperTux */ +/*************************************************************************** + leveleditor.h - built'in level editor + ------------------- + begin : June, 23 2004 + copyright : (C) 2004 by Ricardo Cruz + email : rick2@aeiou.pt + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ #ifndef SUPERTUX_LEVELEDITOR_H #define SUPERTUX_LEVELEDITOR_H -#include "screen/drawing_context.h" -#include "game_object.h" -#include "screen/surface.h" +#include +#include + +#include "video/drawing_context.h" +#include "timer.h" #include "level.h" -#include "button.h" -#include "menu.h" +#include "level_subset.h" + +using namespace SuperTux; + +namespace SuperTux { +class ButtonGroup; +class Menu; +class Surface; +} + +class Sector; +class TileMap; + +enum { + MN_ID_RETURN, + MN_ID_LOAD_SUBSET, + MN_ID_QUIT, + + // settings menu ids: + MN_ID_NAME, + MN_ID_AUTHOR, + MN_ID_WIDTH, + MN_ID_HEIGHT, + MN_ID_APPLY_SETTINGS, + + // creating subset menu ids: + MN_ID_FILENAME_SUBSET, + MN_ID_TITLE_SUBSET, + MN_ID_DESCRIPTION_SUBSET, + MN_ID_CREATE_SUBSET + }; + +enum { + BT_LEVEL_SAVE, + BT_LEVEL_TEST, + BT_LEVEL_SETUP, + + BT_NEXT_LEVEL, + BT_PREVIOUS_LEVEL, + BT_NEXT_SECTOR, + BT_PREVIOUS_SECTOR + }; + +enum { + OBJ_TRAMPOLINE = -100, + OBJ_FLYING_PLATFORM = -101, + OBJ_DOOR = -102 + }; class LevelEditor { @@ -36,126 +79,71 @@ public: LevelEditor(); ~LevelEditor(); - int run(char* filename = NULL); + void run(const std::string filename = ""); private: + void events(); + void action(); + void draw(DrawingContext& context); -// 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 load_level_subset(std::string filename); + void load_level(std::string filename); + void load_level(int nb); + void load_sector(size_t num); - 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 save_level(); + void test_level(); + void setup_level(); + void show_help(); - void Init() { tile = 0; obj = NULL; is_tile = true; }; + void change(int x, int y, int newtile, int layer); - bool is_tile; //true for tile (false for object) - unsigned int tile; - GameObject* obj; -}; + void load_buttons_gfx(); + void free_buttons_gfx(); -struct square -{ - int x1, y1, x2, y2; -}; + Level* level; + std::string level_filename; + + size_t sectornum; // number of current sector + Sector* sector; // current sector + TileMap *solids, *foregrounds, *backgrounds; + std::string sector_name; + + std::set level_subsets; + LevelSubset* level_subset; + int level_nb; + + Menu* main_menu; + Menu* subset_menu; + Menu* create_subset_menu; + Menu* settings_menu; -/* 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; + bool left_button, middle_button, mouse_moved; + int mouse_x, mouse_y; + bool done; + bool show_grid; + + Vector scroll; + float zoom; + + Timer2 level_name_timer; + + Surface *img_background_bt, *img_foreground_bt, *img_interactive_bt; + Surface *img_save_level_bt, *img_setup_level_bt, *img_test_level_bt; + Surface *img_rubber_bt; + Surface *img_previous_level_bt, *img_next_level_bt, *img_previous_sector_bt, *img_next_sector_bt; + + ButtonGroup *tiles_board, *tiles_layer, *level_options; + int gameobjs_first_id, cur_layer; + + std::vector > selection; + Vector selection_ini, selection_end; + + bool level_changed; + +private: + Sector* create_sector(const std::string& name, size_t width, size_t height); }; -#endif /*SUPERTUX_LEVELEDITOR_H*/ +#endif