mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 05:53:26 +02:00
messagebox (not working yet)
This commit is contained in:
@@ -24,3 +24,10 @@
|
||||
|
||||
#include <prerequisites.h>
|
||||
#include <ui/uilabel.h>
|
||||
|
||||
void UILabel::setText(const std::string& text)
|
||||
{
|
||||
m_text = text;
|
||||
// text size changed, reaplly skin
|
||||
getSkin()->apply(this);
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ public:
|
||||
m_align(ALIGN_TOP_LEFT),
|
||||
m_color(Color::white) { }
|
||||
|
||||
void setText(const std::string& text) { m_text = text; }
|
||||
void setText(const std::string& text);
|
||||
const std::string& getText() const { return m_text; }
|
||||
|
||||
void setAlign(int align) { m_align = align; }
|
||||
|
@@ -151,24 +151,6 @@ void UILoader::loadElements(const UIElementPtr& parent, const YAML::Node& node)
|
||||
|
||||
void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node)
|
||||
{
|
||||
// load specific element type
|
||||
if(element->getElementType() == UI::Button)
|
||||
loadButton(boost::static_pointer_cast<UIButton>(element), node);
|
||||
else if(element->getElementType() == UI::Window) {
|
||||
UIWindowPtr window = boost::static_pointer_cast<UIWindow>(element);
|
||||
window->setTitle(node["title"].Read<std::string>());
|
||||
}
|
||||
else if(element->getElementType() == UI::Label) {
|
||||
UILabelPtr label = boost::static_pointer_cast<UILabel>(element);
|
||||
label->setText(node["text"].Read<std::string>());
|
||||
if(node.FindValue("align")) {
|
||||
std::string alignDesc;
|
||||
node["align"] >> alignDesc;
|
||||
if(alignDesc == "center")
|
||||
label->setAlign(ALIGN_CENTER);
|
||||
}
|
||||
}
|
||||
|
||||
// set element skin
|
||||
if(node.FindValue("skin")) {
|
||||
if(node["skin"].GetType() == YAML::CT_SCALAR) {
|
||||
@@ -249,6 +231,26 @@ void UILoader::loadElement(const UIElementPtr& element, const YAML::Node& node)
|
||||
} else
|
||||
throw YAML::Exception(cnode.GetMark(), "failed to parse lua script");
|
||||
}
|
||||
|
||||
// load specific element type
|
||||
if(element->getElementType() == UI::Button)
|
||||
loadButton(boost::static_pointer_cast<UIButton>(element), node);
|
||||
else if(element->getElementType() == UI::Window) {
|
||||
UIWindowPtr window = boost::static_pointer_cast<UIWindow>(element);
|
||||
if(node.FindValue("title"))
|
||||
window->setTitle(node["title"].Read<std::string>());
|
||||
}
|
||||
else if(element->getElementType() == UI::Label) {
|
||||
UILabelPtr label = boost::static_pointer_cast<UILabel>(element);
|
||||
if(node.FindValue("text"))
|
||||
label->setText(node["text"].Read<std::string>());
|
||||
if(node.FindValue("align")) {
|
||||
std::string alignDesc;
|
||||
node["align"] >> alignDesc;
|
||||
if(alignDesc == "center")
|
||||
label->setAlign(ALIGN_CENTER);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UILoader::loadElementAnchor(const UIElementPtr& element, EAnchorType type, const YAML::Node& node)
|
||||
|
Reference in New Issue
Block a user