Skip to content

Commit

Permalink
fix for experimental version
Browse files Browse the repository at this point in the history
  • Loading branch information
Helfima committed Oct 22, 2024
1 parent 5250299 commit 2580605
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 113 deletions.
6 changes: 3 additions & 3 deletions core/Converter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ end
---@return string
function Converter.write(data_table)
local data_string = serpent.dump(data_table)
return game.encode_string(data_string)
return helpers.encode_string(data_string)
end

-------------------------------------------------------------------------------
Expand All @@ -36,7 +36,7 @@ function Converter.read(data_string)
data_string = Converter.trim(data_string)
if (string.sub(data_string, 1, 8) ~= "do local") then
local ok , err = pcall(function()
data_string = game.decode_string(data_string)
data_string = helpers.decode_string(data_string)
end)
if not(ok) then
return nil
Expand All @@ -54,7 +54,7 @@ end
---@param json string
---@return string
function Converter.indent(json)
local table_value = game.json_to_table(json)
local table_value = helpers.json_to_table(json)
local result = Converter.indentTable(table_value, 0)
return result
end
Expand Down
24 changes: 12 additions & 12 deletions dialog/AdminPanel.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-------------------------------------------------------------------------------
---Class to build panel
---@class AdminPanel
---@class AdminPanel : Form
AdminPanel = newclass(Form,function(base,classname)
Form.init(base,classname)
end)
Expand Down Expand Up @@ -276,7 +276,7 @@ function AdminPanel:updateCache()
end
end

local users_data = global["users"]
local users_data = storage["users"]
if table.size(users_data) > 0 then
local cache_panel = GuiElement.add(table_panel, GuiFlowV("user-caches"))
GuiElement.add(cache_panel, GuiLabel("translate-label"):caption("User caches"):style("helmod_label_title_frame"))
Expand Down Expand Up @@ -559,7 +559,7 @@ function AdminPanel:updateGlobal()
local scroll_panel = self:getGlobalTab()
local root_branch = GuiElement.add(scroll_panel, GuiFlowV())
root_branch.style.vertically_stretchable = false
self:createTree(root_branch, {global=global}, true)
self:createTree(root_branch, {storage=storage}, true)
end

-------------------------------------------------------------------------------
Expand Down Expand Up @@ -685,12 +685,12 @@ function AdminPanel:onEvent(event)
local decoded_textbox = parent["decoded-text"]
local encoded_textbox = parent["encoded-text"]
local input = string.sub(encoded_textbox.text,2)
local json = game.decode_string(input)
local json = helpers.decode_string(input)
local result = Converter.indent(json)
decoded_textbox.text = result

local tree_view = parent["tree_view"]["content"]
local data = game.json_to_table(json)
local data = helpers.json_to_table(json)
tree_view.clear()
self:createTree(tree_view, data)

Expand Down Expand Up @@ -736,19 +736,19 @@ function AdminPanel:onEvent(event)
local parent = event.element.parent.parent
local decoded_textbox = parent["decoded-text"]
local encoded_textbox = parent["encoded-text"]
encoded_textbox.text = "0"..game.encode_string(decoded_textbox.text)
encoded_textbox.text = "0"..helpers.encode_string(decoded_textbox.text)
end

if event.action == "delete-cache" then
if event.item1 ~= nil and global[event.item1] ~= nil then
if event.item1 ~= nil and storage[event.item1] ~= nil then
if event.item2 == "" and event.item3 == "" and event.item4 == "" then
global[event.item1] = nil
storage[event.item1] = nil
elseif event.item3 == "" and event.item4 == "" then
global[event.item1][event.item2] = {}
storage[event.item1][event.item2] = {}
elseif event.item4 == "" then
global[event.item1][event.item2][event.item3] = nil
storage[event.item1][event.item2][event.item3] = nil
else
global[event.item1][event.item2][event.item3][event.item4] = nil
storage[event.item1][event.item2][event.item3][event.item4] = nil
end
Player.print("Deleted:", event.item1, event.item2, event.item3, event.item4)
else
Expand All @@ -758,7 +758,7 @@ function AdminPanel:onEvent(event)
end

if event.action == "refresh-cache" then
global[event.item1][event.item2] = {}
storage[event.item1][event.item2] = {}

if event.item2 == "HMPlayer" then
Player.getResources()
Expand Down
2 changes: 1 addition & 1 deletion dialog/ProductionPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ end)
-------------------------------------------------------------------------------
---On initialization
function ProductionPanel:onInit()
self.panelCaption = string.format("%s %s", "Helmod", script.active_mods["helmod"])
self.panelCaption = string.format("%s %s %s", "Helmod", script.active_mods["helmod"], "Experimental (Quality not implemented)")
end

-------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 2580605

Please sign in to comment.