From 948927e51664887764489259cea0e5dd73364eab Mon Sep 17 00:00:00 2001 From: Helfima Date: Fri, 2 Jun 2017 21:19:32 +0200 Subject: [PATCH] Added few output recipe for product block Added few output recipe for product block Changed disable/hidden recipe in selector panel Fixed power tab Fixed minimum speed with modules --- controller/Controller.lua | 2 +- controller/PlayerController.lua | 6 +- dialog/Dialog.lua | 64 +++---- dialog/PinPanel.lua | 40 ++--- dialog/Settings.lua | 249 ++------------------------- edition/AbstractEdition.lua | 210 +++++++++++------------ edition/EnergyEdition.lua | 118 ++++++------- edition/ProductEdition.lua | 30 ++-- edition/RecipeEdition.lua | 291 ++++++++++++++++---------------- edition/ResourceEdition.lua | 34 ++-- info.json | 2 +- locale/en/helmod.cfg | 2 + locale/fr/helmod.cfg | 2 + model/Model.lua | 191 ++++++++++++--------- selector/AbstractSelector.lua | 114 +++++++------ selector/EntitySelector.lua | 12 +- selector/ItemSelector.lua | 12 +- selector/RecipeSelector.lua | 26 ++- selector/TechnologySelector.lua | 21 ++- tab/EnergyTab.lua | 74 +------- tab/MainTab.lua | 42 +++-- tab/ProductionBlockTab.lua | 31 ++-- tab/PropertiesTab.lua | 37 ++-- tab/ResourceTab.lua | 13 +- 24 files changed, 666 insertions(+), 957 deletions(-) diff --git a/controller/Controller.lua b/controller/Controller.lua index 96eceb37..232dd4ba 100644 --- a/controller/Controller.lua +++ b/controller/Controller.lua @@ -221,7 +221,7 @@ function Controller.methods:parse_event(event, type) local item2 = string.match(event.element.name,patternItem2,1) local item3 = string.match(event.element.name,patternItem3,1) Logging:debug(self:classname(), "parse_event:", event.element.name, action, item, item2, item3) - eventController:send_event(player, event.element, action, item, item2, item3) + eventController:send_event(player, event, action, item, item2, item3) end end end diff --git a/controller/PlayerController.lua b/controller/PlayerController.lua index 582e1641..5bc8ef9d 100644 --- a/controller/PlayerController.lua +++ b/controller/PlayerController.lua @@ -241,6 +241,7 @@ function PlayerController.methods:getDefaultSettings() model_filter_beacon_module = true, other_speed_panel=false, real_name=false, + filter_show_disable=false, filter_show_hidden=false } end @@ -624,7 +625,8 @@ function PlayerController.methods:createFakeRecipe(player, entity, type) group = entity.group, subgroup = entity.subgroup, energy = 1, - enabled = true + enabled = true, + hidden = false } if type == "resource" and entity.resource_category ~= nil then recipe.localised_name = {"entity-name."..entity.name} @@ -688,6 +690,7 @@ end -- @return #LuaEntityPrototype entity prototype -- function PlayerController.methods:getEntityPrototype(name) + if name == nil then return nil end return game.entity_prototypes[name] end @@ -1052,6 +1055,7 @@ end -- @param #string property -- function PlayerController.methods:getEntityProperty(name, property) + Logging:trace(self:classname(), "getEntityProperty(name, property)", name, property) local entity = self:getEntityPrototype(name) if entity ~= nil then if property == "type" then diff --git a/dialog/Dialog.lua b/dialog/Dialog.lua index 5a18e027..0fc873f9 100644 --- a/dialog/Dialog.lua +++ b/dialog/Dialog.lua @@ -90,22 +90,22 @@ end -- @function [parent=#Dialog] open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function Dialog.methods:open(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "open():",player, element, action, item, item2, item3) +function Dialog.methods:open(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "open():", action, item, item2, item3) local parentPanel = self:getParentPanel(player) if parentPanel[self:classname()] ~= nil and parentPanel[self:classname()].valid then - local close = self:on_open(player, element, action, item, item2, item3) + local close = self:on_open(player, event, action, item, item2, item3) --Logging:debug(self:classname() , "must close:",close) if close then - self:close(player, element, action, item, item2, item3) + self:close(player, event, action, item, item2, item3) else - self:update(player, element, action, item, item2, item3) + self:update(player, event, action, item, item2, item3) end else @@ -117,9 +117,9 @@ function Dialog.methods:open(player, element, action, item, item2, item3) local headerPanel = self:addGuiFrameH(panel, "header-panel", "helmod_frame_resize_row_width") self:addGuiLabel(headerPanel, "title", caption, "helmod_label_title_frame") - self:on_open(player, element, action, item, item2, item3) - self:after_open(player, element, action, item, item2, item3) - self:update(player, element, action, item, item2, item3) + self:on_open(player, event, action, item, item2, item3) + self:after_open(player, event, action, item, item2, item3) + self:update(player, event, action, item, item2, item3) end end @@ -129,27 +129,27 @@ end -- @function [parent=#Dialog] send_event -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function Dialog.methods:send_event(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "send_event():",player, element, action, item, item2, item3) +function Dialog.methods:send_event(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "send_event():", action, item, item2, item3) if action == "OPEN" then - self:open(player, element, action, item, item2, item3) + self:open(player, event, action, item, item2, item3) end if action == "UPDATE" then - self:update(player, element, action, item, item2, item3) + self:update(player, event, action, item, item2, item3) end if action == "CLOSE" then - self:close(player, element, action, item, item2, item3) + self:close(player, event, action, item, item2, item3) end - self:on_event(player, element, action, item, item2, item3) + self:on_event(player, event, action, item, item2, item3) end ------------------------------------------------------------------------------- @@ -158,13 +158,13 @@ end -- @function [parent=#Dialog] on_event -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function Dialog.methods:on_event(player, element, action, item, item2, item3) +function Dialog.methods:on_event(player, event, action, item, item2, item3) end ------------------------------------------------------------------------------- @@ -173,13 +173,13 @@ end -- @function [parent=#Dialog] on_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function Dialog.methods:on_open(player, element, action, item, item2, item3) +function Dialog.methods:on_open(player, event, action, item, item2, item3) end ------------------------------------------------------------------------------- @@ -188,13 +188,13 @@ end -- @function [parent=#Dialog] after_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function Dialog.methods:after_open(player, element, action, item, item2, item3) +function Dialog.methods:after_open(player, event, action, item, item2, item3) end ------------------------------------------------------------------------------- @@ -203,14 +203,14 @@ end -- @function [parent=#Dialog] update -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function Dialog.methods:update(player, element, action, item, item2, item3) - self:on_update(player, element, action, item, item2, item3) +function Dialog.methods:update(player, event, action, item, item2, item3) + self:on_update(player, event, action, item, item2, item3) end ------------------------------------------------------------------------------- @@ -219,13 +219,13 @@ end -- @function [parent=#Dialog] on_update -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function Dialog.methods:on_update(player, element, action, item, item2, item3) +function Dialog.methods:on_update(player, event, action, item, item2, item3) end @@ -235,14 +235,14 @@ end -- @function [parent=#Dialog] close -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function Dialog.methods:close(player, element, action, item, item2, item3) - self:on_close(player, element, action, item, item2, item3) +function Dialog.methods:close(player, event, action, item, item2, item3) + self:on_close(player, event, action, item, item2, item3) local parentPanel = self:getParentPanel(player) if parentPanel[self:classname()] ~= nil and parentPanel[self:classname()].valid then parentPanel[self:classname()].destroy() @@ -255,7 +255,7 @@ end -- @function [parent=#Dialog] on_close -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name @@ -263,5 +263,5 @@ end -- -- @return #boolean if true the next call close dialog -- -function Dialog.methods:on_close(player, element, action, item, item2, item3) +function Dialog.methods:on_close(player, event, action, item, item2, item3) end diff --git a/dialog/PinPanel.lua b/dialog/PinPanel.lua index f48bb73f..a864b60a 100644 --- a/dialog/PinPanel.lua +++ b/dialog/PinPanel.lua @@ -39,7 +39,7 @@ end -- @function [parent=#PinPanel] on_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name @@ -47,7 +47,7 @@ end -- -- @return #boolean if true the next call close dialog -- -function PinPanel.methods:on_open(player, element, action, item, item2, item3) +function PinPanel.methods:on_open(player, event, action, item, item2, item3) local globalGui = self.player:getGlobalGui(player) local close = true if globalGui.pinBlock == nil or globalGui.pinBlock ~= item then @@ -63,13 +63,13 @@ end -- @function [parent=#PinPanel] on_close -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function PinPanel.methods:on_close(player, element, action, item, item2, item3) +function PinPanel.methods:on_close(player, event, action, item, item2, item3) local globalGui = self.player:getGlobalGui(player) globalGui.pinBlock = nil end @@ -111,14 +111,14 @@ end -- @function [parent=#PinPanel] after_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function PinPanel.methods:after_open(player, element, action, item, item2, item3) - self:updateHeader(player, element, action, item, item2, item3) +function PinPanel.methods:after_open(player, event, action, item, item2, item3) + self:updateHeader(player, event, action, item, item2, item3) self:getInfoPanel(player) end @@ -128,14 +128,14 @@ end -- @function [parent=#PinPanel] on_update -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function PinPanel.methods:on_update(player, element, action, item, item2, item3) - self:updateInfo(player, element, action, item, item2, item3) +function PinPanel.methods:on_update(player, event, action, item, item2, item3) + self:updateInfo(player, event, action, item, item2, item3) end ------------------------------------------------------------------------------- @@ -144,14 +144,14 @@ end -- @function [parent=#PinPanel] updateInfo -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function PinPanel.methods:updateHeader(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateHeader():",player, element, action, item, item2, item3) +function PinPanel.methods:updateHeader(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "updateHeader():", action, item, item2, item3) local headerPanel = self:getHeaderPanel(player) local model = self.model:getModel(player) @@ -171,14 +171,14 @@ end -- @function [parent=#PinPanel] updateInfo -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function PinPanel.methods:updateInfo(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateInfo():",player, element, action, item, item2, item3) +function PinPanel.methods:updateInfo(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "updateInfo():", action, item, item2, item3) local infoPanel = self:getInfoPanel(player) local model = self.model:getModel(player) local globalGui = self.player:getGlobalGui(player) @@ -336,14 +336,14 @@ end -- @function [parent=#PinPanel] on_event -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function PinPanel.methods:on_event(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "on_event():",player, element, action, item, item2, item3) +function PinPanel.methods:on_event(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "on_event():", action, item, item2, item3) local model = self.model:getModel(player) local globalSettings = self.player:getGlobal(player, "settings") local defaultSettings = self.player:getDefaultSettings() @@ -352,6 +352,6 @@ function PinPanel.methods:on_event(player, element, action, item, item2, item3) if action == "change-boolean-settings" then if globalSettings[item] == nil then globalSettings[item] = defaultSettings[item] end globalSettings[item] = not(globalSettings[item]) - self:updateInfo(player, element, action, globalGui.pinBlock, item2, item3) + self:updateInfo(player, event, action, globalGui.pinBlock, item2, item3) end end diff --git a/dialog/Settings.lua b/dialog/Settings.lua index ab29ab87..2375a28b 100644 --- a/dialog/Settings.lua +++ b/dialog/Settings.lua @@ -43,7 +43,7 @@ end -- @function [parent=#Settings] on_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name @@ -51,7 +51,7 @@ end -- -- @return #boolean if true the next call close dialog -- -function Settings.methods:on_open(player, element, action, item, item2, item3) +function Settings.methods:on_open(player, event, action, item, item2, item3) -- close si nouvel appel return true end @@ -137,14 +137,14 @@ end -- @function [parent=#Settings] on_event -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function Settings.methods:on_event(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "on_event():",player, element, action, item, item2, item3) +function Settings.methods:on_event(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "on_event():", action, item, item2, item3) local model = self.model:getModel(player) local globalSettings = self.player:getGlobal(player, "settings") local defaultSettings = self.player:getDefaultSettings() @@ -202,23 +202,19 @@ end -- @function [parent=#Settings] after_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function Settings.methods:after_open(player, element, action, item, item2, item3) +function Settings.methods:after_open(player, event, action, item, item2, item3) self.parent:send_event(player, "HMRecipeEdition", "CLOSE") self.parent:send_event(player, "HMRecipeSelector", "CLOSE") self.parent:send_event(player, "HMProductEdition", "CLOSE") self.parent:send_event(player, "HMEnergyEdition", "CLOSE") - self:updateAboutSettings(player, element, action, item, item2, item3) --- self:updateDisplaySettings(player, element, action, item, item2, item3) --- self:updateDataSettings(player, element, action, item, item2, item3) --- self:updateModelSettings(player, element, action, item, item2, item3) --- self:updateOtherSettings(player, element, action, item, item2, item3) + self:updateAboutSettings(player, event, action, item, item2, item3) end ------------------------------------------------------------------------------- @@ -227,14 +223,14 @@ end -- @function [parent=#Settings] updateAboutSettings -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function Settings.methods:updateAboutSettings(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateAboutSettings():",player, element, action, item, item2, item3) +function Settings.methods:updateAboutSettings(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "updateAboutSettings():", action, item, item2, item3) local aboutSettingsPanel = self:getAboutSettingsPanel(player) @@ -244,225 +240,4 @@ function Settings.methods:updateAboutSettings(player, element, action, item, ite self:addGuiLabel(dataSettingsTable, self:classname().."=version", game.active_mods["helmod"]) self:addGuiLabel(aboutSettingsPanel, self:classname().."=info", {"helmod_settings-panel.mod-info"}, "helmod_label_max_250", nil, false) -end - -------------------------------------------------------------------------------- --- Update display settings --- --- @function [parent=#Settings] updateDisplaySettings --- --- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name --- @param #string item first item name --- @param #string item2 second item name --- @param #string item3 third item name --- -function Settings.methods:updateDisplaySettings(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateDisplaySettings():",player, element, action, item, item2, item3) - - local globalSettings = self.player:getGlobal(player, "settings") - local defaultSettings = self.player:getDefaultSettings() - - local displaySettingsPanel = self:getDisplaySettingsPanel(player) - - for k,guiName in pairs(displaySettingsPanel.children_names) do - displaySettingsPanel[guiName].destroy() - end - - - local sizeSettingsTable = self:addGuiTable(displaySettingsPanel, "size", 3) - - local display_size = defaultSettings.display_size - if globalSettings.display_size ~= nil then display_size = globalSettings.display_size end - self:addGuiLabel(sizeSettingsTable, self:classname().."=display_size", ({"helmod_settings-panel.display-size"})) - - local display_size = defaultSettings.display_size - if globalSettings.display_size ~= nil then display_size = globalSettings.display_size end - local cell = self:addGuiTable(sizeSettingsTable,"display_sizes_list", 3) - for _,current_size in ipairs(helmod_display_sizes) do - local style = "helmod_button_default" - if display_size == current_size then style = "helmod_button_selected" end - self:addGuiButton(cell, self:classname().."=change-display-settings=ID=display_size=", current_size, style, current_size) - end - - local column_max = 7 - local columnSettingsTable = self:addGuiTable(displaySettingsPanel, "column", column_max) - self:addGuiLabel(columnSettingsTable, self:classname().."=display_product_cols", ({"helmod_settings-panel.display-product-cols"})) - local display_product_cols = defaultSettings.display_product_cols - if globalSettings.display_product_cols ~= nil then display_product_cols = globalSettings.display_product_cols end - for i = 2, column_max, 1 do - local style = "helmod_button_default" - if display_product_cols == i then style = "helmod_button_selected" end - self:addGuiButton(columnSettingsTable, self:classname().."=change-column-settings=ID=display_product_cols=", i, style, i) - end - - self:addGuiLabel(columnSettingsTable, self:classname().."=display_ingredient_cols", ({"helmod_settings-panel.display-ingredient-cols"})) - local display_ingredient_cols = defaultSettings.display_ingredient_cols - if globalSettings.display_ingredient_cols ~= nil then display_ingredient_cols = globalSettings.display_ingredient_cols end - for i = 2, column_max, 1 do - local style = "helmod_button_default" - if display_ingredient_cols == i then style = "helmod_button_selected" end - self:addGuiButton(columnSettingsTable, self:classname().."=change-column-settings=ID=display_ingredient_cols=", i, style, i) - end - - local cellmodSettingsTable = self:addGuiTable(displaySettingsPanel, "display_cell_mod", 3) - self:addGuiLabel(cellmodSettingsTable, self:classname().."=display_cell_mod", ({"helmod_settings-panel.display-cell-mod"})) - local display_cell_mod = defaultSettings.display_cell_mod - if globalSettings.display_cell_mod ~= nil then display_cell_mod = globalSettings.display_cell_mod end - local cell = self:addGuiTable(cellmodSettingsTable,"display_mod_list", 2) - for _,current_cell_mod in ipairs(helmod_display_cell_mod) do - local style = "helmod_button_default" - if display_cell_mod == current_cell_mod then style = "helmod_button_selected" end - self:addGuiButton(cell, self:classname().."=change-option-settings=ID=display_cell_mod=", current_cell_mod, style, current_cell_mod) - end - -end - -------------------------------------------------------------------------------- --- Update data settings --- --- @function [parent=#Settings] updateDataSettings --- --- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name --- @param #string item first item name --- @param #string item2 second item name --- @param #string item3 third item name --- -function Settings.methods:updateDataSettings(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateDataSettings():",player, element, action, item, item2, item3) - - local globalSettings = self.player:getGlobal(player, "settings") - local defaultSettings = self.player:getDefaultSettings() - - local dataSettingsPanel = self:getDataSettingsPanel(player) - - local dataSettingsTable = self:addGuiTable(dataSettingsPanel, "settings", 2) - - local display_data_col_name = defaultSettings.display_data_col_name - if globalSettings.display_data_col_name ~= nil then display_data_col_name = globalSettings.display_data_col_name end - self:addGuiLabel(dataSettingsTable, self:classname().."=display_data_col_name", ({"helmod_settings-panel.data-col-name"})) - self:addGuiCheckbox(dataSettingsTable, self:classname().."=change-boolean-settings=ID=display_data_col_name", display_data_col_name) - - local display_data_col_id = defaultSettings.display_data_col_id - if globalSettings.display_data_col_id ~= nil then display_data_col_id = globalSettings.display_data_col_id end - self:addGuiLabel(dataSettingsTable, self:classname().."=display_data_col_id", ({"helmod_settings-panel.data-col-id"})) - self:addGuiCheckbox(dataSettingsTable, self:classname().."=change-boolean-settings=ID=display_data_col_id", display_data_col_id) - - local display_data_col_index = defaultSettings.display_data_col_index - if globalSettings.display_data_col_index ~= nil then display_data_col_index = globalSettings.display_data_col_index end - self:addGuiLabel(dataSettingsTable, self:classname().."=display_data_col_index", ({"helmod_settings-panel.data-col-index"})) - self:addGuiCheckbox(dataSettingsTable, self:classname().."=change-boolean-settings=ID=display_data_col_index", display_data_col_index) - -end - -------------------------------------------------------------------------------- --- Update model settings --- --- @function [parent=#Settings] updateModelSettings --- --- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name --- @param #string item first item name --- @param #string item2 second item name --- @param #string item3 third item name --- -function Settings.methods:updateModelSettings(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateModelSettings():",player, element, action, item, item2, item3) - - local globalSettings = self.player:getGlobal(player, "settings") - local defaultSettings = self.player:getDefaultSettings() - - local modelSettingsPanel = self:getModelSettingsPanel(player) - - local modelSettingsTable = self:addGuiTable(modelSettingsPanel, "settings", 3) - - -- model_filter_factory - self:addGuiLabel(modelSettingsTable, self:classname().."=model_filter_factory", ({"helmod_settings-panel.model-filter-factory"})) - - local model_filter_factory = defaultSettings.model_filter_factory - if globalSettings.model_filter_factory ~= nil then model_filter_factory = globalSettings.model_filter_factory end - self:addGuiCheckbox(modelSettingsTable, self:classname().."=change-boolean-settings=ID=model_filter_factory", model_filter_factory) - self:addGuiLabel(modelSettingsTable, self:classname().."=blank=ID=model_filter_factory", "") - - -- model_filter_factory - self:addGuiLabel(modelSettingsTable, self:classname().."=model_filter_beacon", ({"helmod_settings-panel.model-filter-beacon"})) - - local model_filter_beacon = defaultSettings.model_filter_beacon - if globalSettings.model_filter_beacon ~= nil then model_filter_beacon = globalSettings.model_filter_beacon end - self:addGuiCheckbox(modelSettingsTable, self:classname().."=change-boolean-settings=ID=model_filter_beacon", model_filter_beacon) - self:addGuiLabel(modelSettingsTable, self:classname().."=blank=ID=model_filter_beacon", "") - - -- model_filter_generator - self:addGuiLabel(modelSettingsTable, self:classname().."=model_filter_generator", ({"helmod_settings-panel.model-filter-generator"})) - - local model_filter_generator = self.player:getGlobalSettings(player, "model_filter_generator") - self:addGuiCheckbox(modelSettingsTable, self:classname().."=change-boolean-settings=ID=model_filter_generator", model_filter_generator) - self:addGuiLabel(modelSettingsTable, self:classname().."=blank=ID=model_filter_generator", "") - - -- model_filter_factory_module - self:addGuiLabel(modelSettingsTable, self:classname().."=model_filter_factory_module", ({"helmod_settings-panel.model-filter-factory-module"})) - - local model_filter_factory_module = self.player:getGlobalSettings(player, "model_filter_factory_module") - self:addGuiCheckbox(modelSettingsTable, self:classname().."=change-boolean-settings=ID=model_filter_factory_module", model_filter_factory_module) - self:addGuiLabel(modelSettingsTable, self:classname().."=blank=ID=model_filter_factory_module", "") - - -- model_filter_beacon_module - self:addGuiLabel(modelSettingsTable, self:classname().."=model_filter_beacon_module", ({"helmod_settings-panel.model-filter-beacon-module"})) - - local model_filter_beacon_module = self.player:getGlobalSettings(player, "model_filter_beacon_module") - self:addGuiCheckbox(modelSettingsTable, self:classname().."=change-boolean-settings=ID=model_filter_beacon_module", model_filter_beacon_module) - self:addGuiLabel(modelSettingsTable, self:classname().."=blank=ID=model_filter_beacon_module", "") - -end - -------------------------------------------------------------------------------- --- Update other settings --- --- @function [parent=#Settings] updateOtherSettings --- --- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name --- @param #string item first item name --- @param #string item2 second item name --- @param #string item3 third item name --- -function Settings.methods:updateOtherSettings(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateOtherSettings():",player, element, action, item, item2, item3) - - local globalSettings = self.player:getGlobal(player, "settings") - local defaultSettings = self.player:getDefaultSettings() - - local otherSettingsPanel = self:getOtherSettingsPanel(player) - - local otherSettingsTable = self:addGuiTable(otherSettingsPanel, "settings", 3) - - -- other_speed_panel - self:addGuiLabel(otherSettingsTable, self:classname().."=other_speed_panel", ({"helmod_settings-panel.other-speed-panel"})) - - local other_speed_panel = defaultSettings.other_speed_panel - if globalSettings.other_speed_panel ~= nil then other_speed_panel = globalSettings.other_speed_panel end - self:addGuiCheckbox(otherSettingsTable, self:classname().."=change-boolean-settings=ID=other_speed_panel", other_speed_panel) - self:addGuiLabel(otherSettingsTable, self:classname().."=blank=ID=other_speed_panel", "") - - -- real_name - self:addGuiLabel(otherSettingsTable, self:classname().."=real_name", ({"helmod_settings-panel.real-name"})) - - local real_name = defaultSettings.real_name - if globalSettings.real_name ~= nil then real_name = globalSettings.real_name end - self:addGuiCheckbox(otherSettingsTable, self:classname().."=change-boolean-settings=ID=real_name", real_name) - self:addGuiLabel(otherSettingsTable, self:classname().."=blank=ID=real_name", "") - -end - - - - - - - - +end \ No newline at end of file diff --git a/edition/AbstractEdition.lua b/edition/AbstractEdition.lua index c7211eca..43f13ad1 100644 --- a/edition/AbstractEdition.lua +++ b/edition/AbstractEdition.lua @@ -26,7 +26,7 @@ end -- @function [parent=#AbstractEdition] on_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name @@ -34,7 +34,7 @@ end -- -- @return #boolean if true the next call close dialog -- -function AbstractEdition.methods:on_open(player, element, action, item, item2, item3) +function AbstractEdition.methods:on_open(player, event, action, item, item2, item3) local model = self.model:getModel(player) local close = true model.moduleListRefresh = false @@ -54,13 +54,13 @@ end -- @function [parent=#AbstractEdition] on_close -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:on_close(player, element, action, item, item2, item3) +function AbstractEdition.methods:on_close(player, event, action, item, item2, item3) local model = self.model:getModel(player) model.guiElementLast = nil model.moduleListRefresh = false @@ -264,18 +264,18 @@ end -- @function [parent=#AbstractEdition] after_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:after_open(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "after_open():",player, element, action, item, item2, item3) +function AbstractEdition.methods:after_open(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "after_open():", action, item, item2, item3) self.parent:send_event(player, "HMProductEdition", "CLOSE") self.parent:send_event(player, "HMRecipeSelector", "CLOSE") self.parent:send_event(player, "HMSettings", "CLOSE") - local object = self:getObject(player, element, action, item, item2, item3) + local object = self:getObject(player, event, action, item, item2, item3) local model = self.model:getModel(player) if model.module_panel == nil then @@ -335,22 +335,22 @@ end -- @function [parent=#AbstractEdition] on_update -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:on_update(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "on_update():",player, element, action, item, item2, item3) - local object = self:getObject(player, element, action, item, item2, item3) +function AbstractEdition.methods:on_update(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "on_update():", action, item, item2, item3) + local object = self:getObject(player, item, item2, item3) -- header - self:updateHeader(player, element, action, item, item2, item3) + self:updateHeader(player, item, item2, item3) if object ~= nil then -- factory - self:updateFactory(player, element, action, item, item2, item3) + self:updateFactory(player, item, item2, item3) -- beacon - self:updateBeacon(player, element, action, item, item2, item3) + self:updateBeacon(player, item, item2, item3) end end @@ -360,14 +360,12 @@ end -- @function [parent=#AbstractEdition] updateHeader -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:updateHeader(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateHeader():",player, element, action, item, item2, item3) +function AbstractEdition.methods:updateHeader(player, item, item2, item3) + Logging:debug(self:classname(), "updateHeader():", item, item2, item3) -- TODO something end @@ -377,22 +375,20 @@ end -- @function [parent=#AbstractEdition] updateFactory -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:updateFactory(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateFactory():",player, element, action, item, item2, item3) +function AbstractEdition.methods:updateFactory(player, item, item2, item3) + Logging:debug(self:classname(), "updateFactory():", item, item2, item3) local model = self.model:getModel(player) - self:updateFactoryInfo(player, element, action, item, item2, item3) + self:updateFactoryInfo(player, item, item2, item3) if model.module_panel == true then - self:updateFactoryActivedModules(player, element, action, item, item2, item3) - self:updateFactoryModulesSelector(player, element, action, item, item2, item3) + self:updateFactoryActivedModules(player, item, item2, item3) + self:updateFactoryModulesSelector(player, item, item2, item3) else - self:updateFactorySelector(player, element, action, item, item2, item3) + self:updateFactorySelector(player, item, item2, item3) end end @@ -402,22 +398,20 @@ end -- @function [parent=#AbstractEdition] updateBeacon -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:updateBeacon(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateBeacon():",player, element, action, item, item2, item3) +function AbstractEdition.methods:updateBeacon(player, item, item2, item3) + Logging:debug(self:classname(), "updateBeacon():", item, item2, item3) local model = self.model:getModel(player) - self:updateBeaconInfo(player, element, action, item, item2, item3) + self:updateBeaconInfo(player, item, item2, item3) if model.module_panel == true then - self:updateBeaconActivedModules(player, element, action, item, item2, item3) - self:updateBeaconModulesSelector(player, element, action, item, item2, item3) + self:updateBeaconActivedModules(player, item, item2, item3) + self:updateBeaconModulesSelector(player, item, item2, item3) else - self:updateBeaconSelector(player, element, action, item, item2, item3) + self:updateBeaconSelector(player, item, item2, item3) end end @@ -427,13 +421,13 @@ end -- @function [parent=#AbstractEdition] getElement -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:getObject(player, element, action, item, item2, item3) +function AbstractEdition.methods:getObject(player, event, action, item, item2, item3) -- TODO something return nil end @@ -443,16 +437,14 @@ end -- @function [parent=#AbstractEdition] updateFactoryInfo -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:updateFactoryInfo(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateFactoryInfo():",player, element, action, item, item2, item3) +function AbstractEdition.methods:updateFactoryInfo(player, item, item2, item3) + Logging:debug(self:classname(), "updateFactoryInfo():", item, item2, item3) local infoPanel = self:getFactoryInfoPanel(player) - local object = self:getObject(player, element, action, item, item2, item3) + local object = self:getObject(player, item, item2, item3) local model = self.model:getModel(player) if object ~= nil then Logging:debug(self:classname(), "updateFactoryInfo():object:",object) @@ -466,7 +458,7 @@ function AbstractEdition.methods:updateFactoryInfo(player, element, action, item local headerPanel = self:addGuiTable(infoPanel,"table-header",2) local tooltip = ({"tooltip.selector-module"}) if model.module_panel == true then tooltip = ({"tooltip.selector-factory"}) end - self:addGuiButtonSelectSprite(headerPanel, self:classname().."=change-panel=ID="..item.."="..object.name.."=", self.player:getIconType(factory), factory.name, factory.name, tooltip, self.color_button_edit) + self:addGuiButtonSelectSprite(headerPanel, self:classname().."=change-panel=ID="..item.."="..object.id.."=", self.player:getIconType(factory), factory.name, factory.name, tooltip, self.color_button_edit) if _factory == nil then self:addGuiLabel(headerPanel, "label", factory.name) else @@ -503,7 +495,7 @@ function AbstractEdition.methods:updateFactoryInfo(player, element, action, item self:addGuiLabel(inputPanel, "label-limit", ({"helmod_label.limit"}), nil, {"tooltip.factory-limit"}) self:addGuiText(inputPanel, "limit", factory.limit, "helmod_textfield", {"tooltip.factory-limit"}) - self:addGuiButton(infoPanel, self:classname().."=factory-update=ID="..item.."=", object.name, "helmod_button_default", ({"helmod_button.update"})) + self:addGuiButton(infoPanel, self:classname().."=factory-update=ID="..item.."=", object.id, "helmod_button_default", ({"helmod_button.update"})) end end @@ -513,17 +505,15 @@ end -- @function [parent=#AbstractEdition] updateFactoryModulesSelector -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:updateFactoryModulesSelector(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateFactoryModulesSelector():",player, element, action, item, item2, item3) +function AbstractEdition.methods:updateFactoryModulesSelector(player, item, item2, item3) + Logging:debug(self:classname(), "updateFactoryModulesSelector():", item, item2, item3) local selectorPanel = self:getFactoryModulesSelectorPanel(player) local model = self.model:getModel(player) - local object = self:getObject(player, element, action, item, item2, item3) + local object = self:getObject(player, item, item2, item3) local model_filter_factory_module = self.player:getSettings(player, "model_filter_factory_module", true) @@ -551,9 +541,9 @@ function AbstractEdition.methods:updateFactoryModulesSelector(player, element, a local tooltip = ({"tooltip.module-description" , localised_name, consumption, speed, productivity, pollution}) if allowed == false then tooltip = ({"item-limitation."..module.limitation_message_key}) - self:addGuiButtonSelectSprite(tableModulesPanel, self:classname().."=do-nothing=ID="..item.."="..object.name.."=", "item", module.name, module.name, tooltip, "red") + self:addGuiButtonSelectSprite(tableModulesPanel, self:classname().."=do-nothing=ID="..item.."="..object.id.."=", "item", module.name, module.name, tooltip, "red") else - self:addGuiButtonSelectSprite(tableModulesPanel, self:classname().."=factory-module-add=ID="..item.."="..object.name.."=", "item", module.name, module.name, tooltip) + self:addGuiButtonSelectSprite(tableModulesPanel, self:classname().."=factory-module-add=ID="..item.."="..object.id.."=", "item", module.name, module.name, tooltip) end end end @@ -565,16 +555,14 @@ end -- @function [parent=#AbstractEdition] updateFactoryActivedModules -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:updateFactoryActivedModules(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateFactoryActivedModules():",player, element, action, item, item2, item3) +function AbstractEdition.methods:updateFactoryActivedModules(player, item, item2, item3) + Logging:debug(self:classname(), "updateFactoryActivedModules():", item, item2, item3) local activedModulesPanel = self:getFactoryActivedModulesPanel(player) - local object = self:getObject(player, element, action, item, item2, item3) + local object = self:getObject(player, item, item2, item3) local factory = object.factory if activedModulesPanel["modules"] ~= nil and activedModulesPanel["modules"].valid then @@ -594,7 +582,7 @@ function AbstractEdition.methods:updateFactoryActivedModules(player, element, ac tooltip = ({"tooltip.module-description" , _module.localised_name, consumption, speed, productivity, pollution}) end for i = 1, count, 1 do - self:addGuiButtonSelectSprite(currentTableModulesPanel, self:classname().."=factory-module-remove=ID="..item.."="..object.name.."="..module.."="..i, "item", module, module, tooltip) + self:addGuiButtonSelectSprite(currentTableModulesPanel, self:classname().."=factory-module-remove=ID="..item.."="..object.id.."="..module.."="..i, "item", module, module, tooltip) end end end @@ -605,14 +593,12 @@ end -- @function [parent=#AbstractEdition] updateFactorySelector -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:updateFactorySelector(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateFactorySelector():",player, element, action, item, item2, item3) +function AbstractEdition.methods:updateFactorySelector(player, item, item2, item3) + Logging:debug(self:classname(), "updateFactorySelector():", item, item2, item3) local selectorPanel = self:getFactorySelectorPanel(player) if selectorPanel["scroll-factory"] ~= nil and selectorPanel["scroll-factory"].valid then @@ -622,7 +608,7 @@ function AbstractEdition.methods:updateFactorySelector(player, element, action, local model = self.model:getModel(player) - local object = self:getObject(player, element, action, item, item2, item3) + local object = self:getObject(player, item, item2, item3) -- ajouter de la table des groupes de recipe local groupsPanel = self:addGuiTable(scrollPanel, "factory-groups", 2) @@ -652,7 +638,7 @@ function AbstractEdition.methods:updateFactorySelector(player, element, action, -- set le groupe if model.factoryGroupSelected == nil then model.factoryGroupSelected = group end -- ajoute les icons de groupe - local action = self:addGuiButton(groupsPanel, self:classname().."=factory-group=ID="..item.."="..object.name.."=", group, "helmod_button_default", group) + local action = self:addGuiButton(groupsPanel, self:classname().."=factory-group=ID="..item.."="..object.id.."=", group, "helmod_button_default", group) end end @@ -660,7 +646,7 @@ function AbstractEdition.methods:updateFactorySelector(player, element, action, for key, factory in pairs(factories) do if category ~= nil or (factory.subgroup ~= nil and factory.subgroup.name == model.factoryGroupSelected) then local localised_name = self.player:getLocalisedName(player, factory) - self:addGuiButtonSelectSprite(tablePanel, self:classname().."=factory-select=ID="..item.."="..object.name.."=", "item", factory.name, factory.name, localised_name) + self:addGuiButtonSelectSprite(tablePanel, self:classname().."=factory-select=ID="..item.."="..object.id.."=", "item", factory.name, factory.name, localised_name) end end end @@ -671,16 +657,14 @@ end -- @function [parent=#AbstractEdition] updateBeaconInfo -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:updateBeaconInfo(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateBeaconInfo():",player, element, action, item, item2, item3) +function AbstractEdition.methods:updateBeaconInfo(player, item, item2, item3) + Logging:debug(self:classname(), "updateBeaconInfo():", item, item2, item3) local infoPanel = self:getBeaconInfoPanel(player) - local object = self:getObject(player, element, action, item, item2, item3) + local object = self:getObject(player, item, item2, item3) local model = self.model:getModel(player) if object ~= nil then @@ -694,7 +678,7 @@ function AbstractEdition.methods:updateBeaconInfo(player, element, action, item, local headerPanel = self:addGuiTable(infoPanel,"table-header",2) local tooltip = ({"tooltip.selector-module"}) if model.module_panel == true then tooltip = ({"tooltip.selector-factory"}) end - self:addGuiButtonSelectSprite(headerPanel, self:classname().."=change-panel=ID="..item.."="..object.name.."=", self.player:getIconType(beacon), beacon.name, beacon.name, tooltip, self.color_button_edit) + self:addGuiButtonSelectSprite(headerPanel, self:classname().."=change-panel=ID="..item.."="..object.id.."=", self.player:getIconType(beacon), beacon.name, beacon.name, tooltip, self.color_button_edit) if _beacon == nil then self:addGuiLabel(headerPanel, "label", beacon.name) else @@ -718,7 +702,7 @@ function AbstractEdition.methods:updateBeaconInfo(player, element, action, item, self:addGuiLabel(inputPanel, "label-factory", ({"helmod_label.factory-per-beacon"}), nil, {"tooltip.factory-per-beacon"}) self:addGuiText(inputPanel, "factory", beacon.factory, "helmod_textfield", {"tooltip.factory-per-beacon"}) - self:addGuiButton(infoPanel, self:classname().."=beacon-update=ID="..item.."=", object.name, "helmod_button_default", ({"helmod_button.update"})) + self:addGuiButton(infoPanel, self:classname().."=beacon-update=ID="..item.."=", object.id, "helmod_button_default", ({"helmod_button.update"})) end end @@ -728,17 +712,15 @@ end -- @function [parent=#AbstractEdition] updateBeaconActivedModules -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:updateBeaconActivedModules(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateBeaconActivedModules():",player, element, action, item, item2, item3) +function AbstractEdition.methods:updateBeaconActivedModules(player, item, item2, item3) + Logging:debug(self:classname(), "updateBeaconActivedModules():", item, item2, item3) local activedModulesPanel = self:getBeaconActivedModulesPanel(player) - local object = self:getObject(player, element, action, item, item2, item3) + local object = self:getObject(player, item, item2, item3) local beacon = object.beacon if activedModulesPanel["modules"] ~= nil and activedModulesPanel["modules"].valid then @@ -759,7 +741,7 @@ function AbstractEdition.methods:updateBeaconActivedModules(player, element, act end for i = 1, count, 1 do - self:addGuiButtonSelectSprite(currentTableModulesPanel, self:classname().."=beacon-module-remove=ID="..item.."="..object.name.."="..module.."="..i, "item", module, module, tooltip) + self:addGuiButtonSelectSprite(currentTableModulesPanel, self:classname().."=beacon-module-remove=ID="..item.."="..object.id.."="..module.."="..i, "item", module, module, tooltip) end end end @@ -770,17 +752,15 @@ end -- @function [parent=#AbstractEdition] updateBeaconModulesSelector -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:updateBeaconModulesSelector(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateBeaconModulesSelector():",player, element, action, item, item2, item3) +function AbstractEdition.methods:updateBeaconModulesSelector(player, item, item2, item3) + Logging:debug(self:classname(), "updateBeaconModulesSelector():", item, item2, item3) local selectorPanel = self:getBeaconModulesSelectorPanel(player) local model = self.model:getModel(player) - local object = self:getObject(player, element, action, item, item2, item3) + local object = self:getObject(player, item, item2, item3) local model_filter_beacon_module = self.player:getSettings(player, "model_filter_beacon_module", true) if selectorPanel["modules"] ~= nil and selectorPanel["modules"].valid and model.moduleListRefresh == true then @@ -802,9 +782,9 @@ function AbstractEdition.methods:updateBeaconModulesSelector(player, element, ac local tooltip = ({"tooltip.module-description" , localised_name, consumption, speed, productivity, pollution}) if allowed == false then tooltip = ({"item-limitation.item-not-allowed-in-this-container-item"}) - self:addGuiButtonSelectSprite(tableModulesPanel, self:classname().."=do-nothing=ID="..item.."="..object.name.."=", "item", module.name, module.name, tooltip, "red") + self:addGuiButtonSelectSprite(tableModulesPanel, self:classname().."=do-nothing=ID="..item.."="..object.id.."=", "item", module.name, module.name, tooltip, "red") else - self:addGuiButtonSelectSprite(tableModulesPanel, self:classname().."=beacon-module-add=ID="..item.."="..object.name.."=", "item", module.name, module.name, tooltip) + self:addGuiButtonSelectSprite(tableModulesPanel, self:classname().."=beacon-module-add=ID="..item.."="..object.id.."=", "item", module.name, module.name, tooltip) end end end @@ -816,14 +796,12 @@ end -- @function [parent=#AbstractEdition] updateBeaconSelector -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:updateBeaconSelector(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateBeaconSelector():",player, element, action, item, item2, item3) +function AbstractEdition.methods:updateBeaconSelector(player, item, item2, item3) + Logging:debug(self:classname(), "updateBeaconSelector():", item, item2, item3) local selectorPanel = self:getBeaconSelectorPanel(player) local model = self.model:getModel(player) @@ -832,7 +810,7 @@ function AbstractEdition.methods:updateBeaconSelector(player, element, action, i end local scrollPanel = self:addGuiScrollPane(selectorPanel, "scroll-beacon", "helmod_scroll_recipe_factories", "auto", "auto") - local object = self:getObject(player, element, action, item, item2, item3) + local object = self:getObject(player, item, item2, item3) local groupsPanel = self:addGuiTable(scrollPanel, "beacon-groups", 2) @@ -860,7 +838,7 @@ function AbstractEdition.methods:updateBeaconSelector(player, element, action, i -- set le groupe if model.beaconGroupSelected == nil then model.beaconGroupSelected = group end -- ajoute les icons de groupe - local action = self:addGuiButton(groupsPanel, self:classname().."=beacon-group=ID="..item.."="..object.name.."=", group, "helmod_button_default", group) + local action = self:addGuiButton(groupsPanel, self:classname().."=beacon-group=ID="..item.."="..object.id.."=", group, "helmod_button_default", group) end end @@ -869,7 +847,7 @@ function AbstractEdition.methods:updateBeaconSelector(player, element, action, i for key, beacon in pairs(factories) do if category ~= nil or (beacon.subgroup ~= nil and beacon.subgroup.name == model.beaconGroupSelected) then local localised_name = self.player:getLocalisedName(player, beacon) - self:addGuiButtonSelectSprite(tablePanel, self:classname().."=beacon-select=ID="..item.."="..object.name.."=", "item", beacon.name, beacon.name, localised_name) + self:addGuiButtonSelectSprite(tablePanel, self:classname().."=beacon-select=ID="..item.."="..object.id.."=", "item", beacon.name, beacon.name, localised_name) end end end @@ -880,30 +858,30 @@ end -- @function [parent=#AbstractEdition] on_event -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractEdition.methods:on_event(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "on_event():",player, element, action, item, item2, item3) +function AbstractEdition.methods:on_event(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "on_event():", action, item, item2, item3) local model = self.model:getModel(player) if action == "change-panel" then model.module_panel = not(model.module_panel) - self:send_event(player, element, "CLOSE", item, item2, item3) - self:send_event(player, element, "OPEN", item, item2, item3) + self:send_event(player, event, "CLOSE", item, item2, item3) + self:send_event(player, event, "OPEN", item, item2, item3) end if action == "factory-group" then model.factoryGroupSelected = item3 - self:updateFactorySelector(player, element, action, item, item2, item3) + self:updateFactorySelector(player, item, item2, item3) end if action == "beacon-group" then model.beaconGroupSelected = item3 - self:updateBeaconSelector(player, element, action, item, item2, item3) + self:updateBeaconSelector(player, item, item2, item3) end if self.player:isAdmin(player) or model.owner == player.name or (model.share ~= nil and bit32.band(model.share, 2) > 0) then @@ -917,7 +895,7 @@ function AbstractEdition.methods:on_event(player, element, action, item, item2, self.model:updateObject(player, item, item2, options) self.model:update(player) - self:updateObjectInfo(player, element, action, item, item2, item3) + self:updateObjectInfo(player, item, item2, item3) self.parent:refreshDisplayData(player, nil, item, item2) end @@ -926,7 +904,7 @@ function AbstractEdition.methods:on_event(player, element, action, item, item2, -- item=recipe item2=factory self.model:setFactory(player, item, item2, item3) self.model:update(player) - self:updateFactoryInfo(player, element, action, item, item2, item3) + self:updateFactoryInfo(player, item, item2, item3) self.parent:refreshDisplayData(player, nil, item, item2) end @@ -940,32 +918,32 @@ function AbstractEdition.methods:on_event(player, element, action, item, item2, self.model:updateFactory(player, item, item2, options) self.model:update(player) - self:updateFactoryInfo(player, element, action, item, item2, item3) + self:updateFactoryInfo(player, item, item2, item3) self.parent:refreshDisplayData(player, nil, item, item2) end if action == "factory-module-add" then self.model:addFactoryModule(player, item, item2, item3) self.model:update(player) - self:updateFactoryInfo(player, element, action, item, item2, item3) - self:updateFactoryActivedModules(player, element, action, item, item2, item3) - self:updateBeaconInfo(player, element, action, item, item2, item3) + self:updateFactoryInfo(player, item, item2, item3) + self:updateFactoryActivedModules(player, item, item2, item3) + self:updateBeaconInfo(player, item, item2, item3) self.parent:refreshDisplayData(player, nil, item, item2) end if action == "factory-module-remove" then self.model:removeFactoryModule(player, item, item2, item3) self.model:update(player) - self:updateFactoryInfo(player, element, action, item, item2, item3) - self:updateFactoryActivedModules(player, element, action, item, item2, item3) - self:updateBeaconInfo(player, element, action, item, item2, item3) + self:updateFactoryInfo(player, item, item2, item3) + self:updateFactoryActivedModules(player, item, item2, item3) + self:updateBeaconInfo(player, item, item2, item3) self.parent:refreshDisplayData(player, nil, item, item2) end if action == "beacon-select" then self.model:setBeacon(player, item, item2, item3) self.model:update(player) - self:updateBeaconInfo(player, element, action, item, item2, item3) + self:updateBeaconInfo(player, item, item2, item3) self.parent:refreshDisplayData(player, nil, item, item2) end @@ -983,26 +961,26 @@ function AbstractEdition.methods:on_event(player, element, action, item, item2, self.model:updateBeacon(player, item, item2, options) self.model:update(player) - self:updateBeaconInfo(player, element, action, item, item2, item3) - self:updateFactoryInfo(player, element, action, item, item2, item3) + self:updateBeaconInfo(player, item, item2, item3) + self:updateFactoryInfo(player, item, item2, item3) self.parent:refreshDisplayData(player, nil, item, item2) end if action == "beacon-module-add" then self.model:addBeaconModule(player, item, item2, item3) self.model:update(player) - self:updateBeaconInfo(player, element, action, item, item2, item3) - self:updateBeaconActivedModules(player, element, action, item, item2, item3) - self:updateFactoryInfo(player, element, action, item, item2, item3) + self:updateBeaconInfo(player, item, item2, item3) + self:updateBeaconActivedModules(player, item, item2, item3) + self:updateFactoryInfo(player, item, item2, item3) self.parent:refreshDisplayData(player, nil, item, item2) end if action == "beacon-module-remove" then self.model:removeBeaconModule(player, item, item2, item3) self.model:update(player) - self:updateBeaconInfo(player, element, action, item, item2, item3) - self:updateBeaconActivedModules(player, element, action, item, item2, item3) - self:updateFactoryInfo(player, element, action, item, item2, item3) + self:updateBeaconInfo(player, item, item2, item3) + self:updateBeaconActivedModules(player, item, item2, item3) + self:updateFactoryInfo(player, item, item2, item3) self.parent:refreshDisplayData(player, nil, item, item2) end end diff --git a/edition/EnergyEdition.lua b/edition/EnergyEdition.lua index a773e334..11e33b4b 100644 --- a/edition/EnergyEdition.lua +++ b/edition/EnergyEdition.lua @@ -182,13 +182,11 @@ end -- @function [parent=#EnergyEdition] getObject -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function EnergyEdition.methods:getObject(player, element, action, item, item2, item3) +function EnergyEdition.methods:getObject(player, item, item2, item3) local model = self.model:getModel(player) if model.powers ~= nil and model.powers[item] ~= nil then -- return power @@ -203,7 +201,7 @@ end -- @function [parent=#EnergyEdition] on_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name @@ -211,8 +209,8 @@ end -- -- @return #boolean if true the next call close dialog -- -function EnergyEdition.methods:on_open(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "on_open():",player, element, action, item, item2, item3) +function EnergyEdition.methods:on_open(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "on_open():", action, item, item2, item3) local model = self.model:getModel(player) local close = true if model.guiPowerLast == nil or model.guiPowerLast ~= item then @@ -231,13 +229,13 @@ end -- @function [parent=#EnergyEdition] on_close -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function EnergyEdition.methods:on_close(player, element, action, item, item2, item3) +function EnergyEdition.methods:on_close(player, event, action, item, item2, item3) local model = self.model:getModel(player) end @@ -247,14 +245,14 @@ end -- @function [parent=#EnergyEdition] after_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function EnergyEdition.methods:after_open(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "after_open():",player, element, action, item, item2, item3) +function EnergyEdition.methods:after_open(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "after_open():", action, item, item2, item3) self.parent:send_event(player, "HMProductEdition", "CLOSE") self.parent:send_event(player, "HMRecipeSelector", "CLOSE") self.parent:send_event(player, "HMSettings", "CLOSE") @@ -270,24 +268,24 @@ end -- @function [parent=#EnergyEdition] on_event -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function EnergyEdition.methods:on_event(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "on_event():",player, element, action, item, item2, item3) +function EnergyEdition.methods:on_event(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "on_event():", action, item, item2, item3) local model = self.model:getModel(player) if action == "primary-group" then model.primaryGroupSelected = item2 - self:updatePrimarySelector(player, element, action, item, item2, item3) + self:updatePrimarySelector(player, item, item2, item3) end if action == "secondary-group" then model.secondaryGroupSelected = item2 - self:updateSecondarySelector(player, element, action, item, item2, item3) + self:updateSecondarySelector(player, item, item2, item3) end if self.player:isAdmin(player) or model.owner == player.name or (model.share ~= nil and bit32.band(model.share, 2) > 0) then @@ -300,12 +298,12 @@ function EnergyEdition.methods:on_event(player, element, action, item, item2, it end self.model:updatePower(player, item, options) - self:updatePowerInfo(player, element, action, item, item2, item3) + self:updatePowerInfo(player, item, item2, item3) self.parent:refreshDisplayData(player, nil, item, item2) end if action == "primary-select" then - local object = self:getObject(player, element, action, item, item2, item3) + local object = self:getObject(player, item, item2, item3) if object ~= nil then local power = self.model:addPrimaryPower(player, item, item2) else @@ -314,12 +312,12 @@ function EnergyEdition.methods:on_event(player, element, action, item, item2, it end self.model:computePower(player, item) self.parent:refreshDisplayData(player) - self:send_event(player, element, "CLOSE", item, item2, item3) - self:send_event(player, element, "OPEN", item, item2, item3) + self:send_event(player, event, "CLOSE", item, item2, item3) + self:send_event(player, event, "OPEN", item, item2, item3) end if action == "secondary-select" then - local object = self:getObject(player, element, action, item, item2, item3) + local object = self:getObject(player, item, item2, item3) if object ~= nil then local power = self.model:addSecondaryPower(player, item, item2) else @@ -328,8 +326,8 @@ function EnergyEdition.methods:on_event(player, element, action, item, item2, it end self.model:computePower(player, item) self.parent:refreshDisplayData(player) - self:send_event(player, element, "CLOSE", item, item2, item3) - self:send_event(player, element, "OPEN", item, item2, item3) + self:send_event(player, event, "CLOSE", item, item2, item3) + self:send_event(player, event, "OPEN", item, item2, item3) end end end @@ -340,16 +338,16 @@ end -- @function [parent=#EnergyEdition] on_update -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function EnergyEdition.methods:on_update(player, element, action, item, item2, item3) - self:updatePowerInfo(player, element, action, item, item2, item3) - self:updatePrimary(player, element, action, item, item2, item3) - self:updateSecondary(player, element, action, item, item2, item3) +function EnergyEdition.methods:on_update(player, event, action, item, item2, item3) + self:updatePowerInfo(player, item, item2, item3) + self:updatePrimary(player, item, item2, item3) + self:updateSecondary(player, item, item2, item3) end ------------------------------------------------------------------------------- @@ -358,21 +356,19 @@ end -- @function [parent=#EnergyEdition] updatePowerInfo -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function EnergyEdition.methods:updatePowerInfo(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updatePowerInfo():",player, element, action, item, item2, item3) +function EnergyEdition.methods:updatePowerInfo(player, item, item2, item3) + Logging:debug(self:classname(), "updatePowerInfo():", item, item2, item3) local infoPanel = self:getPowerPanel(player) local model = self.model:getModel(player) local default = self.model:getDefault(player) local model = self.model:getModel(player) if model.powers ~= nil and model.powers[item] ~= nil then - local power = self:getObject(player, element, action, item, item2, item3) + local power = self:getObject(player, item, item2, item3) if power ~= nil then Logging:debug(self:classname(), "updatePowerInfo():power=",power) for k,guiName in pairs(infoPanel.children_names) do @@ -394,18 +390,16 @@ end -- @function [parent=#EnergyEdition] updatePrimary -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function EnergyEdition.methods:updatePrimary(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updatePrimary():",player, element, action, item, item2, item3) +function EnergyEdition.methods:updatePrimary(player, item, item2, item3) + Logging:debug(self:classname(), "updatePrimary():", item, item2, item3) local model = self.model:getModel(player) - self:updatePrimaryInfo(player, element, action, item, item2, item3) - self:updatePrimarySelector(player, element, action, item, item2, item3) + self:updatePrimaryInfo(player, item, item2, item3) + self:updatePrimarySelector(player, item, item2, item3) end ------------------------------------------------------------------------------- @@ -414,16 +408,14 @@ end -- @function [parent=#EnergyEdition] updatePrimaryInfo -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function EnergyEdition.methods:updatePrimaryInfo(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updatePrimaryInfo():",player, element, action, item, item2, item3) +function EnergyEdition.methods:updatePrimaryInfo(player, item, item2, item3) + Logging:debug(self:classname(), "updatePrimaryInfo():", item, item2, item3) local infoPanel = self:getPrimaryInfoPanel(player) - local object = self:getObject(player, element, action, item, item2, item3) + local object = self:getObject(player, item, item2, item3) local model = self.model:getModel(player) for k,guiName in pairs(infoPanel.children_names) do @@ -446,7 +438,7 @@ function EnergyEdition.methods:updatePrimaryInfo(player, element, action, item, self:addGuiLabel(headerPanel, "label", _generator.localised_name) end - local primary_classification = self.player:getItemProperty(primary.name, "classification") + local primary_classification = self.player:getEntityProperty(primary.name, "type") local inputPanel = self:addGuiTable(infoPanel,"table-input",2) @@ -473,14 +465,12 @@ end -- @function [parent=#EnergyEdition] updatePrimarySelector -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function EnergyEdition.methods:updatePrimarySelector(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updatePrimarySelector():",player, element, action, item, item2, item3) +function EnergyEdition.methods:updatePrimarySelector(player, item, item2, item3) + Logging:debug(self:classname(), "updatePrimarySelector():", item, item2, item3) local selectorPanel = self:getPrimarySelectorPanel(player) local model = self.model:getModel(player) @@ -489,7 +479,7 @@ function EnergyEdition.methods:updatePrimarySelector(player, element, action, it end local scrollPanel = self:addGuiScrollPane(selectorPanel, "scroll-primary", "helmod_scroll_recipe_factories", "auto", "auto") - local object = self:getObject(player, element, action, item, item2, item3) + local object = self:getObject(player, item, item2, item3) local groupsPanel = self:addGuiTable(scrollPanel, "primary-groups", 1) @@ -537,18 +527,16 @@ end -- @function [parent=#EnergyEdition] updateSecondary -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function EnergyEdition.methods:updateSecondary(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateSecondary():",player, element, action, item, item2, item3) +function EnergyEdition.methods:updateSecondary(player, item, item2, item3) + Logging:debug(self:classname(), "updateSecondary():", item, item2, item3) local model = self.model:getModel(player) - self:updateSecondaryInfo(player, element, action, item, item2, item3) - self:updateSecondarySelector(player, element, action, item, item2, item3) + self:updateSecondaryInfo(player, item, item2, item3) + self:updateSecondarySelector(player, item, item2, item3) end ------------------------------------------------------------------------------- @@ -557,16 +545,14 @@ end -- @function [parent=#EnergyEdition] updateSecondaryInfo -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function EnergyEdition.methods:updateSecondaryInfo(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateSecondaryInfo():",player, element, action, item, item2, item3) +function EnergyEdition.methods:updateSecondaryInfo(player, item, item2, item3) + Logging:debug(self:classname(), "updateSecondaryInfo():", item, item2, item3) local infoPanel = self:getSecondaryInfoPanel(player) - local object = self:getObject(player, element, action, item, item2, item3) + local object = self:getObject(player, item, item2, item3) local model = self.model:getModel(player) for k,guiName in pairs(infoPanel.children_names) do @@ -591,7 +577,7 @@ function EnergyEdition.methods:updateSecondaryInfo(player, element, action, item local inputPanel = self:addGuiTable(infoPanel,"table-input",2) - local secondary_classification = self.player:getItemProperty(secondary.name, "classification") + local secondary_classification = self.player:getEntityProperty(secondary.name, "type") if secondary_classification == "boiler" then self:addGuiLabel(inputPanel, "label-energy-nominal", ({"helmod_label.energy-nominal"})) @@ -622,14 +608,12 @@ end -- @function [parent=#EnergyEdition] updateSecondarySelector -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function EnergyEdition.methods:updateSecondarySelector(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateSecondarySelector():",player, element, action, item, item2, item3) +function EnergyEdition.methods:updateSecondarySelector(player, item, item2, item3) + Logging:debug(self:classname(), "updateSecondarySelector():", item, item2, item3) local selectorPanel = self:getSecondarySelectorPanel(player) local model = self.model:getModel(player) @@ -638,7 +622,7 @@ function EnergyEdition.methods:updateSecondarySelector(player, element, action, end local scrollPanel = self:addGuiScrollPane(selectorPanel, "scroll-secondary", "helmod_scroll_recipe_factories", "auto", "auto") - local object = self:getObject(player, element, action, item, item2, item3) + local object = self:getObject(player, item, item2, item3) local groupsPanel = self:addGuiTable(scrollPanel, "secondary-groups", 1) diff --git a/edition/ProductEdition.lua b/edition/ProductEdition.lua index 15768067..fdba4be8 100644 --- a/edition/ProductEdition.lua +++ b/edition/ProductEdition.lua @@ -39,7 +39,7 @@ end -- @function [parent=#ProductEdition] on_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name @@ -47,7 +47,7 @@ end -- -- @return #boolean if true the next call close dialog -- -function ProductEdition.methods:on_open(player, element, action, item, item2, item3) +function ProductEdition.methods:on_open(player, event, action, item, item2, item3) local model = self.model:getModel(player) local close = true if model.guiProductLast == nil or model.guiProductLast ~= item then @@ -63,13 +63,13 @@ end -- @function [parent=#ProductEdition] on_close -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function ProductEdition.methods:on_close(player, element, action, item, item2, item3) +function ProductEdition.methods:on_close(player, event, action, item, item2, item3) local model = self.model:getModel(player) model.guiProductLast = nil end @@ -110,13 +110,13 @@ end -- @function [parent=#ProductEdition] after_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function ProductEdition.methods:after_open(player, element, action, item, item2, item3) +function ProductEdition.methods:after_open(player, event, action, item, item2, item3) self.parent:send_event(player, "HMRecipeEdition", "CLOSE") self.parent:send_event(player, "HMRecipeSelector", "CLOSE") self.parent:send_event(player, "HMSettings", "CLOSE") @@ -129,14 +129,14 @@ end -- @function [parent=#ProductEdition] on_update -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function ProductEdition.methods:on_update(player, element, action, item, item2, item3) - self:updateInfo(player, element, action, item, item2, item3) +function ProductEdition.methods:on_update(player, event, action, item, item2, item3) + self:updateInfo(player, item, item2, item3) end ------------------------------------------------------------------------------- @@ -145,14 +145,12 @@ end -- @function [parent=#ProductEdition] updateInfo -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function ProductEdition.methods:updateInfo(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateInfo():",player, element, action, item, item2, item3) +function ProductEdition.methods:updateInfo(player, item, item2, item3) + Logging:debug(self:classname(), "updateInfo():", item, item2, item3) local infoPanel = self:getInfoPanel(player) local model = self.model:getModel(player) @@ -188,14 +186,14 @@ end -- @function [parent=#ProductEdition] on_event -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function ProductEdition.methods:on_event(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "on_event():",player, element, action, item, item2, item3) +function ProductEdition.methods:on_event(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "on_event():", action, item, item2, item3) local model = self.model:getModel(player) if self.player:isAdmin(player) or model.owner == player.name or (model.share ~= nil and bit32.band(model.share, 2) > 0) then if action == "product-update" then diff --git a/edition/RecipeEdition.lua b/edition/RecipeEdition.lua index 4954e2fe..74bf9f25 100644 --- a/edition/RecipeEdition.lua +++ b/edition/RecipeEdition.lua @@ -17,9 +17,9 @@ RecipeEdition = setclass("HMRecipeEdition", AbstractEdition) -- @param #Controller parent parent controller -- function RecipeEdition.methods:on_init(parent) - self.panelCaption = ({"helmod_recipe-edition-panel.title"}) - self.player = self.parent.player - self.model = self.parent.model + self.panelCaption = ({"helmod_recipe-edition-panel.title"}) + self.player = self.parent.player + self.model = self.parent.model end ------------------------------------------------------------------------------- @@ -32,7 +32,7 @@ end -- @return #LuaGuiElement -- function RecipeEdition.methods:getParentPanel(player) - return self.parent:getDialogPanel(player) + return self.parent:getDialogPanel(player) end ------------------------------------------------------------------------------- @@ -41,7 +41,7 @@ end -- @function [parent=#RecipeEdition] on_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name @@ -49,18 +49,18 @@ end -- -- @return #boolean if true the next call close dialog -- -function RecipeEdition.methods:on_open(player, element, action, item, item2, item3) - local model = self.model:getModel(player) - local close = true - model.moduleListRefresh = false - if model.guiRecipeLast == nil or model.guiRecipeLast ~= item..item2 then - close = false - model.factoryGroupSelected = nil - model.beaconGroupSelected = nil - model.moduleListRefresh = true - end - model.guiRecipeLast = item..item2 - return close +function RecipeEdition.methods:on_open(player, event, action, item, item2, item3) + local model = self.model:getModel(player) + local close = true + model.moduleListRefresh = false + if model.guiRecipeLast == nil or model.guiRecipeLast ~= item..item2 then + close = false + model.factoryGroupSelected = nil + model.beaconGroupSelected = nil + model.moduleListRefresh = true + end + model.guiRecipeLast = item..item2 + return close end ------------------------------------------------------------------------------- @@ -69,16 +69,16 @@ end -- @function [parent=#RecipeEdition] on_close -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function RecipeEdition.methods:on_close(player, element, action, item, item2, item3) - local model = self.model:getModel(player) - model.guiRecipeLast = nil - model.moduleListRefresh = false +function RecipeEdition.methods:on_close(player, event, action, item, item2, item3) + local model = self.model:getModel(player) + model.guiRecipeLast = nil + model.moduleListRefresh = false end ------------------------------------------------------------------------------- @@ -89,11 +89,11 @@ end -- @param #LuaPlayer player -- function RecipeEdition.methods:getRecipePanel(player) - local panel = self:getPanel(player) - if panel["recipe"] ~= nil and panel["recipe"].valid then - return panel["recipe"] - end - return self:addGuiFlowH(panel, "recipe", "helmod_flow_resize_row_width") + local panel = self:getPanel(player) + if panel["recipe"] ~= nil and panel["recipe"].valid then + return panel["recipe"] + end + return self:addGuiFlowH(panel, "recipe", "helmod_flow_resize_row_width") end ------------------------------------------------------------------------------- @@ -104,11 +104,11 @@ end -- @param #LuaPlayer player -- function RecipeEdition.methods:getObjectInfoPanel(player) - local panel = self:getRecipePanel(player) - if panel["info"] ~= nil and panel["info"].valid then - return panel["info"] - end - return self:addGuiFrameH(panel, "info", "helmod_frame_recipe_info", ({"helmod_common.recipe"})) + local panel = self:getRecipePanel(player) + if panel["info"] ~= nil and panel["info"].valid then + return panel["info"] + end + return self:addGuiFrameH(panel, "info", "helmod_frame_recipe_info", ({"helmod_common.recipe"})) end ------------------------------------------------------------------------------- @@ -119,11 +119,11 @@ end -- @param #LuaPlayer player -- function RecipeEdition.methods:getOtherInfoPanel(player) - local panel = self:getRecipePanel(player) - if panel["other-info"] ~= nil and panel["other-info"].valid then - return panel["other-info"] - end - return self:addGuiFlowV(panel, "other-info", "helmod_flow_resize_row_width") + local panel = self:getRecipePanel(player) + if panel["other-info"] ~= nil and panel["other-info"].valid then + return panel["other-info"] + end + return self:addGuiFlowV(panel, "other-info", "helmod_flow_resize_row_width") end ------------------------------------------------------------------------------- @@ -134,11 +134,11 @@ end -- @param #LuaPlayer player -- function RecipeEdition.methods:getRecipeIngredientsPanel(player) - local panel = self:getOtherInfoPanel(player) - if panel["ingredients"] ~= nil and panel["ingredients"].valid then - return panel["ingredients"] - end - return self:addGuiFrameV(panel, "ingredients", "helmod_frame_recipe_ingredients", ({"helmod_common.ingredients"})) + local panel = self:getOtherInfoPanel(player) + if panel["ingredients"] ~= nil and panel["ingredients"].valid then + return panel["ingredients"] + end + return self:addGuiFrameV(panel, "ingredients", "helmod_frame_recipe_ingredients", ({"helmod_common.ingredients"})) end ------------------------------------------------------------------------------- @@ -149,11 +149,11 @@ end -- @param #LuaPlayer player -- function RecipeEdition.methods:getRecipeProductsPanel(player) - local panel = self:getOtherInfoPanel(player) - if panel["products"] ~= nil and panel["products"].valid then - return panel["products"] - end - return self:addGuiFrameV(panel, "products", "helmod_frame_recipe_products", ({"helmod_common.products"})) + local panel = self:getOtherInfoPanel(player) + if panel["products"] ~= nil and panel["products"].valid then + return panel["products"] + end + return self:addGuiFrameV(panel, "products", "helmod_frame_recipe_products", ({"helmod_common.products"})) end ------------------------------------------------------------------------------- @@ -162,19 +162,18 @@ end -- @function [parent=#RecipeEdition] getObject -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function RecipeEdition.methods:getObject(player, element, action, item, item2, item3) - local model = self.model:getModel(player) - if model.blocks[item] ~= nil and model.blocks[item].recipes[item2] ~= nil then - -- return recipe - return model.blocks[item].recipes[item2] - end - return nil +function RecipeEdition.methods:getObject(player, item, item2, item3) + Logging:debug(self:classname(), "getObject():", item, item2, item3) + local model = self.model:getModel(player) + if model.blocks[item] ~= nil and model.blocks[item].recipes[item2] ~= nil then + -- return recipe + return model.blocks[item].recipes[item2] + end + return nil end ------------------------------------------------------------------------------- @@ -185,10 +184,10 @@ end -- @param #LuaPlayer player -- function RecipeEdition.methods:buildHeaderPanel(player) - Logging:debug(self:classname(), "buildHeaderPanel():",player) - self:getObjectInfoPanel(player) - self:getRecipeIngredientsPanel(player) - self:getRecipeProductsPanel(player) + Logging:debug(self:classname(), "buildHeaderPanel():",player) + self:getObjectInfoPanel(player) + self:getRecipeIngredientsPanel(player) + self:getRecipeProductsPanel(player) end ------------------------------------------------------------------------------- @@ -197,17 +196,15 @@ end -- @function [parent=#RecipeEdition] updateHeader -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function RecipeEdition.methods:updateHeader(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateHeader():",player, element, action, item, item2, item3) - self:updateObjectInfo(player, element, action, item, item2, item3) - self:updateRecipeIngredients(player, element, action, item, item2, item3) - self:updateRecipeProducts(player, element, action, item, item2, item3) +function RecipeEdition.methods:updateHeader(player, item, item2, item3) + Logging:debug(self:classname(), "updateHeader():", item, item2, item3) + self:updateObjectInfo(player, item, item2, item3) + self:updateRecipeIngredients(player, item, item2, item3) + self:updateRecipeProducts(player, item, item2, item3) end ------------------------------------------------------------------------------- @@ -216,46 +213,46 @@ end -- @function [parent=#RecipeEdition] updateObjectInfo -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function RecipeEdition.methods:updateObjectInfo(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateObjectInfo():",player, element, action, item, item2, item3) - local infoPanel = self:getObjectInfoPanel(player) - local model = self.model:getModel(player) - local default = self.model:getDefault(player) - local _recipe = self.player:getRecipe(player, item2) +function RecipeEdition.methods:updateObjectInfo(player, item, item2, item3) + Logging:debug(self:classname(), "updateObjectInfo():", item, item2, item3) + local infoPanel = self:getObjectInfoPanel(player) + local model = self.model:getModel(player) + local default = self.model:getDefault(player) + - local model = self.model:getModel(player) - if model.blocks[item] ~= nil then - local recipe = self:getObject(player, element, action, item, item2, item3) - if recipe ~= nil then - Logging:debug(self:classname(), "updateObjectInfo():recipe=",recipe) - for k,guiName in pairs(infoPanel.children_names) do - infoPanel[guiName].destroy() - end + local model = self.model:getModel(player) + if model.blocks[item] ~= nil then + local recipe = self:getObject(player, item, item2, item3) + if recipe ~= nil then + Logging:debug(self:classname(), "updateObjectInfo():recipe=",recipe) + for k,guiName in pairs(infoPanel.children_names) do + infoPanel[guiName].destroy() + end - local tablePanel = self:addGuiTable(infoPanel,"table-input",2) - self:addGuiButtonSprite(tablePanel, "recipe", self.player:getRecipeIconType(player, recipe), recipe.name) - if _recipe == nil then - self:addGuiLabel(tablePanel, "label", recipe.name) - else - self:addGuiLabel(tablePanel, "label", _recipe.localised_name) - end + local tablePanel = self:addGuiTable(infoPanel,"table-input",2) + self:addGuiButtonSprite(tablePanel, "recipe", self.player:getRecipeIconType(player, recipe), recipe.name) + local lua_recipe = self.player:getRecipe(player, recipe.name) + if lua_recipe == nil then + self:addGuiLabel(tablePanel, "label", recipe.name) + else + self:addGuiLabel(tablePanel, "label", lua_recipe.localised_name) + end - self:addGuiLabel(tablePanel, "label-energy", ({"helmod_common.energy"})) - self:addGuiLabel(tablePanel, "energy", recipe.energy) - self:addGuiLabel(tablePanel, "label-production", ({"helmod_common.production"})) - self:addGuiText(tablePanel, "production", recipe.production, "helmod_textfield") + self:addGuiLabel(tablePanel, "label-energy", ({"helmod_common.energy"})) + self:addGuiLabel(tablePanel, "energy", recipe.energy) - self:addGuiButton(tablePanel, self:classname().."=object-update=ID="..item.."=", recipe.name, "helmod_button_default", ({"helmod_button.update"})) -- - end - end + self:addGuiLabel(tablePanel, "label-production", ({"helmod_common.production"})) + self:addGuiText(tablePanel, "production", recipe.production, "helmod_textfield") + + self:addGuiButton(tablePanel, self:classname().."=object-update=ID="..item.."=", recipe.id, "helmod_button_default", ({"helmod_button.update"})) -- + end + end end ------------------------------------------------------------------------------- @@ -264,36 +261,37 @@ end -- @function [parent=#RecipeEdition] updateRecipeIngredients -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function RecipeEdition.methods:updateRecipeIngredients(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateRecipeIngredients():",player, element, action, item, item2, item3) - local ingredientsPanel = self:getRecipeIngredientsPanel(player) - local model = self.model:getModel(player) - local recipe = self.player:getRecipe(player, item2) +function RecipeEdition.methods:updateRecipeIngredients(player, item, item2, item3) + Logging:debug(self:classname(), "updateRecipeIngredients():", item, item2, item3) + local ingredientsPanel = self:getRecipeIngredientsPanel(player) + local model = self.model:getModel(player) + local recipe = self:getObject(player, item, item2, item3) - if recipe ~= nil then + if recipe ~= nil then + local lua_recipe = self.player:getRecipe(player, recipe.name) + if lua_recipe ~= nil then - for k,guiName in pairs(ingredientsPanel.children_names) do - ingredientsPanel[guiName].destroy() - end - local tablePanel= self:addGuiTable(ingredientsPanel, "table-ingredients", 6) - for key, ingredient in pairs(recipe.ingredients) do - local tooltip = nil - local localisedName = self.player:getLocalisedName(player, ingredient) - if ingredient.amount ~= nil then - tooltip = ({"tooltip.element-amount", localisedName, ingredient.amount}) - else - tooltip = ({"tooltip.element-amount-probability", localisedName, ingredient.amount_min, ingredient.amount_max, ingredient.probability}) - end - self:addGuiButtonSpriteSm(tablePanel, "item=ID=", self.player:getIconType(ingredient), ingredient.name, ingredient.name, tooltip) - self:addGuiLabel(tablePanel, ingredient.name, self.model:getElementAmount(ingredient), "helmod_label_sm") - end - end + for k,guiName in pairs(ingredientsPanel.children_names) do + ingredientsPanel[guiName].destroy() + end + local tablePanel= self:addGuiTable(ingredientsPanel, "table-ingredients", 6) + for key, ingredient in pairs(lua_recipe.ingredients) do + local tooltip = nil + local localisedName = self.player:getLocalisedName(player, ingredient) + if ingredient.amount ~= nil then + tooltip = ({"tooltip.element-amount", localisedName, ingredient.amount}) + else + tooltip = ({"tooltip.element-amount-probability", localisedName, ingredient.amount_min, ingredient.amount_max, ingredient.probability}) + end + self:addGuiButtonSpriteSm(tablePanel, "item=ID=", self.player:getIconType(ingredient), ingredient.name, ingredient.name, tooltip) + self:addGuiLabel(tablePanel, ingredient.name, self.model:getElementAmount(ingredient), "helmod_label_sm") + end + end + end end ------------------------------------------------------------------------------- @@ -302,34 +300,35 @@ end -- @function [parent=#RecipeEdition] updateRecipeProducts -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function RecipeEdition.methods:updateRecipeProducts(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateRecipeProducts():",player, element, action, item, item2, item3) - local productsPanel = self:getRecipeProductsPanel(player) - local model = self.model:getModel(player) - local recipe = self.player:getRecipe(player, item2) +function RecipeEdition.methods:updateRecipeProducts(player, item, item2, item3) + Logging:debug(self:classname(), "updateRecipeProducts():", item, item2, item3) + local productsPanel = self:getRecipeProductsPanel(player) + local model = self.model:getModel(player) + local recipe = self:getObject(player, item, item2, item3) - if recipe ~= nil then + if recipe ~= nil then + local lua_recipe = self.player:getRecipe(player, recipe.name) + if lua_recipe ~= nil then - for k,guiName in pairs(productsPanel.children_names) do - productsPanel[guiName].destroy() - end - local tablePanel= self:addGuiTable(productsPanel, "table-products", 6) - for key, product in pairs(recipe.products) do - local tooltip = nil - local localisedName = self.player:getLocalisedName(player, product) - if product.amount ~= nil then - tooltip = ({"tooltip.element-amount", localisedName, product.amount}) - else - tooltip = ({"tooltip.element-amount-probability", localisedName, product.amount_min, product.amount_max, product.probability}) - end - self:addGuiButtonSpriteSm(tablePanel, "item=ID=", self.player:getIconType(product), product.name, product.name, tooltip) - self:addGuiLabel(tablePanel, product.name, self.model:getElementAmount(product), "helmod_label_sm") - end - end -end \ No newline at end of file + for k,guiName in pairs(productsPanel.children_names) do + productsPanel[guiName].destroy() + end + local tablePanel= self:addGuiTable(productsPanel, "table-products", 6) + for key, product in pairs(lua_recipe.products) do + local tooltip = nil + local localisedName = self.player:getLocalisedName(player, product) + if product.amount ~= nil then + tooltip = ({"tooltip.element-amount", localisedName, product.amount}) + else + tooltip = ({"tooltip.element-amount-probability", localisedName, product.amount_min, product.amount_max, product.probability}) + end + self:addGuiButtonSpriteSm(tablePanel, "item=ID=", self.player:getIconType(product), product.name, product.name, tooltip) + self:addGuiLabel(tablePanel, product.name, self.model:getElementAmount(product), "helmod_label_sm") + end + end + end +end diff --git a/edition/ResourceEdition.lua b/edition/ResourceEdition.lua index 6a284219..9439c1eb 100644 --- a/edition/ResourceEdition.lua +++ b/edition/ResourceEdition.lua @@ -41,7 +41,7 @@ end -- @function [parent=#ResourceEdition] on_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name @@ -49,7 +49,7 @@ end -- -- @return #boolean if true the next call close dialog -- -function ResourceEdition.methods:on_open(player, element, action, item, item2, item3) +function ResourceEdition.methods:on_open(player, event, action, item, item2, item3) local model = self.model:getModel(player) local close = true model.moduleListRefresh = false @@ -69,13 +69,13 @@ end -- @function [parent=#ResourceEdition] on_close -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function ResourceEdition.methods:on_close(player, element, action, item, item2, item3) +function ResourceEdition.methods:on_close(player, event, action, item, item2, item3) local model = self.model:getModel(player) model.guiRecipeLast = nil model.moduleListRefresh = false @@ -102,13 +102,11 @@ end -- @function [parent=#ResourceEdition] getObject -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function ResourceEdition.methods:getObject(player, element, action, item, item2, item3) +function ResourceEdition.methods:getObject(player, item, item2, item3) local model = self.model:getModel(player) if model.resources[item2] ~= nil then -- return resource @@ -135,15 +133,13 @@ end -- @function [parent=#ResourceEdition] updateHeader -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function ResourceEdition.methods:updateHeader(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateHeader():",player, element, action, item, item2, item3) - self:updateObjectInfo(player, element, action, item, item2, item3) +function ResourceEdition.methods:updateHeader(player, item, item2, item3) + Logging:debug(self:classname(), "updateHeader():", item, item2, item3) + self:updateObjectInfo(player,item, item2, item3) end ------------------------------------------------------------------------------- @@ -152,14 +148,12 @@ end -- @function [parent=#ResourceEdition] updateObjectInfo -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function ResourceEdition.methods:updateObjectInfo(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "updateObjectInfo():",player, element, action, item, item2, item3) +function ResourceEdition.methods:updateObjectInfo(player, item, item2, item3) + Logging:debug(self:classname(), "updateObjectInfo():", item, item2, item3) local infoPanel = self:getObjectInfoPanel(player) local model = self.model:getModel(player) local default = self.model:getDefault(player) @@ -167,7 +161,7 @@ function ResourceEdition.methods:updateObjectInfo(player, element, action, item, local model = self.model:getModel(player) if model.ingredients[item2] ~= nil then - local resource = self:getObject(player, element, action, item, item2, item3) + local resource = self:getObject(player, item, item2, item3) Logging:debug(self:classname(), "updateResourceInfo():resource=",resource) for k,guiName in pairs(infoPanel.children_names) do infoPanel[guiName].destroy() @@ -180,11 +174,5 @@ function ResourceEdition.methods:updateObjectInfo(player, element, action, item, else self:addGuiLabel(tablePanel, "label", _resource.localised_name) end - - --- self:addGuiLabel(tablePanel, "label-production", ({"helmod_common.production"})) --- self:addGuiText(tablePanel, "production", resource.production, "helmod_textfield") --- --- self:addGuiButton(tablePanel, self:classname().."=object-update=ID=resource=", resource.name, "helmod_button_default", ({"helmod_button.update"})) -- end end diff --git a/info.json b/info.json index f75d7d68..1faf4a38 100644 --- a/info.json +++ b/info.json @@ -1,7 +1,7 @@ { "name": "helmod", - "version": "0.5.3", + "version": "0.5.4", "title": "Helmod: Assistant to plan its base.", "author": "Helfima", "contact": "Helfima", diff --git a/locale/en/helmod.cfg b/locale/en/helmod.cfg index c4907bca..649de01c 100644 --- a/locale/en/helmod.cfg +++ b/locale/en/helmod.cfg @@ -90,6 +90,7 @@ title=Resource Edition title=Recipe Edition current-modules=Actived modules selection-modules=Modules list +filter-show-disable=Show Disable filter-show-hidden=Show hidden filter-by-product=Filter by product filter-by-ingredient=Filter by ingredient @@ -190,6 +191,7 @@ col-header-wagon=Wagon col-header-storage=Storage col-header-primary=Primary col-header-secondary=Secondary +col-header-chmod=Access owner=Owner: share=Share diff --git a/locale/fr/helmod.cfg b/locale/fr/helmod.cfg index 21f90084..ea9ae17b 100644 --- a/locale/fr/helmod.cfg +++ b/locale/fr/helmod.cfg @@ -91,6 +91,7 @@ title=Edition de recette current-modules=Modules actifs selection-modules=Liste de modules filter-show-hidden=Afficher les cachés +filter-show-disable=Afficher les désactivés filter-by-product=Filtre sur les produits filter-by-ingredient=Filtre sur les ingredients message=Le filtre utilise uniquement les noms anglais @@ -185,6 +186,7 @@ col-header-wagon=Wagon col-header-storage=Stockage col-header-primary=Primaire col-header-secondary=Secondaire +col-header-chmod=Access owner=Propriétaire: share=Partager: diff --git a/model/Model.lua b/model/Model.lua index 97b5e12f..c473eb21 100644 --- a/model/Model.lua +++ b/model/Model.lua @@ -17,8 +17,9 @@ function Model.methods:init(parent) self.player = self.parent.player self.capEnergy = -0.8 + self.capSpeed = -0.8 - self.version = "0.4.7.1" + self.version = "0.5.4" end ------------------------------------------------------------------------------- @@ -303,7 +304,7 @@ end -- @return #table -- function Model.methods:createPowerModel(player) - Logging:debug(self:classname(), "createProductionBlockModel():",player) + Logging:debug(self:classname(), "createPowerModel():") local model = self.player:getGlobal(player, "model") if model.power_id == nil then model.power_id = 0 end @@ -330,7 +331,7 @@ end -- @return #table -- function Model.methods:createGeneratorModel(player, name, count) - Logging:debug(self:classname(), "createGeneratorModel():",player, name, count) + Logging:debug(self:classname(), "createGeneratorModel():", name, count) if name == nil then name = "steam-engine" end if count == nil then count = 0 end @@ -454,7 +455,7 @@ function Model.methods:createRecipeModel(player, name, count) if count == nil then count = 1 end local recipeModel = {} - recipeModel.id = model.recipe_id + recipeModel.id = "R"..model.recipe_id recipeModel.index = 1 recipeModel.weight = 0 recipeModel.name = name @@ -700,7 +701,7 @@ function Model.methods:addRecipeIntoProductionBlock(player, key) if recipe ~= nil then -- ajoute le bloc si il n'existe pas if model.blocks[blockId] == nil then - local modelBlock = self:createProductionBlockModel(player, recipe) + local modelBlock = self:createProductionBlockModel(player, recipe) local index = self:countBlocks(player) modelBlock.index = index modelBlock.unlinked = unlinked @@ -712,28 +713,26 @@ function Model.methods:addRecipeIntoProductionBlock(player, key) end -- ajoute le recipe si il n'existe pas - if model.blocks[blockId].recipes[key] == nil then - local ModelRecipe = self:createRecipeModel(player, recipe.name, 0) - local index = self:countBlockRecipes(player, blockId) - ModelRecipe.is_resource = not(recipe.force) - ModelRecipe.energy = recipe.energy - ModelRecipe.category = recipe.category - ModelRecipe.group = recipe.group.name - ModelRecipe.ingredients = recipe.ingredients - ModelRecipe.products = recipe.products - ModelRecipe.index = index - self:recipeReset(ModelRecipe) - -- ajoute les produits du block - for _, product in pairs(ModelRecipe.products) do - model.blocks[blockId].products[product.name] = product - end + local ModelRecipe = self:createRecipeModel(player, recipe.name, 0) + local index = self:countBlockRecipes(player, blockId) + ModelRecipe.is_resource = not(recipe.force) + ModelRecipe.energy = recipe.energy + ModelRecipe.category = recipe.category + ModelRecipe.group = recipe.group.name + ModelRecipe.ingredients = recipe.ingredients + ModelRecipe.products = recipe.products + ModelRecipe.index = index + self:recipeReset(ModelRecipe) + -- ajoute les produits du block + for _, product in pairs(ModelRecipe.products) do + model.blocks[blockId].products[product.name] = product + end - -- ajoute les ingredients du block - for _, ingredient in pairs(ModelRecipe.ingredients) do - model.blocks[blockId].ingredients[ingredient.name] = ingredient - end - model.blocks[blockId].recipes[key] = ModelRecipe + -- ajoute les ingredients du block + for _, ingredient in pairs(ModelRecipe.ingredients) do + model.blocks[blockId].ingredients[ingredient.name] = ingredient end + model.blocks[blockId].recipes[ModelRecipe.id] = ModelRecipe local defaultFactory = self:getDefaultRecipeFactory(player, recipe.name) if defaultFactory ~= nil then @@ -757,7 +756,7 @@ end -- @param #string key generator name -- function Model.methods:addPrimaryPower(player, power_id, key) - Logging:debug(self:classname(), "addPrimaryPower():",player, key) + Logging:debug(self:classname(), "addPrimaryPower():", power_id, key) local model = self:getModel(player) if model.powers == nil then model.powers = {} end local power = model.powers[power_id] @@ -867,8 +866,7 @@ function Model.methods:updateProduct(player, blockId, key, quantity) if model.blocks[blockId] ~= nil then local block = model.blocks[blockId] if block.input == nil then block.input = {} end - block.input.key = key - block.input.quantity = quantity + block.input[key] = quantity end end @@ -1161,6 +1159,11 @@ function Model.methods:removeProductionRecipe(player, blockId, key) if model.blocks[blockId] ~= nil and model.blocks[blockId].recipes[key] ~= nil then model.blocks[blockId].recipes[key] = nil self:reIndexList(model.blocks[blockId].recipes) + -- change block name + local first_recipe = self:firstRecipe(model.blocks[blockId].recipes) + if first_recipe ~= nil then + model.blocks[blockId].name = first_recipe.name + end end end @@ -1210,6 +1213,11 @@ function Model.methods:upProductionRecipe(player, blockId, key) local model = self:getModel(player) if model.blocks[blockId] ~= nil and model.blocks[blockId].recipes[key] ~= nil then self:upProductionList(player, model.blocks[blockId].recipes, model.blocks[blockId].recipes[key].index) + -- change block name + local first_recipe = self:firstRecipe(model.blocks[blockId].recipes) + if first_recipe ~= nil then + model.blocks[blockId].name = first_recipe.name + end end end @@ -1282,6 +1290,11 @@ function Model.methods:downProductionRecipe(player, blockId, key) local model = self:getModel(player) if model.blocks[blockId] ~= nil and model.blocks[blockId].recipes[key] ~= nil then self:downProductionList(player, model.blocks[blockId].recipes, model.blocks[blockId].recipes[key].index) + -- change block name + local first_recipe = self:firstRecipe(model.blocks[blockId].recipes) + if first_recipe ~= nil then + model.blocks[blockId].name = first_recipe.name + end end end @@ -1379,6 +1392,25 @@ function Model.methods:update(player) self:checkUnlinkedBlocks(player) Logging:debug(self:classname() , "********** updated version 0.4.6.1") end + if model.version == nil or model.version < "0.5.4" then + for _, productBlock in pairs(model.blocks) do + -- modify recipe id + local recipes = {} + for _, recipe in pairs(productBlock.recipes) do + recipe.id = "R"..recipe.id + recipes[recipe.id] = recipe + end + productBlock.recipes = recipes + -- modify input + if productBlock.input ~= nil and productBlock.input.key ~= nil then + local key = productBlock.input.key + local quantity = productBlock.input.quantity + productBlock.input = {} + productBlock.input[key] = quantity or 0 + end + end + Logging:debug(self:classname() , "********** updated version 0.5.4") + end if model.blocks ~= nil then for _, productBlock in pairs(model.blocks) do for _, recipe in pairs(productBlock.recipes) do @@ -1405,10 +1437,9 @@ function Model.methods:update(player) if not(productBlock.unlinked) then for _,product in pairs(recipe.products) do if input[product.name] ~= nil then - -- hors premier tour - productBlock.input = {} - productBlock.input.key = product.name - productBlock.input.quantity = input[product.name] + -- block linked + if productBlock.input == nil then productBlock.input = {} end + productBlock.input[product.name] = input[product.name] end end end @@ -1460,7 +1491,7 @@ end function Model.methods:getElementAmount(element) Logging:debug(self:classname(), "getElementAmount",element) if element == nil then return 0 end - + if element.amount ~= nil then return element.amount end @@ -1496,7 +1527,22 @@ function Model.methods:computeProductionBlock(player, element, maxLoop, level, p local initProduct = false -- preparation produits et ingredients du block - for _, recipe in pairs(recipes) do + for _, recipe in spairs(recipes,function(t,a,b) return t[b].index > t[a].index end) do + -- construit la list des ingredients + for _, ingredient in pairs(recipe.ingredients) do + if element.ingredients[ingredient.name] == nil then + element.ingredients[ingredient.name] = { + name = ingredient.name, + type = ingredient.type, + amount = ingredient.amount, + count = 0 + } + end + -- initialise ingredient + ingredient.count = 0 + end + end + for _, recipe in spairs(recipes,function(t,a,b) return t[b].index > t[a].index end) do -- construit la list des produits for _, product in pairs(recipe.products) do if element.products[product.name] == nil then @@ -1507,7 +1553,7 @@ function Model.methods:computeProductionBlock(player, element, maxLoop, level, p state = 0, amount = self:getElementAmount(product) } - if initProduct == false then + if not(element.ingredients[product.name]) then element.products[product.name].state = 1 end end @@ -1516,19 +1562,6 @@ function Model.methods:computeProductionBlock(player, element, maxLoop, level, p end -- limit les produits au premier recipe initProduct = true - -- construit la list des ingredients - for _, ingredient in pairs(recipe.ingredients) do - if element.ingredients[ingredient.name] == nil then - element.ingredients[ingredient.name] = { - name = ingredient.name, - type = ingredient.type, - amount = ingredient.amount, - count = 0 - } - end - -- initialise ingredient - ingredient.count = 0 - end end @@ -1541,34 +1574,33 @@ function Model.methods:computeProductionBlock(player, element, maxLoop, level, p self:computeModuleEffects(player, first_recipe) self:computeFactory(player, first_recipe) local _,first_product = next(first_recipe.products) - element.input = {} + if element.input == nil then element.input = {} end -- formula [product amount] * (1 + [productivity]) *[assembly speed]*[time]/[recipe energy] - element.input.key = first_product.name - element.input.quantity = self:getElementAmount(first_product) * (1 + first_recipe.factory.effects.productivity) * ( element.factory_number or 0 ) * first_recipe.factory.speed * model.time / first_recipe.energy + element.input[first_product.name] = self:getElementAmount(first_product) * (1 + first_recipe.factory.effects.productivity) * ( element.factory_number or 0 ) * first_recipe.factory.speed * model.time / first_recipe.energy end - -- initialise la premiere recette avec le input - local first_recipe = self:firstRecipe(recipes) - if first_recipe ~= nil and element.input ~= nil then - for _, product in pairs(first_recipe.products) do - if product.name == element.input.key then - local p_amount = self:getElementAmount(product) - local i_amount = 0 - - -- consolide product.count - if first_recipe.is_resource ~= true then - for k, ingredient in pairs(first_recipe.ingredients) do - if ingredient.name == product.name then - i_amount = self:getElementAmount(ingredient) + if element.input ~= nil then + for _, recipe in spairs(recipes,function(t,a,b) return t[b].index > t[a].index end) do + -- initialise la premiere recette avec le input + for _, product in pairs(recipe.products) do + if element.input[product.name] ~= nil then + local p_amount = self:getElementAmount(product) + local i_amount = 0 + + -- consolide product.count + if recipe.is_resource ~= true then + for k, ingredient in pairs(recipe.ingredients) do + if ingredient.name == product.name then + i_amount = self:getElementAmount(ingredient) + end end end - end - product.count = element.input.quantity * (p_amount/(p_amount-i_amount)) + product.count = element.input[product.name] * (p_amount/(p_amount-i_amount)) + end end end end - Logging:debug(self:classname(), "first_recipe",first_recipe) Logging:debug(self:classname() , "********** initialized:", element) @@ -1679,14 +1711,14 @@ function Model.methods:computeProductionBlock(player, element, maxLoop, level, p element.count = 1 end --- for _, recipe in pairs(recipes) do --- for _, ingredient in pairs(recipe.ingredients) do --- -- consomme les ingredients --- if recipe.is_resource ~= true and element.products[ingredient.name] ~= nil then --- element.products[ingredient.name].count = element.products[ingredient.name].count - ingredient.count --- end --- end --- end + -- for _, recipe in pairs(recipes) do + -- for _, ingredient in pairs(recipe.ingredients) do + -- -- consomme les ingredients + -- if recipe.is_resource ~= true and element.products[ingredient.name] ~= nil then + -- element.products[ingredient.name].count = element.products[ingredient.name].count - ingredient.count + -- end + -- end + -- end -- reduit les produits du block for _, product in pairs(element.products) do @@ -1907,6 +1939,9 @@ function Model.methods:computeModuleEffects(player, object) end end + -- cap la vitesse a self.capSpeed + if factory.effects.speed < self.capSpeed then factory.effects.speed = self.capSpeed end + -- cap l'energy a self.capEnergy if factory.effects.consumption < self.capEnergy then factory.effects.consumption = self.capEnergy end @@ -2052,10 +2087,10 @@ end -- function Model.methods:computePower(player, key) local power = self:getPower(player, key) - Logging:trace(self:classname(), "computePower():", key, power) + Logging:debug(self:classname(), "computePower():", key, power) if power ~= nil then - local primary_classification = self.player:getItemProperty(power.primary.name, "classification") - local secondary_classification = self.player:getItemProperty(power.secondary.name, "classification") + local primary_classification = self.player:getEntityProperty(power.primary.name, "type") + local secondary_classification = self.player:getEntityProperty(power.secondary.name, "type") if primary_classification == "generator" then -- calcul primary local count = math.ceil(power.power/(power.primary.energy_nominal)) diff --git a/selector/AbstractSelector.lua b/selector/AbstractSelector.lua index 63cf89c3..90d33a9e 100644 --- a/selector/AbstractSelector.lua +++ b/selector/AbstractSelector.lua @@ -104,6 +104,18 @@ function AbstractSelector.methods:on_init(parent) self.panelCaption = self:getCaption(parent) self.player = self.parent.player self.model = self.parent.model + self:after_init() +end + +------------------------------------------------------------------------------- +-- After initialization +-- +-- @function [parent=#AbstractSelector] after_init +-- +function AbstractSelector.methods:after_init() + self.disable_option = false + self.hidden_option = false + self.product_option = false end ------------------------------------------------------------------------------- @@ -189,7 +201,7 @@ end -- @function [parent=#AbstractSelector] on_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name @@ -197,8 +209,8 @@ end -- -- @return #boolean if true the next call close dialog -- -function AbstractSelector.methods:on_open(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "on_open():",player, element, action, item, item2, item3) +function AbstractSelector.methods:on_open(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "on_open():", action, item, item2, item3) local globalPlayer = self.player:getGlobal(player) if item3 ~= nil then prototypeFilter = item3:lower():gsub("[-]"," ") @@ -216,13 +228,13 @@ end -- @function [parent=#AbstractSelector] after_open -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractSelector.methods:after_open(player, element, action, item, item2, item3) +function AbstractSelector.methods:after_open(player, event, action, item, item2, item3) self.parent:send_event(player, "HMRecipeEdition", "CLOSE") self.parent:send_event(player, "HMProductEdition", "CLOSE") self.parent:send_event(player, "HMSettings", "CLOSE") @@ -238,14 +250,14 @@ end -- @function [parent=#AbstractSelector] on_event -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractSelector.methods:on_event(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "on_event():",player, element, action, item, item2, item3) +function AbstractSelector.methods:on_event(player, event, action, item, item2, item3) + Logging:debug(self:classname(), "on_event():", action, item, item2, item3) local globalPlayer = self.player:getGlobal(player) local globalSettings = self.player:getGlobal(player, "settings") local defaultSettings = self.player:getDefaultSettings() @@ -286,7 +298,7 @@ function AbstractSelector.methods:on_event(player, element, action, item, item2, if action == "recipe-group" then globalPlayer.recipeGroupSelected = item - self:on_update(player, element, action, item, item2, item3) + self:on_update(player, item, item2, item3) end if action == "change-boolean-settings" then @@ -297,12 +309,12 @@ function AbstractSelector.methods:on_event(player, element, action, item, item2, if action == "recipe-filter-switch" then prototypeFilterProduct = not(prototypeFilterProduct) - self:on_update(player, element, action, item, item2, item3) + self:on_update(player, item, item2, item3) end if action == "recipe-filter" then - prototypeFilter = element.text - self:on_update(player, element, action, item, item2, item3) + prototypeFilter = event.element.text + self:on_update(player, item, item2, item3) end end @@ -313,16 +325,14 @@ end -- @function [parent=#AbstractSelector] updateGroups -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -- @return {groupList, prototypeGroups} -- -function AbstractSelector.methods:updateGroups(player, element, action, item, item2, item3) - Logging:trace(self:classname(), "updateGroups():",player, element, action, item, item2, item3) +function AbstractSelector.methods:updateGroups(player, item, item2, item3) + Logging:trace(self:classname(), "updateGroups():", item, item2, item3) return {},{} end @@ -332,21 +342,19 @@ end -- @function [parent=#AbstractSelector] on_update -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractSelector.methods:on_update(player, element, action, item, item2, item3) - Logging:trace(self:classname(), "on_update():",player, element, action, item, item2, item3) +function AbstractSelector.methods:on_update(player, item, item2, item3) + Logging:trace(self:classname(), "on_update():",item, item2, item3) local globalPlayer = self.player:getGlobal(player) -- recuperation recipes - groupList , prototypeGroups = self:updateGroups(player, element, action, item, item2, item3) + groupList , prototypeGroups = self:updateGroups(player, item, item2, item3) - self:updateFilter(player, element, action, item, item2, item3) - self:updateGroupSelector(player, element, action, item, item2, item3) - self:updateItemList(player, element, action, item, item2, item3) + self:updateFilter(player, item, item2, item3) + self:updateGroupSelector(player, item, item2, item3) + self:updateItemList(player, item, item2, item3) end ------------------------------------------------------------------------------- @@ -355,37 +363,47 @@ end -- @function [parent=#AbstractSelector] updateFilter -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractSelector.methods:updateFilter(player, element, action, item, item2, item3) - Logging:trace(self:classname(), "updateFilter():",player, element, action, item, item2, item3) +function AbstractSelector.methods:updateFilter(player,item, item2, item3) + Logging:trace(self:classname(), "updateFilter():", item, item2, item3) local globalPlayer = self.player:getGlobal(player) local panel = self:getFilterPanel(player) local globalSettings = self.player:getGlobal(player, "settings") if panel["filter"] == nil then local guiFilter = self:addGuiTable(panel, "filter", 2) - local filter_show_hidden = self.player:getGlobalSettings(player, "filter_show_hidden") - self:addGuiCheckbox(guiFilter, self:classname().."=change-boolean-settings=ID=filter_show_hidden", filter_show_hidden) - self:addGuiLabel(guiFilter, "filter_show_hidden", ({"helmod_recipe-edition-panel.filter-show-hidden"})) - - self:addGuiCheckbox(guiFilter, self:classname().."=recipe-filter-switch=ID=filter-product", prototypeFilterProduct) - self:addGuiLabel(guiFilter, "filter-product", ({"helmod_recipe-edition-panel.filter-by-product"})) + if self.disable_option then + local filter_show_disable = self.player:getGlobalSettings(player, "filter_show_disable") + self:addGuiCheckbox(guiFilter, self:classname().."=change-boolean-settings=ID=filter_show_disable", filter_show_disable) + self:addGuiLabel(guiFilter, "filter_show_disable", ({"helmod_recipe-edition-panel.filter-show-disable"})) + end + + if self.hidden_option then + local filter_show_hidden = self.player:getGlobalSettings(player, "filter_show_hidden") + self:addGuiCheckbox(guiFilter, self:classname().."=change-boolean-settings=ID=filter_show_hidden", filter_show_hidden) + self:addGuiLabel(guiFilter, "filter_show_hidden", ({"helmod_recipe-edition-panel.filter-show-hidden"})) + end - self:addGuiCheckbox(guiFilter, self:classname().."=recipe-filter-switch=ID=filter-ingredient", not(prototypeFilterProduct)) - self:addGuiLabel(guiFilter, "filter-ingredient", ({"helmod_recipe-edition-panel.filter-by-ingredient"})) + if self.product_option then + self:addGuiCheckbox(guiFilter, self:classname().."=recipe-filter-switch=ID=filter-product", prototypeFilterProduct) + self:addGuiLabel(guiFilter, "filter-product", ({"helmod_recipe-edition-panel.filter-by-product"})) + + self:addGuiCheckbox(guiFilter, self:classname().."=recipe-filter-switch=ID=filter-ingredient", not(prototypeFilterProduct)) + self:addGuiLabel(guiFilter, "filter-ingredient", ({"helmod_recipe-edition-panel.filter-by-ingredient"})) + end self:addGuiLabel(guiFilter, "filter-value", ({"helmod_common.filter"})) self:addGuiText(guiFilter, self:classname().."=recipe-filter=ID=filter-value", prototypeFilter) self:addGuiLabel(panel, "message", ({"helmod_recipe-edition-panel.message"})) else - panel["filter"][self:classname().."=recipe-filter-switch=ID=filter-product"].state = prototypeFilterProduct - panel["filter"][self:classname().."=recipe-filter-switch=ID=filter-ingredient"].state = not(prototypeFilterProduct) + if self.product_option then + panel["filter"][self:classname().."=recipe-filter-switch=ID=filter-product"].state = prototypeFilterProduct + panel["filter"][self:classname().."=recipe-filter-switch=ID=filter-ingredient"].state = not(prototypeFilterProduct) + end end end @@ -396,14 +414,12 @@ end -- @function [parent=#AbstractSelector] updateItemList -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractSelector.methods:updateItemList(player, element, action, item, item2, item3) - Logging:trace(self:classname(), "updateItemList():",player, element, action, item, item2, item3) +function AbstractSelector.methods:updateItemList(player, item, item2, item3) + Logging:trace(self:classname(), "updateItemList():", item, item2, item3) local globalPlayer = self.player:getGlobal(player) local panel = self:getItemListPanel(player) @@ -412,7 +428,7 @@ function AbstractSelector.methods:updateItemList(player, element, action, item, end -- recuperation recipes et subgroupes - local list = self:getItemList(player, element, action, item, item2, item3) + local list = self:getItemList(player, item, item2, item3) --local guiRecipeSelectorTable = self:addGuiTable(panel, "recipe-table", 10) local guiRecipeSelectorList = self:addGuiFlowV(panel, "recipe-list", "helmod_flow_recipe_selector") @@ -435,14 +451,12 @@ end -- @function [parent=#AbstractSelector] getItemList -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractSelector.methods:getItemList(player, element, action, item, item2, item3) - Logging:trace(self:classname(), "getItemList():",player, element, action, item, item2, item3) +function AbstractSelector.methods:getItemList(player, item, item2, item3) + Logging:trace(self:classname(), "getItemList():", item, item2, item3) local globalPlayer = self.player:getGlobal(player) local list = {} if prototypeGroups[globalPlayer.recipeGroupSelected] ~= nil then @@ -483,14 +497,12 @@ end -- @function [parent=#AbstractSelector] updateGroupSelector -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function AbstractSelector.methods:updateGroupSelector(player, element, action, item, item2, item3) - Logging:trace(self:classname(), "updateGroupSelector():",player, element, action, item, item2, item3) +function AbstractSelector.methods:updateGroupSelector(player, item, item2, item3) + Logging:trace(self:classname(), "updateGroupSelector():", item, item2, item3) local globalPlayer = self.player:getGlobal(player) local panel = self:getGroupsPanel(player) diff --git a/selector/EntitySelector.lua b/selector/EntitySelector.lua index 87c01880..e1284516 100644 --- a/selector/EntitySelector.lua +++ b/selector/EntitySelector.lua @@ -25,16 +25,14 @@ end -- @function [parent=#EntitySelector] updateGroups -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -- @return {groupList, prototypeGroups} -- -function EntitySelector.methods:updateGroups(player, element, action, item, item2, item3) - Logging:trace(self:classname(), "on_update():",player, element, action, item, item2, item3) +function EntitySelector.methods:updateGroups(player, item, item2, item3) + Logging:trace(self:classname(), "on_update():", item, item2, item3) local globalPlayer = self.player:getGlobal(player) -- recuperation recipes local prototypeGroups = {} @@ -81,14 +79,12 @@ end -- @function [parent=#EntitySelector] getItemList -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function EntitySelector.methods:getItemList(player, element, action, item, item2, item3) - Logging:trace(self:classname(), "getItemList():",player, element, action, item, item2, item3) +function EntitySelector.methods:getItemList(player, item, item2, item3) + Logging:trace(self:classname(), "getItemList():", item, item2, item3) local globalPlayer = self.player:getGlobal(player) local list = {} local prototypeGroups = self:getPrototypeGroups() diff --git a/selector/ItemSelector.lua b/selector/ItemSelector.lua index 165565a4..c32f996c 100644 --- a/selector/ItemSelector.lua +++ b/selector/ItemSelector.lua @@ -25,16 +25,14 @@ end -- @function [parent=#ItemSelector] updateGroups -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -- @return {groupList, prototypeGroups} -- -function ItemSelector.methods:updateGroups(player, element, action, item, item2, item3) - Logging:trace(self:classname(), "on_update():",player, element, action, item, item2, item3) +function ItemSelector.methods:updateGroups(player, item, item2, item3) + Logging:trace(self:classname(), "on_update():", item, item2, item3) local globalPlayer = self.player:getGlobal(player) -- recuperation recipes local prototypeGroups = {} @@ -81,14 +79,12 @@ end -- @function [parent=#ItemSelector] getItemList -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function ItemSelector.methods:getItemList(player, element, action, item, item2, item3) - Logging:trace(self:classname(), "getItemList():",player, element, action, item, item2, item3) +function ItemSelector.methods:getItemList(player, item, item2, item3) + Logging:trace(self:classname(), "getItemList():", item, item2, item3) local globalPlayer = self.player:getGlobal(player) local list = {} local prototypeGroups = self:getPrototypeGroups() diff --git a/selector/RecipeSelector.lua b/selector/RecipeSelector.lua index f752a99d..d8424205 100644 --- a/selector/RecipeSelector.lua +++ b/selector/RecipeSelector.lua @@ -8,6 +8,17 @@ require "selector.AbstractSelector" RecipeSelector = setclass("HMRecipeSelector", AbstractSelector) +------------------------------------------------------------------------------- +-- After initialization +-- +-- @function [parent=#RecipeSelector] after_init +-- +function RecipeSelector.methods:after_init() + self.disable_option = true + self.hidden_option = true + self.product_option = true +end + ------------------------------------------------------------------------------- -- Return caption -- @@ -25,16 +36,14 @@ end -- @function [parent=#RecipeSelector] updateGroups -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -- @return groupList, prototypeGroups -- -function RecipeSelector.methods:updateGroups(player, element, action, item, item2, item3) - Logging:trace(self:classname(), "updateGroups():",player, element, action, item, item2, item3) +function RecipeSelector.methods:updateGroups(player, item, item2, item3) + Logging:trace(self:classname(), "updateGroups():", item, item2, item3) local globalPlayer = self.player:getGlobal(player) local globalGui = self.player:getGlobalGui(player) -- recuperation recipes @@ -64,8 +73,9 @@ function RecipeSelector.methods:updateGroups(player, element, action, item, item find = true end + local filter_show_disable = self.player:getGlobalSettings(player, "filter_show_disable") local filter_show_hidden = self.player:getGlobalSettings(player, "filter_show_hidden") - if find == true and (prototype.enabled == true or filter_show_hidden == true) then + if find == true and (prototype.enabled == true or filter_show_disable == true) and (prototype.hidden == false or filter_show_hidden == true) then if firstGroup == nil then firstGroup = prototype.group.name end groupList[prototype.group.name] = prototype.group if prototypeGroups[prototype.group.name] == nil then prototypeGroups[prototype.group.name] = {} end @@ -86,14 +96,12 @@ end -- @function [parent=#RecipeSelector] getItemList -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function RecipeSelector.methods:getItemList(player, element, action, item, item2, item3) - Logging:trace(self:classname(), "getItemList():",player, element, action, item, item2, item3) +function RecipeSelector.methods:getItemList(player, item, item2, item3) + Logging:trace(self:classname(), "getItemList():", item, item2, item3) local globalPlayer = self.player:getGlobal(player) local list = {} local prototypeGroups = self:getPrototypeGroups() diff --git a/selector/TechnologySelector.lua b/selector/TechnologySelector.lua index 31088d4e..874a1855 100644 --- a/selector/TechnologySelector.lua +++ b/selector/TechnologySelector.lua @@ -8,6 +8,15 @@ require "selector.AbstractSelector" TechnologySelector = setclass("HMTechnologySelector", AbstractSelector) +------------------------------------------------------------------------------- +-- After initialization +-- +-- @function [parent=#TechnologySelector] after_init +-- +function TechnologySelector.methods:after_init() + self.disable_option = true +end + ------------------------------------------------------------------------------- -- Return caption -- @@ -25,16 +34,14 @@ end -- @function [parent=#TechnologySelector] updateGroups -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -- @return {groupList, prototypeGroups} -- -function TechnologySelector.methods:updateGroups(player, element, action, item, item2, item3) - Logging:trace(self:classname(), "on_update():",player, element, action, item, item2, item3) +function TechnologySelector.methods:updateGroups(player, item, item2, item3) + Logging:trace(self:classname(), "on_update():", item, item2, item3) local globalPlayer = self.player:getGlobal(player) -- recuperation recipes local prototypeGroups = {} @@ -88,14 +95,12 @@ end -- @function [parent=#TechnologySelector] getItemList -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function TechnologySelector.methods:getItemList(player, element, action, item, item2, item3) - Logging:trace(self:classname(), "getItemList():",player, element, action, item, item2, item3) +function TechnologySelector.methods:getItemList(player, item, item2, item3) + Logging:trace(self:classname(), "getItemList():",player, item, item2, item3) local globalPlayer = self.player:getGlobal(player) local list = {} local prototypeGroups = self:getPrototypeGroups() diff --git a/tab/EnergyTab.lua b/tab/EnergyTab.lua index c74af79c..17ffee13 100644 --- a/tab/EnergyTab.lua +++ b/tab/EnergyTab.lua @@ -19,78 +19,6 @@ function EnergyTab.methods:getButtonCaption() return {"helmod_result-panel.tab-button-energy"} end -------------------------------------------------------------------------------- --- On event --- --- @function [parent=#EnergyTab] on_event_access_all --- --- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name --- @param #string item first item name --- @param #string item2 second item name --- @param #string item3 third item name --- -function EnergyTab.methods:on_event_access_all(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "on_event_access_all():",player, element, action, item, item2, item3) - local globalGui = self.player:getGlobalGui(player) -end - -------------------------------------------------------------------------------- --- On event --- --- @function [parent=#EnergyTab] on_event_access_read --- --- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name --- @param #string item first item name --- @param #string item2 second item name --- @param #string item3 third item name --- -function EnergyTab.methods:on_event_access_read(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "on_event_access_read():",player, element, action, item, item2, item3) - local globalGui = self.player:getGlobalGui(player) -end - -------------------------------------------------------------------------------- --- On event --- --- @function [parent=#EnergyTab] on_event_access_write --- --- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name --- @param #string item first item name --- @param #string item2 second item name --- @param #string item3 third item name --- -function EnergyTab.methods:on_event_access_write(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "on_event_access_write():",player, element, action, item, item2, item3) - local globalGui = self.player:getGlobalGui(player) - if action == "power-remove" then - self.parent.model:removePower(player, item) - self:update(player, self.POWER_TAB, item, item2, item3) - end -end - -------------------------------------------------------------------------------- --- On event --- --- @function [parent=#EnergyTab] on_event_access_delete --- --- @param #LuaPlayer player --- @param #LuaGuiElement element button --- @param #string action action name --- @param #string item first item name --- @param #string item2 second item name --- @param #string item3 third item name --- -function EnergyTab.methods:on_event_access_delete(player, element, action, item, item2, item3) - Logging:debug(self:classname(), "on_event_access_delete():",player, element, action, item, item2, item3) - local globalGui = self.player:getGlobalGui(player) -end - ------------------------------------------------------------------------------- -- Update data -- @@ -162,7 +90,7 @@ function EnergyTab.methods:addTableRow(player, guiTable, power) -- col action local guiAction = self:addGuiFlowH(guiTable,"action"..power.id, "helmod_flow_default") - self:addGuiButton(guiAction, self:classname().."=power-remove=ID=", power.id, "helmod_button_default", ({"helmod_result-panel.row-button-delete"}), ({"tooltip.remove-element"})) + self:addGuiButton(guiAction, self.parent:classname().."=power-remove=ID=", power.id, "helmod_button_default", ({"helmod_result-panel.row-button-delete"}), ({"tooltip.remove-element"})) -- col id if self.player:getSettings(player, "display_data_col_id", true) then diff --git a/tab/MainTab.lua b/tab/MainTab.lua index cc0645ed..4c13252a 100644 --- a/tab/MainTab.lua +++ b/tab/MainTab.lua @@ -188,15 +188,15 @@ end -- @function [parent=#MainTab] send_event -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function MainTab.methods:send_event(player, element, action, item, item2, item3) - Logging:debug("MainTab", "send_event():",player, element, action, item, item2, item3) - self:on_event(player, element, action, item, item2, item3) +function MainTab.methods:send_event(player, event, action, item, item2, item3) + Logging:debug("MainTab", "send_event():", action, item, item2, item3) + self:on_event(player, event, action, item, item2, item3) end ------------------------------------------------------------------------------- -- On event @@ -204,13 +204,13 @@ end -- @function [parent=#MainTab] on_event -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function MainTab.methods:on_event(player, element, action, item, item2, item3) +function MainTab.methods:on_event(player, event, action, item, item2, item3) Logging:debug(self:classname(), "on_event():", action, item, item2, item3) local globalGui = self.player:getGlobalGui(player) @@ -223,7 +223,7 @@ function MainTab.methods:on_event(player, element, action, item, item2, item3) -- ******************************* if self.player:isAdmin(player) or model.owner == player.name or (model.share ~= nil and bit32.band(model.share, 2) > 0) then - self:on_event_access_write(player, element, action, item, item2, item3) + self:on_event_access_write(player, event, action, item, item2, item3) end -- *************************** @@ -231,7 +231,7 @@ function MainTab.methods:on_event(player, element, action, item, item2, item3) -- *************************** if self.player:isAdmin(player) or model.owner == player.name then - self:on_event_access_read(player, element, action, item, item2, item3) + self:on_event_access_read(player, event, action, item, item2, item3) end -- ******************************** @@ -239,13 +239,13 @@ function MainTab.methods:on_event(player, element, action, item, item2, item3) -- ******************************** if self.player:isAdmin(player) or model.owner == player.name or (model.share ~= nil and bit32.band(model.share, 4) > 0) then - self:on_event_access_delete(player, element, action, item, item2, item3) + self:on_event_access_delete(player, event, action, item, item2, item3) end -- *************************** -- access for all -- *************************** - self:on_event_access_all(player, element, action, item, item2, item3) + self:on_event_access_all(player, event, action, item, item2, item3) end end @@ -255,13 +255,13 @@ end -- @function [parent=#MainTab] on_event_access_all -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function MainTab.methods:on_event_access_all(player, element, action, item, item2, item3) +function MainTab.methods:on_event_access_all(player, event, action, item, item2, item3) Logging:debug(self:classname(), "on_event_access_all():", action, item, item2, item3) local globalGui = self.player:getGlobalGui(player) if action == "refresh-model" then @@ -334,13 +334,13 @@ end -- @function [parent=#MainTab] on_event_access_read -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function MainTab.methods:on_event_access_read(player, element, action, item, item2, item3) +function MainTab.methods:on_event_access_read(player, event, action, item, item2, item3) Logging:debug(self:classname(), "on_event_access_read():", action, item, item2, item3) local model = self.model:getModel(player) if action == "share-model" then @@ -377,13 +377,13 @@ end -- @function [parent=#MainTab] on_event_access_write -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function MainTab.methods:on_event_access_write(player, element, action, item, item2, item3) +function MainTab.methods:on_event_access_write(player, event, action, item, item2, item3) Logging:debug(self:classname(), "on_event_access_write():", action, item, item2, item3) local globalGui = self.player:getGlobalGui(player) local model = self.model:getModel(player) @@ -470,6 +470,12 @@ function MainTab.methods:on_event_access_write(player, element, action, item, it end end + if globalGui.currentTab == "HMEnergyTab" then + if action == "power-remove" then + self.parent.model:removePower(player, item) + self:update(player, item, item2, item3) + end + end end ------------------------------------------------------------------------------- @@ -478,13 +484,13 @@ end -- @function [parent=#MainTab] on_event_access_delete -- -- @param #LuaPlayer player --- @param #LuaGuiElement element button +-- @param #LuaEvent event -- @param #string action action name -- @param #string item first item name -- @param #string item2 second item name -- @param #string item3 third item name -- -function MainTab.methods:on_event_access_delete(player, element, action, item, item2, item3) +function MainTab.methods:on_event_access_delete(player, event, action, item, item2, item3) Logging:debug(self:classname(), "on_event_access_delete():", action, item, item2, item3) local globalGui = self.player:getGlobalGui(player) if action == "remove-model" then diff --git a/tab/ProductionBlockTab.lua b/tab/ProductionBlockTab.lua index a11a0cef..f3301d72 100644 --- a/tab/ProductionBlockTab.lua +++ b/tab/ProductionBlockTab.lua @@ -219,14 +219,11 @@ function ProductionBlockTab.methods:addTableRow(player, guiTable, block, recipe) local display_cell_mod = self.player:getSettings(player, "display_cell_mod") -- col action - local guiAction = self:addGuiFlowH(guiTable,"action"..recipe.name, "helmod_flow_default") - if recipe.index ~= 0 then - self:addGuiButton(guiAction, self.parent:classname().."=production-recipe-remove=ID="..block.id.."=", recipe.name, "helmod_button_default", ({"helmod_result-panel.row-button-delete"}), ({"tooltip.remove-element"})) - self:addGuiButton(guiAction, self.parent:classname().."=production-recipe-down=ID="..block.id.."=", recipe.name, "helmod_button_default", ({"helmod_result-panel.row-button-down"}), ({"tooltip.down-element"})) - end - if recipe.index > 1 then - self:addGuiButton(guiAction, self.parent:classname().."=production-recipe-up=ID="..block.id.."=", recipe.name, "helmod_button_default", ({"helmod_result-panel.row-button-up"}), ({"tooltip.up-element"})) - end + local guiAction = self:addGuiFlowH(guiTable,"action"..recipe.id, "helmod_flow_default") + self:addGuiButton(guiAction, self.parent:classname().."=production-recipe-remove=ID="..block.id.."=", recipe.id, "helmod_button_default", ({"helmod_result-panel.row-button-delete"}), ({"tooltip.remove-element"})) + self:addGuiButton(guiAction, self.parent:classname().."=production-recipe-down=ID="..block.id.."=", recipe.id, "helmod_button_default", ({"helmod_result-panel.row-button-down"}), ({"tooltip.down-element"})) + self:addGuiButton(guiAction, self.parent:classname().."=production-recipe-up=ID="..block.id.."=", recipe.id, "helmod_button_default", ({"helmod_result-panel.row-button-up"}), ({"tooltip.up-element"})) + -- col index if self.player:getSettings(player, "display_data_col_index", true) then local guiIndex = self:addGuiFlowH(guiTable,"index"..recipe.id) @@ -244,16 +241,16 @@ function ProductionBlockTab.methods:addTableRow(player, guiTable, block, recipe) end -- col recipe local production = recipe.production or 1 - local guiRecipe = self:addCellLabel(player, guiTable, "recipe-"..recipe.name, self:formatPercent(production).."%", 35) - self:addIconRecipeCell(player, guiRecipe, recipe, "HMRecipeEdition=OPEN=ID="..block.id.."=", true, "tooltip.edit-recipe", self.color_button_edit) + local guiRecipe = self:addCellLabel(player, guiTable, "recipe-"..recipe.id, self:formatPercent(production).."%", 35) + self:addIconRecipeCell(player, guiRecipe, recipe, "HMRecipeEdition=OPEN=ID="..block.id.."="..recipe.id.."=", true, "tooltip.edit-recipe", self.color_button_edit) -- col energy - local guiEnergy = self:addCellLabel(player, guiTable, "energy-"..recipe.name, self:formatNumberKilo(recipe.energy_total, "W"), 50) + local guiEnergy = self:addCellLabel(player, guiTable, "energy-"..recipe.id, self:formatNumberKilo(recipe.energy_total, "W"), 50) -- col factory local factory = recipe.factory - local guiFactory = self:addCellLabel(player, guiTable, "factory-"..recipe.name, self:formatNumberFactory(factory.limit_count).."/"..self:formatNumberFactory(factory.count), 60) - self:addIconCell(player, guiFactory, factory, "HMRecipeEdition=OPEN=ID="..block.id.."="..recipe.name.."=", true, "tooltip.edit-recipe", self.color_button_edit) + local guiFactory = self:addCellLabel(player, guiTable, "factory-"..recipe.id, self:formatNumberFactory(factory.limit_count).."/"..self:formatNumberFactory(factory.count), 60) + self:addIconCell(player, guiFactory, factory, "HMRecipeEdition=OPEN=ID="..block.id.."="..recipe.id.."=", true, "tooltip.edit-recipe", self.color_button_edit) local col_size = 2 if display_cell_mod == "small-icon" then col_size = 5 end local guiFactoryModule = self:addGuiTable(guiFactory,"factory-modules"..recipe.name, col_size, "helmod_factory_modules") @@ -277,8 +274,8 @@ function ProductionBlockTab.methods:addTableRow(player, guiTable, block, recipe) -- col beacon local beacon = recipe.beacon - local guiBeacon = self:addCellLabel(player, guiTable, "beacon-"..recipe.name, self:formatNumberFactory(beacon.limit_count).."/"..self:formatNumberFactory(beacon.count), 60) - self:addIconCell(player, guiBeacon, beacon, "HMRecipeEdition=OPEN=ID="..block.id.."="..recipe.name.."=", true, "tooltip.edit-recipe", self.color_button_edit) + local guiBeacon = self:addCellLabel(player, guiTable, "beacon-"..recipe.id, self:formatNumberFactory(beacon.limit_count).."/"..self:formatNumberFactory(beacon.count), 60) + self:addIconCell(player, guiBeacon, beacon, "HMRecipeEdition=OPEN=ID="..block.id.."="..recipe.id.."=", true, "tooltip.edit-recipe", self.color_button_edit) local col_size = 1 if display_cell_mod == "small-icon" then col_size = 5 end local guiBeaconModule = self:addGuiTable(guiBeacon,"beacon-modules"..recipe.name, col_size, "helmod_beacon_modules") @@ -302,7 +299,7 @@ function ProductionBlockTab.methods:addTableRow(player, guiTable, block, recipe) -- products local display_product_cols = self.player:getSettings(player, "display_product_cols") - local tProducts = self:addGuiTable(guiTable,"products_"..recipe.name, display_product_cols) + local tProducts = self:addGuiTable(guiTable,"products_"..recipe.id, display_product_cols) if recipe.products ~= nil then for r, product in pairs(recipe.products) do self:addCellElement(player, tProducts, product, "HMProduct=OPEN=ID="..block.id.."="..recipe.name.."=", false, "tooltip.product", nil) @@ -311,7 +308,7 @@ function ProductionBlockTab.methods:addTableRow(player, guiTable, block, recipe) end -- ingredients local display_ingredient_cols = self.player:getSettings(player, "display_ingredient_cols") - local tIngredient = self:addGuiTable(guiTable,"ingredients_"..recipe.name, display_ingredient_cols) + local tIngredient = self:addGuiTable(guiTable,"ingredients_"..recipe.id, display_ingredient_cols) if recipe.ingredients ~= nil then for r, ingredient in pairs(recipe.ingredients) do self:addCellElement(player, tIngredient, ingredient, self.parent:classname().."=production-recipe-add=ID="..block.id.."="..recipe.name.."=", true, "tooltip.add-recipe", self.color_button_add) diff --git a/tab/PropertiesTab.lua b/tab/PropertiesTab.lua index 41b0722e..739ca653 100644 --- a/tab/PropertiesTab.lua +++ b/tab/PropertiesTab.lua @@ -32,6 +32,7 @@ function PropertiesTab.methods:addTableHeader(player, itable) -- data columns self:addCellHeader(player, itable, "property", {"helmod_result-panel.col-header-name"}) + self:addCellHeader(player, itable, "chmod", {"helmod_result-panel.col-header-chmod"}) self:addCellHeader(player, itable, "value", {"helmod_result-panel.col-header-value"}) end @@ -42,17 +43,21 @@ end -- -- @param #LuaPlayer player -- -function PropertiesTab.methods:addTableRow(player, guiTable, property, value) - Logging:debug(self:classname(), "addTableRow():", player, guiTable, property, value) +function PropertiesTab.methods:addTableRow(player, guiTable, property) + Logging:debug(self:classname(), "addTableRow():", player, guiTable, property) local model = self.model:getModel(player) -- col property - local guiCount = self:addGuiFlowH(guiTable,property.."_name") - self:addGuiLabel(guiCount, "label", property) + local guiCount = self:addGuiFlowH(guiTable,property.name.."_name") + self:addGuiLabel(guiCount, "label", property.name) + + -- col chmod + local guiCount = self:addGuiFlowH(guiTable,property.name.."_chmod") + self:addGuiLabel(guiCount, "label", property.chmod or "") -- col value - local guiType = self:addGuiFlowH(guiTable,property.."_value") - self:addGuiLabel(guiType, "label", value, "helmod_label_max_600", nil, false) + local guiType = self:addGuiFlowH(guiTable,property.name.."_value") + self:addGuiLabel(guiType, "label", property.value, "helmod_label_max_600", nil, false) end @@ -100,14 +105,14 @@ function PropertiesTab.methods:updateData(player) end if prototype ~= nil then self:addGuiLabel(listPanel, "type-label", prototype_type, "helmod_label_right_100") - local resultTable = self:addGuiTable(scrollPanel,"table-resources",2) + local resultTable = self:addGuiTable(scrollPanel,"table-resources",3) self:addTableHeader(player, resultTable) local properties = self:parseProperties(prototype, 0) for _, property in pairs(properties) do - self:addTableRow(player, resultTable, property.name, property.value) + self:addTableRow(player, resultTable, property) end end end @@ -123,25 +128,25 @@ end function PropertiesTab.methods:parseProperties(prototype, level) local properties = {} - local help_string = string.gmatch(prototype:help(),"(%S+) [[]R[]]") + local help_string = string.gmatch(prototype:help(),"(%S+) [[](RW?)[]]") - for i in help_string do + for key, chmod in help_string do --Logging:debug(self:classname(), "help_string:", i) pcall(function() - local type = type(prototype[i]) - local value = tostring(prototype[i]) + local type = type(prototype[key]) + local value = tostring(prototype[key]) if type == "table" then - if level < 2 and pcall(function() prototype[i]:help() end) then - local result = PropertiesTab.methods:parseProperties(prototype[i], level + 1) + if level < 2 and pcall(function() prototype[key]:help() end) then + local result = PropertiesTab.methods:parseProperties(prototype[key], level + 1) value = "" for _, property in pairs(result) do value = value .. property.name .. " = " .. property.value .. "\n" end else - value = string.match(serpent.dump(prototype[i]),"do local _=(.*);return _;end") + value = string.match(serpent.dump(prototype[key]),"do local _=(.*);return _;end") end end - table.insert(properties, {name = i, value = value}) + table.insert(properties, {name = key, chmod = chmod, value = value}) --Logging:debug(self:classname(), "help_string:", i, type, value) end) end diff --git a/tab/ResourceTab.lua b/tab/ResourceTab.lua index 4c88138c..7963285c 100644 --- a/tab/ResourceTab.lua +++ b/tab/ResourceTab.lua @@ -32,7 +32,6 @@ function ResourceTab.methods:addTableHeader(player, itable) -- optionnal columns self:addCellHeader(player, itable, "index", {"helmod_result-panel.col-header-index"},"index") - self:addCellHeader(player, itable, "id", {"helmod_result-panel.col-header-id"},"id") self:addCellHeader(player, itable, "name", {"helmod_result-panel.col-header-name"},"name") -- data columns self:addCellHeader(player, itable, "count", {"helmod_result-panel.col-header-total"},"count") @@ -53,17 +52,12 @@ function ResourceTab.methods:addTableRow(player, guiTable, ingredient) -- col index if self.player:getSettings(player, "display_data_col_index", true) then - local guiIndex = self:addGuiFlowH(guiTable,"index"..ingredient.id) + local guiIndex = self:addGuiFlowH(guiTable,"index"..ingredient.name) self:addGuiLabel(guiIndex, "index", ingredient.index, "helmod_label_row_right_40") end - -- col id - if self.player:getSettings(player, "display_data_col_id", true) then - local guiId = self:addGuiFlowH(guiTable,"id"..ingredient.id) - self:addGuiLabel(guiId, "id", ingredient.id) - end -- col name if self.player:getSettings(player, "display_data_col_name", true) then - local guiName = self:addGuiFlowH(guiTable,"name"..ingredient.id) + local guiName = self:addGuiFlowH(guiTable,"name"..ingredient.name) self:addGuiLabel(guiName, "name_", ingredient.name) end -- col count @@ -99,9 +93,6 @@ function ResourceTab.methods:updateData(player) if self.player:getSettings(player, "display_data_col_index", true) then extra_cols = extra_cols + 1 end - if self.player:getSettings(player, "display_data_col_id", true) then - extra_cols = extra_cols + 1 - end if self.player:getSettings(player, "display_data_col_name", true) then extra_cols = extra_cols + 1 end