0527f7aa6585824a1cb2567d1372cca463f66d29
[supertux.git] / src / leveleditor.h
1 /***************************************************************************
2                           leveleditor.h  -  built'in level editor
3                              -------------------
4     begin                : June, 23 2004
5     copyright            : (C) 2004 by Ricardo Cruz
6     email                : rick2@aeiou.pt
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 #ifndef SUPERTUX_LEVELEDITOR_H
19 #define SUPERTUX_LEVELEDITOR_H
20
21 #include "SDL.h"
22
23 #include <set>
24 #include <string>
25
26 #include "video/drawing_context.h"
27 #include "timer.h"
28 #include "level.h"
29 #include "level_subset.h"
30
31 using namespace SuperTux;
32
33 namespace SuperTux {
34 class ButtonGroup;
35 class Menu;
36 class Surface;
37 }
38
39 class Sector;
40 class TileMap;
41
42 enum {
43   MN_ID_RETURN,
44   MN_ID_LOAD_SUBSET,
45   MN_ID_QUIT,
46
47   // settings menu ids:
48   MN_ID_NAME,
49   MN_ID_AUTHOR,
50   MN_ID_WIDTH,
51   MN_ID_HEIGHT,
52   MN_ID_APPLY_SETTINGS,
53   
54   // creating subset menu ids:
55   MN_ID_FILENAME_SUBSET,
56   MN_ID_TITLE_SUBSET,
57   MN_ID_DESCRIPTION_SUBSET,
58   MN_ID_CREATE_SUBSET
59   };
60
61 enum {
62   BT_LEVEL_SAVE,
63   BT_LEVEL_TEST,
64   BT_LEVEL_SETUP,
65
66   BT_NEXT_LEVEL,
67   BT_PREVIOUS_LEVEL,
68   BT_NEXT_SECTOR,
69   BT_PREVIOUS_SECTOR
70   };
71
72 enum {
73   OBJ_TRAMPOLINE = -100,
74   OBJ_FLYING_PLATFORM = -101,
75   OBJ_DOOR = -102
76   };
77
78 class LevelEditor
79 {
80 public:
81   LevelEditor();
82   ~LevelEditor();
83
84   void run(const std::string filename = "");
85
86 private:
87   void events();
88   void action();
89   void draw(DrawingContext& context);
90
91   void load_level_subset(std::string filename);
92   void load_level(std::string filename);
93   void load_level(int nb);
94   void load_sector(std::string name);
95   void load_sector(Sector* sector);
96
97   void save_level();
98   void test_level();
99   void setup_level();
100
101   void show_help();
102
103   void change(int x, int y, int newtile, int layer);
104
105   void load_buttons_gfx();
106   void free_buttons_gfx();
107
108   Level* level;
109   std::string level_filename;
110
111   Sector* sector;  // current sector
112   TileMap *solids, *foregrounds, *backgrounds;
113   std::string sector_name;
114
115   std::set<std::string> level_subsets;
116   LevelSubset* level_subset;
117   int level_nb;
118
119   Menu* main_menu;
120   Menu* subset_menu;
121   Menu* create_subset_menu;
122   Menu* settings_menu;
123
124   bool left_button, middle_button, mouse_moved;
125   bool done;
126   bool show_grid;
127
128   Vector scroll;
129   float zoom;
130
131   SDL_Event event;
132   Timer2 frame_timer;
133   Timer2 level_name_timer;
134
135   Surface *img_background_bt, *img_foreground_bt, *img_interactive_bt;
136   Surface *img_save_level_bt, *img_setup_level_bt, *img_test_level_bt;
137   Surface *img_rubber_bt;
138   Surface *img_previous_level_bt, *img_next_level_bt, *img_previous_sector_bt, *img_next_sector_bt;
139
140   ButtonGroup *tiles_board, *tiles_layer, *level_options;
141   int cur_layer;
142
143   std::vector <std::vector <int> > selection;
144   Vector selection_ini, selection_end;
145
146   bool level_changed;
147 };
148
149 #endif