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

Provide ability to execute an action from the keybindings menu #36859

Merged

Conversation

scrotty
Copy link
Contributor

@scrotty scrotty commented Jan 10, 2020

Summary

SUMMARY: Interface "Option to execute an action from the keybindings menu"

Purpose of change

As a relatively new player who doesn't have all the possible actions or especially their keybindings committed to memory, I find myself frequently opening the keybinding menu both to see what's possible and then how to invoke it. But then I have to remember the keybinding, close keybindings menu, and then invoke the action. It would be much nicer if I could simply invoke the command while I was there.

Describe the solution

Primarily the solution was designed to be minimally disruptive both to players and in code. For this reason, seasoned players probably won't notice its presence - and their existing workflows definitely will not be affected. Since the keybinding menu already includes a system for filtering entries and then editing keybindings, this solution simply adds a discrete option to execute a chosen command as well. By default, the changed function in input.cpp does not present the option to execute an action. A true value to the function's optional permit_execute_action parameter must be provided to enable the option. So, for example, from the game's main screen it makes no sense to execute an action when manipulating key bindings. In game, however, the option is visible.

The edit keybinding keys are '-', '+', and '='. I added '.' for the execute option. Similarly, the letter prefix that the menuing system prefixes actions was color-coded. Keeping with this standard, I made the color of the prefixes for the execution action a basic white - distinct from the others.

When an action is chosen for execution, the keybinding menu automatically closes and the action is run. Importantly, the execution of this action still runs through the normal handle_action.cpp method. So any validity checks are still performed and messages still supplied to the player - in both success and failure cases.

Describe alternatives you've considered

While the keybinding menu is a logical place to locate this functionality for a couple reasons (it is already programmed to limit visibility of actions to what the player should see, and is a common place players already go to for action information), I initially created an entirely new menu devoted to finding other menus by name. After playing with that version for awhile, it seemed overkill and to duplicate existing systems.

Testing

In-game testing and unit tests. I did get a unit test failure but I don't see how my change could be related:

15:43:10.366 WARNING : opendir [./mods/] failed with "No such file or directory".
15:43:12.819 WARNING : opendir [./save/Tom/mods] failed with "No such file or directory".

Starting the actual test at Thu Jan 09 15:43:18 2020

15:45:18.357 ERROR : src/npc.cpp:672 [virtual void npc::setpos(const tripoint&)] could not find npc  on its old overmap
15:45:18.357 ERROR : src/npc.cpp:672 [virtual void npc::setpos(const tripoint&)] could not find npc  on its old overmap
15:45:18.358 ERROR : src/npc.cpp:672 [virtual void npc::setpos(const tripoint&)] could not find npc  on its old overmap
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cata_test.exe is a Catch v2.9.1 host application.
Run with -? for options

-------------------------------------------------------------------------------
place_active_item_at_various_coordinates
-------------------------------------------------------------------------------
active_item_cache.cpp:9
...............................................................................

active_item_cache.cpp:19: FAILED:
  REQUIRE( g->m.get_submaps_with_active_items().empty() )
with expansion:
  false

===============================================================================
test cases:     255 |     254 passed | 1 failed
assertions: 2404091 | 2404090 passed | 1 failed

Additional context

Here is a screen shot of it in action:
execute_in_keybindings

@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Controls / Input Keyboard, mouse, keybindings, input UI, etc. Info / User Interface Game - player communication, menus, etc. Quality of Life QoL: degree to which players are comfortable, and able to enjoy CDDA labels Jan 10, 2020
src/input.h Outdated Show resolved Hide resolved
@ZhilkinSerg
Copy link
Contributor

Looks like it needs to be rebased on top of current master.

@scrotty scrotty force-pushed the execute_action_from_keybindings branch from ad34445 to c32fdfd Compare January 19, 2020 17:56
@ZhilkinSerg ZhilkinSerg merged commit 9c24dec into CleverRaven:master Jan 20, 2020
@scrotty scrotty deleted the execute_action_from_keybindings branch January 20, 2020 15:55
@scrotty
Copy link
Contributor Author

scrotty commented Jan 20, 2020

Turns out this functionality was bypassed by the recent #37109 (Death Cam keybinding). I'll correct and resubmit via new PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Controls / Input Keyboard, mouse, keybindings, input UI, etc. Info / User Interface Game - player communication, menus, etc. [JSON] Changes (can be) made in JSON Quality of Life QoL: degree to which players are comfortable, and able to enjoy CDDA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants