From 94e14e829d178ae2ceb6db4ac0ae6685f75c55b7 Mon Sep 17 00:00:00 2001 From: Procyonae <45432782+Procyonae@users.noreply.github.com> Date: Thu, 7 Nov 2024 16:06:47 +0000 Subject: [PATCH] Unrevert#77339 --- data/raw/keybindings.json | 7 +++++++ src/debug_menu.cpp | 44 ++++++++++++++++++--------------------- src/debug_menu.h | 6 +++--- src/overmap_ui.cpp | 9 +++++--- 4 files changed, 36 insertions(+), 30 deletions(-) diff --git a/data/raw/keybindings.json b/data/raw/keybindings.json index f9aa75b12cb0d..5ef4601f89e2f 100644 --- a/data/raw/keybindings.json +++ b/data/raw/keybindings.json @@ -1247,6 +1247,13 @@ "name": "Teleport to cursor", "bindings": [ { "input_method": "keyboard_any", "key": "d" } ] }, + { + "type": "keybinding", + "id": "REVEAL_MAP", + "category": "OVERMAP", + "name": "Reveal map", + "bindings": [ { "input_method": "keyboard_any", "key": "r" } ] + }, { "type": "keybinding", "id": "MODIFY_HORDE", diff --git a/src/debug_menu.cpp b/src/debug_menu.cpp index 93848dbf2a7e0..895a9d656498e 100644 --- a/src/debug_menu.cpp +++ b/src/debug_menu.cpp @@ -182,7 +182,6 @@ std::string enum_to_string( debug_menu::debug_menu case debug_menu::debug_menu_index::WISH: return "WISH"; case debug_menu::debug_menu_index::SHORT_TELEPORT: return "SHORT_TELEPORT"; case debug_menu::debug_menu_index::LONG_TELEPORT: return "LONG_TELEPORT"; - case debug_menu::debug_menu_index::REVEAL_MAP: return "REVEAL_MAP"; case debug_menu::debug_menu_index::SPAWN_NPC: return "SPAWN_NPC"; case debug_menu::debug_menu_index::SPAWN_NAMED_NPC: return "SPAWN_NAMED_NPC"; case debug_menu::debug_menu_index::SPAWN_OM_NPC: return "SPAWN_OM_NPC"; @@ -460,30 +459,33 @@ bool is_debug_character() debug_names.count( first_word( world_generator->active_world->world_name ) ); } -static void prompt_or_do_map_reveal( int reveal_level = 0 ) +void prompt_map_reveal( const std::optional &p ) { - if( reveal_level == 0 ) { - uilist vis_sel; - vis_sel.text = _( "Reveal at which vision level?" ); - for( int i = static_cast( om_vision_level::unseen ); - i < static_cast( om_vision_level::last ); ++i ) { - vis_sel.addentry( i, true, std::nullopt, io::enum_to_string( static_cast( i ) ) ); - } - vis_sel.query(); - reveal_level = vis_sel.ret; - if( reveal_level == UILIST_CANCEL ) { - return; - } + uilist vis_sel; + vis_sel.text = _( "Reveal at which vision level?" ); + for( int i = static_cast( om_vision_level::full ); + i >= static_cast( om_vision_level::unseen ); --i ) { + vis_sel.addentry( i, true, std::nullopt, io::enum_to_string( static_cast( i ) ) ); + } + vis_sel.query(); + if( vis_sel.ret == UILIST_CANCEL ) { + return; } - overmap &cur_om = g->get_cur_om(); + map_reveal( vis_sel.ret, p ); +} + +void map_reveal( int reveal_level_int, const std::optional &p ) +{ + const om_vision_level reveal_level = static_cast( reveal_level_int ); + overmap &om = !p ? g->get_cur_om() : overmap_buffer.get( project_to( *p ).xy() ); for( int i = 0; i < OMAPX; i++ ) { for( int j = 0; j < OMAPY; j++ ) { for( int k = -OVERMAP_DEPTH; k <= OVERMAP_HEIGHT; k++ ) { - cur_om.set_seen( { i, j, k }, static_cast( reveal_level ), true ); + om.set_seen( { i, j, k }, reveal_level, true ); } } } - add_msg( m_good, _( "Current overmap revealed." ) ); + add_msg( m_good, !p ? _( "Current overmap revealed." ) : _( "Overmap revealed." ) ); } static int player_uilist() @@ -970,7 +972,6 @@ static int spawning_uilist() static int map_uilist() { const std::vector uilist_initializer = { - { uilist_entry( debug_menu_index::REVEAL_MAP, true, 'r', _( "Reveal map" ) ) }, { uilist_entry( debug_menu_index::KILL_AREA, true, 'a', _( "Kill in Area" ) ) }, { uilist_entry( debug_menu_index::KILL_NPCS, true, 'k', _( "Kill NPCs" ) ) }, { uilist_entry( debug_menu_index::MAP_EDITOR, true, 'M', _( "Map editor" ) ) }, @@ -3823,7 +3824,7 @@ void do_debug_quick_setup() for( const std::pair &pair : u.get_all_skills() ) { u.set_skill_level( pair.first, 10 ); } - prompt_or_do_map_reveal( static_cast( om_vision_level::full ) ); + map_reveal( static_cast( om_vision_level::full ) ); } void debug() @@ -3882,11 +3883,6 @@ void debug() debug_menu::teleport_long(); break; - case debug_menu_index::REVEAL_MAP: { - prompt_or_do_map_reveal(); - } - break; - case debug_menu_index::SPAWN_NPC: spawn_npc(); break; diff --git a/src/debug_menu.h b/src/debug_menu.h index 31ed053c2cbda..3bd1ec8649de2 100644 --- a/src/debug_menu.h +++ b/src/debug_menu.h @@ -8,12 +8,11 @@ #include #include -#include "coords_fwd.h" +#include "coordinates.h" class Character; class Creature; struct mongroup; -struct tripoint; template struct enum_traits; @@ -24,7 +23,6 @@ enum class debug_menu_index : int { WISH, SHORT_TELEPORT, LONG_TELEPORT, - REVEAL_MAP, SPAWN_NPC, SPAWN_NAMED_NPC, SPAWN_OM_NPC, @@ -164,6 +162,8 @@ Container string_to_iterable( const std::string_view str, const std::string_view } bool is_debug_character(); +void prompt_map_reveal( const std::optional &p = std::nullopt ); +void map_reveal( int reveal_level_int, const std::optional &p = std::nullopt ); /* Merges iterable elements into std::string with * @param delimiter between them diff --git a/src/overmap_ui.cpp b/src/overmap_ui.cpp index 5516508736b18..3e1d547916108 100644 --- a/src/overmap_ui.cpp +++ b/src/overmap_ui.cpp @@ -1155,10 +1155,11 @@ static void draw_om_sidebar( ui_adaptor &ui, }; if( data.debug_editor ) { - print_hint( "PLACE_TERRAIN", c_light_blue ); + print_hint( "REVEAL_MAP", c_light_blue ); + print_hint( "LONG_TELEPORT", c_light_blue ); print_hint( "PLACE_SPECIAL", c_light_blue ); + print_hint( "PLACE_TERRAIN", c_light_blue ); print_hint( "SET_SPECIAL_ARGS", c_light_blue ); - print_hint( "LONG_TELEPORT", c_light_blue ); print_hint( "MODIFY_HORDE", c_light_blue ); ++y; } @@ -1940,6 +1941,7 @@ static tripoint_abs_omt display() ictxt.register_action( "SET_SPECIAL_ARGS" ); ictxt.register_action( "LONG_TELEPORT" ); ictxt.register_action( "MODIFY_HORDE" ); + ictxt.register_action( "REVEAL_MAP" ); } ictxt.register_action( "QUIT" ); std::string action; @@ -2154,7 +2156,8 @@ static tripoint_abs_omt display() action = "QUIT"; } else if( action == "MODIFY_HORDE" ) { modify_horde_func( curs ); - action = "QUIT"; + } else if( action == "REVEAL_MAP" ) { + debug_menu::prompt_map_reveal( curs ); } else if( action == "MISSIONS" ) { g->list_missions(); }