resolve keyboard shortcuts through one action table instead of a switch
This commit is contained in:
@@ -3,14 +3,19 @@
|
||||
#include <QString>
|
||||
|
||||
#include "BuildingType.h"
|
||||
#include "ControlAction.h"
|
||||
#include "WorldCamera.h"
|
||||
|
||||
class QKeyEvent;
|
||||
|
||||
// Turns raw key events into the game's semantic actions and publishes them
|
||||
// (REQ-UI-HOTKEYS). Widgets react to the action, never to the key, so the two can
|
||||
// be rebound independently later; the bindings themselves are still hard-coded
|
||||
// here for now.
|
||||
// be rebound independently later.
|
||||
//
|
||||
// Which key means what is not decided here: the caller hands in a ControlContext and
|
||||
// ControlAction.h resolves the press against it, so this file only knows what each
|
||||
// action means once resolved. That is what keeps the controls panel and the key
|
||||
// handling from drifting apart -- both read the one table (REQ-UI-CONTROLS-ACCURACY).
|
||||
//
|
||||
// Two output shapes, chosen by the nature of the action rather than by taste:
|
||||
//
|
||||
@@ -34,9 +39,10 @@ public:
|
||||
static QString getBuildHotkeyLabel(BuildingType type);
|
||||
|
||||
// Both return true when the key was consumed; the caller passes anything else
|
||||
// on to its base class so unrelated shortcuts keep working.
|
||||
bool handleKeyPress(QKeyEvent* event);
|
||||
bool handleKeyRelease(QKeyEvent* event);
|
||||
// on to its base class so unrelated shortcuts keep working. `context` is the
|
||||
// player's current situation, which decides what a key does (REQ-UI-CONTROLS-CONTENT).
|
||||
bool handleKeyPress(QKeyEvent* event, const ControlContext& context);
|
||||
bool handleKeyRelease(QKeyEvent* event, const ControlContext& context);
|
||||
|
||||
// Drops all held-key state, publishing the resulting change. Call when the
|
||||
// receiving widget can no longer expect key-up events.
|
||||
|
||||
Reference in New Issue
Block a user