mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-18 21:51:06 +03:00
Compare commits
10 Commits
516e4548f4
...
8536130f8c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8536130f8c | ||
|
|
3d8073cf75 | ||
|
|
bdce266205 | ||
|
|
c099226cd2 | ||
|
|
ae64833a5c | ||
|
|
728d13b216 | ||
|
|
f42416bd0b | ||
|
|
b076c2c573 | ||
|
|
0962e5952e | ||
|
|
4a102c6ace |
@ -47,6 +47,7 @@ float CGlueMgr::m_aspect;
|
|||||||
bool CGlueMgr::m_authenticated;
|
bool CGlueMgr::m_authenticated;
|
||||||
const CharacterSelectionDisplay* CGlueMgr::m_characterInfo;
|
const CharacterSelectionDisplay* CGlueMgr::m_characterInfo;
|
||||||
int32_t CGlueMgr::m_clientKickReason;
|
int32_t CGlueMgr::m_clientKickReason;
|
||||||
|
int32_t CGlueMgr::m_contestAccepted = 1; // TODO
|
||||||
char CGlueMgr::m_currentScreen[64];
|
char CGlueMgr::m_currentScreen[64];
|
||||||
EffectDeath* CGlueMgr::m_deathEffect;
|
EffectDeath* CGlueMgr::m_deathEffect;
|
||||||
int32_t CGlueMgr::m_disconnectPending;
|
int32_t CGlueMgr::m_disconnectPending;
|
||||||
|
|||||||
@ -41,6 +41,7 @@ class CGlueMgr {
|
|||||||
static bool m_authenticated;
|
static bool m_authenticated;
|
||||||
static const CharacterSelectionDisplay* m_characterInfo;
|
static const CharacterSelectionDisplay* m_characterInfo;
|
||||||
static int32_t m_clientKickReason;
|
static int32_t m_clientKickReason;
|
||||||
|
static int32_t m_contestAccepted;
|
||||||
static char m_currentScreen[];
|
static char m_currentScreen[];
|
||||||
static EffectDeath* m_deathEffect;
|
static EffectDeath* m_deathEffect;
|
||||||
static int32_t m_disconnectPending;
|
static int32_t m_disconnectPending;
|
||||||
|
|||||||
@ -222,7 +222,14 @@ int32_t Script_ShowContestNotice(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_ContestAccepted(lua_State* L) {
|
int32_t Script_ContestAccepted(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
if (CGlueMgr::m_contestAccepted) {
|
||||||
|
lua_pushnumber(L, 1.0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lua_pushnil(L);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_AcceptContest(lua_State* L) {
|
int32_t Script_AcceptContest(lua_State* L) {
|
||||||
|
|||||||
@ -16,4 +16,5 @@ target_include_directories(object
|
|||||||
target_link_libraries(object
|
target_link_libraries(object
|
||||||
PRIVATE
|
PRIVATE
|
||||||
db
|
db
|
||||||
|
ui
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
#include "ui/game/ScriptEvents.hpp"
|
#include "ui/game/ScriptEvents.hpp"
|
||||||
#include "object/client/ObjMgr.hpp"
|
#include "db/Db.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 {
|
||||||
@ -707,7 +709,29 @@ int32_t Script_IsXPUserDisabled(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t Script_FillLocalizedClassList(lua_State* L) {
|
int32_t Script_FillLocalizedClassList(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
if (lua_type(L, 1) != LUA_TTABLE) {
|
||||||
|
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,7 +372,18 @@ int32_t CSimpleButton_GetTextWidth(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleButton_GetTextHeight(lua_State* L) {
|
int32_t CSimpleButton_GetTextHeight(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
auto type = CSimpleButton::GetObjectType();
|
||||||
|
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,7 +162,17 @@ int32_t CSimpleFontString_SetFont(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFontString_GetText(lua_State* L) {
|
int32_t CSimpleFontString_GetText(lua_State* L) {
|
||||||
WHOA_UNIMPLEMENTED(0);
|
auto type = CSimpleFontString::GetObjectType();
|
||||||
|
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,6 +376,29 @@ 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();
|
||||||
@ -522,6 +545,18 @@ 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);
|
||||||
@ -737,7 +772,69 @@ int32_t CSimpleFrame::HideThis() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CSimpleFrame::LoadXML_Attributes(const XMLNode* node, CStatus* status) {
|
void CSimpleFrame::LoadXML_Attributes(const XMLNode* node, CStatus* status) {
|
||||||
// TODO
|
auto L = FrameScript_GetContext();
|
||||||
|
|
||||||
|
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) {
|
||||||
@ -1317,6 +1414,18 @@ 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,6 +6,7 @@
|
|||||||
#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>
|
||||||
|
|
||||||
@ -17,6 +18,10 @@ 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
|
||||||
@ -71,6 +76,7 @@ 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;
|
||||||
@ -126,6 +132,7 @@ 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);
|
||||||
@ -139,6 +146,7 @@ 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);
|
||||||
@ -152,6 +160,7 @@ 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