mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-19 06:01:07 +03:00
Compare commits
1 Commits
ba2172ff0a
...
8fe68e4643
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fe68e4643 |
@ -1,164 +0,0 @@
|
||||
#include "ui/game/ActionBarScript.hpp"
|
||||
#include "ui/FrameScript.hpp"
|
||||
#include "ui/game/CGActionBar.hpp"
|
||||
#include "util/Lua.hpp"
|
||||
#include "util/Unimplemented.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
int32_t Script_GetActionInfo(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetActionTexture(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetActionCount(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetActionCooldown(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetActionAutocast(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetActionText(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_HasAction(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_UseAction(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_PickupAction(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_PlaceAction(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_IsAttackAction(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_IsCurrentAction(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_IsAutoRepeatAction(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_IsUsableAction(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_IsConsumableAction(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_IsStackableAction(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_IsEquippedAction(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_ActionHasRange(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_IsActionInRange(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetBonusBarOffset(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetMultiCastBarOffset(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_ChangeActionBarPage(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetActionBarPage(lua_State* L) {
|
||||
if (CGActionBar::s_tempPageActiveFlags) {
|
||||
lua_pushinteger(L, 1);
|
||||
} else {
|
||||
lua_pushinteger(L, CGActionBar::s_currentPage + 1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t Script_GetActionBarToggles(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_SetActionBarToggles(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_IsPossessBarVisible(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetMultiCastTotemSpells(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_SetMultiCastSpell(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static FrameScript_Method s_ScriptFunctions[] = {
|
||||
{ "GetActionInfo", &Script_GetActionInfo },
|
||||
{ "GetActionTexture", &Script_GetActionTexture },
|
||||
{ "GetActionCount", &Script_GetActionCount },
|
||||
{ "GetActionCooldown", &Script_GetActionCooldown },
|
||||
{ "GetActionAutocast", &Script_GetActionAutocast },
|
||||
{ "GetActionText", &Script_GetActionText },
|
||||
{ "HasAction", &Script_HasAction },
|
||||
{ "UseAction", &Script_UseAction },
|
||||
{ "PickupAction", &Script_PickupAction },
|
||||
{ "PlaceAction", &Script_PlaceAction },
|
||||
{ "IsAttackAction", &Script_IsAttackAction },
|
||||
{ "IsCurrentAction", &Script_IsCurrentAction },
|
||||
{ "IsAutoRepeatAction", &Script_IsAutoRepeatAction },
|
||||
{ "IsUsableAction", &Script_IsUsableAction },
|
||||
{ "IsConsumableAction", &Script_IsConsumableAction },
|
||||
{ "IsStackableAction", &Script_IsStackableAction },
|
||||
{ "IsEquippedAction", &Script_IsEquippedAction },
|
||||
{ "ActionHasRange", &Script_ActionHasRange },
|
||||
{ "IsActionInRange", &Script_IsActionInRange },
|
||||
{ "GetBonusBarOffset", &Script_GetBonusBarOffset },
|
||||
{ "GetMultiCastBarOffset", &Script_GetMultiCastBarOffset },
|
||||
{ "ChangeActionBarPage", &Script_ChangeActionBarPage },
|
||||
{ "GetActionBarPage", &Script_GetActionBarPage },
|
||||
{ "GetActionBarToggles", &Script_GetActionBarToggles },
|
||||
{ "SetActionBarToggles", &Script_SetActionBarToggles },
|
||||
{ "IsPossessBarVisible", &Script_IsPossessBarVisible },
|
||||
{ "GetMultiCastTotemSpells", &Script_GetMultiCastTotemSpells },
|
||||
{ "SetMultiCastSpell", &Script_SetMultiCastSpell },
|
||||
};
|
||||
|
||||
void ActionBarRegisterScriptFunctions() {
|
||||
for (auto& func : s_ScriptFunctions) {
|
||||
FrameScript_RegisterFunction(func.name, func.method);
|
||||
}
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
#ifndef UI_GAME_ACTION_BAR_SCRIPT_HPP
|
||||
#define UI_GAME_ACTION_BAR_SCRIPT_HPP
|
||||
|
||||
void ActionBarRegisterScriptFunctions();
|
||||
|
||||
#endif
|
||||
@ -1,4 +0,0 @@
|
||||
#include "ui/game/CGActionBar.hpp"
|
||||
|
||||
uint32_t CGActionBar::s_currentPage;
|
||||
uint32_t CGActionBar::s_tempPageActiveFlags;
|
||||
@ -1,13 +0,0 @@
|
||||
#ifndef UI_GAME_C_G_ACTION_BAR_HPP
|
||||
#define UI_GAME_C_G_ACTION_BAR_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class CGActionBar {
|
||||
public:
|
||||
// Static variables
|
||||
static uint32_t s_currentPage;
|
||||
static uint32_t s_tempPageActiveFlags;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -3,7 +3,6 @@
|
||||
#include "ui/CScriptObject.hpp"
|
||||
#include "ui/FrameXML.hpp"
|
||||
#include "ui/Key.hpp"
|
||||
#include "ui/game/ActionBarScript.hpp"
|
||||
#include "ui/game/BattlefieldInfoScript.hpp"
|
||||
#include "ui/game/CGCharacterModelBase.hpp"
|
||||
#include "ui/game/CGCooldown.hpp"
|
||||
@ -47,10 +46,6 @@ void LoadScriptFunctions() {
|
||||
|
||||
// TODO
|
||||
|
||||
ActionBarRegisterScriptFunctions();
|
||||
|
||||
// TODO
|
||||
|
||||
CharacterInfoRegisterScriptFunctions();
|
||||
|
||||
// TODO
|
||||
|
||||
@ -95,10 +95,6 @@ void CSimpleFrame::AddFrameRegion(CSimpleRegion* region, uint32_t drawlayer) {
|
||||
this->NotifyDrawLayerChanged(drawlayer);
|
||||
}
|
||||
|
||||
int32_t CSimpleFrame::AttributeChangesAllowed() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void CSimpleFrame::DisableDrawLayer(uint32_t drawlayer) {
|
||||
this->m_drawenabled[drawlayer] = 0;
|
||||
this->NotifyDrawLayerChanged(drawlayer);
|
||||
|
||||
@ -128,7 +128,6 @@ class CSimpleFrame : public CScriptRegion {
|
||||
// Member functions
|
||||
CSimpleFrame(CSimpleFrame* parent);
|
||||
void AddFrameRegion(CSimpleRegion* region, uint32_t drawlayer);
|
||||
int32_t AttributeChangesAllowed();
|
||||
void DisableDrawLayer(uint32_t drawlayer);
|
||||
void DisableEvent(CSimpleEventType eventType);
|
||||
void EnableDrawLayer(uint32_t drawlayer);
|
||||
|
||||
@ -180,197 +180,11 @@ int32_t CSimpleFrame_CanChangeAttributes(lua_State* L) {
|
||||
}
|
||||
|
||||
int32_t CSimpleFrame_GetAttribute(lua_State* L) {
|
||||
auto type = CSimpleFrame::GetObjectType();
|
||||
auto frame = static_cast<CSimpleFrame*>(FrameScript_GetObjectThis(L, type));
|
||||
|
||||
// 3 argument form
|
||||
|
||||
if (lua_gettop(L) == 4 && lua_isstring(L, 3)) {
|
||||
size_t prefixLen, nameLen, suffixLen;
|
||||
auto prefix = lua_tolstring(L, 2, &prefixLen);
|
||||
auto name = lua_tolstring(L, 3, &nameLen);
|
||||
auto suffix = lua_tolstring(L, 4, &suffixLen);
|
||||
|
||||
char buffer[256];
|
||||
char* write;
|
||||
size_t remaining;
|
||||
size_t copyLen;
|
||||
|
||||
int32_t luaRef;
|
||||
|
||||
// Attempt 1: prefix + name + suffix
|
||||
|
||||
write = buffer;
|
||||
remaining = 255;
|
||||
|
||||
if (prefixLen > 0) {
|
||||
copyLen = (prefixLen < remaining) ? prefixLen : remaining;
|
||||
memcpy(write, prefix, copyLen);
|
||||
write += copyLen;
|
||||
remaining -= copyLen;
|
||||
}
|
||||
|
||||
if (nameLen > 0) {
|
||||
copyLen = (nameLen < remaining) ? nameLen : remaining;
|
||||
memcpy(write, name, copyLen);
|
||||
write += copyLen;
|
||||
remaining -= copyLen;
|
||||
}
|
||||
|
||||
if (suffixLen > 0) {
|
||||
copyLen = (suffixLen < remaining) ? suffixLen : remaining;
|
||||
memcpy(write, suffix, copyLen);
|
||||
write += copyLen;
|
||||
}
|
||||
|
||||
*write = '\0';
|
||||
|
||||
if (frame->GetAttribute(buffer, luaRef)) {
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, luaRef);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Attempt 2: "*" + name + suffix
|
||||
|
||||
write = buffer;
|
||||
*write++ = '*';
|
||||
remaining = 254;
|
||||
|
||||
if (nameLen > 0) {
|
||||
copyLen = (nameLen < remaining) ? nameLen : remaining;
|
||||
memcpy(write, name, copyLen);
|
||||
write += copyLen;
|
||||
remaining -= copyLen;
|
||||
}
|
||||
|
||||
if (suffixLen > 0) {
|
||||
copyLen = (suffixLen < remaining) ? suffixLen : remaining;
|
||||
memcpy(write, suffix, copyLen);
|
||||
write += copyLen;
|
||||
}
|
||||
|
||||
*write = '\0';
|
||||
|
||||
if (frame->GetAttribute(buffer, luaRef)) {
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, luaRef);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Attempt 3: prefix + name + "*"
|
||||
|
||||
write = buffer;
|
||||
remaining = 254;
|
||||
|
||||
if (prefixLen > 0) {
|
||||
copyLen = (prefixLen < remaining) ? prefixLen : remaining;
|
||||
memcpy(write, prefix, copyLen);
|
||||
write += copyLen;
|
||||
remaining -= copyLen;
|
||||
}
|
||||
|
||||
if (nameLen > 0) {
|
||||
copyLen = (nameLen < remaining) ? nameLen : remaining;
|
||||
memcpy(write, name, copyLen);
|
||||
write += copyLen;
|
||||
}
|
||||
|
||||
*write++ = '*';
|
||||
*write = '\0';
|
||||
|
||||
if (frame->GetAttribute(buffer, luaRef)) {
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, luaRef);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Attempt 4: "*" + name + "*"
|
||||
|
||||
write = buffer;
|
||||
*write++ = '*';
|
||||
remaining = 253;
|
||||
|
||||
if (nameLen > 0) {
|
||||
copyLen = (nameLen < remaining) ? nameLen : remaining;
|
||||
memcpy(write, name, copyLen);
|
||||
write += copyLen;
|
||||
}
|
||||
|
||||
*write++ = '*';
|
||||
*write = '\0';
|
||||
|
||||
if (frame->GetAttribute(buffer, luaRef)) {
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, luaRef);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Attempt 5: name
|
||||
|
||||
if (frame->GetAttribute(name, luaRef)) {
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, luaRef);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Not found
|
||||
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 1 argument form
|
||||
|
||||
if (lua_isstring(L, 2)) {
|
||||
auto attrName = lua_tostring(L, 2);
|
||||
int32_t luaRef;
|
||||
|
||||
if (frame->GetAttribute(attrName, luaRef)) {
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, luaRef);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Not found
|
||||
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Invalid call
|
||||
|
||||
luaL_error(L, "Usage: %s:GetAttribute(\"name\")", frame->GetDisplayName());
|
||||
return 0;
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t CSimpleFrame_SetAttribute(lua_State* L) {
|
||||
auto type = CSimpleFrame::GetObjectType();
|
||||
auto frame = static_cast<CSimpleFrame*>(FrameScript_GetObjectThis(L, type));
|
||||
|
||||
if (!frame->ProtectedFunctionsAllowed() && !frame->AttributeChangesAllowed()) {
|
||||
// TODO disallowed logic
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
lua_settop(L, 3);
|
||||
|
||||
if (!lua_isstring(L, 2) || lua_type(L, 3) == LUA_TNONE) {
|
||||
luaL_error(L, "Usage: %s:SetAttribute(\"name\", value)", frame->GetDisplayName());
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto attrName = lua_tostring(L, 2);
|
||||
int32_t luaRef;
|
||||
|
||||
if (frame->GetAttribute(attrName, luaRef)) {
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, luaRef);
|
||||
}
|
||||
|
||||
// TODO taint management
|
||||
|
||||
luaRef = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
|
||||
// TODO taint management
|
||||
|
||||
frame->SetAttribute(attrName, luaRef);
|
||||
|
||||
return 0;
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t CSimpleFrame_GetEffectiveScale(lua_State* L) {
|
||||
|
||||
@ -19,25 +19,7 @@ int32_t CSimpleTexture_GetDrawLayer(lua_State* L) {
|
||||
}
|
||||
|
||||
int32_t CSimpleTexture_SetDrawLayer(lua_State* L) {
|
||||
auto type = CSimpleTexture::GetObjectType();
|
||||
auto texture = static_cast<CSimpleTexture*>(FrameScript_GetObjectThis(L, type));
|
||||
|
||||
if (!lua_isstring(L, 2)) {
|
||||
luaL_error(L, "Usage: %s:SetDrawLayer(\"layer\")", texture->GetDisplayName());
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto drawlayerStr = lua_tostring(L, 2);
|
||||
int32_t drawlayer = texture->m_drawlayer;
|
||||
|
||||
if (!StringToDrawLayer(drawlayerStr, drawlayer)) {
|
||||
luaL_error(L, "Usage: %s:SetDrawLayer(\"layer\")", texture->GetDisplayName());
|
||||
return 0;
|
||||
}
|
||||
|
||||
texture->SetFrame(texture->m_parent, drawlayer, texture->m_shown);
|
||||
|
||||
return 0;
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t CSimpleTexture_GetBlendMode(lua_State* L) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user