From 979bc58cacaca79b7f5af0d77fa0827f0795047b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 3 Jun 2017 08:37:55 -0700 Subject: [PATCH 1/7] UI: Translate AVI start/stop strings. --- UI/EmuScreen.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 0414cba69d..0e496cf644 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -88,6 +88,8 @@ static bool startDumping; static void __EmuScreenVblank() { + I18NCategory *sy = GetI18NCategory("System"); + if (frameStep_ && lastNumFlips != gpuStats.numFlips) { frameStep_ = false; @@ -98,7 +100,7 @@ static void __EmuScreenVblank() if (g_Config.bDumpFrames && !startDumping) { avi.Start(PSP_CoreParameter().renderWidth, PSP_CoreParameter().renderHeight); - osm.Show("AVI Dump started.", 3.0f); + osm.Show(sy->T("AVI Dump started."), 3.0f); startDumping = true; } if (g_Config.bDumpFrames && startDumping) @@ -108,7 +110,7 @@ static void __EmuScreenVblank() else if (!g_Config.bDumpFrames && startDumping) { avi.Stop(); - osm.Show("AVI Dump stopped.", 3.0f); + osm.Show(sy->T("AVI Dump stopped."), 3.0f); startDumping = false; } #endif From cb1b8f23bb4f1351f304e5bcc752716a5b2176c0 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 3 Jun 2017 08:41:56 -0700 Subject: [PATCH 2/7] UI: Fix fade-out when editing touch controls. --- UI/GamepadEmu.h | 2 +- UI/TouchControlLayoutScreen.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/UI/GamepadEmu.h b/UI/GamepadEmu.h index 00d28d9ab8..79e72bcf43 100644 --- a/UI/GamepadEmu.h +++ b/UI/GamepadEmu.h @@ -34,7 +34,7 @@ public: void Update() override; protected: - float GetButtonOpacity(); + virtual float GetButtonOpacity(); float lastFrameTime_; float secondsWithoutTouch_; diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 0680dbd218..ca99089358 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -15,6 +15,7 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include #include #include "base/colorutil.h" @@ -65,6 +66,12 @@ public: virtual float GetSpacing() const { return 1.0f; } virtual void SetSpacing(float s) { } +protected: + float GetButtonOpacity() override { + float opacity = g_Config.iTouchButtonOpacity / 100.0f; + return std::max(0.5f, opacity); + } + private: // convert from screen coordinates (leftColumnWidth to dp_xres) to actual fullscreen coordinates (0 to 1.0) inline float toFullscreenCoord(int screenx) { From c4af8be5ef05cca29b4fb570163efb385235b5a7 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 3 Jun 2017 08:48:35 -0700 Subject: [PATCH 3/7] UI: Enable mouse settings only if checked. Like other settings do. --- UI/GameSettingsScreen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 4e1d3cf4fb..34b8b72d89 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -590,9 +590,9 @@ void GameSettingsScreen::CreateViews() { settingInfo_->Show(co->T("MouseControl Tip", "You can now map mouse in control mapping screen by pressing the 'M' icon."), e.v); return UI::EVENT_CONTINUE; }); - controlsSettings->Add(new CheckBox(&g_Config.bMouseConfine, co->T("Confine Mouse", "Trap mouse within window/display area"))); - controlsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fMouseSensitivity, 0.01f, 1.0f, co->T("Mouse sensitivity"), 0.01f, screenManager(), "x")); - controlsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fMouseSmoothing, 0.0f, 0.95f, co->T("Mouse smoothing"), 0.05f, screenManager(), "x")); + controlsSettings->Add(new CheckBox(&g_Config.bMouseConfine, co->T("Confine Mouse", "Trap mouse within window/display area")))->SetEnabledPtr(&g_Config.bMouseControl); + controlsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fMouseSensitivity, 0.01f, 1.0f, co->T("Mouse sensitivity"), 0.01f, screenManager(), "x"))->SetEnabledPtr(&g_Config.bMouseControl); + controlsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fMouseSmoothing, 0.0f, 0.95f, co->T("Mouse smoothing"), 0.05f, screenManager(), "x"))->SetEnabledPtr(&g_Config.bMouseControl); #endif ViewGroup *networkingSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); From 64c21949890a9e7d0d96232886d8df2d2d24a20e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 3 Jun 2017 08:52:42 -0700 Subject: [PATCH 4/7] UI: Allow texture ini create only within game. --- UI/GameSettingsScreen.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 34b8b72d89..90391e46b1 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1275,7 +1275,11 @@ void DeveloperToolsScreen::CreateViews() { list->Add(new CheckBox(&g_Config.bSaveNewTextures, dev->T("Save new textures"))); list->Add(new CheckBox(&g_Config.bReplaceTextures, dev->T("Replace textures"))); #if !defined(MOBILE_DEVICE) - list->Add(new Choice(dev->T("Create/Open textures.ini file for current game")))->OnClick.Handle(this, &DeveloperToolsScreen::OnOpenTexturesIniFile); + Choice *createTextureIni = list->Add(new Choice(dev->T("Create/Open textures.ini file for current game"))); + createTextureIni->OnClick.Handle(this, &DeveloperToolsScreen::OnOpenTexturesIniFile); + if (!PSP_IsInited()) { + createTextureIni->SetEnabled(false); + } #endif } From 4e49992e5cba9f84826fc98d691f747d2d18fad5 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 3 Jun 2017 09:38:37 -0700 Subject: [PATCH 5/7] UI: Remove padding hack for setting info message. --- UI/GameSettingsScreen.cpp | 27 ++++++++++++++------------- UI/GameSettingsScreen.h | 10 ++++------ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 90391e46b1..57bfdd0891 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1511,6 +1511,16 @@ UI::EventReturn ProAdhocServerScreen::OnCancelClick(UI::EventParams &e) { return UI::EVENT_DONE; } +SettingInfoMessage::SettingInfoMessage(int align, UI::AnchorLayoutParams *lp) + : UI::LinearLayout(UI::ORIENT_HORIZONTAL, lp) { + using namespace UI; + SetSpacing(0.0f); + Add(new UI::Spacer(10.0f)); + text_ = Add(new UI::TextView("", align, false, new LinearLayoutParams(1.0, Margins(0, 10)))); + text_->SetTag("TEST?"); + Add(new UI::Spacer(10.0f)); +} + void SettingInfoMessage::Show(const std::string &text, UI::View *refView) { if (refView) { Bounds b = refView->GetBounds(); @@ -1521,23 +1531,17 @@ void SettingInfoMessage::Show(const std::string &text, UI::View *refView) { ReplaceLayoutParams(new UI::AnchorLayoutParams(lp->width, lp->height, lp->left, dp_yres - 80.0f - 40.0f, lp->right, lp->bottom, lp->center)); } } - SetText(text); + text_->SetText(text); timeShown_ = time_now_d(); } -void SettingInfoMessage::GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert, float &w, float &h) const { - TextView::GetContentDimensionsBySpec(dc, horiz, vert, w, h); - w += 20.0f; - h += 20.0f; -} - void SettingInfoMessage::Draw(UIContext &dc) { static const double FADE_TIME = 1.0; static const float MAX_ALPHA = 0.9f; // Let's show longer messages for more time (guesstimate at reading speed.) // Note: this will give multibyte characters more time, but they often have shorter words anyway. - double timeToShow = std::max(1.5, GetText().size() * 0.05); + double timeToShow = std::max(1.5, text_->GetText().size() * 0.05); double sinceShow = time_now_d() - timeShown_; float alpha = MAX_ALPHA; @@ -1553,9 +1557,6 @@ void SettingInfoMessage::Draw(UIContext &dc) { dc.FillRect(style.background, bounds_); } - SetTextColor(whiteAlpha(alpha)); - // Fake padding by adjusting bounds. - SetBounds(bounds_.Expand(-10.0f)); - TextView::Draw(dc); - SetBounds(bounds_.Expand(10.0f)); + text_->SetTextColor(whiteAlpha(alpha)); + ViewGroup::Draw(dc); } diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index ad2e1c56d1..cb17a1ce2f 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -122,22 +122,20 @@ private: bool tessHWEnable_; }; -class SettingInfoMessage : public UI::TextView { +class SettingInfoMessage : public UI::LinearLayout { public: - SettingInfoMessage(int align, UI::AnchorLayoutParams *lp) - : UI::TextView("", align, false, lp), timeShown_(0.0) { - } + SettingInfoMessage(int align, UI::AnchorLayoutParams *lp); void SetBottomCutoff(float y) { cutOffY_ = y; } void Show(const std::string &text, UI::View *refView = nullptr); - void GetContentDimensionsBySpec(const UIContext &dc, UI::MeasureSpec horiz, UI::MeasureSpec vert, float &w, float &h) const; void Draw(UIContext &dc); private: - double timeShown_; + UI::TextView *text_ = nullptr; + double timeShown_ = 0.0; float cutOffY_; }; From 977f75ce1e2a22a9645d3ac45e241cbde4a13ab2 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 3 Jun 2017 09:39:18 -0700 Subject: [PATCH 6/7] UI: Fix text wrap when kerning adjusts spaces. This was happening for some setting info messages. The sum of the word lengths didn't actually match the line length, because more space was added between some words. --- ext/native/util/text/wrap_text.cpp | 13 ++++++++++--- ext/native/util/text/wrap_text.h | 10 ++++++---- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ext/native/util/text/wrap_text.cpp b/ext/native/util/text/wrap_text.cpp index e63733225d..70754b4aa1 100644 --- a/ext/native/util/text/wrap_text.cpp +++ b/ext/native/util/text/wrap_text.cpp @@ -82,6 +82,7 @@ void WordWrapper::WrapBeforeWord() { out_[out_.size() - 1] = '-'; } out_ += "\n"; + lastLineStart_ = (int)out_.size(); x_ = 0.0f; forceEarlyWrap_ = false; } @@ -93,6 +94,13 @@ void WordWrapper::AppendWord(int endIndex, bool addNewline) { out_ += std::string(str_ + lastIndex_, endIndex - lastIndex_); if (addNewline) { out_ += "\n"; + lastLineStart_ = (int)out_.size(); + } else { + // We may have appended a newline - check. + size_t pos = out_.find_last_of("\n", lastLineStart_); + if (pos != out_.npos) { + lastLineStart_ = (int)pos; + } } lastIndex_ = endIndex; } @@ -135,9 +143,8 @@ void WordWrapper::Wrap() { // Is this the end of a word (space)? if (wordWidth_ > 0.0f && IsSpace(c)) { AppendWord(afterIndex, false); - // We include the space in the x increase. - // If the space takes it over, we'll wrap on the next word. - x_ += newWordWidth; + // To account for kerning around spaces, we recalculate the entire line width. + x_ = MeasureWidth(out_.c_str() + lastLineStart_, out_.size() - lastLineStart_); wordWidth_ = 0.0f; continue; } diff --git a/ext/native/util/text/wrap_text.h b/ext/native/util/text/wrap_text.h index a5f95d6bc8..ed2bc06d00 100644 --- a/ext/native/util/text/wrap_text.h +++ b/ext/native/util/text/wrap_text.h @@ -5,7 +5,7 @@ class WordWrapper { public: WordWrapper(const char *str, float maxW) - : str_(str), maxW_(maxW), lastIndex_(0), x_(0.0f), forceEarlyWrap_(false) { + : str_(str), maxW_(maxW) { } std::string Wrapped(); @@ -25,11 +25,13 @@ protected: const float maxW_; std::string out_; // Index of last output / start of current word. - int lastIndex_; + int lastIndex_ = 0; + // Index of last line start. + int lastLineStart_ = 0; // Position the current word starts at. - float x_; + float x_ = 0.0f; // Most recent width of word since last index. float wordWidth_; // Force the next word to cut partially and wrap. - bool forceEarlyWrap_; + bool forceEarlyWrap_ = false; }; From 9a14de5831089c0d66f5e7bdf2b1c0200514fe4a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 3 Jun 2017 09:42:34 -0700 Subject: [PATCH 7/7] UI: Make some tooltips less technical. --- UI/GameSettingsScreen.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 57bfdd0891..1f8deb6119 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -218,7 +218,8 @@ void GameSettingsScreen::CreateViews() { renderingModeChoice->SetDisabledPtr(&g_Config.bSoftwareRendering); CheckBox *blockTransfer = graphicsSettings->Add(new CheckBox(&g_Config.bBlockTransferGPU, gr->T("Simulate Block Transfer", "Simulate Block Transfer"))); blockTransfer->OnClick.Add([=](EventParams &e) { - settingInfo_->Show(gr->T("BlockTransfer Tip", "Some games require this to be On for correct graphics"), e.v); + if (!g_Config.bBlockTransferGPU) + settingInfo_->Show(gr->T("BlockTransfer Tip", "Some games require this to be On for correct graphics"), e.v); return UI::EVENT_CONTINUE; }); blockTransfer->SetDisabledPtr(&g_Config.bSoftwareRendering); @@ -305,7 +306,7 @@ void GameSettingsScreen::CreateViews() { CheckBox *swSkin = graphicsSettings->Add(new CheckBox(&g_Config.bSoftwareSkinning, gr->T("Software Skinning"))); swSkin->OnClick.Add([=](EventParams &e) { - settingInfo_->Show(gr->T("SoftwareSkinning Tip", "Reduce drawcalls and faster in games that use the advanced skinning technique, but some games slower"), e.v); + settingInfo_->Show(gr->T("SoftwareSkinning Tip", "Combine skinned model draws on the CPU, faster in most games"), e.v); return UI::EVENT_CONTINUE; }); swSkin->SetDisabledPtr(&g_Config.bSoftwareRendering);