Added GameSettingsGui and GuiAnnouncements

This commit is contained in:
Cooldude2606
2018-10-09 19:51:14 +01:00
parent 6df973eb5c
commit 4375671c9b
22 changed files with 183 additions and 118 deletions

View File

@@ -57,7 +57,7 @@ function AdminGui.draw(frame,filter_buttons)
btn.style.width = 30 btn.style.width = 30
end end
for name,button in pairs(AdminGui.buttons) do for name,button in pairs(AdminGui.buttons) do
if not filter_buttons or filter_buttons[name] then format(button:draw(frame)) end if not filter_buttons or filter_buttons[name] then format(button(frame)) end
end end
return frame.player return frame.player
end end
@@ -113,7 +113,7 @@ local action_drop_down = Gui.inputs.add_drop_down('action-drop-down-rank-change'
end end
end) end)
local take_action = Gui.inputs.add{ local take_action = Gui.inputs{
type='button', type='button',
name='admin-commands-take', name='admin-commands-take',
caption={'ExpGamingAdmin.take-action'} caption={'ExpGamingAdmin.take-action'}
@@ -131,7 +131,7 @@ local take_action = Gui.inputs.add{
Gui.center.clear(event) Gui.center.clear(event)
end) end)
Admin.center = Gui.center.add{ Admin.center = Gui.center{
name='admin-commands', name='admin-commands',
caption='utility/danger_icon', caption='utility/danger_icon',
tooltip={'ExpGamingAdmin.tooltip'}, tooltip={'ExpGamingAdmin.tooltip'},
@@ -211,4 +211,5 @@ Admin.center = Gui.center.add{
} }
-- Module Return -- Module Return
return AdminGui -- calling will draw the admin buttons to that frame
return setmetatable(AdminGui,{__call=function(self,...) self.draw(...) end})

View File

@@ -121,7 +121,7 @@ function Admin.clear_reports(player,by_player,no_emit)
end end
end end
local confirm_report = Gui.inputs.add{ local confirm_report = Gui.inputs{
type='button', type='button',
name='admin-report-confirm', name='admin-report-confirm',
caption='utility/spawn_flag', caption='utility/spawn_flag',
@@ -134,7 +134,7 @@ local confirm_report = Gui.inputs.add{
Gui.center.clear(event.player_index) Gui.center.clear(event.player_index)
end) end)
Admin.report_btn = Gui.inputs.add{ Admin.report_btn = Gui.inputs{
type='button', type='button',
name='admin-report', name='admin-report',
caption='utility/spawn_flag', caption='utility/spawn_flag',

View File

@@ -8,7 +8,6 @@ local Game = require('FactorioStdLib.Game')
local Color = require('FactorioStdLib.Color') local Color = require('FactorioStdLib.Color')
local Gui = {} local Gui = {}
local Gui_data = {}
local global = global() local global = global()
--- Used to set and get data about different guis --- Used to set and get data about different guis
-- @usage Gui.data[location] -- returns the gui data for that gui location ex center -- @usage Gui.data[location] -- returns the gui data for that gui location ex center
@@ -143,13 +142,14 @@ script.on_event('on_tick', function(event)
Gui.left.update() Gui.left.update()
end end
if loaded_modules['ExpGamingCore.Server'] then return end if loaded_modules['ExpGamingCore.Server'] then return end
if global.cams and is_type(global.cams,'table') and #global.cams > 0 then if global.cams and is_type(global.cams,'table') and #global.cams > 0 then
local update = 4 local update = 4
if global.cam_index >= #global.cams then global.cam_index = 1 end if global.cam_index >= #global.cams then global.cam_index = 1 end
if update > #global.cams then update = #global.cams end if update > #global.cams then update = #global.cams end
for cam_offset = 0,update do for cam_offset = 0,update do
local _cam = global.cams[global.cam_index] local _cam = global.cams[global.cam_index]
if not _cam then return end if not _cam then break end
if not _cam.cam.valid then table.remove(global.cams,global.cam_index) if not _cam.cam.valid then table.remove(global.cams,global.cam_index)
elseif not _cam.entity.valid then table.remove(global.cams,global.cam_index) elseif not _cam.entity.valid then table.remove(global.cams,global.cam_index)
else _cam.cam.position = _cam.entity.position if not _cam.surface then _cam.cam.surface_index = _cam.entity.surface.index end global.cam_index = global.cam_index+1 else _cam.cam.position = _cam.entity.position if not _cam.surface then _cam.cam.surface_index = _cam.entity.surface.index end global.cam_index = global.cam_index+1
@@ -164,11 +164,11 @@ script.on_event('on_player_respawned',function(event)
if global.players and is_type(global.players,'table') and #global.players > 0 and global.players[event.player_index] then if global.players and is_type(global.players,'table') and #global.players > 0 and global.players[event.player_index] then
local remove = {} local remove = {}
for index,cam in pairs(global.players[event.player_index]) do for index,cam in pairs(global.players[event.player_index]) do
Gui.cam_link{cam=cam,entity=Game.get_player(event).character} if cam.valid then table.insert(global.cams,{cam=cam,entity=player.character,surface=player.surface})
if not cam.valid then table.insert(remove,index) end else table.insert(remove,index) end
end end
for _,index in pairs(remove) do for n,index in pairs(remove) do
table.remove(global.players[event.player_index],index) table.remove(global.players[event.player_index],index-n+1)
end end
end end
end) end)

View File

@@ -28,7 +28,7 @@ function center.add(obj)
obj.tabs = {} obj.tabs = {}
obj._tabs = {} obj._tabs = {}
Gui.data('center',obj.name,obj) Gui.data('center',obj.name,obj)
Gui.toolbar.add(obj.name,obj.caption,obj.tooltip,obj.open) Gui.toolbar(obj.name,obj.caption,obj.tooltip,obj.open)
return obj return obj
end end

View File

@@ -32,7 +32,7 @@ function left.add(obj)
verbose('Created Left Gui: '..obj.name) verbose('Created Left Gui: '..obj.name)
setmetatable(obj,{__index=left._prototype,__call=function(self,player) if player then self:toggle{player=player,element={name=self.name}} else left.update(self.name) end end}) setmetatable(obj,{__index=left._prototype,__call=function(self,player) if player then self:toggle{player=player,element={name=self.name}} else left.update(self.name) end end})
Gui.data('left',obj.name,obj) Gui.data('left',obj.name,obj)
Gui.toolbar.add(obj.name,obj.caption,obj.tooltip,obj.toggle) Gui.toolbar(obj.name,obj.caption,obj.tooltip,obj.toggle)
return obj return obj
end end
@@ -154,13 +154,13 @@ function left._prototype.toggle(event)
elseif global.over_ride_left_can_open then elseif global.over_ride_left_can_open then
if is_type(Role,'table') then if is_type(Role,'table') then
if Role.allowed(player,_left.name) then open = true if Role.allowed(player,_left.name) then open = true
else open = {gui.unauthorized} end else open = {'ExpGamingCore_Gui.unauthorized'} end
else open = true end else open = true end
else open = err end else open = err end
else else
if is_type(Role,'table') then if is_type(Role,'table') then
if Role.allowed(player,_left.name) then open = true if Role.allowed(player,_left.name) then open = true
else open = {gui.unauthorized} end else open = {'ExpGamingCore_Gui.unauthorized'} end
else open = true end else open = true end
end end
if open == true and left.style.visible ~= true then if open == true and left.style.visible ~= true then

View File

@@ -109,7 +109,7 @@ end
function popup._prototype:add_left(obj) function popup._prototype:add_left(obj)
obj.name = obj.name or self.name obj.name = obj.name or self.name
self.left = Gui.left.add(obj) self.left = Gui.left(obj)
end end
popup.on_player_joined_game = popup.flow popup.on_player_joined_game = popup.flow

View File

@@ -1,15 +1,8 @@
--- Adds a objective version to custom guis. --- This file will be loaded when ExpGamingCore.Server is present
-- @submodule ExpGamingCore.Gui
-- @alias Gui
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
--- This file will be loaded when ExpGamingCore.Command is present
-- @function _comment -- @function _comment
local Game = require('FactorioStdLib.Game') local Game = require('FactorioStdLib.Game@^0.8.0')
local Server = require('ExpGamingCore.Server') local Server = require('ExpGamingCore.Server@^4.0.0')
local Gui = Gui -- this is to force gui to remain in the ENV
--- Adds a server thread that allows the camera follows to be toggled off and on --- Adds a server thread that allows the camera follows to be toggled off and on
-- @function __comment -- @function __comment

View File

@@ -10,19 +10,19 @@ local Game = require('FactorioStdLib.Game@^0.8.0')
local Gui = Gui -- this is to force gui to remain in the ENV local Gui = Gui -- this is to force gui to remain in the ENV
local mod_gui = require("mod-gui") local mod_gui = require("mod-gui")
local gui_tset_close = Gui.inputs.add{ local gui_test_close = Gui.inputs{
name='gui-test-close', name='gui-test-close',
type='button', type='button',
caption='Close Test Gui' caption='Close Test Gui'
}:on_event('click',function(event) event.element.parent.destroy() end) }:on_event('click',function(event) event.element.parent.destroy() end)
local caption_test = Gui.inputs.add{ local caption_test = Gui.inputs{
name='text-button', name='text-button',
type='button', type='button',
caption='Test' caption='Test'
}:on_event('click',function(event) game.print('test') end) }:on_event('click',function(event) game.print('test') end)
local sprite_test = Gui.inputs.add{ local sprite_test = Gui.inputs{
name='sprite-button', name='sprite-button',
type='button', type='button',
sprite='item/lab' sprite='item/lab'
@@ -109,24 +109,24 @@ local function test_gui(player)
if not player then return end if not player then return end
if mod_gui.get_frame_flow(player)['gui-test'] then mod_gui.get_frame_flow(player)['gui-test'].destroy() end if mod_gui.get_frame_flow(player)['gui-test'] then mod_gui.get_frame_flow(player)['gui-test'].destroy() end
local frame = mod_gui.get_frame_flow(player).add{type='frame',name='gui-test',direction='vertical'} local frame = mod_gui.get_frame_flow(player).add{type='frame',name='gui-test',direction='vertical'}
gui_tset_close:draw(frame) gui_test_close(frame)
caption_test:draw(frame) caption_test(frame)
sprite_test:draw(frame) sprite_test(frame)
input_test:draw(frame) input_test(frame)
elem_test:draw(frame) elem_test(frame)
check_test:draw(frame) check_test(frame)
radio_test:draw(frame) radio_test(frame)
radio_test_reset:draw(frame) radio_test_reset(frame)
text_test:draw(frame) text_test(frame)
box_test:draw(frame) box_test(frame)
slider_test:draw(frame) slider_test(frame)
drop_test:draw(frame) drop_test(frame)
end end
Gui.toolbar.add('open-gui-test','Open Test Gui','Opens the test gui with every input',test_gui) Gui.toolbar.add('open-gui-test','Open Test Gui','Opens the test gui with every input',test_gui)
-- testing the center gui -- testing the center gui
Gui.center.add{ Gui.center{
name='test-center', name='test-center',
caption='Gui Center', caption='Gui Center',
tooltip='Just a gui test' tooltip='Just a gui test'
@@ -139,7 +139,7 @@ end):add_tab('tab-2','Tab 2','Just a tab',function(frame)
end) end)
-- testing the left gui -- testing the left gui
Gui.left.add{ Gui.left{
name='test-left', name='test-left',
caption='Gui Left', caption='Gui Left',
tooltip='just testing', tooltip='just testing',
@@ -154,7 +154,7 @@ Gui.left.add{
local text_popup = Gui.inputs.add_text('test-popup-text',true,'Message To Send',function(player,text,element) local text_popup = Gui.inputs.add_text('test-popup-text',true,'Message To Send',function(player,text,element)
element.text = text element.text = text
end) end)
local send_popup = Gui.inputs.add{ local send_popup = Gui.inputs{
type='button', type='button',
name='test-popup-send', name='test-popup-send',
caption='Send Message' caption='Send Message'
@@ -163,7 +163,7 @@ local send_popup = Gui.inputs.add{
local message = event.element.parent['test-popup-text'].text local message = event.element.parent['test-popup-text'].text
Gui.popup.open('test-popup',{player=player.name,message=message}) Gui.popup.open('test-popup',{player=player.name,message=message})
end) end)
Gui.popup.add{ Gui.popup{
name='test-popup', name='test-popup',
caption='Gui Popup', caption='Gui Popup',
draw=function(frame,data) draw=function(frame,data)

View File

@@ -41,7 +41,7 @@ end
--- Creates a center gui that will appear on join --- Creates a center gui that will appear on join
-- @gui server-info -- @gui server-info
Gui.center.add{ Sync.info_gui = Gui.center{
name='server-info', name='server-info',
caption='Server Info', caption='Server Info',
tooltip='Basic info about the current server', tooltip='Basic info about the current server',
@@ -101,5 +101,5 @@ end)
script.on_event(defines.events.on_player_joined_game,function(event) script.on_event(defines.events.on_player_joined_game,function(event)
local player = Game.get_player(event) local player = Game.get_player(event)
Gui.center.open(player,'server-info') Sync.info_gui(player)
end) end)

View File

@@ -22,7 +22,7 @@ local function format_label(label)
label.style.single_line = false label.style.single_line = false
end end
Gui.center.add{ ThisModule.Gui = Gui.center{
name='readme', name='readme',
caption='utility/questionmark', caption='utility/questionmark',
tooltip={'ExpGamingInfo-Readme.tooltip'} tooltip={'ExpGamingInfo-Readme.tooltip'}
@@ -129,4 +129,5 @@ end):add_tab('rules',{'ExpGamingInfo-Readme.rules-name'},{'ExpGamingInfo-Readme.
end) end)
-- Module Return -- Module Return
return ThisModule -- when called will open readme for that user
return setmetatable(ThisModule,{__call=function(self,...) self.Gui(...) end})

View File

@@ -27,7 +27,7 @@ local global = global{
} }
-- Function Define -- Function Define
Gui.left.add{ ThisModule.Gui = Gui.left{
name='rockets', name='rockets',
caption='item/rocket-silo', caption='item/rocket-silo',
tooltip={'ExpGamingInfo-Rockets.tooltip'}, tooltip={'ExpGamingInfo-Rockets.tooltip'},
@@ -100,4 +100,5 @@ Gui.left.add{
script.on_event(defines.events.on_rocket_launched,function(event) Gui.left.update('rockets') end) script.on_event(defines.events.on_rocket_launched,function(event) Gui.left.update('rockets') end)
-- Module Return -- Module Return
return ThisModule -- when called will toggle the gui for that player, updates gui if no player given
return setmetatable(ThisModule,{__call=function(self,...) self.Gui(...) end})

View File

@@ -38,7 +38,7 @@ local global = global{
} }
-- Function Define -- Function Define
Gui.left.add{ ThisModule.Gui = Gui.left{
name='science', name='science',
caption='item/lab', caption='item/lab',
tooltip={'ExpGamingInfo-Science.tooltip'}, tooltip={'ExpGamingInfo-Science.tooltip'},
@@ -100,4 +100,5 @@ Gui.left.add{
script.on_event(defines.events.on_research_finished,function(event) Gui.left.update('science') end) script.on_event(defines.events.on_research_finished,function(event) Gui.left.update('science') end)
-- Module Return -- Module Return
return ThisModule -- when called will toogle the gui for that player, if no player it will update the gui
return setmetatable(ThisModule,{_call=function(self,...) self.Gui(...) end})

View File

@@ -25,7 +25,7 @@ local global = global{
} }
-- Function Define -- Function Define
local edit = Gui.inputs.add{ local edit = Gui.inputs{
name='tasklist-edit', name='tasklist-edit',
type='button', type='button',
caption='utility/rename_icon_normal' caption='utility/rename_icon_normal'
@@ -45,7 +45,7 @@ local edit = Gui.inputs.add{
end) end)
local function _edit(frame) local function _edit(frame)
local element = edit:draw(frame) local element = edit(frame)
element.style.height = 20 element.style.height = 20
element.style.width = 20 element.style.width = 20
local text_flow = element.parent.parent.text_flow local text_flow = element.parent.parent.text_flow
@@ -66,7 +66,7 @@ local function _edit(frame)
end end
end end
local remove = Gui.inputs.add{ local remove = Gui.inputs{
name='tasklist-remove', name='tasklist-remove',
type='button', type='button',
caption='utility/remove' caption='utility/remove'
@@ -83,7 +83,7 @@ local remove = Gui.inputs.add{
Gui.left.update('tasklist',event.player_index) Gui.left.update('tasklist',event.player_index)
end) end)
local add = Gui.inputs.add{ local add = Gui.inputs{
name='tasklist-add', name='tasklist-add',
type='button', type='button',
caption='utility/add' caption='utility/add'
@@ -126,7 +126,7 @@ local function _tasks(player)
end end
end end
Gui.left.add{ ThisModule.Gui = Gui.left{
name='tasklist', name='tasklist',
caption='utility/not_enough_repair_packs_icon', caption='utility/not_enough_repair_packs_icon',
tooltip={'ExpGamingInfo-Tasklist.tooltip'}, tooltip={'ExpGamingInfo-Tasklist.tooltip'},
@@ -169,10 +169,10 @@ Gui.left.add{
if allowed then if allowed then
_edit(button_flow) _edit(button_flow)
if global._edit[player.index]._editing[i] then if global._edit[player.index]._editing[i] then
local element = remove:draw(button_flow) local element = remove(button_flow)
element.style.height = 30 element.style.height = 30
element.style.width = 30 element.style.width = 30
local _element = add:draw(button_flow) local _element = add(button_flow)
_element.style.height = 30 _element.style.height = 30
_element.style.width = 30 _element.style.width = 30
end end
@@ -188,7 +188,7 @@ Gui.left.add{
type='flow', type='flow',
direction='horizontal' direction='horizontal'
} }
local element = add:draw(button_flow) local element = add(button_flow)
element.style.height = 20 element.style.height = 20
element.style.width = 20 element.style.width = 20
end end
@@ -201,4 +201,6 @@ Gui.left.add{
open_on_join=true open_on_join=true
} }
return ThisModule -- Module return
-- when called it will toggle the gui for that player, if no player then it will update the gui
return setmetatable(ThisModule,{__call=function(self,...) self.Gui(...) end})

View File

@@ -4,7 +4,6 @@
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
local Game = require('FactorioStdLib.Game@^0.8.0') local Game = require('FactorioStdLib.Game@^0.8.0')
local Gui = require('ExpGamingCore.Gui@^4.0.0')
local Role -- ExpGamingCore.Role@^4.0.0 local Role -- ExpGamingCore.Role@^4.0.0
local Sync -- ExpGamingCore.Sync@^4.0.0 local Sync -- ExpGamingCore.Sync@^4.0.0

View File

@@ -48,7 +48,7 @@ function ThisModule.update(tick)
end end
end end
local back_btn = Gui.inputs.add{ local back_btn = Gui.inputs{
type='button', type='button',
caption='utility/enter', caption='utility/enter',
name='player-list-back' name='player-list-back'
@@ -57,7 +57,7 @@ local back_btn = Gui.inputs.add{
event.element.parent.destroy() event.element.parent.destroy()
end) end)
Gui.left.add{ ThisModule.Gui = Gui.left{
name='player-list', name='player-list',
caption='entity/player', caption='entity/player',
tooltip={'ExpGamingPlayer-playerList.tooltip'}, tooltip={'ExpGamingPlayer-playerList.tooltip'},
@@ -96,7 +96,7 @@ Gui.left.add{
end end
if Admin and Admin.report_btn then if Admin and Admin.report_btn then
if not rank[4] and player.index ~= frame.player_index then if not rank[4] and player.index ~= frame.player_index then
local btn = Admin.report_btn:draw(flow) local btn = Admin.report_btn(flow)
btn.style.height = 20 btn.style.height = 20
btn.style.width = 20 btn.style.width = 20
end end
@@ -110,7 +110,7 @@ Gui.left.add{
script.on_event(defines.events.on_tick,function(event) script.on_event(defines.events.on_tick,function(event)
if event.tick > global.update then if event.tick > global.update then
Gui.left.update('player-list') ThisModule.Gui()
global.update = event.tick + global.intervial global.update = event.tick + global.intervial
end end
end) end)
@@ -136,5 +136,6 @@ script.on_event(defines.events.on_player_joined_game,ThisModule.update)
script.on_event(defines.events.on_player_left_game,ThisModule.update) script.on_event(defines.events.on_player_left_game,ThisModule.update)
script.on_event(defines.events.rank_change,ThisModule.update) script.on_event(defines.events.rank_change,ThisModule.update)
ThisModule.force_update = function() return Gui.left.update('player-list') end ThisModule.force_update = function() return ThisModule.Gui() end
return ThisModule -- when called it will queue an update to the player list
return setmetatable(ThisModule,{__call=function(self,...) self.update(...) end})

View File

@@ -91,7 +91,7 @@ local opption_drop_down = Gui.inputs.add_drop_down('opption-drop-down-polls',_op
element.parent.answer.caption = 'Your Answer: '..selected element.parent.answer.caption = 'Your Answer: '..selected
end) end)
local prev = Gui.inputs.add{ local prev = Gui.inputs{
type='button', type='button',
name='prev-poll', name='prev-poll',
caption='utility/hint_arrow_left' caption='utility/hint_arrow_left'
@@ -105,7 +105,7 @@ local prev = Gui.inputs.add{
draw_poll(parent.parent.poll_area) draw_poll(parent.parent.poll_area)
end) end)
local next = Gui.inputs.add{ local next = Gui.inputs{
type='button', type='button',
name='next-poll', name='next-poll',
caption='utility/hint_arrow_right' caption='utility/hint_arrow_right'
@@ -132,7 +132,7 @@ local poll_option_input = Gui.inputs.add_text('poll-option-input',true,'Enter Op
else options[element.parent.name].caption = text end else options[element.parent.name].caption = text end
if options.last.caption == element.parent.name then if options.last.caption == element.parent.name then
options.last.caption = tonumber(options.last.caption)+1 options.last.caption = tonumber(options.last.caption)+1
_self_referace_poll_option_input:draw(element.parent.parent.add{type='flow',name=options.last.caption}).style.minimal_width = 200 _self_referace_poll_option_input(element.parent.parent.add{type='flow',name=options.last.caption}).style.minimal_width = 200
end end
end) end)
_self_referace_poll_option_input = poll_option_input _self_referace_poll_option_input = poll_option_input
@@ -142,13 +142,13 @@ local function poll_assembler(frame)
local options = frame.add{type='flow',name='options'} local options = frame.add{type='flow',name='options'}
options.style.visible = false options.style.visible = false
options.add{type='label',name='last',caption='2'} options.add{type='label',name='last',caption='2'}
poll_question_input:draw(frame).style.minimal_width = 200 poll_question_input(frame).style.minimal_width = 200
local flow = frame.add{type='flow',direction='vertical'} local flow = frame.add{type='flow',direction='vertical'}
poll_option_input:draw(flow.add{type='flow',name='1'}).style.minimal_width = 200 poll_option_input(flow.add{type='flow',name='1'}).style.minimal_width = 200
poll_option_input:draw(flow.add{type='flow',name='2'}).style.minimal_width = 200 poll_option_input(flow.add{type='flow',name='2'}).style.minimal_width = 200
end end
local create_poll = Gui.inputs.add{ local create_poll = Gui.inputs{
type='button', type='button',
name='create-poll', name='create-poll',
caption='utility/add' caption='utility/add'
@@ -182,7 +182,7 @@ local create_poll = Gui.inputs.add{
end end
end) end)
Gui.popup.add{ ThisModule.Gui = Gui.popup{
name='polls', name='polls',
caption={'polls.name'}, caption={'polls.name'},
draw=function(frame,data) draw=function(frame,data)
@@ -248,4 +248,5 @@ Gui.popup.add{
-- Event Handlers Define -- Event Handlers Define
-- Module Return -- Module Return
return ThisModule -- when called it will toogle the left gui for this player
return setmetatable(ThisModule,{__call=function(self,...) self.Gui(...) end})

View File

@@ -1,13 +1,13 @@
--[[ --- A gui for controlling game settings with sliders as well as some global commands.
Explosive Gaming -- @module GameSettingsGui@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
This file can be used with permission but this and the credit below must remain in the file. -- Module Require
Contact a member of management on our discord to seek permission to use our code. local Server = require('ExpGamingCore.Server@^4.0.0')
Any changes that you may make to the code are yours but that does not make the script yours. local Gui = require('ExpGamingCore.Gui@^4.0.0')
Discord: https://discord.gg/r6dC2uK
]]
--Please Only Edit Below This Line-----------------------------------------------------------
-- Local Varibles
--{type='slider',object='',key='',name='',min=x,max=y} --{type='slider',object='',key='',name='',min=x,max=y}
--{type='function',object='',key='',name='',param={}} --{type='function',object='',key='',name='',param={}}
local basic_settings = { local basic_settings = {
@@ -46,6 +46,11 @@ local personal_settings = {
local _root_list = {basic_settings=basic_settings,advanced_settings=advanced_settings,personal_settings=personal_settings} local _root_list = {basic_settings=basic_settings,advanced_settings=advanced_settings,personal_settings=personal_settings}
-- Module Define
local module_verbose = false
local ThisModule = {}
-- Function Define
local function _get_data(root_frame) local function _get_data(root_frame)
local object = root_frame.name local object = root_frame.name
local key = root_frame.setting_name.caption local key = root_frame.setting_name.caption
@@ -121,7 +126,7 @@ local function _draw_setting(frame,setting)
} }
frame.add{ frame.add{
type='label', type='label',
caption={'game-settings.effect-'..setting.name}, caption={'GameSettingsGui.effect-'..setting.name},
style='caption_label' style='caption_label'
} }
frame.add{ frame.add{
@@ -130,7 +135,7 @@ local function _draw_setting(frame,setting)
name='setting_name' name='setting_name'
}.style.visible = false }.style.visible = false
if setting.type == 'slider' then if setting.type == 'slider' then
local slider = setting._loaded:draw(frame) local slider = setting._loaded(frame)
slider.style.width = 300 slider.style.width = 300
local _caption = string.format('%.2f',slider.slider_value); if slider.slider_value > 2 then _caption = tostring(math.floor(slider.slider_value)) end local _caption = string.format('%.2f',slider.slider_value); if slider.slider_value > 2 then _caption = tostring(math.floor(slider.slider_value)) end
frame.add{ frame.add{
@@ -139,44 +144,48 @@ local function _draw_setting(frame,setting)
caption=_caption caption=_caption
} }
elseif setting.type == 'function' then elseif setting.type == 'function' then
are_you_sure:draw(frame) are_you_sure(frame)
local flow = frame.add{type='flow',name='sure'} local flow = frame.add{type='flow',name='sure'}
flow.style.visible = false flow.style.visible = false
flow.add{ flow.add{
type='label', type='label',
caption={'game-settings.sure'}, caption={'GameSettingsGui.sure'},
style='bold_red_label' style='bold_red_label'
} }
setting._loaded:draw(flow) setting._loaded(flow)
end end
end end
Gui.center.add{ ThisModule.Gui = Gui.center{
name='game-settings', name='game-settings',
caption='utility/no_building_material_icon', caption='utility/no_building_material_icon',
tooltip={'game-settings.tooltip'} tooltip={'GameSettingsGui.tooltip'}
}:add_tab('basic',{'game-settings.basic-name'},{'game-settings.basic-name'},function(frame) }:add_tab('basic',{'GameSettingsGui.basic-name'},{'GameSettingsGui.basic-name'},function(frame)
frame.add{ frame.add{
type='label', type='label',
caption={'game-settings.basic-message'} caption={'GameSettingsGui.basic-message'}
}.style.single_line = false }.style.single_line = false
for _,setting in pairs(basic_settings) do for _,setting in pairs(basic_settings) do
_draw_setting(frame,setting) _draw_setting(frame,setting)
end end
end):add_tab('advanced',{'game-settings.advanced-name'},{'game-settings.advanced-tooltip'},function(frame) end):add_tab('advanced',{'GameSettingsGui.advanced-name'},{'GameSettingsGui.advanced-tooltip'},function(frame)
frame.add{ frame.add{
type='label', type='label',
caption={'game-settings.advanced-message'} caption={'GameSettingsGui.advanced-message'}
}.style.single_line = false }.style.single_line = false
for _,setting in pairs(advanced_settings) do for _,setting in pairs(advanced_settings) do
_draw_setting(frame,setting) _draw_setting(frame,setting)
end end
end):add_tab('personal',{'game-settings.personal-name'},{'game-settings.personal-tooltip'},function(frame) end):add_tab('personal',{'GameSettingsGui.personal-name'},{'GameSettingsGui.personal-tooltip'},function(frame)
frame.add{ frame.add{
type='label', type='label',
caption={'game-settings.personal-message'} caption={'GameSettingsGui.personal-message'}
}.style.single_line = false }.style.single_line = false
for _,setting in pairs(personal_settings) do for _,setting in pairs(personal_settings) do
_draw_setting(frame,setting) _draw_setting(frame,setting)
end end
end) end)
-- Module return
-- when called it will open the center gui for the player
return setmetatable(ThisModule,{__call=function(self,...) self.Gui(...) end})

View File

@@ -0,0 +1,21 @@
{
"name": "GameSettingsGui",
"version": "4.0.0",
"type": "Module",
"description": "A gui for controlling game settings with sliders as well as some global commands.",
"location": "<blank>",
"keywords": [
"Gui",
"Game",
"Game Settings",
"Settings",
"Admin"
],
"author": "Cooldude2606",
"contact": "Discord: Cooldude2606#5241",
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
"dependencies": {
"ExpGamingCore.Server": "^4.0.0",
"ExpGamingCore.Gui": "^4.0.0"
}
}

View File

@@ -1,13 +1,20 @@
--[[ --- Creates a gui for making and reciving announcements
Explosive Gaming -- @module GuiAnnouncements@4.0.0
-- @author Cooldude2606
-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE
This file can be used with permission but this and the credit below must remain in the file. -- maybe make this not require Role and have it optinal
Contact a member of management on our discord to seek permission to use our code.
Any changes that you may make to the code are yours but that does not make the script yours.
Discord: https://discord.gg/r6dC2uK
]]
--Please Only Edit Below This Line-----------------------------------------------------------
-- Module Require
local Game = require('FactorioStdLib.Game@^0.8.0')
local Gui = require('ExpGamingCore.Gui@^4.0.0')
local Role = require('ExpGamingCore.Role@^4.0.0')
-- Module Define
local module_verbose = false
local ThisModule = {}
-- Function Define
local function _roles(player) local function _roles(player)
local roles = {'Select Rank'} local roles = {'Select Rank'}
local _role = Role.get_highest(player) local _role = Role.get_highest(player)
@@ -25,7 +32,7 @@ local role_drop_down = Gui.inputs.add_drop_down('rank-drop-down-annoncements',_r
else element.parent['send-annoncement'].style.visible = true end else element.parent['send-annoncement'].style.visible = true end
end) end)
local send_popup = Gui.inputs.add{ local send_popup = Gui.inputs{
type='button', type='button',
name='send-annoncement', name='send-annoncement',
caption='utility/export_slot' caption='utility/export_slot'
@@ -45,7 +52,7 @@ local send_popup = Gui.inputs.add{
end end
end) end)
Gui.popup.add{ ThisModule.Gui = Gui.popup{
name='announcements', name='announcements',
caption={'announcements.name'}, caption={'announcements.name'},
draw=function(frame,data) draw=function(frame,data)
@@ -94,4 +101,8 @@ Gui.popup.add{
caption='' caption=''
}.style.visible = false }.style.visible = false
end end
} }
-- Module return
-- when called it will open the center gui for the player
return setmetatable(ThisModule,{__call=function(self,...) self.Gui(...) end})

View File

@@ -0,0 +1,20 @@
{
"name": "GuiAnnouncements",
"version": "4.0.0",
"type": "Module",
"description": "Creates a gui for making and reciving announcements",
"location": "<blank>",
"keywords": [
"Announcements",
"Gui",
"Admin"
],
"author": "Cooldude2606",
"contact": "Discord: Cooldude2606#5241",
"license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE",
"dependencies": {
"FactorioStdLib.Game": "^0.8.0",
"ExpGamingCore.Role": "^4.0.0",
"ExpGamingCore.Gui": "^4.0.0"
}
}

View File

@@ -8,6 +8,8 @@ Discord: https://discord.gg/r6dC2uK
]] ]]
--Please Only Edit Below This Line----------------------------------------------------------- --Please Only Edit Below This Line-----------------------------------------------------------
-- to be removed as Ranking is not a thing now
local get_player_info = get_player_info or function(player,frame) local get_player_info = get_player_info or function(player,frame)
frame.add{ frame.add{
type='label', type='label',
@@ -63,7 +65,7 @@ local role_drop_down = Gui.inputs.add_drop_down('rank-drop-down-rank-change',_ro
element.parent.parent.role.caption = selected element.parent.parent.role.caption = selected
end) end)
local set_role = Gui.inputs.add{ local set_role = Gui.inputs{
type='button', type='button',
name='rank-change-set', name='rank-change-set',
caption={'rank-changer.set-rank'} caption={'rank-changer.set-rank'}
@@ -79,7 +81,7 @@ local set_role = Gui.inputs.add{
Gui.center.clear(event) Gui.center.clear(event)
end) end)
Gui.center.add{ Gui.center{
name='rank-changer', name='rank-changer',
caption='utility/circuit_network_panel', caption='utility/circuit_network_panel',
tooltip={'rank-changer.tooltip'}, tooltip={'rank-changer.tooltip'},
@@ -106,9 +108,9 @@ Gui.center.add{
} }
label.style.single_line = false label.style.single_line = false
label.style.width = 200 label.style.width = 200
online_check:draw(dropdowns) online_check(dropdowns)
player_drop_down:draw(dropdowns) player_drop_down(dropdowns)
rank_drop_down:draw(dropdowns) rank_drop_down(dropdowns)
local label = dropdowns.add{ local label = dropdowns.add{
name='warning', name='warning',
type='label', type='label',
@@ -117,7 +119,7 @@ Gui.center.add{
} }
label.style.single_line = false label.style.single_line = false
label.style.width = 200 label.style.width = 200
set_role:draw(dropdowns) set_role(dropdowns)
frame.add{ frame.add{
name='player', name='player',
type='label', type='label',

View File

@@ -8,6 +8,8 @@ Discord: https://discord.gg/r6dC2uK
]] ]]
--Please Only Edit Below This Line----------------------------------------------------------- --Please Only Edit Below This Line-----------------------------------------------------------
-- Needs updating to new gui core
local warp_tiles = { local warp_tiles = {
{-3,-2},{-3,-1},{-3,0},{-3,1},{-3,2},{3,-2},{3,-1},{3,0},{3,1},{3,2}, {-3,-2},{-3,-1},{-3,0},{-3,1},{-3,2},{3,-2},{3,-1},{3,0},{3,1},{3,2},
{-2,-3},{-1,-3},{0,-3},{1,-3},{2,-3},{-2,3},{-1,3},{0,3},{1,3},{2,3} {-2,-3},{-1,-3},{0,-3},{1,-3},{2,-3},{-2,3},{-1,3},{0,3},{1,3},{2,3}