Skip to content

Commit

Permalink
theme.reset() does not save resetted values
Browse files Browse the repository at this point in the history
  • Loading branch information
hugeping committed May 19, 2024
1 parent d851c61 commit 917e4cc
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions stead/stead3/ext/sprites.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ instead.screen_dpi = instead_screen_dpi
local theme = std.obj {
nam = '@theme';
vars = {};
reset_vars = {};
{ reset_vars = {}; };
{
win = { gfx = {}};
inv = { gfx = {}};
Expand All @@ -68,29 +68,31 @@ function theme.restore(name)
if not v then
return
end
if not theme.reset_vars[name] then
theme.reset_vars[name] = instead.theme_var(name)
end
instead.theme_var(name, v);
end

function theme.set(name, val)
if type(name) ~= 'string' or val == nil then
std.err("Wrong parameter to theme.set", 2)
end
if not theme.reset_vars[name] then
theme.reset_vars[name] = instead.theme_var(name)
end
instead.theme_var(name, std.tostr(val));
theme.vars[name] = std.tostr(val);
theme.restore(name)
end

function theme.reset(name)
if type(name) ~= 'string' then
std.err("Wrong parameter to theme.reset", 2)
end
local v = theme.reset_vars[name]
if not v then
if not theme.vars[name] then
return
end
instead.theme_var(name, v);
local v = theme.reset_vars[name]
if v then
instead.theme_var(name, v);
end
theme.vars[name] = nil
theme.reset_vars[name] = nil
end
Expand Down

0 comments on commit 917e4cc

Please sign in to comment.