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 this = Public.get()
|
||||||
local wave_defense_table = WD.get_table()
|
local wave_defense_table = WD.get_table()
|
||||||
Misc.reset()
|
Misc.reset()
|
||||||
|
Misc.bottom_button(true)
|
||||||
|
|
||||||
LinkedChests.reset()
|
LinkedChests.reset()
|
||||||
|
|
||||||
|
@ -55,11 +55,6 @@ local on_init_token =
|
|||||||
end
|
end
|
||||||
|
|
||||||
this.tooltip = tooltip
|
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
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -83,6 +78,7 @@ local delay_tooltip_token =
|
|||||||
frame.tooltip = this.tooltip
|
frame.tooltip = this.tooltip
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
BottomFrame.add_inner_frame({player = player, element_name = auto_stash_button_name, tooltip = this.tooltip, sprite = 'item/wooden-chest'})
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -504,16 +500,16 @@ local function auto_stash(player, event)
|
|||||||
local ctrl = event.control
|
local ctrl = event.control
|
||||||
local shift = event.shift
|
local shift = event.shift
|
||||||
if not player.character then
|
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
|
return
|
||||||
end
|
end
|
||||||
if not player.character.valid then
|
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
|
return
|
||||||
end
|
end
|
||||||
local inventory = player.get_main_inventory()
|
local inventory = player.get_main_inventory()
|
||||||
if inventory.is_empty() then
|
if inventory.is_empty() then
|
||||||
player.print(module_name 'Inventory is empty.', Color.warning)
|
player.print(module_name .. 'Inventory is empty.', Color.warning)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -692,8 +688,9 @@ end
|
|||||||
local function on_player_joined_game(event)
|
local function on_player_joined_game(event)
|
||||||
local player = game.get_player(event.player_index)
|
local player = game.get_player(event.player_index)
|
||||||
create_gui_button(player)
|
create_gui_button(player)
|
||||||
Task.delay(delay_tooltip_token, {player_index = player.index})
|
if this.bottom_button then
|
||||||
BottomFrame.add_inner_frame({player = player, element_name = auto_stash_button_name, tooltip = this.tooltip, sprite = 'item/wooden-chest'})
|
Task.delay(delay_tooltip_token, {player_index = player.index})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Gui.on_click(
|
Gui.on_click(
|
||||||
|
@ -10,7 +10,7 @@ local SpamProtection = require 'utils.spam_protection'
|
|||||||
|
|
||||||
local this = {
|
local this = {
|
||||||
players = {},
|
players = {},
|
||||||
activate_custom_buttons = false
|
bottom_button = false
|
||||||
}
|
}
|
||||||
|
|
||||||
Global.register(
|
Global.register(
|
||||||
@ -472,7 +472,7 @@ local function create_clear_corpse_frame(player, bottom_frame_data)
|
|||||||
button.style.margin = 0
|
button.style.margin = 0
|
||||||
end
|
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
|
if button and button.valid then
|
||||||
button.destroy()
|
button.destroy()
|
||||||
end
|
end
|
||||||
@ -517,13 +517,20 @@ function Public.reset()
|
|||||||
this.players = {}
|
this.players = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Public.bottom_button(value)
|
||||||
|
this.bottom_button = value or false
|
||||||
|
end
|
||||||
|
|
||||||
Event.add(
|
Event.add(
|
||||||
defines.events.on_player_joined_game,
|
defines.events.on_player_joined_game,
|
||||||
function(event)
|
function(event)
|
||||||
local player = game.players[event.player_index]
|
local player = game.players[event.player_index]
|
||||||
on_player_joined_game(player)
|
on_player_joined_game(player)
|
||||||
create_clear_corpse_frame(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
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ Event.add(
|
|||||||
end
|
end
|
||||||
|
|
||||||
local secs = Server.get_current_time()
|
local secs = Server.get_current_time()
|
||||||
if secs == nil then
|
if secs == nil or secs == false then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
try_get_ban(player.name, try_get_is_banned_token)
|
try_get_ban(player.name, try_get_is_banned_token)
|
||||||
|
@ -30,7 +30,7 @@ local fetch =
|
|||||||
-- @param data_set player token
|
-- @param data_set player token
|
||||||
function Public.fetch(key)
|
function Public.fetch(key)
|
||||||
local secs = Server.get_current_time()
|
local secs = Server.get_current_time()
|
||||||
if secs == nil then
|
if secs == nil or secs == false then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
try_get_data(color_data_set, key, fetch)
|
try_get_data(color_data_set, key, fetch)
|
||||||
|
@ -171,7 +171,7 @@ function Public.try_dl_resets()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local secs = Server.get_current_time()
|
local secs = Server.get_current_time()
|
||||||
if secs == nil then
|
if secs == nil or secs == false then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
try_get_data(this.settings.dataset, this.settings.reset_key, try_download_amount_of_resets_token)
|
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)
|
key = tostring(key)
|
||||||
local secs = Server.get_current_time()
|
local secs = Server.get_current_time()
|
||||||
if secs == nil then
|
if secs == nil or secs == false then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
try_get_data(this.settings.dataset, key, try_download_data_token)
|
try_get_data(this.settings.dataset, key, try_download_data_token)
|
||||||
@ -203,7 +203,7 @@ function Public.try_ul_data(key)
|
|||||||
|
|
||||||
key = tostring(key)
|
key = tostring(key)
|
||||||
local secs = Server.get_current_time()
|
local secs = Server.get_current_time()
|
||||||
if secs == nil then
|
if secs == nil or secs == false then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
try_get_data(this.settings.dataset, key, try_upload_data_token)
|
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
|
end
|
||||||
|
|
||||||
local secs = Server.get_current_time()
|
local secs = Server.get_current_time()
|
||||||
if secs == nil then
|
if secs == nil or secs == false then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
try_get_data_and_print(session_data_set, target_player, player.name, get_total_playtime_token)
|
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)
|
function Public.try_dl_data(player_index)
|
||||||
player_index = tostring(player_index)
|
player_index = tostring(player_index)
|
||||||
local secs = Server.get_current_time()
|
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
|
session[player_index] = game.get_player(player_index).online_time
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
@ -238,7 +238,7 @@ end
|
|||||||
function Public.try_ul_data(player_index)
|
function Public.try_ul_data(player_index)
|
||||||
player_index = tostring(player_index)
|
player_index = tostring(player_index)
|
||||||
local secs = Server.get_current_time()
|
local secs = Server.get_current_time()
|
||||||
if secs == nil then
|
if secs == nil or secs == false then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
try_get_data(session_data_set, player_index, try_upload_data_token)
|
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 try_get_data = Server.try_get_data
|
||||||
-- local set_data = Server.set_data
|
-- local set_data = Server.set_data
|
||||||
|
|
||||||
|
|
||||||
local this = {
|
local this = {
|
||||||
players = {},
|
players = {},
|
||||||
storage = {},
|
storage = {},
|
||||||
activate_custom_buttons = false,
|
activate_custom_buttons = false,
|
||||||
bottom_quickbar_button = {},
|
bottom_quickbar_button = {}
|
||||||
bottom_quickbar_button_data = {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Global.register(
|
Global.register(
|
||||||
@ -34,6 +32,8 @@ local Public = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local set_location
|
local set_location
|
||||||
|
local destroy_frame
|
||||||
|
local remove_player
|
||||||
local get_player_data
|
local get_player_data
|
||||||
local bottom_dataset = 'bottom_frame_data'
|
local bottom_dataset = 'bottom_frame_data'
|
||||||
|
|
||||||
@ -81,7 +81,25 @@ local restore_bottom_location_token =
|
|||||||
end
|
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.players[index] = nil
|
||||||
this.storage[index] = nil
|
this.storage[index] = nil
|
||||||
this.bottom_quickbar_button[index] = nil
|
this.bottom_quickbar_button[index] = nil
|
||||||
@ -155,6 +173,19 @@ local function refresh_inner_frames(player)
|
|||||||
end
|
end
|
||||||
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
|
---Adds a new inner frame to the bottom frame
|
||||||
-- local BottomFrame = require 'utils.gui.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' })
|
-- 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 = player_data.row_selection + 1
|
||||||
player_data.row_selection_added = player_data.row_selection_added + 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
|
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
|
end
|
||||||
|
|
||||||
local function destroy_frame(player)
|
destroy_frame = function(player)
|
||||||
local gui = player.gui
|
local gui = player.gui
|
||||||
local frame = gui.screen[main_frame_name]
|
local frame = gui.screen[main_frame_name]
|
||||||
if frame and frame.valid then
|
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.section_data = data.section_data or {}
|
||||||
data.alignment = alignment
|
data.alignment = alignment
|
||||||
|
|
||||||
|
Task.priority_delay(5, check_bottom_buttons_token, {player_index = player.index})
|
||||||
|
|
||||||
return frame
|
return frame
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1552,6 +1552,11 @@ Event.add(
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local secs = server_time.secs
|
||||||
|
if secs == nil then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
output_data(player_join_tag .. player.name)
|
output_data(player_join_tag .. player.name)
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
@ -1578,6 +1583,11 @@ Event.add(
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local secs = server_time.secs
|
||||||
|
if secs == nil then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
local reason = leave_reason_map[event.reason] or ''
|
local reason = leave_reason_map[event.reason] or ''
|
||||||
output_data(player_leave_tag .. player.name .. reason)
|
output_data(player_leave_tag .. player.name .. reason)
|
||||||
end
|
end
|
||||||
@ -1592,6 +1602,11 @@ Event.add(
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local secs = server_time.secs
|
||||||
|
if secs == nil then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
local cause = event.cause
|
local cause = event.cause
|
||||||
|
|
||||||
local message = {discord_bold_tag, player.name}
|
local message = {discord_bold_tag, player.name}
|
||||||
|
Loading…
Reference in New Issue
Block a user