Skip to content

Commit

Permalink
Merge pull request #78515 from Procyonae/WallWiringTweaks
Browse files Browse the repository at this point in the history
Wall wiring tweaks
  • Loading branch information
Night-Pryanik authored Dec 13, 2024
2 parents fb3126c + 772a4b9 commit a7c5b6f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 2 deletions.
6 changes: 4 additions & 2 deletions data/json/furniture_and_terrain/terrain-walls.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"name": { "str": "abstract concrete wall", "//~": "NO_I18N" },
"description": "Encompasses most concrete-like walls. If you see this in-game, it's a bug.",
"roof": "t_concrete_roof",
"color": "light_gray"
"color": "light_gray",
"extend": { "flags": [ "WIRED_WALL" ] }
},
{
"type": "terrain",
Expand All @@ -68,7 +69,8 @@
"name": { "str": "abstract brick wall", "//~": "NO_I18N" },
"description": "Encompasses most brick-like walls. If you see this in-game, it's a bug.",
"roof": "t_brick_roof",
"color": "brown"
"color": "brown",
"extend": { "flags": [ "WIRED_WALL" ] }
},
{
"type": "terrain",
Expand Down
2 changes: 2 additions & 0 deletions src/savegame_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3234,6 +3234,7 @@ void vehicle_part::deserialize( const JsonObject &data )
data.read( "locked", locked );
data.read( "last_disconnected", last_disconnected );
data.read( "last_charged", last_charged );
data.read( "hidden", hidden );

if( migration != nullptr ) {
for( const itype_id &it : migration->add_veh_tools ) {
Expand Down Expand Up @@ -3289,6 +3290,7 @@ void vehicle_part::serialize( JsonOut &json ) const
json.member( "locked", locked );
json.member( "last_disconnected", last_disconnected );
json.member( "last_charged", last_charged );
json.member( "hidden", hidden );
json.end_object();
}

Expand Down
17 changes: 17 additions & 0 deletions src/veh_appliance.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "cached_options.h"
#include "game.h"
#include "handle_liquid.h"
#include "imgui/imgui.h"
Expand Down Expand Up @@ -536,6 +537,13 @@ void veh_app_interact::plug()
}
}

void veh_app_interact::hide()
{
const int part_idx = veh->part_at( veh->coord_translate( a_point ) );
vehicle_part &vp = veh->part( part_idx );
vp.hidden = !vp.hidden;
}

void veh_app_interact::populate_app_actions()
{
map &here = get_map();
Expand Down Expand Up @@ -585,6 +593,15 @@ void veh_app_interact::populate_app_actions()
string_format( "%s%s", ctxt.get_action_name( "PLUG" ),
//~ An addendum to Plug In's description, as in: Plug in appliance / merge power grid".
veh->is_powergrid() ? _( " / merge power grid" ) : "" ) );
#if defined(TILES)
// Hide
if( use_tiles && vp->info().has_flag( flag_WIRING ) ) {
app_actions.emplace_back( [this]() {
hide();
} );
imenu.addentry( -1, true, 0, "Hide/Unhide wiring" );
}
#endif

if( veh->is_powergrid() && veh->part_count() > 1 && !vp->info().has_flag( VPFLAG_WALL_MOUNTED ) ) {
// Disconnect from power grid
Expand Down
5 changes: 5 additions & 0 deletions src/veh_appliance.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ class veh_app_interact
* Connects the power cable to selected tile.
*/
void plug();
/**
* Function associated with the "HIDE" action.
* Hides the selected tiles sprite.
*/
void hide();
/**
* The main loop of the appliance UI. Redraws windows, checks for input, and
* performs selected actions. The loop exits once an activity is assigned
Expand Down
3 changes: 3 additions & 0 deletions src/vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,9 @@ struct vehicle_part {
/** door is locked */
bool locked = false;

// If the part's sprite/symbol shouldn't be shown
bool hidden = false;

/** direction the part is facing */
units::angle direction = 0_degrees;

Expand Down
3 changes: 3 additions & 0 deletions src/vehicle_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ vpart_display vehicle::get_display_of_tile( const point_rel_ms &dp, bool rotate,
}

const vehicle_part &vp = part( part_idx );
if( vp.hidden ) {
return {};
}
const vpart_info &vpi = vp.info();

auto variant_it = vpi.variants.find( vp.variant );
Expand Down

0 comments on commit a7c5b6f

Please sign in to comment.