feat(ui): add LoadXML_Gradient

This commit is contained in:
fallenoak 2025-12-23 11:39:55 -06:00
parent a6e93122a7
commit 066a53e667
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 26 additions and 1 deletions

View File

@ -128,6 +128,28 @@ int32_t LoadXML_Dimensions(XMLNode* node, float& x, float& y, CStatus* status) {
} }
} }
int32_t LoadXML_Gradient(XMLNode* node, ORIENTATION& orientation, CImVector& minColor, CImVector& maxColor, CStatus* status) {
orientation = ORIENTATION_HORIZONTAL;
// Orientation
auto orientationAttr = node->GetAttributeByName("orientation");
if (orientationAttr && *orientationAttr) {
if (!StringToOrientation(orientationAttr, orientation)) {
status->Add(STATUS_WARNING, "Unknown orientation %s in element %s", orientationAttr, node->GetName());
}
}
for (auto child = node->m_child; child; child = child->m_next) {
if (!SStrCmpI(child->GetName(), "MinColor")) {
LoadXML_Color(child, minColor);
} else if (!SStrCmpI(child->GetName(), "MaxColor")) {
LoadXML_Color(child, maxColor);
}
}
return 1;
}
int32_t LoadXML_Insets(XMLNode* node, float& left, float& right, float& top, float& bottom, CStatus* status) { int32_t LoadXML_Insets(XMLNode* node, float& left, float& right, float& top, float& bottom, CStatus* status) {
left = 0.0f; left = 0.0f;
right = 0.0f; right = 0.0f;

View File

@ -1,19 +1,22 @@
#ifndef UI_LOAD_XML_HPP #ifndef UI_LOAD_XML_HPP
#define UI_LOAD_XML_HPP #define UI_LOAD_XML_HPP
#include "ui/Types.hpp"
#include <cstdint> #include <cstdint>
class CImVector;
class CSimpleFontString; class CSimpleFontString;
class CSimpleFrame; class CSimpleFrame;
class CSimpleTexture; class CSimpleTexture;
class CStatus; class CStatus;
class XMLNode; class XMLNode;
class CImVector;
int32_t LoadXML_Color(XMLNode* node, CImVector& color); int32_t LoadXML_Color(XMLNode* node, CImVector& color);
int32_t LoadXML_Dimensions(XMLNode* node, float& x, float& y, CStatus* status); int32_t LoadXML_Dimensions(XMLNode* node, float& x, float& y, CStatus* status);
int32_t LoadXML_Gradient(XMLNode* node, ORIENTATION& orientation, CImVector& minColor, CImVector& maxColor, CStatus* status);
int32_t LoadXML_Insets(XMLNode* node, float& left, float& right, float& top, float& bottom, CStatus* status); int32_t LoadXML_Insets(XMLNode* node, float& left, float& right, float& top, float& bottom, CStatus* status);
CSimpleFontString* LoadXML_String(XMLNode* node, CSimpleFrame* frame, CStatus* status); CSimpleFontString* LoadXML_String(XMLNode* node, CSimpleFrame* frame, CStatus* status);