mirror of
https://github.com/whoahq/whoa.git
synced 2026-02-01 00:02:45 +03:00
feat(ui): add CSimpleSlider::LoadXML
This commit is contained in:
parent
590e92ff19
commit
88aeb11698
@ -1,7 +1,11 @@
|
||||
#include "ui/CSimpleSlider.hpp"
|
||||
#include "math/Utils.hpp"
|
||||
#include "ui/CSimpleSliderScript.hpp"
|
||||
#include "ui/CSimpleTexture.hpp"
|
||||
#include "ui/LoadXML.hpp"
|
||||
#include "util/Lua.hpp"
|
||||
#include "util/StringTo.hpp"
|
||||
#include <common/XML.hpp>
|
||||
|
||||
int32_t CSimpleSlider::s_metatable;
|
||||
int32_t CSimpleSlider::s_objectType;
|
||||
@ -56,6 +60,26 @@ bool CSimpleSlider::IsA(int32_t type) {
|
||||
|| type == CScriptObject::s_objectType;
|
||||
}
|
||||
|
||||
void CSimpleSlider::LoadXML(XMLNode* node, CStatus* status) {
|
||||
this->CSimpleFrame::LoadXML(node, status);
|
||||
|
||||
int32_t drawLayer = DRAWLAYER_ARTWORK_OVERLAY;
|
||||
|
||||
auto drawLayerStr = node->GetAttributeByName("drawLayer");
|
||||
if (drawLayerStr && *drawLayerStr) {
|
||||
StringToDrawLayer(drawLayerStr, drawLayer);
|
||||
}
|
||||
|
||||
for (auto child = node->m_child; child; child = child->m_next) {
|
||||
if (!SStrCmpI(child->GetName(), "ThumbTexture")) {
|
||||
auto thumbTexture = LoadXML_Texture(child, this, status);
|
||||
this->SetThumbTexture(thumbTexture, drawLayer);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
void CSimpleSlider::RunOnMinMaxChangedScript() {
|
||||
if (!this->m_onMinMaxChanged.luaRef) {
|
||||
return;
|
||||
@ -101,6 +125,24 @@ void CSimpleSlider::SetMinMaxValues(float min, float max) {
|
||||
}
|
||||
}
|
||||
|
||||
void CSimpleSlider::SetThumbTexture(CSimpleTexture* texture, int32_t drawLayer) {
|
||||
if (this->m_thumbTexture == texture) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->m_thumbTexture) {
|
||||
delete this->m_thumbTexture;
|
||||
}
|
||||
|
||||
if (texture) {
|
||||
texture->SetFrame(this, drawLayer, 1);
|
||||
texture->ClearAllPoints();
|
||||
}
|
||||
|
||||
this->m_changed = 1;
|
||||
this->m_thumbTexture = texture;
|
||||
}
|
||||
|
||||
void CSimpleSlider::SetValue(float value) {
|
||||
if (!this->m_rangeSet) {
|
||||
return;
|
||||
|
||||
@ -23,6 +23,7 @@ class CSimpleSlider : public CSimpleFrame {
|
||||
float m_range = 0.0f;
|
||||
float m_value = 0.0f;
|
||||
float m_valueStep = 0.0f;
|
||||
CSimpleTexture* m_thumbTexture = nullptr;
|
||||
ScriptIx m_onValueChanged;
|
||||
ScriptIx m_onMinMaxChanged;
|
||||
|
||||
@ -30,6 +31,7 @@ class CSimpleSlider : public CSimpleFrame {
|
||||
virtual ScriptIx* GetScriptByName(const char* name, ScriptData& data);
|
||||
virtual bool IsA(int32_t type);
|
||||
virtual int32_t GetScriptMetaTable();
|
||||
virtual void LoadXML(XMLNode* node, CStatus* status);
|
||||
|
||||
// Member functions
|
||||
CSimpleSlider(CSimpleFrame* parent)
|
||||
@ -44,6 +46,7 @@ class CSimpleSlider : public CSimpleFrame {
|
||||
void RunOnMinMaxChangedScript();
|
||||
void RunOnValueChangedScript();
|
||||
void SetMinMaxValues(float min, float max);
|
||||
void SetThumbTexture(CSimpleTexture* texture, int32_t drawLayer);
|
||||
void SetValue(float value);
|
||||
float Sub96BC10(float value);
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user