mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-28 03:55:23 +09:00
Added GameSettingsGui and GuiAnnouncements
This commit is contained in:
@@ -8,7 +8,6 @@ local Game = require('FactorioStdLib.Game')
|
||||
local Color = require('FactorioStdLib.Color')
|
||||
|
||||
local Gui = {}
|
||||
local Gui_data = {}
|
||||
local global = global()
|
||||
--- Used to set and get data about different guis
|
||||
-- @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()
|
||||
end
|
||||
if loaded_modules['ExpGamingCore.Server'] then return end
|
||||
|
||||
if global.cams and is_type(global.cams,'table') and #global.cams > 0 then
|
||||
local update = 4
|
||||
if global.cam_index >= #global.cams then global.cam_index = 1 end
|
||||
if update > #global.cams then update = #global.cams end
|
||||
for cam_offset = 0,update do
|
||||
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)
|
||||
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
|
||||
@@ -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
|
||||
local remove = {}
|
||||
for index,cam in pairs(global.players[event.player_index]) do
|
||||
Gui.cam_link{cam=cam,entity=Game.get_player(event).character}
|
||||
if not cam.valid then table.insert(remove,index) end
|
||||
if cam.valid then table.insert(global.cams,{cam=cam,entity=player.character,surface=player.surface})
|
||||
else table.insert(remove,index) end
|
||||
end
|
||||
for _,index in pairs(remove) do
|
||||
table.remove(global.players[event.player_index],index)
|
||||
for n,index in pairs(remove) do
|
||||
table.remove(global.players[event.player_index],index-n+1)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -28,7 +28,7 @@ function center.add(obj)
|
||||
obj.tabs = {}
|
||||
obj._tabs = {}
|
||||
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
|
||||
end
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ function left.add(obj)
|
||||
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})
|
||||
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
|
||||
end
|
||||
|
||||
@@ -154,13 +154,13 @@ function left._prototype.toggle(event)
|
||||
elseif global.over_ride_left_can_open then
|
||||
if is_type(Role,'table') then
|
||||
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 = err end
|
||||
else
|
||||
if is_type(Role,'table') then
|
||||
if Role.allowed(player,_left.name) then open = true
|
||||
else open = {gui.unauthorized} end
|
||||
else open = {'ExpGamingCore_Gui.unauthorized'} end
|
||||
else open = true end
|
||||
end
|
||||
if open == true and left.style.visible ~= true then
|
||||
|
||||
@@ -109,7 +109,7 @@ end
|
||||
|
||||
function popup._prototype:add_left(obj)
|
||||
obj.name = obj.name or self.name
|
||||
self.left = Gui.left.add(obj)
|
||||
self.left = Gui.left(obj)
|
||||
end
|
||||
|
||||
popup.on_player_joined_game = popup.flow
|
||||
|
||||
@@ -1,15 +1,8 @@
|
||||
--- Adds a objective version to custom guis.
|
||||
-- @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
|
||||
--- This file will be loaded when ExpGamingCore.Server is present
|
||||
-- @function _comment
|
||||
|
||||
local Game = require('FactorioStdLib.Game')
|
||||
local Server = require('ExpGamingCore.Server')
|
||||
local Gui = Gui -- this is to force gui to remain in the ENV
|
||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||
local Server = require('ExpGamingCore.Server@^4.0.0')
|
||||
|
||||
--- Adds a server thread that allows the camera follows to be toggled off and on
|
||||
-- @function __comment
|
||||
|
||||
@@ -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 mod_gui = require("mod-gui")
|
||||
|
||||
local gui_tset_close = Gui.inputs.add{
|
||||
local gui_test_close = Gui.inputs{
|
||||
name='gui-test-close',
|
||||
type='button',
|
||||
caption='Close Test Gui'
|
||||
}:on_event('click',function(event) event.element.parent.destroy() end)
|
||||
|
||||
local caption_test = Gui.inputs.add{
|
||||
local caption_test = Gui.inputs{
|
||||
name='text-button',
|
||||
type='button',
|
||||
caption='Test'
|
||||
}:on_event('click',function(event) game.print('test') end)
|
||||
|
||||
local sprite_test = Gui.inputs.add{
|
||||
local sprite_test = Gui.inputs{
|
||||
name='sprite-button',
|
||||
type='button',
|
||||
sprite='item/lab'
|
||||
@@ -109,24 +109,24 @@ local function test_gui(player)
|
||||
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
|
||||
local frame = mod_gui.get_frame_flow(player).add{type='frame',name='gui-test',direction='vertical'}
|
||||
gui_tset_close:draw(frame)
|
||||
caption_test:draw(frame)
|
||||
sprite_test:draw(frame)
|
||||
input_test:draw(frame)
|
||||
elem_test:draw(frame)
|
||||
check_test:draw(frame)
|
||||
radio_test:draw(frame)
|
||||
radio_test_reset:draw(frame)
|
||||
text_test:draw(frame)
|
||||
box_test:draw(frame)
|
||||
slider_test:draw(frame)
|
||||
drop_test:draw(frame)
|
||||
gui_test_close(frame)
|
||||
caption_test(frame)
|
||||
sprite_test(frame)
|
||||
input_test(frame)
|
||||
elem_test(frame)
|
||||
check_test(frame)
|
||||
radio_test(frame)
|
||||
radio_test_reset(frame)
|
||||
text_test(frame)
|
||||
box_test(frame)
|
||||
slider_test(frame)
|
||||
drop_test(frame)
|
||||
end
|
||||
|
||||
Gui.toolbar.add('open-gui-test','Open Test Gui','Opens the test gui with every input',test_gui)
|
||||
|
||||
-- testing the center gui
|
||||
Gui.center.add{
|
||||
Gui.center{
|
||||
name='test-center',
|
||||
caption='Gui Center',
|
||||
tooltip='Just a gui test'
|
||||
@@ -139,7 +139,7 @@ end):add_tab('tab-2','Tab 2','Just a tab',function(frame)
|
||||
end)
|
||||
|
||||
-- testing the left gui
|
||||
Gui.left.add{
|
||||
Gui.left{
|
||||
name='test-left',
|
||||
caption='Gui Left',
|
||||
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)
|
||||
element.text = text
|
||||
end)
|
||||
local send_popup = Gui.inputs.add{
|
||||
local send_popup = Gui.inputs{
|
||||
type='button',
|
||||
name='test-popup-send',
|
||||
caption='Send Message'
|
||||
@@ -163,7 +163,7 @@ local send_popup = Gui.inputs.add{
|
||||
local message = event.element.parent['test-popup-text'].text
|
||||
Gui.popup.open('test-popup',{player=player.name,message=message})
|
||||
end)
|
||||
Gui.popup.add{
|
||||
Gui.popup{
|
||||
name='test-popup',
|
||||
caption='Gui Popup',
|
||||
draw=function(frame,data)
|
||||
|
||||
@@ -41,7 +41,7 @@ end
|
||||
|
||||
--- Creates a center gui that will appear on join
|
||||
-- @gui server-info
|
||||
Gui.center.add{
|
||||
Sync.info_gui = Gui.center{
|
||||
name='server-info',
|
||||
caption='Server Info',
|
||||
tooltip='Basic info about the current server',
|
||||
@@ -101,5 +101,5 @@ end)
|
||||
|
||||
script.on_event(defines.events.on_player_joined_game,function(event)
|
||||
local player = Game.get_player(event)
|
||||
Gui.center.open(player,'server-info')
|
||||
Sync.info_gui(player)
|
||||
end)
|
||||
Reference in New Issue
Block a user