Fixed some bugs and added parsing

This commit is contained in:
2023-06-16 15:48:33 -07:00
parent 2964aa4a95
commit e6350d99e9
17 changed files with 157 additions and 42 deletions

View File

@ -25,7 +25,7 @@ void UILabel::onStart() {
}
std::vector<struct ShaderPassItem> UILabel::getUIRenderPasses() {
// if(this->texts.size() == 0) return {};
if(this->textsBuffered.empty()) return {};
auto canvas = this->getCanvas();
auto shader = getGame()->renderManager.fontShader;
@ -264,10 +264,12 @@ void UILabel::rebufferQuads(const std::vector<struct UILabelText> newTexts) {
}
// Create mesh
this->mesh.createBuffers(
QUAD_VERTICE_COUNT * vertices.size(),
QUAD_INDICE_COUNT * vertices.size()
);
if(!vertices.empty()) {
this->mesh.createBuffers(
QUAD_VERTICE_COUNT * vertices.size(),
QUAD_INDICE_COUNT * vertices.size()
);
}
// Now buffer the quads.
int32_t j = 0;

View File

@ -22,6 +22,11 @@ void UIRichTextLabel::onStart() {
struct UILabelStyle current;
styleStack.push_back(current);
std::vector<struct UILabelText> bufferTexts;
if(this->richText._realValue.empty()) {
this->rebufferQuads(bufferTexts);
return;
}
std::function<void(Xml*)> parseChildren = [&](Xml *node) {
if(node->children.empty()) {

View File

@ -9,6 +9,7 @@
namespace Dawn {
class UIRichTextLabel : public UILabel {
public:
// @innerXml
StateProperty<std::string> richText;
UIRichTextLabel(SceneItem *item);