Skip to content

Commit

Permalink
Handle windows drop down menu
Browse files Browse the repository at this point in the history
  • Loading branch information
iota97 committed May 20, 2020
1 parent 4dbccf9 commit ac0f187
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions Qt/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "Qt/QtMain.h"

extern bool g_TakeScreenshot;
extern bool g_ShaderNameListChanged;

class MenuAction;
class MenuTree;
Expand Down
8 changes: 7 additions & 1 deletion UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
#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 @@ -1169,6 +1171,10 @@ void GameSettingsScreen::update() {
RecreateViews();
lastVertical_ = vertical;
}
if (g_ShaderNameListChanged) {
g_ShaderNameListChanged = false;
RecreateViews();
}
}

void GameSettingsScreen::onFinish(DialogResult result) {
Expand Down Expand Up @@ -1437,7 +1443,7 @@ UI::EventReturn GameSettingsScreen::OnPostProcShaderChange(UI::EventParams &e) {
NativeMessageReceived("gpu_resized", "");
g_Config.vPostShaderNames.erase(std::remove(g_Config.vPostShaderNames.begin(), g_Config.vPostShaderNames.end(), "Off"), g_Config.vPostShaderNames.end());
g_Config.vPostShaderNames.push_back("Off");
RecreateViews();
g_ShaderNameListChanged = true;
return UI::EVENT_DONE;
}

Expand Down
1 change: 1 addition & 0 deletions UI/NativeApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ 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
12 changes: 8 additions & 4 deletions Windows/MainWindowMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "Core/Core.h"

extern bool g_TakeScreenshot;
extern bool g_ShaderNameListChanged;

namespace MainWindow {
extern HINSTANCE hInst;
Expand Down Expand Up @@ -151,7 +152,7 @@ namespace MainWindow {
int item = ID_SHADERS_BASE + 1;

for (size_t i = 0; i < availableShaders.size(); i++)
CheckMenuItem(menu, item++, ((g_Config.vPostShaderNames[0] == availableShaders[i]) ? MF_CHECKED : MF_UNCHECKED));
CheckMenuItem(menu, item++, ((g_Config.vPostShaderNames[0] == availableShaders[i] && (g_Config.vPostShaderNames[0] == "Off" || g_Config.vPostShaderNames[1] == "Off")) ? MF_CHECKED : MF_UNCHECKED));
}

bool CreateShadersSubmenu(HMENU menu) {
Expand Down Expand Up @@ -185,7 +186,7 @@ namespace MainWindow {
continue;
int checkedStatus = MF_UNCHECKED;
availableShaders.push_back(i->section);
if (g_Config.vPostShaderNames[0] == i->section) {
if (g_Config.vPostShaderNames[0] == i->section && (g_Config.vPostShaderNames[0] == "Off" || g_Config.vPostShaderNames[1] == "Off")) {
checkedStatus = MF_CHECKED;
}

Expand Down Expand Up @@ -1056,8 +1057,11 @@ namespace MainWindow {
// ID_SHADERS_BASE and an additional 1 off it.
u32 index = (wParam - ID_SHADERS_BASE - 1);
if (index < availableShaders.size()) {
g_Config.vPostShaderNames[0] = availableShaders[index];

g_Config.vPostShaderNames.clear();
if (availableShaders[index] != "Off")
g_Config.vPostShaderNames.push_back(availableShaders[index]);
g_Config.vPostShaderNames.push_back("Off");
g_ShaderNameListChanged = true;
NativeMessageReceived("gpu_resized", "");
break;
}
Expand Down

0 comments on commit ac0f187

Please sign in to comment.