mirror of
https://github.com/thunderbrewhq/thunderbrew
synced 2025-12-08 18:36:00 +03:00
Compare commits
No commits in common. "a2e1dc98a212e54e3f5076beccbb9580573198c3" and "98111f2920475fa0fa2db23815d95043557ed14f" have entirely different histories.
a2e1dc98a2
...
98111f2920
@ -1 +1 @@
|
|||||||
Subproject commit 0401d901376995c7a209125b8cb12f1ceaa46fb7
|
Subproject commit a654f25957979c381760916f6382b526ef024491
|
||||||
105
src/gx/Font.cpp
105
src/gx/Font.cpp
@ -10,13 +10,11 @@
|
|||||||
#include "gx/Shader.hpp"
|
#include "gx/Shader.hpp"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdlib>
|
|
||||||
#include <bc/Memory.hpp>
|
#include <bc/Memory.hpp>
|
||||||
#include <storm/Error.hpp>
|
#include <storm/Error.hpp>
|
||||||
#include <storm/String.hpp>
|
#include <storm/String.hpp>
|
||||||
#include <storm/Unicode.hpp>
|
#include <storm/Unicode.hpp>
|
||||||
#include <tempest/Math.hpp>
|
#include <tempest/Math.hpp>
|
||||||
#include <common/Unicode.hpp>
|
|
||||||
|
|
||||||
CGxShader* g_fontPixelShader[1];
|
CGxShader* g_fontPixelShader[1];
|
||||||
CGxShader* g_fontVertexShader[2];
|
CGxShader* g_fontVertexShader[2];
|
||||||
@ -179,18 +177,7 @@ uint32_t GetScreenPixelWidth() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QUOTEDCODE GxuDetermineQuotedCode(const char* text, int32_t& advance, CImVector* color, uint32_t flags, uint32_t& wide) {
|
QUOTEDCODE GxuDetermineQuotedCode(const char* text, int32_t& advance, CImVector* color, uint32_t flags, uint32_t& wide) {
|
||||||
STORM_ASSERT(text);
|
wide = SUniSGetUTF8(reinterpret_cast<const uint8_t*>(text), &advance);
|
||||||
STORM_ASSERT(*text);
|
|
||||||
|
|
||||||
bool ignoreColorCodes = flags & 0x100;
|
|
||||||
bool ignoreNewlines = flags & 0x200;
|
|
||||||
bool ignoreHyperlinks = flags & 0x400;
|
|
||||||
bool ignorePipes = flags & 0x800;
|
|
||||||
bool ignoreTextures = flags & 0x1000;
|
|
||||||
|
|
||||||
auto utext = reinterpret_cast<const uint8_t*>(text);
|
|
||||||
|
|
||||||
wide = sgetu8(utext, &advance);
|
|
||||||
|
|
||||||
switch (wide) {
|
switch (wide) {
|
||||||
case 0x0:
|
case 0x0:
|
||||||
@ -198,7 +185,7 @@ QUOTEDCODE GxuDetermineQuotedCode(const char* text, int32_t& advance, CImVector*
|
|||||||
return CODE_INVALIDCODE;
|
return CODE_INVALIDCODE;
|
||||||
|
|
||||||
case '\r':
|
case '\r':
|
||||||
advance = 2 - (sgetu8(utext + 1, &advance) != '\n');
|
advance = 2 - (SUniSGetUTF8(reinterpret_cast<const uint8_t*>(text + 1), &advance) != '\n');
|
||||||
return CODE_NEWLINE;
|
return CODE_NEWLINE;
|
||||||
|
|
||||||
case '\n':
|
case '\n':
|
||||||
@ -206,7 +193,7 @@ QUOTEDCODE GxuDetermineQuotedCode(const char* text, int32_t& advance, CImVector*
|
|||||||
return CODE_NEWLINE;
|
return CODE_NEWLINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wide != '|' || ignorePipes) {
|
if (wide != '|' || flags & 0x800) {
|
||||||
return CODE_INVALIDCODE;
|
return CODE_INVALIDCODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -216,98 +203,18 @@ QUOTEDCODE GxuDetermineQuotedCode(const char* text, int32_t& advance, CImVector*
|
|||||||
return CODE_INVALIDCODE;
|
return CODE_INVALIDCODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t firstCharAdvance = advance;
|
|
||||||
|
|
||||||
switch (quotedCode) {
|
switch (quotedCode) {
|
||||||
case 'C':
|
|
||||||
case 'c': {
|
|
||||||
if (ignoreColorCodes) {
|
|
||||||
return CODE_INVALIDCODE;
|
|
||||||
}
|
|
||||||
size_t offset = advance + 1;
|
|
||||||
|
|
||||||
uint8_t comps[4];
|
|
||||||
|
|
||||||
for (size_t j = 0; j < 4; ++j) {
|
|
||||||
if (!text[offset] || !text[offset + 1]) {
|
|
||||||
return CODE_INVALIDCODE;
|
|
||||||
}
|
|
||||||
|
|
||||||
char hex[3] = { text[offset], text[offset + 1], '\0' };
|
|
||||||
offset += 2;
|
|
||||||
char* error = nullptr;
|
|
||||||
comps[j] = static_cast<uint8_t>(strtol(hex, &error, 16));
|
|
||||||
if (error && *error) {
|
|
||||||
return CODE_INVALIDCODE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (color) {
|
|
||||||
color->value = CImVector::MakeARGB(255, comps[1], comps[2], comps[3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
advance = 10;
|
|
||||||
return CODE_COLORON;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'H': {
|
|
||||||
if (ignoreHyperlinks) {
|
|
||||||
return CODE_INVALIDCODE;
|
|
||||||
}
|
|
||||||
// TODO
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'N':
|
case 'N':
|
||||||
case 'n': {
|
case 'n': {
|
||||||
if (ignoreNewlines) {
|
if (flags & 0x200) {
|
||||||
return CODE_INVALIDCODE;
|
return CODE_INVALIDCODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
advance = 2;
|
advance = 2;
|
||||||
return CODE_NEWLINE;
|
return CODE_NEWLINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'R':
|
// TODO handle other control codes
|
||||||
case 'r': {
|
|
||||||
if (ignoreColorCodes) {
|
|
||||||
return CODE_INVALIDCODE;
|
|
||||||
}
|
|
||||||
advance = 2;
|
|
||||||
return CODE_COLORRESTORE;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'T': {
|
|
||||||
if (ignoreTextures) {
|
|
||||||
return CODE_INVALIDCODE;
|
|
||||||
}
|
|
||||||
// TODO
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'h': {
|
|
||||||
if (ignoreHyperlinks) {
|
|
||||||
return CODE_INVALIDCODE;
|
|
||||||
}
|
|
||||||
advance = 2;
|
|
||||||
return CODE_HYPERLINKSTOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 't': {
|
|
||||||
if (ignoreTextures) {
|
|
||||||
return CODE_INVALIDCODE;
|
|
||||||
}
|
|
||||||
advance = 2;
|
|
||||||
return CODE_TEXTURESTOP;
|
|
||||||
}
|
|
||||||
|
|
||||||
case '|': {
|
|
||||||
advance = 2;
|
|
||||||
return CODE_PIPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
return CODE_INVALIDCODE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO remainder of function
|
// TODO remainder of function
|
||||||
|
|||||||
@ -348,7 +348,7 @@ int32_t CGxString::Initialize(float fontHeight, const C3Vector& position, float
|
|||||||
|
|
||||||
face->m_strings.LinkToTail(this);
|
face->m_strings.LinkToTail(this);
|
||||||
|
|
||||||
float requestedFontHeight = ((this->m_flags & 0x4) && !(this->m_flags & 0x80))
|
float requestedFontHeight = this->m_flags & 0x4 && !(this->m_flags & 0x80)
|
||||||
? GxuFontGetOneToOneHeight(face)
|
? GxuFontGetOneToOneHeight(face)
|
||||||
: fontHeight;
|
: fontHeight;
|
||||||
this->m_requestedFontHeight = requestedFontHeight;
|
this->m_requestedFontHeight = requestedFontHeight;
|
||||||
@ -382,7 +382,7 @@ void CGxString::InitializeTextLine(const char* currentText, uint32_t numBytes, C
|
|||||||
float stepGlyph = 0.0f;
|
float stepGlyph = 0.0f;
|
||||||
float stepScreen = 0.0f;
|
float stepScreen = 0.0f;
|
||||||
uint32_t prevCode = 0;
|
uint32_t prevCode = 0;
|
||||||
CImVector color = this->m_fontColor;
|
CImVector color;
|
||||||
|
|
||||||
while (numBytes && *currentText) {
|
while (numBytes && *currentText) {
|
||||||
int32_t advance;
|
int32_t advance;
|
||||||
|
|||||||
@ -876,17 +876,9 @@ void CSimpleFontString::UpdateString() {
|
|||||||
uint32_t styleFlags = this->m_styleFlags;
|
uint32_t styleFlags = this->m_styleFlags;
|
||||||
|
|
||||||
if (!(this->m_styleFlags & 0x400)) {
|
if (!(this->m_styleFlags & 0x400)) {
|
||||||
// Set FixedColor flag if the text does not contain color tags
|
// TODO
|
||||||
bool found = false;
|
|
||||||
for (size_t i = 0; displayText && displayText[i]; ++i) {
|
styleFlags |= 0x400;
|
||||||
if (displayText[i] == '|' && (displayText[i + 1] == 'C' || displayText[i + 1] == 'c')) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
styleFlags |= 0x400u;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CImVector color = { 0xFF, 0xFF, 0xFF, 0xFF };
|
CImVector color = { 0xFF, 0xFF, 0xFF, 0xFF };
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user