The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
editor_controller.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2016 by Tomasz Sniatowski <[email protected]>
3  Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 #define GETTEXT_DOMAIN "wesnoth-editor"
15 
16 #include "widgets/slider.hpp"
17 
19 
20 #include "asserts.hpp"
21 #include "editor/action/action.hpp"
24 #include "editor_controller.hpp"
25 
28 
30 
32 
35 #include "gui/dialogs/message.hpp"
37 #include "gui/widgets/window.hpp"
38 #include "wml_exception.hpp"
39 
40 #include "dialogs.hpp"
41 #include "resources.hpp"
42 #include "reports.hpp"
43 
44 #include "desktop/clipboard.hpp"
45 #include "game_preferences.hpp"
46 #include "gettext.hpp"
47 #include "preferences_display.hpp"
48 #include "sound.hpp"
49 #include "units/unit.hpp"
51 
52 #include "quit_confirmation.hpp"
53 
54 #include "halo.hpp"
55 
56 #include "utils/functional.hpp"
57 
58 namespace {
59 static std::vector<std::string> saved_windows_;
60 }
61 
62 namespace editor {
63 
65  : controller_base(game_config, video)
66  , mouse_handler_base()
67  , quit_confirmation(std::bind(&editor_controller::quit_confirm, this))
68  , active_menu_(editor::MAP)
69  , reports_(new reports())
70  , gui_(new editor_display(editor::get_dummy_display_context(), video, *reports_, controller_base::get_theme(game_config, "editor"), config()))
71  , tods_()
72  , context_manager_(new context_manager(*gui_.get(), game_config_))
73  , toolkit_(nullptr)
74  , tooltip_manager_(video)
75  , floating_label_manager_(nullptr)
76  , help_manager_(nullptr)
77  , do_quit_(false)
78  , quit_mode_(EXIT_ERROR)
79  , music_tracks_()
80 {
81  init_gui();
82  toolkit_.reset(new editor_toolkit(*gui_.get(), key_, game_config_, *context_manager_.get()));
83  help_manager_.reset(new help::help_manager(&game_config));
84  context_manager_->switch_context(0, true);
85  init_tods(game_config);
86  init_music(game_config);
87  context_manager_->get_map_context().set_starting_position_labels(gui());
89 
90  gui().create_buttons();
93 }
94 
96 {
97  gui_->change_display_context(&context_manager_->get_map_context());
99  gui_->add_redraw_observer(std::bind(&editor_controller::display_redraw_callback, this, _1));
103 // halo_manager_.reset(new halo::manager(*gui_));
104 // resources::halo = halo_manager_.get();
105 // ^ These lines no longer necessary, the gui owns its halo manager.
106 // TODO: Should the editor map contexts actually own the halo manager and swap them in and out from the gui?
107 // Note that if that is what happens it might not actually be a good idea for the gui to own the halo manager, so that it can be swapped out
108 // without deleting it.
109 }
110 
112 {
113  for (const config &schedule : game_config.child_range("editor_times")) {
114 
115  const std::string& schedule_id = schedule["id"];
116  const std::string& schedule_name = schedule["name"];
117  if (schedule_id.empty()) {
118  ERR_ED << "Missing ID attribute in a TOD Schedule." << std::endl;
119  continue;
120  }
121 
122  tods_map::iterator times = tods_.find(schedule_id);
123  if (times == tods_.end()) {
124  std::pair<tods_map::iterator, bool> new_times =
125  tods_.insert( std::pair<std::string, std::pair<std::string, std::vector<time_of_day> > >
126  (schedule_id, std::pair<std::string, std::vector<time_of_day> >(schedule_name, std::vector<time_of_day>())) );
127  times = new_times.first;
128  } else {
129  ERR_ED << "Duplicate TOD Schedule identifiers." << std::endl;
130  continue;
131  }
132 
133  for (const config &time : schedule.child_range("time")) {
134  times->second.second.push_back(time_of_day(time));
135  }
136 
137  }
138 
139  if (tods_.empty()) {
140  ERR_ED << "No editor time-of-day defined" << std::endl;
141  }
142 }
143 
145 {
146  const std::string tag_name = "editor_music";
147  if (!game_config.has_child(tag_name))
148  ERR_ED << "No editor music defined" << std::endl;
149  else {
150  for (const config& editor_music : game_config.child_range(tag_name)) {
151  for (const config& music : editor_music.child_range("music")) {
152  sound::music_track track(music);
153  if (track.file_path().empty())
154  WRN_ED << "Music track " << track.id() << " not found." << std::endl;
155  else
156  music_tracks_.push_back(sound::music_track(music));
157  }
158  }
159  }
160 }
161 
163 {
164  resources::units = nullptr;
165  resources::tod_manager = nullptr;
166  resources::teams = nullptr;
167 
168  resources::classification = nullptr;
169  resources::mp_settings = nullptr;
170 }
171 
173 {
174  try {
175  while (!do_quit_) {
176  play_slice();
177  }
178  } catch (editor_exception& e) {
179  gui2::show_transient_message(gui().video(), _("Fatal error"), e.what());
180  return EXIT_ERROR;
181  } catch (twml_exception& e) {
182  e.show(gui().video());
183  }
184  return quit_mode_;
185 }
186 
188 }
189 
190 void editor_controller::do_screenshot(const std::string& screenshot_filename /* = "map_screenshot.bmp" */)
191 {
192  try {
193  if (!gui().screenshot(screenshot_filename,true)) {
194  ERR_ED << "Screenshot creation failed!\n";
195  }
196  } catch (twml_exception& e) {
197  e.show(gui().video());
198  }
199 }
200 
202 {
203  std::string modified;
204  size_t amount = context_manager_->modified_maps(modified);
205 
207  if (amount == 0) {
208  message = _("Do you really want to quit?");
209  } else if (amount == 1) {
210  message = _("Do you really want to quit? Changes to this map since the last save will be lost.");
211  } else {
212  message = _("Do you really want to quit? The following maps were modified and all changes since the last save will be lost:");
213  message += "\n" + modified;
214  }
215  return quit_confirmation::show_prompt(message);
216 }
217 
219 {
220  if (tods_.empty()) {
221  gui2::show_error_message(gui().video(),
222  _("No editor time-of-day found."));
223  return;
224  }
225 
226  image::color_adjustment_resetter adjust_resetter;
227 
228  std::vector<time_of_day> schedule = context_manager_->get_map_context().get_time_manager()->times();
229 
230  if(!gui2::tcustom_tod::execute(&(gui()), schedule, gui().video())) {
231  adjust_resetter.reset();
232  } else {
233  // TODO save the new tod here
234  }
235 
236  context_manager_->refresh_all();
237 }
238 
240 {
241  using namespace hotkey; //reduce hotkey:: clutter
242  switch (cmd.id) {
243  case HOTKEY_NULL:
244  if (index >= 0) {
245  unsigned i = static_cast<unsigned>(index);
246 
247  switch (active_menu_) {
248  case editor::MAP:
249  if (i < context_manager_->open_maps()) {
250  return true;
251  }
252  return false;
253  case editor::LOAD_MRU:
254  case editor::PALETTE:
255  case editor::AREA:
256  case editor::SIDE:
257  case editor::TIME:
258  case editor::SCHEDULE:
260  case editor::MUSIC:
261  case editor::LOCAL_TIME:
262  case editor::UNIT_FACING:
263  return true;
264  }
265  }
266  return false;
268  return true;
270  return toolkit_->get_palette_manager()->can_scroll_up();
272  return toolkit_->get_palette_manager()->can_scroll_down();
273  case HOTKEY_ZOOM_IN:
274  return !gui_->zoom_at_max();
275  case HOTKEY_ZOOM_OUT:
276  return !gui_->zoom_at_min();
277  case HOTKEY_ZOOM_DEFAULT:
278  case HOTKEY_FULLSCREEN:
279  case HOTKEY_SCREENSHOT:
281  case HOTKEY_TOGGLE_GRID:
282  case HOTKEY_MOUSE_SCROLL:
283  case HOTKEY_ANIMATE_MAP:
284  case HOTKEY_MUTE:
285  case HOTKEY_PREFERENCES:
286  case HOTKEY_HELP:
287  case HOTKEY_QUIT_GAME:
288  case HOTKEY_SCROLL_UP:
289  case HOTKEY_SCROLL_DOWN:
290  case HOTKEY_SCROLL_LEFT:
291  case HOTKEY_SCROLL_RIGHT:
292  return true; //general hotkeys we can always do
293 
295  return context_manager_->get_map_context().get_units().size() != 0;
296 
297  case HOTKEY_STATUS_TABLE:
298  return !context_manager_->get_map_context().get_teams().empty();
299 
301  return gui().mouseover_hex().valid();
302 
303  // unit tool related
304  case HOTKEY_DELETE_UNIT:
305  case HOTKEY_RENAME_UNIT:
313  {
314  map_location loc = gui_->mouseover_hex();
315  const unit_map& units = context_manager_->get_map_context().get_units();
316  return (toolkit_->is_mouse_action_set(HOTKEY_EDITOR_TOOL_UNIT) &&
317  units.find(loc) != units.end());
318  }
319  case HOTKEY_UNDO:
320  return context_manager_->get_map_context().can_undo();
321  case HOTKEY_REDO:
322  return context_manager_->get_map_context().can_redo();
324  return context_manager_->get_map_context().can_undo();
333  return true;
334 
337  return !context_manager_->get_map_context().is_pure_map();
338 
341  return !context_manager_->get_map_context().get_teams().empty();
342 
343  // brushes
350  return toolkit_->get_mouse_action()->supports_brushes();
351 
353  return true;
355  return toolkit_->get_palette_manager()->active_palette().supports_swap();
357  return context_manager_->get_map_context().modified();
359  {
360  std::string dummy;
361  return context_manager_->modified_maps(dummy) > 1;
362  }
365  return !context_manager_->get_map_context().is_pure_map();
368  return true;
370  return !context_manager_->get_map_context().get_filename().empty()
371  && context_manager_->get_map_context().modified();
372 
373  // Tools
374  // Pure map editing tools this can be used all the time.
379  return true;
380  // WWL dependent tools which don't rely on defined sides.
384  return !context_manager_->get_map_context().is_pure_map();
387  return !context_manager_->get_map_context().get_teams().empty();
388 
392  return !context_manager_->get_map_context().is_pure_map() &&
393  !context_manager_->get_map_context().get_time_manager()->get_area_ids().empty();
394 
396  return !context_manager_->get_map_context().is_pure_map() &&
397  !context_manager_->get_map_context().get_time_manager()->get_area_ids().empty()
398  && !context_manager_->get_map().selection().empty();
399 
404  return !context_manager_->get_map().selection().empty()
405  && !toolkit_->is_mouse_action_set(HOTKEY_EDITOR_CLIPBOARD_PASTE);
407  return (context_manager_->get_map().selection().size() > 1
408  && !toolkit_->is_mouse_action_set(HOTKEY_EDITOR_CLIPBOARD_PASTE));
412  return false; //not implemented
414  return !context_manager_->clipboard_empty();
419  return !context_manager_->clipboard_empty()
420  && toolkit_->is_mouse_action_set(HOTKEY_EDITOR_CLIPBOARD_PASTE);
423  return !toolkit_->is_mouse_action_set(HOTKEY_EDITOR_CLIPBOARD_PASTE);
425  return !context_manager_->get_map_context().get_map().selection().empty()
426  && !context_manager_->get_map_context().get_map().everything_selected()
427  && !toolkit_->is_mouse_action_set(HOTKEY_EDITOR_CLIPBOARD_PASTE);
444  return true;
446  return false; //not implemented
449  return true;
450  default:
451  return false;
452  }
453 }
454 
456  using namespace hotkey;
457  switch (command) {
458 
460  {
462  context_manager_->get_map_context().get_units().find(gui_->mouseover_hex());
463  return un->loyal() ? ACTION_ON : ACTION_OFF;
464 
465  }
467  {
469  context_manager_->get_map_context().get_units().find(gui_->mouseover_hex());
470  return un->can_recruit() ? ACTION_ON : ACTION_OFF;
471  }
473  {
475  context_manager_->get_map_context().get_units().find(gui_->mouseover_hex());
476  return (!un->unrenamable()) ? ACTION_ON : ACTION_OFF;
477  }
478  //TODO remove hardcoded hotkey names
480  return context_manager_->is_active_transitions_hotkey("editor-auto-update-transitions")
483  return context_manager_->is_active_transitions_hotkey("editor-partial-update-transitions")
486  return context_manager_->is_active_transitions_hotkey("editor-no-update-transitions")
489  return toolkit_->is_active_brush("brush-1") ? ACTION_ON : ACTION_OFF;
491  return toolkit_->is_active_brush("brush-2") ? ACTION_ON : ACTION_OFF;
493  return toolkit_->is_active_brush("brush-3") ? ACTION_ON : ACTION_OFF;
495  return toolkit_->is_active_brush("brush-nw-se") ? ACTION_ON : ACTION_OFF;
497  return toolkit_->is_active_brush("brush-sw-ne") ? ACTION_ON : ACTION_OFF;
498 
499  case HOTKEY_TOGGLE_GRID:
502  return context_manager_->get_map_context().get_map().everything_selected() ?
505  return context_manager_->get_map_context().get_map().selection().empty() ?
516  return toolkit_->is_mouse_action_set(command) ? ACTION_ON : ACTION_OFF;
518  return gui_->get_draw_coordinates() ? ACTION_ON : ACTION_OFF;
520  return gui_->get_draw_terrain_codes() ? ACTION_ON : ACTION_OFF;
521 
532  case HOTKEY_ZOOM_DEFAULT:
533  return (gui_->get_zoom_factor() == 1.0) ? hotkey::ACTION_ON : hotkey::ACTION_OFF;
534 
535  case HOTKEY_NULL:
536  switch (active_menu_) {
537  case editor::MAP:
538  return index == context_manager_->current_context_index()
540  case editor::LOAD_MRU:
541  return ACTION_STATELESS;
542  case editor::PALETTE:
543  return ACTION_STATELESS;
544  case editor::AREA:
545  return index == context_manager_->get_map_context().get_active_area()
547  case editor::SIDE:
548  return static_cast<size_t>(index) == gui_->playing_team()
550  case editor::TIME:
551  return index == context_manager_->get_map_context().get_time_manager()->get_current_time()
553  case editor::LOCAL_TIME:
554  return index == context_manager_->get_map_context().get_time_manager()->get_current_area_time(
555  context_manager_->get_map_context().get_active_area())
557  case editor::MUSIC:
558  return context_manager_->get_map_context().is_in_playlist(music_tracks_[index].id())
559  ? ACTION_ON : ACTION_OFF;
560  case editor::SCHEDULE:
561  {
562  tods_map::const_iterator it = tods_.begin();
563  std::advance(it, index);
564  const std::vector<time_of_day>& times1 = it->second.second;
565  const std::vector<time_of_day>& times2 = context_manager_->get_map_context().get_time_manager()->times();
566  return (times1 == times2) ? ACTION_SELECTED : ACTION_DESELECTED;
567  }
569  {
570  tods_map::const_iterator it = tods_.begin();
571  std::advance(it, index);
572  const std::vector<time_of_day>& times1 = it->second.second;
573  int active_area = context_manager_->get_map_context().get_active_area();
574  const std::vector<time_of_day>& times2 = context_manager_->get_map_context().get_time_manager()->times(active_area);
575  return (times1 == times2) ? ACTION_SELECTED : ACTION_DESELECTED;
576  }
577  case editor::UNIT_FACING:
578  {
580  resources::units->find(gui_->mouseover_hex());
581  assert(un != resources::units->end());
582  return un->facing() == index ? ACTION_SELECTED : ACTION_DESELECTED;
583  }
584  }
585  return ACTION_ON;
586  default:
587  return command_executor::get_action_state(command, index);
588  }
589 }
590 
592 {
593  const int zoom_amount = 4;
594  hotkey::HOTKEY_COMMAND command = cmd.id;
595  SCOPE_ED;
596  using namespace hotkey;
597 
598  // nothing here handles release; fall through to base implementation
599  if (!press) {
600  return hotkey::command_executor::execute_command(cmd, index, press);
601  }
602 
603  switch (command) {
604  case HOTKEY_NULL:
605  switch (active_menu_) {
606  case MAP:
607  if (index >= 0) {
608  unsigned i = static_cast<unsigned>(index);
609  if (i < context_manager_->size()) {
610  context_manager_->switch_context(index);
611  toolkit_->hotkey_set_mouse_action(HOTKEY_EDITOR_TOOL_PAINT);
612  return true;
613  }
614  }
615  return false;
616  case LOAD_MRU:
617  if (index >= 0) {
618  context_manager_->load_mru_item(static_cast<unsigned>(index));
619  }
620  return true;
621  case PALETTE:
622  toolkit_->get_palette_manager()->set_group(index);
623  return true;
624  case SIDE:
625  gui_->set_team(index, true);
626  gui_->set_playing_team(index);
627  toolkit_->get_palette_manager()->draw_contents();
628  return true;
629  case AREA:
630  {
631  context_manager_->get_map_context().set_active_area(index);
632  const std::set<map_location>& area =
633  context_manager_->get_map_context().get_time_manager()->get_area_by_index(index);
634  std::vector<map_location> locs(area.begin(), area.end());
635  context_manager_->get_map_context().select_area(index);
636  gui_->scroll_to_tiles(locs.begin(), locs.end());
637  return true;
638  }
639  case TIME:
640  {
641  context_manager_->get_map_context().set_starting_time(index);
642  const tod_manager* tod = context_manager_->get_map_context().get_time_manager();
643  tod_color col = tod->times()[index].color;
644  image::set_color_adjustment(col.r, col.g, col.b);
645  return true;
646  }
647  case LOCAL_TIME:
648  {
649  context_manager_->get_map_context().set_local_starting_time(index);
650  return true;
651  }
652  case MUSIC:
653  {
654  //TODO mark the map as changed
656  context_manager_->get_map_context().add_to_playlist(music_tracks_[index]);
657  std::vector<std::string> items;
658  items.push_back("editor-playlist");
659  std::shared_ptr<gui::button> b = gui_->find_menu_button("menu-playlist");
660  show_menu(items, b->location().x +1, b->location().y + b->height() +1, false, *gui_);
661  return true;
662  }
663  case SCHEDULE:
664  {
665  tods_map::iterator iter = tods_.begin();
666  std::advance(iter, index);
667  context_manager_->get_map_context().replace_schedule(iter->second.second);
668  const tod_manager* tod = context_manager_->get_map_context().get_time_manager();
669  tod_color col = tod->times()[0].color;
670  image::set_color_adjustment(col.r, col.g, col.b);
671  return true;
672  }
673  case LOCAL_SCHEDULE:
674  {
675  tods_map::iterator iter = tods_.begin();
676  std::advance(iter, index);
677  context_manager_->get_map_context().replace_local_schedule(iter->second.second);
678  return true;
679  }
680  case UNIT_FACING:
681  {
683  resources::units->find(gui_->mouseover_hex());
684  assert(un != resources::units->end());
685  un->set_facing(map_location::DIRECTION(index));
686  un->anim_comp().set_standing();
687  return true;
688  }
689  }
690  return true;
691 
692  //Zoom
693  case HOTKEY_ZOOM_IN:
694  gui_->set_zoom(zoom_amount);
695  context_manager_->get_map_context().get_labels().recalculate_labels();
696  toolkit_->get_mouse_action()->set_mouse_overlay(*gui_);
697  return true;
698  case HOTKEY_ZOOM_OUT:
699  gui_->set_zoom(-zoom_amount);
700  context_manager_->get_map_context().get_labels().recalculate_labels();
701  toolkit_->get_mouse_action()->set_mouse_overlay(*gui_);
702  return true;
703  case HOTKEY_ZOOM_DEFAULT:
704  gui_->set_default_zoom();
705  context_manager_->get_map_context().get_labels().recalculate_labels();
706  toolkit_->get_mouse_action()->set_mouse_overlay(*gui_);
707  return true;
708 
709  //Palette
711  {
712  //TODO this code waits for the gui2 dialog to get ready
713 // std::vector< std::pair< std::string, std::string > > blah_items;
714 // toolkit_->get_palette_manager()->active_palette().expand_palette_groups_menu(blah_items);
715 // int selected = 1; //toolkit_->get_palette_manager()->active_palette().get_selected;
716 // gui2::teditor_select_palette_group::execute(selected, blah_items, gui_->video());
717  }
718  return true;
720  toolkit_->get_palette_manager()->scroll_up();
721  gui_->draw(true,false);
722  return true;
724  toolkit_->get_palette_manager()->scroll_down();
725  gui_->draw(true,false);
726  return true;
727 
728  case HOTKEY_QUIT_GAME:
730  do_quit_ = true;
732  }
733  return true;
736  return true;
738  context_manager_->save_all_maps(true);
739  do_quit_ = true;
741  return true;
744  return true;
746  toolkit_->get_palette_manager()->active_palette().swap();
747  return true;
749  if (dynamic_cast<const editor_action_chain*>(context_manager_->get_map_context().last_undo_action()) != nullptr) {
750  context_manager_->get_map_context().partial_undo();
751  context_manager_->refresh_after_action();
752  } else {
753  undo();
754  }
755  return true;
756 
757  //Tool Selection
766  toolkit_->hotkey_set_mouse_action(command);
767  return true;
768 
770  add_area();
771  return true;
772 
774  change_unit_id();
775  return true;
776 
778  {
779  map_location loc = gui_->mouseover_hex();
780  const unit_map::unit_iterator un = context_manager_->get_map_context().get_units().find(loc);
781  const std::set<std::string>& recruit_set = toolkit_->get_palette_manager()->unit_palette_->get_selected_bg_items();
782  std::vector<std::string> recruits(recruit_set.begin(), recruit_set.end());
783  un->set_recruits(recruits);
784  }
785  return true;
787  {
788  map_location loc = gui_->mouseover_hex();
789  const unit_map::unit_iterator un = context_manager_->get_map_context().get_units().find(loc);
790  bool unrenamable = un->unrenamable();
791  un->set_unrenamable(!unrenamable);
792  }
793  return true;
795  {
796  map_location loc = gui_->mouseover_hex();
797  const unit_map::unit_iterator un = context_manager_->get_map_context().get_units().find(loc);
798  bool canrecruit = un->can_recruit();
799  un->set_can_recruit(!canrecruit);
800  un->anim_comp().set_standing();
801  }
802  return true;
803  case HOTKEY_DELETE_UNIT:
804  {
805  map_location loc = gui_->mouseover_hex();
807  }
808  return true;
809  case HOTKEY_EDITOR_CLIPBOARD_PASTE: //paste is somewhat different as it might be "one action then revert to previous mode"
810  toolkit_->hotkey_set_mouse_action(command);
811  return true;
812 
813  //Clipboard
815  context_manager_->get_clipboard().rotate_60_cw();
816  toolkit_->update_mouse_action_highlights();
817  return true;
819  context_manager_->get_clipboard().rotate_60_ccw();
820  toolkit_->update_mouse_action_highlights();
821  return true;
823  context_manager_->get_clipboard().flip_horizontal();
824  toolkit_->update_mouse_action_highlights();
825  return true;
827  context_manager_->get_clipboard().flip_vertical();
828  toolkit_->update_mouse_action_highlights();
829  return true;
830 
831  //Brushes
833  toolkit_->cycle_brush();
834  return true;
836  toolkit_->set_brush("brush-1");
837  return true;
839  toolkit_->set_brush("brush-2");
840  return true;
842  toolkit_->set_brush("brush-3");
843  return true;
845  toolkit_->set_brush("brush-nw-se");
846  return true;
848  toolkit_->set_brush("brush-sw-ne");
849  return true;
850 
852  copy_selection();
853  return true;
855  cut_selection();
856  return true;
858  context_manager_->rename_area_dialog();
859  return true;
861  save_area();
862  return true;
865  return true;
867  if (!context_manager_->get_map().everything_selected()) {
868  context_manager_->perform_refresh(editor_action_select_all());
869  return true;
870  } //else intentionally fall through
873  return true;
875  context_manager_->perform_refresh(editor_action_select_none());
876  return true;
878  context_manager_->fill_selection();
879  return true;
882  context_manager_->get_map().selection()));
883  return true;
884 
886  context_manager_->edit_scenario_dialog();
887  return true;
888 
890  context_manager_->get_map_context().remove_area(
891  context_manager_->get_map_context().get_active_area());
892  return true;
893 
894  // map specific
896  context_manager_->close_current_context();
897  return true;
899  context_manager_->load_map_dialog();
900  return true;
902  context_manager_->revert_map();
903  return true;
905  context_manager_->new_map_dialog();
906  return true;
908  context_manager_->new_scenario_dialog();
909  return true;
911  save_map();
912  return true;
914  context_manager_->save_all_maps();
915  return true;
917  context_manager_->save_map_as_dialog();
918  return true;
920  context_manager_->save_scenario_as_dialog();
921  return true;
923  context_manager_->generate_map_dialog();
924  return true;
926  context_manager_->apply_mask_dialog();
927  return true;
929  context_manager_->create_mask_to_dialog();
930  return true;
932  context_manager_->resize_map_dialog();
933  return true;
934 
935  // Side specific ones
937  context_manager_->get_map_context().new_side();
938  gui_->init_flags();
939  return true;
941  gui_->set_team(0, true);
942  gui_->set_playing_team(0);
943  context_manager_->get_map_context().remove_side();
944  return true;
946  context_manager_->edit_side_dialog(gui_->viewing_team());
947  return true;
948 
949  // Transitions
951  context_manager_->set_update_trasitions_mode(2);
952  return true;
954  context_manager_->set_update_trasitions_mode(1);
955  return true;
957  context_manager_->set_update_trasitions_mode(0);
958  return true;
960  if (context_manager_->toggle_update_transitions())
961  return true;
962  // else intentionally fall through
964  context_manager_->refresh_all();
965  return true;
966  // Refresh
968  context_manager_->reload_map();
969  return true;
972  return true;
973 
975  gui().set_draw_coordinates(!gui().get_draw_coordinates());
976  preferences::editor::set_draw_hex_coordinates(gui().get_draw_coordinates());
977  gui().invalidate_all();
978  return true;
980  gui().set_draw_terrain_codes(!gui().get_draw_terrain_codes());
981  preferences::editor::set_draw_terrain_codes(gui().get_draw_terrain_codes());
982  gui().invalidate_all();
983  return true;
985  location_palette* lp = dynamic_cast<location_palette*>(&toolkit_->get_palette_manager()->active_palette());
986  if (lp) {
988  }
989  return true;
990  }
991  default:
992  return hotkey::command_executor::execute_command(cmd, index, press);
993  }
994 }
995 
997 {
998  help::show_help(gui_->video(), "..editor");
999 }
1000 
1001 void editor_controller::show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu, display& disp)
1002 {
1003  if (context_menu) {
1004  if (!context_manager_->get_map().on_board_with_border(gui().hex_clicked_on(xloc, yloc))) {
1005  return;
1006  }
1007  }
1008 
1009  std::vector<std::string> items;
1010  std::vector<std::string>::const_iterator i = items_arg.begin();
1011  while(i != items_arg.end())
1012  {
1013 
1015 
1016  if ( ( can_execute_command(command)
1017  && (!context_menu || in_context_menu(command.id)) )
1018  || command.id == hotkey::HOTKEY_NULL) {
1019  items.push_back(*i);
1020  }
1021  ++i;
1022  }
1023  if (!items.empty() && items.front() == "EDITOR-LOAD-MRU-PLACEHOLDER") {
1025  context_manager_->expand_load_mru_menu(items);
1026  }
1027  if (!items.empty() && items.front() == "editor-switch-map") {
1029  context_manager_->expand_open_maps_menu(items);
1030  }
1031  if (!items.empty() && items.front() == "editor-palette-groups") {
1033  toolkit_->get_palette_manager()->active_palette().expand_palette_groups_menu(items);
1034  }
1035  if (!items.empty() && items.front() == "editor-switch-side") {
1037  context_manager_->expand_sides_menu(items);
1038  }
1039  if (!items.empty() && items.front() == "editor-switch-area") {
1041  context_manager_->expand_areas_menu(items);
1042  }
1043  if (!items.empty() && items.front() == "editor-switch-time") {
1045  context_manager_->expand_time_menu(items);
1046  }
1047  if (!items.empty() && items.front() == "editor-assign-local-time") {
1049  context_manager_->expand_local_time_menu(items);
1050  }
1051  if (!items.empty() && items.front() == "menu-unit-facings") {
1053  items.erase(items.begin());
1054  for (int dir = 0; dir != map_location::NDIRECTIONS; dir++)
1056  }
1057  if (!items.empty() && items.front() == "editor-playlist") {
1059  items.erase(items.begin());
1060  for (const sound::music_track& track : music_tracks_) {
1061  items.push_back(track.title().empty() ? track.id() : track.title());
1062  }
1063  }
1064  if (!items.empty() && items.front() == "editor-assign-schedule") {
1066 
1067  items.erase(items.begin());
1068 
1069  for (tods_map::iterator iter = tods_.begin();
1070  iter != tods_.end(); ++iter) {
1071  items.push_back(iter->second.first);
1072  }
1073  }
1074  if (!items.empty() && items.front() == "editor-assign-local-schedule") {
1076 
1077  items.erase(items.begin());
1078 
1079  for (tods_map::iterator iter = tods_.begin();
1080  iter != tods_.end(); ++iter) {
1081  items.push_back(iter->second.first);
1082  }
1083  }
1084 
1085  command_executor::show_menu(items, xloc, yloc, context_menu, disp);
1086 }
1087 
1089 {
1090  gui_->video().clear_all_help_strings();
1092 
1093  gui_->redraw_everything();
1094 }
1095 
1097 {
1099  gui_->invalidate_all();
1100 }
1101 
1103 {
1104  map_location loc = gui_->mouseover_hex();
1105  const unit_map & units = context_manager_->get_map_context().get_units();
1106  const unit_map::const_unit_iterator un = units.find(loc);
1107  if(un != units.end()) {
1108  help::show_unit_help(gui_->video(), un->type_id(), un->type().show_variations_in_help(), false);
1109  } else {
1110  help::show_help(gui_->video(), "..units");
1111  }
1112 }
1113 
1114 
1116 {
1117  if (!context_manager_->get_map().selection().empty()) {
1118  context_manager_->get_clipboard() = map_fragment(context_manager_->get_map(), context_manager_->get_map().selection());
1119  context_manager_->get_clipboard().center_by_mass();
1120  }
1121 }
1122 
1124 {
1125  map_location loc = gui_->mouseover_hex();
1126  unit_map& units = context_manager_->get_map_context().get_units();
1127  const unit_map::unit_iterator& un = units.find(loc);
1128 
1129  const std::string title(N_("Change Unit ID"));
1130  const std::string label(N_("ID:"));
1131 
1132  if(un != units.end()) {
1133  std::string id = un->id();
1134  if (gui2::tedit_text::execute(title, label, id, gui_->video())) {
1135  un->set_id(id);
1136  }
1137  }
1138 }
1139 
1141 {
1142  map_location loc = gui_->mouseover_hex();
1143  unit_map& units = context_manager_->get_map_context().get_units();
1144  const unit_map::unit_iterator& un = units.find(loc);
1145 
1146  const std::string title(N_("Rename Unit"));
1147  const std::string label(N_("Name:"));
1148 
1149  if(un != units.end()) {
1150  std::string name = un->name();
1151  if(gui2::tedit_text::execute(title, label, name, gui_->video())) {
1152  //TODO we may not want a translated name here.
1153  un->set_name(name);
1154  }
1155  }
1156 }
1157 
1159 {
1161 }
1162 
1164 {
1165  copy_selection();
1166  context_manager_->perform_refresh(editor_action_paint_area(context_manager_->get_map().selection(), get_selected_bg_terrain()));
1167 }
1168 
1170 {
1171  const std::set<map_location>& area = context_manager_->get_map().selection();
1172  context_manager_->get_map_context().save_area(area);
1173 }
1174 
1176 {
1177  const std::set<map_location>& area = context_manager_->get_map().selection();
1178  context_manager_->get_map_context().new_area(area);
1179 }
1180 
1182 {
1183  std::stringstream ssx, ssy;
1184  std::set<map_location>::const_iterator i = context_manager_->get_map().selection().begin();
1185  if (i != context_manager_->get_map().selection().end()) {
1186  ssx << "x = " << i->x + 1;
1187  ssy << "y = " << i->y + 1;
1188  ++i;
1189  while (i != context_manager_->get_map().selection().end()) {
1190  ssx << ", " << i->x + 1;
1191  ssy << ", " << i->y + 1;
1192  ++i;
1193  }
1194  ssx << "\n" << ssy.str() << "\n";
1195  desktop::clipboard::copy_to_clipboard(ssx.str(), false);
1196  }
1197 }
1198 
1200 {
1201  if (action) {
1202  boost::scoped_ptr<editor_action> action_auto(action);
1203  context_manager_->get_map_context().perform_action(*action);
1204  }
1205 }
1206 
1207 void editor_controller::perform_refresh_delete(editor_action* action, bool drag_part /* =false */)
1208 {
1209  if (action) {
1210  boost::scoped_ptr<editor_action> action_auto(action);
1211  context_manager_->perform_refresh(*action, drag_part);
1212  }
1213 }
1214 
1216 {
1218  context_manager_->refresh_all();
1219 }
1220 
1222 {
1223  set_button_state();
1224  toolkit_->adjust_size();
1225  context_manager_->get_map_context().get_labels().recalculate_labels();
1226 }
1227 
1229 {
1230  context_manager_->get_map_context().undo();
1231  context_manager_->refresh_after_action();
1232 }
1233 
1235 {
1236  context_manager_->get_map_context().redo();
1237  context_manager_->refresh_after_action();
1238 }
1239 
1240 void editor_controller::mouse_motion(int x, int y, const bool /*browse*/,
1241  bool update, map_location /*new_loc*/)
1242 {
1243  if (mouse_handler_base::mouse_motion_default(x, y, update)) return;
1244  map_location hex_clicked = gui().hex_clicked_on(x, y);
1245  if (context_manager_->get_map().on_board_with_border(drag_from_hex_) && is_dragging()) {
1246  editor_action* a = nullptr;
1247  bool partial = false;
1248  editor_action* last_undo = context_manager_->get_map_context().last_undo_action();
1249  if (dragging_left_ && (SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON(1)) != 0) {
1250  if (!context_manager_->get_map().on_board_with_border(hex_clicked)) return;
1251  a = toolkit_->get_mouse_action()->drag_left(*gui_, x, y, partial, last_undo);
1252  } else if (dragging_right_ && (SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON(3)) != 0) {
1253  if (!context_manager_->get_map().on_board_with_border(hex_clicked)) return;
1254  a = toolkit_->get_mouse_action()->drag_right(*gui_, x, y, partial, last_undo);
1255  }
1256  //Partial means that the mouse action has modified the
1257  //last undo action and the controller shouldn't add
1258  //anything to the undo stack (hence a different perform_ call)
1259  if (a != nullptr) {
1260  boost::scoped_ptr<editor_action> aa(a);
1261  if (partial) {
1262  context_manager_->get_map_context().perform_partial_action(*a);
1263  } else {
1264  context_manager_->get_map_context().perform_action(*a);
1265  }
1266  context_manager_->refresh_after_action(true);
1267  }
1268  } else {
1269  toolkit_->get_mouse_action()->move(*gui_, hex_clicked);
1270  }
1271  gui().highlight_hex(hex_clicked);
1272 }
1273 
1275 {
1276  return context_manager_->get_map().on_board_with_border(gui().hex_clicked_on(x,y));
1277 }
1278 
1279 bool editor_controller::right_click_show_menu(int /*x*/, int /*y*/, const bool /*browse*/)
1280 {
1281  return toolkit_->get_mouse_action()->has_context_menu();
1282 }
1283 
1284 bool editor_controller::left_click(int x, int y, const bool browse)
1285 {
1286  toolkit_->clear_mouseover_overlay();
1287  if (mouse_handler_base::left_click(x, y, browse))
1288  return true;
1289 
1290  LOG_ED << "Left click, after generic handling\n";
1291  map_location hex_clicked = gui().hex_clicked_on(x, y);
1292  if (!context_manager_->get_map().on_board_with_border(hex_clicked))
1293  return true;
1294 
1295  LOG_ED << "Left click action " << hex_clicked.x << " " << hex_clicked.y << "\n";
1296  editor_action* a = toolkit_->get_mouse_action()->click_left(*gui_, x, y);
1297  perform_refresh_delete(a, true);
1298  if (a) set_button_state();
1299 
1300  return false;
1301 }
1302 
1303 void editor_controller::left_drag_end(int x, int y, const bool /*browse*/)
1304 {
1305  editor_action* a = toolkit_->get_mouse_action()->drag_end_left(*gui_, x, y);
1306  perform_delete(a);
1307 }
1308 
1309 void editor_controller::left_mouse_up(int x, int y, const bool /*browse*/)
1310 {
1311  editor_action* a = toolkit_->get_mouse_action()->up_left(*gui_, x, y);
1312  perform_delete(a);
1313  if (a) set_button_state();
1314  toolkit_->set_mouseover_overlay();
1315  std::shared_ptr<gui::slider> s = gui_->find_slider("map-zoom-slider");
1316  if (s && s->value_change()) {
1317  if (gui_->set_zoom(s->value(), true)) {
1318  context_manager_->get_map_context().get_labels().recalculate_labels();
1319  toolkit_->get_mouse_action()->set_mouse_overlay(*gui_);
1320  set_button_state();
1321  }
1322  }
1323  context_manager_->refresh_after_action();
1324 }
1325 
1326 bool editor_controller::right_click(int x, int y, const bool browse)
1327 {
1328  toolkit_->clear_mouseover_overlay();
1329  if (mouse_handler_base::right_click(x, y, browse)) return true;
1330  LOG_ED << "Right click, after generic handling\n";
1331  map_location hex_clicked = gui().hex_clicked_on(x, y);
1332  if (!context_manager_->get_map().on_board_with_border(hex_clicked)) return true;
1333  LOG_ED << "Right click action " << hex_clicked.x << " " << hex_clicked.y << "\n";
1334  editor_action* a = toolkit_->get_mouse_action()->click_right(*gui_, x, y);
1335  perform_refresh_delete(a, true);
1336  if (a) set_button_state();
1337  return false;
1338 }
1339 
1340 void editor_controller::right_drag_end(int x, int y, const bool /*browse*/)
1341 {
1342  editor_action* a = toolkit_->get_mouse_action()->drag_end_right(*gui_, x, y);
1343  perform_delete(a);
1344 }
1345 
1346 void editor_controller::right_mouse_up(int x, int y, const bool /*browse*/)
1347 {
1348  editor_action* a = toolkit_->get_mouse_action()->up_right(*gui_, x, y);
1349  perform_delete(a);
1350  if (a) set_button_state();
1351  toolkit_->set_mouseover_overlay();
1352  context_manager_->refresh_after_action();
1353 }
1354 
1356 {
1357  const map_location& loc = gui().mouseover_hex();
1358  if (context_manager_->get_map().on_board(loc) == false)
1359  return;
1360 
1361  const terrain_type& type = context_manager_->get_map().get_terrain_info(loc);
1362  help::show_terrain_description(gui().video(), type);
1363 }
1364 
1366 {
1367  editor_action* a = toolkit_->get_mouse_action()->key_event(gui(), event);
1369  toolkit_->set_mouseover_overlay();
1370 }
1371 
1373  return this;
1374 }
1375 
1377 {
1379 }
1380 
1382 {
1384 }
1385 
1387 {
1389 }
1390 
1392 {
1394 }
1395 
1397 {
1398  return toolkit_->get_palette_manager()->active_palette().action_pressed();
1399 }
1400 
1401 } //end namespace editor
void perform_refresh_delete(editor_action *action, bool drag_part=false)
Peform an action on the current map_context, then refresh the display and delete the pointer...
child_itors child_range(const std::string &key)
Definition: config.cpp:613
Randomize terrain in an area.
Definition: action.hpp:354
bool right_click_show_menu(int x, int y, const bool browse)
Called in the default right_click when the context menu is about to be shown, can be used for preproc...
boost::scoped_ptr< editor_toolkit > toolkit_
void set_grid(bool ison)
void show_error_message(CVideo &video, const std::string &message, bool message_use_markup)
Shows an error message to the user.
Definition: message.cpp:198
void set_scroll_up(bool on)
void show_help(CVideo &video, const std::string &show_topic, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
Definition: help.cpp:117
void set_preference_display_settings()
::tod_manager * tod_manager
Definition: resources.cpp:31
void copy_selection()
Copy the selection on the current map to the clipboard.
static std::string write_translated_direction(DIRECTION dir)
Definition: location.cpp:165
void set_scroll_down(bool on)
unit_iterator end()
Definition: map.hpp:311
bool minimap_draw_units()
A map fragment – a collection of locations and information abut them.
Select the entire map.
void save_map()
Save the map, open dialog if not named yet.
editor_display & gui()
Reference to the used display objects.
Small struct to store and manipulate ToD colors.
Definition: time_of_day.hpp:30
bool dragging_right_
RMB drag init flag.
void set_draw_terrain_codes(bool value)
Setter for the terrain code debug overlay on tiles.
Definition: display.hpp:371
void set(CURSOR_TYPE type)
Use the default parameter to reset cursors.
Definition: cursor.cpp:154
void export_selection_coords()
Export the WML-compatible list of selected tiles to the system clipboard.
game_classification * classification
Definition: resources.cpp:37
void do_screenshot(const std::string &screenshot_filename="map_screenshot.bmp")
Takes a screenshot.
bool right_click(int x, int y, const bool browse)
Overridden in derived classes, called on a right click (mousedown).
const char * what() const
Definition: exceptions.hpp:35
bool quit_confirm()
Show a quit confirmation dialog and returns true if the user pressed 'yes'.
const mp_game_settings * mp_settings
Definition: resources.cpp:38
Editor action classes.
bool left_click(int x, int y, const bool browse)
Overridden in derived classes, called on a left click (mousedown).
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
void custom_tods_dialog()
Display the settings dialog, used to control e.g.
GLuint GLuint GLsizei GLenum type
Definition: glew.h:1221
Definition: video.hpp:58
bool minimap_movement_coding()
This file contains the window object, this object is a top level container which has the event manage...
void redraw_everything()
Invalidates entire screen, including all tiles and sidebar.
Definition: display.cpp:2650
void show(CVideo &video)
Shows the error in a dialog.
#define LOG_ED
void redo()
Redos an action in the current map context.
void left_drag_end(int x, int y, const bool browse)
Called whenever the left mouse drag has "ended".
void save_area()
Save the current selection to the active area.
static bool show_prompt(const std::string &message)
bool can_execute_command(const hotkey::hotkey_command &command, int index=-1) const
command_executor override
Stores all information related to functions that can be bound to hotkeys.
hotkey::ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND command, int index) const
command_executor override
const map_location hex_clicked_on(int x, int y) const
given x,y co-ordinates of an onscreen pixel, will return the location of the hex that this pixel corr...
Definition: display.cpp:577
void add_area()
Add a new area to the current context, filled with the selection if any.
void play_slice(bool is_delay_enabled=true)
STL namespace.
void show_transient_message(CVideo &video, const std::string &title, const std::string &message, const std::string &image, const bool message_use_markup, const bool title_use_markup, const bool restore_background)
Shows a transient message to the user.
boost::scoped_ptr< font::floating_label_context > floating_label_manager_
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1220
#define SCOPE_ED
const std::vector< std::string > items
void play_music_once(const std::string &file)
Definition: sound.cpp:472
boost::scoped_ptr< context_manager > context_manager_
The editor_controller class contains the mouse and keyboard event handling routines for the editor...
void scroll_up(bool on)
Handle hotkeys to scroll map.
Set starting position action.
Definition: action.hpp:283
Keyboard shortcuts for game actions.
Unit and team statistics.
void flush_cache()
Definition: image.cpp:191
const std::string & selected_item() const
Return the currently selected item.
GLdouble GLdouble GLdouble b
Definition: glew.h:6966
#define WRN_ED
bool minimap_draw_villages()
Object which defines a time of day with associated bonuses, image, sounds etc.
Definition: time_of_day.hpp:48
bool has_child(const std::string &key) const
Determine whether a config has a child or not.
Definition: config.cpp:651
void right_drag_end(int x, int y, const bool browse)
Called whenever the right mouse drag has "ended".
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:82
static bool execute(const std::string &title, const std::string &label, std::string &text, CVideo &video)
Executes the dialog.
Definition: edit_text.hpp:51
GLuint GLuint end
Definition: glew.h:1221
const map_location & mouseover_hex() const
Definition: display.hpp:293
void toggle_grid()
Grid toggle.
bool allow_mouse_wheel_scroll(int x, int y)
Derived classes can override this to disable mousewheel scrolling under some circumstances, e.g.
std::vector< team > * teams
Definition: resources.cpp:29
bool valid() const
Definition: location.hpp:69
void init_tods(const config &game_config)
init the available time-of-day settings
Implements a quit confirmation dialog.
void show_preferences_dialog(CVideo &video, const config &game_cfg, const DIALOG_OPEN_TO initial_view)
void set_draw_coordinates(bool value)
Setter for the x,y debug overlay on tiles.
Definition: display.hpp:366
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:7319
map_location drag_from_hex_
Drag start map location.
void show_unit_list(display &gui)
Definition: dialogs.cpp:294
void preferences()
Show the preferences dialog.
Editor action classes.
virtual hotkey::command_executor * get_hotkey_command_executor()
Get (optionally) a command executor to handle context menu events.
void create_buttons()
Definition: display.cpp:897
editor_controller(const config &game_config, CVideo &video)
The constructor.
void refresh_image_cache()
Reload images.
Manage the empty-palette in the editor.
Definition: action.cpp:28
void show_menu(const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu, display &disp)
controller_base override
void undo()
Undos an action in the current map context.
void invalidate_all()
Function to invalidate all tiles.
Definition: display.cpp:3525
boost::scoped_ptr< help::help_manager > help_manager_
const std::string & file_path() const
void raise_draw_event()
Definition: events.cpp:565
Paint the same terrain on a number of locations on the map.
Definition: action.hpp:244
bool dragging_left_
LMB drag init flag.
void show_terrain_description(CVideo &video, const terrain_type &t)
Definition: help.cpp:64
const std::string &parameters float amount
Definition: filter.cpp:132
static bool quit()
Shows the quit confirmation if needed.
void set_color_adjustment(int r, int g, int b)
will make all scaled images have these rgb values added to all their pixels.
Definition: image.cpp:698
Encapsulates the map of the game.
Definition: location.hpp:38
void process_keyup_event(const SDL_Event &event)
Process keyup (always).
boost::scoped_ptr< editor_display > gui_
The display object used and owned by the editor.
static void quit_to_desktop()
void init_gui()
init the display object and general set-up
virtual void highlight_hex(map_location hex)
Definition: display.cpp:1800
Game configuration data as global variables.
Definition: build_info.cpp:38
const display_context * get_dummy_display_context()
const t_translation::t_terrain & get_selected_bg_terrain()
const config & game_config_
GLuint index
Definition: glew.h:1782
structure which will hide all current floating labels, and cause floating labels instantiated after i...
Base class for all editor actions.
Definition: action_base.hpp:41
Internal representation of music tracks.
virtual std::vector< std::string > additional_actions_pressed() override
void set_scroll_right(bool on)
size_t i
Definition: function.cpp:1057
CURSOR_TYPE get()
Definition: cursor.cpp:194
void cut_selection()
Cut the selection from the current map to the clipboard.
GLint GLint GLint GLint GLint x
Definition: glew.h:1220
DIRECTION
Valid directions which can be moved in our hexagonal world.
Definition: location.hpp:40
void left_mouse_up(int x, int y, const bool browse)
Called when the left mouse button is up.
void display_redraw_callback(display &)
Callback function passed to display to be called on each redraw_everything run.
std::vector< sound::music_track > music_tracks_
#define N_(String)
Definition: gettext.hpp:90
void mouse_motion(int x, int y, const bool browse, bool update, map_location new_loc=map_location::null_location())
Called when a mouse motion event takes place.
void perform_delete(editor_action *action)
Perform an action, then delete the action object.
virtual bool execute_command(const hotkey_command &command, int index=-1, bool press=true)
GLuint const GLchar * name
Definition: glew.h:1782
GLsizeiptr size
Definition: glew.h:1649
bool do_quit_
Quit main loop flag.
static bool execute(editor::editor_display *display, const std::vector< time_of_day > &tods, CVideo &video)
Definition: custom_tod.hpp:48
void set_scroll_left(bool on)
EXIT_STATUS main_loop()
Editor main loop.
void copy_to_clipboard(const std::string &text, const bool)
Copies text to the clipboard.
Definition: clipboard.cpp:40
bool minimap_draw_terrain()
cl_event event
Definition: glew.h:3070
const hotkey::HOTKEY_COMMAND id
the names are strange: the "hotkey::HOTKEY_COMMAND" is named id, and the string to identify the objec...
void set_draw_terrain_codes(bool value)
#define ERR_ED
const std::vector< time_of_day > & times(const map_location &loc=map_location::null_location()) const
Remove a unit from the map.
Definition: action_unit.hpp:58
bool execute_command(const hotkey::hotkey_command &command, int index=-1, bool press=true)
command_executor override
Container associating units to locations.
Definition: map.hpp:90
GLsizei GLenum GLuint GLuint GLsizei char * message
Definition: glew.h:2499
void init_music(const config &game_config)
init background music for the editor
void show_unit_help(CVideo &video, const std::string &show_topic, bool has_variations, bool hidden, int xloc, int yloc)
Open the help browser, show unit with id unit_id.
Definition: help.cpp:127
#define e
void set_draw_hex_coordinates(bool value)
unit_iterator find(size_t id)
Definition: map.cpp:285
std::string::const_iterator iterator
Definition: tokenizer.hpp:21
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:83
Helper class, don't construct this directly.
GLdouble s
Definition: glew.h:1358
const hotkey_command & get_hotkey_command(const std::string &command)
returns the hotkey_command with the given name
Editor action classes.
GLsizei const GLcharARB ** string
Definition: glew.h:4503
virtual bool in_context_menu(hotkey::HOTKEY_COMMAND command) const
unit_map * units
Definition: resources.cpp:35
void right_mouse_up(int x, int y, const bool browse)
Called when the right mouse button is up.
const std::string & id() const
bool minimap_terrain_coding()