Merge pull request #19482 from hrydgard/ppge-double-ampersand
Some checks failed
Build / build (./b.sh --headless --unittest, clang, clang++, test, clang-normal, ubuntu-latest) (push) Failing after 0s
Build / build (./b.sh --headless --unittest, gcc, g++, gcc-normal, ubuntu-latest) (push) Failing after 0s
Build / build (./b.sh --libretro_android ppsspp_libretro, clang, clang++, android, android-libretro, ubuntu-latest) (push) Failing after 0s
Build / build (./b.sh --qt, gcc, g++, qt, qt, ubuntu-latest) (push) Failing after 0s
Build / build (cd android && ./ab.sh -j2 APP_ABI=arm64-v8a OPENXR=1, clang, clang++, android, android-vr, ubuntu-latest) (push) Failing after 0s
Build / build (cd android && ./ab.sh -j2 APP_ABI=arm64-v8a UNITTEST=1 HEADLESS=1, clang, clang++, android, android-arm64, ubuntu-latest) (push) Failing after 0s
Build / build (cd android && ./ab.sh -j2 APP_ABI=armeabi-v7a UNITTEST=1 HEADLESS=1, clang, clang++, android, android-arm32, ubuntu-latest) (push) Failing after 0s
Build / build (cd android && ./ab.sh -j2 APP_ABI=x86_64 UNITTEST=1 HEADLESS=1, clang, clang++, android, android-x86_64, ubuntu-latest) (push) Failing after 0s
Build / build (make -C libretro -f Makefile -j2, clang, clang++, libretro, clang-libretro, ubuntu-latest) (push) Failing after 0s
Build / build (make -C libretro -f Makefile -j2, gcc, g++, libretro, gcc-libretro, ubuntu-latest) (push) Failing after 0s
Build / build_test_headless_alpine (push) Failing after 0s
Generate Docker Layer / build (push) Failing after 0s
Build / build-windows (ARM64) (push) Has been cancelled
Build / build-windows (x64) (push) Has been cancelled
Build / build-uwp (push) Has been cancelled
Build / build (./b.sh --headless --unittest --fat --no-png --no-sdl2, clang, clang++, test, macos, macos-latest) (push) Has been cancelled
Build / build (./b.sh --ios, clang, clang++, ios, ios, macos-latest) (push) Has been cancelled
Build / test-windows (push) Has been cancelled
Build / test (macos-latest) (push) Has been cancelled
Build / test (ubuntu-latest) (push) Has been cancelled

Remove double ampersands from PPGe-drawn text (in-game UI)
This commit is contained in:
Henrik Rydgård 2024-09-22 18:29:30 +02:00 committed by GitHub
commit 1935bba789
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 13 deletions

View File

@ -94,7 +94,7 @@ void MIPSTracer::prepare_block(const MIPSComp::IRBlock* block, MIPSComp::IRBlock
trace_info.push_back({ virt_addr, storage_index });
u32 index = trace_info.size() - 1;
u32 index = (u32)(trace_info.size() - 1);
auto ir_ptr = (IRInst*)blocks.GetBlockInstructionPtr(*block);
ir_ptr[1].constant = index;
}

View File

@ -780,15 +780,13 @@ void PPGeMeasureText(float *w, float *h, std::string_view text, float scale, int
std::string s = PPGeSanitizeText(text);
if (HasTextDrawer()) {
std::string s2 = ReplaceAll(s, "&", "&&");
float mw, mh;
textDrawer->SetFontScale(scale, scale);
int dtalign = (WrapType & PPGE_LINE_WRAP_WORD) ? FLAG_WRAP_TEXT : 0;
if (WrapType & PPGE_LINE_USE_ELLIPSIS)
dtalign |= FLAG_ELLIPSIZE_TEXT;
Bounds b(0, 0, wrapWidth <= 0 ? 480.0f : wrapWidth, 272.0f);
textDrawer->MeasureStringRect(s2, b, &mw, &mh, dtalign);
textDrawer->MeasureStringRect(s, b, &mw, &mh, dtalign);
if (w)
*w = mw;
@ -898,14 +896,14 @@ inline int GetPow2(int x) {
return ret;
}
static PPGeTextDrawerImage PPGeGetTextImage(const char *text, const PPGeStyle &style, float maxWidth, bool wrap) {
static PPGeTextDrawerImage PPGeGetTextImage(std::string_view text, const PPGeStyle &style, float maxWidth, bool wrap) {
int tdalign = 0;
tdalign |= FLAG_ELLIPSIZE_TEXT;
if (wrap) {
tdalign |= FLAG_WRAP_TEXT;
}
PPGeTextDrawerCacheKey key{ text, tdalign, maxWidth / style.scale };
PPGeTextDrawerCacheKey key{ std::string(text), tdalign, maxWidth / style.scale };
PPGeTextDrawerImage im{};
auto cacheItem = textDrawerImages.find(key);
@ -1065,7 +1063,7 @@ void PPGeDrawText(std::string_view text, float x, float y, const PPGeStyle &styl
}
if (HasTextDrawer()) {
PPGeTextDrawerImage im = PPGeGetTextImage(ReplaceAll(str, "&", "&&").c_str(), style, 480.0f - x, false);
PPGeTextDrawerImage im = PPGeGetTextImage(str, style, 480.0f - x, false);
if (im.ptr) {
PPGeDrawTextImage(im, x, y, style);
return;
@ -1116,13 +1114,11 @@ void PPGeDrawTextWrapped(std::string_view text, float x, float y, float wrapWidt
float maxScaleDown = zoom == 1 ? 1.3f : 2.0f;
if (HasTextDrawer()) {
std::string s2 = ReplaceAll(s, "&", "&&");
float actualWidth, actualHeight;
Bounds b(0, 0, wrapWidth <= 0 ? 480.0f - x : wrapWidth, wrapHeight);
int tdalign = 0;
textDrawer->SetFontScale(style.scale, style.scale);
textDrawer->MeasureStringRect(s2, b, &actualWidth, &actualHeight, tdalign | FLAG_WRAP_TEXT);
textDrawer->MeasureStringRect(s, b, &actualWidth, &actualHeight, tdalign | FLAG_WRAP_TEXT);
// Check if we need to scale the text down to fit better.
PPGeStyle adjustedStyle = style;
@ -1138,14 +1134,14 @@ void PPGeDrawTextWrapped(std::string_view text, float x, float y, float wrapWidt
actualHeight = (maxLines + 1) * lineHeight;
// Add an ellipsis if it's just too long to be readable.
// On a PSP, it does this without scaling it down.
s2 = StripTrailingWhite(CropLinesToCount(s2, (int)maxLines));
s2.append("\n...");
s = StripTrailingWhite(CropLinesToCount(s, (int)maxLines));
s.append("\n...");
}
adjustedStyle.scale *= wrapHeight / actualHeight;
}
PPGeTextDrawerImage im = PPGeGetTextImage(s2.c_str(), adjustedStyle, wrapWidth <= 0 ? 480.0f - x : wrapWidth, true);
PPGeTextDrawerImage im = PPGeGetTextImage(s, adjustedStyle, wrapWidth <= 0 ? 480.0f - x : wrapWidth, true);
if (im.ptr) {
PPGeDrawTextImage(im, x, y, adjustedStyle);
return;