Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Common/Data/Text/I18n.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static const char * const g_categoryNames[(size_t)I18NCat::CATEGORY_COUNT] = {
"TextureShaders",
"Themes",
"UI Elements",
"UISettings",
"VR",
"Achievements",
"PSPSettings",
Expand Down
1 change: 1 addition & 0 deletions Common/Data/Text/I18n.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ enum class I18NCat : uint8_t {
TEXTURESHADERS,
THEMES,
UI_ELEMENTS,
UISETTINGS,
VR,
ACHIEVEMENTS,
PSPSETTINGS,
Expand Down
7 changes: 7 additions & 0 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,13 @@ static const ConfigSetting soundSettings[] = {
ConfigSetting("UIVolume", SETTING(g_Config, iUIVolume), 75, CfgFlag::DEFAULT),
ConfigSetting("GamePreviewVolume", SETTING(g_Config, iGamePreviewVolume), &DefaultGamePreviewVolume, CfgFlag::DEFAULT),

// Customizations
ConfigSetting("UISelectAudioFile", SETTING(g_Config, sUISelectAudioFile), "", CfgFlag::DEFAULT),
ConfigSetting("UIConfirmAudioFile", SETTING(g_Config, sUIConfirmAudioFile), "", CfgFlag::DEFAULT),
ConfigSetting("UIBackAudioFile", SETTING(g_Config, sUIBackAudioFile), "", CfgFlag::DEFAULT),
ConfigSetting("UIToggleOnAudioFile", SETTING(g_Config, sUIToggleOnAudioFile), "", CfgFlag::DEFAULT),
ConfigSetting("UIToggleOffAudioFile", SETTING(g_Config, sUIToggleOffAudioFile), "", CfgFlag::DEFAULT),

ConfigSetting("AudioDevice", SETTING(g_Config, sAudioDevice), "", CfgFlag::DEFAULT),
ConfigSetting("AutoAudioDevice", SETTING(g_Config, bAutoSwitchAudioDevice), true, CfgFlag::DEFAULT),
ConfigSetting("AudioMixWithOthers", SETTING(g_Config, bAudioMixWithOthers), &DefaultAudioMixWithOthers, CfgFlag::DEFAULT),
Expand Down
8 changes: 8 additions & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,12 @@ struct Config : public ConfigBlock {
int iAchievementVolume;
int iAltSpeedVolume;

std::string sUISelectAudioFile;
std::string sUIConfirmAudioFile;
std::string sUIBackAudioFile;
std::string sUIToggleOnAudioFile;
std::string sUIToggleOffAudioFile;

bool bExtraAudioBuffering; // For bluetooth
std::string sAudioDevice;
bool bAutoSwitchAudioDevice;
Expand All @@ -443,6 +449,8 @@ struct Config : public ConfigBlock {
bool bTransparentBackground;
int iSettingsCurrentTab;
int iDeveloperSettingsCurrentTab;
int iRetroAchievementsSettingsCurrentTab;
int iUISettingsCurrentTab;

std::string sThemeName;

Expand Down
35 changes: 30 additions & 5 deletions UI/BackgroundAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,17 +636,42 @@ void SoundEffectMixer::Init() {
}

void SoundEffectMixer::LoadSamplesOnThread() {
LoadDefaultSample(UI::UISound::BACK);
LoadDefaultSample(UI::UISound::SELECT);
LoadDefaultSample(UI::UISound::CONFIRM);
LoadDefaultSample(UI::UISound::TOGGLE_ON);
LoadDefaultSample(UI::UISound::TOGGLE_OFF);
if (!g_Config.sUIBackAudioFile.empty()) {
UpdateSample(UI::UISound::BACK, Sample::Load(g_Config.sUIBackAudioFile));
} else {
LoadDefaultSample(UI::UISound::BACK);
}

if (!g_Config.sUISelectAudioFile.empty()) {
UpdateSample(UI::UISound::SELECT, Sample::Load(g_Config.sUISelectAudioFile));
} else {
LoadDefaultSample(UI::UISound::SELECT);
}

if (!g_Config.sUIConfirmAudioFile.empty()) {
UpdateSample(UI::UISound::CONFIRM, Sample::Load(g_Config.sUIConfirmAudioFile));
} else {
LoadDefaultSample(UI::UISound::CONFIRM);
}

if (!g_Config.sUIToggleOnAudioFile.empty()) {
UpdateSample(UI::UISound::TOGGLE_ON, Sample::Load(g_Config.sUIToggleOnAudioFile));
} else {
LoadDefaultSample(UI::UISound::TOGGLE_ON);
}

if (!g_Config.sUIToggleOffAudioFile.empty()) {
UpdateSample(UI::UISound::TOGGLE_OFF, Sample::Load(g_Config.sUIToggleOffAudioFile));
} else {
LoadDefaultSample(UI::UISound::TOGGLE_OFF);
}

if (!g_Config.sAchievementsUnlockAudioFile.empty()) {
UpdateSample(UI::UISound::ACHIEVEMENT_UNLOCKED, Sample::Load(g_Config.sAchievementsUnlockAudioFile));
} else {
LoadDefaultSample(UI::UISound::ACHIEVEMENT_UNLOCKED);
}

if (!g_Config.sAchievementsLeaderboardSubmitAudioFile.empty()) {
UpdateSample(UI::UISound::LEADERBOARD_SUBMITTED, Sample::Load(g_Config.sAchievementsLeaderboardSubmitAudioFile));
} else {
Expand Down
2 changes: 2 additions & 0 deletions UI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ list(APPEND UISource
GameScreen.cpp
GameSettingsScreen.h
GameSettingsScreen.cpp
UISettingsScreen.h
UISettingsScreen.cpp
DeveloperToolsScreen.h
DeveloperToolsScreen.cpp
DriverManagerScreen.h
Expand Down
2 changes: 0 additions & 2 deletions UI/DeveloperToolsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ void DeveloperToolsScreen::CreateGeneralTab(UI::LinearLayout *list) {
screenManager()->push(new GPIGPOScreen(dev->T("GPI/GPO switches/LEDs")));
});

list->Add(new CheckBox(&g_Config.bShowSaveLoadIndicator, dev->T("Show indicator when saving/loading")));

#if PPSSPP_PLATFORM(ANDROID)
static const char *framerateModes[] = { "Default", "Request 60 Hz", "Force 60Hz" };
PopupMultiChoice *framerateMode = list->Add(new PopupMultiChoice(&g_Config.iDisplayFramerateMode, gr->T("Framerate mode"), framerateModes, 0, ARRAY_SIZE(framerateModes), I18NCat::GRAPHICS, screenManager()));
Expand Down
163 changes: 5 additions & 158 deletions UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,22 @@
#include <algorithm>
#include <set>

#include "Common/Net/Resolve.h"
#include "Common/Audio/AudioBackend.h"
#include "Common/GPU/OpenGL/GLFeatures.h"
#include "Common/Render/DrawBuffer.h"
#include "Common/UI/Root.h"
#include "Common/UI/View.h"
#include "Common/UI/ViewGroup.h"
#include "Common/UI/Context.h"
#include "Common/UI/Notice.h"
#include "Common/UI/ScreenManager.h"
#include "Common/Render/ManagedTexture.h"
#include "Common/VR/PPSSPPVR.h"
#include "Common/BitSet.h"
#include "Common/VR/PPSSPPVR.h"
#include "Common/System/Display.h" // Only to check screen aspect ratio with pixel_yres/pixel_xres
#include "Common/System/Request.h"
#include "Common/System/OSD.h"
#include "Common/System/NativeApp.h"
#include "Common/Data/Color/RGBAUtil.h"
#include "Common/Data/Text/I18n.h"
#include "Common/Data/Encoding/Utf8.h"
#include "Common/UI/PopupScreens.h"
#include "UI/EmuScreen.h"
#include "UI/GameSettingsScreen.h"
Expand All @@ -56,6 +52,7 @@
#include "UI/TouchControlLayoutScreen.h"
#include "UI/TouchControlVisibilityScreen.h"
#include "UI/TiltAnalogSettingsScreen.h"
#include "UI/UISettingsScreen.h"
#include "UI/MemStickScreen.h"
#include "UI/Theme.h"
#include "UI/RetroAchievementScreens.h"
Expand All @@ -72,13 +69,11 @@
#include "Core/Config.h"
#include "Core/ConfigValues.h"
#include "Core/KeyMap.h"
#include "Core/TiltEventProcessor.h"
#include "Core/Instance.h"
#include "Core/System.h"
#include "Core/Reporting.h"
#include "Core/HLE/sceUsbCam.h"
#include "Core/HLE/sceUsbMic.h"
#include "Core/HLE/sceUtility.h"
#include "Core/Util/PortManager.h"
#include "GPU/Common/PostShader.h"
#include "GPU/GPU.h"
Expand Down Expand Up @@ -1144,9 +1139,9 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
using namespace UI;

auto sy = GetI18NCategory(I18NCat::SYSTEM);
auto ui = GetI18NCategory(I18NCat::UISETTINGS);
auto di = GetI18NCategory(I18NCat::DIALOG);
auto vr = GetI18NCategory(I18NCat::VR);
auto th = GetI18NCategory(I18NCat::THEMES);
auto psps = GetI18NCategory(I18NCat::PSPSETTINGS); // TODO: Should move more into this section.

systemSettings->Add(new ItemHeader(sy->T("UI")));
Expand All @@ -1169,89 +1164,10 @@ void GameSettingsScreen::CreateSystemSettings(UI::ViewGroup *systemSettings) {
screenManager()->push(langScreen);
});

#if PPSSPP_PLATFORM(IOS)
static const char *indicator[] = {
"Swipe once to switch app (indicator auto-hides)",
"Swipe twice to switch app (indicator stays visible)"
};
PopupMultiChoice *switchMode = systemSettings->Add(new PopupMultiChoice(&g_Config.iAppSwitchMode, sy->T("App switching mode"), indicator, 0, ARRAY_SIZE(indicator), I18NCat::SYSTEM, screenManager()));
switchMode->OnChoice.Add([](EventParams &e) {
System_Notify(SystemNotification::APP_SWITCH_MODE_CHANGED);
});

{
// Note: On iPhone, iOS hides the status bar in landscape no matter what this is set to.
DisplayLayoutConfig &config = g_Config.GetDisplayLayoutConfig(GetDeviceOrientation());
systemSettings->Add(new CheckBox(&config.bImmersiveMode, sy->T("Hide status bar")))->OnClick.Add([](EventParams &e) {
System_Notify(SystemNotification::IMMERSIVE_MODE_CHANGE);
});
}
#endif

#if PPSSPP_PLATFORM(ANDROID)
// Hide Immersive Mode on pre-kitkat Android
if (System_GetPropertyInt(SYSPROP_SYSTEMVERSION) >= 19) {
DisplayLayoutConfig &config = g_Config.GetDisplayLayoutConfig(GetDeviceOrientation());
systemSettings->Add(new CheckBox(&config.bImmersiveMode, sy->T("Hide navigation bar")))->OnClick.Handle(this, &GameSettingsScreen::OnImmersiveModeChange);
}
#endif

PopupSliderChoice *uiScale = systemSettings->Add(new PopupSliderChoice(&g_Config.iUIScaleFactor, -8, 8, 0, sy->T("UI size adjustment (DPI)"), screenManager()));
uiScale->SetZeroLabel(sy->T("Off"));
UIContext *ctx = screenManager()->getUIContext();
uiScale->OnChange.Add([ctx](UI::EventParams &e) {
const float dpiMul = UIScaleFactorToMultiplier(g_Config.iUIScaleFactor);
g_display.Recalculate(-1, -1, -1, -1, dpiMul);
ctx->InvalidateAtlas();
NativeResized();
});

const Path bgPng = GetSysDirectory(DIRECTORY_SYSTEM) / "background.png";
const Path bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) / "background.jpg";
Choice *backgroundChoice = nullptr;
if (File::Exists(bgPng) || File::Exists(bgJpg)) {
backgroundChoice = systemSettings->Add(new Choice(sy->T("Clear UI background")));
} else if (System_GetPropertyBool(SYSPROP_HAS_IMAGE_BROWSER) || System_GetPropertyBool(SYSPROP_HAS_FILE_BROWSER)) {
backgroundChoice = systemSettings->Add(new Choice(sy->T("Set UI background...")));
}
if (backgroundChoice) {
backgroundChoice->OnClick.Handle(this, &GameSettingsScreen::OnChangeBackground);
}

systemSettings->Add(new CheckBox(&g_Config.bTransparentBackground, sy->T("Transparent UI background")));

// Shared with achievements.
static const char *positions[] = { "None", "Bottom Left", "Bottom Center", "Bottom Right", "Top Left", "Top Center", "Top Right", "Center Left", "Center Right" };

systemSettings->Add(new PopupMultiChoice(&g_Config.iNotificationPos, sy->T("Notification screen position"), positions, -1, ARRAY_SIZE(positions), I18NCat::DIALOG, screenManager()));

static const char *backgroundAnimations[] = { "No animation", "Floating symbols", "Recent games", "Waves", "Moving background", "Bouncing icon", "Colored floating symbols" };
systemSettings->Add(new PopupMultiChoice(&g_Config.iBackgroundAnimation, sy->T("UI background animation"), backgroundAnimations, 0, ARRAY_SIZE(backgroundAnimations), I18NCat::SYSTEM, screenManager()));

PopupMultiChoiceDynamic *theme = systemSettings->Add(new PopupMultiChoiceDynamic(&g_Config.sThemeName, sy->T("Theme"), GetThemeInfoNames(), I18NCat::THEMES, screenManager()));
theme->OnChoice.Add([](EventParams &e) {
UpdateTheme();
// Reset the tint/saturation if the theme changed.
if (e.b) {
g_Config.fUITint = 0.0f;
g_Config.fUISaturation = 1.0f;
}
systemSettings->Add(new Choice(ui->T("UI settings")))->OnClick.Add([this](UI::EventParams &) {
screenManager()->push(new UISettingsScreen(gamePath_));
});

Draw::DrawContext *draw = screenManager()->getDrawContext();

if (!draw->GetBugs().Has(Draw::Bugs::RASPBERRY_SHADER_COMP_HANG)) {
// We use shaders without tint capability on hardware with this driver bug.
PopupSliderChoiceFloat *tint = new PopupSliderChoiceFloat(&g_Config.fUITint, 0.0f, 1.0f, 0.0f, sy->T("Color tint"), 0.01f, screenManager());
tint->SetHasDropShadow(false);
tint->SetLiveUpdate(true);
systemSettings->Add(tint);
PopupSliderChoiceFloat *saturation = new PopupSliderChoiceFloat(&g_Config.fUISaturation, 0.0f, 2.0f, 1.0f, sy->T("Color saturation"), 0.01f, screenManager());
saturation->SetHasDropShadow(false);
saturation->SetLiveUpdate(true);
systemSettings->Add(saturation);
}

systemSettings->Add(new ItemHeader(sy->T("PSP Memory Stick")));

if (System_GetPropertyBool(SYSPROP_HAS_OPEN_DIRECTORY)) {
Expand Down Expand Up @@ -1518,13 +1434,6 @@ void GameSettingsScreen::CreateVRSettings(UI::ViewGroup *vrSettings) {
vrSettings->Add(new CheckBox(&g_Config.bManualForceVR, vr->T("Manual switching between flat screen and VR using SCREEN key")));
}

void GameSettingsScreen::OnImmersiveModeChange(UI::EventParams &e) {
System_Notify(SystemNotification::IMMERSIVE_MODE_CHANGE);
if (g_Config.iAndroidHwScale != 0) {
System_RecreateActivity();
}
}

void GameSettingsScreen::OnSustainedPerformanceModeChange(UI::EventParams &e) {
System_Notify(SystemNotification::SUSTAINED_PERF_CHANGE);
}
Expand Down Expand Up @@ -1596,68 +1505,6 @@ void GameSettingsScreen::OnMemoryStickOther(UI::EventParams &e) {

#endif

void GameSettingsScreen::OnChangeBackground(UI::EventParams &e) {
const Path bgPng = GetSysDirectory(DIRECTORY_SYSTEM) / "background.png";
const Path bgJpg = GetSysDirectory(DIRECTORY_SYSTEM) / "background.jpg";

if (File::Exists(bgPng) || File::Exists(bgJpg)) {
INFO_LOG(Log::UI, "Clearing background image.");
// The button is in clear mode.
File::Delete(bgPng);
File::Delete(bgJpg);
UIBackgroundShutdown();
RecreateViews();
return;
}

auto sy = GetI18NCategory(I18NCat::SYSTEM);
System_BrowseForImage(GetRequesterToken(), sy->T("Set UI background..."), bgJpg, [this](std::string_view value, int converted) {
if (converted == 1) {
// The platform code converted and saved the file to the desired path already.
INFO_LOG(Log::UI, "Platform converted the file: %.*s", STR_VIEW(value));
} else if (!value.empty()) {
Path path(value);

// Check the file format. Don't rely on the file extension here due to scoped storage URLs.
FILE *f = File::OpenCFile(path, "rb");
uint8_t buffer[8];
ImageFileType type = ImageFileType::UNKNOWN;
if (f != nullptr && 8 == fread(buffer, 1, ARRAY_SIZE(buffer), f)) {
type = DetectImageFileType(buffer, ARRAY_SIZE(buffer));
}

std::string filename;
switch (type) {
case ImageFileType::JPEG:
filename = "background.jpg";
break;
case ImageFileType::PNG:
filename = "background.png";
break;
default:
break;
}

if (!filename.empty()) {
Path dest = GetSysDirectory(DIRECTORY_SYSTEM) / filename;
File::Copy(path, dest);
if (path.FilePathContainsNoCase("temp_import.jpg")) {
INFO_LOG(Log::UI, "Deleting temp file: %s", GetFriendlyPath(path).c_str());
File::Delete(path);
}
} else {
auto sy = GetI18NCategory(I18NCat::SYSTEM);
g_OSD.Show(OSDType::MESSAGE_ERROR, sy->T("Only JPG and PNG images are supported"), path.GetFilename(), 5.0);
}
}
// It will init again automatically. We can't init outside a frame on Vulkan.
UIBackgroundShutdown();
RecreateViews();
});

// Change to a browse or clear button.
}

void GameSettingsScreen::dialogFinished(const Screen *dialog, DialogResult result) {
if (equals(dialog->tag(), "NewLanguage") && result == DR_OK) {
screenManager()->RecreateAllViews();
Expand Down
4 changes: 1 addition & 3 deletions UI/GameSettingsScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ class GameSettingsScreen : public UITabbedBaseDialogScreen {

std::string memstickDisplay_;

// Global settings handlers
void OnChangeBackground(UI::EventParams &e);
// Global settings handlers
void OnRestoreDefaultSettings(UI::EventParams &e);
void OnRenderingBackend(UI::EventParams &e);
void OnRenderingDevice(UI::EventParams &e);
Expand All @@ -83,7 +82,6 @@ class GameSettingsScreen : public UITabbedBaseDialogScreen {
void OnMemoryStickMyDoc(UI::EventParams &e);
void OnMemoryStickOther(UI::EventParams &e);
#endif
void OnImmersiveModeChange(UI::EventParams &e);
void OnSustainedPerformanceModeChange(UI::EventParams &e);

void TriggerRestartOrDo(std::function<void()> callback);
Expand Down
Loading
Loading