Change global UI messages to use an enum instead of strings.

Makes it easier to add new ones and delete outdated ones without missing
any uses.
This commit is contained in:
Henrik Rydgård 2023-09-30 11:21:22 +02:00
parent 526d3047c7
commit 19e4de5088
37 changed files with 217 additions and 195 deletions

View file

@ -207,6 +207,40 @@ enum class SystemNotification {
ACTIVITY,
};
// I guess it's not super great architecturally to centralize this, since it's not general - but same with a lot of
// the other stuff, and this is only used by PPSSPP, so... better this than ugly strings.
enum class UIMessage {
PERMISSION_GRANTED,
POWER_SAVING,
RECREATE_VIEWS,
CONFIG_LOADED,
REQUEST_GAME_BOOT,
REQUEST_GAME_RUN, // or continue?
REQUEST_GAME_PAUSE,
REQUEST_GAME_RESET,
REQUEST_GAME_STOP,
SHOW_CONTROL_MAPPING,
SHOW_CHAT_SCREEN,
SHOW_DISPLAY_LAYOUT_EDITOR,
SHOW_SETTINGS,
SHOW_LANGUAGE_SCREEN,
REQUEST_GPU_DUMP_NEXT_FRAME,
REQUEST_CLEAR_JIT,
APP_RESUMED,
REQUEST_PLAY_SOUND,
WINDOW_MINIMIZED,
LOST_FOCUS,
GOT_FOCUS,
GPU_CONFIG_CHANGED,
GPU_RENDER_RESIZED,
GPU_DISPLAY_RESIZED,
POSTSHADER_UPDATED,
ACHIEVEMENT_LOGIN_STATE_CHANGE,
SAVESTATE_DISPLAY_SLOT,
GAMESETTINGS_SEARCH,
SAVEDATA_SEARCH,
};
std::string System_GetProperty(SystemProperty prop);
std::vector<std::string> System_GetPropertyStringVec(SystemProperty prop);
int System_GetPropertyInt(SystemProperty prop);
@ -221,7 +255,7 @@ bool System_AudioRecordingIsAvailable();
bool System_AudioRecordingState();
// This will be changed to take an enum. Replacement for the old NativeMessageReceived.
void System_PostUIMessage(const std::string &message, const std::string &param);
void System_PostUIMessage(UIMessage message, const std::string &param = "");
// For these functions, most platforms will use the implementation provided in UI/AudioCommon.cpp,
// no need to implement separately.

View file

@ -208,12 +208,10 @@ void ScreenManager::getFocusPosition(float &x, float &y, float &z) {
z = stack_.size();
}
void ScreenManager::sendMessage(const char *msg, const char *value) {
if (!msg) {
_dbg_assert_msg_(false, "Empty msg in ScreenManager::sendMessage");
} else if (!strcmp(msg, "recreateviews")) {
void ScreenManager::sendMessage(UIMessage message, const char *value) {
if (message == UIMessage::RECREATE_VIEWS) {
RecreateAllViews();
} else if (!strcmp(msg, "lost_focus")) {
} else if (message == UIMessage::LOST_FOCUS) {
TouchInput input{};
input.x = -50000.0f;
input.y = -50000.0f;
@ -224,7 +222,7 @@ void ScreenManager::sendMessage(const char *msg, const char *value) {
}
if (!stack_.empty())
stack_.back().screen->sendMessage(msg, value);
stack_.back().screen->sendMessage(message, value);
}
Screen *ScreenManager::topScreen() const {

View file

@ -21,6 +21,7 @@
#include "Common/Common.h"
#include "Common/Input/InputState.h"
#include "Common/System/System.h"
namespace UI {
class View;
@ -55,7 +56,7 @@ public:
virtual void postRender() {}
virtual void resized() {}
virtual void dialogFinished(const Screen *dialog, DialogResult result) {}
virtual void sendMessage(const char *msg, const char *value) {}
virtual void sendMessage(UIMessage message, const char *value) {}
virtual void deviceLost() {}
virtual void deviceRestored() {}
@ -138,7 +139,7 @@ public:
void axis(const AxisInput *axes, size_t count);
// Generic facility for gross hacks :P
void sendMessage(const char *msg, const char *value);
void sendMessage(UIMessage message, const char *value);
Screen *topScreen() const;

View file

@ -269,10 +269,10 @@ bool UIDialogScreen::key(const KeyInput &key) {
return retval;
}
void UIDialogScreen::sendMessage(const char *msg, const char *value) {
void UIDialogScreen::sendMessage(UIMessage message, const char *value) {
Screen *screen = screenManager()->dialogParent(this);
if (screen) {
screen->sendMessage(msg, value);
screen->sendMessage(message, value);
}
}

View file

@ -88,7 +88,7 @@ class UIDialogScreen : public UIScreen {
public:
UIDialogScreen() : UIScreen(), finished_(false) {}
bool key(const KeyInput &key) override;
void sendMessage(const char *msg, const char *value) override;
void sendMessage(UIMessage message, const char *value) override;
private:
bool finished_;

View file

@ -306,7 +306,7 @@ bool Load_PSP_ISO(FileLoader *fileLoader, std::string *error_string) {
//in case we didn't go through EmuScreen::boot
g_Config.loadGameConfig(id, g_paramSFO.GetValueString("TITLE"));
System_PostUIMessage("config_loaded", "");
System_PostUIMessage(UIMessage::CONFIG_LOADED);
INFO_LOG(LOADER, "Loading %s...", bootpath.c_str());
PSPLoaders_Shutdown();

View file

@ -58,7 +58,7 @@ static inline const char *DeNull(const char *ptr) {
}
void OnAchievementsLoginStateChange() {
System_PostUIMessage("achievements_loginstatechange", "");
System_PostUIMessage(UIMessage::ACHIEVEMENT_LOGIN_STATE_CHANGE);
}
namespace Achievements {
@ -228,7 +228,7 @@ static void event_handler_callback(const rc_client_event_t *event, rc_client_t *
case RC_CLIENT_EVENT_ACHIEVEMENT_TRIGGERED:
// An achievement was earned by the player. The handler should notify the player that the achievement was earned.
g_OSD.ShowAchievementUnlocked(event->achievement->id);
System_PostUIMessage("play_sound", "achievement_unlocked");
System_PostUIMessage(UIMessage::REQUEST_PLAY_SOUND, "achievement_unlocked");
INFO_LOG(ACHIEVEMENTS, "Achievement unlocked: '%s' (%d)", event->achievement->title, event->achievement->id);
break;
@ -250,7 +250,7 @@ static void event_handler_callback(const rc_client_event_t *event, rc_client_t *
g_OSD.Show(OSDType::MESSAGE_INFO, title, message, DeNull(gameInfo->badge_name), 10.0f);
System_PostUIMessage("play_sound", "achievement_unlocked");
System_PostUIMessage(UIMessage::REQUEST_PLAY_SOUND, "achievement_unlocked");
INFO_LOG(ACHIEVEMENTS, "%s", message.c_str());
break;
@ -284,7 +284,7 @@ static void event_handler_callback(const rc_client_event_t *event, rc_client_t *
title = event->leaderboard->description;
}
g_OSD.ShowLeaderboardSubmitted(ApplySafeSubstitutions(ac->T("Submitted %1 for %2"), DeNull(event->leaderboard->tracker_value), title), "");
System_PostUIMessage("play_sound", "leaderboard_submitted");
System_PostUIMessage(UIMessage::REQUEST_PLAY_SOUND, "leaderboard_submitted");
break;
}
case RC_CLIENT_EVENT_ACHIEVEMENT_CHALLENGE_INDICATOR_SHOW:
@ -341,7 +341,7 @@ static void event_handler_callback(const rc_client_event_t *event, rc_client_t *
case RC_CLIENT_EVENT_RESET:
WARN_LOG(ACHIEVEMENTS, "Resetting game due to achievement setting change!");
// Challenge mode was enabled, or something else that forces a game reset.
System_PostUIMessage("reset", "");
System_PostUIMessage(UIMessage::REQUEST_GAME_RESET);
break;
case RC_CLIENT_EVENT_SERVER_ERROR:
ERROR_LOG(ACHIEVEMENTS, "Server error: %s: %s", event->server_error->api, event->server_error->error_message);

View file

@ -542,7 +542,7 @@ QString MainUI::InputBoxGetQString(QString title, QString defaultValue) {
void MainUI::resizeGL(int w, int h) {
if (UpdateScreenScale(w, h)) {
System_PostUIMessage("gpu_displayResized", "");
System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED);
}
xscale = w / this->width();
yscale = h / this->height();

View file

@ -130,7 +130,7 @@ void MainWindow::loadAct()
{
QFileInfo info(filename);
g_Config.currentDirectory = Path(info.absolutePath().toStdString());
System_PostUIMessage("boot", filename.toStdString().c_str());
System_PostUIMessage(UIMessage::REQUEST_GAME_BOOT, filename.toStdString().c_str());
}
}
@ -138,7 +138,7 @@ void MainWindow::closeAct()
{
updateMenus();
System_PostUIMessage("stop", "");
System_PostUIMessage(UIMessage::REQUEST_GAME_STOP);
SetGameTitle("");
}
@ -232,25 +232,24 @@ void MainWindow::exitAct()
void MainWindow::runAct()
{
System_PostUIMessage("run", "");
System_PostUIMessage(UIMessage::REQUEST_GAME_RUN);
}
void MainWindow::pauseAct()
{
System_PostUIMessage("pause", "");
System_PostUIMessage(UIMessage::REQUEST_GAME_PAUSE);
}
void MainWindow::stopAct()
{
Core_Stop();
System_PostUIMessage("stop", "");
System_PostUIMessage(UIMessage::REQUEST_GAME_STOP);
}
void MainWindow::resetAct()
{
updateMenus();
System_PostUIMessage("reset", "");
System_PostUIMessage(UIMessage::REQUEST_GAME_RESET);
}
void MainWindow::switchUMDAct()

View file

@ -113,20 +113,20 @@ private slots:
void consoleAct();
// Game settings
void languageAct() { System_PostUIMessage("language screen", ""); }
void controlMappingAct() { System_PostUIMessage("control mapping", ""); }
void displayLayoutEditorAct() { System_PostUIMessage("display layout editor", ""); }
void moreSettingsAct() { System_PostUIMessage("settings", ""); }
void languageAct() { System_PostUIMessage(UIMessage::SHOW_LANGUAGE_SCREEN); }
void controlMappingAct() { System_PostUIMessage(UIMessage::SHOW_CONTROL_MAPPING); }
void displayLayoutEditorAct() { System_PostUIMessage(UIMessage::SHOW_DISPLAY_LAYOUT_EDITOR); }
void moreSettingsAct() { System_PostUIMessage(UIMessage::SHOW_SETTINGS); }
void bufferRenderAct() {
System_PostUIMessage("gpu_renderResized", "");
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED);
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
void linearAct() { g_Config.iTexFiltering = (g_Config.iTexFiltering != 0) ? 0 : 3; }
void renderingResolutionGroup_triggered(QAction *action) {
g_Config.iInternalResolution = action->data().toInt();
System_PostUIMessage("gpu_renderResized", "");
System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED);
}
void windowGroup_triggered(QAction *action) { SetWindowScale(action->data().toInt()); }
@ -134,7 +134,7 @@ private slots:
g_Config.bAutoFrameSkip = !g_Config.bAutoFrameSkip;
if (g_Config.bSkipBufferEffects) {
g_Config.bSkipBufferEffects = false;
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
}
void frameSkippingGroup_triggered(QAction *action) { g_Config.iFrameSkip = action->data().toInt(); }
@ -143,19 +143,19 @@ private slots:
void screenScalingFilterGroup_triggered(QAction *action) { g_Config.iDisplayFilter = action->data().toInt(); }
void textureScalingLevelGroup_triggered(QAction *action) {
g_Config.iTexScalingLevel = action->data().toInt();
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
void textureScalingTypeGroup_triggered(QAction *action) {
g_Config.iTexScalingType = action->data().toInt();
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
void deposterizeAct() {
g_Config.bTexDeposterize = !g_Config.bTexDeposterize;
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
void transformAct() {
g_Config.bHardwareTransform = !g_Config.bHardwareTransform;
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
void vertexCacheAct() { g_Config.bVertexCache = !g_Config.bVertexCache; }
void frameskipAct() { g_Config.iFrameSkip = !g_Config.iFrameSkip; }
@ -172,7 +172,7 @@ private slots:
// Chat
void chatAct() {
if (GetUIState() == UISTATE_INGAME) {
System_PostUIMessage("chat screen", "");
System_PostUIMessage(UIMessage::SHOW_CHAT_SCREEN);
}
}

View file

@ -442,17 +442,17 @@ void OSXOpenURL(const char *url) {
}
-(void)pauseAction: (NSMenuItem *)item {
System_PostUIMessage("pause", "");
System_PostUIMessage(UIMessage::REQUEST_GAME_PAUSE);
}
-(void)resetAction: (NSMenuItem *)item {
System_PostUIMessage("reset", "");
System_PostUIMessage(UIMessage::REQUEST_GAME_RESET);
Core_EnableStepping(false);
}
-(void)chatAction: (NSMenuItem *)item {
if (GetUIState() == UISTATE_INGAME) {
System_PostUIMessage("chat screen", "");
System_PostUIMessage(UIMessage::REQUEST_CHAT_SCREEN);
}
}
@ -549,7 +549,7 @@ TOGGLE_METHOD(FullScreen, g_Config.bFullScreen, System_MakeRequest(SystemRequest
} else {
g_Config.iDebugOverlay = (int)DebugOverlay::DEBUG_STATS;
}
System_PostUIMessage("clear jit", "");
System_PostUIMessage(UIMessage::REQUEST_CLEAR_JIT);
item.state = [self controlStateForBool: (DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS]; \
}
@ -631,14 +631,14 @@ TOGGLE_METHOD(FullScreen, g_Config.bFullScreen, System_MakeRequest(SystemRequest
}
-(void)openRecentItem: (NSMenuItem *)item {
System_PostUIMessage("boot", g_Config.RecentIsos()[item.tag].c_str());
System_PostUIMessage(UIMessage::REQUEST_BOOT_GAME, g_Config.RecentIsos()[item.tag].c_str());
}
-(void)openSystemFileBrowser {
int g = 0;
DarwinDirectoryPanelCallback callback = [g] (bool succ, Path thePathChosen) {
if (succ)
System_PostUIMessage("boot", thePathChosen.c_str());
System_PostUIMessage(UIMessage::REQUEST_BOOT_GAME, thePathChosen.c_str());
};
DarwinFileSystemServices services;

View file

@ -880,7 +880,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta
if (Core_IsStepping())
Core_EnableStepping(false);
Core_Stop();
System_PostUIMessage("stop", "");
System_PostUIMessage(UIMessage::REQUEST_GAME_STOP);
// NOTE: Unlike Windows version, this
// does not need Core_WaitInactive();
// since SDL does not have a separate
@ -888,7 +888,7 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta
}
if (ctrl && (k == SDLK_b))
{
System_PostUIMessage("reset", "");
System_PostUIMessage(UIMessage::REQUEST_GAME_RESET);
Core_EnableStepping(false);
}
}

View file

@ -155,9 +155,9 @@ UI::EventReturn DisplayLayoutScreen::OnPostProcShaderChange(UI::EventParams &e)
g_Config.vPostShaderNames.erase(std::remove(g_Config.vPostShaderNames.begin(), g_Config.vPostShaderNames.end(), "Off"), g_Config.vPostShaderNames.end());
FixPostShaderOrder(&g_Config.vPostShaderNames);
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage("gpu_renderResized", ""); // To deal with shaders that can change render resolution like upscaling.
System_PostUIMessage("postshader_updated", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED); // To deal with shaders that can change render resolution like upscaling.
System_PostUIMessage(UIMessage::POSTSHADER_UPDATED);
if (gpu) {
gpu->NotifyConfigChanged();
@ -181,9 +181,9 @@ static std::string PostShaderTranslateName(const char *value) {
}
}
void DisplayLayoutScreen::sendMessage(const char *message, const char *value) {
void DisplayLayoutScreen::sendMessage(UIMessage message, const char *value) {
UIDialogScreenWithGameBackground::sendMessage(message, value);
if (!strcmp(message, "postshader_updated")) {
if (message == UIMessage::POSTSHADER_UPDATED) {
g_Config.bShaderChainRequires60FPS = PostShaderChainRequires60FPS(GetFullPostShadersChain(g_Config.vPostShaderNames));
RecreateViews();
}
@ -381,7 +381,7 @@ void DisplayLayoutScreen::CreateViews() {
auto removeButton = shaderRow->Add(new Choice(ImageID("I_TRASHCAN"), new LinearLayoutParams(0.0f)));
removeButton->OnClick.Add([=](EventParams &e) -> UI::EventReturn {
g_Config.vPostShaderNames.erase(g_Config.vPostShaderNames.begin() + i);
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
RecreateViews();
return UI::EVENT_DONE;
});
@ -409,7 +409,7 @@ void DisplayLayoutScreen::CreateViews() {
return UI::EVENT_DONE;
}
FixPostShaderOrder(&g_Config.vPostShaderNames);
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
RecreateViews();
return UI::EVENT_DONE;
});
@ -493,18 +493,17 @@ void PostProcScreen::OnCompleted(DialogResult result) {
if (showStereoShaders_) {
if (g_Config.sStereoToMonoShader != value) {
g_Config.sStereoToMonoShader = value;
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
} else {
if (id_ < (int)g_Config.vPostShaderNames.size()) {
if (g_Config.vPostShaderNames[id_] != value) {
g_Config.vPostShaderNames[id_] = value;
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
}
else {
} else {
g_Config.vPostShaderNames.push_back(value);
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
}
}

View file

@ -43,7 +43,7 @@ public:
protected:
UI::EventReturn OnPostProcShaderChange(UI::EventParams &e);
void sendMessage(const char *message, const char *value) override;
void sendMessage(UIMessage message, const char *value) override;
private:
UI::ChoiceStrip *mode_ = nullptr;

View file

@ -461,18 +461,18 @@ static void AfterStateBoot(SaveState::Status status, const std::string &message,
System_Notify(SystemNotification::DISASSEMBLY);
}
void EmuScreen::sendMessage(const char *message, const char *value) {
void EmuScreen::sendMessage(UIMessage message, const char *value) {
// External commands, like from the Windows UI.
if (!strcmp(message, "pause") && screenManager()->topScreen() == this) {
if (message == UIMessage::REQUEST_GAME_PAUSE && screenManager()->topScreen() == this) {
screenManager()->push(new GamePauseScreen(gamePath_));
} else if (!strcmp(message, "stop")) {
} else if (message == UIMessage::REQUEST_GAME_STOP) {
// We will push MainScreen in update().
PSP_Shutdown();
bootPending_ = false;
stopRender_ = true;
invalid_ = true;
System_Notify(SystemNotification::DISASSEMBLY);
} else if (!strcmp(message, "reset")) {
} else if (message == UIMessage::REQUEST_GAME_RESET) {
PSP_Shutdown();
bootPending_ = true;
invalid_ = true;
@ -485,7 +485,7 @@ void EmuScreen::sendMessage(const char *message, const char *value) {
screenManager()->switchScreen(new MainScreen());
return;
}
} else if (!strcmp(message, "boot")) {
} else if (message == UIMessage::REQUEST_GAME_BOOT) {
const char *ext = strrchr(value, '.');
if (ext != nullptr && !strcmp(ext, ".ppst")) {
SaveState::Load(Path(value), -1, &AfterStateBoot);
@ -496,33 +496,33 @@ void EmuScreen::sendMessage(const char *message, const char *value) {
// Don't leave it on CORE_POWERDOWN, we'll sometimes aggressively bail.
Core_UpdateState(CORE_POWERUP);
}
} else if (!strcmp(message, "config_loaded")) {
} else if (message == UIMessage::CONFIG_LOADED) {
// In case we need to position touch controls differently.
RecreateViews();
} else if (!strcmp(message, "control mapping") && screenManager()->topScreen() == this) {
} else if (message == UIMessage::SHOW_CONTROL_MAPPING && screenManager()->topScreen() == this) {
UpdateUIState(UISTATE_PAUSEMENU);
screenManager()->push(new ControlMappingScreen(gamePath_));
} else if (!strcmp(message, "display layout editor") && screenManager()->topScreen() == this) {
} else if (message == UIMessage::SHOW_DISPLAY_LAYOUT_EDITOR && screenManager()->topScreen() == this) {
UpdateUIState(UISTATE_PAUSEMENU);
screenManager()->push(new DisplayLayoutScreen(gamePath_));
} else if (!strcmp(message, "settings") && screenManager()->topScreen() == this) {
} else if (message == UIMessage::SHOW_SETTINGS && screenManager()->topScreen() == this) {
UpdateUIState(UISTATE_PAUSEMENU);
screenManager()->push(new GameSettingsScreen(gamePath_));
} else if (!strcmp(message, "gpu dump next frame")) {
} else if (message == UIMessage::REQUEST_GPU_DUMP_NEXT_FRAME) {
if (gpu)
gpu->DumpNextFrame();
} else if (!strcmp(message, "clear jit")) {
} else if (message == UIMessage::REQUEST_CLEAR_JIT) {
currentMIPS->ClearJitCache();
if (PSP_IsInited()) {
currentMIPS->UpdateCore((CPUCore)g_Config.iCpuCore);
}
} else if (!strcmp(message, "window minimized")) {
} else if (message == UIMessage::WINDOW_MINIMIZED) {
if (!strcmp(value, "true")) {
gstate_c.skipDrawReason |= SKIPDRAW_WINDOW_MINIMIZED;
} else {
gstate_c.skipDrawReason &= ~SKIPDRAW_WINDOW_MINIMIZED;
}
} else if (!strcmp(message, "chat screen")) {
} else if (message == UIMessage::SHOW_CHAT_SCREEN) {
if (g_Config.bEnableNetworkChat) {
if (!chatButton_)
RecreateViews();
@ -541,7 +541,7 @@ void EmuScreen::sendMessage(const char *message, const char *value) {
OnChatMenu.Trigger(e);
#endif
}
} else if (!strcmp(message, "app_resumed") && screenManager()->topScreen() == this) {
} else if (message == UIMessage::APP_RESUMED && screenManager()->topScreen() == this) {
if (System_GetPropertyInt(SYSPROP_DEVICE_TYPE) == DEVICE_TYPE_TV) {
if (!KeyMap::IsKeyMapped(DEVICE_ID_PAD_0, VIRTKEY_PAUSE) || !KeyMap::IsKeyMapped(DEVICE_ID_PAD_1, VIRTKEY_PAUSE)) {
// If it's a TV (so no built-in back button), and there's no back button mapped to a pad,
@ -550,7 +550,7 @@ void EmuScreen::sendMessage(const char *message, const char *value) {
screenManager()->push(new GamePauseScreen(gamePath_));
}
}
} else if (!strcmp(message, "play_sound")) {
} else if (message == UIMessage::REQUEST_PLAY_SOUND) {
if (g_Config.bAchievementsSoundEffects) {
// TODO: Handle this some nicer way.
if (!strcmp(value, "achievement_unlocked")) {
@ -732,13 +732,13 @@ void EmuScreen::onVKey(int virtualKeyCode, bool down) {
case VIRTKEY_PREVIOUS_SLOT:
if (down && !Achievements::WarnUserIfChallengeModeActive()) {
SaveState::PrevSlot();
System_PostUIMessage("savestate_displayslot", "");
System_PostUIMessage(UIMessage::SAVESTATE_DISPLAY_SLOT);
}
break;
case VIRTKEY_NEXT_SLOT:
if (down && !Achievements::WarnUserIfChallengeModeActive()) {
SaveState::NextSlot();
System_PostUIMessage("savestate_displayslot", "");
System_PostUIMessage(UIMessage::SAVESTATE_DISPLAY_SLOT);
}
break;
case VIRTKEY_TOGGLE_FULLSCREEN:
@ -756,7 +756,7 @@ void EmuScreen::onVKey(int virtualKeyCode, bool down) {
g_Config.bSaveNewTextures = !g_Config.bSaveNewTextures;
if (g_Config.bSaveNewTextures) {
g_OSD.Show(OSDType::MESSAGE_INFO, sc->T("saveNewTextures_true", "Textures will now be saved to your storage"), 2.0);
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
} else {
g_OSD.Show(OSDType::MESSAGE_INFO, sc->T("saveNewTextures_false", "Texture saving was disabled"), 2.0);
}
@ -769,7 +769,7 @@ void EmuScreen::onVKey(int virtualKeyCode, bool down) {
g_OSD.Show(OSDType::MESSAGE_INFO, sc->T("replaceTextures_true", "Texture replacement enabled"), 2.0);
else
g_OSD.Show(OSDType::MESSAGE_INFO, sc->T("replaceTextures_false", "Textures no longer are being replaced"), 2.0);
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
break;
case VIRTKEY_RAPID_FIRE:
@ -1075,7 +1075,7 @@ UI::EventReturn EmuScreen::OnResume(UI::EventParams &params) {
UI::EventReturn EmuScreen::OnReset(UI::EventParams &params) {
if (coreState == CoreState::CORE_RUNTIME_ERROR) {
System_PostUIMessage("reset", "");
System_PostUIMessage(UIMessage::REQUEST_GAME_RESET);
}
return UI::EVENT_DONE;
}

View file

@ -46,7 +46,7 @@ public:
void preRender() override;
void postRender() override;
void dialogFinished(const Screen *dialog, DialogResult result) override;
void sendMessage(const char *msg, const char *value) override;
void sendMessage(UIMessage message, const char *value) override;
void resized() override;
// Note: Unlike your average boring UIScreen, here we override the Unsync* functions

View file

@ -298,7 +298,7 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings)
static const char *msaaModes[] = { "Off", "2x", "4x", "8x", "16x" };
auto msaaChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iMultiSampleLevel, gr->T("Antialiasing (MSAA)"), msaaModes, 0, ARRAY_SIZE(msaaModes), I18NCat::GRAPHICS, screenManager()));
msaaChoice->OnChoice.Add([&](UI::EventParams &) -> UI::EventReturn {
System_PostUIMessage("gpu_renderResized", "");
System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED);
return UI::EVENT_DONE;
});
msaaChoice->SetDisabledPtr(&g_Config.bSoftwareRendering);
@ -393,7 +393,7 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings)
settingInfo_->Show(gr->T("RenderingMode NonBuffered Tip", "Faster, but graphics may be missing in some games"), e.v);
g_Config.bAutoFrameSkip = false;
}
System_PostUIMessage("gpu_renderResized", "");
System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED);
return UI::EVENT_DONE;
});
skipBufferEffects->SetDisabledPtr(&g_Config.bSoftwareRendering);
@ -1231,7 +1231,7 @@ UI::EventReturn GameSettingsScreen::OnSustainedPerformanceModeChange(UI::EventPa
}
UI::EventReturn GameSettingsScreen::OnJitAffectingSetting(UI::EventParams &e) {
System_PostUIMessage("clear jit", "");
System_PostUIMessage(UIMessage::REQUEST_CLEAR_JIT);
return UI::EVENT_DONE;
}
@ -1348,7 +1348,7 @@ UI::EventReturn GameSettingsScreen::OnResolutionChange(UI::EventParams &e) {
System_RecreateActivity();
}
Reporting::UpdateConfig();
System_PostUIMessage("gpu_renderResized", "");
System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED);
return UI::EVENT_DONE;
}
@ -1372,7 +1372,7 @@ void GameSettingsScreen::onFinish(DialogResult result) {
// Wipe some caches after potentially changing settings.
// Let's not send resize messages here, handled elsewhere.
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
void GameSettingsScreen::dialogFinished(const Screen *dialog, DialogResult result) {
@ -1586,7 +1586,7 @@ UI::EventReturn GameSettingsScreen::OnTextureShader(UI::EventParams &e) {
}
UI::EventReturn GameSettingsScreen::OnTextureShaderChange(UI::EventParams &e) {
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
RecreateViews(); // Update setting name
g_Config.bTexHardwareScaling = g_Config.sTextureShaderName != "Off";
return UI::EVENT_DONE;
@ -1785,7 +1785,7 @@ void DeveloperToolsScreen::CreateViews() {
void DeveloperToolsScreen::onFinish(DialogResult result) {
g_Config.Save("DeveloperToolsScreen::onFinish");
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
void GameSettingsScreen::CallbackRestoreDefaults(bool yes) {
@ -1866,7 +1866,7 @@ UI::EventReturn DeveloperToolsScreen::OnTouchscreenTest(UI::EventParams &e) {
}
UI::EventReturn DeveloperToolsScreen::OnJitAffectingSetting(UI::EventParams &e) {
System_PostUIMessage("clear jit", "");
System_PostUIMessage(UIMessage::REQUEST_CLEAR_JIT);
return UI::EVENT_DONE;
}

View file

@ -1343,27 +1343,15 @@ UI::EventReturn MainScreen::OnDismissUpgrade(UI::EventParams &e) {
return UI::EVENT_DONE;
}
void MainScreen::sendMessage(const char *message, const char *value) {
void MainScreen::sendMessage(UIMessage message, const char *value) {
// Always call the base class method first to handle the most common messages.
UIScreenWithBackground::sendMessage(message, value);
if (screenManager()->topScreen() == this) {
if (!strcmp(message, "boot")) {
if (message == UIMessage::REQUEST_GAME_BOOT) {
if (screenManager()->topScreen() == this) {
LaunchFile(screenManager(), Path(std::string(value)));
}
if (!strcmp(message, "browse_fileSelect")) {
INFO_LOG(SYSTEM, "Attempting to launch: '%s'", value);
LaunchFile(screenManager(), Path(std::string(value)));
}
if (!strcmp(message, "browse_folderSelect")) {
std::string filename = value;
INFO_LOG(SYSTEM, "Got folder: '%s'", filename.c_str());;
// switch to the 'Games' tab which has the file browser
tabHolder_->SetCurrentTab(1);
gameBrowsers_[1]->SetPath(Path(filename));
}
}
if (!strcmp(message, "permission_granted") && !strcmp(value, "storage")) {
} else if (message == UIMessage::PERMISSION_GRANTED && !strcmp(value, "storage")) {
RecreateViews();
}
}
@ -1383,7 +1371,7 @@ UI::EventReturn MainScreen::OnLoadFile(UI::EventParams &e) {
if (System_GetPropertyBool(SYSPROP_HAS_FILE_BROWSER)) {
auto mm = GetI18NCategory(I18NCat::MAINMENU);
System_BrowseForFile(mm->T("Load"), BrowseFileType::BOOTABLE, [](const std::string &value, int) {
System_PostUIMessage("boot", value);
System_PostUIMessage(UIMessage::REQUEST_GAME_BOOT, value);
});
}
return UI::EVENT_DONE;

View file

@ -124,7 +124,7 @@ protected:
void CreateViews() override;
void DrawBackground(UIContext &dc) override;
void update() override;
void sendMessage(const char *message, const char *value) override;
void sendMessage(UIMessage message, const char *value) override;
void dialogFinished(const Screen *dialog, DialogResult result) override;
bool DrawBackgroundFor(UIContext &dc, const Path &gamePath, float progress);

View file

@ -423,35 +423,36 @@ void DrawGameBackground(UIContext &dc, const Path &gamePath, float x, float y, f
}
}
void HandleCommonMessages(const char *message, const char *value, ScreenManager *manager, const Screen *activeScreen) {
void HandleCommonMessages(UIMessage message, const char *value, ScreenManager *manager, const Screen *activeScreen) {
bool isActiveScreen = manager->topScreen() == activeScreen;
if (!strcmp(message, "clear jit") && PSP_IsInited()) {
if (message == UIMessage::REQUEST_CLEAR_JIT && PSP_IsInited()) {
// TODO: This seems to clearly be the wrong place to handle this.
if (MIPSComp::jit) {
std::lock_guard<std::recursive_mutex> guard(MIPSComp::jitLock);
if (MIPSComp::jit)
MIPSComp::jit->ClearCache();
}
currentMIPS->UpdateCore((CPUCore)g_Config.iCpuCore);
} else if (!strcmp(message, "control mapping") && isActiveScreen && std::string(activeScreen->tag()) != "ControlMapping") {
} else if (message == UIMessage::SHOW_CONTROL_MAPPING && isActiveScreen && std::string(activeScreen->tag()) != "ControlMapping") {
UpdateUIState(UISTATE_MENU);
manager->push(new ControlMappingScreen(Path()));
} else if (!strcmp(message, "display layout editor") && isActiveScreen && std::string(activeScreen->tag()) != "DisplayLayout") {
} else if (message == UIMessage::SHOW_DISPLAY_LAYOUT_EDITOR && isActiveScreen && std::string(activeScreen->tag()) != "DisplayLayout") {
UpdateUIState(UISTATE_MENU);
manager->push(new DisplayLayoutScreen(Path()));
} else if (!strcmp(message, "settings") && isActiveScreen && std::string(activeScreen->tag()) != "GameSettings") {
} else if (message == UIMessage::SHOW_SETTINGS && isActiveScreen && std::string(activeScreen->tag()) != "GameSettings") {
UpdateUIState(UISTATE_MENU);
manager->push(new GameSettingsScreen(Path()));
} else if (!strcmp(message, "language screen") && isActiveScreen) {
} else if (message == UIMessage::SHOW_LANGUAGE_SCREEN && isActiveScreen) {
auto sy = GetI18NCategory(I18NCat::SYSTEM);
auto langScreen = new NewLanguageScreen(sy->T("Language"));
langScreen->OnChoice.Add([](UI::EventParams &) {
System_PostUIMessage("recreateviews", "");
System_PostUIMessage(UIMessage::RECREATE_VIEWS);
System_Notify(SystemNotification::UI);
return UI::EVENT_DONE;
});
manager->push(langScreen);
} else if (!strcmp(message, "window minimized")) {
} else if (message == UIMessage::WINDOW_MINIMIZED) {
if (!strcmp(value, "true")) {
gstate_c.skipDrawReason |= SKIPDRAW_WINDOW_MINIMIZED;
} else {
@ -478,8 +479,8 @@ void UIScreenWithGameBackground::DrawBackground(UIContext &dc) {
}
}
void UIScreenWithGameBackground::sendMessage(const char *message, const char *value) {
if (!strcmp(message, "settings") && screenManager()->topScreen() == this) {
void UIScreenWithGameBackground::sendMessage(UIMessage message, const char *value) {
if (message == UIMessage::SHOW_SETTINGS && screenManager()->topScreen() == this) {
screenManager()->push(new GameSettingsScreen(gamePath_));
} else {
UIScreenWithBackground::sendMessage(message, value);
@ -499,15 +500,15 @@ void UIDialogScreenWithGameBackground::DrawBackground(UIContext &dc) {
}
}
void UIDialogScreenWithGameBackground::sendMessage(const char *message, const char *value) {
if (!strcmp(message, "settings") && screenManager()->topScreen() == this) {
void UIDialogScreenWithGameBackground::sendMessage(UIMessage message, const char *value) {
if (message == UIMessage::SHOW_SETTINGS && screenManager()->topScreen() == this) {
screenManager()->push(new GameSettingsScreen(gamePath_));
} else {
UIDialogScreenWithBackground::sendMessage(message, value);
}
}
void UIScreenWithBackground::sendMessage(const char *message, const char *value) {
void UIScreenWithBackground::sendMessage(UIMessage message, const char *value) {
HandleCommonMessages(message, value, screenManager(), this);
}
@ -524,7 +525,7 @@ void UIDialogScreenWithBackground::AddStandardBack(UI::ViewGroup *parent) {
parent->Add(new Choice(di->T("Back"), "", false, new AnchorLayoutParams(150, 64, 10, NONE, NONE, 10)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
}
void UIDialogScreenWithBackground::sendMessage(const char *message, const char *value) {
void UIDialogScreenWithBackground::sendMessage(UIMessage message, const char *value) {
HandleCommonMessages(message, value, screenManager(), this);
}
@ -741,8 +742,8 @@ void LogoScreen::update() {
sinceStart_ = (double)frames_ / rate;
}
void LogoScreen::sendMessage(const char *message, const char *value) {
if (!strcmp(message, "boot") && screenManager()->topScreen() == this) {
void LogoScreen::sendMessage(UIMessage message, const char *value) {
if (message == UIMessage::REQUEST_GAME_BOOT && screenManager()->topScreen() == this) {
screenManager()->switchScreen(new EmuScreen(Path(value)));
}
}

View file

@ -41,7 +41,7 @@ public:
UIScreenWithBackground() : UIScreen() {}
protected:
void DrawBackground(UIContext &dc) override;
void sendMessage(const char *message, const char *value) override;
void sendMessage(UIMessage message, const char *value) override;
};
class UIScreenWithGameBackground : public UIScreenWithBackground {
@ -49,7 +49,7 @@ public:
UIScreenWithGameBackground(const std::string &gamePath)
: UIScreenWithBackground(), gamePath_(gamePath) {}
void DrawBackground(UIContext &dc) override;
void sendMessage(const char *message, const char *value) override;
void sendMessage(UIMessage message, const char *value) override;
protected:
Path gamePath_;
@ -62,7 +62,7 @@ public:
UIDialogScreenWithBackground() : UIDialogScreen() {}
protected:
void DrawBackground(UIContext &dc) override;
void sendMessage(const char *message, const char *value) override;
void sendMessage(UIMessage message, const char *value) override;
void AddStandardBack(UI::ViewGroup *parent);
};
@ -72,7 +72,7 @@ public:
UIDialogScreenWithGameBackground(const Path &gamePath)
: UIDialogScreenWithBackground(), gamePath_(gamePath) {}
void DrawBackground(UIContext &dc) override;
void sendMessage(const char *message, const char *value) override;
void sendMessage(UIMessage message, const char *value) override;
protected:
Path gamePath_;
@ -141,7 +141,7 @@ public:
void touch(const TouchInput &touch) override;
void update() override;
void render() override;
void sendMessage(const char *message, const char *value) override;
void sendMessage(UIMessage message, const char *value) override;
void CreateViews() override {}
const char *tag() const override { return "Logo"; }

View file

@ -153,7 +153,7 @@
#include <Core/HLE/Plugins.h>
bool HandleGlobalMessage(const std::string &msg, const std::string &value);
bool HandleGlobalMessage(UIMessage message, const std::string &value);
ScreenManager *g_screenManager;
std::string config_filename;
@ -167,7 +167,7 @@ static bool restarting = false;
static int renderCounter = 0;
struct PendingMessage {
std::string msg;
UIMessage message;
std::string value;
};
@ -1078,10 +1078,11 @@ void NativeFrame(GraphicsContext *graphicsContext) {
}
for (const auto &item : toProcess) {
if (HandleGlobalMessage(item.msg, item.value)) {
INFO_LOG(SYSTEM, "Handled global message: %s / %s", item.msg.c_str(), item.value.c_str());
if (HandleGlobalMessage(item.message, item.value)) {
// TODO: Add a to-string thingy.
INFO_LOG(SYSTEM, "Handled global message: %d / %s", (int)item.message, item.value.c_str());
}
g_screenManager->sendMessage(item.msg.c_str(), item.value.c_str());
g_screenManager->sendMessage(item.message, item.value.c_str());
}
g_requestManager.ProcessRequests();
@ -1177,7 +1178,7 @@ void NativeFrame(GraphicsContext *graphicsContext) {
#if !PPSSPP_PLATFORM(WINDOWS) && !defined(ANDROID)
PSP_CoreParameter().pixelWidth = g_display.pixel_xres;
PSP_CoreParameter().pixelHeight = g_display.pixel_yres;
System_PostUIMessage("gpu_displayResized", "");
System_PostUIMessage(UIMessage::GPU_DISPLAY_RESIZED);
#endif
} else {
// INFO_LOG(G3D, "Polling graphics context");
@ -1185,34 +1186,34 @@ void NativeFrame(GraphicsContext *graphicsContext) {
}
}
bool HandleGlobalMessage(const std::string &msg, const std::string &value) {
if (msg == "savestate_displayslot") {
bool HandleGlobalMessage(UIMessage message, const std::string &value) {
if (message == UIMessage::SAVESTATE_DISPLAY_SLOT) {
auto sy = GetI18NCategory(I18NCat::SYSTEM);
std::string msg = StringFromFormat("%s: %d", sy->T("Savestate Slot"), SaveState::GetCurrentSlot() + 1);
// Show for the same duration as the preview.
g_OSD.Show(OSDType::MESSAGE_INFO, msg, 2.0f, "savestate_slot");
return true;
}
else if (msg == "gpu_displayResized") {
else if (message == UIMessage::GPU_DISPLAY_RESIZED) {
if (gpu) {
gpu->NotifyDisplayResized();
}
return true;
}
else if (msg == "gpu_renderResized") {
else if (message == UIMessage::GPU_RENDER_RESIZED) {
if (gpu) {
gpu->NotifyRenderResized();
}
return true;
}
else if (msg == "gpu_configChanged") {
else if (message == UIMessage::GPU_CONFIG_CHANGED) {
if (gpu) {
gpu->NotifyConfigChanged();
}
Reporting::UpdateConfig();
return true;
}
else if (msg == "core_powerSaving") {
else if (message == UIMessage::POWER_SAVING) {
if (value != "false") {
auto sy = GetI18NCategory(I18NCat::SYSTEM);
#if PPSSPP_PLATFORM(ANDROID)
@ -1224,7 +1225,7 @@ bool HandleGlobalMessage(const std::string &msg, const std::string &value) {
Core_SetPowerSaving(value != "false");
return true;
}
else if (msg == "permission_granted" && value == "storage") {
else if (message == UIMessage::PERMISSION_GRANTED && value == "storage") {
CreateSysDirectories();
// We must have failed to load the config before, so load it now to avoid overwriting the old config
// with a freshly generated one.
@ -1237,7 +1238,7 @@ bool HandleGlobalMessage(const std::string &msg, const std::string &value) {
PostLoadConfig();
g_Config.iGPUBackend = gpuBackend;
return true;
} else if (msg == "app_resumed" || msg == "got_focus") {
} else if (message == UIMessage::APP_RESUMED || message == UIMessage::GOT_FOCUS) {
// Assume that the user may have modified things.
MemoryStick_NotifyWrite();
return true;
@ -1370,10 +1371,10 @@ void NativeAccelerometer(float tiltX, float tiltY, float tiltZ) {
HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_ACCELEROMETER_Z] = tiltZ;
}
void System_PostUIMessage(const std::string &message, const std::string &value) {
void System_PostUIMessage(UIMessage message, const std::string &value) {
std::lock_guard<std::mutex> lock(pendingMutex);
PendingMessage pendingMessage;
pendingMessage.msg = message;
pendingMessage.message = message;
pendingMessage.value = value;
pendingMessages.push_back(pendingMessage);
}

View file

@ -28,7 +28,7 @@
NSURL *firstURL = urls.firstObject;
if (!firstURL) return; // No URLs, don't do anything
System_PostUIMessage("boot", firstURL.fileSystemRepresentation);
System_PostUIMessage(UIMessage::REQUEST_GAME_BOOT, firstURL.fileSystemRepresentation);
}
- (NSMenu *)applicationDockMenu:(NSApplication *)sender {

View file

@ -260,10 +260,10 @@ void RetroAchievementsSettingsScreen::CreateTabs() {
CreateDeveloperToolsTab(AddTab("AchievementsDeveloperTools", sy->T("Developer Tools")));
}
void RetroAchievementsSettingsScreen::sendMessage(const char *message, const char *value) {
void RetroAchievementsSettingsScreen::sendMessage(UIMessage message, const char *value) {
TabbedUIDialogScreenWithGameBackground::sendMessage(message, value);
if (!strcmp(message, "achievements_loginstatechange")) {
if (message == UIMessage::ACHIEVEMENT_LOGIN_STATE_CHANGE) {
RecreateViews();
}
}

View file

@ -35,7 +35,7 @@ public:
const char *tag() const override { return "RetroAchievementsSettingsScreen"; }
void CreateTabs() override;
void sendMessage(const char *message, const char *value) override;
void sendMessage(UIMessage message, const char *value) override;
protected:
bool ShowSearchControls() const override { return false; }

View file

@ -675,7 +675,7 @@ UI::EventReturn SavedataScreen::OnSearch(UI::EventParams &e) {
auto di = GetI18NCategory(I18NCat::DIALOG);
if (System_GetPropertyBool(SYSPROP_HAS_TEXT_INPUT_DIALOG)) {
System_InputBoxGetString(di->T("Filter"), searchFilter_, [](const std::string &value, int ivalue) {
System_PostUIMessage("savedatascreen_search", value);
System_PostUIMessage(UIMessage::SAVEDATA_SEARCH, value);
});
}
return UI::EVENT_DONE;
@ -698,9 +698,9 @@ void SavedataScreen::dialogFinished(const Screen *dialog, DialogResult result) {
}
}
void SavedataScreen::sendMessage(const char *message, const char *value) {
void SavedataScreen::sendMessage(UIMessage message, const char *value) {
UIDialogScreenWithGameBackground::sendMessage(message, value);
if (!strcmp(message, "savedatascreen_search")) {
if (message == UIMessage::SAVEDATA_SEARCH) {
searchFilter_ = value;
dataBrowser_->SetSearchFilter(searchFilter_);
stateBrowser_->SetSearchFilter(searchFilter_);

View file

@ -73,7 +73,7 @@ public:
~SavedataScreen();
void dialogFinished(const Screen *dialog, DialogResult result) override;
void sendMessage(const char *message, const char *value) override;
void sendMessage(UIMessage message, const char *value) override;
const char *tag() const override { return "Savedata"; }

View file

@ -87,13 +87,13 @@ void TabbedUIDialogScreenWithGameBackground::CreateViews() {
searchSettings->Add(new ItemHeader(se->T("Find settings")));
searchSettings->Add(new PopupTextInputChoice(&searchFilter_, se->T("Filter"), "", 64, screenManager()))->OnChange.Add([=](UI::EventParams &e) {
System_PostUIMessage("gameSettings_search", StripSpaces(searchFilter_));
System_PostUIMessage(UIMessage::GAMESETTINGS_SEARCH, StripSpaces(searchFilter_));
return UI::EVENT_DONE;
});
clearSearchChoice_ = searchSettings->Add(new Choice(se->T("Clear filter")));
clearSearchChoice_->OnClick.Add([=](UI::EventParams &e) {
System_PostUIMessage("gameSettings_search", "");
System_PostUIMessage(UIMessage::GAMESETTINGS_SEARCH, "");
return UI::EVENT_DONE;
});
@ -104,9 +104,9 @@ void TabbedUIDialogScreenWithGameBackground::CreateViews() {
}
}
void TabbedUIDialogScreenWithGameBackground::sendMessage(const char *message, const char *value) {
void TabbedUIDialogScreenWithGameBackground::sendMessage(UIMessage message, const char *value) {
UIDialogScreenWithGameBackground::sendMessage(message, value);
if (!strcmp(message, "gameSettings_search")) {
if (message == UIMessage::GAMESETTINGS_SEARCH) {
std::string filter = value ? value : "";
searchFilter_.resize(filter.size());
std::transform(filter.begin(), filter.end(), searchFilter_.begin(), tolower);

View file

@ -3,6 +3,7 @@
#include "ppsspp_config.h"
#include "Common/UI/UIScreen.h"
#include "Common/System/System.h"
#include "Core/ConfigValues.h"
#include "UI/MiscScreens.h"
@ -21,7 +22,7 @@ protected:
virtual bool ShowSearchControls() const { return true; }
void RecreateViews() override;
void sendMessage(const char *message, const char *value) override;
void sendMessage(UIMessage message, const char *value) override;
SettingInfoMessage *settingInfo_ = nullptr;

View file

@ -331,7 +331,7 @@ void App::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ ar
PSP_CoreParameter().pixelWidth = (int)(width * scale);
PSP_CoreParameter().pixelHeight = (int)(height * scale);
if (UpdateScreenScale((int)width, (int)height)) {
System_PostUIMessage("gpu_displayResized", "");
System_PostUIMessage(UIMessage::GPU_DISPLAY_RESIZED);
}
}

View file

@ -241,7 +241,7 @@ namespace MainWindow
g_Config.iInternalResolution = 0;
}
System_PostUIMessage("gpu_renderResized", "");
System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED);
}
void CorrectCursor() {
@ -282,7 +282,7 @@ namespace MainWindow
SavePosition();
Core_NotifyWindowHidden(false);
if (!g_Config.bPauseWhenMinimized) {
System_PostUIMessage("window minimized", "false");
System_PostUIMessage(UIMessage::WINDOW_MINIMIZED, "false");
}
int width, height;
@ -302,8 +302,8 @@ namespace MainWindow
DEBUG_LOG(SYSTEM, "Pixel width/height: %dx%d", PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
if (UpdateScreenScale(width, height)) {
System_PostUIMessage("gpu_displayResized", "");
System_PostUIMessage("gpu_renderResized", "");
System_PostUIMessage(UIMessage::GPU_DISPLAY_RESIZED);
System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED);
}
// Don't save the window state if fullscreen.
@ -853,12 +853,12 @@ namespace MainWindow
}
if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) {
System_PostUIMessage("got_focus", "");
System_PostUIMessage(UIMessage::GOT_FOCUS);
hasFocus = true;
trapMouse = true;
}
if (wParam == WA_INACTIVE) {
System_PostUIMessage("lost_focus", "");
System_PostUIMessage(UIMessage::LOST_FOCUS);
WindowsRawInput::LoseFocus();
InputDevice::LoseFocus();
hasFocus = false;
@ -905,7 +905,7 @@ namespace MainWindow
case SIZE_MINIMIZED:
Core_NotifyWindowHidden(true);
if (!g_Config.bPauseWhenMinimized) {
System_PostUIMessage("window minimized", "true");
System_PostUIMessage(UIMessage::WINDOW_MINIMIZED, "true");
}
InputDevice::LoseFocus();
break;
@ -1029,7 +1029,7 @@ namespace MainWindow
TCHAR filename[512];
if (DragQueryFile(hdrop, 0, filename, 512) != 0) {
const std::string utf8_filename = ReplaceAll(ConvertWStringToUTF8(filename), "\\", "/");
System_PostUIMessage("boot", utf8_filename);
System_PostUIMessage(UIMessage::REQUEST_GAME_BOOT, utf8_filename);
Core_EnableStepping(false);
}
}

View file

@ -343,7 +343,7 @@ namespace MainWindow {
Core_EnableStepping(false);
}
filename = ReplaceAll(filename, "\\", "/");
System_PostUIMessage("boot", filename);
System_PostUIMessage(UIMessage::REQUEST_GAME_BOOT, filename);
W32Util::MakeTopMost(GetHWND(), g_Config.bTopMost);
}
@ -364,17 +364,17 @@ namespace MainWindow {
// not static
void setTexScalingMultiplier(int level) {
g_Config.iTexScalingLevel = level;
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
static void setTexScalingType(int type) {
g_Config.iTexScalingType = type;
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
static void setSkipBufferEffects(bool skip) {
g_Config.bSkipBufferEffects = skip;
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
static void setFrameSkipping(int framesToSkip = -1) {
@ -477,7 +477,7 @@ namespace MainWindow {
break;
case ID_EMULATION_PAUSE:
System_PostUIMessage("pause", "");
System_PostUIMessage(UIMessage::REQUEST_GAME_PAUSE);
break;
case ID_EMULATION_STOP:
@ -485,12 +485,12 @@ namespace MainWindow {
Core_EnableStepping(false);
Core_Stop();
System_PostUIMessage("stop", "");
System_PostUIMessage(UIMessage::REQUEST_GAME_STOP);
Core_WaitInactive();
break;
case ID_EMULATION_RESET:
System_PostUIMessage("reset", "");
System_PostUIMessage(UIMessage::REQUEST_GAME_RESET);
Core_EnableStepping(false);
break;
@ -510,7 +510,7 @@ namespace MainWindow {
case ID_EMULATION_CHAT:
if (GetUIState() == UISTATE_INGAME) {
System_PostUIMessage("chat screen", "");
System_PostUIMessage(UIMessage::SHOW_CHAT_SCREEN);
}
break;
case ID_FILE_LOADSTATEFILE:
@ -534,7 +534,7 @@ namespace MainWindow {
{
if (!Achievements::WarnUserIfChallengeModeActive()) {
SaveState::NextSlot();
System_PostUIMessage("savestate_displayslot", "");
System_PostUIMessage(UIMessage::SAVESTATE_DISPLAY_SLOT);
}
break;
}
@ -544,7 +544,7 @@ namespace MainWindow {
if (!Achievements::WarnUserIfChallengeModeActive()) {
if (!KeyMap::PspButtonHasMappings(VIRTKEY_NEXT_SLOT)) {
SaveState::NextSlot();
System_PostUIMessage("savestate_displayslot", "");
System_PostUIMessage(UIMessage::SAVESTATE_DISPLAY_SLOT);
}
}
break;
@ -600,7 +600,7 @@ namespace MainWindow {
}
case ID_OPTIONS_LANGUAGE:
System_PostUIMessage("language screen", "");
System_PostUIMessage(UIMessage::SHOW_LANGUAGE_SCREEN);
break;
case ID_OPTIONS_IGNOREWINKEY:
@ -645,7 +645,7 @@ namespace MainWindow {
g_Config.bAutoFrameSkip = !g_Config.bAutoFrameSkip;
if (g_Config.bAutoFrameSkip && g_Config.bSkipBufferEffects) {
g_Config.bSkipBufferEffects = false;
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
}
break;
@ -662,7 +662,7 @@ namespace MainWindow {
case ID_TEXTURESCALING_DEPOSTERIZE:
g_Config.bTexDeposterize = !g_Config.bTexDeposterize;
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
break;
case ID_OPTIONS_DIRECT3D9:
@ -691,7 +691,7 @@ namespace MainWindow {
case ID_OPTIONS_SKIP_BUFFER_EFFECTS:
g_Config.bSkipBufferEffects = !g_Config.bSkipBufferEffects;
System_PostUIMessage("gpu_renderResized", "");
System_PostUIMessage(UIMessage::GPU_RENDER_RESIZED);
g_OSD.ShowOnOff(gr->T("Skip Buffer Effects"), g_Config.bSkipBufferEffects);
break;
@ -703,17 +703,17 @@ namespace MainWindow {
} else {
g_Config.iDebugOverlay = (int)DebugOverlay::DEBUG_STATS;
}
System_PostUIMessage("clear jit", "");
System_PostUIMessage(UIMessage::REQUEST_CLEAR_JIT);
break;
case ID_OPTIONS_HARDWARETRANSFORM:
g_Config.bHardwareTransform = !g_Config.bHardwareTransform;
System_PostUIMessage("gpu_configChanged", "");
System_PostUIMessage(UIMessage::GPU_CONFIG_CHANGED);
g_OSD.ShowOnOff(gr->T("Hardware Transform"), g_Config.bHardwareTransform);
break;
case ID_OPTIONS_DISPLAY_LAYOUT:
System_PostUIMessage("display layout editor", "");
System_PostUIMessage(UIMessage::SHOW_DISPLAY_LAYOUT_EDITOR);
break;
@ -744,7 +744,7 @@ namespace MainWindow {
break;
case ID_DEBUG_DUMPNEXTFRAME:
System_PostUIMessage("gpu dump next frame", "");
System_PostUIMessage(UIMessage::REQUEST_GPU_DUMP_NEXT_FRAME);
break;
case ID_DEBUG_LOADMAPFILE:
@ -880,11 +880,11 @@ namespace MainWindow {
break;
case ID_OPTIONS_CONTROLS:
System_PostUIMessage("control mapping", "");
System_PostUIMessage(UIMessage::SHOW_CONTROL_MAPPING);
break;
case ID_OPTIONS_MORE_SETTINGS:
System_PostUIMessage("settings", "");
System_PostUIMessage(UIMessage::SHOW_SETTINGS);
break;
case ID_EMULATION_SOUND:

View file

@ -863,7 +863,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_resume(JNIEnv *, jclass) {
INFO_LOG(SYSTEM, "NativeApp.resume() - resuming audio");
AndroidAudio_Resume(g_audioState);
System_PostUIMessage("app_resumed", "");
System_PostUIMessage(UIMessage::APP_RESUMED);
}
extern "C" void Java_org_ppsspp_ppsspp_NativeApp_pause(JNIEnv *, jclass) {
@ -982,7 +982,7 @@ extern "C" bool Java_org_ppsspp_ppsspp_NativeRenderer_displayInit(JNIEnv * env,
renderer_inited = true;
}
System_PostUIMessage("recreateviews", "");
System_PostUIMessage(UIMessage::RECREATE_VIEWS);
if (IsVREnabled()) {
EnterVR(firstStart, graphicsContext->GetAPIContext());
@ -1265,7 +1265,7 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendMessageFromJava(JNI
INFO_LOG(SYSTEM, "STORAGE PERMISSION: GRANTED");
permissions[SYSTEM_PERMISSION_STORAGE] = PERMISSION_STATUS_GRANTED;
// Send along.
System_PostUIMessage(msg.c_str(), prm.c_str());
System_PostUIMessage(UIMessage::PERMISSION_GRANTED, prm);
} else if (msg == "sustained_perf_supported") {
sustainedPerfSupported = true;
} else if (msg == "safe_insets") {
@ -1284,7 +1284,7 @@ extern "C" void JNICALL Java_org_ppsspp_ppsspp_NativeApp_sendMessageFromJava(JNI
KeyMap::NotifyPadConnected(nextInputDeviceID, prm);
} else if (msg == "core_powerSaving") {
// Forward.
System_PostUIMessage(msg.c_str(), prm.c_str());
System_PostUIMessage(UIMessage::POWER_SAVING, prm);
} else if (msg == "exception") {
g_OSD.Show(OSDType::MESSAGE_ERROR, std::string("Java Exception"), prm, 10.0f);
} else {

View file

@ -116,7 +116,7 @@ bool System_GetPropertyBool(SystemProperty prop) {
}
}
void System_Notify(SystemNotification notification) {}
void System_PostUIMessage(const std::string &message, const std::string &param) {}
void System_PostUIMessage(UIMessage message, const std::string &param) {}
bool System_MakeRequest(SystemRequestType type, int requestId, const std::string &param1, const std::string &param2, int param3) {
switch (type) {
case SystemRequestType::SEND_DEBUG_OUTPUT:

View file

@ -112,7 +112,7 @@
iOSCoreAudioShutdown();
}
System_PostUIMessage("lost_focus", "");
System_PostUIMessage(UIMessage::LOST_FOCUS);
}
-(void) applicationDidBecomeActive:(UIApplication *)application {
@ -120,7 +120,7 @@
iOSCoreAudioInit();
}
System_PostUIMessage("got_focus", "");
System_PostUIMessage(UIMessage::GOT_FOCUS);
}
- (void)applicationWillTerminate:(UIApplication *)application {

View file

@ -1709,7 +1709,7 @@ void System_Notify(SystemNotification notification) {
}
}
bool System_MakeRequest(SystemRequestType type, int requestId, const std::string &param1, const std::string &param2, int param3) { return false; }
void System_PostUIMessage(const std::string &message, const std::string &param) {}
void System_PostUIMessage(UIMessage message, const std::string &param) {}
void NativeFrame(GraphicsContext *graphicsContext) {}
void NativeResized() {}

View file

@ -99,7 +99,7 @@ bool System_GetPropertyBool(SystemProperty prop) {
}
}
void System_Notify(SystemNotification notification) {}
void System_PostUIMessage(const std::string &message, const std::string &param) {}
void System_PostUIMessage(UIMessage message, const std::string &param) {}
void System_AudioGetDebugStats(char *buf, size_t bufSize) { if (buf) buf[0] = '\0'; }
void System_AudioClear() {}
void System_AudioPushSamples(const s32 *audio, int numSamples) {}