moved over some changes from cvs
[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 <set>
22 #include <string>
23
24 #include "video/drawing_context.h"
25 #include "timer.h"
26 #include "level.h"
27 #include "level_subset.h"
28
29 using namespace SuperTux;
30
31 namespace SuperTux {
32 class ButtonGroup;
33 class Menu;
34 class Surface;
35 }
36
37 class Sector;
38 class TileMap;
39
40 enum {
41   MN_ID_RETURN,
42   MN_ID_LOAD_SUBSET,
43   MN_ID_QUIT,
44
45   // settings menu ids:
46   MN_ID_NAME,
47   MN_ID_AUTHOR,
48   MN_ID_WIDTH,
49   MN_ID_HEIGHT,
50   MN_ID_APPLY_SETTINGS,
51   
52   // creating subset menu ids:
53   MN_ID_FILENAME_SUBSET,
54   MN_ID_TITLE_SUBSET,
55   MN_ID_DESCRIPTION_SUBSET,
56   MN_ID_CREATE_SUBSET
57   };
58
59 enum {
60   BT_LEVEL_SAVE,
61   BT_LEVEL_TEST,
62   BT_LEVEL_SETUP,
63
64   BT_NEXT_LEVEL,
65   BT_PREVIOUS_LEVEL,
66   BT_NEXT_SECTOR,
67   BT_PREVIOUS_SECTOR
68   };
69
70 enum {
71   OBJ_TRAMPOLINE = -100,
72   OBJ_FLYING_PLATFORM = -101,
73   OBJ_DOOR = -102
74   };
75
76 class LevelEditor
77 {
78 public:
79   LevelEditor();
80   ~LevelEditor();
81
82   void run(const std::string filename = "");
83
84 private:
85   void events();
86   void action();
87   void draw(DrawingContext& context);
88
89   void load_level_subset(std::string filename);
90   void load_level(std::string filename);
91   void load_level(int nb);
92   void load_sector(size_t num);
93
94   void save_level();
95   void test_level();
96   void setup_level();
97
98   void show_help();
99
100   void change(int x, int y, int newtile, int layer);
101
102   void load_buttons_gfx();
103   void free_buttons_gfx();
104
105   Level* level;
106   std::string level_filename;
107
108   size_t sectornum; // number of current sector
109   Sector* sector;  // current sector
110   TileMap *solids, *foregrounds, *backgrounds;
111   std::string sector_name;
112
113   std::set<std::string> level_subsets;
114   LevelSubset* level_subset;
115   int level_nb;
116
117   Menu* main_menu;
118   Menu* subset_menu;
119   Menu* create_subset_menu;
120   Menu* settings_menu;
121
122   bool left_button, middle_button, mouse_moved;
123   int mouse_x, mouse_y;
124   bool done;
125   bool show_grid;
126
127   Vector scroll;
128   float zoom;
129
130   Timer2 level_name_timer;
131
132   Surface *img_background_bt, *img_foreground_bt, *img_interactive_bt;
133   Surface *img_save_level_bt, *img_setup_level_bt, *img_test_level_bt;
134   Surface *img_rubber_bt;
135   Surface *img_previous_level_bt, *img_next_level_bt, *img_previous_sector_bt, *img_next_sector_bt;
136
137   ButtonGroup *tiles_board, *tiles_layer, *level_options;
138   int gameobjs_first_id, cur_layer;
139
140   std::vector <std::vector <int> > selection;
141   Vector selection_ini, selection_end;
142
143   bool level_changed;
144
145 private:
146   Sector* create_sector(const std::string& name, size_t width, size_t height);
147 };
148
149 #endif