From 196f90e1d5fd02a93a7883cfeae5fbcface637be Mon Sep 17 00:00:00 2001 From: fallenoak Date: Sat, 29 Nov 2025 22:51:48 -0600 Subject: [PATCH] feat(ui): set orientation in CSimpleSlider::LoadXML --- src/ui/CSimpleSlider.cpp | 27 +++++++++++++++++++++++++++ src/ui/CSimpleSlider.hpp | 1 + 2 files changed, 28 insertions(+) diff --git a/src/ui/CSimpleSlider.cpp b/src/ui/CSimpleSlider.cpp index 14d53ac..3e573fc 100644 --- a/src/ui/CSimpleSlider.cpp +++ b/src/ui/CSimpleSlider.cpp @@ -79,6 +79,23 @@ void CSimpleSlider::LoadXML(XMLNode* node, CStatus* status) { } // TODO + + auto orientationStr = node->GetAttributeByName("orientation"); + if (orientationStr && *orientationStr) { + SLIDER_ORIENTATION orientation; + + if (StringToOrientation(orientationStr, orientation)) { + this->SetOrientation(orientation); + } else { + status->Add( + STATUS_WARNING, + "Frame %s: Unknown orientation %s in element %s", + this->GetDisplayName(), + orientationStr, + node->GetName() + ); + } + } } void CSimpleSlider::OnLayerUpdate(float elapsedSec) { @@ -151,6 +168,16 @@ void CSimpleSlider::SetMinMaxValues(float min, float max) { } } +void CSimpleSlider::SetOrientation(SLIDER_ORIENTATION orientation) { + this->m_orientation = orientation; + + if (this->m_thumbTexture) { + this->m_thumbTexture->ClearAllPoints(); + } + + this->m_changed = 1; +} + void CSimpleSlider::SetThumbTexture(CSimpleTexture* texture, int32_t drawLayer) { if (this->m_thumbTexture == texture) { return; diff --git a/src/ui/CSimpleSlider.hpp b/src/ui/CSimpleSlider.hpp index 2dfd66f..4d72ce3 100644 --- a/src/ui/CSimpleSlider.hpp +++ b/src/ui/CSimpleSlider.hpp @@ -48,6 +48,7 @@ class CSimpleSlider : public CSimpleFrame { void RunOnMinMaxChangedScript(); void RunOnValueChangedScript(); void SetMinMaxValues(float min, float max); + void SetOrientation(SLIDER_ORIENTATION orientation); void SetThumbTexture(CSimpleTexture* texture, int32_t drawLayer); void SetValue(float value); float Sub96BC10(float value);