For some reason MinGW doesn't like using template argument deduction on the array... Make it explicit when building there. Also moves the `sized_array` alias to `enum_base` since we don't need it defined in the definition class. Also makes the two versions of ENUM_AND_ARRAY cleaner.
- Cleaned up code and documentation
- Made both overloads of get_enum constexpr (one now takes a string_view instead of a string)
- Used type deduction for the values array. For existing uses this will deduce the same as before (const char*)
This also means it's not explicit, and some classes can use string_view.
Since this is the only way to add things to the hotkey list, there can be at most one
matching entry in the list. Since order doesn't matter, just swap in the new hotkey at
that position rather than erasing and re-adding at end. If we want efficient mid-list
removal we should use std::list.
We don't need the check-if-we-need-to-remove-existing-entry behavior when loading defaults,
since we always want the defaults as a base. This splits load_hotkeys into two functions,
one which directly sets the hotkeys list and the other which will check before adding.
This replaces deactivate_all_scopes followed by set_scope_active. These cases didn't have restorer behavior.
I'm not sure if using restorer behavior would be ok, will need to evaluate that. This is just to clean up
code while matching current behavior.
- get_hotkey_null replaced with hotkey_command::null_command (latter just called the former)
- get_id replaced with direct member access
- get_description replaced with direct member access
- get_tooltip replaced with direct member access
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.
The only place that used this was the preferences dialog, and that was refactored out in 023bdb71426bf3fca4ad22f2a7f63f6272bb241e.
We want to reduce as much global state as possible, especially since this code is accessed by multiple threads (loading screen)
Constitutes a further refinement of a688ab77b9f18db7fd34118267a3c59e9cf5584c.
Instead of getting a list of categories and filtering out those without any hotkeys (custom WML ones,
for example), we generate a set of categories from the list of visible hotkeys when we set up the list.
This ensures we only ever have matching categories for the hotkeys we're seeing and removes the need
for extra global bookkeeping in the category code.
This also ensures the category list is reconstructed when resetting hotkeys. I don't know how categories
could have appeared/disappeared after resetting (the old code should be safe), but this makes sure it
will never be an issue since when visible_hotkeys is changed, so is visible_categories.
- Moved hotkey_command_temp definition to the cpp
- Removed trailing underscores from non-private objects
- Initialize master_hotkey_list at compile-time
- Mark const containers const
Fixes the following issue:
base64.hpp:23:49: error: 'uint8_t' was not declared in this scope
and:
deprecation.hpp:20:22: error: found ':' in nested-name-specifier, expected '::'