Skip to content

Commit

Permalink
Adds engine controls to electronic controls & tweaks portable generat…
Browse files Browse the repository at this point in the history
…or (#2633)

* initial

* Format src/vehicle_use.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Only shows engine options when there is one

* Format src/vehicle_use.cpp 2

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Format src/vehicle_use.cpp 3

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
MrLostman and github-actions[bot] committed Apr 13, 2023
1 parent 1f3990f commit 2e9bc6e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion data/json/vehicles/utility.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
{ "x": 1, "y": 0, "part": "frame_cover" },
{ "x": 1, "y": 0, "part": "tank_small", "fuel": "gasoline" },
{ "x": 1, "y": 0, "part": "stowboard_vertical" },
{ "x": 1, "y": 0, "part": "controls" },
{ "x": 1, "y": 0, "part": "controls_electronic" },
{ "x": 1, "y": 0, "parts": [ "wheel_mount_light", "wheel_small" ] }
],
"items": [
Expand Down
16 changes: 16 additions & 0 deletions src/vehicle_use.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,22 @@ void vehicle::control_electronics()

set_electronics_menu_options( options, actions );

if( has_part( "ENGINE" ) ) {
options.emplace_back( engine_on ? _( "Turn off the engine" ) : _( "Turn on the engine" ),
keybind( "TOGGLE_ENGINE" ) );
actions.push_back( [&] {
if( engine_on )
{
engine_on = false;
stop_engines();
} else
{
start_engines();
valid_option = false;
}
refresh();
} );
}
uilist menu;
menu.text = _( "Electronics controls" );
menu.entries = options;
Expand Down

0 comments on commit 2e9bc6e

Please sign in to comment.