mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-10-25 21:36:05 +03:00
feat(gameui): implement CGUIBindings::LoadBindings
This commit is contained in:
parent
d59589550d
commit
7057bebcd6
@ -163,7 +163,7 @@ void CGGameUI::Initialize() {
|
||||
//CGGameUI::SomeSavedAccountVariables((int)v23);
|
||||
//LoadAccountData(6, (int(__cdecl*)(int, int, int))sub_5183A0, 0);
|
||||
//CGGameUI::UpdateInitCounter();
|
||||
//CGUIBindings::LoadBindings();
|
||||
CGUIBindings::LoadBindings();
|
||||
//CGUIMacros::Initialize();
|
||||
//CGUIMacros::LoadMacros();
|
||||
//CGChat::LoadChatSettings();
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
static CStatus s_nullStatus;
|
||||
static uint16_t s_initRound = 0;
|
||||
static uint32_t s_loadPendingMask = 0;
|
||||
|
||||
CGUIBindings* CGUIBindings::s_bindings = nullptr;
|
||||
|
||||
@ -114,7 +115,7 @@ static bool ValidateKeyString(const char* key) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void MODIFIEDCLICK::SetBinding(BINDING_SET a1, const char* binding) {
|
||||
void MODIFIEDCLICK::SetBinding(BINDING_SET set, const char* binding) {
|
||||
}
|
||||
|
||||
|
||||
@ -125,6 +126,63 @@ void CGUIBindings::Initialize() {
|
||||
}
|
||||
}
|
||||
|
||||
void CGUIBindings::LoadBindings() {
|
||||
char* buffer = nullptr;
|
||||
if (SFile::Load(nullptr, "WTF\\DefaultBindings.wtf", reinterpret_cast<void**>(&buffer), nullptr, 1, 1, nullptr)) {
|
||||
CGUIBindings::LoadBindings(BINDING_DEFAULT, buffer);
|
||||
SFile::Unload(buffer);
|
||||
// TODO: LoadJoystickConfig
|
||||
}
|
||||
s_loadPendingMask = 6;
|
||||
// TODO: LoadAccountData
|
||||
}
|
||||
|
||||
void CGUIBindings::LoadBindings(BINDING_SET set, const char* buffer) {
|
||||
auto bindings = CGUIBindings::s_bindings;
|
||||
|
||||
if (!CGUIBindings::s_bindings) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (set != BINDING_DEFAULT) {
|
||||
// TODO: bindings->CopyBindings(BINDING_DEFAULT, set);
|
||||
}
|
||||
|
||||
BINDING_MODE mode = BINDING_MODE_0;
|
||||
|
||||
while (*buffer) {
|
||||
char token[1024];
|
||||
SStrTokenize(&buffer, token, sizeof(token), "\r\n", nullptr);
|
||||
|
||||
char* line = token;
|
||||
while (*line == ' ' || *line == '\t') {
|
||||
++line;
|
||||
}
|
||||
|
||||
if (!SStrCmpI(line, "BINDINGMODE ", 12)) {
|
||||
auto value = SStrToInt(&line[12]);
|
||||
if (value <= BINDING_MODE_3) {
|
||||
mode = static_cast<BINDING_MODE>(value);
|
||||
}
|
||||
} else if (!SStrCmpI(line, "bind ", 5)) {
|
||||
const char* command = &line[5];
|
||||
char keystring[32];
|
||||
SStrTokenize(&command, keystring, sizeof(keystring), " ", nullptr);
|
||||
bindings->Bind(set, mode, keystring, command);
|
||||
} else if (!SStrCmpI(line, "modifiedclick ", 14)) {
|
||||
const char* command = &line[14];
|
||||
char keystring[32];
|
||||
SStrTokenize(&command, keystring, sizeof(keystring), " ", nullptr);
|
||||
if (command) {
|
||||
auto modifiedClick = bindings->m_modifiedClicks.Ptr(command);
|
||||
if (modifiedClick)
|
||||
modifiedClick->SetBinding(set, keystring);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool CGUIBindings::Load(const char* commandsFile, MD5_CTX* md5, CStatus* status) {
|
||||
if (!status) {
|
||||
status = &s_nullStatus;
|
||||
|
||||
@ -43,7 +43,7 @@ class KEYCOMMAND : public TSHashObject<KEYCOMMAND, HASHKEY_STRI> {
|
||||
|
||||
class MODIFIEDCLICK : public TSHashObject<MODIFIEDCLICK, HASHKEY_STRI> {
|
||||
public:
|
||||
void SetBinding(BINDING_SET a1, const char* binding);
|
||||
void SetBinding(BINDING_SET set, const char* binding);
|
||||
|
||||
int32_t index;
|
||||
};
|
||||
@ -53,6 +53,8 @@ class CGUIBindings {
|
||||
static CGUIBindings* s_bindings;
|
||||
|
||||
static void Initialize();
|
||||
static void LoadBindings();
|
||||
static void LoadBindings(BINDING_SET set, const char* buffer);
|
||||
|
||||
|
||||
CGUIBindings() = default;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user