mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-08 18:36:00 +03:00
Compare commits
No commits in common. "9d2b94b0cdc5e5638a579419f65fb601401a511f" and "ff2a0da2544a88216b130ba970f8eaa1b595ec9d" have entirely different histories.
9d2b94b0cd
...
ff2a0da254
@ -1,5 +1,4 @@
|
|||||||
#include "gameui/CGTooltipScript.hpp"
|
#include "gameui/CGTooltipScript.hpp"
|
||||||
#include "gameui/CGTooltip.hpp"
|
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
|
|
||||||
@ -24,40 +23,11 @@ static int32_t Script_GetPadding(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_IsOwned(lua_State* L) {
|
static int32_t Script_IsOwned(lua_State* L) {
|
||||||
auto type = CGTooltip::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto tooltip = static_cast<CGTooltip*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
|
|
||||||
if (lua_type(L, 2) != LUA_TTABLE) {
|
|
||||||
return luaL_error(L, "Usage: %s:IsOwned(frame)", tooltip->GetDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_rawgeti(L, 2, 0);
|
|
||||||
auto frame = static_cast<CScriptObject*>(lua_touserdata(L, -1));
|
|
||||||
lua_settop(L, -2);
|
|
||||||
|
|
||||||
if (!frame) {
|
|
||||||
return luaL_error(L, "%s:IsOwned(): Couldn't find 'this' in frame object", tooltip->GetDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!frame->IsA(CSimpleFrame::GetObjectType())) {
|
|
||||||
return luaL_error(L, "%s:IsOwned(): Wrong object type, expected frame", tooltip->GetDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tooltip->m_parent == frame) {
|
|
||||||
lua_pushnumber(L, 1.0);
|
|
||||||
} else {
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_GetOwner(lua_State* L) {
|
static int32_t Script_GetOwner(lua_State* L) {
|
||||||
auto type = CGTooltip::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto tooltip = static_cast<CGTooltip*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
lua_pushnil(L);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_SetOwner(lua_State* L) {
|
static int32_t Script_SetOwner(lua_State* L) {
|
||||||
|
|||||||
@ -20,7 +20,6 @@
|
|||||||
void RegisterSimpleFrameScriptMethods();
|
void RegisterSimpleFrameScriptMethods();
|
||||||
int32_t Script_GetScreenWidth(lua_State* L);
|
int32_t Script_GetScreenWidth(lua_State* L);
|
||||||
int32_t Script_GetScreenHeight(lua_State* L);
|
int32_t Script_GetScreenHeight(lua_State* L);
|
||||||
int32_t Script_GetCursorPosition(lua_State* L);
|
|
||||||
|
|
||||||
|
|
||||||
static int32_t Script_FrameXML_Debug(lua_State* L) {
|
static int32_t Script_FrameXML_Debug(lua_State* L) {
|
||||||
@ -742,6 +741,10 @@ static int32_t Script_CancelSummon(lua_State* L) {
|
|||||||
WHOA_UNIMPLEMENTED(0);
|
WHOA_UNIMPLEMENTED(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t Script_GetCursorPosition(lua_State* L) {
|
||||||
|
WHOA_UNIMPLEMENTED(0);
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t Script_GetNetStats(lua_State* L) {
|
static int32_t Script_GetNetStats(lua_State* L) {
|
||||||
// v1 = ClientServices__Connection();
|
// v1 = ClientServices__Connection();
|
||||||
// NetClient__GetNetStats(v1, &v5, &v4, (int*)&v3);
|
// NetClient__GetNetStats(v1, &v5, &v4, (int*)&v3);
|
||||||
@ -1150,17 +1153,11 @@ static int32_t Script_IsAddOnLoadOnDemand(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_IsAddOnLoaded(lua_State* L) {
|
static int32_t Script_IsAddOnLoaded(lua_State* L) {
|
||||||
// TODO
|
WHOA_UNIMPLEMENTED(0);
|
||||||
lua_pushnil(L);
|
|
||||||
lua_pushnil(L);
|
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_LoadAddOn(lua_State* L) {
|
static int32_t Script_LoadAddOn(lua_State* L) {
|
||||||
// TODO
|
WHOA_UNIMPLEMENTED(0);
|
||||||
lua_pushnil(L);
|
|
||||||
lua_pushstring(L, "UNKNOWN_ERROR");
|
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_PartialPlayTime(lua_State* L) {
|
static int32_t Script_PartialPlayTime(lua_State* L) {
|
||||||
|
|||||||
@ -105,8 +105,7 @@ static int32_t Script_GetBattlefieldStatData(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_RequestBattlefieldPositions(lua_State* L) {
|
static int32_t Script_RequestBattlefieldPositions(lua_State* L) {
|
||||||
// TODO: sub_54CF60
|
WHOA_UNIMPLEMENTED(0);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_GetNumBattlefieldPositions(lua_State* L) {
|
static int32_t Script_GetNumBattlefieldPositions(lua_State* L) {
|
||||||
|
|||||||
@ -161,14 +161,7 @@ static int32_t Script_ClearInspectPlayer(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_GetWeaponEnchantInfo(lua_State* L) {
|
static int32_t Script_GetWeaponEnchantInfo(lua_State* L) {
|
||||||
// TODO
|
WHOA_UNIMPLEMENTED(0);
|
||||||
lua_pushnil(L);
|
|
||||||
lua_pushnil(L);
|
|
||||||
lua_pushnil(L);
|
|
||||||
lua_pushnil(L);
|
|
||||||
lua_pushnil(L);
|
|
||||||
lua_pushnil(L);
|
|
||||||
return 6;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_HasWandEquipped(lua_State* L) {
|
static int32_t Script_HasWandEquipped(lua_State* L) {
|
||||||
|
|||||||
@ -257,9 +257,7 @@ static int32_t Script_UnitIsDeadOrGhost(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_UnitIsConnected(lua_State* L) {
|
static int32_t Script_UnitIsConnected(lua_State* L) {
|
||||||
// TODO
|
WHOA_UNIMPLEMENTED(0);
|
||||||
lua_pushnil(L);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_UnitAffectingCombat(lua_State* L) {
|
static int32_t Script_UnitAffectingCombat(lua_State* L) {
|
||||||
|
|||||||
@ -64,10 +64,6 @@ bool CScriptRegion::IsDragging() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CScriptRegion::IsMouseOver(float a1, float a2, float a3, float a4) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CScriptRegion::LoadXML(XMLNode* node, CStatus* status) {
|
void CScriptRegion::LoadXML(XMLNode* node, CStatus* status) {
|
||||||
CLayoutFrame::LoadXML(node, status);
|
CLayoutFrame::LoadXML(node, status);
|
||||||
|
|
||||||
|
|||||||
@ -29,7 +29,6 @@ class CScriptRegion : public CScriptObject, public CLayoutFrame {
|
|||||||
virtual bool IsA(const char* typeName);
|
virtual bool IsA(const char* typeName);
|
||||||
virtual const char* GetObjectTypeName();
|
virtual const char* GetObjectTypeName();
|
||||||
virtual bool IsDragging();
|
virtual bool IsDragging();
|
||||||
virtual bool IsMouseOver(float a1, float a2, float a3, float a4);
|
|
||||||
virtual void PreOnAnimUpdate() {};
|
virtual void PreOnAnimUpdate() {};
|
||||||
virtual void OnLayerUpdate(float elapsedSec);
|
virtual void OnLayerUpdate(float elapsedSec);
|
||||||
virtual void NotifyAnimBegin(CSimpleAnimGroup* animGroup);
|
virtual void NotifyAnimBegin(CSimpleAnimGroup* animGroup);
|
||||||
|
|||||||
@ -518,23 +518,7 @@ int32_t CScriptRegion_IsDragging(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CScriptRegion_IsMouseOver(lua_State* L) {
|
int32_t CScriptRegion_IsMouseOver(lua_State* L) {
|
||||||
int32_t type = CScriptRegion::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto region = static_cast<CScriptRegion*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
|
|
||||||
float rect[4];
|
|
||||||
for (int32_t i = 0; i < 4; ++i) {
|
|
||||||
if (lua_isnumber(L, i + 2)) {
|
|
||||||
rect[i] = lua_tonumber(L, i + 2);
|
|
||||||
rect[i] /= CoordinateGetAspectCompensation() * 1024.0f;
|
|
||||||
rect[i] = NDCToDDCWidth(rect[i]);
|
|
||||||
} else {
|
|
||||||
rect[i] = 0.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto result = region->IsMouseOver(rect[0], rect[1], rect[2], rect[3]);
|
|
||||||
lua_pushboolean(L, result);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameScript_Method ScriptRegionMethods[NUM_SCRIPT_REGION_SCRIPT_METHODS] = {
|
FrameScript_Method ScriptRegionMethods[NUM_SCRIPT_REGION_SCRIPT_METHODS] = {
|
||||||
|
|||||||
@ -71,10 +71,7 @@ int32_t CSimpleButton_Disable(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleButton_IsEnabled(lua_State* L) {
|
int32_t CSimpleButton_IsEnabled(lua_State* L) {
|
||||||
auto type = CSimpleButton::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto button = static_cast<CSimpleButton*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
lua_pushnumber(L, button->GetButtonState() != BUTTONSTATE_DISABLED);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleButton_GetButtonState(lua_State* L) {
|
int32_t CSimpleButton_GetButtonState(lua_State* L) {
|
||||||
|
|||||||
@ -56,25 +56,11 @@ int32_t CSimpleFontString_Hide(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFontString_IsVisible(lua_State* L) {
|
int32_t CSimpleFontString_IsVisible(lua_State* L) {
|
||||||
auto type = CSimpleFontString::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto string = static_cast<CSimpleFontString*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
if (string->m_visible) {
|
|
||||||
lua_pushnumber(L, 1.0);
|
|
||||||
} else {
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFontString_IsShown(lua_State* L) {
|
int32_t CSimpleFontString_IsShown(lua_State* L) {
|
||||||
auto type = CSimpleFontString::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto string = static_cast<CSimpleFontString*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
if (string->m_shown) {
|
|
||||||
lua_pushnumber(L, 1.0);
|
|
||||||
} else {
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleFontString_GetFontObject(lua_State* L) {
|
int32_t CSimpleFontString_GetFontObject(lua_State* L) {
|
||||||
|
|||||||
@ -1,10 +1,5 @@
|
|||||||
#include "ui/CSimpleStatusBar.hpp"
|
#include "ui/CSimpleStatusBar.hpp"
|
||||||
#include "ui/CSimpleStatusBarScript.hpp"
|
#include "ui/CSimpleStatusBarScript.hpp"
|
||||||
#include "ui/CSimpleTexture.hpp"
|
|
||||||
#include "ui/LoadXML.hpp"
|
|
||||||
#include "util/Lua.hpp"
|
|
||||||
#include "util/StringTo.hpp"
|
|
||||||
#include <common/XML.hpp>
|
|
||||||
|
|
||||||
int32_t CSimpleStatusBar::s_metatable = 0;
|
int32_t CSimpleStatusBar::s_metatable = 0;
|
||||||
int32_t CSimpleStatusBar::s_objectType = 0;
|
int32_t CSimpleStatusBar::s_objectType = 0;
|
||||||
@ -37,114 +32,6 @@ void CSimpleStatusBar::SetOrientation(uint32_t orientation) {
|
|||||||
this->m_orientation = orientation;
|
this->m_orientation = orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimpleStatusBar::SetMinMaxValues(float minValue, float maxValue) {
|
|
||||||
if ((this->m_flags & 2) != 0 && this->m_minValue == minValue && this->m_maxValue == maxValue) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->m_flags |= 3;
|
|
||||||
this->m_minValue = minValue;
|
|
||||||
this->m_maxValue = maxValue;
|
|
||||||
this->RunOnMinMaxChanged();
|
|
||||||
|
|
||||||
if (this->m_flags & 4) {
|
|
||||||
this->SetValue(this->m_value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimpleStatusBar::SetBarTexture(const char* texFile, int32_t layer) {
|
|
||||||
if (this->m_barTexture) {
|
|
||||||
this->m_barTexture->SetTexture(texFile, false, false, GxTex_Linear, ImageMode_UI);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: CDataAllocator__GetData(CSimpleTexture::s_allocator, 0, ".?AVCSimpleTexture@@", -2);
|
|
||||||
auto texture = NEW(CSimpleTexture, nullptr, DRAWLAYER_ARTWORK, 0);
|
|
||||||
if (texture->SetTexture(texFile, false, false, GxTex_Linear, ImageMode_UI)) {
|
|
||||||
texture->SetAllPoints(this, 1);
|
|
||||||
texture->SetBlendMode(GxBlend_Add);
|
|
||||||
this->SetBarTexture(texture, layer);
|
|
||||||
} else if (texture) {
|
|
||||||
// TODO: FrameScript_Object::LookupScriptMethod(texture, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimpleStatusBar::SetBarTexture(CSimpleTexture* texture, int32_t layer) {
|
|
||||||
if (texture == this->m_barTexture) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->m_barTexture) {
|
|
||||||
// TODO: FrameScript_Object::LookupScriptMethod(this->m_checkedTexture, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (texture) {
|
|
||||||
texture->SetFrame(this, layer, 1);
|
|
||||||
texture->SetPoint(FRAMEPOINT_BOTTOMLEFT, this, FRAMEPOINT_BOTTOMLEFT, 0.0f, 0.0f, 1);
|
|
||||||
texture->SetPoint(FRAMEPOINT_BOTTOMRIGHT, this, FRAMEPOINT_BOTTOMRIGHT, 0.0f, 0.0f, 1);
|
|
||||||
texture->SetPoint(FRAMEPOINT_TOPLEFT, this, FRAMEPOINT_TOPLEFT, 0.0f, 0.0f, 1);
|
|
||||||
texture->SetPoint(FRAMEPOINT_TOPRIGHT, this, FRAMEPOINT_TOPRIGHT, 0.0f, 0.0f, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->m_flags |= 1;
|
|
||||||
this->m_barTexture = texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimpleStatusBar::SetRotatesTexture(bool rotates) {
|
|
||||||
if (rotates) {
|
|
||||||
C2Vector v[4] = {
|
|
||||||
{ 0.0f, 1.0f },
|
|
||||||
{ 1.0f, 1.0f },
|
|
||||||
{ 0.0f, 0.0f },
|
|
||||||
{ 1.0f, 0.0f }
|
|
||||||
};
|
|
||||||
|
|
||||||
this->m_barTexture->SetTexCoord(v);
|
|
||||||
this->m_flags = this->m_flags ^ (this->m_flags ^ 8) & 8 | 1;
|
|
||||||
} else {
|
|
||||||
CRect r(0.0f, 0.0f, 1.0f, 1.0f);
|
|
||||||
this->m_barTexture->SetTexCoord(r);
|
|
||||||
this->m_flags = this->m_flags ^ (this->m_flags ^ 0) & 8 | 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimpleStatusBar::RunOnMinMaxChanged() {
|
|
||||||
if (this->m_onMinMaxChanged.luaRef) {
|
|
||||||
auto L = FrameScript_GetContext();
|
|
||||||
lua_pushnumber(L, this->m_minValue);
|
|
||||||
lua_pushnumber(L, this->m_maxValue);
|
|
||||||
this->RunScript(this->m_onMinMaxChanged, 2, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimpleStatusBar::RunOnValueChanged() {
|
|
||||||
if (this->m_onValueChanged.luaRef) {
|
|
||||||
auto L = FrameScript_GetContext();
|
|
||||||
lua_pushnumber(L, this->m_value);
|
|
||||||
this->RunScript(this->m_onMinMaxChanged, 1, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimpleStatusBar::SetValue(float value) {
|
|
||||||
if ((this->m_flags & 2) == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = std::min(value, this->m_maxValue);
|
|
||||||
value = std::max(value, this->m_minValue);
|
|
||||||
|
|
||||||
if ((this->m_flags & 4) == 0 || this->m_value != value) {
|
|
||||||
this->m_value = value;
|
|
||||||
this->RunOnValueChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimpleStatusBar::SetStatusBarColor(CImVector& color) {
|
|
||||||
if (this->m_barTexture) {
|
|
||||||
this->m_barTexture->SetVertexColor(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CSimpleStatusBar::IsA(int32_t type) {
|
bool CSimpleStatusBar::IsA(int32_t type) {
|
||||||
return type == CSimpleStatusBar::s_objectType
|
return type == CSimpleStatusBar::s_objectType
|
||||||
|| type == CSimpleFrame::s_objectType
|
|| type == CSimpleFrame::s_objectType
|
||||||
@ -175,60 +62,3 @@ FrameScript_Object::ScriptIx* CSimpleStatusBar::GetScriptByName(const char* name
|
|||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSimpleStatusBar::LoadXML(XMLNode* node, CStatus* status) {
|
|
||||||
CSimpleFrame::LoadXML(node, status);
|
|
||||||
|
|
||||||
int32_t layer = 2;
|
|
||||||
|
|
||||||
auto drawLayer = node->GetAttributeByName("drawLayer");
|
|
||||||
if (drawLayer && *drawLayer) {
|
|
||||||
StringToDrawLayer(drawLayer, layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto child = node->m_child; child; child = child->m_next) {
|
|
||||||
if (!SStrCmpI(child->GetName(), "BarTexture", STORM_MAX_STR)) {
|
|
||||||
auto texture = LoadXML_Texture(child, this, status);
|
|
||||||
this->SetBarTexture(texture, layer);
|
|
||||||
} else if (!SStrCmpI(child->GetName(), "BarColor", STORM_MAX_STR)) {
|
|
||||||
CImVector color;
|
|
||||||
if (LoadXML_Color(child, color)) {
|
|
||||||
this->SetStatusBarColor(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto sminValue = node->GetAttributeByName("minValue");
|
|
||||||
auto smaxValue = node->GetAttributeByName("maxValue");
|
|
||||||
if (sminValue && *sminValue && smaxValue && *smaxValue) {
|
|
||||||
auto minValue = SStrToFloat(sminValue);
|
|
||||||
auto maxValue = SStrToFloat(smaxValue);
|
|
||||||
if (minValue < -1.0e12 || minValue > 1.0e12 || maxValue < -1.0e12 || maxValue > 1.0e12) {
|
|
||||||
status->Add(STATUS_ERROR, "Frame %s: Min or Max out of range", this->GetDisplayName());
|
|
||||||
} else if (maxValue - minValue <= 1.0e12) {
|
|
||||||
status->Add(STATUS_ERROR, "Frame %s: Min and Max too far apart", this->GetDisplayName());
|
|
||||||
} else {
|
|
||||||
this->SetMinMaxValues(minValue, maxValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto sdefValue = node->GetAttributeByName("defaultValue");
|
|
||||||
if (sdefValue && *sdefValue) {
|
|
||||||
this->SetValue(SStrToFloat(sdefValue));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto sorientation = node->GetAttributeByName("orientation");
|
|
||||||
if (sorientation && *sorientation) {
|
|
||||||
uint32_t orientation;
|
|
||||||
if (StringToOrientation(sorientation, orientation)) {
|
|
||||||
this->SetOrientation(orientation);
|
|
||||||
} else {
|
|
||||||
status->Add(STATUS_WARNING, "Frame %s: Unknown orientation %s in element %s", this->GetDisplayName(), sorientation, node->GetName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto rotatesTexture = node->GetAttributeByName("rotatesTexture");
|
|
||||||
if (rotatesTexture && *rotatesTexture) {
|
|
||||||
this->SetRotatesTexture(StringToBOOL(rotatesTexture));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -17,20 +17,11 @@ class CSimpleStatusBar : public CSimpleFrame {
|
|||||||
// Member functions
|
// Member functions
|
||||||
CSimpleStatusBar(CSimpleFrame* parent);
|
CSimpleStatusBar(CSimpleFrame* parent);
|
||||||
void SetOrientation(uint32_t orientation);
|
void SetOrientation(uint32_t orientation);
|
||||||
void SetMinMaxValues(float minValue, float maxValue);
|
|
||||||
void SetBarTexture(const char* texFile, int32_t layer);
|
|
||||||
void SetBarTexture(CSimpleTexture* texture, int32_t layer);
|
|
||||||
void SetRotatesTexture(bool rotates);
|
|
||||||
void RunOnMinMaxChanged();
|
|
||||||
void RunOnValueChanged();
|
|
||||||
|
|
||||||
// Virtual member functions
|
// Virtual member functions
|
||||||
virtual void SetValue(float value);
|
|
||||||
virtual void SetStatusBarColor(CImVector& color);
|
|
||||||
virtual bool IsA(int32_t type);
|
virtual bool IsA(int32_t type);
|
||||||
virtual int32_t GetScriptMetaTable();
|
virtual int32_t GetScriptMetaTable();
|
||||||
virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data);
|
virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data);
|
||||||
virtual void LoadXML(XMLNode* node, CStatus* status);
|
|
||||||
|
|
||||||
// Member variables
|
// Member variables
|
||||||
uint32_t m_flags = 0;
|
uint32_t m_flags = 0;
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
#include "ui/CSimpleStatusBarScript.hpp"
|
#include "ui/CSimpleStatusBarScript.hpp"
|
||||||
#include "ui/CSimpleStatusBar.hpp"
|
#include "ui/CSimpleStatusBar.hpp"
|
||||||
#include "ui/CSimpleTexture.hpp"
|
|
||||||
#include "ui/Util.hpp"
|
#include "ui/Util.hpp"
|
||||||
#include "util/Lua.hpp"
|
#include "util/Lua.hpp"
|
||||||
#include "util/Unimplemented.hpp"
|
#include "util/Unimplemented.hpp"
|
||||||
@ -39,22 +38,7 @@ static int32_t Script_GetMinMaxValues(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_SetMinMaxValues(lua_State* L) {
|
static int32_t Script_SetMinMaxValues(lua_State* L) {
|
||||||
auto type = CSimpleStatusBar::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto statusBar = static_cast<CSimpleStatusBar*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
if (!lua_isnumber(L, 2) || !lua_isnumber(L, 3)) {
|
|
||||||
return luaL_error(L, "Usage: %s:SetMinMaxValues(min, max)", statusBar->GetDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
auto minval = lua_tonumber(L, 2);
|
|
||||||
auto maxval = lua_tonumber(L, 3);
|
|
||||||
if (minval < -1.0e12 || minval > 1.0e12 || maxval < -1.0e12 || maxval > 1.0e12) {
|
|
||||||
return luaL_error(L, "Min or Max out of range");
|
|
||||||
}
|
|
||||||
if (maxval - minval > 1.0e12) {
|
|
||||||
return luaL_error(L, "Min and Max too far apart");
|
|
||||||
}
|
|
||||||
statusBar->SetMinMaxValues(minval, maxval);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_GetValue(lua_State* L) {
|
static int32_t Script_GetValue(lua_State* L) {
|
||||||
@ -65,120 +49,31 @@ static int32_t Script_GetValue(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_SetValue(lua_State* L) {
|
static int32_t Script_SetValue(lua_State* L) {
|
||||||
auto type = CSimpleStatusBar::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto statusBar = static_cast<CSimpleStatusBar*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
if (!lua_isnumber(L, 2)) {
|
|
||||||
return luaL_error(L, "Usage: %s:SetValue(value)", statusBar->GetDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
auto value = lua_tonumber(L, 2);
|
|
||||||
statusBar->SetValue(value);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_GetStatusBarTexture(lua_State* L) {
|
static int32_t Script_GetStatusBarTexture(lua_State* L) {
|
||||||
auto type = CSimpleStatusBar::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto statusBar = static_cast<CSimpleStatusBar*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
auto texture = statusBar->m_barTexture;
|
|
||||||
if (texture) {
|
|
||||||
if (!texture->lua_registered) {
|
|
||||||
texture->RegisterScriptObject(nullptr);
|
|
||||||
}
|
|
||||||
lua_rawgeti(L, LUA_REGISTRYINDEX, texture->lua_objectRef);
|
|
||||||
} else {
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_SetStatusBarTexture(lua_State* L) {
|
static int32_t Script_SetStatusBarTexture(lua_State* L) {
|
||||||
auto type = CSimpleStatusBar::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto statusBar = static_cast<CSimpleStatusBar*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
|
|
||||||
int32_t layer = 2;
|
|
||||||
|
|
||||||
if (lua_isstring(L, 3)) {
|
|
||||||
StringToDrawLayer(lua_tolstring(L, 3, nullptr), layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lua_type(L, 2) == LUA_TTABLE) {
|
|
||||||
lua_rawgeti(L, 2, 0);
|
|
||||||
auto texture = static_cast<CSimpleTexture*>(lua_touserdata(L, -1));
|
|
||||||
lua_settop(L, -2);
|
|
||||||
|
|
||||||
if (!texture) {
|
|
||||||
return luaL_error(L, "%s:SetStatusBarTexture(): Couldn't find 'this' in texture", statusBar->GetDisplayName());
|
|
||||||
} else {
|
|
||||||
auto textureType = CSimpleTexture::GetObjectType();
|
|
||||||
if (!texture->IsA(textureType)) {
|
|
||||||
return luaL_error(L, "%s:SetStatusBarTexture(): Wrong object type, expected texture", statusBar->GetDisplayName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
statusBar->SetBarTexture(texture, layer);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lua_isstring(L, 2)) {
|
|
||||||
auto texFile = lua_tostring(L, 2);
|
|
||||||
statusBar->SetBarTexture(texFile, layer);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lua_type(L, 2) != LUA_TNIL) {
|
|
||||||
luaL_error(L, "Usage: %s:SetStatusBarTexture(texture or \"texture\" or nil [, \"layer\"])", statusBar->GetDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
statusBar->SetBarTexture(static_cast<CSimpleTexture*>(nullptr), 2);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_GetStatusBarColor(lua_State* L) {
|
static int32_t Script_GetStatusBarColor(lua_State* L) {
|
||||||
auto type = CSimpleStatusBar::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto statusBar = static_cast<CSimpleStatusBar*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
auto texture = statusBar->m_barTexture;
|
|
||||||
|
|
||||||
CImVector color;
|
|
||||||
|
|
||||||
if (texture) {
|
|
||||||
texture->GetVertexColor(color);
|
|
||||||
} else {
|
|
||||||
color.Set(1.0f, 1.0f, 1.0f, 1.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
lua_pushnumber(L, color.r * 0.00392156);
|
|
||||||
lua_pushnumber(L, color.g * 0.00392156);
|
|
||||||
lua_pushnumber(L, color.b * 0.00392156);
|
|
||||||
lua_pushnumber(L, color.a * 0.00392156);
|
|
||||||
return 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_SetStatusBarColor(lua_State* L) {
|
static int32_t Script_SetStatusBarColor(lua_State* L) {
|
||||||
auto type = CSimpleStatusBar::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto statusBar = static_cast<CSimpleStatusBar*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
|
|
||||||
CImVector color;
|
|
||||||
FrameScript_GetColor(L, 2, color);
|
|
||||||
statusBar->SetStatusBarColor(color);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_GetRotatesTexture(lua_State* L) {
|
static int32_t Script_GetRotatesTexture(lua_State* L) {
|
||||||
auto type = CSimpleStatusBar::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto statusBar = static_cast<CSimpleStatusBar*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
if (statusBar->m_flags & 8) {
|
|
||||||
lua_pushnumber(L, 1.0);
|
|
||||||
} else {
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t Script_SetRotatesTexture(lua_State* L) {
|
static int32_t Script_SetRotatesTexture(lua_State* L) {
|
||||||
auto type = CSimpleStatusBar::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto statusBar = static_cast<CSimpleStatusBar*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
statusBar->SetRotatesTexture(StringToBOOL(L, 2, 0));
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -96,25 +96,11 @@ int32_t CSimpleTexture_Hide(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleTexture_IsVisible(lua_State* L) {
|
int32_t CSimpleTexture_IsVisible(lua_State* L) {
|
||||||
auto type = CSimpleTexture::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto texture = static_cast<CSimpleTexture*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
if (texture->m_visible) {
|
|
||||||
lua_pushnumber(L, 1.0);
|
|
||||||
} else {
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleTexture_IsShown(lua_State* L) {
|
int32_t CSimpleTexture_IsShown(lua_State* L) {
|
||||||
auto type = CSimpleTexture::GetObjectType();
|
WHOA_UNIMPLEMENTED(0);
|
||||||
auto texture = static_cast<CSimpleTexture*>(FrameScript_GetObjectThis(L, type));
|
|
||||||
if (texture->m_shown) {
|
|
||||||
lua_pushnumber(L, 1.0);
|
|
||||||
} else {
|
|
||||||
lua_pushnil(L);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleTexture_GetTexture(lua_State* L) {
|
int32_t CSimpleTexture_GetTexture(lua_State* L) {
|
||||||
@ -225,15 +211,11 @@ int32_t CSimpleTexture_SetRotation(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleTexture_SetDesaturated(lua_State* L) {
|
int32_t CSimpleTexture_SetDesaturated(lua_State* L) {
|
||||||
// TODO
|
WHOA_UNIMPLEMENTED(0);
|
||||||
lua_pushnil(L);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleTexture_IsDesaturated(lua_State* L) {
|
int32_t CSimpleTexture_IsDesaturated(lua_State* L) {
|
||||||
// TODO
|
WHOA_UNIMPLEMENTED(0);
|
||||||
lua_pushnil(L);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CSimpleTexture_SetNonBlocking(lua_State* L) {
|
int32_t CSimpleTexture_SetNonBlocking(lua_State* L) {
|
||||||
|
|||||||
@ -106,9 +106,7 @@ int32_t strlenutf8(lua_State* L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t issecure(lua_State* L) {
|
int32_t issecure(lua_State* L) {
|
||||||
// TODO
|
WHOA_UNIMPLEMENTED(0);
|
||||||
lua_pushnil(L);
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t issecurevariable(lua_State* L) {
|
int32_t issecurevariable(lua_State* L) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user