mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-11 19:43:52 +00:00
55th open format — replaces KeyBinding.dbc plus the AzerothCore-style default-keybind SQL data. Defines the key bindings shipped with the game: movement (W/A/S/D), targeting (Tab), action bars (1-9, 0, -, =), UI panels (C/I/B/P/N/L), chat (Enter), camera (Insert/Delete). Each binding has an internal action name (SCREAMING_SNAKE convention — "MOVE_FORWARD"), a primary key, an optional alternate key, a category for the keybindings UI grouping, and a flag indicating whether the user can override it. Hardcoded engine bindings (alt-F4, ESC) set isUserOverridable=0 so the rebind dialog can't accidentally break them. 9 categories (Movement / Combat / Targeting / Camera / UIPanels / Chat / Macro / Bar / Other) for the rebind dialog grouping. CLI: --gen-kbd (3 essential WASD/Tab/C bindings), --gen-kbd- movement (8 movement: WASD + arrow alternates + jump + autorun), --gen-kbd-ui (10 UI panel bindings covering all the standard interface windows), --info-wkbd, --validate-wkbd with --json variants. Validator catches id+actionName+ defaultKey required, category 0..8, alternateKey == defaultKey (no point in alt), action-name lowercase warning (should be SCREAMING_SNAKE), duplicate primary keys (would silently shadow earlier binding), and duplicate action names. Format graph: 54 → 55 binary formats. CLI flag count: 791 → 796.
100 lines
3.6 KiB
C++
100 lines
3.6 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace wowee {
|
|
namespace pipeline {
|
|
|
|
// Wowee Open Keybinding catalog (.wkbd) — novel replacement
|
|
// for Blizzard's KeyBinding.dbc plus the AzerothCore-style
|
|
// default-keybind SQL data. Defines the key bindings shipped
|
|
// with the game: movement (W/A/S/D), targeting (Tab),
|
|
// action bars (1-9, 0, -, =), UI panels (C/I/B/P/N/L), chat
|
|
// (Enter), camera control (Insert/Delete), macro slots, etc.
|
|
//
|
|
// Each binding has an internal action name ("MOVE_FORWARD"),
|
|
// a primary key, an optional alternate key, a category for
|
|
// the keybindings UI grouping, and a flag indicating whether
|
|
// the user can override it. Hardcoded engine bindings (alt-
|
|
// F4, ESC) set isUserOverridable=0 so the rebind dialog
|
|
// can't accidentally break them.
|
|
//
|
|
// This catalog has no cross-references to other formats —
|
|
// it's a self-contained binding map between strings and
|
|
// keys, consumed directly by the input layer.
|
|
//
|
|
// Binary layout (little-endian):
|
|
// magic[4] = "WKBD"
|
|
// version (uint32) = current 1
|
|
// nameLen + name (catalog label)
|
|
// entryCount (uint32)
|
|
// entries (each):
|
|
// bindingId (uint32)
|
|
// actionLen + actionName
|
|
// descLen + description
|
|
// primaryLen + defaultKey
|
|
// altLen + alternateKey
|
|
// category (uint8) / isUserOverridable (uint8) /
|
|
// sortOrder (uint8) / pad[1]
|
|
struct WoweeKeyBinding {
|
|
enum Category : uint8_t {
|
|
Movement = 0, // WASD, jump, walk
|
|
Combat = 1, // attack, spell cast, action bars
|
|
Targeting = 2, // tab, focus, assist
|
|
Camera = 3, // mouse look, zoom, pitch
|
|
UIPanels = 4, // character/inv/bags/spellbook
|
|
Chat = 5, // enter, slash, reply
|
|
Macro = 6, // macro slots
|
|
Bar = 7, // bar shift / page
|
|
Other = 8, // misc / scripted
|
|
};
|
|
|
|
struct Entry {
|
|
uint32_t bindingId = 0;
|
|
std::string actionName; // "MOVE_FORWARD"
|
|
std::string description;
|
|
std::string defaultKey; // "W"
|
|
std::string alternateKey; // "" if none
|
|
uint8_t category = Movement;
|
|
uint8_t isUserOverridable = 1;
|
|
uint8_t sortOrder = 0; // display order within category
|
|
};
|
|
|
|
std::string name;
|
|
std::vector<Entry> entries;
|
|
|
|
bool isValid() const { return !entries.empty(); }
|
|
|
|
const Entry* findById(uint32_t bindingId) const;
|
|
const Entry* findByActionName(const std::string& actionName) const;
|
|
|
|
static const char* categoryName(uint8_t c);
|
|
};
|
|
|
|
class WoweeKeyBindingLoader {
|
|
public:
|
|
static bool save(const WoweeKeyBinding& cat,
|
|
const std::string& basePath);
|
|
static WoweeKeyBinding load(const std::string& basePath);
|
|
static bool exists(const std::string& basePath);
|
|
|
|
// Preset emitters used by --gen-kbd* variants.
|
|
//
|
|
// makeStarter — 3 essential bindings (MOVE_FORWARD,
|
|
// TARGET_NEAREST_ENEMY, TOGGLE_CHARACTER).
|
|
// makeMovement — 8 movement bindings (4-directional,
|
|
// JUMP, TOGGLE_AUTORUN, TOGGLE_WALK,
|
|
// SIT_OR_STAND).
|
|
// makeUIPanels — 10 UI toggle bindings
|
|
// (Character/Inventory/Bags/Spellbook/
|
|
// Talents/QuestLog/Friends/Guild/
|
|
// MainMenu/Calendar).
|
|
static WoweeKeyBinding makeStarter(const std::string& catalogName);
|
|
static WoweeKeyBinding makeMovement(const std::string& catalogName);
|
|
static WoweeKeyBinding makeUIPanels(const std::string& catalogName);
|
|
};
|
|
|
|
} // namespace pipeline
|
|
} // namespace wowee
|