Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef EDITOR_EDITOR_CONTROLLER_HPP_INCLUDED
00017 #define EDITOR_EDITOR_CONTROLLER_HPP_INCLUDED
00018
00019 #include "editor_display.hpp"
00020 #include "editor_main.hpp"
00021 #include "map/map_context.hpp"
00022 #include "map/map_fragment.hpp"
00023
00024 #include "editor/toolkit/editor_toolkit.hpp"
00025
00026 #include "../controller_base.hpp"
00027 #include "../mouse_handler_base.hpp"
00028 #include "../tooltips.hpp"
00029
00030 #include "editor/map/context_manager.hpp"
00031
00032 class map_generator;
00033
00034 namespace tooltips {
00035 struct manager;
00036 }
00037
00038 namespace font {
00039 struct floating_label_context;
00040 }
00041
00042 namespace rand_rng {
00043 class rng;
00044 struct set_random_generator;
00045 }
00046
00047 namespace preferences {
00048 struct display_manager;
00049 }
00050
00051 namespace halo {
00052 struct manager;
00053 }
00054
00055 namespace editor {
00056
00057 class editor_map;
00058
00059 std::string get_left_button_function();
00060
00061 enum menu_type {
00062 MAP,
00063 PALETTE,
00064 AREA,
00065 SIDE
00066 };
00067
00068
00069
00070
00071
00072
00073 class editor_controller : public controller_base,
00074 public events::mouse_handler_base,
00075 private boost::noncopyable
00076 {
00077 public:
00078
00079
00080
00081
00082
00083
00084 editor_controller(const config &game_config, CVideo& video);
00085
00086 ~editor_controller();
00087
00088
00089 EXIT_STATUS main_loop();
00090
00091
00092 void do_screenshot(const std::string& screenshot_filename = "map_screenshot.bmp");
00093
00094
00095 void hotkey_quit();
00096
00097
00098 void quit_confirm(EXIT_STATUS status);
00099
00100
00101 void editor_settings_dialog();
00102
00103
00104 void save_map() {context_manager_->save_map();};
00105
00106
00107 bool can_execute_command(hotkey::HOTKEY_COMMAND, int index = -1) const;
00108
00109
00110 hotkey::ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND command, int index) const;
00111
00112
00113 bool execute_command(hotkey::HOTKEY_COMMAND command, int index = -1);
00114
00115
00116 void show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu);
00117
00118
00119 void preferences();
00120
00121
00122 void toggle_grid();
00123
00124
00125 void copy_selection();
00126
00127
00128 void cut_selection();
00129
00130
00131 void export_selection_coords();
00132
00133 void update_mouse_action_highlights();
00134
00135
00136 void mouse_motion(int x, int y, const bool browse, bool update, map_location new_loc = map_location::null_location);
00137 editor_display& gui() { return *gui_; }
00138 const editor_display& gui() const { return *gui_; }
00139 bool allow_mouse_wheel_scroll(int x, int y);
00140 bool right_click_show_menu(int x, int y, const bool browse);
00141 bool left_click(int x, int y, const bool browse);
00142 void left_drag_end(int x, int y, const bool browse);
00143 void left_mouse_up(int x, int y, const bool browse);
00144 bool right_click(int x, int y, const bool browse);
00145 void right_drag_end(int x, int y, const bool browse);
00146 void right_mouse_up(int x, int y, const bool browse);
00147
00148
00149 protected:
00150
00151 void process_keyup_event(const SDL_Event& event);
00152 mouse_handler_base& get_mouse_handler_base() { return *this; };
00153 editor_display& get_display() {return *gui_;};
00154
00155
00156 mouse_action* get_mouse_action();
00157
00158
00159
00160
00161
00162 void perform_delete(editor_action* action);
00163
00164
00165
00166
00167
00168 void perform_refresh_delete(editor_action* action, bool drag_part = false);
00169
00170
00171
00172
00173
00174
00175
00176 void editor_settings_dialog_redraw_callback(int r, int g, int b);
00177
00178 private:
00179
00180
00181 void init_gui();
00182
00183
00184 void init_tods(const config& game_config);
00185
00186
00187 void init_music(const config& game_config);
00188
00189
00190 void load_tooltips();
00191
00192
00193 void refresh_image_cache();
00194
00195
00196
00197
00198
00199 void display_redraw_callback(display&);
00200
00201
00202
00203
00204 void undo();
00205
00206
00207
00208
00209 void redo();
00210
00211 editor::menu_type active_menu_;
00212
00213 boost::scoped_ptr<rand_rng::rng> rng_;
00214
00215 boost::scoped_ptr<rand_rng::set_random_generator> rng_setter_;
00216
00217 unit_map units_;
00218
00219
00220 boost::scoped_ptr<editor_display> gui_;
00221
00222 std::vector<team> teams_;
00223
00224
00225 std::vector<time_of_day> tods_;
00226
00227
00228 public:
00229 boost::scoped_ptr<context_manager> context_manager_;
00230 private:
00231 boost::scoped_ptr<editor_toolkit> toolkit_;
00232 boost::scoped_ptr<preferences::display_manager> prefs_disp_manager_;
00233 tooltips::manager tooltip_manager_;
00234 boost::scoped_ptr<font::floating_label_context> floating_label_manager_;
00235
00236 boost::scoped_ptr<halo::manager> halo_manager_;
00237
00238
00239 bool do_quit_;
00240 EXIT_STATUS quit_mode_;
00241
00242 };
00243
00244 }
00245
00246 #endif