Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------------------------------------------------------------------------------------------------
Expand Down
83 changes: 63 additions & 20 deletions dialog/PinPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please explain to me what this is doing and why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no Block given, the pin function could be called from production line view. It checks if that pin-button contained information in item3 about the needed information to find the correct production line.

Would need to debug now, to see what exactly is saved in blocks. Can do that on Monday. Should have added comments, I guess it's because I added block _id's to the buttons. There was a good reason why I did that, just can't remember now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the pin-panel is opened without a block selected, but with the whole production line the block will always be nil.
So when for example using the pipet function, the block needs to be set. Item3 holds the block id which I double check, because when opening the pin-panel, block needs to be nil and item3 has a different string (if i remember correctly)

block = model.blocks[event.item3]
end
if block == nil then
return
end

if event.action == "pipette-entity" then
local recipes = block.recipes
Expand Down
2 changes: 1 addition & 1 deletion dialog/ProductionPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down