Skip to content

Commit

Permalink
UI: Remove extern global for UI message.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Apr 11, 2021
1 parent ca1a936 commit b5d21b4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
18 changes: 10 additions & 8 deletions UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@
#include "Windows/W32Util/ShellUtil.h"
#endif

extern bool g_ShaderNameListChanged;

GameSettingsScreen::GameSettingsScreen(std::string gamePath, std::string gameID, bool editThenRestore)
: UIDialogScreenWithGameBackground(gamePath), gameID_(gameID), enableReports_(false), editThenRestore_(editThenRestore) {
lastVertical_ = UseVerticalLayout();
Expand Down Expand Up @@ -1260,11 +1258,6 @@ void GameSettingsScreen::update() {
RecreateViews();
lastVertical_ = vertical;
}
if (g_ShaderNameListChanged) {
g_ShaderNameListChanged = false;
g_Config.bShaderChainRequires60FPS = PostShaderChainRequires60FPS(GetFullPostShadersChain(g_Config.vPostShaderNames));
RecreateViews();
}
}

void GameSettingsScreen::onFinish(DialogResult result) {
Expand Down Expand Up @@ -1292,6 +1285,14 @@ void GameSettingsScreen::onFinish(DialogResult result) {
NativeMessageReceived("gpu_clearCache", "");
}

void GameSettingsScreen::sendMessage(const char *message, const char *value) {
UIDialogScreenWithGameBackground::sendMessage(message, value);
if (!strcmp(message, "postshader_updated")) {
g_Config.bShaderChainRequires60FPS = PostShaderChainRequires60FPS(GetFullPostShadersChain(g_Config.vPostShaderNames));
RecreateViews();
}
}

#if PPSSPP_PLATFORM(ANDROID)
void GameSettingsScreen::CallbackMemstickFolder(bool yes) {
auto sy = GetI18NCategory("System");
Expand Down Expand Up @@ -1530,8 +1531,9 @@ UI::EventReturn GameSettingsScreen::OnLanguageChange(UI::EventParams &e) {

UI::EventReturn GameSettingsScreen::OnPostProcShaderChange(UI::EventParams &e) {
g_Config.vPostShaderNames.erase(std::remove(g_Config.vPostShaderNames.begin(), g_Config.vPostShaderNames.end(), "Off"), g_Config.vPostShaderNames.end());
g_ShaderNameListChanged = true;

NativeMessageReceived("gpu_resized", "");
NativeMessageReceived("postshader_updated", "");
return UI::EVENT_DONE;
}

Expand Down
1 change: 1 addition & 0 deletions UI/GameSettingsScreen.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class GameSettingsScreen : public UIDialogScreenWithGameBackground {
std::string tag() const override { return "settings"; }

protected:
void sendMessage(const char *message, const char *value) override;
void CreateViews() override;
void CallbackRestoreDefaults(bool yes);
void CallbackRenderingBackend(bool yes);
Expand Down
1 change: 0 additions & 1 deletion UI/NativeApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ std::string config_filename;

// Really need to clean this mess of globals up... but instead I add more :P
bool g_TakeScreenshot;
bool g_ShaderNameListChanged = false;
static bool isOuya;
static bool resized = false;
static bool restarting = false;
Expand Down
4 changes: 2 additions & 2 deletions Windows/MainWindowMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
#include "Core/Core.h"

extern bool g_TakeScreenshot;
extern bool g_ShaderNameListChanged;

namespace MainWindow {
extern HINSTANCE hInst;
Expand Down Expand Up @@ -1069,9 +1068,10 @@ namespace MainWindow {
g_Config.vPostShaderNames.clear();
if (availableShaders[index] != "Off")
g_Config.vPostShaderNames.push_back(availableShaders[index]);
g_ShaderNameListChanged = true;
g_Config.bShaderChainRequires60FPS = PostShaderChainRequires60FPS(GetFullPostShadersChain(g_Config.vPostShaderNames));

NativeMessageReceived("gpu_resized", "");
NativeMessageReceived("postshader_updated", "");
break;
}

Expand Down

0 comments on commit b5d21b4

Please sign in to comment.