mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-19 06:01:07 +03:00
Compare commits
1 Commits
f87f151e8c
...
b93d01e265
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b93d01e265 |
@ -16,5 +16,4 @@ target_include_directories(object
|
|||||||
target_link_libraries(object
|
target_link_libraries(object
|
||||||
PRIVATE
|
PRIVATE
|
||||||
db
|
db
|
||||||
ui
|
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,13 +1,11 @@
|
|||||||
#include "ui/game/ScriptEvents.hpp"
|
#include "ui/game/ScriptEvents.hpp"
|
||||||
#include "db/Db.hpp"
|
#include "object/client/ObjMgr.hpp"
|
||||||
#include "object/Client.hpp"
|
|
||||||
#include "ui/FrameScript.hpp"
|
#include "ui/FrameScript.hpp"
|
||||||
#include "ui/ScriptFunctionsSystem.hpp"
|
#include "ui/ScriptFunctionsSystem.hpp"
|
||||||
#include "ui/game/CGGameUI.hpp"
|
#include "ui/game/CGGameUI.hpp"
|
||||||
#include "ui/game/ScriptUtil.hpp"
|
#include "ui/game/ScriptUtil.hpp"
|
||||||
#include "util/GUID.hpp"
|
#include "util/GUID.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -709,29 +707,7 @@ int32_t Script_IsXPUserDisabled(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_FillLocalizedClassList(lua_State* L) {
|
int32_t Script_FillLocalizedClassList(lua_State* L) {
|
||||||
if (lua_type(L, 1) != LUA_TTABLE) {
|
WHOA_UNIMPLEMENTED(0);
|
||||||
luaL_error(L, "Usage: FillLocalizedClassList(classTable[, isFemale])");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto isFemale = StringToBOOL(L, 2, 0);
|
|
||||||
auto sex = isFemale ? UNITSEX_FEMALE : UNITSEX_MALE;
|
|
||||||
|
|
||||||
lua_settop(L, 1);
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < g_chrClassesDB.GetNumRecords(); ++i) {
|
|
||||||
auto classRec = g_chrClassesDB.GetRecordByIndex(i);
|
|
||||||
if (classRec) {
|
|
||||||
auto displayName = CGUnit_C::GetDisplayClassNameFromRecord(classRec, sex, 0);
|
|
||||||
|
|
||||||
lua_pushstring(L, classRec->m_filename);
|
|
||||||
lua_pushstring(L, displayName);
|
|
||||||
|
|
||||||
lua_settable(L, -3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -372,18 +372,7 @@ int32_t CSimpleButton_GetTextWidth(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleButton_GetTextHeight(lua_State* L) {
|
int32_t CSimpleButton_GetTextHeight(lua_State* L) {
|
||||||
auto type = CSimpleButton::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto button = static_cast<CSimpleButton*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
|
|
||||||
auto text = button->m_text;
|
|
||||||
|
|
||||||
float height = text ? text->GetHeight() : 0.0f;
|
|
||||||
float ddcHeight = CoordinateGetAspectCompensation() * 1024.0f * height;
|
|
||||||
float ndcHeight = DDCToNDCWidth(ddcHeight);
|
|
||||||
|
|
||||||
lua_pushnumber(L, ndcHeight);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleButton_RegisterForClicks(lua_State* L) {
|
int32_t CSimpleButton_RegisterForClicks(lua_State* L) {
|
||||||
|
|||||||
@ -162,17 +162,7 @@ int32_t CSimpleFontString_SetFont(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFontString_GetText(lua_State* L) {
|
int32_t CSimpleFontString_GetText(lua_State* L) {
|
||||||
auto type = CSimpleFontString::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto string = static_cast<CSimpleFontString*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
|
|
||||||
auto text = string->GetText();
|
|
||||||
if (!text || !*text) {
|
|
||||||
text = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_pushstring(L, text);
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFontString_GetFieldSize(lua_State* L) {
|
int32_t CSimpleFontString_GetFieldSize(lua_State* L) {
|
||||||
|
|||||||
@ -376,29 +376,6 @@ void CSimpleFrame::RegisterForEvents(int32_t a2) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimpleFrame::RunOnAttributeChangedScript(const char* name, int32_t luaRef) {
|
|
||||||
if (!this->m_onAttributeChange.luaRef) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto L = FrameScript_GetContext();
|
|
||||||
|
|
||||||
// TODO taint management
|
|
||||||
|
|
||||||
// Attribute name
|
|
||||||
auto nameLower = static_cast<char*>(alloca(SStrLen(name) + 1));
|
|
||||||
SStrCopy(nameLower, name);
|
|
||||||
SStrLower(nameLower);
|
|
||||||
lua_pushstring(L, nameLower);
|
|
||||||
|
|
||||||
// Attribute ref
|
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, luaRef);
|
|
||||||
|
|
||||||
this->RunScript(this->m_onAttributeChange, 2, nullptr);
|
|
||||||
|
|
||||||
// TODO taint management
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimpleFrame::RunOnCharScript(const char* chr) {
|
void CSimpleFrame::RunOnCharScript(const char* chr) {
|
||||||
if (this->m_onChar.luaRef) {
|
if (this->m_onChar.luaRef) {
|
||||||
auto L = FrameScript_GetContext();
|
auto L = FrameScript_GetContext();
|
||||||
@ -545,18 +522,6 @@ void CSimpleFrame::PreLoadXML(XMLNode* node, CStatus* status) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSimpleFrame::GetAttribute(const char* name, int32_t& luaRef) {
|
|
||||||
auto attr = this->m_attributes.Ptr(name);
|
|
||||||
|
|
||||||
if (!attr || attr->luaRef == -1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
luaRef = attr->luaRef;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t CSimpleFrame::GetBoundsRect(CRect& bounds) {
|
int32_t CSimpleFrame::GetBoundsRect(CRect& bounds) {
|
||||||
if (this->IsResizePending()) {
|
if (this->IsResizePending()) {
|
||||||
this->Resize(1);
|
this->Resize(1);
|
||||||
@ -772,69 +737,7 @@ int32_t CSimpleFrame::HideThis() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CSimpleFrame::LoadXML_Attributes(const XMLNode* node, CStatus* status) {
|
void CSimpleFrame::LoadXML_Attributes(const XMLNode* node, CStatus* status) {
|
||||||
auto L = FrameScript_GetContext();
|
// TODO
|
||||||
|
|
||||||
auto child = node->GetChild();
|
|
||||||
|
|
||||||
while (child) {
|
|
||||||
// Unexpected child node
|
|
||||||
if (SStrCmpI(child->GetName(), "Attribute")) {
|
|
||||||
status->Add(STATUS_WARNING, "Frame %s: Unknown attributes element %s", this->GetDisplayName(), child->GetName());
|
|
||||||
child = child->GetSibling();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto attrName = child->GetAttributeByName("name");
|
|
||||||
|
|
||||||
// No attribute name
|
|
||||||
if (!attrName) {
|
|
||||||
status->Add(STATUS_WARNING, "Frame %s: unnamed attribute element", this->GetDisplayName());
|
|
||||||
child = child->GetSibling();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto attrType = child->GetAttributeByName("type");
|
|
||||||
|
|
||||||
if (!attrType) {
|
|
||||||
attrType = "string";
|
|
||||||
}
|
|
||||||
|
|
||||||
auto attrValue = child->GetAttributeByName("value");
|
|
||||||
|
|
||||||
// Missing attribute value for non-nil type
|
|
||||||
if (SStrCmpI(attrType, "nil") && !attrValue) {
|
|
||||||
status->Add(STATUS_WARNING, "Frame %s: attribute element named %s missing value", this->GetDisplayName(), attrName);
|
|
||||||
child = child->GetSibling();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Push attribute value to stack
|
|
||||||
if (!SStrCmpI(attrType, "nil")) {
|
|
||||||
lua_pushnil(L);
|
|
||||||
} else if (!SStrCmpI(attrType, "boolean")) {
|
|
||||||
lua_pushboolean(L, StringToBOOL(attrValue));
|
|
||||||
} else if (!SStrCmpI(attrType, "number")) {
|
|
||||||
lua_pushnumber(L, SStrToFloat(attrValue));
|
|
||||||
} else {
|
|
||||||
lua_pushstring(L, attrValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto attr = this->m_attributes.Ptr(attrName);
|
|
||||||
|
|
||||||
if (attr) {
|
|
||||||
luaL_unref(L, LUA_REGISTRYINDEX, attr->luaRef);
|
|
||||||
} else {
|
|
||||||
attr = this->m_attributes.New(attrName, 0, 0x0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO taint management
|
|
||||||
|
|
||||||
attr->luaRef = luaL_ref(L, LUA_REGISTRYINDEX);
|
|
||||||
|
|
||||||
// TODO taint management
|
|
||||||
|
|
||||||
child = child->GetSibling();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimpleFrame::LoadXML_Backdrop(const XMLNode* node, CStatus* status) {
|
void CSimpleFrame::LoadXML_Backdrop(const XMLNode* node, CStatus* status) {
|
||||||
@ -1414,18 +1317,6 @@ void CSimpleFrame::RemoveFrameRegion(CSimpleRegion* region, uint32_t drawlayer)
|
|||||||
this->NotifyDrawLayerChanged(drawlayer);
|
this->NotifyDrawLayerChanged(drawlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimpleFrame::SetAttribute(const char* name, int32_t luaRef) {
|
|
||||||
auto attr = this->m_attributes.Ptr(name);
|
|
||||||
|
|
||||||
if (!attr) {
|
|
||||||
attr = this->m_attributes.New(name, 0, 0x0);
|
|
||||||
}
|
|
||||||
|
|
||||||
attr->luaRef = luaRef;
|
|
||||||
|
|
||||||
this->RunOnAttributeChangedScript(name, luaRef);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimpleFrame::SetBackdrop(CBackdropGenerator* backdrop) {
|
void CSimpleFrame::SetBackdrop(CBackdropGenerator* backdrop) {
|
||||||
if (this->m_backdrop) {
|
if (this->m_backdrop) {
|
||||||
delete this->m_backdrop;
|
delete this->m_backdrop;
|
||||||
|
|||||||
@ -6,7 +6,6 @@
|
|||||||
#include "ui/CScriptRegion.hpp"
|
#include "ui/CScriptRegion.hpp"
|
||||||
#include "ui/Types.hpp"
|
#include "ui/Types.hpp"
|
||||||
#include "ui/simple/CSimpleRegion.hpp"
|
#include "ui/simple/CSimpleRegion.hpp"
|
||||||
#include <storm/Hash.hpp>
|
|
||||||
#include <storm/List.hpp>
|
#include <storm/List.hpp>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
@ -18,10 +17,6 @@ class CSimpleTitleRegion;
|
|||||||
class CSimpleTop;
|
class CSimpleTop;
|
||||||
struct lua_State;
|
struct lua_State;
|
||||||
|
|
||||||
struct FRAMEATTR : TSHashObject<FRAMEATTR, HASHKEY_STRI> {
|
|
||||||
int32_t luaRef;
|
|
||||||
};
|
|
||||||
|
|
||||||
class CSimpleFrame : public CScriptRegion {
|
class CSimpleFrame : public CScriptRegion {
|
||||||
public:
|
public:
|
||||||
// Static members
|
// Static members
|
||||||
@ -76,7 +71,6 @@ class CSimpleFrame : public CScriptRegion {
|
|||||||
ScriptIx m_onAttributeChange;
|
ScriptIx m_onAttributeChange;
|
||||||
ScriptIx m_onEnable;
|
ScriptIx m_onEnable;
|
||||||
ScriptIx m_onDisable;
|
ScriptIx m_onDisable;
|
||||||
TSHashTable<FRAMEATTR, HASHKEY_STRI> m_attributes;
|
|
||||||
int32_t m_drawenabled[NUM_SIMPLEFRAME_DRAWLAYERS];
|
int32_t m_drawenabled[NUM_SIMPLEFRAME_DRAWLAYERS];
|
||||||
CBackdropGenerator* m_backdrop = nullptr;
|
CBackdropGenerator* m_backdrop = nullptr;
|
||||||
STORM_EXPLICIT_LIST(CSimpleRegion, m_regionLink) m_regions;
|
STORM_EXPLICIT_LIST(CSimpleRegion, m_regionLink) m_regions;
|
||||||
@ -132,7 +126,6 @@ class CSimpleFrame : public CScriptRegion {
|
|||||||
void DisableEvent(CSimpleEventType eventType);
|
void DisableEvent(CSimpleEventType eventType);
|
||||||
void EnableDrawLayer(uint32_t drawlayer);
|
void EnableDrawLayer(uint32_t drawlayer);
|
||||||
void EnableEvent(CSimpleEventType eventType, int32_t priority);
|
void EnableEvent(CSimpleEventType eventType, int32_t priority);
|
||||||
bool GetAttribute(const char* name, int32_t& luaRef);
|
|
||||||
int32_t GetHitRect(CRect& rect);
|
int32_t GetHitRect(CRect& rect);
|
||||||
void Hide();
|
void Hide();
|
||||||
void LoadXML_Attributes(const XMLNode* node, CStatus* status);
|
void LoadXML_Attributes(const XMLNode* node, CStatus* status);
|
||||||
@ -146,7 +139,6 @@ class CSimpleFrame : public CScriptRegion {
|
|||||||
void RegisterForEvents(int32_t a2);
|
void RegisterForEvents(int32_t a2);
|
||||||
void RegisterRegion(CSimpleRegion* region);
|
void RegisterRegion(CSimpleRegion* region);
|
||||||
void RemoveFrameRegion(CSimpleRegion* region, uint32_t drawlayer);
|
void RemoveFrameRegion(CSimpleRegion* region, uint32_t drawlayer);
|
||||||
void RunOnAttributeChangedScript(const char* name, int32_t luaRef);
|
|
||||||
void RunOnCharScript(const char* chr);
|
void RunOnCharScript(const char* chr);
|
||||||
void RunOnEnableScript();
|
void RunOnEnableScript();
|
||||||
void RunOnEnterScript(int32_t a2);
|
void RunOnEnterScript(int32_t a2);
|
||||||
@ -160,7 +152,6 @@ class CSimpleFrame : public CScriptRegion {
|
|||||||
void RunOnShowScript();
|
void RunOnShowScript();
|
||||||
void RunOnSizeChangedScript(float width, float height);
|
void RunOnSizeChangedScript(float width, float height);
|
||||||
void RunOnUpdateScript(float elapsedSec);
|
void RunOnUpdateScript(float elapsedSec);
|
||||||
void SetAttribute(const char* name, int32_t luaRef);
|
|
||||||
void SetBackdrop(CBackdropGenerator* backdrop);
|
void SetBackdrop(CBackdropGenerator* backdrop);
|
||||||
void SetBeingScrolled(int32_t a2, int32_t a3);
|
void SetBeingScrolled(int32_t a2, int32_t a3);
|
||||||
void SetFrameAlpha(uint8_t alpha);
|
void SetFrameAlpha(uint8_t alpha);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user