Skip to content

Commit 372175d

Browse files
committed
Try to autodetect Linux and ATI for overdrive cables.
Remove some (vibecoded?) nonsense from the widget.
1 parent a79dde4 commit 372175d

2 files changed

Lines changed: 13 additions & 23 deletions

File tree

LuaUI/Widgets/gfx_overdrive_cables_menu.lua

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ options = {
4848
name = 'Energy grid cables',
4949
type = 'radioButton',
5050
items = {
51+
{ key = 'auto', name = 'Autodetect', desc = 'Show cables unless you are on Linux with ATI graphics because someone with this combination has yet to take on a simple investigation of graphics bugs.' },
5152
{ key = 'full', name = 'Full (animated flows)', desc = 'Show overdrive energy flowing through the grid (default).' },
5253
{ key = 'noflow', name = 'Static (no flows)', desc = 'Cheaper: gray pipes only, no per-tick flow reads or shader bubble pass.' },
5354
{ key = 'off', name = 'Off (no cables)', desc = 'Hide the cables/wires entirely.' },
5455
},
55-
value = 'full',
56+
value = 'auto',
5657
OnChange = function(self)
5758
Spring.SendCommands("luarules cabletree detail " .. self.value)
5859
end,
@@ -77,26 +78,14 @@ function widget:Initialize()
7778
options.cabletree_ghosts.value = readCurrentGhosts()
7879
-- And ensure the gadget agrees with whatever was saved (idempotent —
7980
-- the gadget's setters return early if state is unchanged).
80-
Spring.SendCommands("luarules cabletree detail " .. options.cabletree_detail.value)
81-
Spring.SendCommands("luarules cabletree ghosts " .. (options.cabletree_ghosts.value and "on" or "off"))
82-
end
83-
84-
-- Persistence: the gadget owns the truth via Spring.GetConfigInt. We let the
85-
-- widget framework's per-widget config (ZK_data.lua) hold a redundant copy
86-
-- of the value so the radio button shows correctly the moment the menu opens
87-
-- — but on Initialize we override it with the gadget's actual value.
88-
function widget:GetConfigData()
89-
return {
90-
value = options.cabletree_detail.value,
91-
ghosts = options.cabletree_ghosts.value,
92-
}
93-
end
94-
95-
function widget:SetConfigData(data)
96-
if data and data.value and LEVEL_BY_KEY[data.value] then
97-
options.cabletree_detail.value = data.value
98-
end
99-
if data and type(data.ghosts) == "boolean" then
100-
options.cabletree_ghosts.value = data.ghosts
81+
local detail = options.cabletree_detail.value
82+
if detail == "auto" then
83+
if Platform.gpuVendor == "ATI" and Platform.osFamily == "Linux" then
84+
detail = "off"
85+
else
86+
detail = "full"
87+
end
10188
end
89+
Spring.SendCommands("luarules cabletree detail " .. detail)
90+
Spring.SendCommands("luarules cabletree ghosts " .. (options.cabletree_ghosts.value and "on" or "off"))
10291
end

LuaUI/Widgets/gui_simple_settings.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,12 @@ local optionGenerationTable = {
149149
optionName = "cabletree_detail",
150150
name = "Energy grid cables",
151151
items = {
152+
{ key = 'auto', name = 'Autodetect', desc = 'Show cables unless you are on Linux with ATI graphics because someone with this combination has yet to take on a simple investigation of graphics bugs.' },
152153
{ key = 'full', name = 'Full (animated flows)', desc = 'Show overdrive energy flowing through the grid (default).' },
153154
{ key = 'noflow', name = 'Static (no flows)', desc = 'Cheaper: gray pipes only, no per-tick flow reads or shader bubble pass.' },
154155
{ key = 'off', name = 'Off (no cables)', desc = 'Hide the cables/wires entirely.' },
155156
},
156-
value = 'full',
157+
value = 'auto',
157158
type = 'radioButton',
158159
path = "Settings/Graphics",
159160
},

0 commit comments

Comments
 (0)