Compare commits

...

18 Commits

Author SHA1 Message Date
Tristan 'Natrist' Cormier
fa540420c6
Merge c12a79d6e6 into aa22dd952a 2026-02-05 11:28:52 -05:00
fallenoak
aa22dd952a
feat(ui): add CSimpleStatusBar::OnLayerUpdate
Some checks are pending
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Waiting to run
2026-02-05 07:05:28 -06:00
fallenoak
534e05be93
feat(ui): add CLayoutFrame::GetSize 2026-02-05 07:01:30 -06:00
fallenoak
856bb72e1a
chore(ui): improve CSimpleStatusBar ctor
Some checks are pending
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Waiting to run
2026-02-04 21:53:51 -06:00
fallenoak
3713a7ee89
feat(ui): implement CSimpleStatusBar_GetMinMaxValues 2026-02-04 21:40:42 -06:00
fallenoak
98103db5ee
feat(ui): implement CSimpleStatusBar_SetStatusBarColor 2026-02-04 21:15:32 -06:00
fallenoak
d0621df975
feat(ui): implement CSimpleStatusBar::SetStatusBarColor 2026-02-04 21:10:42 -06:00
fallenoak
fd31a10eaf
feat(ui): implement CSimpleStatusBar::SetBarTexture 2026-02-04 21:06:53 -06:00
fallenoak
78f2afb891
feat(ui): add CSimpleStatusBar::LoadXML 2026-02-04 17:08:31 -06:00
fallenoak
d9b6647c42
feat(ui): add CSimpleStatusBar::IsA
Some checks are pending
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:cl compiler_name:MSVC cxx:cl os:windows-latest system_name:Windows test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:clang compiler_name:Clang cxx:clang++ os:macos-latest system_name:macOS test_path:WhoaTest]) (push) Waiting to run
Push / ${{ matrix.build.system_name }} / ${{ matrix.build.build_type }} / ${{ matrix.build.compiler_name }} (map[build_type:Release cc:gcc compiler_name:GCC cxx:g++ os:ubuntu-latest system_name:Linux test_path:WhoaTest]) (push) Waiting to run
2026-02-04 15:22:58 -06:00
fallenoak
dc22db2f18
feat(ui): implement CSimpleStatusBar_GetValue 2026-02-04 15:16:33 -06:00
fallenoak
977a3051db
feat(ui): implement CSimpleStatusBar_SetMinMaxValues 2026-02-04 15:08:45 -06:00
fallenoak
c54dda367b
feat(ui): implement CSimpleStatusBar_SetValue 2026-02-04 14:33:23 -06:00
fallenoak
35699af8d2
feat(ui): add CSimpleStatusBar::SetMinMaxValues 2026-02-04 14:28:55 -06:00
fallenoak
61484450b8
feat(ui): add CSimpleStatusBar::SetValue 2026-02-04 13:23:14 -06:00
fallenoak
bc2dabeea9
feat(ui): add CSimpleStatusBar::GetScriptByName 2026-02-04 12:48:52 -06:00
fallenoak
6a4a2110f4
feat(ui): implement CSimpleFrame_GetScript 2026-02-04 11:37:30 -06:00
Tristan Cormier
c12a79d6e6 feat(console): add CONSOLELINE::Backspace 2025-12-08 09:17:54 -05:00
10 changed files with 431 additions and 18 deletions

View File

@ -84,6 +84,26 @@ CONSOLELINE::~CONSOLELINE() {
} }
} }
void CONSOLELINE::Backspace() {
if (this->inputpos > this->inputstart) {
if (this->chars <= this->inputpos) {
this->buffer[this->inputpos - 1] = '\0';
}
else {
memcpy(
&this->buffer[this->inputpos - 1],
&this->buffer[this->inputpos],
this->chars - this->inputpos + 1
);
}
this->inputpos--;
this->chars--;
SetInputString(this->buffer);
}
}
void DrawBackground() { void DrawBackground() {
uint16_t indices[] = { uint16_t indices[] = {
0, 1, 2, 3 0, 1, 2, 3

View File

@ -19,6 +19,7 @@ class CONSOLELINE : public TSLinkedNode<CONSOLELINE> {
// Member functions // Member functions
~CONSOLELINE(); ~CONSOLELINE();
void Backspace();
}; };
void ConsoleScreenAnimate(float elapsedSec); void ConsoleScreenAnimate(float elapsedSec);

View File

@ -332,6 +332,10 @@ void CLayoutFrame::GetFirstPointY(const FRAMEPOINT* const pointarray, int32_t el
} }
} }
float CLayoutFrame::GetHeight() {
return this->m_height;
}
CLayoutFrame* CLayoutFrame::GetLayoutFrameByName(const char* name) { CLayoutFrame* CLayoutFrame::GetLayoutFrameByName(const char* name) {
return nullptr; return nullptr;
} }
@ -353,8 +357,20 @@ int32_t CLayoutFrame::GetRect(CRect* rect) {
return 1; return 1;
} }
float CLayoutFrame::GetHeight() { void CLayoutFrame::GetSize(float& width, float& height, int32_t a4) {
return this->m_height; width = this->GetWidth();
height = this->GetHeight();
if (!a4 && (width == 0.0f || height == 0.0f)) {
if (this->m_flags & FLAG_RESIZE_PENDING) {
this->Resize(1);
}
if (this->m_flags & 0x1) {
width = (this->m_rect.maxX - this->m_rect.minX) / this->m_layoutScale;
height = (this->m_rect.maxY - this->m_rect.minY) / this->m_layoutScale;
}
}
} }
float CLayoutFrame::GetWidth() { float CLayoutFrame::GetWidth() {

View File

@ -51,6 +51,7 @@ class CLayoutFrame {
virtual void SetHeight(float height); virtual void SetHeight(float height);
virtual float GetWidth(); virtual float GetWidth();
virtual float GetHeight(); virtual float GetHeight();
virtual void GetSize(float& width, float& height, int32_t a4);
virtual void GetClampRectInsets(float& a1, float& a2, float& a3, float& a4); virtual void GetClampRectInsets(float& a1, float& a2, float& a3, float& a4);
virtual int32_t IsAttachmentOrigin(); virtual int32_t IsAttachmentOrigin();
virtual CLayoutFrame* GetLayoutFrameByName(const char* name); virtual CLayoutFrame* GetLayoutFrameByName(const char* name);

View File

@ -35,6 +35,33 @@ const char* FrameScript_Object::GetDisplayName() {
return name ? name : "<unnamed>"; return name ? name : "<unnamed>";
} }
int32_t FrameScript_Object::GetScript(lua_State* L) {
if (!lua_isstring(L, 2)) {
luaL_error(L, "Usage: %s:GetScript(\"type\")", this->GetDisplayName());
return 0;
}
auto name = lua_tostring(L, 2);
ScriptData data;
auto script = this->GetScriptByName(name, data);
if (!script) {
luaL_error(L, "%s doesn't have a \"%s\" script", this->GetDisplayName(), lua_tostring(L, 2));
return 0;
}
// TODO taint management
if (script->luaRef > 0) {
lua_rawgeti(L, LUA_REGISTRYINDEX, script->luaRef);
} else {
lua_pushnil(L);
}
return 1;
}
FrameScript_Object::ScriptIx* FrameScript_Object::GetScriptByName(const char* name, FrameScript_Object::ScriptData& data) { FrameScript_Object::ScriptIx* FrameScript_Object::GetScriptByName(const char* name, FrameScript_Object::ScriptData& data) {
if (!SStrCmpI(name, "OnEvent", STORM_MAX_STR)) { if (!SStrCmpI(name, "OnEvent", STORM_MAX_STR)) {
data.wrapper = "return function(self,event,...) %s end"; data.wrapper = "return function(self,event,...) %s end";

View File

@ -43,6 +43,7 @@ class FrameScript_Object {
// Member functions // Member functions
const char* GetDisplayName(); const char* GetDisplayName();
int32_t GetScript(lua_State* L);
int32_t RegisterScriptEvent(const char* name); int32_t RegisterScriptEvent(const char* name);
void RegisterScriptObject(const char* name); void RegisterScriptObject(const char* name);
void RunScript(ScriptIx const& script, int32_t argCount, const char* a4); void RunScript(ScriptIx const& script, int32_t argCount, const char* a4);

View File

@ -188,7 +188,10 @@ int32_t CSimpleFrame_HasScript(lua_State* L) {
} }
int32_t CSimpleFrame_GetScript(lua_State* L) { int32_t CSimpleFrame_GetScript(lua_State* L) {
WHOA_UNIMPLEMENTED(0); auto type = CSimpleFrame::GetObjectType();
auto frame = static_cast<CSimpleFrame*>(FrameScript_GetObjectThis(L, type));
return frame->GetScript(L);
} }
int32_t CSimpleFrame_SetScript(lua_State* L) { int32_t CSimpleFrame_SetScript(lua_State* L) {

View File

@ -1,5 +1,11 @@
#include "ui/simple/CSimpleStatusBar.hpp" #include "ui/simple/CSimpleStatusBar.hpp"
#include "ui/LoadXML.hpp"
#include "ui/simple/CSimpleStatusBarScript.hpp" #include "ui/simple/CSimpleStatusBarScript.hpp"
#include "ui/simple/CSimpleTexture.hpp"
#include "util/CStatus.hpp"
#include "util/Lua.hpp"
#include "util/StringTo.hpp"
#include <common/XML.hpp>
int32_t CSimpleStatusBar::s_metatable; int32_t CSimpleStatusBar::s_metatable;
int32_t CSimpleStatusBar::s_objectType; int32_t CSimpleStatusBar::s_objectType;
@ -22,10 +28,260 @@ void CSimpleStatusBar::RegisterScriptMethods(lua_State* L) {
FrameScript_Object::FillScriptMethodTable(L, SimpleStatusBarMethods, NUM_SIMPLE_STATUS_BAR_SCRIPT_METHODS); FrameScript_Object::FillScriptMethodTable(L, SimpleStatusBarMethods, NUM_SIMPLE_STATUS_BAR_SCRIPT_METHODS);
} }
CSimpleStatusBar::CSimpleStatusBar(CSimpleFrame* parent) : CSimpleFrame(parent) { float CSimpleStatusBar::GetAnimValue() const {
// TODO auto range = this->m_maxValue - this->m_minValue;
if (range <= 0.0f) {
return 0.0f;
}
return (this->m_value - this->m_minValue) / range;
}
FrameScript_Object::ScriptIx* CSimpleStatusBar::GetScriptByName(const char* name, ScriptData& data) {
auto script = this->CSimpleFrame::GetScriptByName(name, data);
if (script) {
return script;
}
if (!SStrCmpI(name, "OnValueChanged")) {
script = &this->m_onValueChanged;
data.wrapper = "return function(self,value) %s end";
} else if (!SStrCmpI(name, "OnMinMaxChanged")) {
script = &this->m_onMinMaxChanged;
data.wrapper = "return function(self,min,max) %s end";
}
return script;
} }
int32_t CSimpleStatusBar::GetScriptMetaTable() { int32_t CSimpleStatusBar::GetScriptMetaTable() {
return CSimpleStatusBar::s_metatable; return CSimpleStatusBar::s_metatable;
} }
float CSimpleStatusBar::GetMaxValue() const {
return this->m_maxValue;
}
float CSimpleStatusBar::GetMinValue() const {
return this->m_minValue;
}
float CSimpleStatusBar::GetValue() const {
return this->m_value;
}
bool CSimpleStatusBar::IsA(int32_t type) {
return type == CSimpleStatusBar::s_objectType
|| type == CSimpleFrame::s_objectType
|| type == CScriptRegion::s_objectType
|| type == CScriptObject::s_objectType;
}
void CSimpleStatusBar::LoadXML(const XMLNode* node, CStatus* status) {
this->CSimpleFrame::LoadXML(node, status);
int32_t drawlayer = DRAWLAYER_ARTWORK;
auto drawlayerAttr = node->GetAttributeByName("drawLayer");
if (drawlayerAttr && *drawlayerAttr) {
StringToDrawLayer(drawlayerAttr, drawlayer);
}
for (auto child = node->GetChild(); child; child = child->GetSibling()) {
if (!SStrCmpI(child->GetName(), "BarTexture")) {
auto texture = LoadXML_Texture(child, this, status);
this->SetBarTexture(texture, drawlayer);
} else if (!SStrCmpI(child->GetName(), "BarColor")) {
CImVector color = {};
LoadXML_Color(child, color);
this->SetStatusBarColor(color);
}
}
auto minValueAttr = node->GetAttributeByName("minValue");
if (minValueAttr && *minValueAttr) {
auto maxValueAttr = node->GetAttributeByName("maxValue");
if (maxValueAttr && *maxValueAttr) {
auto minValue = SStrToFloat(minValueAttr);
auto maxValue = SStrToFloat(maxValueAttr);
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 defaultValueAttr = node->GetAttributeByName("defaultValue");
if (defaultValueAttr && *defaultValueAttr) {
auto defaultValue = SStrToFloat(defaultValueAttr);
this->SetValue(defaultValue);
}
}
}
auto orientationAttr = node->GetAttributeByName("orientation");
if (orientationAttr && *orientationAttr) {
ORIENTATION orientation;
if (StringToOrientation(orientationAttr, orientation)) {
this->SetOrientation(orientation);
} else {
status->Add(STATUS_WARNING, "Frame %s: Unknown orientation %s in element %s", this->GetDisplayName(), orientationAttr, node->GetName());
}
}
auto rotatesTextureAttr = node->GetAttributeByName("rotatesTexture");
if (rotatesTextureAttr && *rotatesTextureAttr) {
auto rotatesTexture = StringToBOOL(rotatesTextureAttr);
this->SetRotatesTexture(rotatesTexture);
}
}
void CSimpleStatusBar::OnLayerUpdate(float elapsedSec) {
this->CSimpleFrame::OnLayerUpdate(elapsedSec);
if (!this->m_changed || !this->m_rangeSet || !this->m_valueSet || !this->m_barTexture) {
return;
}
auto animValue = this->GetAnimValue();
if (animValue <= 0.0f) {
this->m_barTexture->Hide();
this->m_changed = false;
return;
}
float width, height;
this->GetSize(width, height, false);
auto fill = 1.0f - animValue;
this->m_barTexture->Show();
if (this->m_orientation == ORIENTATION_VERTICAL) {
this->m_barTexture->SetPoint(FRAMEPOINT_BOTTOMLEFT, this, FRAMEPOINT_BOTTOMLEFT, 0.0f, 0.0f, true);
this->m_barTexture->SetPoint(FRAMEPOINT_BOTTOMRIGHT, this, FRAMEPOINT_BOTTOMRIGHT, 0.0f, 0.0f, true);
this->m_barTexture->SetPoint(FRAMEPOINT_TOPLEFT, this, FRAMEPOINT_TOPLEFT, 0.0f, -(fill * height), true);
this->m_barTexture->SetPoint(FRAMEPOINT_TOPRIGHT, this, FRAMEPOINT_TOPRIGHT, 0.0f, -(fill * height), true);
} else {
this->m_barTexture->SetPoint(FRAMEPOINT_TOPLEFT, this, FRAMEPOINT_TOPLEFT, 0.0f, 0.0f, true);
this->m_barTexture->SetPoint(FRAMEPOINT_BOTTOMLEFT, this, FRAMEPOINT_BOTTOMLEFT, 0.0f, 0.0f, true);
this->m_barTexture->SetPoint(FRAMEPOINT_TOPRIGHT, this, FRAMEPOINT_TOPRIGHT, -(fill * width), 0.0f, true);
this->m_barTexture->SetPoint(FRAMEPOINT_BOTTOMRIGHT, this, FRAMEPOINT_BOTTOMRIGHT, -(fill * width), 0.0f, true);
}
this->m_changed = false;
}
void CSimpleStatusBar::RunOnMinMaxChangedScript() {
if (!this->m_onMinMaxChanged.luaRef) {
return;
}
auto L = FrameScript_GetContext();
lua_pushnumber(L, this->m_minValue);
lua_pushnumber(L, this->m_maxValue);
this->RunScript(this->m_onMinMaxChanged, 2, nullptr);
}
void CSimpleStatusBar::RunOnValueChangedScript() {
if (!this->m_onValueChanged.luaRef) {
return;
}
auto L = FrameScript_GetContext();
lua_pushnumber(L, this->m_value);
this->RunScript(this->m_onValueChanged, 1, nullptr);
}
void CSimpleStatusBar::SetBarTexture(CSimpleTexture* texture, int32_t drawlayer) {
// No change
if (this->m_barTexture == texture) {
return;
}
if (this->m_barTexture) {
delete this->m_barTexture;
}
if (texture) {
texture->SetFrame(this, drawlayer, true);
texture->SetPoint(FRAMEPOINT_BOTTOMLEFT, this, FRAMEPOINT_BOTTOMLEFT, 0.0f, 0.0f, true);
texture->SetPoint(FRAMEPOINT_BOTTOMRIGHT, this, FRAMEPOINT_BOTTOMRIGHT, 0.0f, 0.0f, true);
texture->SetPoint(FRAMEPOINT_TOPLEFT, this, FRAMEPOINT_TOPLEFT, 0.0f, 0.0f, true);
texture->SetPoint(FRAMEPOINT_TOPRIGHT, this, FRAMEPOINT_TOPRIGHT, 0.0f, 0.0f, true);
}
this->m_barTexture = texture;
this->m_changed = true;
}
void CSimpleStatusBar::SetMinMaxValues(float min, float max) {
if (min > max) {
min = max;
}
// No change
if (this->m_rangeSet && this->m_minValue == min && this->m_maxValue == max) {
return;
}
this->m_minValue = min;
this->m_maxValue = max;
this->m_changed = true;
this->m_rangeSet = true;
this->RunOnMinMaxChangedScript();
if (this->m_valueSet) {
this->SetValue(this->m_value);
}
}
void CSimpleStatusBar::SetOrientation(ORIENTATION orientation) {
// TODO
}
void CSimpleStatusBar::SetRotatesTexture(int32_t enabled) {
// TODO
}
void CSimpleStatusBar::SetStatusBarColor(const CImVector& color) {
if (this->m_barTexture) {
this->m_barTexture->SetVertexColor(color);
}
}
void CSimpleStatusBar::SetValue(float value) {
if (!this->m_rangeSet) {
return;
}
// Clamp value
value = std::min(std::max(value, this->m_minValue), this->m_maxValue);
// No change
if (this->m_valueSet && this->m_value == value) {
return;
}
this->m_value = value;
this->m_changed = true;
this->m_valueSet = true;
this->RunOnValueChangedScript();
}

View File

@ -5,23 +5,55 @@
class CSimpleStatusBar : public CSimpleFrame { class CSimpleStatusBar : public CSimpleFrame {
public: public:
// Static variables // Public static variables
static int32_t s_metatable; static int32_t s_metatable;
static int32_t s_objectType; static int32_t s_objectType;
// Static functions // Public static functions
static void CreateScriptMetaTable(); static void CreateScriptMetaTable();
static int32_t GetObjectType(); static int32_t GetObjectType();
static void RegisterScriptMethods(lua_State* L); static void RegisterScriptMethods(lua_State* L);
// Member variables // Public virtual member functions
// TODO
// Virtual member functions
virtual int32_t GetScriptMetaTable(); virtual int32_t GetScriptMetaTable();
virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data);
virtual bool IsA(int32_t type);
// TODO
virtual void OnLayerUpdate(float elapsedSec);
// TODO
virtual void SetValue(float value);
virtual void LoadXML(const XMLNode* node, CStatus* status);
// Member functions // Public member functions
CSimpleStatusBar(CSimpleFrame* parent); CSimpleStatusBar(CSimpleFrame* parent)
: CSimpleFrame(parent)
, m_changed(false)
, m_rangeSet(false)
, m_valueSet(false) {};
float GetAnimValue() const;
float GetMaxValue() const;
float GetMinValue() const;
float GetValue() const;
void RunOnMinMaxChangedScript();
void RunOnValueChangedScript();
void SetBarTexture(CSimpleTexture* texture, int32_t drawlayer);
void SetMinMaxValues(float min, float max);
void SetOrientation(ORIENTATION orientation);
void SetRotatesTexture(int32_t enabled);
void SetStatusBarColor(const CImVector& color);
protected:
// Protected member variables
uint32_t m_changed : 1;
uint32_t m_rangeSet : 1;
uint32_t m_valueSet : 1;
float m_minValue = 0.0f;
float m_maxValue = 0.0f;
float m_value = 0.0f;
CSimpleTexture* m_barTexture = nullptr;
ORIENTATION m_orientation = ORIENTATION_HORIZONTAL;
ScriptIx m_onValueChanged;
ScriptIx m_onMinMaxChanged;
}; };
#endif #endif

View File

@ -1,5 +1,7 @@
#include "ui/simple/CSimpleStatusBarScript.hpp" #include "ui/simple/CSimpleStatusBarScript.hpp"
#include "ui/simple/CSimpleStatusBar.hpp"
#include "ui/FrameScript.hpp" #include "ui/FrameScript.hpp"
#include "util/Lua.hpp"
#include "util/Unimplemented.hpp" #include "util/Unimplemented.hpp"
namespace { namespace {
@ -13,19 +15,65 @@ int32_t CSimpleStatusBar_SetOrientation(lua_State* L) {
} }
int32_t CSimpleStatusBar_GetMinMaxValues(lua_State* L) { int32_t CSimpleStatusBar_GetMinMaxValues(lua_State* L) {
WHOA_UNIMPLEMENTED(0); auto type = CSimpleStatusBar::GetObjectType();
auto statusBar = static_cast<CSimpleStatusBar*>(FrameScript_GetObjectThis(L, type));
lua_pushnumber(L, statusBar->GetMinValue());
lua_pushnumber(L, statusBar->GetMaxValue());
return 2;
} }
int32_t CSimpleStatusBar_SetMinMaxValues(lua_State* L) { int32_t CSimpleStatusBar_SetMinMaxValues(lua_State* L) {
WHOA_UNIMPLEMENTED(0); auto type = CSimpleStatusBar::GetObjectType();
auto statusBar = static_cast<CSimpleStatusBar*>(FrameScript_GetObjectThis(L, type));
if (!lua_isnumber(L, 2) || !lua_isnumber(L, 3)) {
luaL_error(L, "Usage: %s:SetMinMaxValues(min, max)", statusBar->GetDisplayName());
return 0;
}
auto min = lua_tonumber(L, 2);
auto max = lua_tonumber(L, 3);
if (min < -1.0e12 || min > 1.0e12 || max < -1.0e12 || max > 1.0e12) {
luaL_error(L, "Min or Max out of range");
return 0;
}
if (max - min > 1.0e12) {
luaL_error(L, "Min and Max too far apart");
return 0;
}
statusBar->SetMinMaxValues(static_cast<float>(min), static_cast<float>(max));
return 0;
} }
int32_t CSimpleStatusBar_GetValue(lua_State* L) { int32_t CSimpleStatusBar_GetValue(lua_State* L) {
WHOA_UNIMPLEMENTED(0); auto type = CSimpleStatusBar::GetObjectType();
auto statusBar = static_cast<CSimpleStatusBar*>(FrameScript_GetObjectThis(L, type));
lua_pushnumber(L, statusBar->GetValue());
return 1;
} }
int32_t CSimpleStatusBar_SetValue(lua_State* L) { int32_t CSimpleStatusBar_SetValue(lua_State* L) {
WHOA_UNIMPLEMENTED(0); auto type = CSimpleStatusBar::GetObjectType();
auto statusBar = static_cast<CSimpleStatusBar*>(FrameScript_GetObjectThis(L, type));
if (!lua_isnumber(L, 2)) {
luaL_error(L, "Usage: %s:SetValue(value)", statusBar->GetDisplayName());
return 0;
}
auto value = static_cast<float>(lua_tonumber(L, 2));
statusBar->SetValue(value);
return 0;
} }
int32_t CSimpleStatusBar_GetStatusBarTexture(lua_State* L) { int32_t CSimpleStatusBar_GetStatusBarTexture(lua_State* L) {
@ -41,7 +89,15 @@ int32_t CSimpleStatusBar_GetStatusBarColor(lua_State* L) {
} }
int32_t CSimpleStatusBar_SetStatusBarColor(lua_State* L) { int32_t CSimpleStatusBar_SetStatusBarColor(lua_State* L) {
WHOA_UNIMPLEMENTED(0); auto type = CSimpleStatusBar::GetObjectType();
auto statusBar = static_cast<CSimpleStatusBar*>(FrameScript_GetObjectThis(L, type));
CImVector color = {};
FrameScript_GetColor(L, 2, color);
statusBar->SetStatusBarColor(color);
return 0;
} }
int32_t CSimpleStatusBar_GetRotatesTexture(lua_State* L) { int32_t CSimpleStatusBar_GetRotatesTexture(lua_State* L) {