- More work on scripting interface
[supertux.git] / src / leveleditor.h
1 //  $Id$
2 // 
3 //  SuperTux
4 //  Copyright (C) 2005 Matthias Braun <matze@braunis.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 // 
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 //  02111-1307, USA.
20 #ifndef SUPERTUX_LEVELEDITOR_H
21 #define SUPERTUX_LEVELEDITOR_H
22
23 #if 0
24
25 #include <set>
26 #include <string>
27
28 #include "video/drawing_context.h"
29 #include "timer.h"
30 #include "level.h"
31 #include "level_subset.h"
32
33 using namespace SuperTux;
34
35 namespace SuperTux {
36 class ButtonGroup;
37 }
38
39 class Menu;
40 class Sector;
41 class TileMap;
42 class Surface;
43
44 enum {
45   MN_ID_RETURN,
46   MN_ID_LOAD_SUBSET,
47   MN_ID_QUIT,
48
49   // settings menu ids:
50   MN_ID_NAME,
51   MN_ID_AUTHOR,
52   MN_ID_WIDTH,
53   MN_ID_HEIGHT,
54   MN_ID_APPLY_SETTINGS,
55   
56   // creating subset menu ids:
57   MN_ID_FILENAME_SUBSET,
58   MN_ID_TITLE_SUBSET,
59   MN_ID_DESCRIPTION_SUBSET,
60   MN_ID_CREATE_SUBSET
61   };
62
63 enum {
64   BT_LEVEL_SAVE,
65   BT_LEVEL_TEST,
66   BT_LEVEL_SETUP,
67
68   BT_NEXT_LEVEL,
69   BT_PREVIOUS_LEVEL,
70   BT_NEXT_SECTOR,
71   BT_PREVIOUS_SECTOR
72   };
73
74 enum {
75   OBJ_TRAMPOLINE = -100,
76   OBJ_FLYING_PLATFORM = -101,
77   OBJ_DOOR = -102
78   };
79
80 class LevelEditor
81 {
82 public:
83   LevelEditor();
84   ~LevelEditor();
85
86   void run(const std::string filename = "");
87
88 private:
89   void events();
90   void action();
91   void draw(DrawingContext& context);
92
93   void load_level_subset(std::string filename);
94   void load_level(std::string filename);
95   void load_level(int nb);
96   void load_sector(size_t num);
97
98   void save_level();
99   void test_level();
100   void setup_level();
101
102   void show_help();
103
104   void change(int x, int y, int newtile, int layer);
105
106   void load_buttons_gfx();
107   void free_buttons_gfx();
108
109   Level* level;
110   std::string level_filename;
111
112   size_t sectornum; // number of current sector
113   Sector* sector;  // current sector
114   TileMap *solids, *foregrounds, *backgrounds;
115   std::string sector_name;
116
117   std::set<std::string> level_subsets;
118   LevelSubset* level_subset;
119   int level_nb;
120
121   Menu* main_menu;
122   Menu* subset_menu;
123   Menu* create_subset_menu;
124   Menu* settings_menu;
125
126   bool left_button, middle_button, mouse_moved;
127   int mouse_x, mouse_y;
128   bool done;
129   bool show_grid;
130
131   Vector scroll;
132   float zoom;
133
134   Timer2 level_name_timer;
135
136   Surface *img_background_bt, *img_foreground_bt, *img_interactive_bt;
137   Surface *img_save_level_bt, *img_setup_level_bt, *img_test_level_bt;
138   Surface *img_rubber_bt;
139   Surface *img_previous_level_bt, *img_next_level_bt, *img_previous_sector_bt, *img_next_sector_bt;
140
141   ButtonGroup *tiles_board, *tiles_layer, *level_options;
142   int gameobjs_first_id, cur_layer;
143
144   std::vector <std::vector <int> > selection;
145   Vector selection_ini, selection_end;
146
147   bool level_changed;
148
149 private:
150   Sector* create_sector(const std::string& name, size_t width, size_t height);
151 };
152
153 #endif
154
155 #endif