The Battle for Wesnoth  1.13.10+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 - 2017 by Tomasz Sniatowski <kailoran@gmail.com>
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 
17 
18 #include "editor/action/action.hpp"
22 
25 
27 
28 #include "preferences/editor.hpp"
29 
32 #include "gui/dialogs/message.hpp"
36 #include "gui/widgets/window.hpp"
37 #include "wml_exception.hpp"
38 
39 #include "resources.hpp"
40 #include "reports.hpp"
41 
42 #include "desktop/clipboard.hpp"
43 #include "floating_label.hpp"
44 #include "game_board.hpp"
45 #include "preferences/game.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 "utils/functional.hpp"
55 
56 namespace {
57 static std::vector<std::string> saved_windows_;
58 }
59 
60 namespace editor {
61 
63  : controller_base(game_config)
64  , mouse_handler_base()
65  , quit_confirmation(std::bind(&editor_controller::quit_confirm, this))
66  , active_menu_(editor::MAP)
67  , reports_(new reports())
68  , gui_(new editor_display(*this, video, *reports_, controller_base::get_theme(game_config, "editor")))
69  , tods_()
70  , context_manager_(new context_manager(*gui_.get(), game_config_))
71  , toolkit_(nullptr)
72  , tooltip_manager_(video)
73  , floating_label_manager_(nullptr)
74  , help_manager_(nullptr)
75  , do_quit_(false)
76  , quit_mode_(EXIT_ERROR)
77  , music_tracks_()
78 {
79  init_gui();
80  toolkit_.reset(new editor_toolkit(*gui_.get(), key_, game_config_, *context_manager_.get()));
81  help_manager_.reset(new help::help_manager(&game_config));
82  context_manager_->switch_context(0, true);
83  init_tods(game_config);
84  init_music(game_config);
87 
88  gui().create_buttons();
91 }
92 
94 {
95  gui_->change_display_context(&get_current_map_context());
97  gui_->add_redraw_observer(std::bind(&editor_controller::display_redraw_callback, this, _1));
102 // halo_manager_.reset(new halo::manager(*gui_));
103 // resources::halo = halo_manager_.get();
104 // ^ These lines no longer necessary, the gui owns its halo manager.
105 // TODO: Should the editor map contexts actually own the halo manager and swap them in and out from the gui?
106 // 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
107 // without deleting it.
108 }
109 
111 {
112  for (const config &schedule : game_config.child_range("editor_times")) {
113 
114  const std::string& schedule_id = schedule["id"];
115  const std::string& schedule_name = schedule["name"];
116  if (schedule_id.empty()) {
117  ERR_ED << "Missing ID attribute in a TOD Schedule." << std::endl;
118  continue;
119  }
120 
121  tods_map::iterator times = tods_.find(schedule_id);
122  if (times == tods_.end()) {
123  std::pair<tods_map::iterator, bool> new_times =
124  tods_.insert( std::pair<std::string, std::pair<std::string, std::vector<time_of_day> > >
125  (schedule_id, std::pair<std::string, std::vector<time_of_day> >(schedule_name, std::vector<time_of_day>())) );
126  times = new_times.first;
127  } else {
128  ERR_ED << "Duplicate TOD Schedule identifiers." << std::endl;
129  continue;
130  }
131 
132  for (const config &time : schedule.child_range("time")) {
133  times->second.second.emplace_back(time);
134  }
135 
136  }
137 
138  if (tods_.empty()) {
139  ERR_ED << "No editor time-of-day defined" << std::endl;
140  }
141 }
142 
144 {
145  const std::string tag_name = "editor_music";
146  if (!game_config.has_child(tag_name))
147  ERR_ED << "No editor music defined" << std::endl;
148  else {
149  for (const config& editor_music : game_config.child_range(tag_name)) {
150  for (const config& music : editor_music.child_range("music")) {
151  sound::music_track track(music);
152  if (track.file_path().empty())
153  WRN_ED << "Music track " << track.id() << " not found." << std::endl;
154  else
155  music_tracks_.emplace_back(music);
156  }
157  }
158  }
159 }
160 
162 {
163  resources::units = nullptr;
164  resources::tod_manager = nullptr;
165  resources::filter_con = nullptr;
166 
167  resources::classification = nullptr;
168 }
169 
171 {
172  try {
173  while (!do_quit_) {
174  play_slice();
175  }
176  } catch (editor_exception& e) {
177  gui2::show_transient_message(gui().video(), _("Fatal error"), e.what());
178  return EXIT_ERROR;
179  } catch (wml_exception& e) {
180  e.show(gui().video());
181  }
182  return quit_mode_;
183 }
184 
186 }
187 
188 void editor_controller::do_screenshot(const std::string& screenshot_filename /* = "map_screenshot.bmp" */)
189 {
190  try {
191  if (!gui().screenshot(screenshot_filename,true)) {
192  ERR_ED << "Screenshot creation failed!\n";
193  }
194  } catch (wml_exception& e) {
195  e.show(gui().video());
196  }
197 }
198 
200 {
201  std::string modified;
202  size_t amount = context_manager_->modified_maps(modified);
203 
204  std::string message;
205  if (amount == 0) {
206  message = _("Do you really want to quit?");
207  } else if (amount == 1) {
208  message = _("Do you really want to quit? Changes to this map since the last save will be lost.");
209  } else {
210  message = _("Do you really want to quit? The following maps were modified and all changes since the last save will be lost:");
211  message += "\n" + modified;
212  }
213  return quit_confirmation::show_prompt(message);
214 }
215 
217 {
218  if (tods_.empty()) {
219  gui2::show_error_message(gui().video(),
220  _("No editor time-of-day found."));
221  return;
222  }
223 
225 
226  if(gui2::dialogs::custom_tod::execute(manager.times(), manager.get_current_time(), gui().video())) {
227  // TODO save the new tod here
228  }
229 
230  gui_->update_tod();
231 
232  context_manager_->refresh_all();
233 }
234 
236 {
237  using namespace hotkey; //reduce hotkey:: clutter
238  switch (cmd.id) {
239  case HOTKEY_NULL:
240  if (index >= 0) {
241  unsigned i = static_cast<unsigned>(index);
242 
243  switch (active_menu_) {
244  case editor::MAP:
245  if (i < context_manager_->open_maps()) {
246  return true;
247  }
248  return false;
249  case editor::LOAD_MRU:
250  case editor::PALETTE:
251  case editor::AREA:
252  case editor::SIDE:
253  case editor::TIME:
254  case editor::SCHEDULE:
256  case editor::MUSIC:
257  case editor::LOCAL_TIME:
258  case editor::UNIT_FACING:
259  return true;
260  }
261  }
262  return false;
264  return true;
266  return toolkit_->get_palette_manager()->can_scroll_up();
268  return toolkit_->get_palette_manager()->can_scroll_down();
269  case HOTKEY_ZOOM_IN:
270  return !gui_->zoom_at_max();
271  case HOTKEY_ZOOM_OUT:
272  return !gui_->zoom_at_min();
273  case HOTKEY_ZOOM_DEFAULT:
274  case HOTKEY_FULLSCREEN:
275  case HOTKEY_SCREENSHOT:
277  case HOTKEY_TOGGLE_GRID:
278  case HOTKEY_MOUSE_SCROLL:
279  case HOTKEY_ANIMATE_MAP:
280  case HOTKEY_MUTE:
281  case HOTKEY_PREFERENCES:
282  case HOTKEY_HELP:
283  case HOTKEY_QUIT_GAME:
284  case HOTKEY_SCROLL_UP:
285  case HOTKEY_SCROLL_DOWN:
286  case HOTKEY_SCROLL_LEFT:
287  case HOTKEY_SCROLL_RIGHT:
288  return true; //general hotkeys we can always do
289 
292 
293  case HOTKEY_STATUS_TABLE:
294  return !get_current_map_context().get_teams().empty();
295 
297  return gui().mouseover_hex().valid();
298 
299  // unit tool related
300  case HOTKEY_DELETE_UNIT:
301  case HOTKEY_RENAME_UNIT:
309  {
310  map_location loc = gui_->mouseover_hex();
312  return (toolkit_->is_mouse_action_set(HOTKEY_EDITOR_TOOL_UNIT) &&
313  units.find(loc) != units.end());
314  }
315  case HOTKEY_UNDO:
317  case HOTKEY_REDO:
329  return true;
330 
334 
337  return !get_current_map_context().get_teams().empty();
338 
339  // brushes
347 
349  return true;
351  return toolkit_->get_palette_manager()->active_palette().supports_swap();
355  {
357  return context_manager_->modified_maps(dummy) > 1;
358  }
364  return true;
366  return !get_current_map_context().get_filename().empty()
368 
369  // Tools
370  // Pure map editing tools this can be used all the time.
375  return true;
376  // WWL dependent tools which don't rely on defined sides.
383  return !get_current_map_context().get_teams().empty();
384 
388  return !get_current_map_context().is_pure_map() &&
390 
392  return !get_current_map_context().is_pure_map() &&
394  && !context_manager_->get_map().selection().empty();
395 
400  return !context_manager_->get_map().selection().empty()
401  && !toolkit_->is_mouse_action_set(HOTKEY_EDITOR_CLIPBOARD_PASTE);
403  return (context_manager_->get_map().selection().size() > 1
404  && !toolkit_->is_mouse_action_set(HOTKEY_EDITOR_CLIPBOARD_PASTE));
408  return false; //not implemented
410  return !context_manager_->clipboard_empty();
415  return !context_manager_->clipboard_empty()
416  && toolkit_->is_mouse_action_set(HOTKEY_EDITOR_CLIPBOARD_PASTE);
419  return !toolkit_->is_mouse_action_set(HOTKEY_EDITOR_CLIPBOARD_PASTE);
421  return !get_current_map_context().get_map().selection().empty()
423  && !toolkit_->is_mouse_action_set(HOTKEY_EDITOR_CLIPBOARD_PASTE);
440  return true;
442  return false; //not implemented
446  return true;
447  default:
448  return false;
449  }
450 }
451 
453  using namespace hotkey;
454  switch (command) {
455 
457  {
459  get_current_map_context().get_units().find(gui_->mouseover_hex());
460  return un->loyal() ? ACTION_ON : ACTION_OFF;
461 
462  }
464  {
466  get_current_map_context().get_units().find(gui_->mouseover_hex());
467  return un->can_recruit() ? ACTION_ON : ACTION_OFF;
468  }
470  {
472  get_current_map_context().get_units().find(gui_->mouseover_hex());
473  return (!un->unrenamable()) ? ACTION_ON : ACTION_OFF;
474  }
475  //TODO remove hardcoded hotkey names
477  return context_manager_->is_active_transitions_hotkey("editor-auto-update-transitions")
480  return context_manager_->is_active_transitions_hotkey("editor-partial-update-transitions")
483  return context_manager_->is_active_transitions_hotkey("editor-no-update-transitions")
486  return toolkit_->is_active_brush("brush-1") ? ACTION_ON : ACTION_OFF;
488  return toolkit_->is_active_brush("brush-2") ? ACTION_ON : ACTION_OFF;
490  return toolkit_->is_active_brush("brush-3") ? ACTION_ON : ACTION_OFF;
492  return toolkit_->is_active_brush("brush-nw-se") ? ACTION_ON : ACTION_OFF;
494  return toolkit_->is_active_brush("brush-sw-ne") ? ACTION_ON : ACTION_OFF;
495 
496  case HOTKEY_TOGGLE_GRID:
502  return get_current_map_context().get_map().selection().empty() ?
513  return toolkit_->is_mouse_action_set(command) ? ACTION_ON : ACTION_OFF;
515  return gui_->get_draw_coordinates() ? ACTION_ON : ACTION_OFF;
517  return gui_->get_draw_terrain_codes() ? ACTION_ON : ACTION_OFF;
519  return gui_->get_draw_num_of_bitmaps() ? ACTION_ON : ACTION_OFF;
520 
531  case HOTKEY_ZOOM_DEFAULT:
532  return (gui_->get_zoom_factor() == 1.0) ? hotkey::ACTION_ON : hotkey::ACTION_OFF;
533 
534  case HOTKEY_NULL:
535  switch (active_menu_) {
536  case editor::MAP:
537  return index == context_manager_->current_context_index()
539  case editor::LOAD_MRU:
540  return ACTION_STATELESS;
541  case editor::PALETTE:
542  return ACTION_STATELESS;
543  case editor::AREA:
544  return index == get_current_map_context().get_active_area()
546  case editor::SIDE:
547  return static_cast<size_t>(index) == gui_->playing_team()
549  case editor::TIME:
552  case editor::LOCAL_TIME:
554  get_current_map_context().get_active_area())
556  case editor::MUSIC:
558  ? ACTION_ON : ACTION_OFF;
559  case editor::SCHEDULE:
560  {
561  tods_map::const_iterator it = tods_.begin();
562  std::advance(it, index);
563  const std::vector<time_of_day>& times1 = it->second.second;
564  const std::vector<time_of_day>& times2 = get_current_map_context().get_time_manager()->times();
565  return (times1 == times2) ? ACTION_SELECTED : ACTION_DESELECTED;
566  }
568  {
569  tods_map::const_iterator it = tods_.begin();
570  std::advance(it, index);
571  const std::vector<time_of_day>& times1 = it->second.second;
572  int active_area = get_current_map_context().get_active_area();
573  const std::vector<time_of_day>& times2 = get_current_map_context().get_time_manager()->times(active_area);
574  return (times1 == times2) ? ACTION_SELECTED : ACTION_DESELECTED;
575  }
576  case editor::UNIT_FACING:
577  {
579  assert(un != get_current_map_context().get_units().end());
580  return un->facing() == index ? ACTION_SELECTED : ACTION_DESELECTED;
581  }
582  }
583  return ACTION_ON;
584  default:
585  return command_executor::get_action_state(command, index);
586  }
587 }
588 
590 {
591  hotkey::HOTKEY_COMMAND command = cmd.id;
592  SCOPE_ED;
593  using namespace hotkey;
594 
595  // nothing here handles release; fall through to base implementation
596  if (!press) {
597  return hotkey::command_executor::execute_command(cmd, index, press);
598  }
599 
600  switch (command) {
601  case HOTKEY_NULL:
602  switch (active_menu_) {
603  case MAP:
604  if (index >= 0) {
605  unsigned i = static_cast<unsigned>(index);
606  if (i < context_manager_->size()) {
607  context_manager_->switch_context(index);
608  toolkit_->hotkey_set_mouse_action(HOTKEY_EDITOR_TOOL_PAINT);
609  return true;
610  }
611  }
612  return false;
613  case LOAD_MRU:
614  if (index >= 0) {
615  context_manager_->load_mru_item(static_cast<unsigned>(index));
616  }
617  return true;
618  case PALETTE:
619  toolkit_->get_palette_manager()->set_group(index);
620  return true;
621  case SIDE:
622  gui_->set_team(index, true);
623  gui_->set_playing_team(index);
624  toolkit_->get_palette_manager()->draw_contents();
625  return true;
626  case AREA:
627  {
629  const std::set<map_location>& area =
631  std::vector<map_location> locs(area.begin(), area.end());
633  gui_->scroll_to_tiles(locs.begin(), locs.end());
634  return true;
635  }
636  case TIME:
637  {
639  gui_->update_tod();
640  return true;
641  }
642  case LOCAL_TIME:
643  {
645  return true;
646  }
647  case MUSIC:
648  {
649  //TODO mark the map as changed
652  std::vector<config> items;
653  items.emplace_back(config {"id", "editor-playlist"});
654  std::shared_ptr<gui::button> b = gui_->find_menu_button("menu-playlist");
655  show_menu(items, b->location().x +1, b->location().y + b->height() +1, false, *gui_);
656  return true;
657  }
658  case SCHEDULE:
659  {
660  tods_map::iterator iter = tods_.begin();
661  std::advance(iter, index);
662  get_current_map_context().replace_schedule(iter->second.second);
663  // TODO: test again after the assign-schedule menu is fixed. Should work, though.
664  gui_->update_tod();
665  return true;
666  }
667  case LOCAL_SCHEDULE:
668  {
669  tods_map::iterator iter = tods_.begin();
670  std::advance(iter, index);
671  get_current_map_context().replace_local_schedule(iter->second.second);
672  return true;
673  }
674  case UNIT_FACING:
675  {
677  assert(un != get_current_map_context().get_units().end());
678  un->set_facing(map_location::DIRECTION(index));
679  un->anim_comp().set_standing();
680  return true;
681  }
682  }
683  return true;
684 
685  //Zoom
686  case HOTKEY_ZOOM_IN:
687  gui_->set_zoom(true);
689  toolkit_->set_mouseover_overlay(*gui_);
690  return true;
691  case HOTKEY_ZOOM_OUT:
692  gui_->set_zoom(false);
694  toolkit_->set_mouseover_overlay(*gui_);
695  return true;
696  case HOTKEY_ZOOM_DEFAULT:
697  gui_->set_default_zoom();
699  toolkit_->set_mouseover_overlay(*gui_);
700  return true;
701 
702  //Palette
704  {
705  //TODO this code waits for the gui2 dialog to get ready
706 // std::vector< std::pair< std::string, std::string > > blah_items;
707 // toolkit_->get_palette_manager()->active_palette().expand_palette_groups_menu(blah_items);
708 // int selected = 1; //toolkit_->get_palette_manager()->active_palette().get_selected;
709 // gui2::teditor_select_palette_group::execute(selected, blah_items, gui_->video());
710  }
711  return true;
713  toolkit_->get_palette_manager()->scroll_up();
714  gui_->draw(true,false);
715  return true;
717  toolkit_->get_palette_manager()->scroll_down();
718  gui_->draw(true,false);
719  return true;
720 
721  case HOTKEY_QUIT_GAME:
723  do_quit_ = true;
725  }
726  return true;
729  return true;
731  context_manager_->save_all_maps(true);
732  do_quit_ = true;
734  return true;
737  return true;
739  toolkit_->get_palette_manager()->active_palette().swap();
740  return true;
742  if (dynamic_cast<const editor_action_chain*>(get_current_map_context().last_undo_action()) != nullptr) {
744  context_manager_->refresh_after_action();
745  } else {
746  undo();
747  }
748  return true;
749 
750  //Tool Selection
759  toolkit_->hotkey_set_mouse_action(command);
760  return true;
761 
763  add_area();
764  return true;
765 
767  change_unit_id();
768  return true;
769 
771  {
772  map_location loc = gui_->mouseover_hex();
774  const std::set<std::string>& recruit_set = toolkit_->get_palette_manager()->unit_palette_->get_selected_bg_items();
775  std::vector<std::string> recruits(recruit_set.begin(), recruit_set.end());
776  un->set_recruits(recruits);
777  }
778  return true;
780  {
781  map_location loc = gui_->mouseover_hex();
783  bool unrenamable = un->unrenamable();
784  un->set_unrenamable(!unrenamable);
785  }
786  return true;
788  {
789  map_location loc = gui_->mouseover_hex();
791  bool canrecruit = un->can_recruit();
792  un->set_can_recruit(!canrecruit);
793  un->anim_comp().set_standing();
794  }
795  return true;
796  case HOTKEY_DELETE_UNIT:
797  {
798  map_location loc = gui_->mouseover_hex();
800  }
801  return true;
802  case HOTKEY_EDITOR_CLIPBOARD_PASTE: //paste is somewhat different as it might be "one action then revert to previous mode"
803  toolkit_->hotkey_set_mouse_action(command);
804  return true;
805 
806  //Clipboard
808  context_manager_->get_clipboard().rotate_60_cw();
809  toolkit_->update_mouse_action_highlights();
810  return true;
812  context_manager_->get_clipboard().rotate_60_ccw();
813  toolkit_->update_mouse_action_highlights();
814  return true;
816  context_manager_->get_clipboard().flip_horizontal();
817  toolkit_->update_mouse_action_highlights();
818  return true;
820  context_manager_->get_clipboard().flip_vertical();
821  toolkit_->update_mouse_action_highlights();
822  return true;
823 
824  //Brushes
826  toolkit_->cycle_brush();
827  return true;
829  toolkit_->set_brush("brush-1");
830  return true;
832  toolkit_->set_brush("brush-2");
833  return true;
835  toolkit_->set_brush("brush-3");
836  return true;
838  toolkit_->set_brush("brush-nw-se");
839  return true;
841  toolkit_->set_brush("brush-sw-ne");
842  return true;
843 
845  copy_selection();
846  return true;
848  cut_selection();
849  return true;
851  context_manager_->rename_area_dialog();
852  return true;
854  save_area();
855  return true;
858  return true;
860  if(!context_manager_->get_map().everything_selected()) {
861  context_manager_->perform_refresh(editor_action_select_all());
862  return true;
863  }
864  FALLTHROUGH;
867  return true;
869  context_manager_->perform_refresh(editor_action_select_none());
870  return true;
872  context_manager_->fill_selection();
873  return true;
876  context_manager_->get_map().selection()));
877  return true;
878 
880  context_manager_->edit_scenario_dialog();
881  return true;
882 
885  get_current_map_context().get_active_area());
886  return true;
887 
888  // map specific
890  context_manager_->close_current_context();
891  return true;
893  context_manager_->load_map_dialog();
894  return true;
896  context_manager_->revert_map();
897  return true;
899  context_manager_->new_map_dialog();
900  return true;
902  context_manager_->new_scenario_dialog();
903  return true;
905  save_map();
906  return true;
908  context_manager_->save_all_maps();
909  return true;
911  context_manager_->save_map_as_dialog();
912  return true;
914  context_manager_->save_scenario_as_dialog();
915  return true;
917  context_manager_->generate_map_dialog();
918  return true;
920  context_manager_->apply_mask_dialog();
921  return true;
923  context_manager_->create_mask_to_dialog();
924  return true;
926  context_manager_->resize_map_dialog();
927  return true;
928 
929  // Side specific ones
932  gui_->init_flags();
933  return true;
935  gui_->set_team(0, true);
936  gui_->set_playing_team(0);
938  return true;
940  context_manager_->edit_side_dialog(gui_->viewing_team());
941  return true;
942 
943  // Transitions
945  context_manager_->set_update_transitions_mode(2);
946  return true;
948  context_manager_->set_update_transitions_mode(1);
949  return true;
951  context_manager_->set_update_transitions_mode(0);
952  return true;
954  if(context_manager_->toggle_update_transitions()) {
955  return true;
956  }
957  FALLTHROUGH;
959  context_manager_->refresh_all();
960  return true;
961  // Refresh
963  context_manager_->reload_map();
964  return true;
967  return true;
968 
970  gui().set_draw_coordinates(!gui().get_draw_coordinates());
971  preferences::editor::set_draw_hex_coordinates(gui().get_draw_coordinates());
972  gui().invalidate_all();
973  return true;
975  gui().set_draw_terrain_codes(!gui().get_draw_terrain_codes());
976  preferences::editor::set_draw_terrain_codes(gui().get_draw_terrain_codes());
977  gui().invalidate_all();
978  return true;
980  gui().set_draw_num_of_bitmaps(!gui().get_draw_num_of_bitmaps());
981  preferences::editor::set_draw_num_of_bitmaps(gui().get_draw_num_of_bitmaps());
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<config>& 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<config> items;
1010  for(const auto& c : items_arg) {
1011  const std::string& id = c["id"];
1013 
1014  if((can_execute_command(command) && (!context_menu || in_context_menu(command.id)))
1015  || command.id == hotkey::HOTKEY_NULL)
1016  {
1017  items.emplace_back(config {"id", id});
1018  }
1019  }
1020 
1021  // No point in showing an empty menu.
1022  if(items.empty()) {
1023  return;
1024  }
1025 
1026  // Based on the ID of the first entry, we fill the menu contextually.
1027  const std::string& first_id = items.front()["id"];
1028 
1029  if(first_id == "EDITOR-LOAD-MRU-PLACEHOLDER") {
1031  context_manager_->expand_load_mru_menu(items, 0);
1032  }
1033 
1034  if(first_id == "editor-switch-map") {
1036  context_manager_->expand_open_maps_menu(items, 0);
1037  }
1038 
1039  if(first_id == "editor-palette-groups") {
1041  toolkit_->get_palette_manager()->active_palette().expand_palette_groups_menu(items, 0);
1042  }
1043 
1044  if(first_id == "editor-switch-side") {
1046  context_manager_->expand_sides_menu(items, 0);
1047  }
1048 
1049  if(first_id == "editor-switch-area") {
1051  context_manager_->expand_areas_menu(items, 0);
1052  }
1053 
1054  if(!items.empty() && items.front()["id"] == "editor-switch-time") {
1056  context_manager_->expand_time_menu(items, 0);
1057  }
1058 
1059  if(first_id == "editor-assign-local-time") {
1061  context_manager_->expand_local_time_menu(items, 0);
1062  }
1063 
1064  if(first_id == "menu-unit-facings") {
1066  auto pos = items.erase(items.begin());
1067  int dir = 0;
1068  std::generate_n(std::inserter<std::vector<config>>(items, pos), int(map_location::NDIRECTIONS), [&dir]() -> config {
1070  });
1071  }
1072 
1073  if(first_id == "editor-playlist") {
1075  auto pos = items.erase(items.begin());
1076  std::transform(music_tracks_.begin(), music_tracks_.end(), std::inserter<std::vector<config>>(items, pos), [](const sound::music_track& track) -> config {
1077  return config {"label", track.title().empty() ? track.id() : track.title()};
1078  });
1079  }
1080 
1081  if(first_id == "editor-assign-schedule") {
1083  auto pos = items.erase(items.begin());
1084  std::transform(tods_.begin(), tods_.end(), std::inserter<std::vector<config>>(items, pos), [](const tods_map::value_type& tod) -> config {
1085  return config {"label", tod.second.first};
1086  });
1087  }
1088 
1089  if(first_id == "editor-assign-local-schedule") {
1091  auto pos = items.erase(items.begin());
1092  std::transform(tods_.begin(), tods_.end(), std::inserter<std::vector<config>>(items, pos), [](const tods_map::value_type& tod) -> config {
1093  return config {"label", tod.second.first};
1094  });
1095  }
1096 
1097  command_executor::show_menu(items, xloc, yloc, context_menu, disp);
1098 }
1099 
1101 {
1102  gui_->video().clear_all_help_strings();
1104 
1105  gui_->redraw_everything();
1106 }
1107 
1109 {
1111  gui_->invalidate_all();
1112 }
1113 
1115 {
1116  map_location loc = gui_->mouseover_hex();
1118  const unit_map::const_unit_iterator un = units.find(loc);
1119  if(un != units.end()) {
1120  help::show_unit_help(gui_->video(), un->type_id(), un->type().show_variations_in_help(), false);
1121  } else {
1122  help::show_help(gui_->video(), "..units");
1123  }
1124 }
1125 
1126 
1128 {
1129  if (!context_manager_->get_map().selection().empty()) {
1130  context_manager_->get_clipboard() = map_fragment(context_manager_->get_map(), context_manager_->get_map().selection());
1131  context_manager_->get_clipboard().center_by_mass();
1132  }
1133 }
1134 
1136 {
1137  map_location loc = gui_->mouseover_hex();
1139  const unit_map::unit_iterator& un = units.find(loc);
1140 
1141  const std::string title(N_("Change Unit ID"));
1142  const std::string label(N_("ID:"));
1143 
1144  if(un != units.end()) {
1145  std::string id = un->id();
1146  if (gui2::dialogs::edit_text::execute(title, label, id, gui_->video())) {
1147  un->set_id(id);
1148  }
1149  }
1150 }
1151 
1153 {
1154  map_location loc = gui_->mouseover_hex();
1156  const unit_map::unit_iterator& un = units.find(loc);
1157 
1158  const std::string title(N_("Rename Unit"));
1159  const std::string label(N_("Name:"));
1160 
1161  if(un != units.end()) {
1162  std::string name = un->name();
1163  if(gui2::dialogs::edit_text::execute(title, label, name, gui_->video())) {
1164  //TODO we may not want a translated name here.
1165  un->set_name(name);
1166  }
1167  }
1168 }
1169 
1171 {
1173 }
1174 
1176 {
1177  copy_selection();
1178  context_manager_->perform_refresh(editor_action_paint_area(context_manager_->get_map().selection(), get_selected_bg_terrain()));
1179 }
1180 
1182 {
1183  const std::set<map_location>& area = context_manager_->get_map().selection();
1185 }
1186 
1188 {
1189  const std::set<map_location>& area = context_manager_->get_map().selection();
1191 }
1192 
1194 {
1195  std::stringstream ssx, ssy;
1196  std::set<map_location>::const_iterator i = context_manager_->get_map().selection().begin();
1197  if (i != context_manager_->get_map().selection().end()) {
1198  ssx << "x = " << i->wml_x();
1199  ssy << "y = " << i->wml_y();
1200  ++i;
1201  while (i != context_manager_->get_map().selection().end()) {
1202  ssx << ", " << i->wml_x();
1203  ssy << ", " << i->wml_y();
1204  ++i;
1205  }
1206  ssx << "\n" << ssy.str() << "\n";
1207  desktop::clipboard::copy_to_clipboard(ssx.str(), false);
1208  }
1209 }
1210 
1212 {
1213  if (action) {
1214  const editor_action_ptr action_auto(action);
1216  }
1217 }
1218 
1219 void editor_controller::perform_refresh_delete(editor_action* action, bool drag_part /* =false */)
1220 {
1221  if (action) {
1222  const editor_action_ptr action_auto(action);
1223  context_manager_->perform_refresh(*action, drag_part);
1224  }
1225 }
1226 
1228 {
1230  context_manager_->refresh_all();
1231 }
1232 
1234 {
1235  set_button_state();
1236  toolkit_->adjust_size();
1237  toolkit_->get_palette_manager()->draw_contents();
1239 }
1240 
1242 {
1244  context_manager_->refresh_after_action();
1245 }
1246 
1248 {
1250  context_manager_->refresh_after_action();
1251 }
1252 
1253 void editor_controller::mouse_motion(int x, int y, const bool /*browse*/,
1254  bool update, map_location /*new_loc*/)
1255 {
1256  if (mouse_handler_base::mouse_motion_default(x, y, update)) return;
1257  map_location hex_clicked = gui().hex_clicked_on(x, y);
1258  if (context_manager_->get_map().on_board_with_border(drag_from_hex_) && is_dragging()) {
1259  editor_action* a = nullptr;
1260  bool partial = false;
1262  if (dragging_left_ && (SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON(1)) != 0) {
1263  if (!context_manager_->get_map().on_board_with_border(hex_clicked)) return;
1264  a = get_mouse_action().drag_left(*gui_, x, y, partial, last_undo);
1265  } else if (dragging_right_ && (SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON(3)) != 0) {
1266  if (!context_manager_->get_map().on_board_with_border(hex_clicked)) return;
1267  a = get_mouse_action().drag_right(*gui_, x, y, partial, last_undo);
1268  }
1269  //Partial means that the mouse action has modified the
1270  //last undo action and the controller shouldn't add
1271  //anything to the undo stack (hence a different perform_ call)
1272  if (a != nullptr) {
1273  const editor_action_ptr aa(a);
1274  if (partial) {
1276  } else {
1278  }
1279  context_manager_->refresh_after_action(true);
1280  }
1281  } else {
1282  get_mouse_action().move(*gui_, hex_clicked);
1283  }
1284  gui().highlight_hex(hex_clicked);
1285 }
1286 
1288 {
1289  return context_manager_->get_map().on_board_with_border(gui().hex_clicked_on(x,y));
1290 }
1291 
1292 bool editor_controller::right_click_show_menu(int /*x*/, int /*y*/, const bool /*browse*/)
1293 {
1295 }
1296 
1297 bool editor_controller::left_click(int x, int y, const bool browse)
1298 {
1299  toolkit_->clear_mouseover_overlay();
1300  if (mouse_handler_base::left_click(x, y, browse))
1301  return true;
1302 
1303  LOG_ED << "Left click, after generic handling\n";
1304  map_location hex_clicked = gui().hex_clicked_on(x, y);
1305  if (!context_manager_->get_map().on_board_with_border(hex_clicked))
1306  return true;
1307 
1308  LOG_ED << "Left click action " << hex_clicked << "\n";
1310  perform_refresh_delete(a, true);
1311  if (a) set_button_state();
1312 
1313  return false;
1314 }
1315 
1316 void editor_controller::left_drag_end(int x, int y, const bool /*browse*/)
1317 {
1319  perform_delete(a);
1320 }
1321 
1322 void editor_controller::left_mouse_up(int x, int y, const bool /*browse*/)
1323 {
1325  perform_delete(a);
1326  if (a) set_button_state();
1327  toolkit_->set_mouseover_overlay();
1328  context_manager_->refresh_after_action();
1329 }
1330 
1331 bool editor_controller::right_click(int x, int y, const bool browse)
1332 {
1333  toolkit_->clear_mouseover_overlay();
1334  if (mouse_handler_base::right_click(x, y, browse)) return true;
1335  LOG_ED << "Right click, after generic handling\n";
1336  map_location hex_clicked = gui().hex_clicked_on(x, y);
1337  if (!context_manager_->get_map().on_board_with_border(hex_clicked)) return true;
1338  LOG_ED << "Right click action " << hex_clicked << "\n";
1340  perform_refresh_delete(a, true);
1341  if (a) set_button_state();
1342  return false;
1343 }
1344 
1345 void editor_controller::right_drag_end(int x, int y, const bool /*browse*/)
1346 {
1348  perform_delete(a);
1349 }
1350 
1351 void editor_controller::right_mouse_up(int x, int y, const bool /*browse*/)
1352 {
1354  perform_delete(a);
1355  if (a) set_button_state();
1356  toolkit_->set_mouseover_overlay();
1357  context_manager_->refresh_after_action();
1358 }
1359 
1361 {
1362  const map_location& loc = gui().mouseover_hex();
1363  if (context_manager_->get_map().on_board(loc) == false)
1364  return;
1365 
1366  const terrain_type& type = context_manager_->get_map().get_terrain_info(loc);
1367  help::show_terrain_description(gui().video(), type);
1368 }
1369 
1370 void editor_controller::process_keyup_event(const SDL_Event& event)
1371 {
1372  editor_action* a = get_mouse_action().key_event(gui(), event);
1374  toolkit_->set_mouseover_overlay();
1375 }
1376 
1378  return this;
1379 }
1380 
1382 {
1384 }
1385 
1387 {
1389 }
1390 
1392 {
1394 }
1395 
1397 {
1399 }
1400 
1402 {
1403  return toolkit_->get_palette_manager()->active_palette().action_pressed();
1404 }
1405 
1406 } //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...
Randomize terrain in an area.
Definition: action.hpp:441
void undo()
Un-does the last action, and puts it in the redo stack for a possible redo.
void set_grid(bool ison)
Definition: display.cpp:73
void show_error_message(CVideo &video, const std::string &msg, bool message_use_markup)
Shows an error message to the user.
Definition: message.cpp:207
virtual editor_action * click_left(editor_display &disp, int x, int y)=0
A click, possibly the beginning of a drag.
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:116
void set_preference_display_settings()
Definition: display.cpp:47
::tod_manager * tod_manager
Definition: resources.cpp:30
void copy_selection()
Copy the selection on the current map to the clipboard.
static std::string write_translated_direction(DIRECTION dir)
Definition: location.cpp:160
void set_draw_num_of_bitmaps(bool value)
Setter for the terrain code debug overlay on tiles.
Definition: display.hpp:366
void set_scroll_down(bool on)
unit_iterator end()
Definition: map.hpp:415
const char * what() const NOEXCEPT
Definition: exceptions.hpp:37
bool minimap_draw_units()
Definition: general.cpp:922
A map fragment – a collection of locations and information abut them.
std::vector< char_t > string
void add_to_playlist(const sound::music_track &track)
size_t index(const utf8::string &str, const size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:71
Select the entire map.
std::unique_ptr< font::floating_label_context > floating_label_manager_
const t_translation::terrain_code & get_selected_bg_terrain()
virtual bool has_context_menu() const
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:361
void set(CURSOR_TYPE type)
Use the default parameter to reset cursors.
Definition: cursor.cpp:154
void save_map() override
Save the map, open dialog if not named yet.
void export_selection_coords()
Export the WML-compatible list of selected tiles to the system clipboard.
int dummy
Definition: lstrlib.cpp:1125
std::unique_ptr< editor_action > editor_action_ptr
Action pointer typedef.
game_classification * classification
Definition: resources.cpp:36
void do_screenshot(const std::string &screenshot_filename="map_screenshot.bmp")
Takes a screenshot.
void mouse_motion(int x, int y, const bool browse, bool update, map_location new_loc=map_location::null_location()) override
Called when a mouse motion event takes place.
bool quit_confirm()
Show a quit confirmation dialog and returns true if the user pressed 'yes'.
bool draw_num_of_bitmaps()
Definition: editor.cpp:53
Editor action classes.
void save_area(const std::set< map_location > &area)
Add a special kind of assert to validate whether the input from WML doesn't contain any problems that...
void new_side()
Adds a new side to the map.
std::unique_ptr< editor_toolkit > toolkit_
void custom_tods_dialog()
Display the settings dialog, used to control e.g.
void process_keyup_event(const SDL_Event &event) override
Process keyup (always).
void left_drag_end(int x, int y, const bool browse) override
Called whenever the left mouse drag has "ended".
#define a
Definition: video.hpp:29
bool minimap_movement_coding()
Definition: general.cpp:902
int get_current_area_time(int index) const
editor_display & gui() override
Reference to the used display objects.
This file contains the window object, this object is a top level container which has the event manage...
bool can_execute_command(const hotkey::hotkey_command &command, int index=-1) const override
command_executor override
child_itors child_range(config_key_type key)
Definition: config.cpp:295
virtual bool supports_brushes() const
Whether we need the brush bar, is used to grey it out.
void new_area(const std::set< map_location > &area)
void show_unit_list(display &gui)
Definition: unit_list.cpp:198
bool right_click_show_menu(int x, int y, const bool browse) override
Called in the default right_click when the context menu is about to be shown, can be used for preproc...
void set_active_area(int index)
void redraw_everything()
Invalidates entire screen, including all tiles and sidebar.
Definition: display.cpp:2371
map_labels & get_labels()
bool modified() const
#define LOG_ED
void save_area()
Save the current selection to the active area.
void preferences() override
Show the preferences dialog.
static bool show_prompt(const std::string &message)
Stores all information related to functions that can be bound to hotkeys.
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:585
static bool execute(const std::vector< time_of_day > &times, int current_time, CVideo &video)
Definition: custom_tod.hpp:38
void add_area()
Add a new area to the current context, filled with the selection if any.
const std::string & title() const
void play_slice(bool is_delay_enabled=true)
STL namespace.
void redo()
Re-does a previously undid action, and puts it back in the undo stack.
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.
virtual editor_action * drag_left(editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
Drag operation.
const std::string & get_filename() const
#define SCOPE_ED
const std::vector< std::string > items
void play_music_once(const std::string &file)
Definition: sound.cpp:551
The editor_controller class contains the mouse and keyboard event handling routines for the editor...
bool draw_terrain_codes()
Definition: editor.cpp:37
Set starting position action.
Definition: action.hpp:340
void partial_undo()
Un-does a single step from a undo action chain.
Keyboard shortcuts for game actions.
void show(CVideo &video)
Shows the error in a dialog.
Unit and team statistics.
void remove_area(int index)
void flush_cache()
Definition: image.cpp:217
int show_menu(lua_State *L, CVideo &video)
Displays a popup menu at the current mouse position Best used from a [set_menu_item], to show a submenu.
Definition: lua_gui2.cpp:410
#define b
const std::string & selected_item() const
Return the currently selected item.
#define WRN_ED
bool minimap_draw_villages()
Definition: general.cpp:932
const std::unique_ptr< editor_display > gui_
The display object used and owned by the editor.
map_context & get_current_map_context() const
void show_menu(const std::vector< config > &items_arg, int xloc, int yloc, bool context_menu, display &disp) override
controller_base override
void right_mouse_up(int x, int y, const bool browse) override
Called when the right mouse button is up.
static UNUSEDNOWARN std::string _(const char *str)
Definition: gettext.hpp:89
tod_manager * get_time_manager()
virtual editor_action * up_left(editor_display &disp, int x, int y)
void right_drag_end(int x, int y, const bool browse) override
Called whenever the right mouse drag has "ended".
void set_local_starting_time(int time)
TODO.
const map_location & mouseover_hex() const
Definition: display.hpp:286
bool is_pure_map() const
virtual editor_action * key_event(editor_display &disp, const SDL_Event &e)
Function called by the controller on a key event for the current mouse action.
bool everything_selected() const
Definition: editor_map.cpp:210
bool valid() const
Definition: location.hpp:72
void init_tods(const config &game_config)
init the available time-of-day settings
void remove_side()
removes the last side from the scenario
Implements a quit confirmation dialog.
virtual editor_action * drag_right(editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
Drag operation.
filter_context * filter_con
Definition: resources.cpp:23
void set_draw_coordinates(bool value)
Setter for the x,y debug overlay on tiles.
Definition: display.hpp:356
void undo() override
Undos an action in the current map context.
bool execute_command(const hotkey::hotkey_command &command, int index=-1, bool press=true) override
command_executor override
editor_map & get_map()
Map accessor.
Definition: map_context.hpp:92
virtual hotkey::command_executor * get_hotkey_command_executor() override
Optionally get a command executor to handle context menu events.
map_location drag_from_hex_
Drag start map location.
void replace_schedule(const std::vector< time_of_day > &schedule)
virtual editor_action * click_right(editor_display &disp, int x, int y)=0
A click, possibly the beginning of a drag.
Editor action classes.
void set_starting_time(int time)
TODO.
editor_action * last_undo_action()
bool draw_hex_coordinates()
Definition: editor.cpp:45
virtual editor_action * up_right(editor_display &disp, int x, int y)
void create_buttons()
Definition: display.cpp:896
void refresh_image_cache()
Reload images.
Manage the empty-palette in the editor.
Definition: action.cpp:29
static bool execute(const std::string &title, const std::string &label, std::string &text, CVideo &video)
Executes the dialog.
Definition: edit_text.hpp:52
void perform_action(const editor_action &action)
Performs an action (thus modifying the map).
bool can_undo() const
void invalidate_all()
Function to invalidate all tiles.
Definition: display.cpp:2971
const std::string & file_path() const
void raise_draw_event()
Definition: events.cpp:650
Paint the same terrain on a number of locations on the map.
Definition: action.hpp:284
bool dragging_left_
LMB drag init flag.
void show_terrain_description(CVideo &video, const terrain_type &t)
Definition: help.cpp:63
static bool quit()
Shows the quit confirmation if needed.
bool has_child(config_key_type key) const
Determine whether a config has a child or not.
Definition: config.cpp:345
Encapsulates the map of the game.
Definition: location.hpp:40
Helper class, don't construct this directly.
void perform_partial_action(const editor_action &action)
Performs a partial action, assumes that the top undo action has been modified to maintain coherent st...
size_t size(const utf8::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:86
void recalculate_labels()
Definition: label.cpp:244
void set_starting_position_labels(display &disp)
std::vector< team > & get_teams()
Get the team from the current map context object.
static void quit_to_desktop()
void init_gui()
init the display object and general set-up
void scroll_right(bool on) override
bool can_redo() const
std::vector< std::string > get_area_ids() const
void left_mouse_up(int x, int y, const bool browse) override
Called when the left mouse button is up.
virtual void highlight_hex(map_location hex)
Definition: display.cpp:1626
Game configuration data as global variables.
Definition: build_info.cpp:53
const config & game_config_
unit_map & get_units()
Get the unit map from the current map context object.
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:40
Internal representation of music tracks.
virtual std::vector< std::string > additional_actions_pressed() override
const std::set< map_location > & get_area_by_index(int index) const
void set_scroll_right(bool on)
CURSOR_TYPE get()
Definition: cursor.cpp:194
void cut_selection()
Cut the selection from the current map to the clipboard.
#define i
DIRECTION
Valid directions which can be moved in our hexagonal world.
Definition: location.hpp:42
static void display(CVideo &video, const config &game_cfg, const preferences::PREFERENCE_VIEW initial_view=preferences::VIEW_DEFAULT)
The display function – see modal_dialog for more information.
void display_redraw_callback(display &)
Callback function passed to display to be called on each redraw_everything run.
editor_controller(const editor_controller &)=delete
std::vector< sound::music_track > music_tracks_
#define N_(String)
Definition: gettext.hpp:97
const std::set< map_location > & selection() const
Return the selection set.
Definition: editor_map.hpp:149
void toggle_grid() override
Grid toggle.
const mouse_action & get_mouse_action() const
Get the current mouse action.
void perform_delete(editor_action *action)
Perform an action, then delete the action object.
bool allow_mouse_wheel_scroll(int x, int y) override
Derived classes can override this to disable mousewheel scrolling under some circumstances, e.g.
void scroll_left(bool on) override
virtual bool execute_command(const hotkey_command &command, int index=-1, bool press=true)
bool empty() const
Definition: map.hpp:432
const HOTKEY_COMMAND id
the names are strange: the "hotkey::HOTKEY_COMMAND" is named id, and the string to identify the objec...
bool grid()
Definition: general.cpp:504
bool left_click(int x, int y, const bool browse) override
Overridden in derived classes, called on a left click (mousedown).
bool do_quit_
Quit main loop flag.
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:35
int get_current_time(const map_location &loc=map_location::null_location()) const
bool minimap_draw_terrain()
Definition: general.cpp:942
virtual editor_action * drag_end_left(editor_display &disp, int x, int y)
The end of dragging.
void set_draw_terrain_codes(bool value)
Definition: editor.cpp:41
std::unique_ptr< help::help_manager > help_manager_
virtual void move(editor_display &disp, const map_location &hex)
Mouse move (not a drag).
#define ERR_ED
const std::vector< time_of_day > & times(const map_location &loc=map_location::null_location()) const
bool is_in_playlist(std::string track_id)
Remove a unit from the map.
Definition: action_unit.hpp:63
CVideo & video()
Gets the underlying screen object.
Definition: display.hpp:195
void replace_local_schedule(const std::vector< time_of_day > &schedule)
Replace the [time]s of the currently active area.
Container associating units to locations.
Definition: map.hpp:99
int get_active_area() const
static const char * name(const std::vector< SDL_Joystick * > &joysticks, const size_t index)
Definition: joystick.cpp:48
void set_draw_num_of_bitmaps(bool value)
Definition: editor.cpp:57
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:126
#define e
void set_draw_hex_coordinates(bool value)
Definition: editor.cpp:49
unit_iterator find(size_t id)
Definition: map.cpp:311
const std::unique_ptr< context_manager > context_manager_
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:93
mock_char c
void scroll_down(bool on) override
const hotkey_command & get_hotkey_command(const std::string &command)
returns the hotkey_command with the given name
Editor action classes.
void scroll_up(bool on) override
Handle hotkeys to scroll map.
bool right_click(int x, int y, const bool browse) override
Overridden in derived classes, called on a right click (mousedown).
static std::vector< std::string > saved_windows_
virtual bool in_context_menu(hotkey::HOTKEY_COMMAND command) const
std::string::const_iterator iterator
Definition: tokenizer.hpp:24
unit_map * units
Definition: resources.cpp:34
void redo() override
Redos an action in the current map context.
virtual editor_action * drag_end_right(editor_display &disp, int x, int y)
bool select_area(int index)
Select the nth tod area.
hotkey::ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND command, int index) const override
command_executor override
const std::string & id() const
bool minimap_terrain_coding()
Definition: general.cpp:912