mirror of
https://github.com/whoahq/whoa.git
synced 2026-03-18 13:41:06 +03:00
Compare commits
10 Commits
66df4c55da
...
c604ae6d19
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c604ae6d19 | ||
|
|
17198939da | ||
|
|
121f41d6b8 | ||
|
|
0d001d4b3f | ||
|
|
e175894099 | ||
|
|
39bf2f5ad4 | ||
|
|
8e67adc15f | ||
|
|
8da307593d | ||
|
|
4d003129be | ||
|
|
d210df2f43 |
@ -193,6 +193,25 @@ int32_t FrameScript_Object::SetScript(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FrameScript_Object::UnregisterScriptEvent(const char* name) {
|
||||
auto event = FrameScript::s_scriptEventsHash.Ptr(name);
|
||||
|
||||
if (!event) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->pendingSignalCount) {
|
||||
for (auto node = event->registerListeners.Head(); node; node = event->registerListeners.Next(node)) {
|
||||
if (node->listener == this) {
|
||||
event->registerListeners.DeleteNode(node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FrameScript_UnregisterScriptEvent(this, event);
|
||||
}
|
||||
|
||||
void FrameScript_Object::UnregisterScriptObject(const char* name) {
|
||||
auto L = FrameScript_GetContext();
|
||||
|
||||
|
||||
@ -48,6 +48,7 @@ class FrameScript_Object {
|
||||
void RegisterScriptObject(const char* name);
|
||||
void RunScript(ScriptIx const& script, int32_t argCount, const char* a4);
|
||||
int32_t SetScript(lua_State* L);
|
||||
void UnregisterScriptEvent(const char* name);
|
||||
void UnregisterScriptObject(const char* name);
|
||||
};
|
||||
|
||||
|
||||
@ -19,6 +19,8 @@
|
||||
#include "ui/game/CharacterInfoScript.hpp"
|
||||
#include "ui/game/GMTicketInfoScript.hpp"
|
||||
#include "ui/game/GameScript.hpp"
|
||||
#include "ui/game/PartyInfoScript.hpp"
|
||||
#include "ui/game/RaidInfoScript.hpp"
|
||||
#include "ui/game/ScriptEvents.hpp"
|
||||
#include "ui/game/TradeInfoScript.hpp"
|
||||
#include "ui/game/Types.hpp"
|
||||
@ -56,6 +58,7 @@ void LoadScriptFunctions() {
|
||||
// TODO
|
||||
|
||||
ActionBarRegisterScriptFunctions();
|
||||
PartyInfoRegisterScriptFunctions();
|
||||
|
||||
// TODO
|
||||
|
||||
@ -71,6 +74,10 @@ void LoadScriptFunctions() {
|
||||
|
||||
// TODO
|
||||
|
||||
RaidInfoRegisterScriptFunctions();
|
||||
|
||||
// TODO
|
||||
|
||||
GMTicketInfoRegisterScriptFunctions();
|
||||
BattlenetUI_RegisterScriptFunctions();
|
||||
}
|
||||
|
||||
15
src/ui/game/CGPartyInfo.cpp
Normal file
15
src/ui/game/CGPartyInfo.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
#include "ui/game/CGPartyInfo.hpp"
|
||||
|
||||
WOWGUID CGPartyInfo::m_members[4];
|
||||
|
||||
uint32_t CGPartyInfo::NumMembers() {
|
||||
uint32_t count = 0;
|
||||
|
||||
for (auto& member : CGPartyInfo::m_members) {
|
||||
if (member != 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
16
src/ui/game/CGPartyInfo.hpp
Normal file
16
src/ui/game/CGPartyInfo.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef UI_GAME_C_G_PARTY_INFO_HPP
|
||||
#define UI_GAME_C_G_PARTY_INFO_HPP
|
||||
|
||||
#include "util/GUID.hpp"
|
||||
|
||||
class CGPartyInfo {
|
||||
public:
|
||||
// Public static functions
|
||||
static uint32_t NumMembers();
|
||||
|
||||
private:
|
||||
// Private static variables
|
||||
static WOWGUID m_members[];
|
||||
};
|
||||
|
||||
#endif
|
||||
7
src/ui/game/CGRaidInfo.cpp
Normal file
7
src/ui/game/CGRaidInfo.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "ui/game/CGRaidInfo.hpp"
|
||||
|
||||
uint32_t CGRaidInfo::s_numMembers;
|
||||
|
||||
uint32_t CGRaidInfo::NumMembers() {
|
||||
return CGRaidInfo::s_numMembers;
|
||||
}
|
||||
16
src/ui/game/CGRaidInfo.hpp
Normal file
16
src/ui/game/CGRaidInfo.hpp
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef UI_GAME_C_G_RAID_INFO_HPP
|
||||
#define UI_GAME_C_G_RAID_INFO_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class CGRaidInfo {
|
||||
public:
|
||||
// Public static functions
|
||||
static uint32_t NumMembers();
|
||||
|
||||
private:
|
||||
// Private static variables
|
||||
static uint32_t s_numMembers;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -206,7 +206,22 @@ int32_t Script_GetCVarBool(lua_State* L) {
|
||||
}
|
||||
|
||||
int32_t Script_GetCVarDefault(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
if (!lua_isstring(L, 1)) {
|
||||
luaL_error(L, "Usage: GetCVarDefault(\"cvar\")");
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto varName = lua_tostring(L, 1);
|
||||
auto var = CVar::LookupRegistered(varName);
|
||||
|
||||
if (!var || (var->m_flags & 0x40)) {
|
||||
luaL_error(L, "Couldn't find CVar named '%s'", varName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
lua_pushstring(L, var->GetDefaultValue());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t Script_GetCVarMin(lua_State* L) {
|
||||
|
||||
130
src/ui/game/PartyInfoScript.cpp
Normal file
130
src/ui/game/PartyInfoScript.cpp
Normal file
@ -0,0 +1,130 @@
|
||||
#include "ui/game/PartyInfoScript.hpp"
|
||||
#include "ui/FrameScript.hpp"
|
||||
#include "ui/game/CGPartyInfo.hpp"
|
||||
#include "util/Lua.hpp"
|
||||
#include "util/Unimplemented.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
int32_t Script_GetNumPartyMembers(lua_State* L) {
|
||||
lua_pushnumber(L, CGPartyInfo::NumMembers());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t Script_GetRealNumPartyMembers(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetPartyMember(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetPartyLeaderIndex(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_IsPartyLeader(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_IsRealPartyLeader(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_LeaveParty(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetLootMethod(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_SetLootMethod(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetLootThreshold(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_SetLootThreshold(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_SetPartyAssignment(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_ClearPartyAssignment(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetPartyAssignment(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_SilenceMember(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_UnSilenceMember(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_SetOptOutOfLoot(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetOptOutOfLoot(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_CanChangePlayerDifficulty(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_ChangePlayerDifficulty(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_IsPartyLFG(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_HasLFGRestrictions(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static FrameScript_Method s_ScriptFunctions[] = {
|
||||
{ "GetNumPartyMembers", &Script_GetNumPartyMembers },
|
||||
{ "GetRealNumPartyMembers", &Script_GetRealNumPartyMembers },
|
||||
{ "GetPartyMember", &Script_GetPartyMember },
|
||||
{ "GetPartyLeaderIndex", &Script_GetPartyLeaderIndex },
|
||||
{ "IsPartyLeader", &Script_IsPartyLeader },
|
||||
{ "IsRealPartyLeader", &Script_IsRealPartyLeader },
|
||||
{ "LeaveParty", &Script_LeaveParty },
|
||||
{ "GetLootMethod", &Script_GetLootMethod },
|
||||
{ "SetLootMethod", &Script_SetLootMethod },
|
||||
{ "GetLootThreshold", &Script_GetLootThreshold },
|
||||
{ "SetLootThreshold", &Script_SetLootThreshold },
|
||||
{ "SetPartyAssignment", &Script_SetPartyAssignment },
|
||||
{ "ClearPartyAssignment", &Script_ClearPartyAssignment },
|
||||
{ "GetPartyAssignment", &Script_GetPartyAssignment },
|
||||
{ "SilenceMember", &Script_SilenceMember },
|
||||
{ "UnSilenceMember", &Script_UnSilenceMember },
|
||||
{ "SetOptOutOfLoot", &Script_SetOptOutOfLoot },
|
||||
{ "GetOptOutOfLoot", &Script_GetOptOutOfLoot },
|
||||
{ "CanChangePlayerDifficulty", &Script_CanChangePlayerDifficulty },
|
||||
{ "ChangePlayerDifficulty", &Script_ChangePlayerDifficulty },
|
||||
{ "IsPartyLFG", &Script_IsPartyLFG },
|
||||
{ "HasLFGRestrictions", &Script_HasLFGRestrictions },
|
||||
};
|
||||
|
||||
void PartyInfoRegisterScriptFunctions() {
|
||||
for (auto& func : s_ScriptFunctions) {
|
||||
FrameScript_RegisterFunction(func.name, func.method);
|
||||
}
|
||||
}
|
||||
6
src/ui/game/PartyInfoScript.hpp
Normal file
6
src/ui/game/PartyInfoScript.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef UI_GAME_PARTY_INFO_SCRIPT_HPP
|
||||
#define UI_GAME_PARTY_INFO_SCRIPT_HPP
|
||||
|
||||
void PartyInfoRegisterScriptFunctions();
|
||||
|
||||
#endif
|
||||
120
src/ui/game/RaidInfoScript.cpp
Normal file
120
src/ui/game/RaidInfoScript.cpp
Normal file
@ -0,0 +1,120 @@
|
||||
#include "ui/game/RaidInfoScript.hpp"
|
||||
#include "ui/FrameScript.hpp"
|
||||
#include "ui/game/CGRaidInfo.hpp"
|
||||
#include "util/Lua.hpp"
|
||||
#include "util/Unimplemented.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
int32_t Script_GetNumRaidMembers(lua_State* L) {
|
||||
lua_pushnumber(L, CGRaidInfo::NumMembers());
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t Script_GetRealNumRaidMembers(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetRaidRosterInfo(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_SetRaidRosterSelection(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetRaidRosterSelection(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_IsRaidLeader(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_IsRealRaidLeader(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_IsRaidOfficer(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_SetRaidSubgroup(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_SwapRaidSubgroup(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_ConvertToRaid(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_PromoteToLeader(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_PromoteToAssistant(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_DemoteAssistant(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_SetRaidTarget(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetRaidTargetIndex(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_DoReadyCheck(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_ConfirmReadyCheck(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetReadyCheckTimeLeft(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
int32_t Script_GetReadyCheckStatus(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static FrameScript_Method s_ScriptFunctions[] = {
|
||||
{ "GetNumRaidMembers", &Script_GetNumRaidMembers },
|
||||
{ "GetRealNumRaidMembers", &Script_GetRealNumRaidMembers },
|
||||
{ "GetRaidRosterInfo", &Script_GetRaidRosterInfo },
|
||||
{ "SetRaidRosterSelection", &Script_SetRaidRosterSelection },
|
||||
{ "GetRaidRosterSelection", &Script_GetRaidRosterSelection },
|
||||
{ "IsRaidLeader", &Script_IsRaidLeader },
|
||||
{ "IsRealRaidLeader", &Script_IsRealRaidLeader },
|
||||
{ "IsRaidOfficer", &Script_IsRaidOfficer },
|
||||
{ "SetRaidSubgroup", &Script_SetRaidSubgroup },
|
||||
{ "SwapRaidSubgroup", &Script_SwapRaidSubgroup },
|
||||
{ "ConvertToRaid", &Script_ConvertToRaid },
|
||||
{ "PromoteToLeader", &Script_PromoteToLeader },
|
||||
{ "PromoteToAssistant", &Script_PromoteToAssistant },
|
||||
{ "DemoteAssistant", &Script_DemoteAssistant },
|
||||
{ "SetRaidTarget", &Script_SetRaidTarget },
|
||||
{ "GetRaidTargetIndex", &Script_GetRaidTargetIndex },
|
||||
{ "DoReadyCheck", &Script_DoReadyCheck },
|
||||
{ "ConfirmReadyCheck", &Script_ConfirmReadyCheck },
|
||||
{ "GetReadyCheckTimeLeft", &Script_GetReadyCheckTimeLeft },
|
||||
{ "GetReadyCheckStatus", &Script_GetReadyCheckStatus },
|
||||
};
|
||||
|
||||
void RaidInfoRegisterScriptFunctions() {
|
||||
for (auto& func : s_ScriptFunctions) {
|
||||
FrameScript_RegisterFunction(func.name, func.method);
|
||||
}
|
||||
}
|
||||
6
src/ui/game/RaidInfoScript.hpp
Normal file
6
src/ui/game/RaidInfoScript.hpp
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef UI_GAME_RAID_INFO_SCRIPT_HPP
|
||||
#define UI_GAME_RAID_INFO_SCRIPT_HPP
|
||||
|
||||
void RaidInfoRegisterScriptFunctions();
|
||||
|
||||
#endif
|
||||
@ -3,6 +3,8 @@
|
||||
#include "ui/CBackdropGenerator.hpp"
|
||||
#include "ui/FrameScript.hpp"
|
||||
#include "ui/FrameXML.hpp"
|
||||
#include "ui/simple/CSimpleFont.hpp"
|
||||
#include "ui/simple/CSimpleFontString.hpp"
|
||||
#include "ui/simple/CSimpleFrame.hpp"
|
||||
#include "ui/simple/CSimpleTexture.hpp"
|
||||
#include "util/Lua.hpp"
|
||||
@ -85,7 +87,73 @@ int32_t CSimpleFrame_CreateTexture(lua_State* L) {
|
||||
}
|
||||
|
||||
int32_t CSimpleFrame_CreateFontString(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
auto type = CSimpleFrame::GetObjectType();
|
||||
auto frame = static_cast<CSimpleFrame*>(FrameScript_GetObjectThis(L, type));
|
||||
|
||||
const char* name = nullptr;
|
||||
if (lua_isstring(L, 2)) {
|
||||
name = lua_tostring(L, 2);
|
||||
}
|
||||
|
||||
int32_t drawlayer = DRAWLAYER_ARTWORK;
|
||||
if (lua_isstring(L, 3)) {
|
||||
auto drawlayerStr = lua_tostring(L, 3);
|
||||
StringToDrawLayer(drawlayerStr, drawlayer);
|
||||
}
|
||||
|
||||
CSimpleFont* inheritFont = nullptr;
|
||||
XMLNode* inheritNode = nullptr;
|
||||
|
||||
if (lua_type(L, 4) == LUA_TSTRING) {
|
||||
auto inheritName = lua_tostring(L, 4);
|
||||
|
||||
inheritFont = CSimpleFont::GetFont(inheritName, 0);
|
||||
|
||||
if (!inheritFont) {
|
||||
const char* tainted;
|
||||
bool locked;
|
||||
inheritNode = FrameXML_AcquireHashNode(inheritName, tainted, locked);
|
||||
|
||||
if (!inheritNode) {
|
||||
luaL_error(L, "%s:CreateFontString(): Couldn't find inherited node \"%s\"", frame->GetDisplayName(), inheritName);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (locked) {
|
||||
luaL_error(L, "%s:CreateFontString(): Recursively inherited node \"%s\"", frame->GetDisplayName(), inheritName);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO CDataAllocator::GetData
|
||||
auto string = STORM_NEW(CSimpleFontString)(frame, drawlayer, true);
|
||||
|
||||
if (name && *name) {
|
||||
string->SetName(name);
|
||||
}
|
||||
|
||||
if (inheritFont) {
|
||||
string->SetFontObject(inheritFont);
|
||||
} else if (inheritNode) {
|
||||
CStatus status;
|
||||
|
||||
string->LoadXML(inheritNode, &status);
|
||||
string->PostLoadXML(inheritNode, &status);
|
||||
|
||||
auto inheritName = lua_tostring(L, 4);
|
||||
FrameXML_ReleaseHashNode(inheritName);
|
||||
}
|
||||
|
||||
// TODO anim related logic?
|
||||
|
||||
if (!string->lua_registered) {
|
||||
string->RegisterScriptObject(nullptr);
|
||||
}
|
||||
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, string->lua_objectRef);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int32_t CSimpleFrame_GetBoundsRect(lua_State* L) {
|
||||
@ -221,7 +289,19 @@ int32_t CSimpleFrame_RegisterEvent(lua_State* L) {
|
||||
}
|
||||
|
||||
int32_t CSimpleFrame_UnregisterEvent(lua_State* L) {
|
||||
WHOA_UNIMPLEMENTED(0);
|
||||
auto type = CSimpleFrame::GetObjectType();
|
||||
auto frame = static_cast<CSimpleFrame*>(FrameScript_GetObjectThis(L, type));
|
||||
|
||||
if (!lua_isstring(L, 2)) {
|
||||
luaL_error(L, "Usage: %s:UnregisterEvent(\"event\")", frame->GetDisplayName());
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto eventName = lua_tostring(L, 2);
|
||||
|
||||
frame->UnregisterScriptEvent(eventName);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t CSimpleFrame_RegisterAllEvents(lua_State* L) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user