mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-18 21:51:06 +03:00
Compare commits
8 Commits
bd5c1e2d66
...
46b387c19f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
46b387c19f | ||
|
|
7d911e453d | ||
|
|
d34336cd7e | ||
|
|
3bf95af10c | ||
|
|
0681e432e2 | ||
|
|
66fd4a6564 | ||
|
|
c201da76cd | ||
|
|
a82628adaa |
@ -160,6 +160,10 @@ ClientConnection* ClientServices::Connection() {
|
|||||||
return ClientServices::s_currentConnection;
|
return ClientServices::s_currentConnection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientServices::CharacterDelete(uint64_t guid) {
|
||||||
|
ClientServices::Connection()->RequestCharacterDelete(guid);
|
||||||
|
}
|
||||||
|
|
||||||
void ClientServices::Disconnect() {
|
void ClientServices::Disconnect() {
|
||||||
ClientServices::Connection()->Disconnect();
|
ClientServices::Connection()->Disconnect();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,6 +33,7 @@ class ClientServices : public LoginResponse {
|
|||||||
// Static functions
|
// Static functions
|
||||||
static void ConnectToSelectedServer();
|
static void ConnectToSelectedServer();
|
||||||
static ClientConnection* Connection();
|
static ClientConnection* Connection();
|
||||||
|
static void CharacterDelete(uint64_t guid);
|
||||||
static void Disconnect();
|
static void Disconnect();
|
||||||
static const char* GetCurrentLoginPortal();
|
static const char* GetCurrentLoginPortal();
|
||||||
static const char* GetCurrentLoginServer();
|
static const char* GetCurrentLoginServer();
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
#include "glue/CCharacterSelectionScript.hpp"
|
#include "glue/CCharacterSelectionScript.hpp"
|
||||||
|
#include "CGlueMgr.hpp"
|
||||||
#include "db/Db.hpp"
|
#include "db/Db.hpp"
|
||||||
#include "glue/CCharacterSelection.hpp"
|
#include "glue/CCharacterSelection.hpp"
|
||||||
#include "object/client/CGUnit_C.hpp"
|
#include "object/client/CGUnit_C.hpp"
|
||||||
@ -157,7 +158,17 @@ int32_t Script_SelectCharacter(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_DeleteCharacter(lua_State* L) {
|
int32_t Script_DeleteCharacter(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
if (!lua_isnumber(L, 1)) {
|
||||||
|
luaL_error(L, "Usage: DeleteCharacter(index)");
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t index = static_cast<int32_t>(lua_tonumber(L, 1)) - 1;
|
||||||
|
|
||||||
|
if (index >= 0 && index < CCharacterSelection::s_characterList.Count()) {
|
||||||
|
CGlueMgr::DeleteCharacter(CCharacterSelection::s_characterList.m_data[index].m_info.guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_RenameCharacter(lua_State* L) {
|
int32_t Script_RenameCharacter(lua_State* L) {
|
||||||
|
|||||||
@ -129,6 +129,17 @@ void CGlueMgr::ChangeRealm(const REALM_INFO* realmInfo) {
|
|||||||
ClientServices::Connection()->Connect();
|
ClientServices::Connection()->Connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGlueMgr::DeleteCharacter(uint64_t guid) {
|
||||||
|
if (guid) {
|
||||||
|
CGlueMgr::SetIdleState(IDLE_DELETE_CHARACTER);
|
||||||
|
|
||||||
|
auto text = FrameScript_GetText(ClientServices::GetErrorToken(70), -1, GENDER_NOT_APPLICABLE);
|
||||||
|
FrameScript_SignalEvent(OPEN_STATUS_DIALOG, "%s%s", "CANCEL", text);
|
||||||
|
|
||||||
|
ClientServices::CharacterDelete(guid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CGlueMgr::EnterWorld() {
|
void CGlueMgr::EnterWorld() {
|
||||||
if (!ClientServices::GetSelectedRealm()) {
|
if (!ClientServices::GetSelectedRealm()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -66,6 +66,7 @@ class CGlueMgr {
|
|||||||
// Static functions
|
// Static functions
|
||||||
static void CancelRealmListQuery();
|
static void CancelRealmListQuery();
|
||||||
static void ChangeRealm(const REALM_INFO* realmInfo);
|
static void ChangeRealm(const REALM_INFO* realmInfo);
|
||||||
|
static void DeleteCharacter(uint64_t guid);
|
||||||
static void DisplayLoginStatus();
|
static void DisplayLoginStatus();
|
||||||
static void EnterWorld();
|
static void EnterWorld();
|
||||||
static void GetCharacterList();
|
static void GetCharacterList();
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#include "net/connection/ClientConnection.hpp"
|
#include "net/connection/ClientConnection.hpp"
|
||||||
#include "net/Login.hpp"
|
|
||||||
#include "client/ClientServices.hpp"
|
#include "client/ClientServices.hpp"
|
||||||
|
#include "common/datastore/CDataStore.hpp"
|
||||||
|
#include "net/Login.hpp"
|
||||||
#include "ui/FrameScript.hpp"
|
#include "ui/FrameScript.hpp"
|
||||||
|
|
||||||
void ClientConnection::AccountLogin(const char* name, const char* password, int32_t region, WOW_LOCALE locale) {
|
void ClientConnection::AccountLogin(const char* name, const char* password, int32_t region, WOW_LOCALE locale) {
|
||||||
@ -160,3 +161,19 @@ int32_t ClientConnection::PollStatus(WOWCS_OPS& op, const char** msg, int32_t& r
|
|||||||
|
|
||||||
return this->m_statusComplete;
|
return this->m_statusComplete;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientConnection::RequestCharacterDelete(uint64_t guid) {
|
||||||
|
this->Initiate(COP_DELETE_CHARACTER, 70, nullptr);
|
||||||
|
|
||||||
|
if (this->IsConnected()) {
|
||||||
|
CDataStore netMsg;
|
||||||
|
netMsg.Put(static_cast<uint32_t>(CMSG_CHAR_DELETE));
|
||||||
|
netMsg.Put(guid);
|
||||||
|
netMsg.Finalize();
|
||||||
|
|
||||||
|
this->Send(&netMsg);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this->Cancel(4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -43,6 +43,7 @@ class ClientConnection : public RealmConnection {
|
|||||||
void Initiate(WOWCS_OPS op, int32_t errorCode, void (*cleanup)());
|
void Initiate(WOWCS_OPS op, int32_t errorCode, void (*cleanup)());
|
||||||
int32_t IsConnected();
|
int32_t IsConnected();
|
||||||
int32_t PollStatus(WOWCS_OPS& op, const char** msg, int32_t& result, int32_t& errorCode);
|
int32_t PollStatus(WOWCS_OPS& op, const char** msg, int32_t& result, int32_t& errorCode);
|
||||||
|
void RequestCharacterDelete(uint64_t guid);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
164
src/ui/game/ActionBarScript.cpp
Normal file
164
src/ui/game/ActionBarScript.cpp
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
#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);
|
||||||
|
}
|
||||||
|
}
|
||||||
6
src/ui/game/ActionBarScript.hpp
Normal file
6
src/ui/game/ActionBarScript.hpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef UI_GAME_ACTION_BAR_SCRIPT_HPP
|
||||||
|
#define UI_GAME_ACTION_BAR_SCRIPT_HPP
|
||||||
|
|
||||||
|
void ActionBarRegisterScriptFunctions();
|
||||||
|
|
||||||
|
#endif
|
||||||
4
src/ui/game/CGActionBar.cpp
Normal file
4
src/ui/game/CGActionBar.cpp
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#include "ui/game/CGActionBar.hpp"
|
||||||
|
|
||||||
|
uint32_t CGActionBar::s_currentPage;
|
||||||
|
uint32_t CGActionBar::s_tempPageActiveFlags;
|
||||||
13
src/ui/game/CGActionBar.hpp
Normal file
13
src/ui/game/CGActionBar.hpp
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#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,6 +3,7 @@
|
|||||||
#include "ui/CScriptObject.hpp"
|
#include "ui/CScriptObject.hpp"
|
||||||
#include "ui/FrameXML.hpp"
|
#include "ui/FrameXML.hpp"
|
||||||
#include "ui/Key.hpp"
|
#include "ui/Key.hpp"
|
||||||
|
#include "ui/game/ActionBarScript.hpp"
|
||||||
#include "ui/game/BattlefieldInfoScript.hpp"
|
#include "ui/game/BattlefieldInfoScript.hpp"
|
||||||
#include "ui/game/CGCharacterModelBase.hpp"
|
#include "ui/game/CGCharacterModelBase.hpp"
|
||||||
#include "ui/game/CGCooldown.hpp"
|
#include "ui/game/CGCooldown.hpp"
|
||||||
@ -46,6 +47,10 @@ void LoadScriptFunctions() {
|
|||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
|
ActionBarRegisterScriptFunctions();
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
|
||||||
CharacterInfoRegisterScriptFunctions();
|
CharacterInfoRegisterScriptFunctions();
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|||||||
@ -95,6 +95,10 @@ void CSimpleFrame::AddFrameRegion(CSimpleRegion* region, uint32_t drawlayer) {
|
|||||||
this->NotifyDrawLayerChanged(drawlayer);
|
this->NotifyDrawLayerChanged(drawlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t CSimpleFrame::AttributeChangesAllowed() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void CSimpleFrame::DisableDrawLayer(uint32_t drawlayer) {
|
void CSimpleFrame::DisableDrawLayer(uint32_t drawlayer) {
|
||||||
this->m_drawenabled[drawlayer] = 0;
|
this->m_drawenabled[drawlayer] = 0;
|
||||||
this->NotifyDrawLayerChanged(drawlayer);
|
this->NotifyDrawLayerChanged(drawlayer);
|
||||||
|
|||||||
@ -128,6 +128,7 @@ class CSimpleFrame : public CScriptRegion {
|
|||||||
// Member functions
|
// Member functions
|
||||||
CSimpleFrame(CSimpleFrame* parent);
|
CSimpleFrame(CSimpleFrame* parent);
|
||||||
void AddFrameRegion(CSimpleRegion* region, uint32_t drawlayer);
|
void AddFrameRegion(CSimpleRegion* region, uint32_t drawlayer);
|
||||||
|
int32_t AttributeChangesAllowed();
|
||||||
void DisableDrawLayer(uint32_t drawlayer);
|
void DisableDrawLayer(uint32_t drawlayer);
|
||||||
void DisableEvent(CSimpleEventType eventType);
|
void DisableEvent(CSimpleEventType eventType);
|
||||||
void EnableDrawLayer(uint32_t drawlayer);
|
void EnableDrawLayer(uint32_t drawlayer);
|
||||||
|
|||||||
@ -180,11 +180,197 @@ int32_t CSimpleFrame_CanChangeAttributes(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFrame_GetAttribute(lua_State* L) {
|
int32_t CSimpleFrame_GetAttribute(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFrame_SetAttribute(lua_State* L) {
|
int32_t CSimpleFrame_SetAttribute(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFrame_GetEffectiveScale(lua_State* L) {
|
int32_t CSimpleFrame_GetEffectiveScale(lua_State* L) {
|
||||||
|
|||||||
@ -19,7 +19,25 @@ int32_t CSimpleTexture_GetDrawLayer(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleTexture_SetDrawLayer(lua_State* L) {
|
int32_t CSimpleTexture_SetDrawLayer(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleTexture_GetBlendMode(lua_State* L) {
|
int32_t CSimpleTexture_GetBlendMode(lua_State* L) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user