Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flatten vehicle menus, make appliances menu top level #60868

Merged
merged 17 commits into from
Sep 14, 2022

Conversation

irwiss
Copy link
Contributor

@irwiss irwiss commented Sep 9, 2022

Summary

None

Purpose of change

Fixes #24802 - Makes electronics controls top level, and toggling electronics doesn't close menu.

Allows rebinding of vehicle menu keys

Makes appliances menu top level, rather than sub menu of vehicle interact_with; moved 'plug appliance' option inside the appliance menu, and any interact_with items should also appear in menu built by veh_app_interact::populate_app_actions.

Stops closing menu when toggling electronics, remember/forget vehicle position, enable/disable cruise control, camera systems enable/disable and opening/closing doors and curtains.


I've wanted to clean up vehicle::interact_with back in #44940 but then got busy IRL so I dropped it, got to complete it now.

There's 2 very similar menus; vehicle examine menu (triggered with e) and controls menu (triggered with ^), they're super similar but slightly different: Controls menu has half baked (closes after every action) top level electronics menu (and electronics sub menu too which doesn't close after every action) but not handbrake or horn. Examine menu has handbrake but not top level electronics. There's more differences but it's just inconsistent; this patch makes both trigger the same (and single) menu.

Describe the solution

Refactoring the stuff in vehicle_use menus is awkward as it uses uilists with enums or int based indexing, which splits every menu item to 2 (or even 3 in case it needs theft check skip) separate places you need to touch.

This patch makes a helper class veh_menu in veh_utils.h/cpp for syntax sugar and wrapping over uilist functionality related to vehicles - registering hotkeys, theft check, part location callback, invalidating map cache and vehicle::refresh() are all called inside of it, it also stores the delegates in std::function so they can be passed around; for example to be used in appliances UI.

This also allows extracting entries from vehicle::interact_with into veh_app_interact::populate_app_actions enabling appliance to be a top level menu.

Trivial menu example can be seen in autopilot commit

After converting menus to use the helper class I merged the use_controls menu into interact_with menu.

Some hotkeys had overlaps, I moved what (in my opinion) is less important to less convenient keys:

  • Pull handbrake from h to H
  • Activate autoclave from a to C
  • Toggle space heater from s to J
  • Toggle engine from e to s
  • Toggle cruise control from c to nothing
  • Added smart controller settings keybind (nothing by default) to allow rebind
  • Added hotwire hotkey h (only relevant if vehicle locked, not interfering with headlights toggle)

But they can be rebound by players now so most inconvenience can be resolved in ? menu

Describe alternatives you've considered

Testing

Unfortunately manually tested as it's mostly a UI change;

  • e on appliance - appliance menu should appear directly (without vehicle menu first)
  • ^ near vehicle controls - menu should appear
  • ^ on vehicle controls - should take controls
  • ^ on vehicle controls while already in control - should show menu
  • e on vehicle controls while already in control - should show menu
  • Locked vehicles should display menu on either e or ^ with most choices involving electronics/battery disabled and extra options for hotwiring/triggering alarm ( a bit tricky to test as vehicles that are both locked and have security system intact are rare, I worked around it by making horn action set is_locked = true ).

Remember/forget vehicle position, enable/disable cruise control, electronics toggles (including camera system), closing/opening individual doors/curtains in "Toggle doors" menu should not close the menu but let you continue toggling on/off and seeing the light/vision changes live.

Additional context

Appliances menu made top level instead of transitioning through vehicles examine menu
https://user-images.githubusercontent.com/6560075/189246050-68a448ba-24ea-4de5-9749-a35e3566f6d7.mp4

Vehicle menus don't close when activating electronics and similar options
https://user-images.githubusercontent.com/6560075/189245891-f7038b40-7879-4bd1-a454-b25de2b2169c.mp4

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Vehicles Vehicles, parts, mechanics & interactions <Bugfix> This is a fix for a bug (or closes open issue) json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Sep 9, 2022
@irwiss irwiss force-pushed the flatten-veh-controls-menu branch from 1f41ad3 to f41b3af Compare September 9, 2022 00:29
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Sep 9, 2022
@irwiss irwiss force-pushed the flatten-veh-controls-menu branch from f41b3af to 340cb2b Compare September 9, 2022 12:57
@github-actions
Copy link
Contributor

github-actions bot commented Sep 9, 2022

Spell checker encountered unrecognized words in the in-game text added in this pull request. See below for details.

Click to expand
  • Toggle autoclave

This alert is automatically generated. You can simply disregard if this is inaccurate, or (optionally) you can also add the new words to tools/spell_checker/dictionary.txt so they will not trigger an alert next time.

@irwiss irwiss force-pushed the flatten-veh-controls-menu branch from 340cb2b to 5b7096f Compare September 9, 2022 14:29
@github-actions github-actions bot added Code: Tooling Tooling that is not part of the main game but is part of the repo. and removed BasicBuildPassed This PR builds correctly, label assigned by github actions labels Sep 9, 2022
@irwiss irwiss force-pushed the flatten-veh-controls-menu branch from 5b7096f to 0da2351 Compare September 9, 2022 14:52
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Sep 9, 2022
@irwiss irwiss force-pushed the flatten-veh-controls-menu branch from 0da2351 to d36dbca Compare September 10, 2022 01:17
@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Sep 10, 2022
@irwiss irwiss force-pushed the flatten-veh-controls-menu branch 3 times, most recently from 9fb481d to 3b64bc9 Compare September 10, 2022 02:10
@github-actions github-actions bot added Code: Tests Measurement, self-control, statistics, balancing. BasicBuildPassed This PR builds correctly, label assigned by github actions labels Sep 10, 2022
@irwiss irwiss force-pushed the flatten-veh-controls-menu branch from 3b64bc9 to 1d1f8b2 Compare September 10, 2022 19:46
@github-actions github-actions bot removed json-styled JSON lint passed, label assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Sep 10, 2022
@irwiss irwiss force-pushed the flatten-veh-controls-menu branch from 1d1f8b2 to c7e5422 Compare September 10, 2022 20:15
@irwiss irwiss force-pushed the flatten-veh-controls-menu branch from c7e5422 to f2e198a Compare September 10, 2022 20:20
@github-actions github-actions bot added json-styled JSON lint passed, label assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Sep 10, 2022
@irwiss irwiss marked this pull request as ready for review September 10, 2022 23:55
@dseguin dseguin merged commit e3df56e into CleverRaven:master Sep 14, 2022
@irwiss irwiss deleted the flatten-veh-controls-menu branch September 14, 2022 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. Code: Tooling Tooling that is not part of the main game but is part of the repo. [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions Vehicles Vehicles, parts, mechanics & interactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow electronics management from top-level vehicle menu
2 participants