From 811c4068eb89824df8675949df35133d4d485c56 Mon Sep 17 00:00:00 2001 From: fendrin Date: Mon, 6 May 2013 21:19:08 +0200 Subject: [PATCH] Removed the map argument from the help_manager's constructor. --- src/editor/editor_controller.cpp | 47 ++++++++++++++++++++------------ src/editor/editor_controller.hpp | 5 +--- src/game.cpp | 4 +-- src/help.cpp | 11 ++++---- src/help.hpp | 2 +- src/play_controller.cpp | 2 +- 6 files changed, 40 insertions(+), 31 deletions(-) diff --git a/src/editor/editor_controller.cpp b/src/editor/editor_controller.cpp index eae6b0974db..f2026477a4b 100644 --- a/src/editor/editor_controller.cpp +++ b/src/editor/editor_controller.cpp @@ -41,6 +41,7 @@ #include "../preferences_display.hpp" #include "../rng.hpp" #include "../sound.hpp" +#include "../leader_scroll_dialog.hpp" #include "halo.hpp" @@ -60,9 +61,7 @@ editor_controller::editor_controller(const config &game_config, CVideo& video) , active_menu_(editor::MAP) , rng_(NULL) , rng_setter_(NULL) - , units_() , gui_(new editor_display(NULL, video, NULL, NULL, get_theme(game_config, "editor"), config())) - , teams_() , tods_() , context_manager_(new context_manager(*gui_.get(), game_config_)) , toolkit_(NULL) @@ -76,7 +75,7 @@ editor_controller::editor_controller(const config &game_config, CVideo& video) { init_gui(); toolkit_.reset(new editor_toolkit(*gui_.get(), key_, game_config_, *context_manager_.get())); - help_manager_.reset(new help::help_manager(&game_config, &(context_manager_->get_map_context().get_map()))); + help_manager_.reset(new help::help_manager(&game_config)); context_manager_->switch_context(0); init_tods(game_config); init_music(game_config); @@ -160,6 +159,10 @@ EXIT_STATUS editor_controller::main_loop() return quit_mode_; } +void editor_controller::status_table() { + gui::status_table(*gui_, 0); +} + void editor_controller::do_screenshot(const std::string& screenshot_filename /* = "map_screenshot.bmp" */) { try { @@ -256,6 +259,10 @@ bool editor_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int case HOTKEY_QUIT_GAME: return true; //general hotkeys we can always do + + case HOTKEY_STATUS_TABLE: + return true; + // unit tool related case HOTKEY_UNIT_DESCRIPTION: return toolkit_->is_mouse_action_set(HOTKEY_EDITOR_TOOL_UNIT); @@ -301,6 +308,7 @@ bool editor_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int return context_manager_->get_map_context().modified(); case HOTKEY_EDITOR_MAP_SAVE_ALL: case HOTKEY_EDITOR_SWITCH_MAP: + case HOTKEY_EDITOR_SWITCH_AREA: case HOTKEY_EDITOR_CLOSE_MAP: return true; case HOTKEY_EDITOR_MAP_REVERT: @@ -320,6 +328,7 @@ bool editor_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int //TODO // case HOTKEY_EDITOR_EXPORT_SELECTION_COORDS: + case HOTKEY_EDITOR_AREA_DEFINE: case HOTKEY_EDITOR_CUT: case HOTKEY_EDITOR_COPY: case HOTKEY_EDITOR_SELECTION_FILL: @@ -436,6 +445,8 @@ hotkey::ACTION_STATE editor_controller::get_action_state(hotkey::HOTKEY_COMMAND case editor::PALETTE: return ACTION_STATELESS; case editor::AREA: + return index == context_manager_->get_map_context().get_active_area() + ? ACTION_SELECTED : ACTION_DESELECTED; case editor::SIDE: return static_cast(index) == gui_->playing_team() ? ACTION_SELECTED : ACTION_DESELECTED; @@ -621,11 +632,9 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde case HOTKEY_EDITOR_CUT: cut_selection(); return true; - /* TODO - case HOTKEY_EDITOR_EXPORT_SELECTION_COORDS: + case HOTKEY_EDITOR_AREA_DEFINE: export_selection_coords(); return true; - */ case HOTKEY_EDITOR_SELECT_ALL: if (!context_manager_->get_map().everything_selected()) { context_manager_->perform_refresh(editor_action_select_all()); @@ -718,7 +727,6 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde void editor_controller::show_help() { help::show_help(*gui_); - //menu_handler_.show_help(); } void editor_controller::show_menu(const std::vector& items_arg, int xloc, int yloc, bool context_menu) @@ -729,15 +737,14 @@ void editor_controller::show_menu(const std::vector& items_arg, int } } - std::vector items = items_arg; - std::vector::iterator i = items.begin(); - while(i != items.end()) { + std::vector items; + std::vector::const_iterator i = items_arg.begin(); + while(i != items_arg.end()) { hotkey::HOTKEY_COMMAND command = hotkey::get_id(*i); - if(!can_execute_command(command) - || (context_menu && !in_context_menu(command))) { - i = items.erase(i); - continue; + if (!(!can_execute_command(command) + || (context_menu && !in_context_menu(command)))) { + items.push_back(*i); } ++i; } @@ -750,10 +757,14 @@ void editor_controller::show_menu(const std::vector& items_arg, int active_menu_ = editor::PALETTE; toolkit_->get_palette_manager()->active_palette().expand_palette_groups_menu(items); } - if (!items.empty() && items.front() == "editor-side-switch") { + if (!items.empty() && items.front() == "editor-switch-side") { active_menu_ = editor::SIDE; context_manager_->expand_sides_menu(items); } + if (!items.empty() && items.front() == "editor-switch-area") { + active_menu_ = editor::AREA; + context_manager_->expand_areas_menu(items); + } command_executor::show_menu(items, xloc, yloc, context_menu, gui()); } @@ -813,7 +824,6 @@ void editor_controller::cut_selection() context_manager_->perform_refresh(editor_action_paint_area(context_manager_->get_map().selection(), get_selected_bg_terrain())); } -/* TODO void editor_controller::export_selection_coords() { std::stringstream ssx, ssy; @@ -830,8 +840,11 @@ void editor_controller::export_selection_coords() ssx << "\n" << ssy.str() << "\n"; copy_to_clipboard(ssx.str(), false); } + + const std::set& area = context_manager_->get_map().selection(); + context_manager_->get_map_context().get_time_manager()-> + add_time_area("an area", area, config()); } -*/ void editor_controller::perform_delete(editor_action* action) { diff --git a/src/editor/editor_controller.hpp b/src/editor/editor_controller.hpp index 5c8a27b20c4..10949b80fe8 100644 --- a/src/editor/editor_controller.hpp +++ b/src/editor/editor_controller.hpp @@ -115,6 +115,7 @@ class editor_controller : public controller_base, void show_menu(const std::vector& items_arg, int xloc, int yloc, bool context_menu); void show_help(); + void status_table(); /** Show the preferences dialog */ void preferences(); @@ -218,13 +219,9 @@ class editor_controller : public controller_base, boost::scoped_ptr rng_setter_; - unit_map units_; - /** The display object used and owned by the editor. */ boost::scoped_ptr gui_; - std::vector teams_; - /** Pre-defined time of day lighting settings for the settings dialog */ std::vector tods_; diff --git a/src/game.cpp b/src/game.cpp index 6a324e3fb7a..b6783c410db 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -611,13 +611,13 @@ static int do_gameloop(int argc, char** argv) about::show_about(game->disp()); continue; } else if(res == gui2::ttitle_screen::SHOW_HELP) { - help::help_manager help_manager(&game->game_config(), NULL); + help::help_manager help_manager(&game->game_config()); help::show_help(game->disp()); continue; } else if(res == gui2::ttitle_screen::GET_ADDONS) { // NOTE: we need the help_manager to get access to the Add-ons // section in the game help! - help::help_manager help_manager(&game->game_config(), NULL); + help::help_manager help_manager(&game->game_config()); if(manage_addons(game->disp())) { game->reload_changed_game_config(); } diff --git a/src/help.cpp b/src/help.cpp index c558ad54963..24c0b402099 100644 --- a/src/help.cpp +++ b/src/help.cpp @@ -595,7 +595,6 @@ static std::string get_first_word(const std::string &s); namespace { const config *game_cfg = NULL; - gamemap *map = NULL; // The default toplevel. help::section toplevel; // All sections and topics not referenced from the default toplevel. @@ -769,10 +768,10 @@ static void push_tab_pair(std::vector > &v, namespace help { -help_manager::help_manager(const config *cfg, gamemap *_map) +help_manager::help_manager(const config *cfg) //, gamemap *_map) { game_cfg = cfg == NULL ? &dummy_cfg : cfg; - map = _map; +// map = _map; } void generate_contents() @@ -841,7 +840,7 @@ void generate_contents() help_manager::~help_manager() { game_cfg = NULL; - map = NULL; +// map = NULL; toplevel.clear(); hidden_sections.clear(); // These last numbers must be reset so that the content is regenreated. @@ -1598,7 +1597,7 @@ public: } ss << generate_table(resistance_table); - if (map != NULL) { + if (resources::game_map != NULL) { // Print the terrain modifier table of the unit. ss << "\n\n
text='" << escape(_("Terrain Modifiers")) << "'
\n\n"; @@ -1625,7 +1624,7 @@ public: const t_translation::t_terrain terrain = *terrain_it; if (terrain == t_translation::FOGGED || terrain == t_translation::VOID_TERRAIN || terrain == t_translation::OFF_MAP_USER) continue; - const terrain_type& info = map->get_terrain_info(terrain); + const terrain_type& info = resources::game_map->get_terrain_info(terrain); if (info.union_type().size() == 1 && info.union_type()[0] == info.number() && info.is_nonnull()) { std::vector row; diff --git a/src/help.hpp b/src/help.hpp index cc9ce0cd1b1..1fbfdf6ffd6 100644 --- a/src/help.hpp +++ b/src/help.hpp @@ -24,7 +24,7 @@ class gamemap; namespace help { struct help_manager { - help_manager(const config *game_config, gamemap *map); + help_manager(const config *game_config); ~help_manager(); }; diff --git a/src/play_controller.cpp b/src/play_controller.cpp index e4c03ee6446..1334fdf6907 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -91,7 +91,7 @@ play_controller::play_controller(const config& level, game_state& state_of_game, events_manager_(), halo_manager_(), labels_manager_(), - help_manager_(&game_config, &map_), + help_manager_(&game_config), mouse_handler_(NULL, teams_, units_, map_), menu_handler_(NULL, units_, teams_, level, map_, game_config, state_of_game), soundsources_manager_(),