GGActionMap class
#include <GGUI/Public/UIActions.h>
GGActionMap: registered actions and their current chords.
Owned by the host and shared by its documents (UIContext::
Public types
- struct Entry
- A registered action and its bindings.
Public static functions
- static auto ChordName(GGChord chord) -> std::string
- The file form of a chord ("Ctrl+Shift+S", "None"). Always English, so a file means the same on every machine.
- static auto ChordFromName(std::string_view name, GGChord& out) -> bool
- A chord from its file form. False if it isn't one.
- static auto KeyName(GGKey key) -> std::string
- English key name: the file form, and the fallback when there is no translation.
- static auto PadName(GGPad pad) -> std::string
- A gamepad button's file form: "Pad.South", or "None".
- static auto PadFromName(std::string_view name, GGPad& out) -> bool
- A gamepad button from its file form. False if it isn't one.
Public functions
- void Register(const GGInputAction& action)
- Register
action. Nothing if it is already registered. -
auto ChordOf(const GGInputAction& action,
GGSlot slot = GGSlot::
Primary) const -> GGChord - Current chord in
slot, or the action's default if it isn't registered. -
auto ChordOf(uint64_t id,
GGSlot slot = GGSlot::
Primary) const -> GGChord - Current chord in
slot, or none if the ID isn't registered. - auto ShownChordOf(const GGInputAction& action) const -> GGChord
- The chord to show for it: the primary, or the alternate if it has no primary.
- auto IsBoundTo(uint64_t id, GGChord chord) const -> bool
- True if either of its chords is
chord. - auto PadOf(const GGInputAction& action) const -> GGPad
- Its current gamepad button, or the action's default if it isn't registered.
- auto PadOf(uint64_t id) const -> GGPad
- Its current gamepad button, or none if the ID isn't registered.
- void RebindPad(const GGInputAction& action, GGPad pad)
- Bind
actionto gamepad buttonpad; GGPad::None unbinds it. -
void Rebind(const GGInputAction& action,
GGChord chord,
GGSlot slot = GGSlot::
Primary) - Bind
action'sslottochord; an empty chord unbinds that slot. -
void Rebind(uint64_t id,
GGChord chord,
GGSlot slot = GGSlot::
Primary) - The same, by ID. Nothing if the ID isn't registered.
- void Unbind(uint64_t id, GGChord chord)
- Take
chordfrom whichever of its slots has it. - void Reset(const GGInputAction& action)
- Put both chords back to their defaults.
- void Reset(const GGInputAction& action, GGSlot slot)
- Put the chord in
slotback to its default. - void Conflicts(const GGInputAction& action, GGChord chord, std::vector<Entry>& out) const
- Actions currently bound to
chord(in either slot) whose category contains, or is contained by,action's. - auto All() const -> std::vector<Entry>
- A snapshot of every action, sorted by name.
- auto Find(uint64_t id) const -> std::optional<Entry>
- A copy of the entry of the action with ID
id; none if it isn't registered. - auto Changed() const -> const GGRevision&
- Bumped when any chord changes.
- auto Edited() const -> const GGRevision&
- Bumped by Rebind and Reset but not by Load. Use it to decide when to write the file.
- auto Save() const -> std::string
- Non-default bindings, one
Name = Ctrl+Shift+Sper line;Name = Ctrl+Y, Ctrl+Shift+Zwhen the alternate isn't its default either. - auto Load(std::string_view text, std::string* problems = nullptr) -> uint32_t
- Reset every action to its default, then apply
text.
Function documentation
uint32_t GGUI:: GGActionMap:: Load(std::string_view text,
std::string* problems = nullptr)
Reset every action to its default, then apply text.
Lines for actions not registered yet are held and applied on registration. Returns the number of lines applied; unparseable lines are reported in problems.