mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-08 18:36:00 +03:00
Compare commits
No commits in common. "d59589550d74bc230baee6d3c5cde0174c509652" and "60b1f41b0b0324f458f0fa26f0b1e6ca1ec58fce" have entirely different histories.
d59589550d
...
60b1f41b0b
@ -13,7 +13,6 @@
|
||||
#include "gameui/CGDressUpModelFrame.hpp"
|
||||
#include "gameui/CGTabardModelFrame.hpp"
|
||||
#include "gameui/CGQuestPOIFrame.hpp"
|
||||
#include "gameui/CGUIBindings.hpp"
|
||||
#include "gx/Coordinate.hpp"
|
||||
#include "gx/Device.hpp"
|
||||
#include "ui/FrameScript.hpp"
|
||||
@ -85,8 +84,8 @@ void CGGameUI::Initialize() {
|
||||
LoadScriptFunctions();
|
||||
FrameScript_CreateEvents(g_scriptEvents, 722);
|
||||
//CGGameUI::RegisterGameCVars();
|
||||
//CGUIBindings::Initialize();
|
||||
|
||||
CGUIBindings::Initialize();
|
||||
CGGameUI::RegisterFrameFactories();
|
||||
|
||||
// STORM_ASSERT(GetDataInterfaceVersion() == GetCodeInterfaceVersion())
|
||||
@ -140,9 +139,8 @@ void CGGameUI::Initialize() {
|
||||
FrameXML_FreeHashNodes();
|
||||
FrameXML_CreateFrames("Interface\\FrameXML\\FrameXML.toc", 0, &md5, &status);
|
||||
|
||||
if (SFile::FileExistsEx("Interface\\FrameXML\\Bindings.xml", 1)) {
|
||||
CGUIBindings::s_bindings->Load("Interface\\FrameXML\\Bindings.xml", &md5, &status);
|
||||
}
|
||||
//if (SFile__FileExistsEx((void*)"Interface\\FrameXML\\Bindings.xml", 1))
|
||||
// CGUIBindings::Load("Interface\\FrameXML\\Bindings.xml", &md5, &status);
|
||||
|
||||
unsigned char digest2[16];
|
||||
MD5Final(digest2, &md5);
|
||||
@ -208,8 +206,3 @@ void CGGameUI::Reload() {
|
||||
int32_t CGGameUI::HandleDisplaySizeChanged(const CSizeEvent& event) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CGGameUI::CanPerformAction(int32_t action) {
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -13,7 +13,6 @@ class CGGameUI {
|
||||
static void RegisterFrameFactories();
|
||||
static void Reload();
|
||||
static int32_t HandleDisplaySizeChanged(const CSizeEvent& event);
|
||||
static bool CanPerformAction(int32_t action);
|
||||
|
||||
public:
|
||||
static CSimpleTop* m_simpleTop;
|
||||
|
||||
@ -1,129 +1,13 @@
|
||||
#include "gameui/CGUIBindings.hpp"
|
||||
#include "gameui/CGGameUI.hpp"
|
||||
#include "ui/FrameScript.hpp"
|
||||
#include "util/CStatus.hpp"
|
||||
#include "util/SFile.hpp"
|
||||
#include "util/StringTo.hpp"
|
||||
|
||||
#include <common/XML.hpp>
|
||||
#include <common/Unicode.hpp>
|
||||
#include <bc/Memory.hpp>
|
||||
#include <utility>
|
||||
|
||||
|
||||
static CStatus s_nullStatus;
|
||||
static uint16_t s_initRound = 0;
|
||||
|
||||
CGUIBindings* CGUIBindings::s_bindings = nullptr;
|
||||
|
||||
|
||||
static bool ValidateKeyString(const char* key) {
|
||||
static std::pair<const char*, size_t> s_prefixes[3] = {
|
||||
{ "SHIFT-", 6 },
|
||||
{ "CTRL-", 5 },
|
||||
{ "ALT-", 4 }
|
||||
};
|
||||
static std::pair<const char*, size_t> s_numberedKeys[6] = {
|
||||
{ "F", 1 },
|
||||
{ "NUMPAD", 6 },
|
||||
{ "BUTTON", 6 },
|
||||
{ "JOYSTICK", 8 },
|
||||
{ "JOYAXIS", 7 },
|
||||
{ "JOYBUTTON", 9 },
|
||||
};
|
||||
|
||||
static const char* s_namedKeys[31] = {
|
||||
"SPACE",
|
||||
"NUMPADPLUS",
|
||||
"NUMPADMINUS",
|
||||
"NUMPADMULTIPLY",
|
||||
"NUMPADDIVIDE",
|
||||
"NUMPADDECIMAL",
|
||||
"ESCAPE",
|
||||
"ENTER",
|
||||
"BACKSPACE",
|
||||
"TAB",
|
||||
"LEFT",
|
||||
"UP",
|
||||
"RIGHT",
|
||||
"DOWN",
|
||||
"INSERT",
|
||||
"DELETE",
|
||||
"HOME",
|
||||
"END",
|
||||
"PAGEUP",
|
||||
"PAGEDOWN",
|
||||
"NUMLOCK",
|
||||
"CAPSLOCK",
|
||||
"PRINTSCREEN",
|
||||
"NUMPADEQUALS",
|
||||
"MOUSEWHEELDOWN",
|
||||
"MOUSEWHEELUP",
|
||||
"JOYHAT",
|
||||
"JOYHATUP",
|
||||
"JOYHATRIGHT",
|
||||
"JOYHATDOWN",
|
||||
"JOYHATLEFT"
|
||||
};
|
||||
|
||||
for (uint32_t i = 0; i < 3; ++i) {
|
||||
if (SStrCmp(s_prefixes[i].first, key, s_prefixes[i].second)) {
|
||||
break;
|
||||
}
|
||||
|
||||
key += s_prefixes[i].second;
|
||||
}
|
||||
|
||||
int32_t chars = 0;
|
||||
sgetu8(reinterpret_cast<const uint8_t*>(key), &chars);
|
||||
if (!key[chars]) {
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t index;
|
||||
for (index = 0; index < 6; ++index) {
|
||||
if (!SStrCmp(s_numberedKeys[index].first, key, s_numberedKeys[index].second)) {
|
||||
auto ch = key[s_numberedKeys[index].second];
|
||||
if (ch >= '0' && ch <= '9') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (index >= 6) {
|
||||
for (uint32_t i = 0; i < 31; ++i) {
|
||||
if (!SStrCmp(key, s_namedKeys[i], STORM_MAX_STR)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const char* tail = &key[s_numberedKeys[index].second];
|
||||
while (*tail >= '0' && *tail <= '9') {
|
||||
++tail;
|
||||
}
|
||||
|
||||
if (*tail &&
|
||||
(SStrCmp(s_numberedKeys[index].first, "JOYAXIS", STORM_MAX_STR)
|
||||
|| SStrCmp(tail, "POS", STORM_MAX_STR)
|
||||
&& SStrCmp(tail, "NEG", STORM_MAX_STR))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MODIFIEDCLICK::SetBinding(BINDING_SET a1, const char* binding) {
|
||||
}
|
||||
|
||||
|
||||
void CGUIBindings::Initialize() {
|
||||
CGUIBindings::s_bindings = NEW(CGUIBindings);
|
||||
while (!s_initRound) {
|
||||
++s_initRound;
|
||||
}
|
||||
}
|
||||
|
||||
bool CGUIBindings::Load(const char* commandsFile, MD5_CTX* md5, CStatus* status) {
|
||||
if (!status) {
|
||||
@ -242,172 +126,13 @@ void CGUIBindings::LoadBinding(const char* commandsFile, XMLNode* node, CStatus*
|
||||
const char* angle = node->GetAttributeByName("angle");
|
||||
command->angle = StringToBOOL(angle);
|
||||
|
||||
const char* binding = node->GetAttributeByName("default");
|
||||
if (binding && *binding) {
|
||||
if (!this->m_bindings[BINDING_DEFAULT].Ptr(binding)) {
|
||||
this->Bind(BINDING_DEFAULT, BINDING_MODE_0, binding, name);
|
||||
const char* defaultValue = node->GetAttributeByName("default");
|
||||
if (defaultValue && *defaultValue) {
|
||||
if (!this->m_commands.Ptr(defaultValue)) {
|
||||
// TODO: CGUIBindings::Bind(0, 0, defaultValue, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGUIBindings::LoadModifiedClick(const char* commandsFile, XMLNode* node, CStatus* status) {
|
||||
const char* action = node->GetAttributeByName("action");
|
||||
if (!action || !*action) {
|
||||
status->Add(STATUS_WARNING, "Found modified click with no action in %s", commandsFile);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->m_modifiedClicks.Ptr(action)) {
|
||||
status->Add(STATUS_WARNING, "Modified click %s is defined more than once in %s", action, commandsFile);
|
||||
return;
|
||||
}
|
||||
|
||||
auto modifiedClick = this->m_modifiedClicks.New(action, 0, 0);
|
||||
this->m_numModifiedClicks++;
|
||||
|
||||
const char* binding = node->GetAttributeByName("default");
|
||||
if (binding && *binding) {
|
||||
modifiedClick->SetBinding(BINDING_DEFAULT, binding);
|
||||
}
|
||||
}
|
||||
|
||||
bool CGUIBindings::Bind(BINDING_SET set, BINDING_MODE mode, const char* keystring, const char* command) {
|
||||
if (!CGGameUI::CanPerformAction(13) || !keystring) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!command || !*command) {
|
||||
command = "NONE";
|
||||
}
|
||||
|
||||
static char s_character[2] = {};
|
||||
|
||||
const char* key = keystring;
|
||||
|
||||
if (!SStrCmpI(keystring, "LEFTBRACKET", STORM_MAX_STR)) {
|
||||
s_character[0] = '[';
|
||||
key = s_character;
|
||||
} else if (!SStrCmpI(keystring, "RIGHTBRACKET", STORM_MAX_STR)) {
|
||||
s_character[0] = ']';
|
||||
key = s_character;
|
||||
} else if (!SStrCmpI(keystring, "SLASH", STORM_MAX_STR)) {
|
||||
s_character[0] = '/';
|
||||
key = s_character;
|
||||
} else if (!SStrCmpI(keystring, "BACKSLASH", STORM_MAX_STR)) {
|
||||
s_character[0] = '\\';
|
||||
key = s_character;
|
||||
} else if (!SStrCmpI(keystring, "SEMICOLON", STORM_MAX_STR)) {
|
||||
s_character[0] = ';';
|
||||
key = s_character;
|
||||
} else if (!SStrCmpI(keystring, "APOSTROPHE", STORM_MAX_STR)) {
|
||||
s_character[0] = '\'';
|
||||
key = s_character;
|
||||
} else if (!SStrCmpI(keystring, "COMMA", STORM_MAX_STR)) {
|
||||
s_character[0] = ',';
|
||||
key = s_character;
|
||||
} else if (!SStrCmpI(keystring, "PERIOD", STORM_MAX_STR)) {
|
||||
s_character[0] = '.';
|
||||
key = s_character;
|
||||
} else if (!SStrCmpI(keystring, "TILDE", STORM_MAX_STR)) {
|
||||
s_character[0] = '`';
|
||||
key = s_character;
|
||||
} else if (!SStrCmpI(keystring, "PLUS", STORM_MAX_STR)) {
|
||||
s_character[0] = '=';
|
||||
key = s_character;
|
||||
} else if (!SStrCmpI(keystring, "MINUS", STORM_MAX_STR)) {
|
||||
s_character[0] = '-';
|
||||
key = s_character;
|
||||
}
|
||||
|
||||
if (!ValidateKeyString(key)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto binding = this->m_bindings[set].Ptr(key);
|
||||
if (!binding) {
|
||||
binding = this->m_bindings[set].New(key, 0, 0);
|
||||
}
|
||||
|
||||
if (set != BINDING_DEFAULT) {
|
||||
binding->flags &= ~1u;
|
||||
} else {
|
||||
binding->flags |= 1u;
|
||||
}
|
||||
|
||||
auto bindingCommand = this->GetBindingCommand(binding, mode);
|
||||
if (!bindingCommand || !command || SStrCmp(bindingCommand, command, STORM_MAX_STR)) {
|
||||
if (bindingCommand) {
|
||||
auto index = this->GetBindingIndex(binding, mode);
|
||||
this->AdjustCommandKeyIndices(set, mode, bindingCommand, index);
|
||||
}
|
||||
auto index = this->GetNumCommandKeys(set, mode, command);
|
||||
binding->data[mode].command.Copy(command);
|
||||
binding->data[mode].index = index;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* CGUIBindings::GetBindingCommand(KEYBINDING* binding, BINDING_MODE mode) const {
|
||||
if (mode != BINDING_MODE_4) {
|
||||
return binding->data[mode].command.GetString();
|
||||
}
|
||||
|
||||
for (int32_t m = BINDING_MODE_3; m >= BINDING_MODE_0; --m) {
|
||||
// TODO
|
||||
auto result = binding->data[m].command.GetString();
|
||||
if (result)
|
||||
return result;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int32_t CGUIBindings::GetBindingIndex(KEYBINDING* binding, BINDING_MODE mode) const {
|
||||
if (mode != BINDING_MODE_4) {
|
||||
return binding->data[mode].index;
|
||||
}
|
||||
|
||||
for (int32_t m = BINDING_MODE_3; m >= BINDING_MODE_0; --m) {
|
||||
// TODO
|
||||
if (binding->data[m].command.GetString())
|
||||
return binding->data[m].index;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t CGUIBindings::GetNumCommandKeys(BINDING_SET set, BINDING_MODE mode, const char* command) {
|
||||
auto binding = this->m_bindings[set].Head();
|
||||
|
||||
int32_t result = 0;
|
||||
|
||||
while (binding) {
|
||||
auto bindingCommand = this->GetBindingCommand(binding, mode);
|
||||
if (bindingCommand && !SStrCmpI(bindingCommand, command, STORM_MAX_STR)) {
|
||||
++result;
|
||||
}
|
||||
|
||||
binding = this->m_bindings[set].Next(binding);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void CGUIBindings::AdjustCommandKeyIndices(BINDING_SET set, BINDING_MODE mode, const char* command, int32_t index) {
|
||||
auto binding = this->m_bindings[set].Head();
|
||||
|
||||
int32_t result = 0;
|
||||
|
||||
while (binding) {
|
||||
auto bindingCommand = this->GetBindingCommand(binding, mode);
|
||||
if (bindingCommand && !SStrCmpI(bindingCommand, command, STORM_MAX_STR)) {
|
||||
auto bindingIndex = this->GetBindingIndex(binding, mode);
|
||||
if (bindingIndex > index) {
|
||||
--binding->data[mode].index;
|
||||
}
|
||||
}
|
||||
|
||||
binding = this->m_bindings[set].Next(binding);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,33 +3,14 @@
|
||||
|
||||
#include <storm/Hash.hpp>
|
||||
#include <common/MD5.hpp>
|
||||
#include <common/String.hpp>
|
||||
|
||||
class CStatus;
|
||||
class XMLNode;
|
||||
|
||||
enum BINDING_SET {
|
||||
BINDING_DEFAULT = 0,
|
||||
BINDING_SET_1,
|
||||
BINDING_SET_2,
|
||||
BINDING_SCRIPT,
|
||||
};
|
||||
|
||||
enum BINDING_MODE {
|
||||
BINDING_MODE_0 = 0,
|
||||
BINDING_MODE_1,
|
||||
BINDING_MODE_2,
|
||||
BINDING_MODE_3,
|
||||
BINDING_MODE_4
|
||||
};
|
||||
|
||||
class KEYBINDING : public TSHashObject<KEYBINDING, HASHKEY_STRI> {
|
||||
public:
|
||||
uint32_t flags;
|
||||
struct {
|
||||
int32_t index;
|
||||
RCString command;
|
||||
} data[4];
|
||||
char* command;
|
||||
};
|
||||
|
||||
class KEYCOMMAND : public TSHashObject<KEYCOMMAND, HASHKEY_STRI> {
|
||||
@ -41,37 +22,18 @@ class KEYCOMMAND : public TSHashObject<KEYCOMMAND, HASHKEY_STRI> {
|
||||
int32_t angle;
|
||||
};
|
||||
|
||||
class MODIFIEDCLICK : public TSHashObject<MODIFIEDCLICK, HASHKEY_STRI> {
|
||||
public:
|
||||
void SetBinding(BINDING_SET a1, const char* binding);
|
||||
|
||||
int32_t index;
|
||||
};
|
||||
|
||||
class CGUIBindings {
|
||||
public:
|
||||
static CGUIBindings* s_bindings;
|
||||
|
||||
static void Initialize();
|
||||
|
||||
|
||||
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);
|
||||
bool Bind(BINDING_SET set, BINDING_MODE mode, const char* keystring, const char* command);
|
||||
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);
|
||||
|
||||
int32_t m_numCommands;
|
||||
int32_t m_numHiddenCommands;
|
||||
int32_t m_numModifiedClicks;
|
||||
TSHashTable<KEYBINDING, HASHKEY_STRI> m_bindings[4];
|
||||
TSHashTable<KEYBINDING, HASHKEY_STRI> m_bindings;
|
||||
TSHashTable<KEYCOMMAND, HASHKEY_STRI> m_commands;
|
||||
TSHashTable<MODIFIEDCLICK, HASHKEY_STRI> m_modifiedClicks;
|
||||
};
|
||||
|
||||
#endif // GAME_UI_CGUIBINDINGS_HPP
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#include "gameui/GameScriptFunctions.hpp"
|
||||
#include "gameui/CGUIBindings.hpp"
|
||||
#include "ui/FrameScript.hpp"
|
||||
#include "util/Lua.hpp"
|
||||
#include "util/Unimplemented.hpp"
|
||||
@ -14,144 +13,23 @@ static int32_t Script_GetBinding(lua_State* L) {
|
||||
}
|
||||
|
||||
static int32_t Script_SetBinding(lua_State* L) {
|
||||
if (!lua_isstring(L, 1)) {
|
||||
return luaL_error(L, "Usage: SetBinding(\"KEY\"[, \"COMMAND\"][, mode])");
|
||||
}
|
||||
|
||||
int32_t mode = BINDING_MODE_0;
|
||||
if (lua_isnumber(L, 3)) {
|
||||
mode = static_cast<int32_t>(lua_tonumber(L, 3)) - 1;
|
||||
if (mode < BINDING_MODE_0 || mode > BINDING_MODE_3) {
|
||||
mode = BINDING_MODE_0;
|
||||
}
|
||||
}
|
||||
auto key = lua_tolstring(L, 1, 0);
|
||||
auto command = lua_tolstring(L, 2, 0);
|
||||
if (CGUIBindings::s_bindings->Bind(BINDING_SCRIPT, static_cast<BINDING_MODE>(mode), key, command)) {
|
||||
FrameScript_SignalEvent(0x177u, 0);
|
||||
lua_pushnumber(L, 1.0);
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
return 1;
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
static int32_t Script_SetBindingSpell(lua_State* L) {
|
||||
if (!lua_isstring(L, 1) || !lua_isstring(L, 2)) {
|
||||
return luaL_error(L, "Usage: SetBindingSpell(\"KEY\", \"spellname\"[, mode])");
|
||||
}
|
||||
|
||||
int32_t mode = BINDING_MODE_0;
|
||||
if (lua_isnumber(L, 3)) {
|
||||
mode = static_cast<int32_t>(lua_tonumber(L, 3)) - 1;
|
||||
if (mode < BINDING_MODE_0 || mode > BINDING_MODE_3) {
|
||||
mode = BINDING_MODE_0;
|
||||
}
|
||||
}
|
||||
auto key = lua_tolstring(L, 1, 0);
|
||||
|
||||
auto spellName = lua_tolstring(L, 2, 0);
|
||||
auto length = SStrLen(spellName) + 7;
|
||||
auto command = static_cast<char*>(alloca(length));
|
||||
SStrPrintf(command, length, "SPELL %s", spellName);
|
||||
|
||||
if (CGUIBindings::s_bindings->Bind(BINDING_SCRIPT, static_cast<BINDING_MODE>(mode), key, command)) {
|
||||
FrameScript_SignalEvent(0x177u, 0);
|
||||
lua_pushnumber(L, 1.0);
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
return 1;
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
static int32_t Script_SetBindingItem(lua_State* L) {
|
||||
if (!lua_isstring(L, 1) || !lua_isstring(L, 2)) {
|
||||
return luaL_error(L, "Usage: SetBindingItem(\"KEY\", \"itemname\"[, mode])");
|
||||
}
|
||||
|
||||
int32_t mode = BINDING_MODE_0;
|
||||
if (lua_isnumber(L, 3)) {
|
||||
mode = static_cast<int32_t>(lua_tonumber(L, 3)) - 1;
|
||||
if (mode < BINDING_MODE_0 || mode > BINDING_MODE_3) {
|
||||
mode = BINDING_MODE_0;
|
||||
}
|
||||
}
|
||||
auto key = lua_tolstring(L, 1, 0);
|
||||
|
||||
auto itemName = lua_tolstring(L, 2, 0);
|
||||
auto length = SStrLen(itemName) + 7;
|
||||
auto command = static_cast<char*>(alloca(length));
|
||||
SStrPrintf(command, length, "ITEM %s", itemName);
|
||||
|
||||
if (CGUIBindings::s_bindings->Bind(BINDING_SCRIPT, static_cast<BINDING_MODE>(mode), key, command)) {
|
||||
FrameScript_SignalEvent(0x177u, 0);
|
||||
lua_pushnumber(L, 1.0);
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
return 1;
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
static int32_t Script_SetBindingMacro(lua_State* L) {
|
||||
if (!lua_isstring(L, 1) || !lua_isstring(L, 2)) {
|
||||
return luaL_error(L, "Usage: SetBindingMacro(\"KEY\", \"macroname\"|macroid[, mode])");
|
||||
}
|
||||
|
||||
int32_t mode = BINDING_MODE_0;
|
||||
if (lua_isnumber(L, 3)) {
|
||||
mode = static_cast<int32_t>(lua_tonumber(L, 3)) - 1;
|
||||
if (mode < BINDING_MODE_0 || mode > BINDING_MODE_3) {
|
||||
mode = BINDING_MODE_0;
|
||||
}
|
||||
}
|
||||
auto key = lua_tolstring(L, 1, 0);
|
||||
|
||||
auto macroName = lua_tolstring(L, 2, 0);
|
||||
auto length = SStrLen(macroName) + 7;
|
||||
auto command = static_cast<char*>(alloca(length));
|
||||
SStrPrintf(command, length, "MACRO %s", macroName);
|
||||
|
||||
if (CGUIBindings::s_bindings->Bind(BINDING_SCRIPT, static_cast<BINDING_MODE>(mode), key, command)) {
|
||||
FrameScript_SignalEvent(0x177u, 0);
|
||||
lua_pushnumber(L, 1.0);
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
return 1;
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
static int32_t Script_SetBindingClick(lua_State* L) {
|
||||
if (!lua_isstring(L, 1) || !lua_isstring(L, 2)) {
|
||||
return luaL_error(L, "Usage: SetBindingClick(\"KEY\", \"buttonName\"[, \"mouseButton\"][, mode])");
|
||||
}
|
||||
|
||||
int32_t mode = BINDING_MODE_0;
|
||||
if (lua_isnumber(L, 4)) {
|
||||
mode = static_cast<int32_t>(lua_tonumber(L, 4)) - 1;
|
||||
if (mode < BINDING_MODE_0 || mode > BINDING_MODE_3) {
|
||||
mode = BINDING_MODE_0;
|
||||
}
|
||||
}
|
||||
auto key = lua_tolstring(L, 1, 0);
|
||||
|
||||
auto buttonName = lua_tolstring(L, 2, 0);
|
||||
|
||||
auto mouseButton = lua_tolstring(L, 3, 0);
|
||||
if (!mouseButton) {
|
||||
mouseButton = "LeftButton";
|
||||
}
|
||||
|
||||
auto length = SStrLen(buttonName) + SStrLen(mouseButton) + 8;
|
||||
auto command = static_cast<char*>(alloca(length));
|
||||
SStrPrintf(command, length, "CLICK %s:%s", buttonName, mouseButton);
|
||||
|
||||
if (CGUIBindings::s_bindings->Bind(BINDING_SCRIPT, static_cast<BINDING_MODE>(mode), key, command)) {
|
||||
FrameScript_SignalEvent(0x177u, 0);
|
||||
lua_pushnumber(L, 1.0);
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
return 1;
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
static int32_t Script_SetOverrideBinding(lua_State* L) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user