The Battle for Wesnoth  1.15.5+dev
editor_controller.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2018 by Tomasz Sniatowski <kailoran@gmail.com>
3  Part of the Battle for Wesnoth Project https://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/retval.hpp"
37 #include "wml_exception.hpp"
38 
39 #include "resources.hpp"
40 #include "reports.hpp"
41 
42 #include "cursor.hpp"
43 #include "desktop/clipboard.hpp"
44 #include "floating_label.hpp"
45 #include "game_board.hpp"
46 #include "preferences/game.hpp"
47 #include "gettext.hpp"
48 #include "picture.hpp"
49 #include "preferences/display.hpp"
50 #include "sound.hpp"
51 #include "units/unit.hpp"
53 #include "game_config_manager.hpp"
54 #include "quit_confirmation.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()
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(*this, *reports_, controller_base::get_theme(game_config_, "editor")))
71  , tods_()
72  , context_manager_(new context_manager(*gui_.get(), game_config_))
73  , toolkit_(nullptr)
74  , tooltip_manager_()
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_->locs_ = toolkit_->get_palette_manager()->location_palette_.get();
85  context_manager_->switch_context(0, true);
86  init_tods(game_config_);
87  init_music(game_config_);
90 
91  gui().create_buttons();
93 }
94 
96 {
97  gui_->change_display_context(&get_current_map_context());
99  gui_->add_redraw_observer(std::bind(&editor_controller::display_redraw_callback, this, _1));
104 // halo_manager_.reset(new halo::manager(*gui_));
105 // resources::halo = halo_manager_.get();
106 // ^ These lines no longer necessary, the gui owns its halo manager.
107 // TODO: Should the editor map contexts actually own the halo manager and swap them in and out from the gui?
108 // 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
109 // without deleting it.
110 }
111 
113 {
114  for (const config &schedule : game_config.child_range("editor_times")) {
115 
116  const std::string& schedule_id = schedule["id"];
117  const std::string& schedule_name = schedule["name"];
118  if (schedule_id.empty()) {
119  ERR_ED << "Missing ID attribute in a TOD Schedule." << std::endl;
120  continue;
121  }
122 
123  tods_map::iterator times = tods_.find(schedule_id);
124  if (times == tods_.end()) {
125  std::pair<tods_map::iterator, bool> new_times =
126  tods_.emplace(schedule_id, std::make_pair(schedule_name, std::vector<time_of_day>()));
127 
128  times = new_times.first;
129  } else {
130  ERR_ED << "Duplicate TOD Schedule identifiers." << std::endl;
131  continue;
132  }
133 
134  for (const config &time : schedule.child_range("time")) {
135  times->second.second.emplace_back(time);
136  }
137 
138  }
139 
140  if (tods_.empty()) {
141  ERR_ED << "No editor time-of-day defined" << std::endl;
142  }
143 }
144 
146 {
147  const std::string tag_name = "editor_music";
148  if (game_config.child_range(tag_name).size() == 0) {
149  ERR_ED << "No editor music defined" << std::endl;
150  }
151  else {
152  for (const config& editor_music : game_config.child_range(tag_name)) {
153  for (const config& music : editor_music.child_range("music")) {
154  sound::music_track track(music);
155  if (track.file_path().empty())
156  WRN_ED << "Music track " << track.id() << " not found." << std::endl;
157  else
158  music_tracks_.emplace_back(music);
159  }
160  }
161  }
162 }
163 
165 {
166  resources::tod_manager = nullptr;
167  resources::filter_con = nullptr;
168 
169  resources::classification = nullptr;
170 }
171 
173 {
174  try {
175  while (!do_quit_) {
176  play_slice();
177  }
178  } catch (const editor_exception& e) {
179  gui2::show_transient_message(_("Fatal error"), e.what());
180  return EXIT_ERROR;
181  } catch (const wml_exception& e) {
182  e.show();
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  surface screenshot = gui().screenshot(true);
194  if(!screenshot || image::save_image(screenshot, screenshot_filename) != image::save_result::success) {
195  ERR_ED << "Screenshot creation failed!\n";
196  }
197  } catch (const wml_exception& e) {
198  e.show();
199  }
200 }
201 
203 {
204  std::string modified;
205  std::size_t amount = context_manager_->modified_maps(modified);
206 
207  std::string message;
208  if (amount == 0) {
209  message = _("Do you really want to quit?");
210  } else if (amount == 1 && get_current_map_context().modified()) {
211  message = _("Do you really want to quit? Changes to this map since the last save will be lost.");
212  } else {
213  message = _("Do you really want to quit? The following maps were modified and all changes since the last save will be lost:");
214  message += "\n" + modified;
215  }
216  return quit_confirmation::show_prompt(message);
217 }
218 
220 {
221  if (tods_.empty()) {
222  gui2::show_error_message(_("No editor time-of-day found."));
223  return;
224  }
225 
227 
228  if(gui2::dialogs::custom_tod::execute(manager.times(), manager.get_current_time())) {
229  // TODO save the new tod here
230  }
231 
232  gui_->update_tod();
233 
234  context_manager_->refresh_all();
235 }
236 
238 {
239  using namespace hotkey; //reduce hotkey:: clutter
240  switch (cmd.id) {
241  case HOTKEY_NULL:
242  if (index >= 0) {
243  unsigned i = static_cast<unsigned>(index);
244 
245  switch (active_menu_) {
246  case editor::MAP:
247  if (i < context_manager_->open_maps()) {
248  return true;
249  }
250  return false;
251  case editor::LOAD_MRU:
252  case editor::PALETTE:
253  case editor::AREA:
254  case editor::SIDE:
255  case editor::TIME:
256  case editor::SCHEDULE:
258  case editor::MUSIC:
259  case editor::LOCAL_TIME:
260  case editor::UNIT_FACING:
261  return true;
262  }
263  }
264  return false;
266  return true;
268  return toolkit_->get_palette_manager()->can_scroll_up();
270  return toolkit_->get_palette_manager()->can_scroll_down();
271  case HOTKEY_ZOOM_IN:
272  return !gui_->zoom_at_max();
273  case HOTKEY_ZOOM_OUT:
274  return !gui_->zoom_at_min();
275  case HOTKEY_ZOOM_DEFAULT:
276  case HOTKEY_FULLSCREEN:
277  case HOTKEY_SCREENSHOT:
279  case HOTKEY_TOGGLE_GRID:
280  case HOTKEY_MOUSE_SCROLL:
281  case HOTKEY_ANIMATE_MAP:
282  case HOTKEY_MUTE:
283  case HOTKEY_PREFERENCES:
284  case HOTKEY_HELP:
285  case HOTKEY_QUIT_GAME:
286  case HOTKEY_SCROLL_UP:
287  case HOTKEY_SCROLL_DOWN:
288  case HOTKEY_SCROLL_LEFT:
289  case HOTKEY_SCROLL_RIGHT:
290  return true; //general hotkeys we can always do
291 
293  return !get_current_map_context().units().empty();
294 
295  case HOTKEY_STATUS_TABLE:
296  return !get_current_map_context().teams().empty();
297 
299  return gui().mouseover_hex().valid();
300 
301  // unit tool related
302  case HOTKEY_DELETE_UNIT:
303  case HOTKEY_RENAME_UNIT:
311  {
312  map_location loc = gui_->mouseover_hex();
313  const unit_map& units = get_current_map_context().units();
314  return (toolkit_->is_mouse_action_set(HOTKEY_EDITOR_TOOL_UNIT) &&
315  units.find(loc) != units.end());
316  }
317  case HOTKEY_UNDO:
319  case HOTKEY_REDO:
331  return true;
332 
336 
339  return !get_current_map_context().teams().empty();
340 
341  // brushes
349 
351  return true;
353  return toolkit_->get_palette_manager()->active_palette().supports_swap();
357  {
359  return context_manager_->modified_maps(dummy) > 1;
360  }
366  return true;
368  return !get_current_map_context().get_filename().empty()
370 
371  // Tools
372  // Pure map editing tools this can be used all the time.
377  return true;
378  // WWL dependent tools which don't rely on defined sides.
385  return !get_current_map_context().teams().empty();
386 
390  return !get_current_map_context().is_pure_map() &&
392 
394  return !get_current_map_context().is_pure_map() &&
396  && !get_current_map_context().map().selection().empty();
397 
402  return !get_current_map_context().map().selection().empty()
403  && !toolkit_->is_mouse_action_set(HOTKEY_EDITOR_CLIPBOARD_PASTE);
405  return (get_current_map_context().map().selection().size() > 1
406  && !toolkit_->is_mouse_action_set(HOTKEY_EDITOR_CLIPBOARD_PASTE));
410  return false; //not implemented
412  return !context_manager_->clipboard_empty();
417  return !context_manager_->clipboard_empty()
418  && toolkit_->is_mouse_action_set(HOTKEY_EDITOR_CLIPBOARD_PASTE);
421  return !toolkit_->is_mouse_action_set(HOTKEY_EDITOR_CLIPBOARD_PASTE);
423  return !get_current_map_context().map().selection().empty()
425  && !toolkit_->is_mouse_action_set(HOTKEY_EDITOR_CLIPBOARD_PASTE);
442  return true;
444  return false; //not implemented
448  return true;
449  default:
450  return false;
451  }
452 }
453 
455  using namespace hotkey;
456  switch (command) {
457 
459  {
461  get_current_map_context().units().find(gui_->mouseover_hex());
462  return un->loyal() ? ACTION_ON : ACTION_OFF;
463 
464  }
466  {
468  get_current_map_context().units().find(gui_->mouseover_hex());
469  return un->can_recruit() ? ACTION_ON : ACTION_OFF;
470  }
472  {
474  get_current_map_context().units().find(gui_->mouseover_hex());
475  return (!un->unrenamable()) ? ACTION_ON : ACTION_OFF;
476  }
477  //TODO remove hardcoded hotkey names
479  return context_manager_->is_active_transitions_hotkey("editor-auto-update-transitions")
482  return context_manager_->is_active_transitions_hotkey("editor-partial-update-transitions")
485  return context_manager_->is_active_transitions_hotkey("editor-no-update-transitions")
488  return toolkit_->is_active_brush("brush-1") ? ACTION_ON : ACTION_OFF;
490  return toolkit_->is_active_brush("brush-2") ? ACTION_ON : ACTION_OFF;
492  return toolkit_->is_active_brush("brush-3") ? ACTION_ON : ACTION_OFF;
494  return toolkit_->is_active_brush("brush-nw-se") ? ACTION_ON : ACTION_OFF;
496  return toolkit_->is_active_brush("brush-sw-ne") ? ACTION_ON : ACTION_OFF;
497 
498  case HOTKEY_TOGGLE_GRID:
504  return get_current_map_context().map().selection().empty() ?
515  return toolkit_->is_mouse_action_set(command) ? ACTION_ON : ACTION_OFF;
517  return gui_->get_draw_coordinates() ? ACTION_ON : ACTION_OFF;
519  return gui_->get_draw_terrain_codes() ? ACTION_ON : ACTION_OFF;
521  return gui_->get_draw_num_of_bitmaps() ? ACTION_ON : ACTION_OFF;
522 
533  case HOTKEY_ZOOM_DEFAULT:
534  return (gui_->get_zoom_factor() == 1.0) ? hotkey::ACTION_ON : hotkey::ACTION_OFF;
535 
536  case HOTKEY_NULL:
537  switch (active_menu_) {
538  case editor::MAP:
539  return index == context_manager_->current_context_index()
541  case editor::LOAD_MRU:
542  return ACTION_STATELESS;
543  case editor::PALETTE:
544  return ACTION_STATELESS;
545  case editor::AREA:
546  return index == get_current_map_context().get_active_area()
548  case editor::SIDE:
549  return static_cast<std::size_t>(index) == gui_->playing_team()
551  case editor::TIME:
554  case editor::LOCAL_TIME:
556  get_current_map_context().get_active_area())
558  case editor::MUSIC:
560  ? ACTION_ON : ACTION_OFF;
561  case editor::SCHEDULE:
562  {
563  tods_map::const_iterator it = tods_.begin();
564  std::advance(it, index);
565  const std::vector<time_of_day>& times1 = it->second.second;
566  const std::vector<time_of_day>& times2 = get_current_map_context().get_time_manager()->times();
567  return (times1 == times2) ? ACTION_SELECTED : ACTION_DESELECTED;
568  }
570  {
571  tods_map::const_iterator it = tods_.begin();
572  std::advance(it, index);
573  const std::vector<time_of_day>& times1 = it->second.second;
574  int active_area = get_current_map_context().get_active_area();
575  const std::vector<time_of_day>& times2 = get_current_map_context().get_time_manager()->times(active_area);
576  return (times1 == times2) ? ACTION_SELECTED : ACTION_DESELECTED;
577  }
578  case editor::UNIT_FACING:
579  {
581  assert(un != get_current_map_context().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 
591 bool editor_controller::do_execute_command(const hotkey::hotkey_command& cmd, int index, bool press, bool release)
592 {
593  hotkey::HOTKEY_COMMAND command = cmd.id;
594  SCOPE_ED;
595  using namespace hotkey;
596 
597  // nothing here handles release; fall through to base implementation
598  if (!press) {
599  return hotkey::command_executor::do_execute_command(cmd, index, press, release);
600  }
601 
602  switch (command) {
603  case HOTKEY_NULL:
604  switch (active_menu_) {
605  case MAP:
606  if (index >= 0) {
607  unsigned i = static_cast<unsigned>(index);
608  if (i < context_manager_->size()) {
609  context_manager_->switch_context(index);
610  toolkit_->hotkey_set_mouse_action(HOTKEY_EDITOR_TOOL_PAINT);
611  return true;
612  }
613  }
614  return false;
615  case LOAD_MRU:
616  if (index >= 0) {
617  context_manager_->load_mru_item(static_cast<unsigned>(index));
618  }
619  return true;
620  case PALETTE:
621  toolkit_->get_palette_manager()->set_group(index);
622  return true;
623  case SIDE:
624  gui_->set_team(index, true);
625  gui_->set_playing_team(index);
626  toolkit_->get_palette_manager()->draw_contents();
627  return true;
628  case AREA:
629  {
631  const std::set<map_location>& area =
633  std::vector<map_location> locs(area.begin(), area.end());
635  gui_->scroll_to_tiles(locs.begin(), locs.end());
636  return true;
637  }
638  case TIME:
639  {
641  gui_->update_tod();
642  return true;
643  }
644  case LOCAL_TIME:
645  {
647  return true;
648  }
649  case MUSIC:
650  {
651  //TODO mark the map as changed
654  std::vector<config> items;
655  items.emplace_back("id", "editor-playlist");
656  std::shared_ptr<gui::button> b = gui_->find_menu_button("menu-playlist");
657  show_menu(items, b->location().x +1, b->location().y + b->height() +1, false, *gui_);
658  return true;
659  }
660  case SCHEDULE:
661  {
662  tods_map::iterator iter = tods_.begin();
663  std::advance(iter, index);
664  get_current_map_context().replace_schedule(iter->second.second);
665  // TODO: test again after the assign-schedule menu is fixed. Should work, though.
666  gui_->update_tod();
667  return true;
668  }
669  case LOCAL_SCHEDULE:
670  {
671  tods_map::iterator iter = tods_.begin();
672  std::advance(iter, index);
673  get_current_map_context().replace_local_schedule(iter->second.second);
674  return true;
675  }
676  case UNIT_FACING:
677  {
679  assert(un != get_current_map_context().units().end());
680  un->set_facing(map_location::DIRECTION(index));
681  un->anim_comp().set_standing();
682  return true;
683  }
684  }
685  return true;
686 
687  //Zoom
688  case HOTKEY_ZOOM_IN:
689  gui_->set_zoom(true);
691  toolkit_->set_mouseover_overlay(*gui_);
692  return true;
693  case HOTKEY_ZOOM_OUT:
694  gui_->set_zoom(false);
696  toolkit_->set_mouseover_overlay(*gui_);
697  return true;
698  case HOTKEY_ZOOM_DEFAULT:
699  gui_->toggle_default_zoom();
701  toolkit_->set_mouseover_overlay(*gui_);
702  return true;
703 
704  //Palette
706  {
707  //TODO this code waits for the gui2 dialog to get ready
708 // std::vector< std::pair< std::string, std::string >> blah_items;
709 // toolkit_->get_palette_manager()->active_palette().expand_palette_groups_menu(blah_items);
710 // int selected = 1; //toolkit_->get_palette_manager()->active_palette().get_selected;
711 // gui2::teditor_select_palette_group::execute(selected, blah_items, gui_->video());
712  }
713  return true;
715  toolkit_->get_palette_manager()->scroll_up();
716  return true;
718  toolkit_->get_palette_manager()->scroll_down();
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(!get_current_map_context().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  get_current_map_context().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
931  if(get_current_map_context().teams().size() >= 9) {
932  size_t new_side_num = get_current_map_context().teams().size() + 1;
933  toolkit_->get_palette_manager()->location_palette_->add_item(std::to_string(new_side_num));
934  }
936  gui_->init_flags();
937  return true;
939  gui_->set_team(0, true);
940  gui_->set_playing_team(0);
942  return true;
944  context_manager_->edit_side_dialog(gui_->viewing_team());
945  return true;
946 
947  // Transitions
949  context_manager_->set_update_transitions_mode(2);
950  return true;
952  context_manager_->set_update_transitions_mode(1);
953  return true;
955  context_manager_->set_update_transitions_mode(0);
956  return true;
958  if(context_manager_->toggle_update_transitions()) {
959  return true;
960  }
961  FALLTHROUGH;
963  context_manager_->refresh_all();
964  return true;
965  // Refresh
967  context_manager_->reload_map();
968  return true;
971  return true;
972 
974  gui().set_draw_coordinates(!gui().get_draw_coordinates());
975  preferences::editor::set_draw_hex_coordinates(gui().get_draw_coordinates());
976  gui().invalidate_all();
977  return true;
979  gui().set_draw_terrain_codes(!gui().get_draw_terrain_codes());
980  preferences::editor::set_draw_terrain_codes(gui().get_draw_terrain_codes());
981  gui().invalidate_all();
982  return true;
984  gui().set_draw_num_of_bitmaps(!gui().get_draw_num_of_bitmaps());
985  preferences::editor::set_draw_num_of_bitmaps(gui().get_draw_num_of_bitmaps());
986  gui().invalidate_all();
987  return true;
989  location_palette* lp = dynamic_cast<location_palette*>(&toolkit_->get_palette_manager()->active_palette());
990  if (lp) {
992  // No idea if this is the right thing to call, but it ensures starting
993  // position labels get removed on delete.
994  context_manager_->refresh_after_action();
995  }
996  return true;
997  }
998  default:
999  return hotkey::command_executor::do_execute_command(cmd, index, press, release);
1000  }
1001 }
1002 
1004 {
1005  help::show_help("..editor");
1006 }
1007 
1008 void editor_controller::show_menu(const std::vector<config>& items_arg, int xloc, int yloc, bool context_menu, display& disp)
1009 {
1010  if(context_menu) {
1011  if(!get_current_map_context().map().on_board_with_border(gui().hex_clicked_on(xloc, yloc))) {
1012  return;
1013  }
1014  }
1015 
1016  std::vector<config> items;
1017  for(const auto& c : items_arg) {
1018  const std::string& id = c["id"];
1020 
1021  if((can_execute_command(command) && (!context_menu || in_context_menu(command.id)))
1022  || command.id == hotkey::HOTKEY_NULL)
1023  {
1024  items.emplace_back("id", id);
1025  }
1026  }
1027 
1028  // No point in showing an empty menu.
1029  if(items.empty()) {
1030  return;
1031  }
1032 
1033  // Based on the ID of the first entry, we fill the menu contextually.
1034  const std::string& first_id = items.front()["id"];
1035 
1036  if(first_id == "EDITOR-LOAD-MRU-PLACEHOLDER") {
1038  context_manager_->expand_load_mru_menu(items, 0);
1039  }
1040 
1041  if(first_id == "editor-switch-map") {
1043  context_manager_->expand_open_maps_menu(items, 0);
1044  }
1045 
1046  if(first_id == "editor-palette-groups") {
1048  toolkit_->get_palette_manager()->active_palette().expand_palette_groups_menu(items, 0);
1049  }
1050 
1051  if(first_id == "editor-switch-side") {
1053  context_manager_->expand_sides_menu(items, 0);
1054  }
1055 
1056  if(first_id == "editor-switch-area") {
1058  context_manager_->expand_areas_menu(items, 0);
1059  }
1060 
1061  if(!items.empty() && items.front()["id"] == "editor-switch-time") {
1063  context_manager_->expand_time_menu(items, 0);
1064  }
1065 
1066  if(first_id == "editor-assign-local-time") {
1068  context_manager_->expand_local_time_menu(items, 0);
1069  }
1070 
1071  if(first_id == "menu-unit-facings") {
1073  auto pos = items.erase(items.begin());
1074  int dir = 0;
1075  std::generate_n(std::inserter<std::vector<config>>(items, pos), static_cast<int>(map_location::NDIRECTIONS), [&dir]() -> config {
1077  });
1078  }
1079 
1080  if(first_id == "editor-playlist") {
1082  auto pos = items.erase(items.begin());
1083  std::transform(music_tracks_.begin(), music_tracks_.end(), std::inserter<std::vector<config>>(items, pos), [](const sound::music_track& track) -> config {
1084  return config {"label", track.title().empty() ? track.id() : track.title()};
1085  });
1086  }
1087 
1088  if(first_id == "editor-assign-schedule") {
1090  auto pos = items.erase(items.begin());
1091  std::transform(tods_.begin(), tods_.end(), std::inserter<std::vector<config>>(items, pos), [](const tods_map::value_type& tod) -> config {
1092  return config {"label", tod.second.first};
1093  });
1094  }
1095 
1096  if(first_id == "editor-assign-local-schedule") {
1098  auto pos = items.erase(items.begin());
1099  std::transform(tods_.begin(), tods_.end(), std::inserter<std::vector<config>>(items, pos), [](const tods_map::value_type& tod) -> config {
1100  return config {"label", tod.second.first};
1101  });
1102  }
1103 
1104  command_executor::show_menu(items, xloc, yloc, context_menu, disp);
1105 }
1106 
1108 {
1109  gui_->video().clear_all_help_strings();
1111 
1112  gui_->redraw_everything();
1113 }
1114 
1116 {
1118  gui_->invalidate_all();
1119 }
1120 
1122 {
1123  map_location loc = gui_->mouseover_hex();
1124  const unit_map & units = get_current_map_context().units();
1125  const unit_map::const_unit_iterator un = units.find(loc);
1126  if(un != units.end()) {
1127  help::show_unit_help(un->type_id(), un->type().show_variations_in_help(), false);
1128  } else {
1129  help::show_help("..units");
1130  }
1131 }
1132 
1133 
1135 {
1136  if (!get_current_map_context().map().selection().empty()) {
1137  context_manager_->get_clipboard() = map_fragment(get_current_map_context().map(), get_current_map_context().map().selection());
1138  context_manager_->get_clipboard().center_by_mass();
1139  }
1140 }
1141 
1143 {
1144  map_location loc = gui_->mouseover_hex();
1145  unit_map& units = get_current_map_context().units();
1146  const unit_map::unit_iterator& un = units.find(loc);
1147 
1148  const std::string title(N_("Change Unit ID"));
1149  const std::string label(N_("ID:"));
1150 
1151  if(un != units.end()) {
1152  std::string id = un->id();
1153  if (gui2::dialogs::edit_text::execute(title, label, id)) {
1154  un->set_id(id);
1155  }
1156  }
1157 }
1158 
1160 {
1161  map_location loc = gui_->mouseover_hex();
1162  unit_map& units = get_current_map_context().units();
1163  const unit_map::unit_iterator& un = units.find(loc);
1164 
1165  const std::string title(N_("Rename Unit"));
1166  const std::string label(N_("Name:"));
1167 
1168  if(un != units.end()) {
1169  std::string name = un->name();
1170  if(gui2::dialogs::edit_text::execute(title, label, name)) {
1171  //TODO we may not want a translated name here.
1172  un->set_name(name);
1173  }
1174  }
1175 }
1176 
1178 {
1180 }
1181 
1183 {
1184  copy_selection();
1186 }
1187 
1189 {
1190  const std::set<map_location>& area = get_current_map_context().map().selection();
1192 }
1193 
1195 {
1196  const std::set<map_location>& area = get_current_map_context().map().selection();
1198 }
1199 
1201 {
1202  std::stringstream ssx, ssy;
1203  std::set<map_location>::const_iterator i = get_current_map_context().map().selection().begin();
1204  if (i != get_current_map_context().map().selection().end()) {
1205  ssx << "x = " << i->wml_x();
1206  ssy << "y = " << i->wml_y();
1207  ++i;
1208  while (i != get_current_map_context().map().selection().end()) {
1209  ssx << ", " << i->wml_x();
1210  ssy << ", " << i->wml_y();
1211  ++i;
1212  }
1213  ssx << "\n" << ssy.str() << "\n";
1214  desktop::clipboard::copy_to_clipboard(ssx.str(), false);
1215  }
1216 }
1217 
1219 {
1220  if (action) {
1221  const editor_action_ptr action_auto(action);
1223  }
1224 }
1225 
1226 void editor_controller::perform_refresh_delete(editor_action* action, bool drag_part /* =false */)
1227 {
1228  if (action) {
1229  const editor_action_ptr action_auto(action);
1230  context_manager_->perform_refresh(*action, drag_part);
1231  }
1232 }
1233 
1235 {
1237  context_manager_->refresh_all();
1238 }
1239 
1241 {
1242  set_button_state();
1243  toolkit_->adjust_size();
1244  toolkit_->get_palette_manager()->draw_contents();
1246 }
1247 
1249 {
1251  context_manager_->refresh_after_action();
1252 }
1253 
1255 {
1257  context_manager_->refresh_after_action();
1258 }
1259 
1260 void editor_controller::mouse_motion(int x, int y, const bool /*browse*/,
1261  bool update, map_location /*new_loc*/)
1262 {
1263  if (mouse_handler_base::mouse_motion_default(x, y, update)) return;
1264  map_location hex_clicked = gui().hex_clicked_on(x, y);
1265  if (get_current_map_context().map().on_board_with_border(drag_from_hex_) && is_dragging()) {
1266  editor_action* a = nullptr;
1267  bool partial = false;
1269  if (dragging_left_ && (SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON(1)) != 0) {
1270  if (!get_current_map_context().map().on_board_with_border(hex_clicked)) return;
1271  a = get_mouse_action().drag_left(*gui_, x, y, partial, last_undo);
1272  } else if (dragging_right_ && (SDL_GetMouseState(nullptr, nullptr) & SDL_BUTTON(3)) != 0) {
1273  if (!get_current_map_context().map().on_board_with_border(hex_clicked)) return;
1274  a = get_mouse_action().drag_right(*gui_, x, y, partial, last_undo);
1275  }
1276  //Partial means that the mouse action has modified the
1277  //last undo action and the controller shouldn't add
1278  //anything to the undo stack (hence a different perform_ call)
1279  if (a != nullptr) {
1280  const editor_action_ptr aa(a);
1281  if (partial) {
1283  } else {
1285  }
1286  context_manager_->refresh_after_action(true);
1287  }
1288  } else {
1289  get_mouse_action().move(*gui_, hex_clicked);
1290  }
1291  gui().highlight_hex(hex_clicked);
1292 }
1293 
1294 void editor_controller::touch_motion(int /* x */, int /* y */, const bool /* browse */, bool /* update */, map_location /* new_loc */)
1295 {
1296  // Not implemented at all. Sorry, it's a very low priority for iOS port.
1297 }
1298 
1300 {
1301  return get_current_map_context().map().on_board_with_border(gui().hex_clicked_on(x,y));
1302 }
1303 
1304 bool editor_controller::right_click_show_menu(int /*x*/, int /*y*/, const bool /*browse*/)
1305 {
1307 }
1308 
1309 bool editor_controller::left_click(int x, int y, const bool browse)
1310 {
1311  toolkit_->clear_mouseover_overlay();
1312  if (mouse_handler_base::left_click(x, y, browse))
1313  return true;
1314 
1315  LOG_ED << "Left click, after generic handling\n";
1316  map_location hex_clicked = gui().hex_clicked_on(x, y);
1317  if (!get_current_map_context().map().on_board_with_border(hex_clicked))
1318  return true;
1319 
1320  LOG_ED << "Left click action " << hex_clicked << "\n";
1322  perform_refresh_delete(a, true);
1323  if (a) set_button_state();
1324 
1325  return false;
1326 }
1327 
1328 void editor_controller::left_drag_end(int x, int y, const bool /*browse*/)
1329 {
1331  perform_delete(a);
1332 }
1333 
1334 void editor_controller::left_mouse_up(int x, int y, const bool /*browse*/)
1335 {
1337  perform_delete(a);
1338  if (a) set_button_state();
1339  toolkit_->set_mouseover_overlay();
1340  context_manager_->refresh_after_action();
1341 }
1342 
1343 bool editor_controller::right_click(int x, int y, const bool browse)
1344 {
1345  toolkit_->clear_mouseover_overlay();
1346  if (mouse_handler_base::right_click(x, y, browse)) return true;
1347  LOG_ED << "Right click, after generic handling\n";
1348  map_location hex_clicked = gui().hex_clicked_on(x, y);
1349  if (!get_current_map_context().map().on_board_with_border(hex_clicked)) return true;
1350  LOG_ED << "Right click action " << hex_clicked << "\n";
1352  perform_refresh_delete(a, true);
1353  if (a) set_button_state();
1354  return false;
1355 }
1356 
1357 void editor_controller::right_drag_end(int x, int y, const bool /*browse*/)
1358 {
1360  perform_delete(a);
1361 }
1362 
1363 void editor_controller::right_mouse_up(int x, int y, const bool browse)
1364 {
1365  // Call base method to handle context menus.
1366  mouse_handler_base::right_mouse_up(x, y, browse);
1367 
1369  perform_delete(a);
1370  if (a) set_button_state();
1371  toolkit_->set_mouseover_overlay();
1372  context_manager_->refresh_after_action();
1373 }
1374 
1376 {
1377  const map_location& loc = gui().mouseover_hex();
1378  if (get_current_map_context().map().on_board(loc) == false)
1379  return;
1380 
1383 }
1384 
1385 void editor_controller::process_keyup_event(const SDL_Event& event)
1386 {
1387  editor_action* a = get_mouse_action().key_event(gui(), event);
1389  toolkit_->set_mouseover_overlay();
1390 }
1391 
1393  return this;
1394 }
1395 
1397 {
1399 }
1400 
1402 {
1404 }
1405 
1407 {
1409 }
1410 
1412 {
1414 }
1415 
1417 {
1418  return toolkit_->get_palette_manager()->active_palette().action_pressed();
1419 }
1420 
1421 } //end namespace editor
virtual bool in_context_menu(hotkey::HOTKEY_COMMAND command) const
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...
const map_location & mouseover_hex() const
Definition: display.hpp:285
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:70
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 set_preference_display_settings()
Definition: display.cpp:44
::tod_manager * tod_manager
Definition: resources.cpp:29
void copy_selection()
Copy the selection on the current map to the clipboard.
static std::string write_translated_direction(DIRECTION dir)
Definition: location.cpp:161
void set_draw_num_of_bitmaps(bool value)
Setter for the terrain code debug overlay on tiles.
Definition: display.hpp:365
void set_scroll_down(bool on)
unit_iterator end()
Definition: map.hpp:429
bool minimap_draw_units()
Definition: general.cpp:796
void show_help(const std::string &show_topic, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
Definition: help.cpp:114
A map fragment – a collection of locations and information abut them.
void add_to_playlist(const sound::music_track &track)
const std::string & id() const
Select the entire map.
std::unique_ptr< font::floating_label_context > floating_label_manager_
HOTKEY_COMMAND id
the names are strange: the "hotkey::HOTKEY_COMMAND" is named id, and the string to identify the objec...
const t_translation::terrain_code & get_selected_bg_terrain()
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:360
void set(CURSOR_TYPE type)
Use the default parameter to reset cursors.
Definition: cursor.cpp:175
void save_map() override
Save the map, open dialog if not named yet.
void init_tods(const game_config_view &game_config)
init the available time-of-day settings
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:34
void show_terrain_description(const terrain_type &t)
Definition: help.cpp:62
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.
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:593
bool quit_confirm()
Show a quit confirmation dialog and returns true if the user pressed &#39;yes&#39;.
bool draw_num_of_bitmaps()
Definition: editor.cpp:52
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&#39;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
config_array_view child_range(config_key_type key) const
bool minimap_movement_coding()
Definition: general.cpp:776
const std::string & get_filename() const
editor_display & gui() override
Reference to the used display objects.
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:362
void new_area(const std::set< map_location > &area)
void show_unit_list(display &gui)
Definition: unit_list.cpp:199
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 show_transient_message(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.
int get_current_time(const map_location &loc=map_location::null_location()) const
void redraw_everything()
Invalidates entire screen, including all tiles and sidebar.
Definition: display.cpp:2421
map_labels & get_labels()
#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.
save_result save_image(const locator &i_locator, const std::string &filename)
Definition: picture.cpp:1101
const mouse_action & get_mouse_action() const
Get the current mouse action.
const terrain_type & get_terrain_info(const t_translation::terrain_code &terrain) const
Definition: map.cpp:97
void add_area()
Add a new area to the current context, filled with the selection if any.
virtual 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.
virtual editor_action * drag_left(editor_display &disp, int x, int y, bool &partial, editor_action *last_undo)
Drag operation.
#define SCOPE_ED
const std::vector< std::string > items
void play_music_once(const std::string &file)
Definition: sound.cpp:602
The editor_controller class contains the mouse and keyboard event handling routines for the editor...
bool draw_terrain_codes()
Definition: editor.cpp:36
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.
Unit and team statistics.
void remove_area(int index)
void flush_cache()
Definition: picture.cpp:225
bool modified() const
#define b
#define WRN_ED
bool minimap_draw_villages()
Definition: general.cpp:806
void show() const
Shows the error in a dialog.
const std::unique_ptr< editor_display > gui_
The display object used and owned by the editor.
void show_menu(const std::vector< config > &items_arg, int xloc, int yloc, bool context_menu, display &disp) override
controller_base override
bool do_execute_command(const hotkey::hotkey_command &command, int index=-1, bool press=true, bool release=false) override
command_executor override
map_context & get_current_map_context() const
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:100
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.
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.
const std::set< map_location > & selection() const
Return the selection set.
Definition: editor_map.hpp:149
surface screenshot(bool map_screenshot=false)
Capture a (map-)screenshot into a surface.
Definition: display.cpp:784
virtual bool has_context_menu() const
bool on_board_with_border(const map_location &loc) const
Definition: map.cpp:382
void remove_side()
removes the last side from the scenario
Definition: map_context.hpp:96
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
bool valid() const
Definition: location.hpp:93
void set_draw_coordinates(bool value)
Setter for the x,y debug overlay on tiles.
Definition: display.hpp:355
void undo() override
Undos an action in the current map context.
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.
int show_menu(lua_State *L)
Displays a popup menu at the current mouse position Best used from a [set_menu_item], to show a submenu.
Definition: lua_gui2.cpp:181
void init_music(const game_config_view &game_config)
init background music for the editor
editor_action * last_undo_action()
bool is_pure_map() const
bool draw_hex_coordinates()
Definition: editor.cpp:44
virtual editor_action * up_right(editor_display &disp, int x, int y)
void create_buttons()
Definition: display.cpp:873
void touch_motion(int x, int y, const bool browse, bool update=false, map_location new_loc=map_location::null_location()) override
void refresh_image_cache()
Reload images.
Manage the empty-palette in the editor.
Definition: action.cpp:29
void perform_action(const editor_action &action)
Performs an action (thus modifying the map).
const char * what() const noexcept
Definition: exceptions.hpp:37
void invalidate_all()
Function to invalidate all tiles.
Definition: display.cpp:3018
Paint the same terrain on a number of locations on the map.
Definition: action.hpp:284
bool dragging_left_
LMB drag init flag.
virtual bool supports_brushes() const
Whether we need the brush bar, is used to grey it out.
bool can_redo() const
static bool quit()
Shows the quit confirmation if needed.
std::vector< std::string > get_area_ids() const
Encapsulates the map of the game.
Definition: location.hpp:42
Helper class, don&#39;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...
unit_iterator find(std::size_t id)
Definition: map.cpp:311
void recalculate_labels()
Definition: label.cpp:244
void set_starting_position_labels(display &disp)
static void quit_to_desktop()
void init_gui()
init the display object and general set-up
void scroll_right(bool on) override
std::size_t i
Definition: function.cpp:933
bool everything_selected() const
Definition: editor_map.cpp:209
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:1619
u64 size
Definition: statement.cpp:80
Game configuration data as global variables.
Definition: build_info.cpp:55
void show_unit_help(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:124
const tod_manager * get_time_manager() const
const std::vector< time_of_day > & times(const map_location &loc=map_location::null_location()) const
structure which will hide all current floating labels, and cause floating labels instantiated after i...
const std::string & selected_item() const
Return the currently selected item.
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
void set_scroll_right(bool on)
bool empty() const
Definition: map.hpp:446
CURSOR_TYPE get()
Definition: cursor.cpp:215
void cut_selection()
Cut the selection from the current map to the clipboard.
virtual bool do_execute_command(const hotkey_command &command, int index=-1, bool press=true, bool release=false)
DIRECTION
Valid directions which can be moved in our hexagonal world.
Definition: location.hpp:44
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:108
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
Definition: unicode.cpp:71
void toggle_grid() override
Grid toggle.
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
bool can_undo() const
bool grid()
Definition: general.cpp:506
bool left_click(int x, int y, const bool browse) override
Overridden in derived classes, called on a left click (mousedown).
const std::string & file_path() const
virtual const unit_map & units() const override
Const units accessor.
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
const game_config_view & game_config_
bool minimap_draw_terrain()
Definition: general.cpp:816
virtual const editor_map & map() const override
Const map accessor.
virtual editor_action * drag_end_left(editor_display &disp, int x, int y)
The end of dragging.
static void display(const game_config_view &game_cfg, const preferences::PREFERENCE_VIEW initial_view=preferences::VIEW_DEFAULT)
The display function – see modal_dialog for more information.
void set_draw_terrain_codes(bool value)
Definition: editor.cpp:40
int get_active_area() const
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
bool is_in_playlist(std::string track_id)
Remove a unit from the map.
Definition: action_unit.hpp:63
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
const std::set< map_location > & get_area_by_index(int index) const
void set_draw_num_of_bitmaps(bool value)
Definition: editor.cpp:56
void show_error_message(const std::string &msg, bool message_use_markup)
Shows an error message to the user.
Definition: message.cpp:205
#define e
int get_current_area_time(int index) const
void set_draw_hex_coordinates(bool value)
Definition: editor.cpp:48
const std::string & title() const
editor_controller()
The constructor.
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:68
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).
virtual const std::vector< team > & teams() const override
Const teams accessor.
static std::vector< std::string > saved_windows_
std::string::const_iterator iterator
Definition: tokenizer.hpp:24
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
bool minimap_terrain_coding()
Definition: general.cpp:786