Skip to content

Commit

Permalink
Add an option to show object IDs in game
Browse files Browse the repository at this point in the history
  • Loading branch information
olanti-p committed Mar 13, 2023
1 parent 5283437 commit 9c2f652
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/cached_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ bool log_from_top;
int message_ttl;
int message_cooldown;
bool display_mod_source;
bool display_object_ids;
bool trigdist;
bool fov_3d;
bool static_z_effect = false;
Expand Down
2 changes: 2 additions & 0 deletions src/cached_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ extern int message_cooldown;

/** Display mod source for items, furniture, terrain and monsters.*/
extern bool display_mod_source;
/** Display internal IDs for items, furniture, terrain and monsters.*/
extern bool display_object_ids;

/**
* Circular distances.
Expand Down
16 changes: 10 additions & 6 deletions src/descriptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@ void game::extended_description( const tripoint &p )
fid->src.end(), []( const std::pair<furn_str_id, mod_id> &source ) {
return string_format( "'%s'", source.second->name() );
}, enumeration_conjunction::arrow );
desc = string_format( _( "Origin: %s\n%s" ), mod_src, fid->extended_description() );
} else {
desc = fid.obj().extended_description();
desc = string_format( _( "Origin: %s\n" ), mod_src );
}
if( display_object_ids ) {
desc += colorize( string_format( "[%s]\n", fid.id() ), c_light_blue );
}
desc += fid.obj().extended_description();
}
break;
case description_target::terrain:
Expand All @@ -137,10 +139,12 @@ void game::extended_description( const tripoint &p )
tid->src.end(), []( const std::pair<ter_str_id, mod_id> &source ) {
return string_format( "'%s'", source.second->name() );
}, enumeration_conjunction::arrow );
desc = string_format( _( "Origin: %s\n%s" ), mod_src, tid->extended_description() );
} else {
desc = tid.obj().extended_description();
desc = string_format( _( "Origin: %s\n" ), mod_src );
}
if( display_object_ids ) {
desc += colorize( string_format( "[%s]\n", tid.id() ), c_light_blue );
}
desc += tid.obj().extended_description();
}
break;
}
Expand Down
14 changes: 14 additions & 0 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,10 @@ void item::basic_info( std::vector<iteminfo> &info, const iteminfo_query *parts,
}, enumeration_conjunction::arrow ) ) );
insert_separation_line( info );
}
if( display_object_ids && parts->test( iteminfo_parts::BASE_ID ) ) {
info.emplace_back( "BASE", colorize( string_format( "[%s]", type->get_id() ), c_light_blue ) );
insert_separation_line( info );
}

const std::string space = " ";
if( parts->test( iteminfo_parts::BASE_MATERIAL ) ) {
Expand Down Expand Up @@ -3580,6 +3584,11 @@ void item::contents_info( std::vector<iteminfo> &info, const iteminfo_query *par
return string_format( "'%s'", content_source.second->name() );
}, enumeration_conjunction::arrow ) ) );
}
if( display_object_ids ) {
info.emplace_back( "DESCRIPTION", colorize(
string_format( "[%s]", contents_item->type->get_id() ),
c_light_blue ) );
}
if( converted_volume_scale != 0 ) {
f |= iteminfo::is_decimal;
}
Expand All @@ -3595,6 +3604,11 @@ void item::contents_info( std::vector<iteminfo> &info, const iteminfo_query *par
return string_format( "'%s'", content_source.second->name() );
}, enumeration_conjunction::arrow ) ) );
}
if( display_object_ids ) {
info.emplace_back( "DESCRIPTION", colorize(
string_format( "[%s]", contents_item->type->get_id() ),
c_light_blue ) );
}
info.emplace_back( "DESCRIPTION", description.translated() );
}
}
Expand Down
1 change: 1 addition & 0 deletions src/iteminfo_query.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
enum class iteminfo_parts : size_t {
BASE_CATEGORY = 0,
BASE_MOD_SRC,
BASE_ID,
BASE_PRICE,
BASE_BARTER,
BASE_VOLUME,
Expand Down
9 changes: 9 additions & 0 deletions src/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,9 @@ int monster::print_info( const catacurses::window &w, int vStart, int vLines, in
vStart += fold_and_print( w, point( column, vStart + 1 ), getmaxx( w ) - 2, c_cyan,
string_format( _( "Origin: %s" ), mod_src ) );
}
if( display_object_ids ) {
mvwprintz( w, point( column, ++vStart ), c_light_blue, string_format( "[%s]", type->id.str() ) );
}

if( sees( g->u ) ) {
mvwprintz( w, point( column, ++vStart ), c_yellow, _( "Aware of your presence!" ) );
Expand Down Expand Up @@ -715,6 +718,12 @@ std::string monster::extended_description() const
return string_format( "'%s'", source.second->name() );
}, enumeration_conjunction::arrow );
}
if( display_object_ids ) {
if( display_mod_source ) {
ss += "\n";
}
ss += colorize( string_format( "[%s]", type->id.str() ), c_light_blue );
}

ss += "\n--\n";

Expand Down
11 changes: 10 additions & 1 deletion src/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2260,6 +2260,10 @@ int npc::print_info( const catacurses::window &w, int line, int vLines, int colu
mvwprintz( w, point( column, line++ ), c_white, _( "NPC: " ) );
wprintz( w, basic_symbol_color(), name );

if( display_object_ids ) {
mvwprintz( w, point( column, line++ ), c_light_blue, string_format( "[%s]", myclass ) );
}

if( sees( g->u ) ) {
mvwprintz( w, point( column, line++ ), c_yellow, _( "Aware of your presence!" ) );
}
Expand Down Expand Up @@ -3016,8 +3020,13 @@ std::string npc::extended_description() const
ss += _( "Is neutral." );
}

if( display_object_ids ) {
ss += "\n--\n";
ss += colorize( string_format( "[%s]", myclass ), c_light_blue );
}

if( hit_by_player ) {
ss += "--\n";
ss += "\n--\n";
ss += _( "Is still innocent and killing them will be considered murder." );
// TODO: "But you don't care because you're an edgy psycho"
}
Expand Down
6 changes: 6 additions & 0 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2101,6 +2101,11 @@ void options_manager::add_options_debug()
true
);

add( "SHOW_IDS", "debug", translate_marker( "Display Object IDs" ),
translate_marker( "Displays internal IDs of game objects and creatures. Warning: IDs may contain spoilers." ),
false
);

add_empty_line();

add_option_group( "debug", Group( "debug_log", to_translation( "Logging" ),
Expand Down Expand Up @@ -3327,6 +3332,7 @@ void options_manager::cache_to_globals()

json_report_strict = test_mode || ::get_option<bool>( "STRICT_JSON_CHECKS" );
display_mod_source = ::get_option<bool>( "MOD_SOURCE" );
display_object_ids = ::get_option<bool>( "SHOW_IDS" );
trigdist = ::get_option<bool>( "CIRCLEDIST" );
#if defined(TILES)
use_tiles = ::get_option<bool>( "USE_TILES" );
Expand Down
11 changes: 10 additions & 1 deletion src/veh_interact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2582,8 +2582,17 @@ void veh_interact::display_stats() const

i = std::max( i, 2 * stats_h );

int fuel_gauge_start_y = y[i];
if( display_object_ids ) {
// Print vehicle type id over above gauges
mvwprintz( w_stats, point( x[i], fuel_gauge_start_y ), c_light_blue,
string_format( "[%s]", veh->type )
);
fuel_gauge_start_y++;
}

// Print fuel percentage & type name only if it fits in the window, 10 is width of "E...F 100%"
veh->print_fuel_indicators( w_stats, point( x[i], y[i] ), fuel_index, true,
veh->print_fuel_indicators( w_stats, point( x[i], fuel_gauge_start_y ), fuel_index, true,
( x[ i ] + 10 < getmaxx( w_stats ) ),
( x[ i ] + 10 < getmaxx( w_stats ) ) );

Expand Down

0 comments on commit 9c2f652

Please sign in to comment.