Merge pull request #14690 from hrydgard/memstick-screen-translatability

Improve translatability of memstick screen
This commit is contained in:
Henrik Rydgård 2021-08-07 00:47:43 +02:00 committed by GitHub
commit f9b31ed22d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 10 deletions

View file

@ -801,6 +801,8 @@ void ImageView::Draw(UIContext &dc) {
}
}
const float bulletOffset = 25;
void TextView::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert, float &w, float &h) const {
Bounds bounds(0, 0, layoutParams_->width, layoutParams_->height);
if (bounds.w < 0) {
@ -812,6 +814,10 @@ void TextView::GetContentDimensionsBySpec(const UIContext &dc, MeasureSpec horiz
}
ApplyBoundsBySpec(bounds, horiz, vert);
dc.MeasureTextRect(small_ ? dc.theme->uiFontSmall : dc.theme->uiFont, 1.0f, 1.0f, text_.c_str(), (int)text_.length(), bounds, &w, &h, textAlign_);
if (bullet_) {
w += bulletOffset;
}
}
void TextView::Draw(UIContext &dc) {
@ -838,11 +844,23 @@ void TextView::Draw(UIContext &dc) {
dc.FillRect(style.background, bounds_);
}
dc.SetFontStyle(small_ ? dc.theme->uiFontSmall : dc.theme->uiFont);
Bounds textBounds = bounds_;
if (bullet_) {
// Possible alternatives: •●■
// TODO: Maybe draw an actual circle if we don't have real unicode fonts. So far this is only
// used on Android.
dc.DrawTextRect("", textBounds, textColor, ALIGN_LEFT);
textBounds.x += bulletOffset;
textBounds.w -= bulletOffset;
}
if (shadow_) {
uint32_t shadowColor = 0x80000000;
dc.DrawTextRect(text_.c_str(), bounds_.Offset(1.0f, 1.0f), shadowColor, textAlign_);
dc.DrawTextRect(text_.c_str(), textBounds.Offset(1.0f, 1.0f), shadowColor, textAlign_);
}
dc.DrawTextRect(text_.c_str(), bounds_, textColor, textAlign_);
dc.DrawTextRect(text_.c_str(), textBounds, textColor, textAlign_);
if (small_) {
// If we changed font style, reset it.
dc.SetFontStyle(dc.theme->uiFont);

View file

@ -841,6 +841,7 @@ public:
void SetShadow(bool shadow) { shadow_ = shadow; }
void SetFocusable(bool focusable) { focusable_ = focusable; }
void SetClip(bool clip) { clip_ = clip; }
void SetBullet(bool bullet) { bullet_ = bullet; }
bool CanBeFocused() const override { return focusable_; }
@ -853,6 +854,7 @@ private:
bool shadow_;
bool focusable_;
bool clip_;
bool bullet_ = false;
};
class TextEdit : public View {

View file

@ -134,28 +134,33 @@ void MemStickScreen::CreateViews() {
leftColumn->Add(new TextView(iz->T("ScopedStorageWarning", "WARNING: BETA ANDROID SCOPED STORAGE SUPPORT\nMAY EAT YOUR DATA"), ALIGN_LEFT, false));
}
leftColumn->Add(new TextView(iz->T("MemoryStickDescription", "Choose PSP data storage (Memory Stick)"), ALIGN_LEFT, false));
leftColumn->Add(new TextView(iz->T("MemoryStickDescription", "Choose PSP data storage (Memory Stick):"), ALIGN_LEFT, false));
// For legacy Android systems, so you can switch back to the old ways if you move to SD or something.
// TODO: Gonna need a scroll view.
#if PPSSPP_PLATFORM(ANDROID)
if (!System_GetPropertyBool(SYSPROP_ANDROID_SCOPED_STORAGE)) {
leftColumn->Add(new Choice(iz->T("Use PSP folder at root of storage")))->OnClick.Handle(this, &MemStickScreen::OnUseStorageRoot);
leftColumn->Add(new TextView(iz->T("ChooseFolderDesc", "* Data will stay even if you uninstall PPSSPP.\n* Data can be shared between PPSSPP regular/Gold.\n* Easy USB access"), ALIGN_LEFT, false));
leftColumn->Add(new TextView(iz->T("DataWillStay", "Data will stay even if you uninstall PPSSPP.")))->SetBullet(true);
leftColumn->Add(new TextView(iz->T("DataCanBeShared", "Data can be shared between PPSSPP regular/Gold.")))->SetBullet(true);
leftColumn->Add(new TextView(iz->T("EasyUSBAccess", "Easy USB access")))->SetBullet(true);
}
#endif
leftColumn->Add(new Choice(iz->T("Create or Choose a PSP folder")))->OnClick.Handle(this, &MemStickScreen::OnBrowse);
leftColumn->Add(new TextView(iz->T("ChooseFolderDesc", "* Data will stay even if you uninstall PPSSPP.\n* Data can be shared between PPSSPP regular/Gold\n* Easy USB access"), ALIGN_LEFT, false));
leftColumn->Add(new TextView(iz->T("DataWillStay", "Data will stay even if you uninstall PPSSPP.")))->SetBullet(true);
leftColumn->Add(new TextView(iz->T("DataCanBeShared", "Data can be shared between PPSSPP regular/Gold.")))->SetBullet(true);
leftColumn->Add(new TextView(iz->T("EasyUSBAccess", "Easy USB access")))->SetBullet(true);
leftColumn->Add(new Choice(iz->T("Use App Private Directory")))->OnClick.Handle(this, &MemStickScreen::OnUseInternalStorage);
leftColumn->Add(new TextView(iz->T("InternalStorageDesc", "* Warning! Data will be deleted if you uninstall PPSSPP!\n* Data cannot be shared between PPSSPP regular/Gold\n* USB access through "
#ifdef GOLD
"Android/data/org.ppsspp.ppssppgold/files"
// Consider https://www.compart.com/en/unicode/U+26A0 (unicode warning sign?)? or a graphic?
leftColumn->Add(new TextView(iz->T("DataWillBeLostOnUninstall", "Warning! Data will be lost when you uninstall PPSSPP!")))->SetBullet(true);
leftColumn->Add(new TextView(iz->T("DataCannotBeShared", "Data CANNOT be shared between PPSSPP regular/Gold!")))->SetBullet(true);
#if GOLD
leftColumn->Add(new TextView(iz->T("USBAccessThroughGold", "USB access through Android/data/org.ppsspp.ppssppgold/files")))->SetBullet(true);
#else
"Android/data/org.ppsspp.ppsspp/files"
leftColumn->Add(new TextView(iz->T("USBAccessThrough", "USB access through Android/data/org.ppsspp.ppsspp/files")))->SetBullet(true);
#endif
), ALIGN_LEFT, false));
leftColumn->Add(new Spacer(new LinearLayoutParams(FILL_PARENT, 12.0f, 0.0f)));