2025-08-09 01:32:15 +04:00
|
|
|
#ifndef GAME_UI_CGUIBINDINGS_HPP
|
|
|
|
|
#define GAME_UI_CGUIBINDINGS_HPP
|
|
|
|
|
|
|
|
|
|
#include <storm/Hash.hpp>
|
|
|
|
|
#include <common/MD5.hpp>
|
2025-08-09 15:49:53 +04:00
|
|
|
#include <common/String.hpp>
|
2025-08-09 01:32:15 +04:00
|
|
|
|
|
|
|
|
class CStatus;
|
|
|
|
|
class XMLNode;
|
|
|
|
|
|
2025-08-09 12:52:20 +04:00
|
|
|
enum BINDING_SET {
|
|
|
|
|
BINDING_SET_0 = 0,
|
|
|
|
|
BINDING_SET_1,
|
|
|
|
|
BINDING_SET_2,
|
|
|
|
|
BINDING_SET_3,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum BINDING_MODE {
|
|
|
|
|
BINDING_MODE_0 = 0,
|
|
|
|
|
BINDING_MODE_1,
|
|
|
|
|
BINDING_MODE_2,
|
2025-08-09 15:49:53 +04:00
|
|
|
BINDING_MODE_3,
|
|
|
|
|
BINDING_MODE_4
|
2025-08-09 12:52:20 +04:00
|
|
|
};
|
|
|
|
|
|
2025-08-09 01:32:15 +04:00
|
|
|
class KEYBINDING : public TSHashObject<KEYBINDING, HASHKEY_STRI> {
|
|
|
|
|
public:
|
2025-08-09 12:52:20 +04:00
|
|
|
uint32_t flags;
|
2025-08-09 15:49:53 +04:00
|
|
|
struct {
|
|
|
|
|
int32_t index;
|
|
|
|
|
RCString command;
|
|
|
|
|
} data[4];
|
2025-08-09 01:32:15 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class KEYCOMMAND : public TSHashObject<KEYCOMMAND, HASHKEY_STRI> {
|
|
|
|
|
public:
|
|
|
|
|
int32_t index;
|
|
|
|
|
int32_t function;
|
|
|
|
|
int32_t runOnUp;
|
|
|
|
|
int32_t pressure;
|
|
|
|
|
int32_t angle;
|
|
|
|
|
};
|
|
|
|
|
|
2025-08-09 12:52:20 +04:00
|
|
|
class MODIFIEDCLICK : public TSHashObject<MODIFIEDCLICK, HASHKEY_STRI> {
|
|
|
|
|
public:
|
|
|
|
|
void SetBinding(BINDING_SET a1, const char* binding);
|
|
|
|
|
|
|
|
|
|
int32_t index;
|
|
|
|
|
};
|
|
|
|
|
|
2025-08-09 01:32:15 +04:00
|
|
|
class CGUIBindings {
|
|
|
|
|
public:
|
|
|
|
|
CGUIBindings() = default;
|
|
|
|
|
|
|
|
|
|
bool Load(const char* commandsFile, MD5_CTX* md5, CStatus* status);
|
|
|
|
|
void LoadBinding(const char* commandsFile, XMLNode* node, CStatus* status);
|
|
|
|
|
void LoadModifiedClick(const char* commandsFile, XMLNode* node, CStatus* status);
|
2025-08-09 12:52:20 +04:00
|
|
|
bool Bind(BINDING_SET set, BINDING_MODE mode, const char* keystring, const char* command);
|
2025-08-09 15:49:53 +04:00
|
|
|
const char* GetBindingCommand(KEYBINDING* binding, BINDING_MODE mode) const;
|
|
|
|
|
int32_t GetBindingIndex(KEYBINDING* binding, BINDING_MODE mode) const;
|
|
|
|
|
int32_t GetNumCommandKeys(BINDING_SET set, BINDING_MODE mode, const char* command);
|
|
|
|
|
void AdjustCommandKeyIndices(BINDING_SET set, BINDING_MODE mode, const char* command, int32_t index);
|
2025-08-09 01:32:15 +04:00
|
|
|
|
|
|
|
|
int32_t m_numCommands;
|
|
|
|
|
int32_t m_numHiddenCommands;
|
2025-08-09 12:52:20 +04:00
|
|
|
int32_t m_numModifiedClicks;
|
2025-08-09 01:32:15 +04:00
|
|
|
TSHashTable<KEYBINDING, HASHKEY_STRI> m_bindings;
|
|
|
|
|
TSHashTable<KEYCOMMAND, HASHKEY_STRI> m_commands;
|
2025-08-09 12:52:20 +04:00
|
|
|
TSHashTable<MODIFIEDCLICK, HASHKEY_STRI> m_modifiedClicks;
|
2025-08-09 01:32:15 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // GAME_UI_CGUIBINDINGS_HPP
|