2021-12-05 23:15:49 +02:00
local Antigrief = require ' utils.antigrief '
2021-05-07 01:36:10 +02:00
local Event = require ' utils.event '
2020-08-22 18:08:39 +02:00
local Color = require ' utils.color_presets '
2020-08-22 17:20:59 +02:00
local SessionData = require ' utils.datastore.session_data '
2020-08-22 17:30:28 +02:00
local Utils = require ' utils.core '
2020-12-14 20:36:37 +02:00
local SpamProtection = require ' utils.spam_protection '
2022-04-05 19:28:08 +02:00
local BottomFrame = require ' utils.gui.bottom_frame '
2021-03-26 00:49:57 +02:00
local Token = require ' utils.token '
2021-05-07 01:36:10 +02:00
local Global = require ' utils.global '
2021-05-23 17:03:52 +02:00
local Gui = require ' utils.gui '
2021-03-26 00:49:57 +02:00
2022-04-05 19:28:08 +02:00
local module_name = Gui.uid_name ( )
2020-04-18 21:09:11 +02:00
2021-05-08 02:03:38 +02:00
local Public = { }
2021-05-07 01:36:10 +02:00
local this = {
gui_config = {
2021-05-25 22:19:20 +02:00
spaghett = {
undo = { }
} ,
2021-05-07 01:36:10 +02:00
poll_trusted = false
}
}
Global.register (
this ,
function ( tbl )
this = tbl
end
)
2020-04-18 21:09:11 +02:00
local spaghett_entity_blacklist = {
2020-08-22 17:20:59 +02:00
[ ' logistic-chest-requester ' ] = true ,
[ ' logistic-chest-buffer ' ] = true ,
[ ' logistic-chest-active-provider ' ] = true
2020-04-18 21:09:11 +02:00
}
2020-08-22 20:15:56 +02:00
local function get_actor ( event , prefix , msg , admins_only )
2020-08-22 17:20:59 +02:00
local player = game.get_player ( event.player_index )
if not player or not player.valid then
return
end
2020-08-22 20:15:56 +02:00
if admins_only then
Utils.print_admins ( msg , player.name )
else
Utils.action_warning ( prefix , player.name .. ' ' .. msg )
end
2020-08-22 17:20:59 +02:00
end
2020-04-18 21:09:11 +02:00
local function spaghett_deny_building ( event )
2021-05-07 01:36:10 +02:00
local spaghett = this.gui_config . spaghett
2020-08-22 17:20:59 +02:00
if not spaghett.enabled then
return
end
local entity = event.created_entity
if not entity.valid then
return
end
if not spaghett_entity_blacklist [ event.created_entity . name ] then
return
end
if event.player_index then
2021-12-05 23:26:18 +02:00
game.get_player ( event.player_index ) . insert ( { name = entity.name , count = 1 } )
2020-08-22 17:20:59 +02:00
else
local inventory = event.robot . get_inventory ( defines.inventory . robot_cargo )
inventory.insert ( { name = entity.name , count = 1 } )
end
event.created_entity . surface.create_entity (
{
name = ' flying-text ' ,
position = entity.position ,
text = ' Spaghett Mode Active! ' ,
color = { r = 0.98 , g = 0.66 , b = 0.22 }
}
)
entity.destroy ( )
2020-04-18 21:09:11 +02:00
end
local function spaghett ( )
2021-05-07 01:36:10 +02:00
local spaghetti = this.gui_config . spaghett
2022-03-07 09:36:18 +02:00
if spaghetti.noop then
return
end
2021-03-24 18:36:07 +02:00
if spaghetti.enabled then
2020-08-22 17:20:59 +02:00
for _ , f in pairs ( game.forces ) do
if f.technologies [ ' logistic-system ' ] . researched then
2021-03-24 18:36:07 +02:00
spaghetti.undo [ f.index ] = true
2020-08-22 17:20:59 +02:00
end
f.technologies [ ' logistic-system ' ] . enabled = false
f.technologies [ ' logistic-system ' ] . researched = false
end
else
for _ , f in pairs ( game.forces ) do
f.technologies [ ' logistic-system ' ] . enabled = true
2021-03-24 18:36:07 +02:00
if spaghetti.undo [ f.index ] then
2020-08-22 17:20:59 +02:00
f.technologies [ ' logistic-system ' ] . researched = true
2021-03-24 18:36:07 +02:00
spaghetti.undo [ f.index ] = nil
2020-08-22 17:20:59 +02:00
end
end
end
end
local function trust_connected_players ( )
local trust = SessionData.get_trusted_table ( )
local AG = Antigrief.get ( )
local players = game.connected_players
if not AG.enabled then
for _ , p in pairs ( players ) do
trust [ p.name ] = true
end
else
for _ , p in pairs ( players ) do
trust [ p.name ] = false
end
end
2020-04-18 21:09:11 +02:00
end
local functions = {
2022-04-05 19:28:08 +02:00
[ ' spectator_switch ' ] = function ( event )
2020-08-22 17:20:59 +02:00
if event.element . switch_state == ' left ' then
2021-12-05 23:26:18 +02:00
game.get_player ( event.player_index ) . spectator = true
2020-08-22 17:20:59 +02:00
else
2021-12-05 23:26:18 +02:00
game.get_player ( event.player_index ) . spectator = false
2020-08-22 17:20:59 +02:00
end
end ,
2022-05-16 01:02:25 +02:00
[ ' blueprint_requesting ' ] = function ( event )
local BPRequests = is_loaded ( ' modules.blueprint_requesting ' )
local Module = BPRequests.get ( )
if not Module [ event.player_index ] then
Module [ event.player_index ] = { }
end
if event.element . switch_state == ' left ' then
Module [ event.player_index ] . disabled = false
else
Module [ event.player_index ] . disabled = true
end
end ,
2022-04-05 19:28:08 +02:00
[ ' bottom_location ' ] = function ( event )
2021-05-23 17:03:52 +02:00
local player = game.get_player ( event.player_index )
if event.element . switch_state == ' left ' then
2021-05-25 22:19:20 +02:00
BottomFrame.set_location ( player , ' bottom_left ' )
else
BottomFrame.set_location ( player , ' bottom_right ' )
end
end ,
2022-04-05 19:28:08 +02:00
[ ' middle_location ' ] = function ( event )
2021-05-25 22:19:20 +02:00
local player = game.get_player ( event.player_index )
local data = BottomFrame.get_player_data ( player )
if event.element . switch_state == ' left ' then
data.above = true
data.portable = false
else
data.above = false
data.portable = false
end
if not data.bottom_state then
data.bottom_state = ' bottom_right '
end
BottomFrame.set_location ( player , data.bottom_state )
end ,
2022-04-05 19:28:08 +02:00
[ ' portable_button ' ] = function ( event )
2021-05-25 22:19:20 +02:00
local player = game.get_player ( event.player_index )
local data = BottomFrame.get_player_data ( player )
if event.element . switch_state == ' left ' then
data.above = false
data.portable = true
2021-05-23 17:03:52 +02:00
else
2021-05-25 22:19:20 +02:00
data.portable = false
data.above = false
2021-05-23 17:03:52 +02:00
end
2021-05-25 22:19:20 +02:00
if not data.bottom_state then
data.bottom_state = ' bottom_right '
end
BottomFrame.set_location ( player , data.bottom_state )
2021-05-23 17:03:52 +02:00
end ,
2022-04-05 19:28:08 +02:00
[ ' auto_hotbar_switch ' ] = function ( event )
2020-08-22 17:20:59 +02:00
if event.element . switch_state == ' left ' then
global.auto_hotbar_enabled [ event.player_index ] = true
else
global.auto_hotbar_enabled [ event.player_index ] = false
end
end ,
2022-04-05 19:28:08 +02:00
[ ' blueprint_toggle ' ] = function ( event )
2020-08-22 17:20:59 +02:00
if event.element . switch_state == ' left ' then
2020-12-14 20:36:37 +02:00
game.permissions . get_group ( ' Default ' ) . set_allows_action ( defines.input_action . open_blueprint_library_gui , true )
2020-08-22 17:20:59 +02:00
game.permissions . get_group ( ' Default ' ) . set_allows_action ( defines.input_action . import_blueprint_string , true )
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Blueprints] ' , ' has enabled blueprints! ' )
2020-08-22 17:20:59 +02:00
else
2020-12-14 20:36:37 +02:00
game.permissions . get_group ( ' Default ' ) . set_allows_action ( defines.input_action . open_blueprint_library_gui , false )
2020-08-22 17:20:59 +02:00
game.permissions . get_group ( ' Default ' ) . set_allows_action ( defines.input_action . import_blueprint_string , false )
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Blueprints] ' , ' has disabled blueprints! ' )
2020-08-22 17:20:59 +02:00
end
end ,
2022-04-05 19:28:08 +02:00
[ ' spaghett_toggle ' ] = function ( event )
2020-08-22 17:20:59 +02:00
if event.element . switch_state == ' left ' then
2021-05-07 01:36:10 +02:00
this.gui_config . spaghett.enabled = true
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Spaghett] ' , ' has enabled spaghett mode! ' )
2020-08-22 17:20:59 +02:00
else
2021-05-07 01:36:10 +02:00
this.gui_config . spaghett.enabled = nil
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Spaghett] ' , ' has disabled spaghett mode! ' )
2020-08-22 17:20:59 +02:00
end
spaghett ( )
2020-09-08 15:21:03 +02:00
end ,
2020-12-14 20:36:37 +02:00
[ ' bb_team_balancing_toggle ' ] = function ( event )
if event.element . switch_state == ' left ' then
global.bb_settings . team_balancing = true
game.print ( ' Team balancing has been enabled! ' )
else
global.bb_settings . team_balancing = false
game.print ( ' Team balancing has been disabled! ' )
end
end ,
[ ' bb_only_admins_vote ' ] = function ( event )
if event.element . switch_state == ' left ' then
global.bb_settings . only_admins_vote = true
global.difficulty_player_votes = { }
game.print ( ' Admin-only difficulty voting has been enabled! ' )
else
global.bb_settings . only_admins_vote = false
game.print ( ' Admin-only difficulty voting has been disabled! ' )
end
2021-05-23 17:03:52 +02:00
end ,
[ ' disable_cleaning ' ] = function ( event )
if event.element . switch_state == ' left ' then
Gui.set_disable_clear_invalid_data ( true )
else
Gui.set_disable_clear_invalid_data ( false )
end
2020-12-14 20:36:37 +02:00
end
2020-04-18 21:09:11 +02:00
}
2020-04-27 23:33:28 +02:00
local poll_function = {
2022-04-05 19:28:08 +02:00
[ ' poll_trusted_toggle ' ] = function ( event )
2020-08-22 17:20:59 +02:00
if event.element . switch_state == ' left ' then
2021-05-07 01:36:10 +02:00
this.gui_config . poll_trusted = true
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Poll Mode] ' , ' has disabled non-trusted people to do polls. ' )
2020-08-22 17:20:59 +02:00
else
2021-05-07 01:36:10 +02:00
this.gui_config . poll_trusted = false
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Poll Mode] ' , ' has allowed non-trusted people to do polls. ' )
2020-08-22 17:20:59 +02:00
end
end ,
2022-04-05 19:28:08 +02:00
[ ' poll_no_notify_toggle ' ] = function ( event )
local poll = is_loaded ( ' utils.gui.poll ' )
2020-08-22 17:20:59 +02:00
local poll_table = poll.get_no_notify_players ( )
if event.element . switch_state == ' left ' then
poll_table [ event.player_index ] = false
else
poll_table [ event.player_index ] = true
end
end
}
local antigrief_functions = {
2022-04-05 19:28:08 +02:00
[ ' disable_antigrief ' ] = function ( event )
2020-08-22 17:20:59 +02:00
local AG = Antigrief.get ( )
if event.element . switch_state == ' left ' then
AG.enabled = true
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Antigrief] ' , ' has enabled the antigrief function. ' , true )
2020-08-22 17:20:59 +02:00
else
AG.enabled = false
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Antigrief] ' , ' has disabled the antigrief function. ' , true )
2020-08-22 17:20:59 +02:00
end
trust_connected_players ( )
end
2020-04-27 23:33:28 +02:00
}
2020-08-22 18:08:39 +02:00
local fortress_functions = {
2022-04-05 19:28:08 +02:00
[ ' disable_fullness ' ] = function ( event )
2020-12-31 19:43:49 +02:00
local Fullness = is_loaded ( ' modules.check_fullness ' )
2021-05-07 01:38:45 +02:00
local Module = Fullness.get ( )
2020-08-22 18:08:39 +02:00
if event.element . switch_state == ' left ' then
2021-05-07 01:38:45 +02:00
Module.fullness_enabled = true
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Fullness] ' , ' has enabled the inventory fullness function. ' )
2020-08-22 18:08:39 +02:00
else
2021-05-07 01:38:45 +02:00
Module.fullness_enabled = false
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Fullness] ' , ' has disabled the inventory fullness function. ' )
2020-08-22 18:08:39 +02:00
end
end ,
2022-04-05 19:28:08 +02:00
[ ' offline_players ' ] = function ( event )
2020-12-31 19:43:49 +02:00
local WPT = is_loaded ( ' maps.mountain_fortress_v3.table ' )
2021-05-07 01:38:45 +02:00
local Module = WPT.get ( )
2020-08-22 18:08:39 +02:00
if event.element . switch_state == ' left ' then
2021-05-07 01:38:45 +02:00
Module.offline_players_enabled = true
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Offline Players] ' , ' has enabled the offline player function. ' )
2020-08-22 18:08:39 +02:00
else
2021-05-07 01:38:45 +02:00
Module.offline_players_enabled = false
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Offline Players] ' , ' has disabled the offline player function. ' )
2020-08-22 18:08:39 +02:00
end
end ,
2022-04-05 19:28:08 +02:00
[ ' collapse_grace ' ] = function ( event )
2020-12-31 19:43:49 +02:00
local WPT = is_loaded ( ' maps.mountain_fortress_v3.table ' )
2021-05-07 01:38:45 +02:00
local Module = WPT.get ( )
2020-08-22 18:08:39 +02:00
if event.element . switch_state == ' left ' then
2021-05-07 01:38:45 +02:00
Module.collapse_grace = true
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Collapse] ' , ' has enabled the collapse function. Collapse will occur after wave 100! ' )
2020-08-22 18:08:39 +02:00
else
2021-05-07 01:38:45 +02:00
Module.collapse_grace = false
2021-11-23 21:28:23 +02:00
get_actor ( event , ' [Collapse] ' , ' has disabled the collapse function. You must breach the first zone for collapse to occur! ' )
2020-08-22 18:08:39 +02:00
end
end ,
2022-04-05 19:28:08 +02:00
[ ' spill_items_to_surface ' ] = function ( event )
2020-12-31 19:43:49 +02:00
local WPT = is_loaded ( ' maps.mountain_fortress_v3.table ' )
2021-05-07 01:38:45 +02:00
local Module = WPT.get ( )
2020-08-22 18:08:39 +02:00
if event.element . switch_state == ' left ' then
2021-05-07 01:38:45 +02:00
Module.spill_items_to_surface = true
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Item Spill] ' , ' has enabled the ore spillage function. Ores now drop to surface when mining. ' )
2020-08-22 18:08:39 +02:00
else
2021-05-07 01:38:45 +02:00
Module.spill_items_to_surface = false
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Item Spill] ' , ' has disabled the item spillage function. Ores no longer drop to surface when mining. ' )
2020-08-22 18:08:39 +02:00
end
2020-08-22 20:28:24 +02:00
end ,
2022-04-05 19:28:08 +02:00
[ ' void_or_tile ' ] = function ( event )
2020-12-31 19:43:49 +02:00
local WPT = is_loaded ( ' maps.mountain_fortress_v3.table ' )
2021-05-07 01:38:45 +02:00
local Module = WPT.get ( )
2020-08-22 20:28:24 +02:00
if event.element . switch_state == ' left ' then
2021-05-07 01:38:45 +02:00
Module.void_or_tile = ' out-of-map '
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Void] ' , ' has changes the tiles of the zones to: out-of-map (void) ' )
2020-08-22 20:28:24 +02:00
else
2021-05-07 01:38:45 +02:00
Module.void_or_tile = ' lab-dark-2 '
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Void] ' , ' has changes the tiles of the zones to: dark-tiles (flammable tiles) ' )
2020-08-27 13:27:34 +02:00
end
end ,
2022-04-05 19:28:08 +02:00
[ ' trusted_only_car_tanks ' ] = function ( event )
2020-12-31 19:43:49 +02:00
local WPT = is_loaded ( ' maps.mountain_fortress_v3.table ' )
2021-05-07 01:38:45 +02:00
local Module = WPT.get ( )
2020-08-27 13:27:34 +02:00
if event.element . switch_state == ' left ' then
2021-05-07 01:38:45 +02:00
Module.trusted_only_car_tanks = true
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Market] ' , ' has changed so only trusted people can buy car/tanks. ' , true )
2020-08-27 13:27:34 +02:00
else
2021-05-07 01:38:45 +02:00
Module.trusted_only_car_tanks = false
2021-07-23 17:23:33 +02:00
get_actor ( event , ' [Market] ' , ' has changed so everybody can buy car/tanks. ' , true )
2020-08-22 20:28:24 +02:00
end
2021-09-17 22:26:13 +02:00
end ,
2022-04-05 19:28:08 +02:00
[ ' allow_decon ' ] = function ( event )
2021-09-17 22:26:13 +02:00
local WPT = is_loaded ( ' maps.mountain_fortress_v3.table ' )
if event.element . switch_state == ' left ' then
local limited_group = game.permissions . get_group ( ' limited ' )
if limited_group then
limited_group.set_allows_action ( defines.input_action . deconstruct , true )
end
WPT.set ( ' allow_decon ' , true )
get_actor ( event , ' [Decon] ' , ' has allowed decon on car/tanks/trains. ' , true )
else
local limited_group = game.permissions . get_group ( ' limited ' )
if limited_group then
limited_group.set_allows_action ( defines.input_action . deconstruct , false )
end
WPT.set ( ' allow_decon ' , false )
get_actor ( event , ' [Decon] ' , ' has disabled decon on car/tanks/trains. ' , true )
end
2021-11-28 22:20:23 +02:00
end ,
2022-04-05 19:28:08 +02:00
[ ' christmas_mode ' ] = function ( event )
2021-11-28 22:20:23 +02:00
local WPT = is_loaded ( ' maps.mountain_fortress_v3.table ' )
if event.element . switch_state == ' left ' then
WPT.set ( ' winter_mode ' , true )
get_actor ( event , ' [WinteryMode] ' , ' has enabled wintery mode. ' , true )
else
WPT.set ( ' winter_mode ' , false )
get_actor ( event , ' [WinteryMode] ' , ' has disabled wintery mode. ' , true )
end
2020-08-22 18:08:39 +02:00
end
}
2020-04-18 21:09:11 +02:00
local function add_switch ( element , switch_state , name , description_main , description )
2020-08-22 17:20:59 +02:00
local t = element.add ( { type = ' table ' , column_count = 5 } )
2021-03-24 18:36:07 +02:00
local on_label = t.add ( { type = ' label ' , caption = ' ON ' } )
on_label.style . padding = 0
on_label.style . left_padding = 10
on_label.style . font_color = { 0.77 , 0.77 , 0.77 }
2020-08-22 17:20:59 +02:00
local switch = t.add ( { type = ' switch ' , name = name } )
switch.switch_state = switch_state
switch.style . padding = 0
switch.style . margin = 0
2021-03-24 18:36:07 +02:00
local off_label = t.add ( { type = ' label ' , caption = ' OFF ' } )
off_label.style . padding = 0
off_label.style . font_color = { 0.70 , 0.70 , 0.70 }
local desc_main_label = t.add ( { type = ' label ' , caption = description_main } )
desc_main_label.style . padding = 2
desc_main_label.style . left_padding = 10
desc_main_label.style . minimal_width = 120
desc_main_label.style . font = ' heading-2 '
desc_main_label.style . font_color = { 0.88 , 0.88 , 0.99 }
local desc_label = t.add ( { type = ' label ' , caption = description } )
desc_label.style . padding = 2
desc_label.style . left_padding = 10
desc_label.style . single_line = false
desc_label.style . font = ' heading-3 '
desc_label.style . font_color = { 0.85 , 0.85 , 0.85 }
2020-08-22 17:20:59 +02:00
return switch
2020-04-18 21:09:11 +02:00
end
2021-03-26 00:49:57 +02:00
local function build_config_gui ( data )
local player = data.player
local frame = data.frame
2020-08-22 17:20:59 +02:00
local AG = Antigrief.get ( )
2020-08-22 18:08:39 +02:00
local switch_state
local label
2020-08-22 17:20:59 +02:00
local admin = player.admin
2020-08-22 20:15:56 +02:00
frame.clear ( )
2020-08-22 17:20:59 +02:00
2020-08-22 18:08:39 +02:00
local scroll_pane =
frame.add {
type = ' scroll-pane ' ,
horizontal_scroll_policy = ' never '
}
local scroll_style = scroll_pane.style
scroll_style.vertically_squashable = true
2021-05-25 22:19:20 +02:00
scroll_style.minimal_height = 350
2020-08-22 18:08:39 +02:00
scroll_style.bottom_padding = 2
scroll_style.left_padding = 2
scroll_style.right_padding = 2
scroll_style.top_padding = 2
label = scroll_pane.add ( { type = ' label ' , caption = ' Player Settings ' } )
2020-08-22 17:20:59 +02:00
label.style . font = ' default-bold '
label.style . padding = 0
label.style . left_padding = 10
label.style . horizontal_align = ' left '
label.style . vertical_align = ' bottom '
label.style . font_color = { 0.55 , 0.55 , 0.99 }
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2020-08-22 17:20:59 +02:00
if player.spectator then
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' spectator_switch ' , { ' gui.spectator_mode ' } , { ' gui-description.spectator_mode ' } )
2020-08-22 17:20:59 +02:00
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
if global.auto_hotbar_enabled then
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2020-08-22 17:20:59 +02:00
if global.auto_hotbar_enabled [ player.index ] then
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' auto_hotbar_switch ' , ' AutoHotbar ' , ' Automatically fills your hotbar with placeable items. ' )
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
end
2022-04-05 19:28:08 +02:00
local poll = is_loaded ( ' utils.gui.poll ' )
2020-12-31 19:43:49 +02:00
if poll then
2020-08-22 17:20:59 +02:00
local poll_table = poll.get_no_notify_players ( )
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2020-08-22 17:20:59 +02:00
if not poll_table [ player.index ] then
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' poll_no_notify_toggle ' , { ' gui.notify_on_polls ' } , { ' gui-description.notify_on_polls ' } )
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
end
2022-05-16 01:02:25 +02:00
local BPRequests = is_loaded ( ' modules.blueprint_requesting ' )
if BPRequests then
local Module = BPRequests.get ( )
switch_state = ' left '
if Module [ player.index ] and Module [ player.index ] . disabled then
switch_state = ' right '
end
add_switch ( scroll_pane , switch_state , ' blueprint_requesting ' , { ' modules.blueprint_requesting ' } , { ' modules.blueprint_requesting_desc ' } )
scroll_pane.add ( { type = ' line ' } )
end
2021-05-23 17:03:52 +02:00
if BottomFrame.is_custom_buttons_enabled ( ) then
2021-05-25 22:19:20 +02:00
label = scroll_pane.add ( { type = ' label ' , caption = ' Bottom Buttons Settings ' } )
label.style . font = ' default-bold '
label.style . padding = 0
label.style . left_padding = 10
label.style . top_padding = 10
label.style . horizontal_align = ' left '
label.style . vertical_align = ' bottom '
label.style . font_color = Color.white_smoke
scroll_pane.add ( { type = ' line ' } )
2021-05-23 17:03:52 +02:00
switch_state = ' right '
2021-05-25 22:19:20 +02:00
local bottom_frame = BottomFrame.get_player_data ( player )
if bottom_frame and bottom_frame.bottom_state == ' bottom_left ' then
2021-05-23 17:03:52 +02:00
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' bottom_location ' , ' Position - bottom ' , ' Toggle to select if you want the bottom button on the left side or the right side. ' )
2021-05-25 22:19:20 +02:00
scroll_pane.add ( { type = ' line ' } )
switch_state = ' right '
if bottom_frame and bottom_frame.above then
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' middle_location ' , ' Position - middle ' , ' Toggle to select if you want the bottom button above the quickbar or the side of the quickbar. ' )
2021-05-25 22:19:20 +02:00
scroll_pane.add ( { type = ' line ' } )
switch_state = ' right '
if bottom_frame and bottom_frame.portable then
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' portable_button ' , ' Position - portable ' , ' Toggle to select if you want the bottom button to be portable or not. ' )
2021-05-23 17:03:52 +02:00
scroll_pane.add ( { type = ' line ' } )
end
2020-08-22 17:20:59 +02:00
if admin then
2020-08-22 18:08:39 +02:00
label = scroll_pane.add ( { type = ' label ' , caption = ' Admin Settings ' } )
2020-08-22 17:20:59 +02:00
label.style . font = ' default-bold '
label.style . padding = 0
label.style . left_padding = 10
label.style . top_padding = 10
label.style . horizontal_align = ' left '
label.style . vertical_align = ' bottom '
label.style . font_color = { 0.77 , 0.11 , 0.11 }
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2020-08-22 17:20:59 +02:00
if game.permissions . get_group ( ' Default ' ) . allows_action ( defines.input_action . open_blueprint_library_gui ) then
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' blueprint_toggle ' , ' Blueprint Library ' , ' Toggles the usage of blueprint strings and the library. ' )
2020-08-22 17:20:59 +02:00
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
2021-05-23 17:03:52 +02:00
switch_state = ' right '
if Gui.get_disable_clear_invalid_data ( ) then
switch_state = ' left '
end
2022-01-27 05:54:00 +02:00
add_switch ( scroll_pane , switch_state , ' disable_cleaning ' , { ' gui.gui_data_cleaning ' } , { ' gui-description.gui_data_cleaning ' } )
2021-05-23 17:03:52 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2021-05-07 01:36:10 +02:00
if this.gui_config . spaghett.enabled then
2020-08-22 17:20:59 +02:00
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' spaghett_toggle ' , { ' gui.spaghett_mode ' } , { ' gui-description.spaghett_mode ' } )
2020-08-22 17:20:59 +02:00
2020-12-31 19:43:49 +02:00
if poll then
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
switch_state = ' right '
2021-05-07 01:36:10 +02:00
if this.gui_config . poll_trusted then
2020-08-22 17:20:59 +02:00
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' poll_trusted_toggle ' , ' Poll mode ' , ' Disables non-trusted plebs to create polls. ' )
2020-08-22 17:20:59 +02:00
end
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
2020-08-22 18:08:39 +02:00
label = scroll_pane.add ( { type = ' label ' , caption = ' Antigrief Settings ' } )
2020-08-22 17:20:59 +02:00
label.style . font = ' default-bold '
label.style . padding = 0
label.style . left_padding = 10
label.style . top_padding = 10
label.style . horizontal_align = ' left '
label.style . vertical_align = ' bottom '
2020-08-22 18:08:39 +02:00
label.style . font_color = Color.yellow
2020-08-22 17:20:59 +02:00
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2020-08-22 17:20:59 +02:00
if AG.enabled then
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' disable_antigrief ' , ' Antigrief ' , ' Toggle antigrief function. ' )
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-12-14 20:36:37 +02:00
2020-12-31 19:43:49 +02:00
if is_loaded ( ' maps.biter_battles_v2.main ' ) then
2020-09-08 15:21:03 +02:00
label = scroll_pane.add ( { type = ' label ' , caption = ' Biter Battles Settings ' } )
label.style . font = ' default-bold '
label.style . padding = 0
label.style . left_padding = 10
label.style . top_padding = 10
label.style . horizontal_align = ' left '
label.style . vertical_align = ' bottom '
label.style . font_color = Color.green
scroll_pane.add ( { type = ' line ' } )
2020-12-14 20:36:37 +02:00
2021-03-24 18:36:07 +02:00
local team_balancing_state = ' right '
2020-12-14 20:36:37 +02:00
if global.bb_settings . team_balancing then
2021-03-24 18:36:07 +02:00
team_balancing_state = ' left '
2020-12-14 20:36:37 +02:00
end
2022-04-05 19:28:08 +02:00
local switch = add_switch ( scroll_pane , team_balancing_state , ' bb_team_balancing_toggle ' , ' Team Balancing ' , ' Players can only join a team that has less or equal players than the opposing. ' )
2020-12-14 20:36:37 +02:00
if not admin then
switch.ignored_by_interaction = true
end
scroll_pane.add ( { type = ' line ' } )
2021-03-24 18:36:07 +02:00
local only_admins_vote_state = ' right '
2020-12-14 20:36:37 +02:00
if global.bb_settings . only_admins_vote then
2021-03-24 18:36:07 +02:00
only_admins_vote_state = ' left '
2020-12-14 20:36:37 +02:00
end
2022-04-05 19:28:08 +02:00
local only_admins_vote_switch = add_switch ( scroll_pane , only_admins_vote_state , ' bb_only_admins_vote ' , ' Admin Vote ' , ' Only admins can vote for map difficulty. Clears all currently existing votes. ' )
2020-12-14 20:36:37 +02:00
if not admin then
2021-03-24 18:36:07 +02:00
only_admins_vote_switch.ignored_by_interaction = true
2020-12-14 20:36:37 +02:00
end
scroll_pane.add ( { type = ' line ' } )
end
2020-12-31 19:43:49 +02:00
if is_loaded ( ' maps.mountain_fortress_v3.main ' ) then
2020-08-22 18:08:39 +02:00
label = scroll_pane.add ( { type = ' label ' , caption = ' Mountain Fortress Settings ' } )
label.style . font = ' default-bold '
label.style . padding = 0
label.style . left_padding = 10
label.style . top_padding = 10
label.style . horizontal_align = ' left '
label.style . vertical_align = ' bottom '
label.style . font_color = Color.green
2020-08-26 11:08:12 +02:00
2020-12-31 19:43:49 +02:00
local Fullness = is_loaded ( ' modules.check_fullness ' )
2020-08-26 11:08:12 +02:00
local full = Fullness.get ( )
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2020-08-26 11:08:12 +02:00
if full.fullness_enabled then
2020-08-22 18:08:39 +02:00
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' disable_fullness ' , ' Inventory Fullness ' , ' On = Enables inventory fullness. \n Off = Disables inventory fullness. ' )
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-12-31 19:43:49 +02:00
local WPT = is_loaded ( ' maps.mountain_fortress_v3.table ' )
2021-05-07 01:38:45 +02:00
local Module = WPT.get ( )
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2021-05-07 01:38:45 +02:00
if Module.offline_players_enabled then
2020-08-22 18:08:39 +02:00
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' offline_players ' , ' Offline Players ' , ' On = Enables offline player inventory drop. \n Off = Disables offline player inventory drop. ' )
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 17:20:59 +02:00
2020-08-22 18:08:39 +02:00
switch_state = ' right '
2021-05-07 01:38:45 +02:00
if Module.collapse_grace then
2020-08-22 18:08:39 +02:00
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' collapse_grace ' , ' Collapse ' , ' On = Enables collapse after wave 100. \n Off = Disables collapse - you must breach the first zone for collapse to occur. ' )
2020-08-22 18:08:39 +02:00
scroll_pane.add ( { type = ' line ' } )
switch_state = ' right '
2021-05-07 01:38:45 +02:00
if Module.spill_items_to_surface then
2020-08-22 18:08:39 +02:00
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' spill_items_to_surface ' , ' Spill Ores ' , ' On = Enables ore spillage to surface when mining. \n Off = Disables ore spillage to surface when mining. ' )
2020-08-22 18:14:04 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 20:28:24 +02:00
switch_state = ' right '
2021-05-07 01:38:45 +02:00
if Module.void_or_tile then
2020-08-22 20:28:24 +02:00
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' void_or_tile ' , ' Void Tiles ' , ' On = Changes the tiles to out-of-map. \n Off = Changes the tiles to lab-dark-2 ' )
2020-08-27 13:27:34 +02:00
scroll_pane.add ( { type = ' line ' } )
switch_state = ' right '
2021-05-07 01:38:45 +02:00
if Module.trusted_only_car_tanks then
2020-08-27 13:27:34 +02:00
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' trusted_only_car_tanks ' , ' Market Purchase ' , ' On = Allows only trusted people to buy car/tanks. \n Off = Allows everyone to buy car/tanks. ' )
2020-08-22 20:28:24 +02:00
scroll_pane.add ( { type = ' line ' } )
2021-09-17 22:26:13 +02:00
switch_state = ' right '
if Module.allow_decon then
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' allow_decon ' , ' Deconstruct ' , ' On = Allows decon on car/tanks/trains. \n Off = Disables decon on car/tanks/trains. ' )
2021-09-17 22:26:13 +02:00
scroll_pane.add ( { type = ' line ' } )
2021-11-28 22:20:23 +02:00
if Module.christmas_mode then
switch_state = ' left '
end
2022-04-05 19:28:08 +02:00
add_switch ( scroll_pane , switch_state , ' christmas_mode ' , ' Wintery Mode ' , ' On = Enables wintery mode. \n Off = Disables wintery mode. ' )
2021-11-28 22:20:23 +02:00
scroll_pane.add ( { type = ' line ' } )
2020-08-22 18:08:39 +02:00
end
2020-08-22 17:20:59 +02:00
end
2020-08-22 18:08:39 +02:00
for _ , e in pairs ( scroll_pane.children ) do
2020-08-22 17:20:59 +02:00
if e.type == ' line ' then
e.style . padding = 0
e.style . margin = 0
end
end
2021-03-26 00:49:57 +02:00
end
local build_config_gui_token = Token.register ( build_config_gui )
2020-04-18 21:09:11 +02:00
local function on_gui_switch_state_changed ( event )
2021-12-05 23:26:18 +02:00
local player = game.get_player ( event.player_index )
2020-12-14 20:36:37 +02:00
if not ( player and player.valid ) then
return
end
2020-08-22 17:20:59 +02:00
if not event.element then
return
end
if not event.element . valid then
return
end
2020-12-14 20:36:37 +02:00
2020-08-22 17:20:59 +02:00
if functions [ event.element . name ] then
2021-01-12 22:52:45 +02:00
local is_spamming = SpamProtection.is_spamming ( player , nil , ' Config Functions Elem ' )
2020-12-14 20:36:37 +02:00
if is_spamming then
return
end
2020-08-22 17:20:59 +02:00
functions [ event.element . name ] ( event )
return
elseif antigrief_functions [ event.element . name ] then
2021-01-12 22:52:45 +02:00
local is_spamming = SpamProtection.is_spamming ( player , nil , ' Config AntiGrief Elem ' )
2020-12-14 20:36:37 +02:00
if is_spamming then
return
end
2020-08-22 17:20:59 +02:00
antigrief_functions [ event.element . name ] ( event )
return
2020-08-22 18:08:39 +02:00
elseif fortress_functions [ event.element . name ] then
2021-01-12 22:52:45 +02:00
local is_spamming = SpamProtection.is_spamming ( player , nil , ' Config Fortress Elem ' )
2020-12-14 20:36:37 +02:00
if is_spamming then
return
end
2020-08-22 18:08:39 +02:00
fortress_functions [ event.element . name ] ( event )
return
2022-04-05 19:28:08 +02:00
elseif is_loaded ( ' utils.gui.poll ' ) then
2021-01-12 22:52:45 +02:00
local is_spamming = SpamProtection.is_spamming ( player , nil , ' Config Poll Elem ' )
2020-12-14 20:36:37 +02:00
if is_spamming then
return
end
2020-08-22 17:20:59 +02:00
if poll_function [ event.element . name ] then
poll_function [ event.element . name ] ( event )
return
end
end
2020-04-18 21:09:11 +02:00
end
2020-08-22 17:20:59 +02:00
local function on_force_created ( )
spaghett ( )
2020-04-18 21:09:11 +02:00
end
local function on_built_entity ( event )
2020-08-22 17:20:59 +02:00
spaghett_deny_building ( event )
2020-04-18 21:09:11 +02:00
end
local function on_robot_built_entity ( event )
2020-08-22 17:20:59 +02:00
spaghett_deny_building ( event )
2020-04-18 21:09:11 +02:00
end
2022-04-05 19:28:08 +02:00
Gui.add_tab_to_gui ( { name = module_name , caption = ' Config ' , id = build_config_gui_token , admin = false } )
2022-02-14 00:32:57 +02:00
2022-04-05 19:28:08 +02:00
Gui.on_click (
module_name ,
function ( event )
local player = event.player
Gui.reload_active_tab ( player )
2022-02-14 00:32:57 +02:00
end
2022-04-05 19:28:08 +02:00
)
2020-04-18 21:09:11 +02:00
Event.add ( defines.events . on_gui_switch_state_changed , on_gui_switch_state_changed )
Event.add ( defines.events . on_force_created , on_force_created )
Event.add ( defines.events . on_built_entity , on_built_entity )
Event.add ( defines.events . on_robot_built_entity , on_robot_built_entity )
2021-05-08 02:03:38 +02:00
function Public . get ( key )
if key then
return this [ key ]
else
return this
end
end
function Public . set ( key , value )
if key and ( value or value == false ) then
this [ key ] = value
return this [ key ]
elseif key then
return this [ key ]
else
return this
end
end
return Public