1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-09-16 09:06:21 +02:00

minor fix

This commit is contained in:
Gerkiz
2022-03-29 21:34:38 +02:00
parent b7315b5980
commit e5611d8a3c
5 changed files with 146 additions and 67 deletions

View File

@@ -13,10 +13,47 @@ local Event = require 'utils.event'
local Server = require 'utils.server'
local SpamProtection = require 'utils.spam_protection'
local Token = require 'utils.token'
local Global = require 'utils.global'
local Gui = require 'utils.gui'
local main_gui_tabs = {}
local Public = {}
local screen_elements = {}
local this = {
settings = {
mod_gui_top_frame = false
}
}
Global.register(
this,
function(tbl)
this = tbl
end
)
--- This adds the given gui to the top gui.
---@param player <userdata>
---@param frame <object>
---@param name <string>
function Public.add_mod_button(player, frame, name)
if Gui.get_button_flow(player)[name] then
return
end
Gui.get_button_flow(player).add(frame)
end
---@param state <bool>
--- If we should use the new mod gui or not
function Public.set_mod_gui_top_frame(state)
this.settings.mod_gui_top_frame = state or false
end
--- Get mod_gui_top_frame
function Public.get_mod_gui_top_frame()
return this.settings.mod_gui_top_frame
end
--- This adds the given gui to the main gui.
---@param tbl
@@ -108,14 +145,18 @@ function Public.comfy_panel_refresh_active_tab(player)
end
local function top_button(player)
if player.gui.top['comfy_panel_top_button'] then
return
if this.settings.mod_gui_top_frame then
Public.add_mod_button(player, {type = 'sprite-button', name = 'comfy_panel_top_button', sprite = 'item/raw-fish'}, 'comfy_panel_top_button')
else
if player.gui.top['comfy_panel_top_button'] then
return
end
local button = player.gui.top.add({type = 'sprite-button', name = 'comfy_panel_top_button', sprite = 'item/raw-fish'})
button.style.minimal_height = 38
button.style.maximal_height = 38
button.style.minimal_width = 40
button.style.padding = -2
end
local button = player.gui.top.add({type = 'sprite-button', name = 'comfy_panel_top_button', sprite = 'item/raw-fish'})
button.style.minimal_height = 38
button.style.maximal_height = 38
button.style.minimal_width = 40
button.style.padding = -2
end
local function main_frame(player)

View File

@@ -3,7 +3,7 @@ local Global = require 'utils.global'
local Event = require 'utils.event'
local Game = require 'utils.game'
local Server = require 'utils.server'
local Tabs = require 'comfy_panel.main'
local ComfyGui = require 'comfy_panel.main'
local session = require 'utils.datastore.session_data'
local Config = require 'comfy_panel.config'
local SpamProtection = require 'utils.spam_protection'
@@ -403,7 +403,7 @@ local function toggle(event)
if main_frame then
remove_main_frame(main_frame, left, event.player)
else
Tabs.comfy_panel_clear_gui(event.player)
ComfyGui.comfy_panel_clear_gui(event.player)
draw_main_frame(left, event.player)
end
end
@@ -766,21 +766,34 @@ local function player_joined(event)
return
end
if player.gui.top[main_button_name] ~= nil then
local frame = player.gui.top[main_frame_name]
if frame and frame.valid then
local data = Gui.get_data(frame)
update_poll_viewer(data)
end
if ComfyGui.get_mod_gui_top_frame() then
ComfyGui.add_mod_button(
player,
{
type = 'sprite-button',
name = main_button_name,
sprite = 'item/programmable-speaker',
tooltip = 'Let your question be heard!'
},
'main_button_name'
)
else
local b =
player.gui.top.add {
type = 'sprite-button',
name = main_button_name,
sprite = 'item/programmable-speaker',
tooltip = 'Let your question be heard!'
}
b.style.maximal_height = 38
if player.gui.top[main_button_name] ~= nil then
local frame = player.gui.top[main_frame_name]
if frame and frame.valid then
local data = Gui.get_data(frame)
update_poll_viewer(data)
end
else
local b =
player.gui.top.add {
type = 'sprite-button',
name = main_button_name,
sprite = 'item/programmable-speaker',
tooltip = 'Let your question be heard!'
}
b.style.maximal_height = 38
end
end
end

View File

@@ -1,6 +1,7 @@
local Event = require 'utils.event'
local Gui = require 'utils.gui'
local Server = require 'utils.server'
local ComfyGui = require 'comfy_panel.main'
local SpamProtection = require 'utils.spam_protection'
local main_frame_name = Gui.uid_name()
@@ -140,25 +141,38 @@ end
local function create_main_button(event)
local player = game.get_player(event.player_index)
local main_button = player.gui.top[main_button_name]
if not main_button or not main_button.valid then
main_button =
player.gui.top.add(
if ComfyGui.get_mod_gui_top_frame() then
ComfyGui.add_mod_button(
player,
{
type = 'sprite-button',
name = main_button_name,
sprite = 'utility/surface_editor_icon',
tooltip = 'Connect to another Comfy server!',
name = main_button_name
}
tooltip = 'Connect to another Comfy server!'
},
main_button_name
)
main_button.style.font_color = {r = 0.11, g = 0.8, b = 0.44}
main_button.style.font = 'heading-1'
main_button.style.minimal_height = 40
main_button.style.maximal_width = 40
main_button.style.minimal_width = 38
main_button.style.maximal_height = 38
main_button.style.padding = 1
main_button.style.margin = 0
else
local main_button = player.gui.top[main_button_name]
if not main_button or not main_button.valid then
main_button =
player.gui.top.add(
{
type = 'sprite-button',
sprite = 'utility/surface_editor_icon',
tooltip = 'Connect to another Comfy server!',
name = main_button_name
}
)
main_button.style.font_color = {r = 0.11, g = 0.8, b = 0.44}
main_button.style.font = 'heading-1'
main_button.style.minimal_height = 40
main_button.style.maximal_width = 40
main_button.style.minimal_width = 38
main_button.style.maximal_height = 38
main_button.style.padding = 1
main_button.style.margin = 0
end
end
end

View File

@@ -5,6 +5,7 @@ local Global = require 'utils.global'
local SpamProtection = require 'utils.spam_protection'
local Event = require 'utils.event'
local BottomFrame = require 'comfy_panel.bottom_frame'
local ComfyGui = require 'comfy_panel.main'
local floor = math.floor
local print_color = {r = 120, g = 255, b = 0}
@@ -537,22 +538,19 @@ local function auto_stash(player, event)
end
local function create_gui_button(player)
if player.gui.top.auto_stash then
return
end
local tooltip
if this.insert_into_furnace and this.insert_into_wagon then
tooltip =
'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nCTRL+RMB: Fill nearby furnaces.\nSHIFT+LMB: Everything onto filtered slots to wagon.\nSHIFT+RMB: Only ores to wagon'
elseif this.insert_into_furnace then
tooltip =
'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nCTRL+RMB: Fill nearby furnaces.'
tooltip = 'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nCTRL+RMB: Fill nearby furnaces.'
elseif this.insert_into_wagon then
tooltip =
'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nSHIFT+LMB: Everything onto filtered slots to wagon.\nSHIFT+RMB: Only ores to wagon'
tooltip = 'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.\nSHIFT+LMB: Everything onto filtered slots to wagon.\nSHIFT+RMB: Only ores to wagon'
else
tooltip =
'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.'
tooltip = 'Sort your inventory into nearby chests.\nLMB: Everything, excluding quickbar items.\nRMB: Only ores to nearby chests, excluding quickbar items.'
end
if player.gui.top.auto_stash then
return
end
if this.bottom_button then
local data = BottomFrame.get('bottom_quickbar_button')
@@ -568,23 +566,36 @@ local function create_gui_button(player)
end
end
else
local b =
player.gui.top.add(
{
type = 'sprite-button',
sprite = 'item/wooden-chest',
name = 'auto_stash',
tooltip = tooltip
}
)
b.style.font_color = {r = 0.11, g = 0.8, b = 0.44}
b.style.font = 'heading-1'
b.style.minimal_height = 40
b.style.maximal_width = 40
b.style.minimal_width = 38
b.style.maximal_height = 38
b.style.padding = 1
b.style.margin = 0
if ComfyGui.get_mod_gui_top_frame() then
ComfyGui.add_mod_button(
player,
{
type = 'sprite-button',
name = 'auto_stash',
sprite = 'item/wooden-chest',
tooltip = tooltip
},
'auto_stash'
)
else
local b =
player.gui.top.add(
{
type = 'sprite-button',
sprite = 'item/wooden-chest',
name = 'auto_stash',
tooltip = tooltip
}
)
b.style.font_color = {r = 0.11, g = 0.8, b = 0.44}
b.style.font = 'heading-1'
b.style.minimal_height = 40
b.style.maximal_width = 40
b.style.minimal_width = 38
b.style.maximal_height = 38
b.style.padding = 1
b.style.margin = 0
end
end
end

View File

@@ -236,10 +236,10 @@ local freeplay_interface = {
this.respawn_items = map or error("Remote call parameter to freeplay set respawn items can't be nil.")
end,
set_skip_intro = function(bool)
this.skip_intro = bool or error('Remote call parameter to freeplay set skip_intro must be bool')
this.skip_intro = bool
end,
set_disabled = function(bool)
this.disabled = bool or error('Remote call parameter to freeplay set disabled must be bool')
this.disabled = bool
end,
set_custom_surface_name = function(str)
this.custom_surface_name = str or error('Remote call parameter to freeplay set custom_surface_name must be string')
@@ -248,7 +248,7 @@ local freeplay_interface = {
this.chart_distance = tonumber(value) or error('Remote call parameter to freeplay set chart distance must be a number')
end,
set_disable_crashsite = function(bool)
this.disable_crashsite = bool or error('Remote call parameter to freeplay set disable_crashsite must be bool')
this.disable_crashsite = bool
end,
get_ship_items = function()
return this.crashed_ship_items