-
-
Notifications
You must be signed in to change notification settings - Fork 994
/
editor_controller.hpp
248 lines (186 loc) · 6.92 KB
/
editor_controller.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/*
Copyright (C) 2008 - 2014 by Tomasz Sniatowski <kailoran@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
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.
See the COPYING file for more details.
*/
#ifndef EDITOR_EDITOR_CONTROLLER_HPP_INCLUDED
#define EDITOR_EDITOR_CONTROLLER_HPP_INCLUDED
#include "editor/editor_display.hpp"
#include "editor/editor_main.hpp"
#include "editor/map/context_manager.hpp"
#include "editor/map/map_context.hpp"
#include "editor/map/map_fragment.hpp"
#include "editor/toolkit/editor_toolkit.hpp"
#include "../../controller_base.hpp"
#include "help/help.hpp"
#include "../../mouse_handler_base.hpp"
#include "../../tooltips.hpp"
#include "sound_music_track.hpp"
class map_generator;
namespace tooltips {
struct manager;
}
namespace font {
struct floating_label_context;
}
namespace preferences {
struct display_manager;
} // namespace preferences
namespace editor {
class editor_map;
std::string get_left_button_function();
enum menu_type {
MAP,
PALETTE,
AREA,
SIDE,
TIME,
LOCAL_TIME,
SCHEDULE,
LOCAL_SCHEDULE,
MUSIC,
UNIT_FACING
};
/**
* The editor_controller class contains the mouse and keyboard event handling
* routines for the editor. It also serves as the main editor class with the
* general logic.
*/
class editor_controller : public controller_base,
public events::mouse_handler_base,
private boost::noncopyable
{
public:
/**
* The constructor. A initial map context can be specified here, the controller
* will assume ownership and delete the pointer during destruction, but changes
* to the map can be retrieved between the main loop's end and the controller's
* destruction.
*/
editor_controller(const config &game_config, CVideo& video);
~editor_controller();
/** Editor main loop */
EXIT_STATUS main_loop();
/** Takes a screenshot **/
void do_screenshot(const std::string& screenshot_filename = "map_screenshot.bmp");
/** Process a hotkey quit command */
void hotkey_quit();
/** Show a quit confirmation dialog and if confirmed quit with the given exit status */
void quit_confirm(EXIT_STATUS status);
/** Display the settings dialog, used to control e.g. the lighting settings */
void custom_tods_dialog();
/** Save the map, open dialog if not named yet. */
void save_map() {context_manager_->save_map();}
/** command_executor override */
bool can_execute_command(const hotkey::hotkey_command& command, int index = -1) const;
/** command_executor override */
hotkey::ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND command, int index) const;
/** command_executor override */
bool execute_command(const hotkey::hotkey_command& command, int index = -1);
/** controller_base override */
void show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu, display& disp);
void show_help();
void status_table();
/** Show the preferences dialog */
void preferences();
/** Grid toggle */
void toggle_grid();
void terrain_description();
void unit_description();
void change_unit_id();
void rename_unit();
void unit_list();
/** Copy the selection on the current map to the clipboard */
void copy_selection();
/** Cut the selection from the current map to the clipboard */
void cut_selection();
/** Export the WML-compatible list of selected tiles to the system clipboard */
void export_selection_coords();
void update_mouse_action_highlights();
/** Save the current selection to the active area. */
void save_area();
/** Add a new area to the current context, filled with the selection if any. */
void add_area();
/* mouse_handler_base overrides */
void mouse_motion(int x, int y, const bool browse, bool update, map_location new_loc = map_location::null_location());
editor_display& gui() { return *gui_; }
const editor_display& gui() const { return *gui_; }
bool allow_mouse_wheel_scroll(int x, int y);
bool right_click_show_menu(int x, int y, const bool browse);
bool left_click(int x, int y, const bool browse);
void left_drag_end(int x, int y, const bool browse);
void left_mouse_up(int x, int y, const bool browse);
bool right_click(int x, int y, const bool browse);
void right_drag_end(int x, int y, const bool browse);
void right_mouse_up(int x, int y, const bool browse);
protected:
/* controller_base overrides */
void process_keyup_event(const SDL_Event& event);
mouse_handler_base& get_mouse_handler_base() { return *this; }
editor_display& get_display() {return *gui_;}
/** Get the current mouse action */
mouse_action* get_mouse_action();
/**
* Perform an action, then delete the action object.
* The pointer can be NULL, in which case nothing will happen.
*/
void perform_delete(editor_action* action);
/**
* Peform an action on the current map_context, then refresh the display
* and delete the pointer. The pointer can be NULL, in which case nothing will happen.
*/
void perform_refresh_delete(editor_action* action, bool drag_part = false);
private:
/** init the display object and general set-up */
void init_gui();
/** init the available time-of-day settings */
void init_tods(const config& game_config);
/** init background music for the editor */
void init_music(const config& game_config);
/** Load editor-specific tooltips */
void load_tooltips();
/** Reload images */
void refresh_image_cache();
/**
* Callback function passed to display to be called on each redraw_everything run.
* Redraws toolbar, brush bar and related items.
*/
void display_redraw_callback(display&);
/**
* Undos an action in the current map context
*/
void undo();
/**
* Redos an action in the current map context
*/
void redo();
editor::menu_type active_menu_;
/** Reports object. Must be initialized before the gui_ */
boost::scoped_ptr<reports> reports_;
/** The display object used and owned by the editor. */
boost::scoped_ptr<editor_display> gui_;
/** Pre-defined time of day lighting settings for the settings dialog */
typedef std::map<std::string, std::pair<std::string ,std::vector<time_of_day> > > tods_map;
tods_map tods_;
/* managers */
public:
boost::scoped_ptr<context_manager> context_manager_;
private:
boost::scoped_ptr<editor_toolkit> toolkit_;
boost::scoped_ptr<preferences::display_manager> prefs_disp_manager_;
tooltips::manager tooltip_manager_;
boost::scoped_ptr<font::floating_label_context> floating_label_manager_;
boost::scoped_ptr<help::help_manager> help_manager_;
/** Quit main loop flag */
bool do_quit_;
EXIT_STATUS quit_mode_;
std::vector<sound::music_track> music_tracks_;
};
} //end namespace editor
#endif