Merge pull request #9773 from unknownbrackets/ui-minor

Tweak some minor UI glitches
This commit is contained in:
Henrik Rydgård 2017-06-03 19:37:34 +02:00 committed by GitHub
commit 0f5c59dc28
7 changed files with 57 additions and 35 deletions

View file

@ -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

View file

@ -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);
@ -590,9 +591,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));
@ -1275,7 +1276,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
}
@ -1507,6 +1512,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();
@ -1517,23 +1532,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;
@ -1549,9 +1558,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);
}

View file

@ -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_;
};

View file

@ -34,7 +34,7 @@ public:
void Update() override;
protected:
float GetButtonOpacity();
virtual float GetButtonOpacity();
float lastFrameTime_;
float secondsWithoutTouch_;

View file

@ -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 <algorithm>
#include <vector>
#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) {

View file

@ -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;
}

View file

@ -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;
};