Progress untangle

This commit is contained in:
2023-06-14 21:14:52 -07:00
parent aab5548ae2
commit a30d1758f4
10 changed files with 191 additions and 106 deletions

View File

@ -0,0 +1,85 @@
// Copyright (c) 2023 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "scene/components/ui/UIComponentRenderable.hpp"
#include "display/mesh/QuadMesh.hpp"
#include "asset/assets/NewTrueTypeAsset.hpp"
#include "util/Xml.hpp"
#define UI_LABEL_MAX_WIDTH_NONE -1
namespace Dawn {
struct UILabelStyle {
struct Color color = COLOR_WHITE;
flag_t style = 0;
uint32_t size = 16;
NewTrueTypeAsset *font = nullptr;
};
struct UILabelText {
std::string text;
struct UILabelStyle style;
// Part index?
// Quad start?
// quad count?
// position?
// size?
// some kind of custom data e.g. wobble or shake?
usagelockid_t lockId = -1;
struct NewTrueTypeFaceTexture *texture = nullptr;
};
class UILabel : public UIComponentRenderable {
private:
Mesh mesh;
FontShaderBuffer shaderBuffer;
std::vector<struct UILabelText> texts;
std::map<NewTrueTypeFaceTexture*, int32_t> textureMap;
/**
* Buffers the quads for the given text and updates the progressing values
* as the buffer process continues.
*
* @param text Text information to buffer.
* @param bufferData The output quad mappings for the text.
* @param textureMap Texture map for the textures to map.
* @param position The 2D position to buffer the quads at.
* @param quadStart The starting quad index.
* @param partIndex The part index to store for each quad buffered.
* @return The number of quads buffered, not the string length.
*/
int32_t bufferQuads(
struct UILabelText text,
struct FontShaderBufferData &bufferData,
std::map<NewTrueTypeFaceTexture*, int32_t> &textureMap,
glm::vec2 &position,
int32_t quadStart,
int32_t partIndex
);
public:
int32_t quadStart = 0;
int32_t quadCount = -1;
int32_t quadCountTotal = -1;
UILabel(SceneItem *item);
void onStart() override;
std::vector<struct ShaderPassItem> getUIRenderPasses() override;
float_t getContentWidth() override;
float_t getContentHeight() override;
/**
* Rebuffer the quads for this label. This method will perform all the
* necessary difference calculations from where the current state of this text is.
*
* @param texts Texts to buffer.
*/
void rebufferQuads(std::vector<struct UILabelText> texts);
};
}