Added text size for text renderable component
This commit is contained in:
parent
e2ef32f130
commit
e05e21ec5a
|
@ -601,7 +601,7 @@ namespace SHADE
|
|||
component->SetText(val);
|
||||
}
|
||||
);
|
||||
|
||||
SHEditorWidgets::DragVec3("Text Size", { "X", "Y", "Z" }, [&textComp = component]() {return textComp->GetTextSize();}, [&textComp = component](SHVec3 const& size) {textComp->SetTextSize(size); });
|
||||
SHEditorWidgets::ColorPicker("Color", [&textComp = component]() {return textComp->GetColor(); }, [&textComp = component](SHVec4 const& newColor) {textComp->SetColor(newColor); });
|
||||
}
|
||||
else
|
||||
|
|
|
@ -29,6 +29,8 @@ namespace SHADE
|
|||
|
||||
// Default white color.
|
||||
color = SHColour::WHITE;
|
||||
|
||||
textSize = SHVec3::One;
|
||||
}
|
||||
|
||||
void SHTextRenderableComponent::OnDestroy(void)
|
||||
|
@ -66,6 +68,11 @@ namespace SHADE
|
|||
color = newColor;
|
||||
}
|
||||
|
||||
void SHTextRenderableComponent::SetTextSize(SHVec3 const& size) noexcept
|
||||
{
|
||||
textSize = size;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/*!
|
||||
|
||||
|
@ -92,6 +99,11 @@ namespace SHADE
|
|||
return color;
|
||||
}
|
||||
|
||||
SHVec3 const& SHTextRenderableComponent::GetTextSize(void) const noexcept
|
||||
{
|
||||
return textSize;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace rttr
|
||||
|
|
|
@ -40,6 +40,9 @@ namespace SHADE
|
|||
//! character position data for each letter in the text
|
||||
Handle<SHVkBuffer> charPositionDataBuffer;
|
||||
|
||||
//! Text size. Multiplied to TRS.
|
||||
SHVec3 textSize;
|
||||
|
||||
void MakeDirty (void) noexcept;
|
||||
void Clean (void) noexcept;
|
||||
|
||||
|
@ -53,10 +56,12 @@ namespace SHADE
|
|||
void SetText (std::string_view newText) noexcept;
|
||||
void SetFont(Handle<SHFont> font) noexcept;
|
||||
void SetColor(SHColour const& newColor) noexcept;
|
||||
void SetTextSize (SHVec3 const& size) noexcept;
|
||||
|
||||
std::string const& GetText (void) const noexcept;
|
||||
Handle<SHFont> GetFont (void) const noexcept;
|
||||
SHColour const& GetColor (void) const noexcept;
|
||||
SHVec3 const& GetTextSize (void) const noexcept;
|
||||
|
||||
friend class SHTextRenderingSubSystem;
|
||||
|
||||
|
|
|
@ -210,10 +210,13 @@ namespace SHADE
|
|||
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::CALCULATED_GLYPH_POSITION, comp.charPositionDataBuffer, 0);
|
||||
cmdBuffer->BindVertexBuffer(SHGraphicsConstants::VertexBufferBindings::GLYPH_INDEX, comp.indexingDataBuffer, 0);
|
||||
|
||||
auto const& textSize = comp.textSize;
|
||||
SHMatrix textSizeScale{textSize.x, 0.0f, 0.0f, 0.0f, 0.0f, textSize.y, 0.0f, 0.0f, 0.0f, 0.0f, textSize.z, 0.0f};
|
||||
|
||||
if (auto* uiComp = SHComponentManager::GetComponent_s<SHUIComponent>(comp.GetEID()))
|
||||
cmdBuffer->SetPushConstantVariable("TestPushConstant.worldTransform", uiComp->GetMatrix(), SH_PIPELINE_TYPE::GRAPHICS);
|
||||
cmdBuffer->SetPushConstantVariable("TestPushConstant.worldTransform", textSizeScale * uiComp->GetMatrix(), SH_PIPELINE_TYPE::GRAPHICS);
|
||||
else
|
||||
cmdBuffer->SetPushConstantVariable("TestPushConstant.worldTransform", transform->GetTRS(), SH_PIPELINE_TYPE::GRAPHICS);
|
||||
cmdBuffer->SetPushConstantVariable("TestPushConstant.worldTransform", textSizeScale * transform->GetTRS(), SH_PIPELINE_TYPE::GRAPHICS);
|
||||
|
||||
|
||||
cmdBuffer->SetPushConstantVariable("TestPushConstant.eid", comp.GetEID(), SH_PIPELINE_TYPE::GRAPHICS);
|
||||
|
|
|
@ -357,6 +357,7 @@ 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 constexpr std::string_view TEXT_SIZE_YAML_TAG = "Text Size";
|
||||
|
||||
static YAML::Node encode(SHTextRenderableComponent const& rhs)
|
||||
{
|
||||
|
@ -372,7 +373,8 @@ namespace YAML
|
|||
{
|
||||
node[FONT_YAML_TAG.data()] = 0;
|
||||
}
|
||||
node[COLOR_YAML_TAG.data()] = SHVec4 (textColor);
|
||||
node[COLOR_YAML_TAG.data()] = SHVec4(textColor);
|
||||
node[TEXT_SIZE_YAML_TAG.data()] = rhs.GetTextSize();
|
||||
return node;
|
||||
}
|
||||
static bool decode(YAML::Node const& node, SHTextRenderableComponent& rhs)
|
||||
|
@ -395,6 +397,10 @@ namespace YAML
|
|||
{
|
||||
rhs.SetColor(node[COLOR_YAML_TAG.data()].as<SHVec4>());
|
||||
}
|
||||
if (node[TEXT_SIZE_YAML_TAG.data()].IsDefined())
|
||||
{
|
||||
rhs.SetTextSize(node[TEXT_SIZE_YAML_TAG.data()].as<SHVec3>());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue