Make the post shader list more editable

This commit is contained in:
Henrik Rydgård committed 2022-12-07 10:27:02 +01:00
1 parent 82680633e7
commit aed5d76fbc
8 files changed
+135 -67

No files matched your search

-39
View File
@@ -551,45 +551,6 @@ void PromptScreen::TriggerFinish(DialogResult result) {
UIDialogScreenWithBackground::TriggerFinish(result);
}
PostProcScreen::PostProcScreen(const std::string &title, int id, bool showStereoShaders) : ListPopupScreen(title), id_(id), showStereoShaders_(showStereoShaders) { }
void PostProcScreen::CreateViews() {
auto ps = GetI18NCategory("PostShaders");
ReloadAllPostShaderInfo(screenManager()->getDrawContext());
shaders_ = GetAllPostShaderInfo();
std::vector<std::string> items;
int selected = -1;
const std::string selectedName = id_ >= (int)g_Config.vPostShaderNames.size() ? "Off" : g_Config.vPostShaderNames[id_];
for (int i = 0; i < (int)shaders_.size(); i++) {
if (!shaders_[i].visible)
continue;
if (shaders_[i].isStereo != showStereoShaders_)
continue;
if (shaders_[i].section == selectedName)
selected = (int)indexTranslation_.size();
items.push_back(ps->T(shaders_[i].section.c_str(), shaders_[i].name.c_str()));
indexTranslation_.push_back(i);
}
adaptor_ = UI::StringVectorListAdaptor(items, selected);
ListPopupScreen::CreateViews();
}
void PostProcScreen::OnCompleted(DialogResult result) {
if (result != DR_OK)
return;
const std::string &value = shaders_[indexTranslation_[listView_->GetSelected()]].section;
// I feel this logic belongs more in the caller, but eh...
if (showStereoShaders_) {
g_Config.sStereoToMonoShader = value;
} else {
if (id_ < (int)g_Config.vPostShaderNames.size())
g_Config.vPostShaderNames[id_] = value;
else
g_Config.vPostShaderNames.push_back(value);
}
}
TextureShaderScreen::TextureShaderScreen(const std::string &title) : ListPopupScreen(title) {}
void TextureShaderScreen::CreateViews() {