Added UI component, resource & system. Now renders on screen and live reloads
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
namespace NuakeUI
|
||||
{
|
||||
class Canvas;
|
||||
typedef std::shared_ptr<Canvas> CanvasPtr;
|
||||
using CanvasPtr = std::shared_ptr<Canvas>;
|
||||
|
||||
class Canvas
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "Node.h"
|
||||
#include "../Renderer.h"
|
||||
#include "src/FileSystem/FileSystem.h"
|
||||
|
||||
#include "NodeState.h"
|
||||
#include "../StringHelper.h"
|
||||
@@ -480,7 +481,7 @@ namespace NuakeUI
|
||||
}
|
||||
else
|
||||
{
|
||||
auto texture = std::make_shared<Texture>(value.string);
|
||||
auto texture = CreateRef<Texture>(value.string);
|
||||
ComputedStyle.BackgroundImage = texture;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <charconv>
|
||||
#include <thread>
|
||||
|
||||
namespace NuakeUI
|
||||
{
|
||||
@@ -249,12 +250,25 @@ namespace NuakeUI
|
||||
}
|
||||
}
|
||||
|
||||
CanvasPtr CanvasParser::Parse(const std::string& path)
|
||||
Ref<Canvas> CanvasParser::Parse(const std::string& path)
|
||||
{
|
||||
_parsingPath = path;
|
||||
|
||||
tinyxml2::XMLDocument doc;
|
||||
if (tinyxml2::XMLError error = doc.LoadFile(path.c_str()))
|
||||
tinyxml2::XMLError error;
|
||||
bool fileLoaded = false;
|
||||
for (int i = 0; i < 5; ++i) { // Try 5 times
|
||||
error = doc.LoadFile(path.c_str());
|
||||
if (error == tinyxml2::XML_SUCCESS) {
|
||||
fileLoaded = true;
|
||||
break;
|
||||
}
|
||||
else if (error == tinyxml2::XML_ERROR_FILE_NOT_FOUND) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100)); // Wait before retrying
|
||||
}
|
||||
}
|
||||
|
||||
if (error)
|
||||
{
|
||||
doc.PrintError();
|
||||
return nullptr;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#include "src/Core/Core.h"
|
||||
#include "../Nodes/Canvas.h"
|
||||
|
||||
#include <functional>
|
||||
@@ -31,7 +32,7 @@ namespace NuakeUI
|
||||
bool HasNodeType(const std::string& name) const;
|
||||
refNew GetNodeType(const std::string& name) const;
|
||||
|
||||
CanvasPtr Parse(const std::string& file);
|
||||
Ref<Canvas> Parse(const std::string& file);
|
||||
private:
|
||||
void ScanFragment(tinyxml2::XMLElement* e, NodePtr node);
|
||||
void WriteValueFromString(std::variant<int, float, bool, std::string, char>& var, const std::string& str);
|
||||
|
||||
Reference in New Issue
Block a user