User chain support

This commit is contained in:
iota97 committed 2020-09-13 21:48:00 +02:00
1 parent a81991f114
commit 0c885db052
13 files changed
+134 -48

No files matched your search

+49 -24
View File
@@ -74,6 +74,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();
@@ -305,24 +307,51 @@ void GameSettingsScreen::CreateViews() {
altSpeed2->SetZeroLabel(gr->T("Unlimited"));
altSpeed2->SetNegativeDisable(gr->T("Disabled"));
graphicsSettings->Add(new ItemHeader(gr->T("Features")));
postProcChoice_ = graphicsSettings->Add(new ChoiceWithValueDisplay(&g_Config.sPostShaderName, gr->T("Postprocessing Shader"), &PostShaderTranslateName));
postProcChoice_->OnClick.Handle(this, &GameSettingsScreen::OnPostProcShader);
postProcChoice_->SetEnabledFunc([] {
return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
});
graphicsSettings->Add(new ItemHeader(gr->T("Postprocessing effect")));
auto shaderChain = GetPostShaderChain(g_Config.sPostShaderName);
for (auto shaderInfo : shaderChain) {
for (size_t i = 0; i < ARRAY_SIZE(shaderInfo->settings); ++i) {
auto &setting = shaderInfo->settings[i];
if (!setting.name.empty()) {
auto &value = g_Config.mPostShaderSetting[StringFromFormat("%sSettingValue%d", shaderInfo->section.c_str(), i + 1)];
graphicsSettings->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, ps->T(setting.name), setting.step, screenManager()));
std::vector<std::string> alreadyAddedShader;
for (int i = 0; i < g_Config.vPostShaderNames.size() && i < ARRAY_SIZE(shaderNames_); ++i) {
// Vector pointer get invalidated on resize, cache name to have always a valid reference for drawing
shaderNames_[i] = g_Config.vPostShaderNames[i];
postProcChoice_ = graphicsSettings->Add(new ChoiceWithValueDisplay(&shaderNames_[i], StringFromFormat("%s #%d", gr->T("Postprocessing Shader"), i + 1), &PostShaderTranslateName));
postProcChoice_->OnClick.Add([=](EventParams &e) {
auto gr = GetI18NCategory("Graphics");
auto procScreen = new PostProcScreen(gr->T("Postprocessing Shader"), i);
procScreen->OnChoice.Handle(this, &GameSettingsScreen::OnPostProcShaderChange);
if (e.v)
procScreen->SetPopupOrigin(e.v);
screenManager()->push(procScreen);
return UI::EVENT_DONE;
});
postProcChoice_->SetEnabledFunc([] {
return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
});
auto shaderChain = GetPostShaderChain(g_Config.vPostShaderNames[i]);
for (auto shaderInfo : shaderChain) {
// Disable duplicated shader slider
bool duplicated = std::find(alreadyAddedShader.begin(), alreadyAddedShader.end(), shaderInfo->section) != alreadyAddedShader.end();
alreadyAddedShader.push_back(shaderInfo->section);
for (size_t i = 0; i < ARRAY_SIZE(shaderInfo->settings); ++i) {
auto &setting = shaderInfo->settings[i];
if (!setting.name.empty()) {
auto &value = g_Config.mPostShaderSetting[StringFromFormat("%sSettingValue%d", shaderInfo->section.c_str(), i + 1)];
if (duplicated) {
auto sliderName = StringFromFormat("%s %s", ps->T(setting.name), ps->T("(duplicated setting, previous slider will be used)"));
PopupSliderChoiceFloat *settingValue = graphicsSettings->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, sliderName, setting.step, screenManager()));
settingValue->SetEnabled(false);
} else {
PopupSliderChoiceFloat *settingValue = graphicsSettings->Add(new PopupSliderChoiceFloat(&value, setting.minValue, setting.maxValue, ps->T(setting.name), setting.step, screenManager()));
settingValue->SetEnabledFunc([] {
return g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
});
}
}
}
}
}
graphicsSettings->Add(new ItemHeader(gr->T("Screen layout")));
#if !defined(MOBILE_DEVICE)
graphicsSettings->Add(new CheckBox(&g_Config.bFullScreen, gr->T("FullScreen", "Full Screen")))->OnClick.Handle(this, &GameSettingsScreen::OnFullscreenChange);
if (System_GetPropertyInt(SYSPROP_DISPLAY_COUNT) > 1) {
@@ -1226,6 +1255,10 @@ void GameSettingsScreen::update() {
RecreateViews();
lastVertical_ = vertical;
}
if (g_ShaderNameListChanged) {
g_ShaderNameListChanged = false;
RecreateViews();
}
}
void GameSettingsScreen::onFinish(DialogResult result) {
@@ -1489,19 +1522,11 @@ UI::EventReturn GameSettingsScreen::OnLanguageChange(UI::EventParams &e) {
return UI::EVENT_DONE;
}
UI::EventReturn GameSettingsScreen::OnPostProcShader(UI::EventParams &e) {
auto gr = GetI18NCategory("Graphics");
auto procScreen = new PostProcScreen(gr->T("Postprocessing Shader"));
procScreen->OnChoice.Handle(this, &GameSettingsScreen::OnPostProcShaderChange);
if (e.v)
procScreen->SetPopupOrigin(e.v);
screenManager()->push(procScreen);
return UI::EVENT_DONE;
}
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_Config.vPostShaderNames.push_back("Off");
g_ShaderNameListChanged = true;
NativeMessageReceived("gpu_resized", "");
RecreateViews(); // Update setting name
return UI::EVENT_DONE;
}
+1 -1
View File
@@ -80,7 +80,6 @@ private:
UI::EventReturn OnLanguage(UI::EventParams &e);
UI::EventReturn OnLanguageChange(UI::EventParams &e);
UI::EventReturn OnAutoFrameskip(UI::EventParams &e);
UI::EventReturn OnPostProcShader(UI::EventParams &e);
UI::EventReturn OnPostProcShaderChange(UI::EventParams &e);
UI::EventReturn OnTextureShader(UI::EventParams &e);
UI::EventReturn OnTextureShaderChange(UI::EventParams &e);
@@ -132,6 +131,7 @@ private:
int prevInflightFrames_;
bool enableReports_;
bool tessHWEnable_;
std::string shaderNames_[256];
//edit the game-specific settings and restore the global settings after exiting
bool editThenRestore_;
+3 -3
View File
@@ -301,7 +301,7 @@ void PromptScreen::TriggerFinish(DialogResult result) {
UIDialogScreenWithBackground::TriggerFinish(result);
}
PostProcScreen::PostProcScreen(const std::string &title) : ListPopupScreen(title) {
PostProcScreen::PostProcScreen(const std::string &title, int id) : ListPopupScreen(title), id_(id) {
auto ps = GetI18NCategory("PostShaders");
ReloadAllPostShaderInfo();
shaders_ = GetAllPostShaderInfo();
@@ -310,7 +310,7 @@ PostProcScreen::PostProcScreen(const std::string &title) : ListPopupScreen(title
for (int i = 0; i < (int)shaders_.size(); i++) {
if (!shaders_[i].visible)
continue;
if (shaders_[i].section == g_Config.sPostShaderName)
if (shaders_[i].section == g_Config.vPostShaderNames[id_])
selected = i;
items.push_back(ps->T(shaders_[i].section.c_str(), shaders_[i].name.c_str()));
}
@@ -320,7 +320,7 @@ PostProcScreen::PostProcScreen(const std::string &title) : ListPopupScreen(title
void PostProcScreen::OnCompleted(DialogResult result) {
if (result != DR_OK)
return;
g_Config.sPostShaderName = shaders_[listView_->GetSelected()].section;
g_Config.vPostShaderNames[id_] = shaders_[listView_->GetSelected()].section;
}
TextureShaderScreen::TextureShaderScreen(const std::string &title) : ListPopupScreen(title) {
+2 -1
View File
@@ -105,12 +105,13 @@ private:
class PostProcScreen : public ListPopupScreen {
public:
PostProcScreen(const std::string &title);
PostProcScreen(const std::string &title, int id);
private:
void OnCompleted(DialogResult result) override;
bool ShowButtons() const override { return true; }
std::vector<ShaderInfo> shaders_;
int id_;
};
class TextureShaderScreen : public ListPopupScreen {
+1
View File
@@ -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;