Skip to content

Commit

Permalink
use special setItemType and setMaterial methods when resetting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TymurGubayev committed Nov 7, 2023
1 parent e861565 commit 5ac5b9c
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions gui/job-details.lua
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,24 @@ function JobDetails:onChangeTrait()
end

function JobDetails:onResetChanges()
for i, stored_obj in pairs(self.stored) do
local iobj = self.job.items[i]
for k,v in pairs(stored_obj) do
if type(v) ~= 'table' then
iobj[k] = v
else
for k1,v1 in pairs(v) do
iobj[k][k1] = v1
end
for _, obj in pairs(self.list.choices) do
local stored_obj = self.stored[obj.index]

local item_type = stored_obj.item_type
local item_subtype = stored_obj.item_subtype
self:setItemType(obj, item_type, item_subtype)

local mat_type = stored_obj.mat_type
local mat_index = stored_obj.mat_index
self:setMaterial(obj, mat_type, mat_index)

for i = 1, 5 do
local k = 'flags'..i
local flags = stored_obj[k]
if not flags then break end

for k1,v1 in pairs(flags) do
obj.iobj[k][k1] = v1
end
end
end
Expand Down

0 comments on commit 5ac5b9c

Please sign in to comment.