mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-08 00:39:30 +02:00
Merge pull request #445 from ComfyFactory/gui-changes
Minor changes to gui elements
This commit is contained in:
commit
6f14be3228
@ -117,6 +117,7 @@ function Public.reset_map()
|
||||
local this = Public.get()
|
||||
local wave_defense_table = WD.get_table()
|
||||
Misc.reset()
|
||||
Misc.bottom_button(true)
|
||||
|
||||
LinkedChests.reset()
|
||||
|
||||
|
@ -55,11 +55,6 @@ local on_init_token =
|
||||
end
|
||||
|
||||
this.tooltip = tooltip
|
||||
if this.bottom_button then
|
||||
local data = BottomFrame.get('bottom_quickbar_button_data')
|
||||
data.sprite = 'item/wooden-chest'
|
||||
data.tooltip = tooltip
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
@ -83,6 +78,7 @@ local delay_tooltip_token =
|
||||
frame.tooltip = this.tooltip
|
||||
end
|
||||
end
|
||||
BottomFrame.add_inner_frame({player = player, element_name = auto_stash_button_name, tooltip = this.tooltip, sprite = 'item/wooden-chest'})
|
||||
end
|
||||
)
|
||||
|
||||
@ -504,16 +500,16 @@ local function auto_stash(player, event)
|
||||
local ctrl = event.control
|
||||
local shift = event.shift
|
||||
if not player.character then
|
||||
player.print(module_name 'It seems that you are not in the realm of the living.', Color.warning)
|
||||
player.print(module_name .. 'It seems that you are not in the realm of the living.', Color.warning)
|
||||
return
|
||||
end
|
||||
if not player.character.valid then
|
||||
player.print(module_name 'It seems that you are not in the realm of the living.', Color.warning)
|
||||
player.print(module_name .. 'It seems that you are not in the realm of the living.', Color.warning)
|
||||
return
|
||||
end
|
||||
local inventory = player.get_main_inventory()
|
||||
if inventory.is_empty() then
|
||||
player.print(module_name 'Inventory is empty.', Color.warning)
|
||||
player.print(module_name .. 'Inventory is empty.', Color.warning)
|
||||
return
|
||||
end
|
||||
|
||||
@ -692,8 +688,9 @@ end
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.get_player(event.player_index)
|
||||
create_gui_button(player)
|
||||
Task.delay(delay_tooltip_token, {player_index = player.index})
|
||||
BottomFrame.add_inner_frame({player = player, element_name = auto_stash_button_name, tooltip = this.tooltip, sprite = 'item/wooden-chest'})
|
||||
if this.bottom_button then
|
||||
Task.delay(delay_tooltip_token, {player_index = player.index})
|
||||
end
|
||||
end
|
||||
|
||||
Gui.on_click(
|
||||
|
@ -10,7 +10,7 @@ local SpamProtection = require 'utils.spam_protection'
|
||||
|
||||
local this = {
|
||||
players = {},
|
||||
activate_custom_buttons = false
|
||||
bottom_button = false
|
||||
}
|
||||
|
||||
Global.register(
|
||||
@ -472,7 +472,7 @@ local function create_clear_corpse_frame(player, bottom_frame_data)
|
||||
button.style.margin = 0
|
||||
end
|
||||
|
||||
if bottom_frame_data ~= nil and not bottom_frame_data.top then
|
||||
if this.bottom_button and bottom_frame_data ~= nil and not bottom_frame_data.top then
|
||||
if button and button.valid then
|
||||
button.destroy()
|
||||
end
|
||||
@ -517,13 +517,20 @@ function Public.reset()
|
||||
this.players = {}
|
||||
end
|
||||
|
||||
function Public.bottom_button(value)
|
||||
this.bottom_button = value or false
|
||||
end
|
||||
|
||||
Event.add(
|
||||
defines.events.on_player_joined_game,
|
||||
function(event)
|
||||
local player = game.players[event.player_index]
|
||||
on_player_joined_game(player)
|
||||
create_clear_corpse_frame(player)
|
||||
BottomFrame.add_inner_frame({player = player, element_name = clear_corpse_button_name, tooltip = {'commands.clear_corpse'}, sprite = 'entity/behemoth-biter'})
|
||||
|
||||
if this.bottom_button then
|
||||
BottomFrame.add_inner_frame({player = player, element_name = clear_corpse_button_name, tooltip = {'commands.clear_corpse'}, sprite = 'entity/behemoth-biter'})
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
|
@ -47,7 +47,7 @@ Event.add(
|
||||
end
|
||||
|
||||
local secs = Server.get_current_time()
|
||||
if secs == nil then
|
||||
if secs == nil or secs == false then
|
||||
return
|
||||
else
|
||||
try_get_ban(player.name, try_get_is_banned_token)
|
||||
|
@ -30,7 +30,7 @@ local fetch =
|
||||
-- @param data_set player token
|
||||
function Public.fetch(key)
|
||||
local secs = Server.get_current_time()
|
||||
if secs == nil then
|
||||
if secs == nil or secs == false then
|
||||
return
|
||||
else
|
||||
try_get_data(color_data_set, key, fetch)
|
||||
|
@ -171,7 +171,7 @@ function Public.try_dl_resets()
|
||||
end
|
||||
|
||||
local secs = Server.get_current_time()
|
||||
if secs == nil then
|
||||
if secs == nil or secs == false then
|
||||
return
|
||||
else
|
||||
try_get_data(this.settings.dataset, this.settings.reset_key, try_download_amount_of_resets_token)
|
||||
@ -187,7 +187,7 @@ function Public.try_dl_data(key)
|
||||
|
||||
key = tostring(key)
|
||||
local secs = Server.get_current_time()
|
||||
if secs == nil then
|
||||
if secs == nil or secs == false then
|
||||
return
|
||||
else
|
||||
try_get_data(this.settings.dataset, key, try_download_data_token)
|
||||
@ -203,7 +203,7 @@ function Public.try_ul_data(key)
|
||||
|
||||
key = tostring(key)
|
||||
local secs = Server.get_current_time()
|
||||
if secs == nil then
|
||||
if secs == nil or secs == false then
|
||||
return
|
||||
else
|
||||
try_get_data(this.settings.dataset, key, try_upload_data_token)
|
||||
|
@ -213,7 +213,7 @@ function Public.get_and_print_to_player(player, target_player)
|
||||
end
|
||||
|
||||
local secs = Server.get_current_time()
|
||||
if secs == nil then
|
||||
if secs == nil or secs == false then
|
||||
return
|
||||
else
|
||||
try_get_data_and_print(session_data_set, target_player, player.name, get_total_playtime_token)
|
||||
@ -225,7 +225,7 @@ end
|
||||
function Public.try_dl_data(player_index)
|
||||
player_index = tostring(player_index)
|
||||
local secs = Server.get_current_time()
|
||||
if secs == nil then
|
||||
if secs == nil or secs == false then
|
||||
session[player_index] = game.get_player(player_index).online_time
|
||||
return
|
||||
else
|
||||
@ -238,7 +238,7 @@ end
|
||||
function Public.try_ul_data(player_index)
|
||||
player_index = tostring(player_index)
|
||||
local secs = Server.get_current_time()
|
||||
if secs == nil then
|
||||
if secs == nil or secs == false then
|
||||
return
|
||||
else
|
||||
try_get_data(session_data_set, player_index, try_upload_data_token)
|
||||
|
@ -6,13 +6,11 @@ local Server = require 'utils.server'
|
||||
local try_get_data = Server.try_get_data
|
||||
-- local set_data = Server.set_data
|
||||
|
||||
|
||||
local this = {
|
||||
players = {},
|
||||
storage = {},
|
||||
activate_custom_buttons = false,
|
||||
bottom_quickbar_button = {},
|
||||
bottom_quickbar_button_data = {}
|
||||
bottom_quickbar_button = {}
|
||||
}
|
||||
|
||||
Global.register(
|
||||
@ -34,6 +32,8 @@ local Public = {
|
||||
}
|
||||
|
||||
local set_location
|
||||
local destroy_frame
|
||||
local remove_player
|
||||
local get_player_data
|
||||
local bottom_dataset = 'bottom_frame_data'
|
||||
|
||||
@ -81,7 +81,25 @@ local restore_bottom_location_token =
|
||||
end
|
||||
)
|
||||
|
||||
local function remove_player(index)
|
||||
local check_bottom_buttons_token =
|
||||
Task.register(
|
||||
function(event)
|
||||
local player_index = event.player_index
|
||||
local player = game.get_player(player_index)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local player_data, storage_data = get_player_data(player)
|
||||
if not player_data or not storage_data or not next(storage_data) then
|
||||
destroy_frame(player)
|
||||
remove_player(player.index)
|
||||
return
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
remove_player = function(index)
|
||||
this.players[index] = nil
|
||||
this.storage[index] = nil
|
||||
this.bottom_quickbar_button[index] = nil
|
||||
@ -155,6 +173,19 @@ local function refresh_inner_frames(player)
|
||||
end
|
||||
end
|
||||
|
||||
local refresh_inner_frames_token =
|
||||
Task.register(
|
||||
function(event)
|
||||
local player_index = event.player_index
|
||||
local player = game.get_player(player_index)
|
||||
if not player or not player.valid then
|
||||
return
|
||||
end
|
||||
|
||||
refresh_inner_frames(player)
|
||||
end
|
||||
)
|
||||
|
||||
---Adds a new inner frame to the bottom frame
|
||||
-- local BottomFrame = require 'utils.gui.bottom_frame'
|
||||
-- BottomFrame.add_inner_frame({player = player, element_name = Gui.uid_name(), tooltip = 'Some tooltip', sprite = 'item/raw-fish' })
|
||||
@ -217,9 +248,10 @@ local function add_inner_frame(data)
|
||||
player_data.row_selection = player_data.row_selection + 1
|
||||
player_data.row_selection_added = player_data.row_selection_added + 1
|
||||
player_data.row_selection = player_data.row_selection > 2 and 1 or player_data.row_selection
|
||||
Task.priority_delay(2, refresh_inner_frames_token, {player_index = player.index})
|
||||
end
|
||||
|
||||
local function destroy_frame(player)
|
||||
destroy_frame = function(player)
|
||||
local gui = player.gui
|
||||
local frame = gui.screen[main_frame_name]
|
||||
if frame and frame.valid then
|
||||
@ -287,6 +319,8 @@ local function create_frame(player, alignment, location, data)
|
||||
data.section_data = data.section_data or {}
|
||||
data.alignment = alignment
|
||||
|
||||
Task.priority_delay(5, check_bottom_buttons_token, {player_index = player.index})
|
||||
|
||||
return frame
|
||||
end
|
||||
|
||||
|
@ -1552,6 +1552,11 @@ Event.add(
|
||||
return
|
||||
end
|
||||
|
||||
local secs = server_time.secs
|
||||
if secs == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
output_data(player_join_tag .. player.name)
|
||||
end
|
||||
)
|
||||
@ -1578,6 +1583,11 @@ Event.add(
|
||||
return
|
||||
end
|
||||
|
||||
local secs = server_time.secs
|
||||
if secs == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
local reason = leave_reason_map[event.reason] or ''
|
||||
output_data(player_leave_tag .. player.name .. reason)
|
||||
end
|
||||
@ -1592,6 +1602,11 @@ Event.add(
|
||||
return
|
||||
end
|
||||
|
||||
local secs = server_time.secs
|
||||
if secs == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
local cause = event.cause
|
||||
|
||||
local message = {discord_bold_tag, player.name}
|
||||
|
Loading…
Reference in New Issue
Block a user