X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fleveleditor.h;h=de4065b6d8c8f4d7b8c6522af15ab16ae2366ee1;hb=609794e5b7fb466ca1a53d7a2406e2a8ed547de8;hp=d4bf7f5c874e4b8c06198d639e79f8f051ffc1d6;hpb=236df51d91f0845cd4e06b3269e262911d81f5db;p=supertux.git diff --git a/src/leveleditor.h b/src/leveleditor.h index d4bf7f5c8..de4065b6d 100644 --- a/src/leveleditor.h +++ b/src/leveleditor.h @@ -1,8 +1,7 @@ // $Id$ // // SuperTux -// Copyright (C) 2003 Ricardo Cruz -// Copyright (C) 2003 Tobias Glaesser +// Copyright (C) 2005 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -16,186 +15,141 @@ // // 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 */ - +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +// 02111-1307, USA. #ifndef SUPERTUX_LEVELEDITOR_H #define SUPERTUX_LEVELEDITOR_H +#if 0 + +#include +#include + #include "video/drawing_context.h" -#include "special/game_object.h" -#include "video/surface.h" +#include "timer.h" #include "level.h" #include "level_subset.h" -#include "special/moving_object.h" -#include "gui/button.h" -#include "gui/menu.h" - -enum LevelEditorMainMenuIDs { - MNID_RETURNLEVELEDITOR, - MNID_SUBSETSETTINGS, - MNID_QUITLEVELEDITOR - }; + +using namespace SuperTux; + +namespace SuperTux { +class ButtonGroup; +} + +class Menu; +class Sector; +class TileMap; +class Surface; + +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, -enum LevelEditorSubsetSettingsIDs { - MNID_SUBSETTITLE, - MNID_SUBSETDESCRIPTION, - MNID_SUBSETSAVECHANGES + // creating subset menu ids: + MN_ID_FILENAME_SUBSET, + MN_ID_TITLE_SUBSET, + MN_ID_DESCRIPTION_SUBSET, + MN_ID_CREATE_SUBSET }; - -enum LevelEditorSubsetNewIDs { - MNID_SUBSETNAME, - MNID_CREATESUBSET -}; -enum LevelEditorSettingsMenuIDs { - MNID_NAME, - MNID_AUTHOR, - MNID_SONG, - MNID_BGIMG, - MNID_PARTICLE, - MNID_LENGTH, - MNID_HEIGHT, - MNID_TIME, - MNID_GRAVITY, - MNID_BGSPEED, - MNID_TopRed, - MNID_TopGreen, - MNID_TopBlue, - MNID_BottomRed, - MNID_BottomGreen, - MNID_BottomBlue, - MNID_APPLY +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 { 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; + + bool left_button, middle_button, mouse_moved; + int mouse_x, mouse_y; + bool done; + bool show_grid; -/* 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; + 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 + +#endif