1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-01-18 03:21:47 +02:00

Merge pull request #1139 from grilledham/loader_gui_layout

Fix loader gui layout issue in multiplayer
This commit is contained in:
grilledham 2021-01-01 15:50:30 +00:00 committed by GitHub
commit 34223ffdd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -328,22 +328,26 @@ end
local function draw_loader_frame_for_player(parent, player)
local frame = parent[loader_crafter_frame_for_player_name]
if frame and frame.valid then
Gui.destroy(frame)
end
local recipes = player.force.recipes
if not any_loader_enabled(recipes) then
if frame and frame.valid then
Gui.destroy(frame)
end
return
end
local anchor = {gui = defines.relative_gui_type.controller_gui, position = defines.relative_gui_position.right}
frame = parent.add {
type = 'frame',
name = loader_crafter_frame_for_player_name,
anchor = anchor,
direction = 'vertical'
}
if frame and frame.valid then
Gui.clear(frame)
else
local anchor = {gui = defines.relative_gui_type.controller_gui, position = defines.relative_gui_position.right}
frame = parent.add {
type = 'frame',
name = loader_crafter_frame_for_player_name,
anchor = anchor,
direction = 'vertical'
}
end
if recipes['loader'].enabled then
local button = frame.add {
@ -378,25 +382,29 @@ end
local function draw_loader_frame_for_assembly_machine(parent, entity, player)
local frame = parent[loader_crafter_frame_for_assembly_machine_name]
if frame and frame.valid then
Gui.destroy(frame)
end
local recipes = player.force.recipes
if not any_loader_enabled(recipes) then
if frame and frame.valid then
Gui.destroy(frame)
end
return
end
local anchor = {
gui = defines.relative_gui_type.assembling_machine_select_recipe_gui,
position = defines.relative_gui_position.right
}
frame = parent.add {
type = 'frame',
name = loader_crafter_frame_for_assembly_machine_name,
anchor = anchor,
direction = 'vertical'
}
if frame and frame.valid then
Gui.clear(frame)
else
local anchor = {
gui = defines.relative_gui_type.assembling_machine_select_recipe_gui,
position = defines.relative_gui_position.right
}
frame = parent.add {
type = 'frame',
name = loader_crafter_frame_for_assembly_machine_name,
anchor = anchor,
direction = 'vertical'
}
end
if recipes['loader'].enabled then
local button = frame.add {
@ -532,12 +540,7 @@ if config.loaders then
local relative = player.gui.relative
local panel = relative[loader_crafter_frame_for_assembly_machine_name]
if panel and panel.valid then
Gui.destroy(panel)
end
panel = relative[loader_crafter_frame_for_player_name]
if panel and panel.valid then
Gui.destroy(panel)
Gui.remove_data_recursively(panel)
end
end)
end