Skip to content

Commit

Permalink
fixed some panel
Browse files Browse the repository at this point in the history
fixed some panel
removed mining power
  • Loading branch information
Helfima committed Mar 1, 2019
1 parent 33cefa3 commit fdd5c3c
Show file tree
Hide file tree
Showing 17 changed files with 112 additions and 58 deletions.
8 changes: 4 additions & 4 deletions controller/Controller.lua
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ function Controller.sendEvent(event, classname, action, item, item2, item3)
form.state = form.STATE_OPEN
form:onEvent(event, action, item, item2, item3)
end
if action == "OPEN" then
--if action == "OPEN" then
if form.state == form.STATE_OPEN then
Logging:debug(Controller.classname, "*** Open", form:classname(), form.state)
form:beforeOpen(event, action, item, item2, item3)
Expand All @@ -310,9 +310,9 @@ function Controller.sendEvent(event, classname, action, item, item2, item3)
form.state = form.STATE_EVENT
form:update(event, action, item, item2, item3)
end
else
form.state = form.STATE_EVENT
end
-- else
-- form.state = form.STATE_EVENT
-- end
end
Logging:debug(Controller.classname, "form state end", form:classname(), form.state)
-- release state in the event without stage
Expand Down
50 changes: 44 additions & 6 deletions core/ElementGui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,27 @@ function ElementGui.addGuiButton(parent, action, key, style, caption, tooltip)
return button
end

-------------------------------------------------------------------------------
-- Add a button element
--
-- @function [parent=#ElementGui] addGuiShortButton
--
-- @param #LuaGuiElement parent container for element
-- @param #string action action name
-- @param #string key unique id
-- @param #string style style of button
-- @param #string caption container for element
-- @param #string tooltip displayed text
--
-- @return #LuaGuiElement the LuaGuiElement added
--
function ElementGui.addGuiShortButton(parent, action, key, style, caption, tooltip)
Logging:trace(ElementGui.classname, "addGuiButton", parent, action, key, style, caption, tooltip)
local button = ElementGui.addGuiButton(parent, action, key, style, caption, tooltip)
button.style.width = 20
return button
end

-------------------------------------------------------------------------------
-- Add a choose element button
--
Expand Down Expand Up @@ -749,7 +770,6 @@ end
-- @param #string key unique id
-- @param #string style style of frame
-- @param #boolean policy scroll horizontally
-- @param #boolean stretchable horizontally
--
-- @return #LuaGuiElement the LuaGuiElement added
--
Expand All @@ -764,7 +784,6 @@ function ElementGui.addGuiScrollPane(parent, key, style, policy)
options.name = key
options.style = style
local scroll = parent.add(options)
--scroll.style.horizontally_stretchable = true
return scroll
end

Expand Down Expand Up @@ -1173,11 +1192,11 @@ function ElementGui.getStyleSizes()
local width , height = ElementGui.getDisplaySizes()
local style_sizes = {}
if type(width) == "number" and type(height) == "number" then
local width_recipe_column_1 = 220
local width_recipe_column_2 = 220
local width_dialog = width_recipe_column_1 + width_recipe_column_2 + 70
local width_recipe_column_1 = 240
local width_recipe_column_2 = 250
local width_dialog = width_recipe_column_1 + width_recipe_column_2
local width_scroll = 8
local width_block_info = 290
local width_block_info = 320
local height_block_header = 450
local height_selector_header = 230
local height_row_element = 110
Expand All @@ -1198,12 +1217,19 @@ function ElementGui.getStyleSizes()
style_sizes.power = {}
style_sizes.power.height = 200

style_sizes.edition_product_tool = {}
style_sizes.edition_product_tool.height = 150

style_sizes.data_section = {}
style_sizes.data_section.width = width_main - width_dialog - 4*width_scroll

style_sizes.recipe_selector = {}
style_sizes.recipe_selector.height = height_main - height_selector_header

style_sizes.scroll_recipe_selector = {}
style_sizes.scroll_recipe_selector.width = width_dialog - 20
style_sizes.scroll_recipe_selector.height = height_main - height_selector_header - 20

style_sizes.recipe_product = {}
style_sizes.recipe_product.height = 77

Expand All @@ -1214,6 +1240,9 @@ function ElementGui.getStyleSizes()
style_sizes.recipe_module.width = width_recipe_column_2 - width_scroll*2
style_sizes.recipe_module.height = 147

style_sizes.recipe_info_object = {}
style_sizes.recipe_info_object.height = 155

style_sizes.recipe_edition_1 = {}
style_sizes.recipe_edition_1.width = width_recipe_column_1
style_sizes.recipe_edition_1.height = 250
Expand All @@ -1225,13 +1254,22 @@ function ElementGui.getStyleSizes()
style_sizes.scroll_help.width = width_dialog - width_scroll - 50
style_sizes.scroll_help.height = height_main - 200


-- block
style_sizes.block_data = {}
style_sizes.block_data.height = height_main - 122 - height_row_element * 2

style_sizes.block_info = {}
style_sizes.block_info.width = width_block_info
style_sizes.block_info.height = (height_row_element) * 2 + 4

style_sizes.scroll_block = {}
style_sizes.scroll_block.height = (height_row_element) * 2 - 34

-- input/output table
style_sizes.block_element = {}
style_sizes.block_element.height = height_row_element
style_sizes.block_element.width = width_main - width_dialog - width_block_info

-- input/output table
style_sizes.scroll_block_element = {}
Expand Down
8 changes: 5 additions & 3 deletions core/Form.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ function Form.methods:getPanel()
if parent_panel[self:classname()] ~= nil and parent_panel[self:classname()].valid then
return parent_panel[self:classname()]
end
return ElementGui.addGuiTable(parent_panel, self:classname(), 1, helmod_table_style.panel)
--local panel = ElementGui.addGuiTable(parent_panel, self:classname(), 1, helmod_table_style.panel)
local panel = ElementGui.addGuiFrameV(parent_panel, self:classname(), helmod_frame_style.hidden, caption)
return panel
end

-------------------------------------------------------------------------------
Expand Down Expand Up @@ -116,8 +118,8 @@ function Form.methods:open(event, action, item, item2, item3)

local panel = self:getPanel()

ElementGui.addGuiFrameH(panel, "header-panel", helmod_frame_style.panel, caption)

local header_panel = ElementGui.addGuiFrameH(panel, "header-panel", helmod_frame_style.panel, caption)
header_panel.style.height = 30
self:onOpen(event, action, item, item2, item3)
self:afterOpen(event, action, item, item2, item3)

Expand Down
4 changes: 2 additions & 2 deletions core/MainPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ function MainPanel.methods:getDataPanel()
end
local panel = ElementGui.addGuiFrameV(main_panel, "helmod_data_panel", helmod_frame_style.hidden)
ElementGui.setStyle(panel, "data", "width")
panel.style.vertically_stretchable = true
--panel.style.vertically_stretchable = false
local table_panel = ElementGui.addGuiTable(panel, "helmod_data_table", 1, helmod_table_style.panel)
--table_panel.draw_horizontal_lines = true
--table_panel.style.vertically_stretchable = false
return table_panel
end

Expand Down
3 changes: 1 addition & 2 deletions core/ModelCompute.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1168,10 +1168,9 @@ function ModelCompute.speedFactory(recipe)
-- (mining power - ore mining hardness) * mining speed
-- @see https://wiki.factorio.com/Mining
local mining_speed = EntityPrototype.load(recipe.factory).getMiningSpeed()
local mining_power = EntityPrototype.load(recipe.factory).getMiningPower()
local hardness = EntityPrototype.load(recipe.name).getMineableHardness()
local mining_time = EntityPrototype.load(recipe.name).getMineableMiningTime()
return (mining_power - hardness) * mining_speed / mining_time
return hardness * mining_speed / mining_time
elseif recipe.type == "technology" then
local bonus = Player.getForce().laboratory_speed_modifier or 1
return 1*bonus
Expand Down
13 changes: 10 additions & 3 deletions edition/ProductEdition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ function ProductEdition.methods:getInfoPanel()
if panel["info"] ~= nil and panel["info"].valid then
return panel["info"]
end
return ElementGui.addGuiFrameV(panel, "info", helmod_frame_style.panel)
local info_panel = ElementGui.addGuiFrameV(panel, "info", helmod_frame_style.panel)
info_panel.style.horizontally_stretchable = true
return info_panel
end

-------------------------------------------------------------------------------
Expand All @@ -85,7 +87,10 @@ function ProductEdition.methods:getToolPanel()
if panel["tool_panel"] ~= nil and panel["tool_panel"].valid then
return panel["tool_panel"]
end
return ElementGui.addGuiFrameV(panel, "tool_panel", helmod_frame_style.panel, {"helmod_product-edition-panel.tool"})
local tool_panel = ElementGui.addGuiFrameV(panel, "tool_panel", helmod_frame_style.panel, {"helmod_product-edition-panel.tool"})
tool_panel.style.horizontally_stretchable = true
ElementGui.setStyle(tool_panel, "edition_product_tool", "height")
return tool_panel
end

-------------------------------------------------------------------------------
Expand All @@ -98,7 +103,9 @@ function ProductEdition.methods:getActionPanel()
if panel["action_panel"] ~= nil and panel["action_panel"].valid then
return panel["action_panel"]
end
return ElementGui.addGuiFrameV(panel, "action_panel", helmod_frame_style.panel)
local action_panel = ElementGui.addGuiFrameV(panel, "action_panel", helmod_frame_style.panel)
action_panel.style.horizontally_stretchable = true
return action_panel
end

-------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions edition/RecipeEdition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function RecipeEdition.methods:getRecipePanel()
return panel["recipe_panel"]
end
local table_panel = ElementGui.addGuiTable(panel, "recipe_panel", 2, helmod_table_style.panel)
ElementGui.setStyle(table_panel, "recipe_info_object", "height")
return table_panel
end

Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "helmod",
"version": "0.8.0",
"version": "0.8.1",
"title": "Helmod: assistant for planning your base.",
"author": "Helfima",
"contact": "Helfima",
Expand Down
14 changes: 0 additions & 14 deletions model/EntityPrototype.lua
Original file line number Diff line number Diff line change
Expand Up @@ -274,20 +274,6 @@ function EntityPrototype.getMiningSpeed()
return 0
end

-------------------------------------------------------------------------------
-- Return mining power
--
-- @function [parent=#EntityPrototype] getMiningPower
--
-- @return #number default 0
--
function EntityPrototype.getMiningPower()
if lua_entity_prototype ~= nil then
return lua_entity_prototype.mining_power or 0
end
return 0
end

-------------------------------------------------------------------------------
-- Return energy type (electrical or burner)
--
Expand Down
3 changes: 1 addition & 2 deletions model/Model.lua
Original file line number Diff line number Diff line change
Expand Up @@ -764,8 +764,7 @@ function Model.getSpeedFactory(key)
local crafting_speed = EntityPrototype.load(key).getCraftingSpeed()
if crafting_speed ~= 0 then return crafting_speed end
local mining_speed = EntityPrototype.load(key).getMiningSpeed()
local mining_power = EntityPrototype.load(key).getMiningPower()
if mining_speed ~= 0 and mining_power ~= 0 then return mining_speed * mining_power end
if mining_speed ~= 0 then return mining_speed end
return 1
end

Expand Down
5 changes: 2 additions & 3 deletions model/RecipePrototype.lua
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,9 @@ function RecipePrototype.getIngredients(factory)
local energy_usage = EntityPrototype.getEnergyUsage()
local burner_effectivity = EntityPrototype.getBurnerEffectivity()
local mining_speed = EntityPrototype.getMiningSpeed()
local mining_power = EntityPrototype.getMiningPower()
Logging:debug(RecipePrototype.classname, "factory properties", "energy_usage", energy_usage, "burner_effectivity", burner_effectivity, "mining_speed", mining_speed, "mining_power", mining_power)
Logging:debug(RecipePrototype.classname, "factory properties", "energy_usage", energy_usage, "burner_effectivity", burner_effectivity, "mining_speed", mining_speed)

local speed_factory = (mining_power - hardness) * mining_speed / mining_time
local speed_factory = hardness * mining_speed / mining_time
local fuel_value = energy_usage*speed_factory*12.5
local burner_count = fuel_value/energy_coal
local burner_ingredient = {name="coal", type="item", amount=burner_count}
Expand Down
5 changes: 2 additions & 3 deletions prototypes/style.lua
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,6 @@ for _,style in pairs(style_list) do
}
end
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Style of button
--
-- @field [parent=#Button] small_bold
Expand All @@ -458,7 +457,7 @@ default_gui["helmod_button_small_bold"] = {
-------------------------------------------------------------------------------
-- Style of button
--
-- @field [parent=#Button] small-bold-start
-- @field [parent=#Button] small_bold_start

default_gui["helmod_button_small_bold_start"] = {
type = "button_style",
Expand All @@ -477,7 +476,7 @@ default_gui["helmod_button_small_bold_start"] = {
-------------------------------------------------------------------------------
-- Style of button
--
-- @field [parent=#Button] small-bold-middle
-- @field [parent=#Button] small_bold_middle

default_gui["helmod_button_small_bold_middle"] = {
type = "button_style",
Expand Down
3 changes: 3 additions & 0 deletions selector/AbstractSelector.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,11 @@ function AbstractSelector.methods:getSrollPanel()
return panel["main_panel"]["scroll_panel"]
end
local main_panel = ElementGui.addGuiFrameV(panel, "main_panel", helmod_frame_style.panel)
ElementGui.setStyle(main_panel, "dialog", "width")
ElementGui.setStyle(main_panel, "recipe_selector", "height")
local scroll_panel = ElementGui.addGuiScrollPane(main_panel, "scroll_panel", helmod_frame_style.scroll_recipe_selector)
ElementGui.setStyle(scroll_panel, "scroll_recipe_selector", "width")
ElementGui.setStyle(scroll_panel, "scroll_recipe_selector", "height")
return scroll_panel
end

Expand Down
22 changes: 19 additions & 3 deletions tab/MainTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function MainTab.methods:getMenuPanel()
return parent_panel["menu_panel"]
end
local panel = ElementGui.addGuiFrameV(parent_panel, "menu_panel", helmod_frame_style.panel)
ElementGui.setStyle(panel, "data", "width")
return panel
end

Expand Down Expand Up @@ -150,7 +151,7 @@ function MainTab.methods:getInfoPanel()
return parent_panel["info_panel"]
end
local table_panel = ElementGui.addGuiTable(parent_panel, "info_panel", 2, helmod_table_style.panel)
table_panel.style.horizontally_stretchable = true
ElementGui.setStyle(table_panel, "block_info", "height")
return table_panel
end

Expand Down Expand Up @@ -187,6 +188,22 @@ function MainTab.methods:getResultScrollPanel(caption)
return scroll_panel
end

-------------------------------------------------------------------------------
-- Get or create result scroll panel
--
-- @function [parent=#MainTab] getResultScrollPanel
--
-- @param #string caption
--
function MainTab.methods:getDataScrollPanel(caption)
local result_panel = self:getResultPanel(caption)
ElementGui.setStyle(result_panel, "block_data", "height")
local scroll_panel = ElementGui.addGuiScrollPane(result_panel, "scroll-data", helmod_frame_style.scroll_pane, true, true)
scroll_panel.style.horizontally_stretchable = true
scroll_panel.style.vertically_stretchable = true
return scroll_panel
end

-------------------------------------------------------------------------------
-- Build the parent panel
--
Expand Down Expand Up @@ -722,7 +739,6 @@ function MainTab.methods:updateHeaderPanel(item, item2, item3)
ElementGui.addGuiButton(tab_menu_panel, self:classname().."=change-tab=ID=", tab:classname(), style, tab:getButtonCaption())
end
end
ElementGui.addGuiFrameH(tab_menu_panel,"tab_final",helmod_frame_style.tab).style.width = 1000
-- action panel
local action_panel = self:getActionPanel()

Expand Down Expand Up @@ -802,7 +818,7 @@ function MainTab.methods:updateHeaderPanel(item, item2, item3)

end
end
ElementGui.addGuiButton(index_panel, self:classname().."=change-model=ID=", "new", "helmod_button_default", "+")
ElementGui.addGuiShortButton(index_panel, self:classname().."=change-model=ID=", "new", "helmod_button_default", "+")
end
end

Expand Down
Loading

0 comments on commit fdd5c3c

Please sign in to comment.