UI: Avoid cached booleans for simple globals.

It's more duplicate code and not really much faster or anything.
This commit is contained in:
Unknown W. Brackets 2020-03-21 18:49:36 -07:00
parent 3b05e839e1
commit 29e1772165
4 changed files with 37 additions and 39 deletions

View File

@ -261,10 +261,12 @@ void DisplayLayoutScreen::CreateViews() {
static const char *displayRotation[] = { "Landscape", "Portrait", "Landscape Reversed", "Portrait Reversed" };
rotation_ = new PopupMultiChoice(&g_Config.iInternalScreenRotation, gr->T("Rotation"), displayRotation, 1, ARRAY_SIZE(displayRotation), co->GetName(), screenManager(), new AnchorLayoutParams(400, WRAP_CONTENT, previewWidth - 200.0f, 10, NONE, local_dp_yres - 64 - 10));
rotation_->SetEnabledPtr(&displayRotEnable_);
displayRotEnable_ = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
rotation_->SetEnabledFunc([] {
return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
});
bool displayRotEnable = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
bRotated = false;
if (displayRotEnable_ && (g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL || g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL180)) {
if (displayRotEnable && (g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL || g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL180)) {
bRotated = true;
}
displayRepresentationScale_ = g_Config.fSmallDisplayZoomLevel * 8.0f; // Visual representation image is just icon size and have to be scaled 8 times to match PSP native resolution which is used as 1.0 for zoom

View File

@ -44,7 +44,6 @@ private:
UI::ChoiceStrip *mode_;
UI::PopupMultiChoice *zoom_;
UI::PopupMultiChoice *rotation_;
bool displayRotEnable_;
bool bRotated;
bool stickToEdgeX;
bool stickToEdgeY;

View File

@ -225,7 +225,7 @@ void GameSettingsScreen::CreateViews() {
}
}
static const char *renderingMode[] = { "Non-Buffered Rendering", "Buffered Rendering"};
static const char *renderingMode[] = { "Non-Buffered Rendering", "Buffered Rendering" };
PopupMultiChoice *renderingModeChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iRenderingMode, gr->T("Mode"), renderingMode, 0, ARRAY_SIZE(renderingMode), gr->GetName(), screenManager()));
renderingModeChoice->OnChoice.Add([=](EventParams &e) {
switch (g_Config.iRenderingMode) {
@ -289,8 +289,9 @@ void GameSettingsScreen::CreateViews() {
auto ps = GetI18NCategory("PostShaders");
postProcChoice_ = graphicsSettings->Add(new ChoiceWithValueDisplay(&g_Config.sPostShaderName, gr->T("Postprocessing Shader"), &PostShaderTranslateName));
postProcChoice_->OnClick.Handle(this, &GameSettingsScreen::OnPostProcShader);
postProcEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
postProcChoice_->SetEnabledPtr(&postProcEnable_);
postProcChoice_->SetEnabledFunc([] {
return !g_Config.bSoftwareRendering && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
});
}
#if !defined(MOBILE_DEVICE)
@ -315,14 +316,15 @@ void GameSettingsScreen::CreateViews() {
graphicsSettings->Add(new ItemHeader(gr->T("Performance")));
#ifndef MOBILE_DEVICE
static const char *internalResolutions[] = {"Auto (1:1)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP", "6x PSP", "7x PSP", "8x PSP", "9x PSP", "10x PSP" };
static const char *internalResolutions[] = { "Auto (1:1)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP", "6x PSP", "7x PSP", "8x PSP", "9x PSP", "10x PSP" };
#else
static const char *internalResolutions[] = {"Auto (1:1)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP" };
static const char *internalResolutions[] = { "Auto (1:1)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP" };
#endif
resolutionChoice_ = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iInternalResolution, gr->T("Rendering Resolution"), internalResolutions, 0, ARRAY_SIZE(internalResolutions), gr->GetName(), screenManager()));
resolutionChoice_->OnChoice.Handle(this, &GameSettingsScreen::OnResolutionChange);
resolutionEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
resolutionChoice_->SetEnabledPtr(&resolutionEnable_);
resolutionChoice_->SetEnabledFunc([] {
return !g_Config.bSoftwareRendering && g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
});
#ifdef __ANDROID__
if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) != DEVICE_TYPE_TV) {
@ -374,8 +376,9 @@ void GameSettingsScreen::CreateViews() {
settingInfo_->Show(gr->T("VertexCache Tip", "Faster, but may cause temporary flicker"), e.v);
return UI::EVENT_CONTINUE;
});
vtxCacheEnable_ = !g_Config.bSoftwareRendering && g_Config.bHardwareTransform;
vtxCache->SetEnabledPtr(&vtxCacheEnable_);
vtxCache->SetEnabledFunc([] {
return !g_Config.bSoftwareRendering && g_Config.bHardwareTransform;
});
CheckBox *texBackoff = graphicsSettings->Add(new CheckBox(&g_Config.bTextureBackoffCache, gr->T("Lazy texture caching", "Lazy texture caching (speedup)")));
texBackoff->SetDisabledPtr(&g_Config.bSoftwareRendering);
@ -397,7 +400,7 @@ void GameSettingsScreen::CreateViews() {
vtxJit->SetEnabled(false);
}*/
static const char *quality[] = { "Low", "Medium", "High"};
static const char *quality[] = { "Low", "Medium", "High" };
PopupMultiChoice *beziersChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iSplineBezierQuality, gr->T("LowCurves", "Spline/Bezier curves quality"), quality, 0, ARRAY_SIZE(quality), gr->GetName(), screenManager()));
beziersChoice->OnChoice.Add([=](EventParams &e) {
if (g_Config.iSplineBezierQuality != 0) {
@ -484,8 +487,9 @@ void GameSettingsScreen::CreateViews() {
static const char *bloomHackOptions[] = { "Off", "Safe", "Balanced", "Aggressive" };
PopupMultiChoice *bloomHack = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iBloomHack, gr->T("Lower resolution for effects (reduces artifacts)"), bloomHackOptions, 0, ARRAY_SIZE(bloomHackOptions), gr->GetName(), screenManager()));
bloomHackEnable_ = !g_Config.bSoftwareRendering && (g_Config.iInternalResolution != 1);
bloomHack->SetEnabledPtr(&bloomHackEnable_);
bloomHack->SetEnabledFunc([] {
return !g_Config.bSoftwareRendering && g_Config.iInternalResolution != 1;
});
graphicsSettings->Add(new ItemHeader(gr->T("Overlay Information")));
static const char *fpsChoices[] = { "None", "Speed", "FPS", "Both" };
@ -566,12 +570,14 @@ void GameSettingsScreen::CreateViews() {
#if defined(MOBILE_DEVICE)
controlsSettings->Add(new CheckBox(&g_Config.bHapticFeedback, co->T("HapticFeedback", "Haptic Feedback (vibration)")));
static const char *tiltTypes[] = { "None (Disabled)", "Analog Stick", "D-PAD", "PSP Action Buttons", "L/R Trigger Buttons"};
static const char *tiltTypes[] = { "None (Disabled)", "Analog Stick", "D-PAD", "PSP Action Buttons", "L/R Trigger Buttons" };
controlsSettings->Add(new PopupMultiChoice(&g_Config.iTiltInputType, co->T("Tilt Input Type"), tiltTypes, 0, ARRAY_SIZE(tiltTypes), co->GetName(), screenManager()))->OnClick.Handle(this, &GameSettingsScreen::OnTiltTypeChange);
Choice *customizeTilt = controlsSettings->Add(new Choice(co->T("Customize tilt")));
customizeTilt->OnClick.Handle(this, &GameSettingsScreen::OnTiltCustomize);
customizeTilt->SetEnabledPtr((bool *)&g_Config.iTiltInputType); //<- dirty int-to-bool cast
customizeTilt->SetEnabledFunc([] {
return g_Config.iTiltInputType != 0;
});
#endif
// TVs don't have touch control, at least not yet.
@ -771,6 +777,10 @@ void GameSettingsScreen::CreateViews() {
View *ioTimingMethod = systemSettings->Add(new PopupMultiChoice(&g_Config.iIOTimingMethod, sy->T("IO timing method"), ioTimingMethods, 0, ARRAY_SIZE(ioTimingMethods), sy->GetName(), screenManager()));
systemSettings->Add(new CheckBox(&g_Config.bForceLagSync, sy->T("Force real clock sync (slower, less lag)")));
PopupSliderChoice *lockedMhz = systemSettings->Add(new PopupSliderChoice(&g_Config.iLockedCPUSpeed, 0, 1000, sy->T("Change CPU Clock", "Change CPU Clock (unstable)"), screenManager(), sy->T("MHz, 0:default")));
lockedMhz->OnChange.Add([&](UI::EventParams &) {
enableReportsCheckbox_->SetEnabled(Reporting::IsSupported());
return UI::EVENT_CONTINUE;
});
lockedMhz->SetZeroLabel(sy->T("Auto"));
PopupSliderChoice *rewindFreq = systemSettings->Add(new PopupSliderChoice(&g_Config.iRewindFlipFrequency, 0, 1800, sy->T("Rewind Snapshot Frequency", "Rewind Snapshot Frequency (mem hog)"), screenManager(), sy->T("frames, 0:off")));
rewindFreq->SetZeroLabel(sy->T("Off"));
@ -867,10 +877,12 @@ void GameSettingsScreen::CreateViews() {
systemSettings->Add(new CheckBox(&g_Config.bCacheFullIsoInRam, sy->T("Cache ISO in RAM", "Cache full ISO in RAM")));
#endif
//#ifndef __ANDROID__
systemSettings->Add(new ItemHeader(sy->T("Cheats", "Cheats (experimental, see forums)")));
systemSettings->Add(new CheckBox(&g_Config.bEnableCheats, sy->T("Enable Cheats")));
//#endif
CheckBox *enableCheats = systemSettings->Add(new CheckBox(&g_Config.bEnableCheats, sy->T("Enable Cheats")));
enableCheats->OnClick.Add([&](UI::EventParams &) {
enableReportsCheckbox_->SetEnabled(Reporting::IsSupported());
return UI::EVENT_CONTINUE;
});
systemSettings->SetSpacing(0);
systemSettings->Add(new ItemHeader(sy->T("PSP Settings")));
@ -913,16 +925,11 @@ UI::EventReturn GameSettingsScreen::OnAutoFrameskip(UI::EventParams &e) {
}
UI::EventReturn GameSettingsScreen::OnSoftwareRendering(UI::EventParams &e) {
vtxCacheEnable_ = !g_Config.bSoftwareRendering && g_Config.bHardwareTransform;
postProcEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
resolutionEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
bloomHackEnable_ = !g_Config.bSoftwareRendering && (g_Config.iInternalResolution != 1);
tessHWEnable_ = DoesBackendSupportHWTess() && !g_Config.bSoftwareRendering && g_Config.bHardwareTransform;
return UI::EVENT_DONE;
}
UI::EventReturn GameSettingsScreen::OnHardwareTransform(UI::EventParams &e) {
vtxCacheEnable_ = !g_Config.bSoftwareRendering && g_Config.bHardwareTransform;
tessHWEnable_ = DoesBackendSupportHWTess() && !g_Config.bSoftwareRendering && g_Config.bHardwareTransform;
return UI::EVENT_DONE;
}
@ -972,9 +979,6 @@ UI::EventReturn GameSettingsScreen::OnRenderingMode(UI::EventParams &e) {
enableReports_ = Reporting::IsEnabled();
enableReportsCheckbox_->SetEnabled(Reporting::IsSupported());
postProcEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
resolutionEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
if (g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) {
g_Config.bAutoFrameSkip = false;
}
@ -1117,7 +1121,6 @@ UI::EventReturn GameSettingsScreen::OnResolutionChange(UI::EventParams &e) {
if (g_Config.iAndroidHwScale == 1) {
RecreateActivity();
}
bloomHackEnable_ = !g_Config.bSoftwareRendering && g_Config.iInternalResolution != 1;
Reporting::UpdateConfig();
return UI::EVENT_DONE;
}

View File

@ -121,22 +121,16 @@ private:
UI::EventReturn OnSavedataManager(UI::EventParams &e);
UI::EventReturn OnSysInfo(UI::EventParams &e);
// Temporaries to convert setting types.
// Temporaries to convert setting types, cache enabled, etc.
int iAlternateSpeedPercent1_;
int iAlternateSpeedPercent2_;
int prevInflightFrames_;
bool enableReports_;
bool tessHWEnable_;
//edit the game-specific settings and restore the global settings after exiting
bool editThenRestore_;
// Cached booleans
bool vtxCacheEnable_;
bool postProcEnable_;
bool resolutionEnable_;
bool bloomHackEnable_;
bool tessHWEnable_;
int prevInflightFrames_;
#if PPSSPP_PLATFORM(ANDROID)
std::string pendingMemstickFolder_;
#endif