mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-10-08 01:34:06 -04:00
CLOSES #1928, CLOSES #1929, CLOSES #1930, CLOSES #1931, CLOSES #1933, CLOSES #1934, CLOSES #1935, CLOSES #1936
This commit is contained in:
+21
-11
@@ -18,25 +18,28 @@ end
|
||||
|
||||
-- One row's display state from its entry.converted, shared by new() and
|
||||
-- onChoose() so a successful convert updates a row exactly as building it did.
|
||||
local function applyRowState(item)
|
||||
local function applyRowState(item, canConvert)
|
||||
if not item.entry then return end
|
||||
-- NOT `cond and a or b`: that idiom breaks when `a` is itself nil/false.
|
||||
if item.entry.converted then
|
||||
item.muted = false
|
||||
item.right = nil
|
||||
else
|
||||
elseif canConvert then
|
||||
item.muted = true
|
||||
item.right = Strings("CONVERT")
|
||||
else
|
||||
item.muted = true
|
||||
item.right = Strings("UPDATE")
|
||||
end
|
||||
end
|
||||
|
||||
-- OFF, every real preset, then the permanent DOWNLOAD SHADERS action row.
|
||||
local function buildItems(active)
|
||||
local function buildItems(active, canConvert)
|
||||
local items = { { label = label(nil), entry = nil } }
|
||||
local selected = 1
|
||||
for _, entry in ipairs(ShaderFX.list()) do
|
||||
local item = { label = label(entry), entry = entry }
|
||||
applyRowState(item)
|
||||
applyRowState(item, canConvert)
|
||||
items[#items + 1] = item
|
||||
if active and active.name == entry.name then selected = #items end
|
||||
end
|
||||
@@ -50,7 +53,8 @@ function ShaderFXScreen.new(game, slot)
|
||||
slot = slot or "main"
|
||||
local optKey = ShaderFX.OPTION_KEY[slot]
|
||||
local title = (slot == "secondary") and "SHADER FX 2" or "SHADER FX"
|
||||
local items, selected = buildItems(ShaderFX.activeEntry(slot))
|
||||
local canConvert = ShaderFX.canConvert()
|
||||
local items, selected = buildItems(ShaderFX.activeEntry(slot), canConvert)
|
||||
|
||||
local self = setmetatable(ListMenu.new(game, title, items, {
|
||||
-- 7 rows leaves the title line and the one-line footer hint free.
|
||||
@@ -64,7 +68,7 @@ function ShaderFXScreen.new(game, slot)
|
||||
-- Rebuilds from ShaderFX.list() (e.g. after an install adds presets), keeping
|
||||
-- the cursor on the same row index (clamped) rather than resetting to OFF.
|
||||
local function refresh()
|
||||
local newItems = buildItems(ShaderFX.activeEntry(slot))
|
||||
local newItems = buildItems(ShaderFX.activeEntry(slot), canConvert)
|
||||
self.items = newItems
|
||||
self.index = math.max(1, math.min(self.index, #newItems))
|
||||
end
|
||||
@@ -113,12 +117,16 @@ function ShaderFXScreen.new(game, slot)
|
||||
-- A on an unconverted preset converts it in place instead of activating;
|
||||
-- the screen stays open either way, since a convert is not a selection.
|
||||
if item.entry and not item.entry.converted then
|
||||
if not canConvert then
|
||||
self.footer = Strings("Reinstall the app")
|
||||
return
|
||||
end
|
||||
local ok, err = ShaderFX.convert(item.entry)
|
||||
if not ok then
|
||||
require("src.core.Logger").error("ShaderFXScreen: convert failed for %s: %s",
|
||||
item.entry.name, tostring(err))
|
||||
end
|
||||
applyRowState(item)
|
||||
applyRowState(item, canConvert)
|
||||
if not ok then item.right = Strings("FAILED") end
|
||||
return
|
||||
end
|
||||
@@ -130,10 +138,12 @@ function ShaderFXScreen.new(game, slot)
|
||||
else
|
||||
-- isConverted() is existence-only with no staleness check, so an explicit
|
||||
-- selection always reconverts. Human-paced, CPU-only, never per frame.
|
||||
local convOk, convErr = ShaderFX.convert(item.entry)
|
||||
if not convOk then
|
||||
require("src.core.Logger").error("ShaderFXScreen: reconvert failed for %s: %s",
|
||||
item.entry.name, tostring(convErr))
|
||||
if canConvert then
|
||||
local convOk, convErr = ShaderFX.convert(item.entry)
|
||||
if not convOk then
|
||||
require("src.core.Logger").error("ShaderFXScreen: reconvert failed for %s: %s",
|
||||
item.entry.name, tostring(convErr))
|
||||
end
|
||||
end
|
||||
local overrides = opts and opts.shaderfxParams and opts.shaderfxParams[item.entry.name]
|
||||
local ok = ShaderFX.activate(slot, item.entry, overrides)
|
||||
|
||||
Reference in New Issue
Block a user