mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Merge pull request #19227 from hrydgard/more-text-fixes
More text fixes on iOS/Mac
This commit is contained in:
@@ -33,14 +33,14 @@ float linearOut(int t, int fadeOutLength) {
|
||||
}
|
||||
|
||||
float ease(float val) {
|
||||
if (val > 1.0f) return 1.0f;
|
||||
if (val < 0.0f) return 0.0f;
|
||||
if (val >= 1.0f) return 1.0f;
|
||||
if (val <= 0.0f) return 0.0f;
|
||||
return (float)(((-cosf(val * PI)) + 1.0f) * 0.5);
|
||||
}
|
||||
|
||||
float ease(int t, int fadeLength)
|
||||
{
|
||||
if (t < 0) return 0.0f;
|
||||
if (t <= 0.0f) return 0.0f;
|
||||
if (t >= fadeLength) return 1.0f;
|
||||
return ease((float)t / (float)fadeLength);
|
||||
}
|
||||
|
||||
@@ -113,10 +113,10 @@ void TextDrawer::DrawString(DrawBuffer &target, std::string_view str, float x, f
|
||||
draw_->BindTexture(0, entry->texture);
|
||||
|
||||
// Okay, the texture is bound, let's draw.
|
||||
float w = entry->width * fontScaleX_ * dpiScale_;
|
||||
float h = entry->height * fontScaleY_ * dpiScale_;
|
||||
float u = entry->width / (float)entry->bmWidth;
|
||||
float v = entry->height / (float)entry->bmHeight;
|
||||
float w = (float)entry->width * (fontScaleX_ * dpiScale_);
|
||||
float h = (float)entry->height * (fontScaleY_ * dpiScale_);
|
||||
float u = (float)entry->width / (float)entry->bmWidth;
|
||||
float v = (float)entry->height / (float)entry->bmHeight;
|
||||
DrawBuffer::DoAlign(align, &x, &y, &w, &h);
|
||||
|
||||
target.DrawTexRect(x, y, x + w, y + h, 0.0f, 0.0f, u, v, color);
|
||||
|
||||
@@ -184,8 +184,8 @@ bool TextDrawerCocoa::DrawStringBitmap(std::vector<uint8_t> &bitmapData, TextStr
|
||||
float w, h;
|
||||
MeasureString(str, &w, &h);
|
||||
// Reverse the DPI scale that MeasureString baked in.
|
||||
w /= dpiScale_;
|
||||
h /= dpiScale_;
|
||||
w /= (dpiScale_ * fontScaleX_);
|
||||
h /= (dpiScale_ * fontScaleY_);
|
||||
|
||||
int width = (int)ceilf(w);
|
||||
int height = (int)ceilf(h);
|
||||
|
||||
+1
-3
@@ -1041,15 +1041,13 @@ void CreditsScreen::DrawForeground(UIContext &dc) {
|
||||
float t = (float)(time_now_d() - startTime_) * 60.0;
|
||||
|
||||
float y = bounds.y2() - fmodf(t, (float)totalHeight);
|
||||
std::string line;
|
||||
for (int i = 0; i < numItems; i++) {
|
||||
float alpha = linearInOut(y+32, 64, bounds.y2() - 192, 64);
|
||||
uint32_t textColor = colorAlpha(dc.theme->infoStyle.fgColor, alpha);
|
||||
|
||||
if (alpha > 0.0f) {
|
||||
dc.SetFontScale(ease(alpha), ease(alpha));
|
||||
line = credits[i];
|
||||
dc.DrawText(line.c_str(), bounds.centerX(), y, textColor, ALIGN_HCENTER);
|
||||
dc.DrawText(credits[i], bounds.centerX(), y, textColor, ALIGN_HCENTER);
|
||||
dc.SetFontScale(1.0f, 1.0f);
|
||||
}
|
||||
y += itemHeight;
|
||||
|
||||
Reference in New Issue
Block a user