Skip to content

Commit

Permalink
Merge pull request #77654 from Procyonae/BetterRevealMap2ElectricBoog…
Browse files Browse the repository at this point in the history
…aloo

Unrevert #77339
  • Loading branch information
Maleclypse authored Nov 9, 2024
2 parents 243622b + 94e14e8 commit 23ddd74
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 30 deletions.
7 changes: 7 additions & 0 deletions data/raw/keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
44 changes: 20 additions & 24 deletions src/debug_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ std::string enum_to_string<debug_menu::debug_menu_index>( 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";
Expand Down Expand Up @@ -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<tripoint_abs_omt> &p )
{
if( reveal_level == 0 ) {
uilist vis_sel;
vis_sel.text = _( "Reveal at which vision level?" );
for( int i = static_cast<int>( om_vision_level::unseen );
i < static_cast<int>( om_vision_level::last ); ++i ) {
vis_sel.addentry( i, true, std::nullopt, io::enum_to_string( static_cast<om_vision_level>( 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<int>( om_vision_level::full );
i >= static_cast<int>( om_vision_level::unseen ); --i ) {
vis_sel.addentry( i, true, std::nullopt, io::enum_to_string( static_cast<om_vision_level>( 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<tripoint_abs_omt> &p )
{
const om_vision_level reveal_level = static_cast<om_vision_level>( reveal_level_int );
overmap &om = !p ? g->get_cur_om() : overmap_buffer.get( project_to<coords::om>( *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<om_vision_level>( 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()
Expand Down Expand Up @@ -970,7 +972,6 @@ static int spawning_uilist()
static int map_uilist()
{
const std::vector<uilist_entry> 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" ) ) },
Expand Down Expand Up @@ -3823,7 +3824,7 @@ void do_debug_quick_setup()
for( const std::pair<const skill_id, SkillLevel> &pair : u.get_all_skills() ) {
u.set_skill_level( pair.first, 10 );
}
prompt_or_do_map_reveal( static_cast<int>( om_vision_level::full ) );
map_reveal( static_cast<int>( om_vision_level::full ) );
}

void debug()
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/debug_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
#include <string>
#include <string_view>

#include "coords_fwd.h"
#include "coordinates.h"

class Character;
class Creature;
struct mongroup;
struct tripoint;

template <typename E> struct enum_traits;

Expand All @@ -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,
Expand Down Expand Up @@ -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<tripoint_abs_omt> &p = std::nullopt );
void map_reveal( int reveal_level_int, const std::optional<tripoint_abs_omt> &p = std::nullopt );

/* Merges iterable elements into std::string with
* @param delimiter between them
Expand Down
9 changes: 6 additions & 3 deletions src/overmap_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 23ddd74

Please sign in to comment.