add dialogue and cutscene system
This commit is contained in:
1 parent
178f69967b
commit
7125674308
23 files changed
+1619
-2
No files matched your search
@@ -133,6 +133,8 @@ bool TextRenderer::loadGlyphs(const std::string& ttfPath, int pixelSize, const s
|
||||
glyphList.emplace_back((char)c, std::move(gb));
|
||||
}
|
||||
|
||||
lineHeight = std::max<float>(static_cast<float>(pixelSize) * 1.3f, static_cast<float>(maxGlyphHeight) * 1.25f);
|
||||
|
||||
// Пакуем глифы в один атлас (упрощённый алгоритм строковой укладки)
|
||||
const int padding = 1;
|
||||
const int maxAtlasWidth = 1024; // безопасное значение для большинства устройств
|
||||
@@ -296,8 +298,16 @@ void TextRenderer::drawText(const std::string& text, float x, float y, float sca
|
||||
|
||||
float totalW = 0.0f;
|
||||
float maxH = 0.0f;
|
||||
|
||||
|
||||
float maxLineWidth = 0.0f;
|
||||
for (char ch : text) {
|
||||
if (ch == '\n') {
|
||||
maxLineWidth = max(maxLineWidth, penX);
|
||||
penX = 0.0f;
|
||||
penY -= lineHeight * scale;
|
||||
continue;
|
||||
}
|
||||
|
||||
auto git = glyphs.find(ch);
|
||||
if (git == glyphs.end()) continue;
|
||||
const GlyphInfo& g = git->second;
|
||||
@@ -332,6 +342,7 @@ void TextRenderer::drawText(const std::string& text, float x, float y, float sca
|
||||
totalW = penX;
|
||||
maxH = max(maxH, h);
|
||||
}
|
||||
totalW = max(maxLineWidth, penX);
|
||||
|
||||
// Сохраняем в кеш
|
||||
CachedText ct;
|
||||
|
||||
@@ -47,6 +47,7 @@ private:
|
||||
std::shared_ptr<Texture> atlasTexture;
|
||||
size_t atlasWidth = 0;
|
||||
size_t atlasHeight = 0;
|
||||
float lineHeight = 32.0f;
|
||||
|
||||
VertexRenderStruct textMesh;
|
||||
|
||||
|
||||
Reference in new issue
Block a user