small fixes

This commit is contained in:
MihailRis 2024-12-05 22:36:12 +03:00
parent 84b3b82dba
commit 605d7e7897
4 changed files with 15 additions and 7 deletions

View File

@ -7,7 +7,7 @@
namespace gui { namespace gui {
struct Page { struct Page {
std::string name; std::string name;
std::shared_ptr<UINode> panel = nullptr; std::shared_ptr<UINode> panel;
}; };
using page_loader_func = std::function<std::shared_ptr<UINode>(const std::string& name)>; using page_loader_func = std::function<std::shared_ptr<UINode>(const std::string& name)>;

View File

@ -189,7 +189,9 @@ void UiXmlReader::readUINode(UiXmlReader& reader, const xml::xmlelement& element
_readContainer(reader, element, container); _readContainer(reader, element, container);
} }
void UiXmlReader::readUINode(UiXmlReader& reader, const xml::xmlelement& element, UINode& node) { void UiXmlReader::readUINode(
const UiXmlReader& reader, const xml::xmlelement& element, UINode& node
) {
_readUINode(reader, element, node); _readUINode(reader, element, node);
} }
@ -246,7 +248,9 @@ static std::wstring readAndProcessInnerText(const xml::xmlelement& element, cons
return text; return text;
} }
static std::shared_ptr<UINode> readLabel(UiXmlReader& reader, const xml::xmlelement& element) { static std::shared_ptr<UINode> readLabel(
const UiXmlReader& reader, const xml::xmlelement& element
) {
std::wstring text = readAndProcessInnerText(element, reader.getContext()); std::wstring text = readAndProcessInnerText(element, reader.getContext());
auto label = std::make_shared<Label>(text); auto label = std::make_shared<Label>(text);
_readUINode(reader, element, *label); _readUINode(reader, element, *label);
@ -423,14 +427,18 @@ static std::shared_ptr<UINode> readTextBox(UiXmlReader& reader, const xml::xmlel
return textbox; return textbox;
} }
static std::shared_ptr<UINode> readImage(UiXmlReader& reader, const xml::xmlelement& element) { static std::shared_ptr<UINode> readImage(
const UiXmlReader& reader, const xml::xmlelement& element
) {
std::string src = element.attr("src", "").getText(); std::string src = element.attr("src", "").getText();
auto image = std::make_shared<Image>(src); auto image = std::make_shared<Image>(src);
_readUINode(reader, element, *image); _readUINode(reader, element, *image);
return image; return image;
} }
static std::shared_ptr<UINode> readTrackBar(UiXmlReader& reader, const xml::xmlelement& element) { static std::shared_ptr<UINode> readTrackBar(
const UiXmlReader& reader, const xml::xmlelement& element
) {
const auto& env = reader.getEnvironment(); const auto& env = reader.getEnvironment();
const auto& file = reader.getFilename(); const auto& file = reader.getFilename();
float minv = element.attr("min", "0.0").asFloat(); float minv = element.attr("min", "0.0").asFloat();

View File

@ -30,7 +30,7 @@ namespace gui {
std::shared_ptr<UINode> readUINode(const xml::xmlelement& element); std::shared_ptr<UINode> readUINode(const xml::xmlelement& element);
void readUINode( void readUINode(
UiXmlReader& reader, const UiXmlReader& reader,
const xml::xmlelement& element, const xml::xmlelement& element,
UINode& node UINode& node
); );

View File

@ -5,7 +5,7 @@
Inventory::Inventory(int64_t id, size_t size) : id(id), slots(size) { Inventory::Inventory(int64_t id, size_t size) : id(id), slots(size) {
} }
Inventory::Inventory(const Inventory& orig) { Inventory::Inventory(const Inventory& orig) : id(0) {
this->slots = orig.slots; this->slots = orig.slots;
} }