Implemented serialization for text color and trajectory rendering #381

Merged
Xenosas1337 merged 10 commits from SP3-1-Rendering into main 2023-03-02 12:47:35 +08:00
4 changed files with 12 additions and 5 deletions
Showing only changes of commit 4b37be6075 - Show all commits

View File

@ -600,7 +600,7 @@ namespace SHADE
}
);
SHEditorWidgets::ColorPicker("Color", [&textComp = component]() {return textComp->GetColour(); }, [&textComp = component](SHVec4 const& newColor) {textComp->SetColour(newColor); });
SHEditorWidgets::ColorPicker("Color", [&textComp = component]() {return textComp->GetColor(); }, [&textComp = component](SHVec4 const& newColor) {textComp->SetColor(newColor); });
}
else
{

View File

@ -61,7 +61,7 @@ namespace SHADE
MakeDirty();
}
void SHTextRenderableComponent::SetColour(SHColour const& newColor) noexcept
void SHTextRenderableComponent::SetColor(SHColour const& newColor) noexcept
{
color = newColor;
}
@ -87,7 +87,7 @@ namespace SHADE
return fontHandle;
}
SHADE::SHColour const& SHTextRenderableComponent::GetColour(void) const noexcept
SHADE::SHColour const& SHTextRenderableComponent::GetColor(void) const noexcept
{
return color;
}

View File

@ -52,11 +52,11 @@ namespace SHADE
/*-----------------------------------------------------------------------*/
void SetText (std::string_view newText) noexcept;
void SetFont(Handle<SHFont> font) noexcept;
void SetColour(SHColour const& newColor) noexcept;
void SetColor(SHColour const& newColor) noexcept;
std::string const& GetText (void) const noexcept;
Handle<SHFont> GetFont (void) const noexcept;
SHColour const& GetColour (void) const noexcept;
SHColour const& GetColor (void) const noexcept;
friend class SHTextRenderingSubSystem;

View File

@ -353,12 +353,14 @@ namespace YAML
{
static constexpr std::string_view TEXT_YAML_TAG = "Text";
static constexpr std::string_view FONT_YAML_TAG = "Font";
static constexpr std::string_view COLOR_YAML_TAG = "Color";
static YAML::Node encode(SHTextRenderableComponent const& rhs)
{
YAML::Node node;
node[TEXT_YAML_TAG.data()] = rhs.GetText();
auto font = rhs.GetFont();
SHColour const& textColor = rhs.GetColor();
if (font)
{
node[FONT_YAML_TAG.data()] = SHResourceManager::GetAssetID<SHFont>(rhs.GetFont()).value_or(0);
@ -367,6 +369,7 @@ namespace YAML
{
node[FONT_YAML_TAG.data()] = 0;
}
node[COLOR_YAML_TAG.data()] = SHVec4 (textColor);
return node;
}
static bool decode(YAML::Node const& node, SHTextRenderableComponent& rhs)
@ -385,6 +388,10 @@ namespace YAML
rhs.SetFont(SHResourceManager::LoadOrGet<SHFont>(node[FONT_YAML_TAG.data()].as<AssetID>()));
}
if (node[COLOR_YAML_TAG.data()].IsDefined())
{
rhs.SetColor(node[COLOR_YAML_TAG.data()].as<SHVec4>());
}
return true;
}
};