diff --git a/data/themes/editor.cfg b/data/themes/editor.cfg index 59e912d4efa..59dec9f6b21 100644 --- a/data/themes/editor.cfg +++ b/data/themes/editor.cfg @@ -79,7 +79,7 @@ id=menu-editor-map title= _ "Map" image=button_menu/menu_button_copper_H20 - items=editor-map-resize,editor-map-generate,editor-map-apply-mask,editor-map-create-mask-to,menu-editor-transitions,editor-refresh,editor-refresh-image-cache,togglegrid,editor-draw-coordinates,editor-draw-terrain-codes,editor-draw-num-of-bitmaps + items=editor-map-resize,editor-map-generate,editor-map-apply-mask,editor-map-create-mask-to,editor-help-text-shown,menu-editor-transitions,editor-refresh,editor-refresh-image-cache,togglegrid,editor-draw-coordinates,editor-draw-terrain-codes,editor-draw-num-of-bitmaps rect="+0,=,+100,+20" xanchor=fixed yanchor=fixed @@ -445,6 +445,22 @@ xanchor=fixed yanchor=fixed [/panel] + [action] + id=toggle_help_text_editor + items=editor-help-text-shown + type=checkbox + image=button_square/button_square_30 + tooltip_name_prepend=yes + rect="=-31,=,+30,+30" + xanchor=right + yanchor=fixed + [/action] + [panel] + id=top_separator4 + rect="=-11,=,+10,+27" + xanchor=fixed + yanchor=fixed + [/panel] [menu] id=switch_time items=editor-switch-time, menu-editor-schedule, editor-custom-tods diff --git a/images/icons/action/editor-help-text-shown_25-active.png b/images/icons/action/editor-help-text-shown_25-active.png new file mode 100644 index 00000000000..76ceee57456 Binary files /dev/null and b/images/icons/action/editor-help-text-shown_25-active.png differ diff --git a/images/icons/action/editor-help-text-shown_25-pressed.png b/images/icons/action/editor-help-text-shown_25-pressed.png new file mode 100644 index 00000000000..32aaa83153e Binary files /dev/null and b/images/icons/action/editor-help-text-shown_25-pressed.png differ diff --git a/images/icons/action/editor-help-text-shown_25.png b/images/icons/action/editor-help-text-shown_25.png new file mode 100644 index 00000000000..343a2f2bb30 Binary files /dev/null and b/images/icons/action/editor-help-text-shown_25.png differ diff --git a/images/icons/action/editor-help-text-shown_30-active.png b/images/icons/action/editor-help-text-shown_30-active.png new file mode 100644 index 00000000000..92a8419d4e9 Binary files /dev/null and b/images/icons/action/editor-help-text-shown_30-active.png differ diff --git a/images/icons/action/editor-help-text-shown_30-pressed.png b/images/icons/action/editor-help-text-shown_30-pressed.png new file mode 100644 index 00000000000..41580a25fc7 Binary files /dev/null and b/images/icons/action/editor-help-text-shown_30-pressed.png differ diff --git a/images/icons/action/editor-help-text-shown_30.png b/images/icons/action/editor-help-text-shown_30.png new file mode 100644 index 00000000000..fa8465a8cac Binary files /dev/null and b/images/icons/action/editor-help-text-shown_30.png differ diff --git a/src/editor/controller/editor_controller.cpp b/src/editor/controller/editor_controller.cpp index 87f69e3f74e..f252b245214 100644 --- a/src/editor/controller/editor_controller.cpp +++ b/src/editor/controller/editor_controller.cpp @@ -109,6 +109,7 @@ void editor_controller::init_gui() gui().set_debug_flag(display::DEBUG_COORDINATES, preferences::editor::draw_hex_coordinates()); gui().set_debug_flag(display::DEBUG_TERRAIN_CODES, preferences::editor::draw_terrain_codes()); gui().set_debug_flag(display::DEBUG_NUM_BITMAPS, preferences::editor::draw_num_of_bitmaps()); + gui().set_help_string_enabled(preferences::editor::help_text_shown()); // halo_manager_.reset(new halo::manager(*gui_)); // resources::halo = halo_manager_.get(); // ^ These lines no longer necessary, the gui owns its halo manager. @@ -499,6 +500,7 @@ bool editor_controller::can_execute_command(const hotkey::ui_command& cmd) const case HOTKEY_EDITOR_PARTIAL_UPDATE_TRANSITIONS: case HOTKEY_EDITOR_NO_UPDATE_TRANSITIONS: case HOTKEY_EDITOR_REFRESH_IMAGE_CACHE: + case HOTKEY_EDITOR_HELP_TEXT_SHOWN: case HOTKEY_MINIMAP_CODING_TERRAIN: case HOTKEY_MINIMAP_CODING_UNIT: case HOTKEY_MINIMAP_DRAW_UNITS: @@ -585,7 +587,8 @@ hotkey::ACTION_STATE editor_controller::get_action_state(const hotkey::ui_comman return gui_->debug_flag_set(display::DEBUG_TERRAIN_CODES) ? ACTION_ON : ACTION_OFF; case HOTKEY_EDITOR_DRAW_NUM_OF_BITMAPS: return gui_->debug_flag_set(display::DEBUG_NUM_BITMAPS) ? ACTION_ON : ACTION_OFF; - + case HOTKEY_EDITOR_HELP_TEXT_SHOWN: + return gui_->help_string_enabled() ? ACTION_ON : ACTION_OFF; case HOTKEY_MINIMAP_DRAW_VILLAGES: return (preferences::minimap_draw_villages()) ? ACTION_ON : ACTION_OFF; case HOTKEY_MINIMAP_CODING_UNIT: @@ -1094,6 +1097,10 @@ bool editor_controller::do_execute_command(const hotkey::ui_command& cmd, bool p preferences::editor::set_draw_num_of_bitmaps(gui().debug_flag_set(display::DEBUG_NUM_BITMAPS)); gui().invalidate_all(); return true; + case HOTKEY_EDITOR_HELP_TEXT_SHOWN: + gui().set_help_string_enabled(!gui().help_string_enabled()); + preferences::editor::set_help_text_shown(gui().help_string_enabled()); + return true; case HOTKEY_EDITOR_REMOVE_LOCATION: { location_palette* lp = dynamic_cast(&toolkit_->get_palette_manager()->active_palette()); if (lp) { diff --git a/src/editor/editor_display.cpp b/src/editor/editor_display.cpp index f1943466ef1..e10635bb0ef 100644 --- a/src/editor/editor_display.cpp +++ b/src/editor/editor_display.cpp @@ -159,6 +159,17 @@ display::overlay_map& editor_display::get_overlays() return controller_.get_current_map_context().get_overlays(); } +void editor_display::set_help_string_enabled(bool value) +{ + help_string_enabled_ = value; + + if (!value) { + clear_help_string(); + } else if (!help_string_.empty()) { + set_help_string(help_string_); + } +} + void editor_display::clear_help_string() { font::remove_floating_label(help_handle_); @@ -167,8 +178,16 @@ void editor_display::clear_help_string() void editor_display::set_help_string(const std::string& str) { + // Always update the internal string so we can toggle its visibility back + // at any time without having to ask the current editor_palette. + help_string_ = str; + clear_help_string(); + if (!help_string_enabled_ || help_string_.empty()) { + return; + } + const color_t color{0, 0, 0, 0xbb}; int size = font::SIZE_LARGE; diff --git a/src/editor/editor_display.hpp b/src/editor/editor_display.hpp index b306aa453c0..9b812ea1323 100644 --- a/src/editor/editor_display.hpp +++ b/src/editor/editor_display.hpp @@ -71,6 +71,15 @@ public: /** Removes the help string. */ void clear_help_string(); + /** Returns whether the help text is currently shown. */ + bool help_string_enabled() const + { + return help_string_enabled_; + } + + /** Sets whether the help text should be shown. */ + void set_help_string_enabled(bool value); + protected: void draw_hex(const map_location& loc) override; @@ -95,6 +104,12 @@ private: * northern hexes in the map area, false if it's over the southern hexes instead. */ bool help_string_at_top_ = false; + + /** Whether the help text is currently shown. */ + bool help_string_enabled_ = true; + + /** Current help string, cached for easy visibility toggling. */ + std::string help_string_; }; } //end namespace editor diff --git a/src/hotkey/hotkey_command.cpp b/src/hotkey/hotkey_command.cpp index b8a8076b10f..5aa44210d94 100644 --- a/src/hotkey/hotkey_command.cpp +++ b/src/hotkey/hotkey_command.cpp @@ -212,6 +212,8 @@ constexpr std::array master_hotkey_list {{ { HOTKEY_EDITOR_UNIT_TOGGLE_LOYAL, "editor-unit-toggle-loyal", N_("Loyal"), false, scope_editor, HKCAT_TOOLS, "" }, { HOTKEY_EDITOR_UNIT_FACING, "menu-unit-facing", "", true, scope_editor, HKCAT_PLACEHOLDER, "" }, + { HOTKEY_EDITOR_HELP_TEXT_SHOWN, "editor-help-text-shown", N_("Show Tool Information"), false, scope_editor, HKCAT_TOOLS, "" }, + { HOTKEY_MINIMAP_CODING_UNIT, "minimap-unit-coding", N_("Toggle Minimap Unit Coding"), false, scope_game | scope_editor, HKCAT_MAP, "" }, { HOTKEY_MINIMAP_CODING_TERRAIN, "minimap-terrain-coding", N_("Toggle Minimap Terrain Coding"), false, scope_game | scope_editor, HKCAT_MAP, "" }, diff --git a/src/hotkey/hotkey_command.hpp b/src/hotkey/hotkey_command.hpp index c9cfd1bdd1f..a996d18a829 100644 --- a/src/hotkey/hotkey_command.hpp +++ b/src/hotkey/hotkey_command.hpp @@ -133,6 +133,8 @@ enum HOTKEY_COMMAND { HOTKEY_EDITOR_LOCAL_TIME, HOTKEY_EDITOR_UNIT_FACING, + HOTKEY_EDITOR_HELP_TEXT_SHOWN, + // Unit HOTKEY_EDITOR_UNIT_TOGGLE_CANRECRUIT, HOTKEY_EDITOR_UNIT_TOGGLE_RENAMEABLE, HOTKEY_EDITOR_UNIT_CHANGE_ID, HOTKEY_EDITOR_UNIT_TOGGLE_LOYAL, diff --git a/src/preferences/editor.cpp b/src/preferences/editor.cpp index 29b85fabff3..88964e88333 100644 --- a/src/preferences/editor.cpp +++ b/src/preferences/editor.cpp @@ -58,6 +58,14 @@ namespace editor { preferences::set("editor_draw_num_of_bitmaps", value); } + bool help_text_shown() { + return preferences::get("editor_help_text_shown", true); + } + + void set_help_text_shown(bool value) { + preferences::set("editor_help_text_shown", value); + } + namespace { std::size_t editor_mru_limit() { diff --git a/src/preferences/editor.hpp b/src/preferences/editor.hpp index 02bddad5163..eade5d88218 100644 --- a/src/preferences/editor.hpp +++ b/src/preferences/editor.hpp @@ -45,6 +45,9 @@ namespace editor { bool draw_num_of_bitmaps(); void set_draw_num_of_bitmaps(bool value); + bool help_text_shown(); + void set_help_text_shown(bool value); + /** Retrieves the list of recently opened files. */ std::vector recent_files(); /** Adds an entry to the recent files list. */