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

Hotkeys: refactored how hotkey_commands are stored and managed (WML hotkeys only) #6728

Merged
merged 2 commits into from
May 26, 2022

Commits on May 26, 2022

  1. Hotkeys: refactored how hotkey_commands are stored and managed (WML h…

    …otkeys only)
    
    This encompasses two closely related changes. First, we now store hotkey_commands in a map instead of
    a vector with accompanying index map. Most code did not rely on the command container being contiguous,
    and since the commonly used get_hotkey_command was already performing a lookup in the index map, there
    wasn't much need to use a separate container. Associative storage makes the most sense here.
    
    The one place that did rely on the command container being contiguous was remove_wml_hotkey. I realized,
    however, that it would be much cleaner to eliminate the manual bookkeeping. To this end, I added a new
    wml_hotkey_record RAII class. It registers a hotkey_command when created and removes it on destruction.
    Using a map for the commands made this even easier, since it doesn't invalidate other iterators or
    require other commands to be moved to keep the container contiguous. In addition, removing the secondary
    index map means we no longer need to recreate that every time a wml hotkey is removed!
    
    Switching to this RAII-based system means delete_all_wml_hotkeys could also be removed, since all WML
    hotkeys should now be handled by wml_hotkey_record and clean themselves up on destruction.
    
    clear_hotkey_commands was also removed, since it was both misleading and now unnecessary. It only cleared
    the index map, not the actual list of hotkey_commands! Given that init_hotkey_commands actually set up
    the command list, this was doubly confusing.
    Vultraz committed May 26, 2022
    Configuration menu
    Copy the full SHA
    063aa9b View commit details
    Browse the repository at this point in the history
  2. Further refinements

    Vultraz committed May 26, 2022
    Configuration menu
    Copy the full SHA
    cbc48c5 View commit details
    Browse the repository at this point in the history