diff --git a/changelog.txt b/changelog.txt index 17dc9174..049e7b38 100644 --- a/changelog.txt +++ b/changelog.txt @@ -20,6 +20,7 @@ Version: 0.12.14 Date: 2022-11-30 Changes: - Updated Russian locale + - Added Pin-Feature for productionlines Bugfixes: - Machine speed calculated incorrectly when fuel temperature below 15 degrees #442 --------------------------------------------------------------------------------------------------- diff --git a/dialog/PinPanel.lua b/dialog/PinPanel.lua index 3976361e..8a4a4a8e 100644 --- a/dialog/PinPanel.lua +++ b/dialog/PinPanel.lua @@ -102,21 +102,32 @@ function PinPanel:updateInfo(event) local model, block, recipe = self:getParameterObjects() + local resultTable = GuiElement.add(infoPanel, GuiTable("list-data"):column(column):style("helmod_table-odd")) + resultTable.vertical_centering = false + resultTable.style.horizontally_stretchable = false + self:addProductionBlockHeader(resultTable) if block ~= nil then - local resultTable = GuiElement.add(infoPanel, GuiTable("list-data"):column(column):style("helmod_table-odd")) - resultTable.vertical_centering = false - resultTable.style.horizontally_stretchable = false - - self:addProductionBlockHeader(resultTable) - for _, recipe in spairs(block.recipes, function(t,a,b) return t[b]["index"] > t[a]["index"] end) do - local is_done = recipe.is_done or false - if not(is_done and User.getSetting("pin_panel_column_hide_done")) then - self:addProductionBlockRow(resultTable, model, block, recipe) - end + self:addRecipes(resultTable,model,block) + else + for _, iterBlock in spairs(model.blocks) do + self:addRecipes(resultTable,model,iterBlock) end - end + end end +------------------------------------------------------------------------------- +---Add recipes of given block +---@param resultTable GuiTable +---@param model any +---@param block any +function PinPanel:addRecipes(resultTable,model,block) + for _, recipe in spairs(block.recipes, function(t,a,b) return t[b]["index"] > t[a]["index"] end) do + local is_done = recipe.is_done or false + if not(is_done and User.getSetting("pin_panel_column_hide_done")) then + self:addProductionBlockRow(resultTable, model, block, recipe) + end + end +end ------------------------------------------------------------------------------- ---Add header data tab ---@param itable LuaGuiElement @@ -163,20 +174,38 @@ function PinPanel:addProductionBlockRow(gui_table, model, block, recipe) ---col done if is_done == true then - GuiElement.add(gui_table, GuiButton(self.classname, "recipe-done", recipe.id):sprite("menu", defines.sprites.status_ok.black, defines.sprites.status_ok.black):style("helmod_button_menu_selected_green"):tooltip({"helmod_button.done"})) + GuiElement.add( + gui_table, + GuiButton(self.classname, "recipe-done", recipe.id, "", block.id) + :sprite("menu", defines.sprites.status_ok.black, defines.sprites.status_ok.black) + :style("helmod_button_menu_selected_green") + :tooltip({ "helmod_button.done" }) + ) else - GuiElement.add(gui_table, GuiButton(self.classname, "recipe-done", recipe.id):sprite("menu", defines.sprites.checkmark.black, defines.sprites.checkmark.black):style("helmod_button_menu_actived_green"):tooltip({"helmod_button.done"})) + GuiElement.add( + gui_table, + GuiButton(self.classname, "recipe-done", recipe.id,"", block.id) + :sprite("menu", defines.sprites.checkmark.black, defines.sprites.checkmark.black) + :style("helmod_button_menu_actived_green") + :tooltip({ "helmod_button.done" }) + ) end ---col recipe - local cell_recipe = GuiElement.add(gui_table, GuiFrameH("recipe", recipe.id):style(helmod_frame_style.hidden)) - local button_recipe = GuiCellRecipe("HMRecipeEdition", "OPEN", model.id, block.id, recipe.id):element(recipe):infoIcon(recipe.type):tooltip("tooltip.edit-recipe"):color(GuiElement.color_button_default):mask(is_done) + local cell_recipe = + GuiElement.add(gui_table, GuiFrameH("recipe", recipe.id, "", block.id):style(helmod_frame_style.hidden)) + local button_recipe = GuiCellRecipe("HMRecipeEdition", "OPEN", model.id, block.id, recipe.id) + :element(recipe) + :infoIcon(recipe.type) + :tooltip("tooltip.edit-recipe") + :color(GuiElement.color_button_default) + :mask(is_done) --local button_recipe = GuiCellRecipe(self.classname, "do_noting", "recipe"):element(recipe):infoIcon(recipe.type):tooltip("tooltip.info-product"):color(GuiElement.color_button_default):mask(is_done) GuiElement.add(cell_recipe, button_recipe) local by_limit = block.count ~= 1 if not(User.getSetting("pin_panel_column_hide_product")) then ---products - local cell_products = GuiElement.add(gui_table, GuiTable("products",recipe.id):column(3)) + local cell_products = GuiElement.add(gui_table, GuiTable("products",recipe.id, block.id):column(3)) cell_products.style.horizontally_stretchable = false local lua_products = recipe_prototype:getProducts(recipe.factory) if lua_products ~= nil then @@ -196,12 +225,21 @@ function PinPanel:addProductionBlockRow(gui_table, model, block, recipe) if not(User.getSetting("pin_panel_column_hide_machine")) then ---col factory local factory = recipe.factory - GuiElement.add(gui_table, GuiCellFactory(self.classname, "pipette-entity", recipe.id, "factory"):index(recipe.id):element(factory):tooltip("controls.smart-pipette"):color(GuiElement.color_button_default):byLimit(by_limit):mask(is_done)) + GuiElement.add( + gui_table, + GuiCellFactory(self.classname, "pipette-entity", recipe.id, "factory", block.id) + :index(recipe.id) + :element(factory) + :tooltip("controls.smart-pipette") + :color(GuiElement.color_button_default) + :byLimit(by_limit) + :mask(is_done) + ) end if not(User.getSetting("pin_panel_column_hide_product")) then ---ingredients - local cell_ingredients = GuiElement.add(gui_table, GuiTable("ingredients", recipe.id):column(3)) + local cell_ingredients = GuiElement.add(gui_table, GuiTable("ingredients", recipe.id, block.id):column(3)) cell_ingredients.style.horizontally_stretchable = false local lua_ingredients = recipe_prototype:getIngredients(recipe.factory) if lua_ingredients ~= nil then @@ -226,7 +264,7 @@ function PinPanel:addProductionBlockRow(gui_table, model, block, recipe) else beacon.limit_count = nil end - GuiElement.add(gui_table, GuiCellFactory(self.classname, "pipette-entity", recipe.id, "beacon"):index(recipe.id):element(beacon):tooltip("controls.smart-pipette"):color(GuiElement.color_button_default):byLimit(by_limit):mask(is_done)) + GuiElement.add(gui_table, GuiCellFactory(self.classname, "pipette-entity", recipe.id, "beacon", block.id):index(recipe.id):element(beacon):tooltip("controls.smart-pipette"):color(GuiElement.color_button_default):byLimit(by_limit):mask(is_done)) end end @@ -246,7 +284,12 @@ function PinPanel:onEvent(event) local model, block, recipe = self:getParameterObjects() - if block == nil then return end + if block == nil and (event.item3 ~= nil and event.item3:find("^block_")) then + block = model.blocks[event.item3] + end + if block == nil then + return + end if event.action == "pipette-entity" then local recipes = block.recipes diff --git a/dialog/ProductionPanel.lua b/dialog/ProductionPanel.lua index b093818e..e93323e5 100644 --- a/dialog/ProductionPanel.lua +++ b/dialog/ProductionPanel.lua @@ -341,6 +341,7 @@ function ProductionPanel:updateSubMenuLeftPanel(model, block) local group_tool = GuiElement.add(left_panel, GuiFlowH("group_tool")) group_tool.style.horizontal_spacing = button_spacing GuiElement.add(group_tool, GuiButton("HMSummaryPanel", "OPEN", model.id, block_id):sprite("menu", defines.sprites.list_view.black,defines.sprites.list_view.black):style("helmod_button_menu"):tooltip({"helmod_result-panel.tab-button-summary"})) + GuiElement.add(group_tool, GuiButton("HMPinPanel", "OPEN", model.id, block_id):sprite("menu", defines.sprites.push_pin.black, defines.sprites.push_pin.black):style("helmod_button_menu"):tooltip({"helmod_result-panel.tab-button-pin"})) if block ~= nil then ---unlinked button local linked_button @@ -359,7 +360,6 @@ function ProductionPanel:updateSubMenuLeftPanel(model, block) linked_button.tooltip = {"tooltip.block-cannot-link-by-factory"} end - GuiElement.add(group_tool, GuiButton("HMPinPanel", "OPEN", model.id, block_id):sprite("menu", defines.sprites.push_pin.black, defines.sprites.push_pin.black):style("helmod_button_menu"):tooltip({"helmod_result-panel.tab-button-pin"})) ---by limit if block.by_limit == true then