Implemented serialization for text color and trajectory rendering #381
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue