mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-07-26 18:36:23 +09:00
Merge branch 'aperx' of https://github.com/PHIDIAS0303/ExpCluster into aperx
This commit is contained in:
@@ -16,14 +16,11 @@ return {
|
||||
"modules.data.quickbar",
|
||||
"modules.data.alt-view",
|
||||
"modules.data.tag",
|
||||
-- 'modules.data.bonus',
|
||||
"modules.data.personal-logistic",
|
||||
"modules.data.language",
|
||||
--"modules.data.toolbar",
|
||||
|
||||
--- GUI
|
||||
"modules.gui.warp-list",
|
||||
"modules.gui.player-list",
|
||||
"modules.gui.vlayer",
|
||||
"modules.gui._role_updates",
|
||||
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
|
||||
return {
|
||||
--[[
|
||||
TODO
|
||||
force bonus
|
||||
quick health regeneration
|
||||
|
||||
Base point is equal to the amount of standard value in each parameter.
|
||||
|
||||
CMMS CRS CCS CISB CHB CRDB PBR
|
||||
@@ -28,7 +24,6 @@ return {
|
||||
scale = 1,
|
||||
cost = 10,
|
||||
max_value = 4,
|
||||
initial_value = 2,
|
||||
value_step = 0.5,
|
||||
is_percentage = true,
|
||||
},
|
||||
@@ -37,7 +32,6 @@ return {
|
||||
scale = 1,
|
||||
cost = 60,
|
||||
max_value = 2,
|
||||
initial_value = 1,
|
||||
value_step = 0.25,
|
||||
is_percentage = true,
|
||||
},
|
||||
@@ -46,7 +40,6 @@ return {
|
||||
scale = 1,
|
||||
cost = 4,
|
||||
max_value = 12,
|
||||
initial_value = 6,
|
||||
value_step = 1,
|
||||
is_percentage = true,
|
||||
},
|
||||
@@ -55,7 +48,6 @@ return {
|
||||
scale = 10,
|
||||
cost = 2,
|
||||
max_value = 100,
|
||||
initial_value = 50,
|
||||
value_step = 10,
|
||||
},
|
||||
{
|
||||
@@ -63,7 +55,6 @@ return {
|
||||
scale = 50,
|
||||
cost = 4,
|
||||
max_value = 300,
|
||||
initial_value = 150,
|
||||
value_step = 50,
|
||||
},
|
||||
{
|
||||
@@ -71,7 +62,6 @@ return {
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
max_value = 16,
|
||||
initial_value = 8,
|
||||
value_step = 2,
|
||||
combined_bonus = {
|
||||
"character_resource_reach_distance_bonus",
|
||||
@@ -83,101 +73,12 @@ return {
|
||||
scale = 4,
|
||||
cost = 40,
|
||||
max_value = 8,
|
||||
initial_value = 4,
|
||||
value_step = 1,
|
||||
is_special = true,
|
||||
},
|
||||
--[[
|
||||
['character_item_pickup_distance_bonus'] = {
|
||||
initial_value = 0,
|
||||
max_value = 20,
|
||||
value_step = 1,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
},
|
||||
['character_loot_pickup_distance_bonus'] = {
|
||||
initial_value = 0,
|
||||
max_value = 20,
|
||||
value_step = 1,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
},
|
||||
['character_item_drop_distance_bonus'] = {
|
||||
initial_value = 0,
|
||||
max_value = 20,
|
||||
value_step = 1,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
}
|
||||
]]
|
||||
},
|
||||
force_bonus = {
|
||||
--[[
|
||||
['character_mining_speed_modifier'] = {
|
||||
initial_value = 0,
|
||||
max_value = 6,
|
||||
value_step = 0.5,
|
||||
scale = 1,
|
||||
cost = 10,
|
||||
is_percentage = true
|
||||
},
|
||||
['character_running_speed_modifier'] = {
|
||||
initial_value = 0,
|
||||
max_value = 3,
|
||||
value_step = 0.25,
|
||||
scale = 1,
|
||||
cost = 40,
|
||||
is_percentage = true
|
||||
},
|
||||
['character_crafting_speed_modifier'] = {
|
||||
initial_value = 0,
|
||||
max_value = 16,
|
||||
value_step = 1,
|
||||
scale = 1,
|
||||
cost = 4,
|
||||
is_percentage = true
|
||||
},
|
||||
['character_inventory_slots_bonus'] = {
|
||||
initial_value = 0,
|
||||
max_value = 200,
|
||||
value_step = 10,
|
||||
scale = 100,
|
||||
cost = 2,
|
||||
is_percentage = false
|
||||
},
|
||||
['character_health_bonus'] = {
|
||||
initial_value = 0,
|
||||
max_value = 400,
|
||||
value_step = 50,
|
||||
cost = 4,
|
||||
is_percentage = false
|
||||
},
|
||||
['character_reach_distance_bonus'] = {
|
||||
initial_value = 0,
|
||||
max_value = 24,
|
||||
value_step = 2,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false,
|
||||
combined_bonus = {
|
||||
'character_resource_reach_distance_bonus',
|
||||
'character_build_distance_bonus'
|
||||
}
|
||||
},
|
||||
['worker_robots_speed_modifier'] = {
|
||||
initial_value = 0,
|
||||
max_value = 0,
|
||||
value_step = 0,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
},
|
||||
]]
|
||||
["worker_robots_battery_modifier"] = {
|
||||
initial_value = 1,
|
||||
max_value = 1,
|
||||
value_step = 1,
|
||||
scale = 1,
|
||||
@@ -185,7 +86,6 @@ return {
|
||||
is_percentage = false,
|
||||
},
|
||||
["worker_robots_storage_bonus"] = {
|
||||
initial_value = 1,
|
||||
max_value = 1,
|
||||
value_step = 1,
|
||||
scale = 1,
|
||||
@@ -193,114 +93,13 @@ return {
|
||||
is_percentage = false,
|
||||
},
|
||||
["following_robots_lifetime_modifier"] = {
|
||||
initial_value = 1,
|
||||
max_value = 1,
|
||||
value_step = 1,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false,
|
||||
},
|
||||
--[[
|
||||
['character_item_pickup_distance_bonus'] = {
|
||||
initial_value = 0,
|
||||
max_value = 20,
|
||||
value_step = 1,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
},
|
||||
['character_loot_pickup_distance_bonus'] = {
|
||||
initial_value = 0,
|
||||
max_value = 20,
|
||||
value_step = 1,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
},
|
||||
['character_item_drop_distance_bonus'] = {
|
||||
initial_value = 0,
|
||||
max_value = 20,
|
||||
value_step = 1,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
},
|
||||
['character_trash_slot_count'] = {
|
||||
initial_value = 0,
|
||||
max_value = 0,
|
||||
value_step = 0,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
},
|
||||
['mining_drill_productivity_bonus'] = {
|
||||
initial_value = 0,
|
||||
max_value = 0,
|
||||
value_step = 0,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
},
|
||||
['train_braking_force_bonus'] = {
|
||||
initial_value = 0,
|
||||
max_value = 0,
|
||||
value_step = 0,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
},
|
||||
['laboratory_speed_modifier'] = {
|
||||
initial_value = 0,
|
||||
max_value = 0,
|
||||
value_step = 0,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
},
|
||||
['laboratory_productivity_bonus'] = {
|
||||
initial_value = 0,
|
||||
max_value = 0,
|
||||
value_step = 0,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
},
|
||||
['inserter_stack_size_bonus'] = {
|
||||
initial_value = 0,
|
||||
max_value = 0,
|
||||
value_step = 0,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
},
|
||||
['stack_inserter_capacity_bonus'] = {
|
||||
initial_value = 0,
|
||||
max_value = 0,
|
||||
value_step = 0,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
},
|
||||
['artillery_range_modifier'] = {
|
||||
initial_value = 0,
|
||||
max_value = 0,
|
||||
value_step = 0,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
}
|
||||
]]
|
||||
},
|
||||
surface_bonus = {
|
||||
--[[
|
||||
['solar_power_multiplier'] = {
|
||||
initial_value = 1,
|
||||
max_value = 1000,
|
||||
value_step = 1,
|
||||
scale = 1,
|
||||
cost = 1,
|
||||
is_percentage = false
|
||||
}
|
||||
]]
|
||||
},
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ Roles.define_flag_trigger("is_spectator", function(player, state)
|
||||
end)
|
||||
Roles.define_flag_trigger("is_jail", function(player, state)
|
||||
if player.character then
|
||||
player.character.active = not state
|
||||
player.character.disabled_by_script = not state
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -133,6 +133,9 @@ Roles.new_role("Board Member", "Board")
|
||||
"command/search-online",
|
||||
"command/search-amount",
|
||||
"command/search-recent",
|
||||
"command/spectate",
|
||||
"command/follow",
|
||||
"command/clear-blueprints-surface",
|
||||
}
|
||||
|
||||
Roles.new_role("Supporter", "Sup")
|
||||
@@ -167,7 +170,6 @@ Roles.new_role("Member", "Mem")
|
||||
:allow{
|
||||
"fast-tree-decon",
|
||||
"gui/bonus",
|
||||
--"command/bonus",
|
||||
--"command/tag-color",
|
||||
"command/set-join-message",
|
||||
"command/remove-join-message",
|
||||
@@ -199,9 +201,7 @@ Roles.new_role("Veteran", "Vet")
|
||||
"command/chat-commands",
|
||||
"command/clear-ground-items",
|
||||
"command/clear-blueprints",
|
||||
"command/clear-blueprints-radius",
|
||||
"command/set-trains-to-automatic",
|
||||
"command/set-auto-research",
|
||||
"command/lawnmower",
|
||||
"command/waterfill",
|
||||
"command/artillery",
|
||||
@@ -261,7 +261,6 @@ local default = Roles.new_role("Guest", "")
|
||||
"gui/research",
|
||||
"gui/autofill",
|
||||
"gui/module",
|
||||
"gui/landfill",
|
||||
"gui/production",
|
||||
-- "command/tag",
|
||||
-- "command/tag-clear",
|
||||
|
||||
@@ -14,9 +14,10 @@ local Jail = require("modules.exp_legacy.modules.control.jail") --- @dep modules
|
||||
local Colors = require("modules/exp_util/include/color")
|
||||
local format_player_name = ExpUtil.format_player_name_locale
|
||||
|
||||
local SelectedPlayer, SelectedAction
|
||||
local function set_datastores(player, action)
|
||||
SelectedPlayer, SelectedAction = player, action
|
||||
--- Accessors injected by the gui so the actions can read the selected player and set the selected action
|
||||
local get_selected_player, set_selected_action
|
||||
local function set_accessors(player_getter, action_setter)
|
||||
get_selected_player, set_selected_action = player_getter, action_setter
|
||||
end
|
||||
|
||||
-- auth that will only allow when on player's of lower roles
|
||||
@@ -29,11 +30,10 @@ local function auth_lower_role(player, selected_player_name)
|
||||
end
|
||||
|
||||
-- gets the action player and a coloured name for the action to be used on
|
||||
local function get_action_player_name(player)
|
||||
local selected_player_name = SelectedPlayer:get(player)
|
||||
local selected_player = game.players[selected_player_name]
|
||||
local function get_action_player(player)
|
||||
local selected_player = get_selected_player(player) --[[ @as LuaPlayer ]]
|
||||
local selected_player_color = format_player_name(selected_player)
|
||||
return selected_player_name, selected_player_color
|
||||
return selected_player, selected_player_color
|
||||
end
|
||||
|
||||
-- teleports one player to another
|
||||
@@ -63,12 +63,11 @@ end
|
||||
|
||||
--- Teleports the user to the action player
|
||||
-- @element goto_player
|
||||
local goto_player = new_button("utility/export", { "player-list.goto-player" })
|
||||
local goto_player = new_button("utility/export", { "exp-gui_player-list.goto-player" })
|
||||
:on_click(function(def, player, element)
|
||||
local selected_player_name = get_action_player_name(player)
|
||||
local selected_player = game.players[selected_player_name]
|
||||
local selected_player = get_action_player(player)
|
||||
if not player.character or not selected_player.character then
|
||||
player.print({ "expcore-commands.reject-player-alive" }, Colors.orange_red)
|
||||
player.print({ "exp-commands-parse.player-alive" }, Colors.orange_red)
|
||||
else
|
||||
teleport(player, selected_player)
|
||||
end
|
||||
@@ -76,12 +75,11 @@ local goto_player = new_button("utility/export", { "player-list.goto-player" })
|
||||
|
||||
--- Teleports the action player to the user
|
||||
-- @element bring_player
|
||||
local bring_player = new_button("utility/import", { "player-list.bring-player" })
|
||||
local bring_player = new_button("utility/import", { "exp-gui_player-list.bring-player" })
|
||||
:on_click(function(def, player, element)
|
||||
local selected_player_name = get_action_player_name(player)
|
||||
local selected_player = game.players[selected_player_name]
|
||||
local selected_player = get_action_player(player)
|
||||
if not player.character or not selected_player.character then
|
||||
player.print({ "expcore-commands.reject-player-alive" }, Colors.orange_red)
|
||||
player.print({ "exp-commands-parse.player-alive" }, Colors.orange_red)
|
||||
else
|
||||
teleport(selected_player, player)
|
||||
end
|
||||
@@ -89,83 +87,83 @@ local bring_player = new_button("utility/import", { "player-list.bring-player" }
|
||||
|
||||
--- Reports the action player, requires a reason to be given
|
||||
-- @element report_player
|
||||
local report_player = new_button("utility/spawn_flag", { "player-list.report-player" })
|
||||
local report_player = new_button("utility/spawn_flag", { "exp-gui_player-list.report-player" })
|
||||
:on_click(function(def, player, element)
|
||||
local selected_player_name = get_action_player_name(player)
|
||||
if Reports.is_reported(selected_player_name, player.name) then
|
||||
local selected_player = get_action_player(player)
|
||||
if Reports.is_reported(selected_player.name, player.name) then
|
||||
player.print({ "exp-commands_report.already-reported" }, Colors.orange_red)
|
||||
else
|
||||
SelectedAction:set(player, "command/report")
|
||||
set_selected_action(player, "command/report")
|
||||
end
|
||||
end)
|
||||
|
||||
local function report_player_callback(player, reason)
|
||||
local selected_player_name, selected_player_color = get_action_player_name(player)
|
||||
local selected_player, selected_player_color = get_action_player(player)
|
||||
local by_player_name_color = format_player_name(player)
|
||||
game.print{ "exp-commands_reports.response", selected_player_color, reason }
|
||||
Roles.print_to_roles_higher("Trainee", { "exp-commands_reports.response-admin", selected_player_color, by_player_name_color, reason })
|
||||
Reports.report_player(selected_player_name, player.name, reason)
|
||||
Reports.report_player(selected_player.name, player.name, reason)
|
||||
end
|
||||
|
||||
--- Gives the action player a warning, requires a reason
|
||||
-- @element warn_player
|
||||
local warn_player = new_button("utility/spawn_flag", { "player-list.warn-player" })
|
||||
local warn_player = new_button("utility/spawn_flag", { "exp-gui_player-list.warn-player" })
|
||||
:on_click(function(def, player, element)
|
||||
SelectedAction:set(player, "command/give-warning")
|
||||
set_selected_action(player, "command/give-warning")
|
||||
end)
|
||||
|
||||
local function warn_player_callback(player, reason)
|
||||
local selected_player_name, selected_player_color = get_action_player_name(player)
|
||||
local selected_player, selected_player_color = get_action_player(player)
|
||||
local by_player_name_color = format_player_name(player)
|
||||
game.print{ "exp-commands_warnings.create", selected_player_color, by_player_name_color, reason }
|
||||
Warnings.add_warning(selected_player_name, player.name, reason)
|
||||
Warnings.add_warning(selected_player.name, player.name, reason)
|
||||
end
|
||||
|
||||
--- Jails the action player, requires a reason
|
||||
-- @element jail_player
|
||||
local jail_player = new_button("utility/multiplayer_waiting_icon", { "player-list.jail-player" })
|
||||
local jail_player = new_button("utility/multiplayer_waiting_icon", { "exp-gui_player-list.jail-player" })
|
||||
:on_click(function(def, player, element)
|
||||
local selected_player_name, selected_player_color = get_action_player_name(player)
|
||||
if Jail.is_jailed(selected_player_name) then
|
||||
local selected_player, selected_player_color = get_action_player(player)
|
||||
if Jail.is_jailed(selected_player.name) then
|
||||
player.print({ "exp-commands_jail.already-jailed", selected_player_color }, Colors.orange_red)
|
||||
else
|
||||
SelectedAction:set(player, "command/jail")
|
||||
set_selected_action(player, "command/jail")
|
||||
end
|
||||
end)
|
||||
|
||||
local function jail_player_callback(player, reason)
|
||||
local selected_player_name, selected_player_color = get_action_player_name(player)
|
||||
local selected_player, selected_player_color = get_action_player(player)
|
||||
local by_player_name_color = format_player_name(player)
|
||||
game.print{ "exp-commands_jail.jailed", selected_player_color, by_player_name_color, reason }
|
||||
Jail.jail_player(selected_player_name, player.name, reason)
|
||||
Jail.jail_player(selected_player.name, player.name, reason)
|
||||
end
|
||||
|
||||
--- Kicks the action player, requires a reason
|
||||
-- @element kick_player
|
||||
local kick_player = new_button("utility/warning_icon", { "player-list.kick-player" })
|
||||
local kick_player = new_button("utility/warning_icon", { "exp-gui_player-list.kick-player" })
|
||||
:on_click(function(def, player, element)
|
||||
SelectedAction:set(player, "command/kick")
|
||||
set_selected_action(player, "command/kick")
|
||||
end)
|
||||
|
||||
local function kick_player_callback(player, reason)
|
||||
local selected_player = get_action_player_name(player)
|
||||
local selected_player = get_action_player(player)
|
||||
game.kick_player(selected_player, reason)
|
||||
end
|
||||
|
||||
--- Bans the action player, requires a reason
|
||||
-- @element ban_player
|
||||
local ban_player = new_button("utility/danger_icon", { "player-list.ban-player" })
|
||||
local ban_player = new_button("utility/danger_icon", { "exp-gui_player-list.ban-player" })
|
||||
:on_click(function(def, player, element)
|
||||
SelectedAction:set(player, "command/ban")
|
||||
set_selected_action(player, "command/ban")
|
||||
end)
|
||||
|
||||
local function ban_player_callback(player, reason)
|
||||
local selected_player = get_action_player_name(player)
|
||||
local selected_player = get_action_player(player)
|
||||
game.ban_player(selected_player, reason)
|
||||
end
|
||||
|
||||
return {
|
||||
set_datastores = set_datastores,
|
||||
set_accessors = set_accessors,
|
||||
buttons = {
|
||||
["command/teleport"] = {
|
||||
auth = function(player, selected_player)
|
||||
|
||||
@@ -4,4 +4,5 @@
|
||||
return {
|
||||
fluid = true, --- @setting fluid When true, checks for for fluid pipes when removing miners
|
||||
chest = true, --- @setting chest When true, checks for for chest when removing miners
|
||||
beacon = true, --- @setting beacon When true, checks for for beacon when removing miners
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,15 +5,13 @@ return {
|
||||
repeat_lifetime = 3600 * 20, --- @setting repeat_lifetime The length of time, in ticks, that protected removals will be remembered for
|
||||
refresh_rate = 3600 * 5, --- @setting refresh_rate How often the age of protected removals are checked against repeat_lifetime
|
||||
always_protected_names = { --- @setting always_protected_names Names of entities which are always protected
|
||||
|
||||
},
|
||||
always_protected_types = { --- @setting always_protected_types Types of entities which are always protected
|
||||
"boiler", "generator", "offshore-pump", "power-switch", "reactor", "rocket-silo",
|
||||
"boiler", "generator", "offshore-pump", "reactor", "heat-exchanger", "heat-pipe", "fusion-reactor", "fusion-generator", "power-switch", "rocket-silo",
|
||||
},
|
||||
always_trigger_repeat_names = { --- @setting always_trigger_repeat_names Names of entities which always trigger repeated removal protection
|
||||
|
||||
},
|
||||
always_trigger_repeat_types = { --- @setting always_trigger_repeat_types Types of entities which always trigger repeated removal protection
|
||||
"reactor", "rocket-silo",
|
||||
"reactor", "fusion-reactor", "rocket-silo",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -2,14 +2,6 @@
|
||||
-- @config Repair
|
||||
|
||||
return {
|
||||
disallow = { --- @setting disallow items in this list will never be repaired
|
||||
["loader"] = true,
|
||||
["fast-loader"] = true,
|
||||
["express-loader"] = true,
|
||||
["electric-energy-interface"] = true,
|
||||
["infinity-chest"] = true,
|
||||
},
|
||||
max_range = 50, --- @setting max_range the max range that can be used with the repair command
|
||||
allow_blueprint_repair = false, --- @setting allow_blueprint_repair when true will allow blueprints (things not destroyed by biters) to be build instantly using the repair command
|
||||
allow_ghost_revive = true, --- @setting allow_ghost_revive when true will allow ghosts (things destroyed by biters) to be build instantly using the repair command
|
||||
allow_heal_entities = true, --- @setting allow_heal_entities when true will heal entities to full health that are within range
|
||||
|
||||
@@ -12,16 +12,6 @@ return {
|
||||
-- this enable 20 more inventory for each mining productivity level up to 4
|
||||
bonus_inventory = {
|
||||
enabled = true,
|
||||
log = {
|
||||
["base"] = {
|
||||
["name"] = "mining-productivity-4",
|
||||
["level"] = 4
|
||||
},
|
||||
["space-age"] = {
|
||||
["name"] = "mining-productivity-3",
|
||||
["level"] = 3
|
||||
},
|
||||
},
|
||||
res = {
|
||||
-- Mining Productivity
|
||||
["mining-productivity"] = true,
|
||||
|
||||
@@ -349,7 +349,7 @@ function vlayer.create_input_interface(surface, position, circuit, last_user)
|
||||
end
|
||||
|
||||
interface.destructible = false
|
||||
interface.minable = false
|
||||
interface.minable_flag = false
|
||||
interface.operable = true
|
||||
|
||||
return interface
|
||||
@@ -427,7 +427,7 @@ function vlayer.create_output_interface(surface, position, circuit, last_user)
|
||||
end
|
||||
|
||||
interface.destructible = false
|
||||
interface.minable = false
|
||||
interface.minable_flag = false
|
||||
interface.operable = true
|
||||
|
||||
return interface
|
||||
@@ -514,9 +514,6 @@ function vlayer.get_statistics()
|
||||
energy_sustained = vdp * gsm,
|
||||
energy_capacity = vlayer_data.properties.capacity * mega,
|
||||
energy_storage = vlayer_data.storage.energy,
|
||||
day_time = math.floor(vlayer_data.surface.daytime * vlayer_data.surface.ticks_per_day),
|
||||
day_length = vlayer_data.surface.ticks_per_day,
|
||||
tick = game.tick,
|
||||
}
|
||||
end
|
||||
|
||||
@@ -540,9 +537,6 @@ function vlayer.get_circuits()
|
||||
energy_sustained = "signal-S",
|
||||
energy_capacity = "signal-C",
|
||||
energy_storage = "signal-E",
|
||||
day_time = "signal-D",
|
||||
day_length = "signal-L",
|
||||
tick = "signal-T",
|
||||
}
|
||||
end
|
||||
|
||||
@@ -574,7 +568,7 @@ function vlayer.create_circuit_interface(surface, position, circuit, last_user)
|
||||
end
|
||||
|
||||
interface.destructible = false
|
||||
interface.minable = false
|
||||
interface.minable_flag = false
|
||||
interface.operable = true
|
||||
|
||||
return interface
|
||||
@@ -653,7 +647,7 @@ function vlayer.create_energy_interface(surface, position, last_user)
|
||||
end
|
||||
|
||||
interface.destructible = false
|
||||
interface.minable = false
|
||||
interface.minable_flag = false
|
||||
interface.operable = false
|
||||
interface.electric_buffer_size = 0
|
||||
interface.power_production = 0
|
||||
|
||||
@@ -182,7 +182,7 @@ function Warps.make_warp_area(warp_id)
|
||||
}
|
||||
entity.destructible = false
|
||||
entity.health = 0
|
||||
entity.minable = false
|
||||
entity.minable_flag = false
|
||||
entity.rotatable = false
|
||||
|
||||
-- Save reference of the last power pole
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
--[[-- Commands Module - Bonus
|
||||
- Adds a command that allows players to have increased stats
|
||||
@data Bonus
|
||||
]]
|
||||
|
||||
local Roles = require("modules.exp_legacy.expcore.roles") --- @dep expcore.roles
|
||||
local Event = require("modules/exp_legacy/utils/event") --- @dep utils.event
|
||||
local config = require("modules.exp_legacy.config.bonus") --- @dep config.bonuses
|
||||
local Commands = require("modules/exp_commands")
|
||||
|
||||
-- Stores the bonus for the player
|
||||
local PlayerData = require("modules.exp_legacy.expcore.player_data") --- @dep expcore.player_data
|
||||
local PlayerBonus = PlayerData.Settings:combine("Bonus")
|
||||
PlayerBonus:set_default(0)
|
||||
PlayerBonus:set_metadata{
|
||||
permission = "command/bonus",
|
||||
stringify = function(value)
|
||||
if not value or value == 0 then
|
||||
return "None set"
|
||||
end
|
||||
|
||||
return value
|
||||
end,
|
||||
}
|
||||
|
||||
--- Apply a bonus to a player
|
||||
local function apply_bonus(player, stage)
|
||||
if not player.character then
|
||||
return
|
||||
end
|
||||
|
||||
for k, v in pairs(config.player_bonus) do
|
||||
player[k] = v.value * stage / 10
|
||||
|
||||
if v.combined_bonus then
|
||||
for i = 1, #v.combined_bonus, 1 do
|
||||
player[v.combined_bonus[i]] = v.value * stage / 10
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- When store is updated apply new bonus to the player
|
||||
PlayerBonus:on_update(function(player_name, player_bonus)
|
||||
apply_bonus(game.players[player_name], player_bonus or 0)
|
||||
end)
|
||||
|
||||
--- Changes the amount of bonus you receive
|
||||
Commands.new("bonus", { "bonus.description" })
|
||||
:optional("amount", { "bonus.arg-amount" }, Commands.types.integer_range(0, 10))
|
||||
:register(function(player, amount)
|
||||
--- @cast amount number?
|
||||
if amount then
|
||||
PlayerBonus:set(player, amount)
|
||||
return Commands.status.success{ "bonus.set", amount }
|
||||
else
|
||||
return Commands.status.success{ "bonus.get", PlayerBonus:get(player) }
|
||||
end
|
||||
end)
|
||||
|
||||
--- When a player respawns re-apply bonus
|
||||
Event.add(defines.events.on_player_respawned, function(event)
|
||||
local player = game.players[event.player_index]
|
||||
apply_bonus(player, PlayerBonus:get(player))
|
||||
end)
|
||||
|
||||
--- Remove bonus if a player no longer has access to the command
|
||||
local function role_update(event)
|
||||
local player = game.players[event.player_index]
|
||||
if not Roles.player_allowed(player, "command/bonus") then
|
||||
apply_bonus(player, 0)
|
||||
end
|
||||
end
|
||||
|
||||
--- When a player dies allow them to have instant respawn
|
||||
Event.add(defines.events.on_player_died, function(event)
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
if Roles.player_has_flag(player, "instant-respawn") then
|
||||
player.ticks_to_respawn = 120
|
||||
end
|
||||
end)
|
||||
|
||||
Event.add(defines.events.on_player_created, function(event)
|
||||
if event.player_index ~= 1 then
|
||||
return
|
||||
end
|
||||
|
||||
for k, v in pairs(config.force_bonus) do
|
||||
game.players[event.player_index].force[k] = v.value
|
||||
end
|
||||
|
||||
for k, v in pairs(config.surface_bonus) do
|
||||
game.players[event.player_index].surface[k] = v.value
|
||||
end
|
||||
end)
|
||||
|
||||
Event.add(Roles.events.on_role_assigned, role_update)
|
||||
Event.add(Roles.events.on_role_unassigned, role_update)
|
||||
@@ -1,89 +0,0 @@
|
||||
local Commands = require("modules/exp_commands")
|
||||
local config = require("modules.exp_legacy.config.personal_logistic") --- @dep config.personal-logistic
|
||||
|
||||
---@param target LuaEntity | LuaPlayer
|
||||
---@param amount number
|
||||
local function pl(target, amount)
|
||||
local c
|
||||
local s
|
||||
|
||||
--- @cast target any Remove cast once implemented
|
||||
error("Needs updating to use 2.0 logistics")
|
||||
|
||||
if target.object_name == "LuaPlayer" then
|
||||
c = target.clear_personal_logistic_slot
|
||||
s = target.set_personal_logistic_slot
|
||||
else
|
||||
c = target.clear_vehicle_logistic_slot
|
||||
s = target.set_vehicle_logistic_slot
|
||||
end
|
||||
|
||||
for _, v in pairs(config.request) do
|
||||
c(config.start + v.key)
|
||||
end
|
||||
|
||||
if (amount < 0) then
|
||||
return
|
||||
end
|
||||
|
||||
local stats = target.force.get_item_production_statistics(target.surface)
|
||||
|
||||
for k, v in pairs(config.request) do
|
||||
local v_min = math.ceil(v.min * amount)
|
||||
local v_max = math.ceil(v.max * amount)
|
||||
|
||||
if v.stack ~= nil and v.stack ~= 1 and v.type ~= "weapon" then
|
||||
v_min = math.floor(v_min / v.stack) * v.stack
|
||||
v_max = math.ceil(v_max / v.stack) * v.stack
|
||||
end
|
||||
|
||||
if v.upgrade_of == nil then
|
||||
if v.type ~= nil then
|
||||
if stats.get_input_count(k) < config.production_required[v.type] then
|
||||
if v_min > 0 then
|
||||
if v_min == v_max then
|
||||
v_min = math.floor((v_max * 0.5) / v.stack) * v.stack
|
||||
end
|
||||
else
|
||||
v_min = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
s(config.start + v.key, { name = k, min = v_min, max = v_max })
|
||||
else
|
||||
if v.type ~= nil then
|
||||
if stats.get_input_count(k) >= config.production_required[v.type] then
|
||||
s(config.start + v.key, { name = k, min = v_min, max = v_max })
|
||||
local vuo = v.upgrade_of
|
||||
|
||||
while (vuo ~= nil) do
|
||||
s(config.start + config.request[vuo].key, { name = vuo, min = 0, max = 0 })
|
||||
vuo = config.request[vuo].upgrade_of
|
||||
end
|
||||
else
|
||||
s(config.start + v.key, { name = k, min = 0, max = v_max })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Commands.new("personal-logistic", "Set Personal Logistic (-1 to cancel all) (Select spidertron to edit spidertron)")
|
||||
:argument("amount", "", Commands.types.integer_range(-1, 10))
|
||||
:add_aliases{ "pl" }
|
||||
:add_flags{ "disabled" } -- Remove once implemented above
|
||||
:register(function(player, amount)
|
||||
--- @cast amount number
|
||||
if player.force.technologies["logistic-robotics"].researched then
|
||||
if player.selected ~= nil then
|
||||
if player.selected.name == "spidertron" then
|
||||
pl(player.selected, amount / 10)
|
||||
end
|
||||
else
|
||||
pl(player, amount / 10)
|
||||
end
|
||||
else
|
||||
return Commands.status.error("Personal Logistic not researched")
|
||||
end
|
||||
end)
|
||||
@@ -43,10 +43,14 @@ local ignored_items = {
|
||||
--- Saves your quickbar preset to the script-output folder
|
||||
Commands.new("save-quickbar", "Saves your Quickbar preset items to file")
|
||||
:add_aliases{ "save-toolbar" }
|
||||
:add_flags{ "disabled" }
|
||||
:register(function(player)
|
||||
local filters = {}
|
||||
|
||||
error("2.1 changes to get_quick_bar_slot beak compatibility with 2.0; waiting for upstream")
|
||||
-- Upstream may add method to compat, or change inventory sync to have a quickbar only mode
|
||||
for i = 1, 100 do
|
||||
--[[
|
||||
local slot = player.get_quick_bar_slot(i)
|
||||
-- Need to filter out blueprint and blueprint books because the slot is a LuaItemPrototype and does not contain a way to export blueprint data
|
||||
if slot ~= nil then
|
||||
@@ -55,6 +59,7 @@ Commands.new("save-quickbar", "Saves your Quickbar preset items to file")
|
||||
filters[i] = slot.name
|
||||
end
|
||||
end
|
||||
]]
|
||||
end
|
||||
|
||||
if next(filters) then
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
|
||||
local Model = require("modules.exp_legacy.modules.gui.debug.model") --- @dep modules.gui.debug.model
|
||||
local Color = require("modules/exp_util/include/color")
|
||||
|
||||
local dump = Model.dump
|
||||
|
||||
local Public = {}
|
||||
|
||||
local ignore = {
|
||||
_G = true,
|
||||
assert = true,
|
||||
collectgarbage = true,
|
||||
error = true,
|
||||
getmetatable = true,
|
||||
ipairs = true,
|
||||
load = true,
|
||||
loadstring = true,
|
||||
next = true,
|
||||
pairs = true,
|
||||
pcall = true,
|
||||
print = true,
|
||||
rawequal = true,
|
||||
rawlen = true,
|
||||
rawget = true,
|
||||
rawset = true,
|
||||
select = true,
|
||||
setmetatable = true,
|
||||
tonumber = true,
|
||||
tostring = true,
|
||||
type = true,
|
||||
xpcall = true,
|
||||
_VERSION = true,
|
||||
["module"] = true,
|
||||
require = true,
|
||||
package = true,
|
||||
unpack = true,
|
||||
table = true,
|
||||
string = true,
|
||||
bit32 = true,
|
||||
math = true,
|
||||
debug = true,
|
||||
serpent = true,
|
||||
log = true,
|
||||
table_size = true,
|
||||
storage = true,
|
||||
remote = true,
|
||||
commands = true,
|
||||
settings = true,
|
||||
rcon = true,
|
||||
script = true,
|
||||
util = true,
|
||||
mod_gui = true,
|
||||
game = true,
|
||||
rendering = true,
|
||||
}
|
||||
|
||||
local header_name = Gui.uid_name()
|
||||
local left_panel_name = Gui.uid_name()
|
||||
local right_panel_name = Gui.uid_name()
|
||||
|
||||
Public.name = "_G"
|
||||
|
||||
function Public.show(container)
|
||||
local main_flow = container.add{ type = "flow", direction = "horizontal" }
|
||||
|
||||
local left_panel = main_flow.add{ type = "scroll-pane", name = left_panel_name }
|
||||
local left_panel_style = left_panel.style
|
||||
left_panel_style.width = 300
|
||||
|
||||
for key, value in pairs(_G) do
|
||||
if not ignore[key] then
|
||||
local header =
|
||||
left_panel.add{ type = "flow" }.add{ type = "label", name = header_name, caption = tostring(key) }
|
||||
Gui.set_data(header, value)
|
||||
end
|
||||
end
|
||||
|
||||
local right_panel = main_flow.add{ type = "text-box", name = right_panel_name }
|
||||
right_panel.read_only = true
|
||||
right_panel.selectable = true
|
||||
|
||||
local right_panel_style = right_panel.style
|
||||
right_panel_style.vertically_stretchable = true
|
||||
right_panel_style.horizontally_stretchable = true
|
||||
right_panel_style.maximal_width = 1000
|
||||
right_panel_style.maximal_height = 1000
|
||||
|
||||
Gui.set_data(left_panel, { right_panel = right_panel, selected_header = nil })
|
||||
end
|
||||
|
||||
Gui.on_click(
|
||||
header_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local value = Gui.get_data(element)
|
||||
|
||||
local left_panel = element.parent.parent
|
||||
local left_panel_data = Gui.get_data(left_panel)
|
||||
local right_panel = left_panel_data.right_panel
|
||||
local selected_header = left_panel_data.selected_header
|
||||
|
||||
if selected_header then
|
||||
selected_header.style.font_color = Color.white
|
||||
end
|
||||
|
||||
element.style.font_color = Color.orange
|
||||
left_panel_data.selected_header = element
|
||||
|
||||
local content = dump(value)
|
||||
right_panel.text = content
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
||||
@@ -1,174 +0,0 @@
|
||||
local Event = require("modules/exp_legacy/utils/event")
|
||||
local Storage = require("modules/exp_util/storage")
|
||||
local Gui = require("modules.exp_legacy.utils.gui")
|
||||
local Model = require("modules.exp_legacy.modules.gui.debug.model")
|
||||
|
||||
local format = string.format
|
||||
local insert = table.insert
|
||||
|
||||
local events = defines.events
|
||||
|
||||
-- Constants
|
||||
local events_to_keep = 10
|
||||
|
||||
-- Local vars
|
||||
local Public = {
|
||||
name = "Events",
|
||||
}
|
||||
local name_lookup = {}
|
||||
|
||||
-- GUI names
|
||||
local checkbox_name = Gui.uid_name()
|
||||
local filter_name = Gui.uid_name()
|
||||
local clear_filter_name = Gui.uid_name()
|
||||
|
||||
local storage = {}
|
||||
Storage.register(storage, function(tbl)
|
||||
storage = tbl
|
||||
end)
|
||||
|
||||
-- storage tables
|
||||
local enabled = {}
|
||||
local last_events = {}
|
||||
storage.debug_event_view = {
|
||||
enabled = enabled,
|
||||
last_events = last_events,
|
||||
filter = "",
|
||||
}
|
||||
|
||||
function Public.on_open_debug()
|
||||
local tbl = storage.debug_event_view
|
||||
if tbl then
|
||||
enabled = tbl.enabled
|
||||
last_events = tbl.last_events
|
||||
else
|
||||
enabled = {}
|
||||
last_events = {}
|
||||
|
||||
storage.debug_event_view = {
|
||||
enabled = enabled,
|
||||
last_events = last_events,
|
||||
}
|
||||
end
|
||||
|
||||
Public.on_open_debug = nil
|
||||
end
|
||||
|
||||
-- Local functions
|
||||
local function event_callback(event)
|
||||
local id = event.name
|
||||
if not enabled[id] then
|
||||
return
|
||||
end
|
||||
local name = name_lookup[id]
|
||||
|
||||
if not last_events[name] then
|
||||
last_events[name] = {}
|
||||
end
|
||||
|
||||
insert(last_events[name], 1, event)
|
||||
last_events[name][events_to_keep + 1] = nil
|
||||
event.name = nil
|
||||
|
||||
local str = format("%s (id = %s): %s", name, id, Model.dump(event))
|
||||
game.print(str)
|
||||
log(str)
|
||||
end
|
||||
|
||||
local function on_gui_checked_state_changed(event)
|
||||
local element = event.element
|
||||
local name = element.caption
|
||||
local id = events[name]
|
||||
local state = element.state and true or false
|
||||
element.state = state
|
||||
if state then
|
||||
enabled[id] = true
|
||||
else
|
||||
enabled[id] = false
|
||||
end
|
||||
end
|
||||
|
||||
-- GUI
|
||||
|
||||
-- Create a table with events sorted by their names
|
||||
local grid_builder = {}
|
||||
for name, _ in pairs(events) do
|
||||
grid_builder[#grid_builder + 1] = name
|
||||
end
|
||||
|
||||
table.sort(grid_builder)
|
||||
|
||||
local function redraw_event_table(gui_table, filter)
|
||||
for _, event_name in pairs(grid_builder) do
|
||||
if filter == "" or event_name:find(filter) then
|
||||
local index = events[event_name]
|
||||
gui_table.add{ type = "flow" }.add{
|
||||
name = checkbox_name,
|
||||
type = "checkbox",
|
||||
state = enabled[index] or false,
|
||||
caption = event_name,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.show(container)
|
||||
local filter = storage.debug_event_view.filter
|
||||
|
||||
local main_frame_flow = container.add{ type = "flow", direction = "vertical" }
|
||||
|
||||
local filter_flow = main_frame_flow.add{ type = "flow", direction = "horizontal" }
|
||||
filter_flow.add{ type = "label", caption = "filter" }
|
||||
local filter_textfield = filter_flow.add{ type = "textfield", name = filter_name, text = filter }
|
||||
local clear_button = filter_flow.add{ type = "button", name = clear_filter_name, caption = "clear" }
|
||||
|
||||
local scroll_pane = main_frame_flow.add{ type = "scroll-pane" }
|
||||
local gui_table = scroll_pane.add{ type = "table", column_count = 3, draw_horizontal_lines = true }
|
||||
|
||||
Gui.set_data(filter_textfield, gui_table)
|
||||
Gui.set_data(clear_button, { gui_table = gui_table, filter_textfield = filter_textfield })
|
||||
|
||||
redraw_event_table(gui_table, filter)
|
||||
end
|
||||
|
||||
Gui.on_checked_state_changed(checkbox_name, on_gui_checked_state_changed)
|
||||
|
||||
Gui.on_text_changed(
|
||||
filter_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local gui_table = Gui.get_data(element)
|
||||
|
||||
local filter = element.text:gsub(" ", "_")
|
||||
|
||||
storage.debug_event_view.filter = filter
|
||||
element.text = filter
|
||||
|
||||
gui_table.clear()
|
||||
redraw_event_table(gui_table, filter)
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
clear_filter_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local data = Gui.get_data(element)
|
||||
local filter_textfield = data.filter_textfield
|
||||
local gui_table = data.gui_table
|
||||
|
||||
filter_textfield.text = ""
|
||||
storage.debug_event_view.filter = ""
|
||||
|
||||
gui_table.clear()
|
||||
redraw_event_table(gui_table, "")
|
||||
end
|
||||
)
|
||||
|
||||
-- Event registers (TODO: turn to removable hooks.. maybe)
|
||||
for name, id in pairs(events) do
|
||||
name_lookup[id] = name
|
||||
Event.add(id, event_callback)
|
||||
end
|
||||
|
||||
return Public
|
||||
@@ -1,132 +0,0 @@
|
||||
local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
|
||||
local Datastore = require("modules.exp_legacy.expcore.datastore") --- @dep expcore.datastore
|
||||
local Color = require("modules/exp_util/include/color")
|
||||
local Model = require("modules.exp_legacy.modules.gui.debug.model") --- @dep modules.gui.debug.model
|
||||
|
||||
local dump = Model.dump
|
||||
local concat = table.concat
|
||||
|
||||
local Public = {}
|
||||
|
||||
local header_name = Gui.uid_name()
|
||||
local left_panel_name = Gui.uid_name()
|
||||
local right_panel_name = Gui.uid_name()
|
||||
local input_text_box_name = Gui.uid_name()
|
||||
local refresh_name = Gui.uid_name()
|
||||
|
||||
Public.name = "Datastore"
|
||||
|
||||
function Public.show(container)
|
||||
local main_flow = container.add{ type = "flow", direction = "horizontal" }
|
||||
|
||||
local left_panel = main_flow.add{ type = "scroll-pane", name = left_panel_name }
|
||||
local left_panel_style = left_panel.style
|
||||
left_panel_style.width = 300
|
||||
|
||||
for name in pairs(table.key_sort(Datastore.debug())) do
|
||||
local header = left_panel.add{ type = "flow" }.add{ type = "label", name = header_name, caption = name }
|
||||
Gui.set_data(header, name)
|
||||
end
|
||||
|
||||
local right_flow = main_flow.add{ type = "flow", direction = "vertical" }
|
||||
|
||||
local right_top_flow = right_flow.add{ type = "flow", direction = "horizontal" }
|
||||
|
||||
local input_text_box = right_top_flow.add{ type = "text-box", name = input_text_box_name }
|
||||
local input_text_box_style = input_text_box.style
|
||||
input_text_box_style.horizontally_stretchable = true
|
||||
input_text_box_style.height = 32
|
||||
input_text_box_style.maximal_width = 1000
|
||||
|
||||
local refresh_button =
|
||||
right_top_flow.add{ type = "sprite-button", name = refresh_name, sprite = "utility/reset", tooltip = "refresh" }
|
||||
local refresh_button_style = refresh_button.style
|
||||
refresh_button_style.width = 32
|
||||
refresh_button_style.height = 32
|
||||
|
||||
local right_panel = right_flow.add{ type = "text-box", name = right_panel_name }
|
||||
right_panel.read_only = true
|
||||
right_panel.selectable = true
|
||||
|
||||
local right_panel_style = right_panel.style
|
||||
right_panel_style.vertically_stretchable = true
|
||||
right_panel_style.horizontally_stretchable = true
|
||||
right_panel_style.maximal_width = 1000
|
||||
right_panel_style.maximal_height = 1000
|
||||
|
||||
local data = {
|
||||
right_panel = right_panel,
|
||||
input_text_box = input_text_box,
|
||||
selected_header = nil,
|
||||
}
|
||||
|
||||
Gui.set_data(input_text_box, data)
|
||||
Gui.set_data(left_panel, data)
|
||||
Gui.set_data(refresh_button, data)
|
||||
end
|
||||
|
||||
Gui.on_click(
|
||||
header_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local table_name = Gui.get_data(element)
|
||||
|
||||
local left_panel = element.parent.parent
|
||||
local data = Gui.get_data(left_panel)
|
||||
local right_panel = data.right_panel
|
||||
local selected_header = data.selected_header
|
||||
local input_text_box = data.input_text_box
|
||||
|
||||
if selected_header then
|
||||
selected_header.style.font_color = Color.white
|
||||
end
|
||||
|
||||
element.style.font_color = Color.orange
|
||||
data.selected_header = element
|
||||
|
||||
input_text_box.text = table_name
|
||||
input_text_box.style.font_color = Color.black
|
||||
|
||||
local content = Datastore.debug(table_name)
|
||||
local content_string = {}
|
||||
for key, value in pairs(content) do
|
||||
content_string[#content_string + 1] = key:gsub("^%l", string.upper) .. " = " .. dump(value)
|
||||
end
|
||||
|
||||
right_panel.text = concat(content_string, "\n")
|
||||
end
|
||||
)
|
||||
|
||||
local function update_dump(text_input, data)
|
||||
local content = Datastore.debug(text_input.text)
|
||||
local content_string = {}
|
||||
for key, value in pairs(content) do
|
||||
content_string[#content_string + 1] = key:gsub("^%l", string.upper) .. " = " .. dump(value)
|
||||
end
|
||||
|
||||
data.right_panel.text = concat(content_string, "\n")
|
||||
end
|
||||
|
||||
Gui.on_text_changed(
|
||||
input_text_box_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local data = Gui.get_data(element)
|
||||
|
||||
update_dump(element, data)
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
refresh_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local data = Gui.get_data(element)
|
||||
|
||||
local input_text_box = data.input_text_box
|
||||
|
||||
update_dump(input_text_box, data)
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
||||
@@ -1,145 +0,0 @@
|
||||
local ExpElement = require("modules/exp_gui/prototype")
|
||||
local ExpData = require("modules/exp_gui/data")
|
||||
local ExpIter = require("modules/exp_gui/iter")
|
||||
local Color = require("modules/exp_util/include/color")
|
||||
|
||||
local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
|
||||
local Model = require("modules.exp_legacy.modules.gui.debug.model") --- @dep modules.gui.debug.model
|
||||
|
||||
local dump = Model.dump
|
||||
local dump_text = Model.dump_text
|
||||
local concat = table.concat
|
||||
|
||||
local Public = {}
|
||||
|
||||
local header_name = Gui.uid_name()
|
||||
local left_panel_name = Gui.uid_name()
|
||||
local right_panel_name = Gui.uid_name()
|
||||
local input_text_box_name = Gui.uid_name()
|
||||
local refresh_name = Gui.uid_name()
|
||||
|
||||
Public.name = "Elements"
|
||||
|
||||
function Public.show(container)
|
||||
local main_flow = container.add{ type = "flow", direction = "horizontal" }
|
||||
|
||||
local left_panel = main_flow.add{ type = "scroll-pane", name = left_panel_name }
|
||||
local left_panel_style = left_panel.style
|
||||
left_panel_style.width = 300
|
||||
|
||||
--- @diagnostic disable-next-line invisible
|
||||
for element_name in pairs(ExpElement._elements) do
|
||||
local header = left_panel.add{ type = "flow" }.add{ type = "label", name = header_name, caption = element_name }
|
||||
Gui.set_data(header, element_name)
|
||||
end
|
||||
|
||||
local right_flow = main_flow.add{ type = "flow", direction = "vertical" }
|
||||
|
||||
local right_top_flow = right_flow.add{ type = "flow", direction = "horizontal" }
|
||||
|
||||
local input_text_box = right_top_flow.add{ type = "text-box", name = input_text_box_name }
|
||||
local input_text_box_style = input_text_box.style
|
||||
input_text_box_style.horizontally_stretchable = true
|
||||
input_text_box_style.height = 32
|
||||
input_text_box_style.maximal_width = 1000
|
||||
|
||||
local refresh_button =
|
||||
right_top_flow.add{ type = "sprite-button", name = refresh_name, sprite = "utility/reset", tooltip = "refresh" }
|
||||
local refresh_button_style = refresh_button.style
|
||||
refresh_button_style.width = 32
|
||||
refresh_button_style.height = 32
|
||||
|
||||
local right_panel = right_flow.add{ type = "text-box", name = right_panel_name }
|
||||
right_panel.read_only = true
|
||||
right_panel.selectable = true
|
||||
|
||||
local right_panel_style = right_panel.style
|
||||
right_panel_style.vertically_stretchable = true
|
||||
right_panel_style.horizontally_stretchable = true
|
||||
right_panel_style.maximal_width = 1000
|
||||
right_panel_style.maximal_height = 1000
|
||||
|
||||
local data = {
|
||||
right_panel = right_panel,
|
||||
input_text_box = input_text_box,
|
||||
selected_header = nil,
|
||||
}
|
||||
|
||||
Gui.set_data(input_text_box, data)
|
||||
Gui.set_data(left_panel, data)
|
||||
Gui.set_data(refresh_button, data)
|
||||
end
|
||||
|
||||
Gui.on_click(
|
||||
header_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local element_name = Gui.get_data(element)
|
||||
|
||||
local left_panel = element.parent.parent
|
||||
local data = Gui.get_data(left_panel)
|
||||
local right_panel = data.right_panel
|
||||
local selected_header = data.selected_header
|
||||
local input_text_box = data.input_text_box
|
||||
|
||||
if selected_header then
|
||||
selected_header.style.font_color = Color.white
|
||||
end
|
||||
|
||||
element.style.font_color = Color.orange
|
||||
data.selected_header = element
|
||||
|
||||
input_text_box.text = concat{ "ExpElement._elements[\"", element_name, "\"]" }
|
||||
input_text_box.style.font_color = Color.black
|
||||
|
||||
--- @diagnostic disable-next-line invisible
|
||||
local define = ExpElement._elements[element_name]
|
||||
local content = dump({
|
||||
--- @diagnostic disable-next-line invisible
|
||||
debug = define._debug,
|
||||
--- @diagnostic disable-next-line invisible
|
||||
has_handlers = define._has_handlers,
|
||||
--- @diagnostic disable-next-line invisible
|
||||
track_elements = define._track_elements,
|
||||
--- @diagnostic disable-next-line invisible
|
||||
elements = ExpIter._scopes[element_name],
|
||||
--- @diagnostic disable-next-line invisible
|
||||
data = ExpData._scopes[element_name]._raw,
|
||||
}) or "nil"
|
||||
right_panel.text = content
|
||||
end
|
||||
)
|
||||
|
||||
local function update_dump(text_input, data, player)
|
||||
local suc, ouput = dump_text(text_input.text, player)
|
||||
if not suc then
|
||||
text_input.style.font_color = Color.red
|
||||
else
|
||||
text_input.style.font_color = Color.black
|
||||
data.right_panel.text = ouput
|
||||
end
|
||||
end
|
||||
|
||||
Gui.on_text_changed(
|
||||
input_text_box_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local data = Gui.get_data(element)
|
||||
|
||||
update_dump(element, data, event.player)
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
refresh_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local data = Gui.get_data(element)
|
||||
|
||||
local input_text_box = data.input_text_box
|
||||
|
||||
update_dump(input_text_box, data, event.player)
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
||||
@@ -1,133 +0,0 @@
|
||||
local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
|
||||
local Model = require("modules.exp_legacy.modules.gui.debug.model") --- @dep modules.gui.debug.model
|
||||
local Color = require("modules/exp_util/include/color")
|
||||
|
||||
local dump = Model.dump
|
||||
local dump_text = Model.dump_text
|
||||
local concat = table.concat
|
||||
|
||||
local Public = {}
|
||||
|
||||
local ignore = { tokens = true, data_store = true, datastores = true }
|
||||
|
||||
local header_name = Gui.uid_name()
|
||||
local left_panel_name = Gui.uid_name()
|
||||
local right_panel_name = Gui.uid_name()
|
||||
local input_text_box_name = Gui.uid_name()
|
||||
local refresh_name = Gui.uid_name()
|
||||
|
||||
Public.name = "storage"
|
||||
|
||||
function Public.show(container)
|
||||
local main_flow = container.add{ type = "flow", direction = "horizontal" }
|
||||
|
||||
local left_panel = main_flow.add{ type = "scroll-pane", name = left_panel_name }
|
||||
local left_panel_style = left_panel.style
|
||||
left_panel_style.width = 300
|
||||
|
||||
for key, _ in pairs(storage) do
|
||||
if not ignore[key] then
|
||||
local header =
|
||||
left_panel.add{ type = "flow" }.add{ type = "label", name = header_name, caption = tostring(key) }
|
||||
Gui.set_data(header, key)
|
||||
end
|
||||
end
|
||||
|
||||
local right_flow = main_flow.add{ type = "flow", direction = "vertical" }
|
||||
|
||||
local right_top_flow = right_flow.add{ type = "flow", direction = "horizontal" }
|
||||
|
||||
local input_text_box = right_top_flow.add{ type = "text-box", name = input_text_box_name }
|
||||
local input_text_box_style = input_text_box.style
|
||||
input_text_box_style.horizontally_stretchable = true
|
||||
input_text_box_style.height = 32
|
||||
input_text_box_style.maximal_width = 1000
|
||||
|
||||
local refresh_button =
|
||||
right_top_flow.add{ type = "sprite-button", name = refresh_name, sprite = "utility/reset", tooltip = "refresh" }
|
||||
local refresh_button_style = refresh_button.style
|
||||
refresh_button_style.width = 32
|
||||
refresh_button_style.height = 32
|
||||
|
||||
local right_panel = right_flow.add{ type = "text-box", name = right_panel_name }
|
||||
right_panel.read_only = true
|
||||
right_panel.selectable = true
|
||||
|
||||
local right_panel_style = right_panel.style
|
||||
right_panel_style.vertically_stretchable = true
|
||||
right_panel_style.horizontally_stretchable = true
|
||||
right_panel_style.maximal_width = 1000
|
||||
right_panel_style.maximal_height = 1000
|
||||
|
||||
local data = {
|
||||
right_panel = right_panel,
|
||||
input_text_box = input_text_box,
|
||||
selected_header = nil,
|
||||
selected_token_id = nil,
|
||||
}
|
||||
|
||||
Gui.set_data(input_text_box, data)
|
||||
Gui.set_data(left_panel, data)
|
||||
Gui.set_data(refresh_button, data)
|
||||
end
|
||||
|
||||
Gui.on_click(
|
||||
header_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local key = Gui.get_data(element)
|
||||
|
||||
local left_panel = element.parent.parent
|
||||
local data = Gui.get_data(left_panel)
|
||||
local right_panel = data.right_panel
|
||||
local selected_header = data.selected_header
|
||||
local input_text_box = data.input_text_box
|
||||
|
||||
if selected_header then
|
||||
selected_header.style.font_color = Color.white
|
||||
end
|
||||
|
||||
element.style.font_color = Color.orange
|
||||
data.selected_header = element
|
||||
|
||||
input_text_box.text = concat{ "storage['", key, "']" }
|
||||
input_text_box.style.font_color = Color.black
|
||||
|
||||
local content = dump(storage[key]) or "nil"
|
||||
right_panel.text = content
|
||||
end
|
||||
)
|
||||
|
||||
local function update_dump(text_input, data, player)
|
||||
local suc, ouput = dump_text(text_input.text, player)
|
||||
if not suc then
|
||||
text_input.style.font_color = Color.red
|
||||
else
|
||||
text_input.style.font_color = Color.black
|
||||
data.right_panel.text = ouput
|
||||
end
|
||||
end
|
||||
|
||||
Gui.on_text_changed(
|
||||
input_text_box_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local data = Gui.get_data(element)
|
||||
|
||||
update_dump(element, data, event.player)
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
refresh_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local data = Gui.get_data(element)
|
||||
|
||||
local input_text_box = data.input_text_box
|
||||
|
||||
update_dump(input_text_box, data, event.player)
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
||||
@@ -1,113 +0,0 @@
|
||||
local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
|
||||
local Color = require("modules/exp_util/include/color")
|
||||
|
||||
local Public = {}
|
||||
|
||||
local pages = {
|
||||
require("modules.exp_legacy.modules.gui.debug.redmew_global_view"),
|
||||
require("modules.exp_legacy.modules.gui.debug.expcore_datastore_view"),
|
||||
require("modules.exp_legacy.modules.gui.debug.expcore_gui_view"),
|
||||
require("modules.exp_legacy.modules.gui.debug.global_view"),
|
||||
require("modules.exp_legacy.modules.gui.debug.package_view"),
|
||||
require("modules.exp_legacy.modules.gui.debug._g_view"),
|
||||
require("modules.exp_legacy.modules.gui.debug.event_view"),
|
||||
}
|
||||
|
||||
local main_frame_name = Gui.uid_name()
|
||||
local close_name = Gui.uid_name()
|
||||
local tab_name = Gui.uid_name()
|
||||
|
||||
function Public.open_debug(player)
|
||||
for i = 1, #pages do
|
||||
local page = pages[i]
|
||||
local callback = page.on_open_debug
|
||||
if callback then
|
||||
callback()
|
||||
end
|
||||
end
|
||||
|
||||
local center = player.gui.center
|
||||
local frame = center[main_frame_name]
|
||||
if frame then
|
||||
return
|
||||
end
|
||||
|
||||
--[[
|
||||
local screen_element = player.gui.screen
|
||||
|
||||
frame = screen_element.add{type = 'frame', name = main_frame_name, caption = 'Debuggertron 3000'}
|
||||
frame.style.size = {900, 600}
|
||||
frame.auto_center = true
|
||||
]]
|
||||
|
||||
frame = center.add{ type = "frame", name = main_frame_name, caption = "Debuggertron 3002", direction = "vertical" }
|
||||
local frame_style = frame.style
|
||||
frame_style.height = 600
|
||||
frame_style.width = 900
|
||||
|
||||
local tab_flow = frame.add{ type = "flow", direction = "horizontal" }
|
||||
local container = frame.add{ type = "flow" }
|
||||
container.style.vertically_stretchable = true
|
||||
|
||||
local data = {}
|
||||
|
||||
for i = 1, #pages do
|
||||
local page = pages[i]
|
||||
local tab_button = tab_flow.add{ type = "flow" }.add{ type = "button", name = tab_name, caption = page.name }
|
||||
local tab_button_style = tab_button.style
|
||||
|
||||
Gui.set_data(tab_button, { index = i, frame_data = data })
|
||||
|
||||
if i == 1 then
|
||||
tab_button_style.font_color = Color.orange
|
||||
|
||||
data.selected_index = i
|
||||
data.selected_tab_button = tab_button
|
||||
data.container = container
|
||||
|
||||
Gui.set_data(frame, data)
|
||||
page.show(container)
|
||||
end
|
||||
end
|
||||
|
||||
frame.add{ type = "button", name = close_name, caption = "Close" }
|
||||
end
|
||||
|
||||
Gui.on_click(
|
||||
tab_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local data = Gui.get_data(element)
|
||||
|
||||
local index = data.index
|
||||
local frame_data = data.frame_data
|
||||
local selected_index = frame_data.selected_index
|
||||
|
||||
if selected_index == index then
|
||||
return
|
||||
end
|
||||
|
||||
local selected_tab_button = frame_data.selected_tab_button
|
||||
selected_tab_button.style.font_color = Color.black
|
||||
|
||||
frame_data.selected_tab_button = element
|
||||
frame_data.selected_index = index
|
||||
element.style.font_color = Color.orange
|
||||
|
||||
local container = frame_data.container
|
||||
Gui.clear(container)
|
||||
pages[index].show(container)
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
close_name,
|
||||
function(event)
|
||||
local frame = event.player.gui.center[main_frame_name]
|
||||
if frame then
|
||||
Gui.destroy(frame)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
||||
@@ -1,73 +0,0 @@
|
||||
local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
|
||||
local concat = table.concat
|
||||
local inspect = table.inspect
|
||||
local pcall = pcall
|
||||
local loadstring = loadstring --- @diagnostic disable-line
|
||||
local rawset = rawset
|
||||
|
||||
local Public = {}
|
||||
|
||||
local inspect_process = ExpUtil.safe_value
|
||||
|
||||
local inspect_options = { process = inspect_process }
|
||||
function Public.dump(data)
|
||||
return inspect(data, inspect_options)
|
||||
end
|
||||
|
||||
local dump = Public.dump
|
||||
|
||||
function Public.dump_ignore_builder(ignore)
|
||||
local function process(item)
|
||||
if ignore[item] then
|
||||
return nil
|
||||
end
|
||||
|
||||
return inspect_process(item)
|
||||
end
|
||||
|
||||
local options = { process = process }
|
||||
return function(data)
|
||||
return inspect(data, options)
|
||||
end
|
||||
end
|
||||
|
||||
function Public.dump_function(func)
|
||||
local res = { "upvalues:\n", "no longer available" }
|
||||
|
||||
local i = 1
|
||||
--[[while true do
|
||||
local n, v = debug.getupvalue(func, i)
|
||||
|
||||
if n == nil then
|
||||
break
|
||||
elseif n ~= "_ENV" then
|
||||
res[#res + 1] = n
|
||||
res[#res + 1] = " = "
|
||||
res[#res + 1] = dump(v)
|
||||
res[#res + 1] = "\n"
|
||||
end
|
||||
|
||||
i = i + 1
|
||||
end]]
|
||||
|
||||
return concat(res)
|
||||
end
|
||||
|
||||
function Public.dump_text(text, player)
|
||||
local func = loadstring("return " .. text)
|
||||
if not func then
|
||||
return false
|
||||
end
|
||||
|
||||
local suc, var = pcall(func)
|
||||
|
||||
if not suc then
|
||||
return false
|
||||
end
|
||||
|
||||
return true, dump(var)
|
||||
end
|
||||
|
||||
return Public
|
||||
@@ -1,161 +0,0 @@
|
||||
local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
|
||||
local Color = require("modules/exp_util/include/color")
|
||||
local Model = require("modules.exp_legacy.modules.gui.debug.model") --- @dep modules.gui.debug.model
|
||||
|
||||
local dump_function = Model.dump_function
|
||||
local loaded = _G.package.loaded
|
||||
|
||||
local Public = {}
|
||||
|
||||
local ignore = {
|
||||
_G = true,
|
||||
package = true,
|
||||
coroutine = true,
|
||||
table = true,
|
||||
string = true,
|
||||
bit32 = true,
|
||||
math = true,
|
||||
debug = true,
|
||||
serpent = true,
|
||||
["overrides.math"] = true,
|
||||
util = true,
|
||||
["mod-gui"] = true,
|
||||
}
|
||||
|
||||
local file_label_name = Gui.uid_name()
|
||||
local left_panel_name = Gui.uid_name()
|
||||
local breadcrumbs_name = Gui.uid_name()
|
||||
local top_panel_name = Gui.uid_name()
|
||||
local variable_label_name = Gui.uid_name()
|
||||
local text_box_name = Gui.uid_name()
|
||||
|
||||
Public.name = "package"
|
||||
|
||||
function Public.show(container)
|
||||
local main_flow = container.add{ type = "flow", direction = "horizontal" }
|
||||
|
||||
local left_panel = main_flow.add{ type = "scroll-pane", name = left_panel_name }
|
||||
local left_panel_style = left_panel.style
|
||||
left_panel_style.width = 300
|
||||
|
||||
for name, file in pairs(loaded) do
|
||||
if not ignore[name] then
|
||||
local file_label =
|
||||
left_panel.add{ type = "flow" }.add{ type = "label", name = file_label_name, caption = name }
|
||||
Gui.set_data(file_label, file)
|
||||
end
|
||||
end
|
||||
|
||||
local right_flow = main_flow.add{ type = "flow", direction = "vertical" }
|
||||
|
||||
local breadcrumbs = right_flow.add{ type = "label", name = breadcrumbs_name }
|
||||
|
||||
local top_panel = right_flow.add{ type = "scroll-pane", name = top_panel_name }
|
||||
local top_panel_style = top_panel.style
|
||||
top_panel_style.height = 200
|
||||
top_panel_style.maximal_width = 1000
|
||||
top_panel_style.horizontally_stretchable = true
|
||||
|
||||
local text_box = right_flow.add{ type = "text-box", name = text_box_name }
|
||||
text_box.read_only = true
|
||||
text_box.selectable = true
|
||||
|
||||
local text_box_style = text_box.style
|
||||
text_box_style.vertically_stretchable = true
|
||||
text_box_style.horizontally_stretchable = true
|
||||
text_box_style.maximal_width = 1000
|
||||
text_box_style.maximal_height = 1000
|
||||
|
||||
local data = {
|
||||
left_panel = left_panel,
|
||||
breadcrumbs = breadcrumbs,
|
||||
top_panel = top_panel,
|
||||
text_box = text_box,
|
||||
selected_file_label = nil,
|
||||
selected_variable_label = nil,
|
||||
}
|
||||
|
||||
Gui.set_data(left_panel, data)
|
||||
Gui.set_data(top_panel, data)
|
||||
end
|
||||
|
||||
Gui.on_click(
|
||||
file_label_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local file = Gui.get_data(element)
|
||||
|
||||
local left_panel = element.parent.parent
|
||||
local data = Gui.get_data(left_panel)
|
||||
|
||||
local selected_file_label = data.selected_file_label
|
||||
|
||||
if selected_file_label then
|
||||
selected_file_label.style.font_color = Color.white
|
||||
end
|
||||
|
||||
element.style.font_color = Color.orange
|
||||
data.selected_file_label = element
|
||||
|
||||
local top_panel = data.top_panel
|
||||
local text_box = data.text_box
|
||||
|
||||
Gui.clear(top_panel)
|
||||
|
||||
local file_type = type(file)
|
||||
|
||||
if file_type == "table" then
|
||||
for k, v in pairs(file) do
|
||||
local label =
|
||||
top_panel.add{ type = "flow" }.add{ type = "label", name = variable_label_name, caption = k }
|
||||
Gui.set_data(label, v)
|
||||
end
|
||||
elseif file_type == "function" then
|
||||
text_box.text = dump_function(file)
|
||||
else
|
||||
text_box.text = tostring(file)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
variable_label_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local variable = Gui.get_data(element)
|
||||
|
||||
local top_panel = element.parent.parent
|
||||
local data = Gui.get_data(top_panel)
|
||||
local text_box = data.text_box
|
||||
|
||||
local variable_type = type(variable)
|
||||
|
||||
if variable_type == "table" then
|
||||
Gui.clear(top_panel)
|
||||
for k, v in pairs(variable) do
|
||||
local label =
|
||||
top_panel.add{ type = "flow" }.add{ type = "label", name = variable_label_name, caption = k }
|
||||
Gui.set_data(label, v)
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
local selected_label = data.selected_variable_label
|
||||
|
||||
if selected_label and selected_label.valid then
|
||||
selected_label.style.font_color = Color.white
|
||||
end
|
||||
|
||||
element.style.font_color = Color.orange
|
||||
data.selected_variable_label = element
|
||||
|
||||
if variable_type == "function" then
|
||||
text_box.text = dump_function(variable)
|
||||
else
|
||||
text_box.text = tostring(variable)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
||||
@@ -1,129 +0,0 @@
|
||||
local Gui = require("modules.exp_legacy.utils.gui") --- @dep utils.gui
|
||||
local Storage = require("modules/exp_util/storage")
|
||||
local Color = require("modules/exp_util/include/color")
|
||||
local Model = require("modules.exp_legacy.modules.gui.debug.model") --- @dep modules.gui.debug.model
|
||||
|
||||
local dump = Model.dump
|
||||
local dump_text = Model.dump_text
|
||||
local concat = table.concat
|
||||
|
||||
local Public = {}
|
||||
|
||||
local header_name = Gui.uid_name()
|
||||
local left_panel_name = Gui.uid_name()
|
||||
local right_panel_name = Gui.uid_name()
|
||||
local input_text_box_name = Gui.uid_name()
|
||||
local refresh_name = Gui.uid_name()
|
||||
|
||||
Public.name = "Storage"
|
||||
|
||||
function Public.show(container)
|
||||
local main_flow = container.add{ type = "flow", direction = "horizontal" }
|
||||
|
||||
local left_panel = main_flow.add{ type = "scroll-pane", name = left_panel_name }
|
||||
local left_panel_style = left_panel.style
|
||||
left_panel_style.width = 300
|
||||
|
||||
--- @diagnostic disable-next-line invisible
|
||||
for token_id in pairs(Storage._registered) do
|
||||
local header = left_panel.add{ type = "flow" }.add{ type = "label", name = header_name, caption = token_id }
|
||||
Gui.set_data(header, token_id)
|
||||
end
|
||||
|
||||
local right_flow = main_flow.add{ type = "flow", direction = "vertical" }
|
||||
|
||||
local right_top_flow = right_flow.add{ type = "flow", direction = "horizontal" }
|
||||
|
||||
local input_text_box = right_top_flow.add{ type = "text-box", name = input_text_box_name }
|
||||
local input_text_box_style = input_text_box.style
|
||||
input_text_box_style.horizontally_stretchable = true
|
||||
input_text_box_style.height = 32
|
||||
input_text_box_style.maximal_width = 1000
|
||||
|
||||
local refresh_button =
|
||||
right_top_flow.add{ type = "sprite-button", name = refresh_name, sprite = "utility/reset", tooltip = "refresh" }
|
||||
local refresh_button_style = refresh_button.style
|
||||
refresh_button_style.width = 32
|
||||
refresh_button_style.height = 32
|
||||
|
||||
local right_panel = right_flow.add{ type = "text-box", name = right_panel_name }
|
||||
right_panel.read_only = true
|
||||
right_panel.selectable = true
|
||||
|
||||
local right_panel_style = right_panel.style
|
||||
right_panel_style.vertically_stretchable = true
|
||||
right_panel_style.horizontally_stretchable = true
|
||||
right_panel_style.maximal_width = 1000
|
||||
right_panel_style.maximal_height = 1000
|
||||
|
||||
local data = {
|
||||
right_panel = right_panel,
|
||||
input_text_box = input_text_box,
|
||||
selected_header = nil,
|
||||
}
|
||||
|
||||
Gui.set_data(input_text_box, data)
|
||||
Gui.set_data(left_panel, data)
|
||||
Gui.set_data(refresh_button, data)
|
||||
end
|
||||
|
||||
Gui.on_click(
|
||||
header_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local token_id = Gui.get_data(element)
|
||||
|
||||
local left_panel = element.parent.parent
|
||||
local data = Gui.get_data(left_panel)
|
||||
local right_panel = data.right_panel
|
||||
local selected_header = data.selected_header
|
||||
local input_text_box = data.input_text_box
|
||||
|
||||
if selected_header then
|
||||
selected_header.style.font_color = Color.white
|
||||
end
|
||||
|
||||
element.style.font_color = Color.orange
|
||||
data.selected_header = element
|
||||
|
||||
input_text_box.text = concat{ "storage.exp_storage['", token_id, "']" }
|
||||
input_text_box.style.font_color = Color.black
|
||||
|
||||
local content = dump(storage.exp_storage[token_id]) or "nil"
|
||||
right_panel.text = content
|
||||
end
|
||||
)
|
||||
|
||||
local function update_dump(text_input, data, player)
|
||||
local suc, ouput = dump_text(text_input.text, player)
|
||||
if not suc then
|
||||
text_input.style.font_color = Color.red
|
||||
else
|
||||
text_input.style.font_color = Color.black
|
||||
data.right_panel.text = ouput
|
||||
end
|
||||
end
|
||||
|
||||
Gui.on_text_changed(
|
||||
input_text_box_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local data = Gui.get_data(element)
|
||||
|
||||
update_dump(element, data, event.player)
|
||||
end
|
||||
)
|
||||
|
||||
Gui.on_click(
|
||||
refresh_name,
|
||||
function(event)
|
||||
local element = event.element
|
||||
local data = Gui.get_data(element)
|
||||
|
||||
local input_text_box = data.input_text_box
|
||||
|
||||
update_dump(input_text_box, data, event.player)
|
||||
end
|
||||
)
|
||||
|
||||
return Public
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
@@ -1,448 +0,0 @@
|
||||
--[[-- Gui Module - Player List
|
||||
- Adds a player list to show names and play time; also includes action buttons which can preform actions to players
|
||||
@gui Player-List
|
||||
@alias player_list
|
||||
]]
|
||||
|
||||
-- luacheck:ignore 211/Colors
|
||||
local ExpUtil = require("modules/exp_util")
|
||||
local Gui = require("modules/exp_gui")
|
||||
local Roles = require("modules.exp_legacy.expcore.roles") --- @dep expcore.roles
|
||||
local Datastore = require("modules.exp_legacy.expcore.datastore") --- @dep expcore.datastore
|
||||
local Event = require("modules/exp_legacy/utils/event") --- @dep utils.event
|
||||
local config = require("modules.exp_legacy.config.gui.player_list_actions") --- @dep config.gui.player_list_actions
|
||||
|
||||
--- Stores all data for the warp gui
|
||||
local PlayerListData = Datastore.connect("PlayerListData")
|
||||
PlayerListData:set_serializer(Datastore.name_serializer)
|
||||
local SelectedPlayer = PlayerListData:combine("SelectedPlayer")
|
||||
local SelectedAction = PlayerListData:combine("SelectedAction")
|
||||
|
||||
-- Set the config to use these stores
|
||||
config.set_datastores(SelectedPlayer, SelectedAction)
|
||||
|
||||
--- Button used to open the action bar
|
||||
-- @element open_action_bar
|
||||
local open_action_bar = Gui.define("open_action_bar")
|
||||
:draw{
|
||||
type = "sprite-button",
|
||||
sprite = "utility/expand_dots",
|
||||
tooltip = { "player-list.open-action-bar" },
|
||||
style = "frame_button",
|
||||
name = Gui.from_name,
|
||||
}
|
||||
:style{
|
||||
padding = -2,
|
||||
width = 8,
|
||||
height = 14,
|
||||
}
|
||||
:on_click(function(def, player, element)
|
||||
local selected_player_name = element.parent.name
|
||||
local old_selected_player_name = SelectedPlayer:get(player)
|
||||
if selected_player_name == old_selected_player_name then
|
||||
SelectedPlayer:remove(player)
|
||||
else
|
||||
SelectedPlayer:set(player, selected_player_name)
|
||||
end
|
||||
end)
|
||||
|
||||
--- Button used to close the action bar
|
||||
-- @element close_action_bar
|
||||
local close_action_bar = Gui.define("close_action_bar")
|
||||
:draw{
|
||||
type = "sprite-button",
|
||||
sprite = "utility/close_black",
|
||||
tooltip = { "player-list.close-action-bar" },
|
||||
style = "slot_sized_button_red",
|
||||
}
|
||||
:style(Gui.styles.sprite{
|
||||
size = 20,
|
||||
padding = -1,
|
||||
top_margin = -1,
|
||||
right_margin = -1,
|
||||
})
|
||||
:on_click(function(def, player, element)
|
||||
SelectedPlayer:remove(player)
|
||||
SelectedAction:remove(player)
|
||||
end)
|
||||
|
||||
--- Button used to confirm a reason
|
||||
-- @element reason_confirm
|
||||
local reason_confirm = Gui.define("reason_confirm")
|
||||
:draw{
|
||||
type = "sprite-button",
|
||||
sprite = "utility/confirm_slot",
|
||||
tooltip = { "player-list.reason-confirm" },
|
||||
style = "slot_sized_button_green",
|
||||
}
|
||||
:style(Gui.styles.sprite{
|
||||
size = 30,
|
||||
padding = -1,
|
||||
left_margin = -2,
|
||||
right_margin = -1,
|
||||
})
|
||||
:on_click(function(def, player, element)
|
||||
local reason = element.parent.entry.text
|
||||
local action_name = SelectedAction:get(player)
|
||||
local reason_callback = config.buttons[action_name].reason_callback
|
||||
if reason == nil or not reason:find("%S") then reason = "no reason given" end
|
||||
reason_callback(player, reason)
|
||||
SelectedPlayer:remove(player)
|
||||
SelectedAction:remove(player)
|
||||
element.parent.entry.text = ""
|
||||
end)
|
||||
|
||||
--- Set of elements that are used to make up a row of the player table
|
||||
-- @element add_player_base
|
||||
local add_player_base = Gui.define("add_player_base")
|
||||
:draw(function(_, parent, player_data)
|
||||
-- Add the button to open the action bar
|
||||
local toggle_action_bar_flow = parent.add{ type = "flow", name = player_data.name }
|
||||
open_action_bar(toggle_action_bar_flow)
|
||||
|
||||
-- Add the player name
|
||||
local player_name = parent.add{
|
||||
type = "label",
|
||||
name = "player-name-" .. player_data.index,
|
||||
caption = player_data.name,
|
||||
tooltip = { "player-list.open-map", player_data.name, player_data.tag, player_data.role_name },
|
||||
}
|
||||
player_name.style.padding = { 0, 2, 0, 0 }
|
||||
player_name.style.font_color = player_data.chat_color
|
||||
|
||||
-- Add the time played label
|
||||
local alignment = Gui.elements.aligned_flow(parent, { name = "player-time-" .. player_data.index })
|
||||
local time_label = alignment.add{
|
||||
name = "label",
|
||||
type = "label",
|
||||
caption = player_data.caption,
|
||||
tooltip = player_data.tooltip,
|
||||
}
|
||||
time_label.style.padding = 0
|
||||
|
||||
return player_name
|
||||
end)
|
||||
:on_click(function(def, player, element, event)
|
||||
local selected_player_name = element.caption
|
||||
local selected_player = game.players[selected_player_name]
|
||||
if event.button == defines.mouse_button_type.left then
|
||||
-- LMB will open the map to the selected player
|
||||
player.set_controller{
|
||||
type = defines.controllers.remote,
|
||||
position = selected_player.physical_position,
|
||||
surface = selected_player.physical_surface
|
||||
}
|
||||
else
|
||||
-- RMB will toggle the settings
|
||||
local old_selected_player_name = SelectedPlayer:get(player)
|
||||
if selected_player_name == old_selected_player_name then
|
||||
SelectedPlayer:remove(player)
|
||||
SelectedAction:remove(player)
|
||||
else
|
||||
SelectedPlayer:set(player, selected_player_name)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
-- Removes the three elements that are added as part of the base
|
||||
local function remove_player_base(parent, player)
|
||||
Gui.destroy_if_valid(parent[player.name])
|
||||
Gui.destroy_if_valid(parent["player-name-" .. player.index])
|
||||
Gui.destroy_if_valid(parent["player-time-" .. player.index])
|
||||
end
|
||||
|
||||
-- Update the time label for a player using there player time data
|
||||
local function update_player_base(parent, player_time)
|
||||
local time_element = parent[player_time.element_name]
|
||||
if time_element and time_element.valid then
|
||||
time_element.label.caption = player_time.caption
|
||||
time_element.label.tooltip = player_time.tooltip
|
||||
end
|
||||
end
|
||||
|
||||
--- Adds all the buttons and flows that make up the action bar
|
||||
-- @element add_action_bar
|
||||
local add_action_bar_buttons = Gui.define("add_action_bar_buttons")
|
||||
:draw(function(_, parent)
|
||||
close_action_bar(parent)
|
||||
-- Loop over all the buttons in the config
|
||||
for action_name, button_data in pairs(config.buttons) do
|
||||
-- Added the permission flow
|
||||
local permission_flow = parent.add{ type = "flow", name = action_name }
|
||||
permission_flow.visible = false
|
||||
-- Add the buttons under that permission
|
||||
for _, button in ipairs(button_data) do
|
||||
button(permission_flow)
|
||||
end
|
||||
end
|
||||
|
||||
return parent
|
||||
end)
|
||||
|
||||
--- Updates the visible state of the action bar buttons
|
||||
local function update_action_bar(element)
|
||||
local player = Gui.get_player(element)
|
||||
local selected_player_name = SelectedPlayer:get(player)
|
||||
|
||||
if not selected_player_name then
|
||||
-- Hide the action bar when no player is selected
|
||||
element.visible = false
|
||||
else
|
||||
local selected_player = game.players[selected_player_name]
|
||||
if not selected_player.connected then
|
||||
-- If the player is offline then reest stores
|
||||
element.visible = false
|
||||
SelectedPlayer:remove(player)
|
||||
SelectedAction:remove(player)
|
||||
else
|
||||
-- Otherwise check what actions the player is allowed to use
|
||||
element.visible = true
|
||||
for action_name, buttons in pairs(config.buttons) do
|
||||
if buttons.auth and not buttons.auth(player, selected_player) then
|
||||
element[action_name].visible = false
|
||||
elseif Roles.player_allowed(player, action_name) then
|
||||
element[action_name].visible = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Main player list container for the left flow
|
||||
-- @element player_list_container
|
||||
local player_list_container = Gui.define("player_list_container")
|
||||
:draw(function(definition, parent)
|
||||
-- Draw the internal container
|
||||
local container = Gui.elements.container(parent)
|
||||
|
||||
-- Draw the scroll table for the players
|
||||
local scroll_table = Gui.elements.scroll_table(container, 184, 3, "scroll")
|
||||
|
||||
-- Change the style of the scroll table
|
||||
local scroll_table_style = scroll_table.style
|
||||
scroll_table_style.padding = { 1, 0, 1, 2 }
|
||||
|
||||
-- Add the action bar
|
||||
local action_bar = Gui.elements.footer(container, { name = "action_bar", no_flow = true })
|
||||
|
||||
-- Change the style of the action bar
|
||||
local action_bar_style = action_bar.style
|
||||
action_bar_style.height = 35
|
||||
action_bar_style.padding = { 1, 3 }
|
||||
action_bar.visible = false
|
||||
|
||||
-- Add the buttons to the action bar
|
||||
add_action_bar_buttons(action_bar)
|
||||
|
||||
-- Add the reason bar
|
||||
local reason_bar = Gui.elements.footer(container, { name = "reason_bar", no_flow = true })
|
||||
|
||||
-- Change the style of the reason bar
|
||||
local reason_bar_style = reason_bar.style
|
||||
reason_bar_style.height = 35
|
||||
reason_bar_style.padding = { -1, 3 }
|
||||
reason_bar.visible = false
|
||||
|
||||
-- Add the text entry for the reason bar
|
||||
local reason_field =
|
||||
reason_bar.add{
|
||||
name = "entry",
|
||||
type = "textfield",
|
||||
style = "stretchable_textfield",
|
||||
tooltip = { "player-list.reason-entry" },
|
||||
}
|
||||
|
||||
-- Change the style of the text entry
|
||||
local reason_entry_style = reason_field.style
|
||||
reason_entry_style.padding = 0
|
||||
reason_entry_style.height = 28
|
||||
reason_entry_style.minimal_width = 160
|
||||
|
||||
-- Add the confirm reason button
|
||||
reason_confirm(reason_bar)
|
||||
|
||||
-- Return the exteral container
|
||||
return container.parent
|
||||
end)
|
||||
|
||||
--- Add the element to the left flow with a toolbar button
|
||||
Gui.add_left_element(player_list_container, true)
|
||||
Gui.toolbar.create_button{
|
||||
name = "player_list_toggle",
|
||||
left_element = player_list_container,
|
||||
sprite = "entity/character",
|
||||
tooltip = { "player-list.main-tooltip" },
|
||||
visible = function(player, element)
|
||||
return Roles.player_allowed(player, "gui/player-list")
|
||||
end
|
||||
}
|
||||
|
||||
local online_time_format = ExpUtil.format_time_factory_locale{ format = "short", hours = true, minutes = true }
|
||||
local afk_time_format = ExpUtil.format_time_factory_locale{ format = "long", minutes = true }
|
||||
|
||||
-- Get caption and tooltip format for a player
|
||||
local function get_time_formats(online_time, afk_time)
|
||||
local tick = game.tick > 0 and game.tick or 1
|
||||
local percent = math.round(online_time / tick, 3) * 100
|
||||
local caption = online_time_format(online_time)
|
||||
local tooltip = { "player-list.afk-time", percent, afk_time_format(afk_time) }
|
||||
return caption, tooltip
|
||||
end
|
||||
|
||||
-- Get the player time to be used to update time label
|
||||
local function get_player_times()
|
||||
local ctn = 0
|
||||
local player_times = {}
|
||||
for _, player in pairs(game.connected_players) do
|
||||
ctn = ctn + 1
|
||||
-- Add the player time details to the array
|
||||
local caption, tooltip = get_time_formats(player.online_time, player.afk_time)
|
||||
player_times[ctn] = {
|
||||
element_name = "player-time-" .. player.index,
|
||||
caption = caption,
|
||||
tooltip = tooltip,
|
||||
}
|
||||
end
|
||||
|
||||
return player_times
|
||||
end
|
||||
|
||||
-- Get a sorted list of all online players
|
||||
local function get_player_list_order()
|
||||
-- Sort all the online players into roles
|
||||
local players = {}
|
||||
for _, player in pairs(game.connected_players) do
|
||||
local highest_role = Roles.get_player_highest_role(player)
|
||||
if not players[highest_role.name] then
|
||||
players[highest_role.name] = {}
|
||||
end
|
||||
table.insert(players[highest_role.name], player)
|
||||
end
|
||||
|
||||
-- Sort the players from roles into a set order
|
||||
local ctn = 0
|
||||
local player_list_order = {}
|
||||
for _, role_name in pairs(Roles.config.order) do
|
||||
if players[role_name] then
|
||||
for _, player in pairs(players[role_name]) do
|
||||
ctn = ctn + 1
|
||||
-- Add the player data to the array
|
||||
local caption, tooltip = get_time_formats(player.online_time, player.afk_time)
|
||||
player_list_order[ctn] = {
|
||||
name = player.name,
|
||||
index = player.index,
|
||||
tag = player.tag,
|
||||
role_name = role_name,
|
||||
chat_color = player.chat_color,
|
||||
caption = caption,
|
||||
tooltip = tooltip,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--[[Adds fake players to the player list
|
||||
local tick = game.tick+1
|
||||
for i = 1, 10 do
|
||||
local online_time = math.random(1, tick)
|
||||
local afk_time = math.random(online_time-(tick/10), tick)
|
||||
local caption, tooltip = get_time_formats(online_time, afk_time)
|
||||
player_list_order[ctn+i] = {
|
||||
name='Player '..i,
|
||||
index=0-i,
|
||||
tag='',
|
||||
role_name = 'Fake Player',
|
||||
chat_color = table.get_random(Colors),
|
||||
caption = caption,
|
||||
tooltip = tooltip
|
||||
}
|
||||
end--]]
|
||||
|
||||
return player_list_order
|
||||
end
|
||||
|
||||
--- Update the play times every 30 sections
|
||||
Event.on_nth_tick(1800, function()
|
||||
local player_times = get_player_times()
|
||||
for _, player in pairs(game.connected_players) do
|
||||
local container = Gui.get_left_element(player_list_container, player)
|
||||
local scroll_table = container.frame.scroll.table
|
||||
for _, player_time in pairs(player_times) do
|
||||
update_player_base(scroll_table, player_time)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
--- When a player leaves only remove they entry
|
||||
Event.add(defines.events.on_player_left_game, function(event)
|
||||
local remove_player = game.players[event.player_index]
|
||||
for _, player in pairs(game.connected_players) do
|
||||
local container = Gui.get_left_element(player_list_container, player)
|
||||
local scroll_table = container.frame.scroll.table
|
||||
remove_player_base(scroll_table, remove_player)
|
||||
|
||||
local selected_player_name = SelectedPlayer:get(player)
|
||||
if selected_player_name == remove_player.name then
|
||||
SelectedPlayer:remove(player)
|
||||
SelectedAction:remove(player)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
--- All other events require a full redraw of the table
|
||||
local function redraw_player_list()
|
||||
local player_list_order = get_player_list_order()
|
||||
for _, player in pairs(game.connected_players) do
|
||||
local container = Gui.get_left_element(player_list_container, player)
|
||||
local scroll_table = container.frame.scroll.table
|
||||
scroll_table.clear()
|
||||
for _, next_player_data in ipairs(player_list_order) do
|
||||
add_player_base(scroll_table, next_player_data)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Event.add(defines.events.on_player_joined_game, redraw_player_list)
|
||||
Event.add(Roles.events.on_role_assigned, redraw_player_list)
|
||||
Event.add(Roles.events.on_role_unassigned, redraw_player_list)
|
||||
|
||||
--- When the action player is changed the action bar will update
|
||||
SelectedPlayer:on_update(function(player_name, selected_player)
|
||||
local player = game.players[player_name]
|
||||
local container = Gui.get_left_element(player_list_container, player)
|
||||
local scroll_table = container.frame.scroll.table
|
||||
update_action_bar(container.frame.action_bar)
|
||||
for _, next_player in pairs(game.connected_players) do
|
||||
local element = scroll_table[next_player.name][open_action_bar.name]
|
||||
local style = "frame_button"
|
||||
if next_player.name == selected_player then
|
||||
style = "tool_button"
|
||||
end
|
||||
element.style = style
|
||||
local element_style = element.style --[[@as LuaStyle]]
|
||||
element_style.padding = -2
|
||||
element_style.width = 8
|
||||
element_style.height = 14
|
||||
end
|
||||
end)
|
||||
|
||||
--- When the action name is changed the reason input will update
|
||||
SelectedAction:on_update(function(player_name, selected_action)
|
||||
local player = game.players[player_name]
|
||||
local container = Gui.get_left_element(player_list_container, player)
|
||||
local element = container.frame.reason_bar
|
||||
if selected_action then
|
||||
-- if there is a new value then check the player is still online
|
||||
local selected_player_name = SelectedPlayer:get(player_name)
|
||||
local selected_player = game.players[selected_player_name]
|
||||
if selected_player.connected then
|
||||
element.visible = true
|
||||
else
|
||||
-- Clear if the player is offline
|
||||
SelectedPlayer:remove(player)
|
||||
SelectedAction:remove(player)
|
||||
end
|
||||
else
|
||||
element.visible = false
|
||||
end
|
||||
end)
|
||||
@@ -1,132 +0,0 @@
|
||||
local Storage = require("modules/exp_util/storage")
|
||||
local Event = require("modules/exp_legacy/utils/event")
|
||||
local mod_gui = require "mod-gui"
|
||||
|
||||
local Gui = {}
|
||||
local data = {}
|
||||
local uid = 0
|
||||
|
||||
Storage.register(
|
||||
data,
|
||||
function(tbl)
|
||||
data = tbl
|
||||
end
|
||||
)
|
||||
|
||||
function Gui.uid_name()
|
||||
uid = uid + 1
|
||||
return "Redmew_" .. uid
|
||||
end
|
||||
|
||||
-- Associates data with the LuaGuiElement. If data is nil then removes the data
|
||||
function Gui.set_data(element, value)
|
||||
data[element.player_index * 0x100000000 + element.index] = value
|
||||
end
|
||||
|
||||
-- Gets the Associated data with this LuaGuiElement if any.
|
||||
function Gui.get_data(element)
|
||||
return data[element.player_index * 0x100000000 + element.index]
|
||||
end
|
||||
|
||||
-- Removes data associated with LuaGuiElement and its children recursively.
|
||||
function Gui.remove_data_recursively(element)
|
||||
Gui.set_data(element, nil)
|
||||
|
||||
local children = element.children
|
||||
|
||||
if not children then
|
||||
return
|
||||
end
|
||||
|
||||
for _, child in ipairs(children) do
|
||||
if child.valid then
|
||||
Gui.remove_data_recursively(child)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Gui.remove_children_data(element)
|
||||
local children = element.children
|
||||
|
||||
if not children then
|
||||
return
|
||||
end
|
||||
|
||||
for _, child in ipairs(children) do
|
||||
if child.valid then
|
||||
Gui.set_data(child, nil)
|
||||
Gui.remove_children_data(child)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Gui.destroy(element)
|
||||
Gui.remove_data_recursively(element)
|
||||
element.destroy()
|
||||
end
|
||||
|
||||
function Gui.clear(element)
|
||||
Gui.remove_children_data(element)
|
||||
element.clear()
|
||||
end
|
||||
|
||||
local function handler_factory(event_name)
|
||||
return function(element_name, handler)
|
||||
Event.add(defines.events[event_name], function(event)
|
||||
if event.element and event.element.valid and event.element.name == element_name then
|
||||
event.player = game.players[event.player_index]
|
||||
handler(event)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
-- Register a handler for the on_gui_checked_state_changed event for LuaGuiElements with element_name.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_checked_state_changed = handler_factory("on_gui_checked_state_changed")
|
||||
|
||||
-- Register a handler for the on_gui_click event for LuaGuiElements with element_name.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_click = handler_factory("on_gui_click")
|
||||
|
||||
-- Register a handler for the on_gui_closed event for a custom LuaGuiElements with element_name.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_custom_close = handler_factory("on_gui_closed")
|
||||
|
||||
-- Register a handler for the on_gui_elem_changed event for LuaGuiElements with element_name.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_elem_changed = handler_factory("on_gui_elem_changed")
|
||||
|
||||
-- Register a handler for the on_gui_selection_state_changed event for LuaGuiElements with element_name.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_selection_state_changed = handler_factory("on_gui_selection_state_changed")
|
||||
|
||||
-- Register a handler for the on_gui_text_changed event for LuaGuiElements with element_name.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_text_changed = handler_factory("on_gui_text_changed")
|
||||
|
||||
-- Register a handler for the on_gui_value_changed event for LuaGuiElements with element_name.
|
||||
-- Can only have one handler per element name.
|
||||
-- Guarantees that the element and the player are valid when calling the handler.
|
||||
-- Adds a player field to the event table.
|
||||
Gui.on_value_changed = handler_factory("on_gui_value_changed")
|
||||
|
||||
--- Returns the flow where top elements can be added and will be effected by google visibility
|
||||
-- For the toggle to work it must be registed with Gui.allow_player_to_toggle_top_element_visibility(element_name)
|
||||
-- @tparam LuaPlayer player pointer to the player who has the gui
|
||||
-- @treturn LuaGuiElement the top element flow
|
||||
Gui.get_top_element_flow = mod_gui.get_button_flow
|
||||
|
||||
return Gui
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@expcluster/legacy",
|
||||
"version": "0.1.0",
|
||||
"version": "6.5.0",
|
||||
"description": "Clusterio plugin implementing the legacy v6 scenario updated for factorio 2.0",
|
||||
"author": "Cooldude2606 <https://github.com/Cooldude2606>",
|
||||
"license": "MIT",
|
||||
@@ -26,6 +26,7 @@
|
||||
"dependencies": {
|
||||
"@expcluster/lib_commands": "workspace:^",
|
||||
"@expcluster/lib_util": "workspace:^",
|
||||
"@expcluster/lib_gui": "workspace:^",
|
||||
"@sinclair/typebox": "catalog:"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
||||
Reference in New Issue
Block a user