Skip to content

Commit

Permalink
Fixed open current block
Browse files Browse the repository at this point in the history
Fixed open current block
Fixed height data section
  • Loading branch information
Helfima committed Mar 24, 2019
1 parent a686717 commit ee4b0e3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
6 changes: 5 additions & 1 deletion controller/Controller.lua
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ function Controller.openMainPanel()
local lua_player = Player.native()
local location = Player.getSettings("display_location")
local globalGui = Player.getGlobalGui()
local model = Model.getModel()
local gui_main = lua_player.gui[location]
if Controller.isOpened() then
Controller.cleanController(Player.native())
Expand All @@ -591,7 +592,7 @@ function Controller.openMainPanel()
ui.menu = "HMMainMenuPanel"
ui.left = "HMLeftMenuPanel"
ui.data = "HMProductionLineTab"
if globalGui.currentBlock ~= nil then
if globalGui.currentBlock and model.blocks[globalGui.currentBlock] then
ui.data = "HMProductionBlockTab"
end
ui.dialog = helmod_tab_dialog[ui.data]
Expand Down Expand Up @@ -747,8 +748,10 @@ function Controller.onEventAccessAll(event, action, item, item2, item3)
if action == "change-model" then
globalGui.model_id = item
ui.data = "HMProductionLineTab"
ui.dialog = helmod_tab_dialog[ui.data]
globalGui.currentBlock = "new"
Event.force_refresh = true
Event.force_open = true
end

if action == "change-tab" then
Expand All @@ -757,6 +760,7 @@ function Controller.onEventAccessAll(event, action, item, item2, item3)
if item == "HMProductionLineTab" then
globalGui.currentBlock = "new"
end
ui.dialog = helmod_tab_dialog[ui.data]
globalGui.currentBlock = item2
Event.force_refresh = true
Event.force_open = true
Expand Down
20 changes: 19 additions & 1 deletion core/ElementGui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1380,8 +1380,9 @@ function ElementGui.getStyleSizes()


-- block
local row_number = math.floor(Model.countModel()/ElementGui.getIndexColumnNumber())
style_sizes.block_data = {}
style_sizes.block_data.height = height_main - 122
style_sizes.block_data.height = height_main - 122 - row_number*32

style_sizes.block_info = {}
style_sizes.block_info.width = width_block_info
Expand Down Expand Up @@ -1418,6 +1419,23 @@ function ElementGui.getStyleSizes()
return style_sizes
end

-------------------------------------------------------------------------------
-- Get Index column number
--
-- @function [parent=#ElementGui] getIndexColumnNumber
--
-- @param #LuaGuiElement element
-- @param #string style
-- @param #string property
--
function ElementGui.getIndexColumnNumber()

local display_ratio_horizontal = Player.getSettings("display_ratio_horizontal")
local width , height = ElementGui.getDisplaySizes()
local width_main = math.ceil(width*display_ratio_horizontal)

return math.ceil((width_main-650)/32)
end
-------------------------------------------------------------------------------
-- Set style
--
Expand Down
7 changes: 1 addition & 6 deletions dialog/MainMenuPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@ function MainMenuPanel.methods:getIndexPanel()
if parent_panel["index_panel"] ~= nil and parent_panel["index_panel"].valid then
return parent_panel["index_panel"]
end
local display_ratio_horizontal = Player.getSettings("display_ratio_horizontal")
local width , height = ElementGui.getDisplaySizes()
local width_main = math.ceil(width*display_ratio_horizontal)

local col_num = math.ceil((width_main-650)/32)
local panel = ElementGui.addGuiTable(parent_panel, "index_panel", col_num, helmod_table_style.list)
local panel = ElementGui.addGuiTable(parent_panel, "index_panel", ElementGui.getIndexColumnNumber(), helmod_table_style.list)
return 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.5",
"version": "0.8.6",
"title": "Helmod: assistant for planning your base.",
"author": "Helfima",
"contact": "Helfima",
Expand Down

0 comments on commit ee4b0e3

Please sign in to comment.