mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Merge branch 'core' into testing
This commit is contained in:
@@ -25,13 +25,20 @@ function center.add(obj)
|
|||||||
return obj
|
return obj
|
||||||
end
|
end
|
||||||
|
|
||||||
-- used to get the center frame of the player, used mainly in script
|
--- Used to get the center frame of the player, used mainly in script
|
||||||
|
-- @usage Gui.center.get_flow(player) -- returns gui emelemt
|
||||||
|
-- @param player a player indifier to get the flow for
|
||||||
|
-- @treturn table the gui element flow
|
||||||
function center.get_flow(player)
|
function center.get_flow(player)
|
||||||
local player = Game.get_player(player)
|
local player = Game.get_player(player)
|
||||||
return player.gui.center.exp_center or player.gui.center.add{name='exp_center',type='flow'}
|
return player.gui.center.exp_center or player.gui.center.add{name='exp_center',type='flow'}
|
||||||
end
|
end
|
||||||
|
|
||||||
-- used to open any center gui
|
--- Used to open a center frame for a player
|
||||||
|
-- @usage Gui.center.open(player,'server-info') -- return true
|
||||||
|
-- @param player a player indifier to get the flow for
|
||||||
|
-- @tparam center string the name of the center frame to open
|
||||||
|
-- @treturn boelon based on if it successed or not
|
||||||
function center.open(player,center)
|
function center.open(player,center)
|
||||||
local player = Game.get_player(player)
|
local player = Game.get_player(player)
|
||||||
Gui.center.clear(player)
|
Gui.center.clear(player)
|
||||||
@@ -43,13 +50,33 @@ function center.open(player,center)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- used to clear the center frame of the player, used mainly in script
|
--- Used to open a center frame for a player
|
||||||
|
-- @usage Gui.center.open_tab(player,'readme','rules') -- return true
|
||||||
|
-- @param player a player indifier to get the flow for
|
||||||
|
-- @tparam center string the name of the center frame to open
|
||||||
|
-- @tparam tab string the name of the tab to open
|
||||||
|
-- @treturn boelon based on if it successed or not
|
||||||
|
function center.open_tab(player,center,tab)
|
||||||
|
local player = Game.get_player(player)
|
||||||
|
if not Gui.center.open(player,center) then return false end
|
||||||
|
local name = center..'_'..tab
|
||||||
|
if not Gui._get_data('inputs_button')[name] then return false end
|
||||||
|
Gui._get_data('inputs_button')[name].events[defines.events.on_gui_click]{
|
||||||
|
element=Gui.center.get_flow(player)[center].tab_bar.tab_bar_scroll.tab_bar_scroll_flow[name],
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Used to clear the center frame of the player, used mainly in script
|
||||||
|
-- @usage Gui.center.clear(player)
|
||||||
|
-- @param player a player indifier to get the flow for
|
||||||
function center.clear(player)
|
function center.clear(player)
|
||||||
local player = Game.get_player(player)
|
local player = Game.get_player(player)
|
||||||
center.get_flow(player).clear()
|
center.get_flow(player).clear()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- used on the button press when the toolbar button is press, can be overriden
|
-- used on the button press when the toolbar button is press, can be overriden
|
||||||
|
-- not recomented for direct use see Gui.center.open
|
||||||
function center._center.open(event)
|
function center._center.open(event)
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
local _center = Gui._get_data('center')[event.element.name]
|
local _center = Gui._get_data('center')[event.element.name]
|
||||||
@@ -71,7 +98,8 @@ function center._center.open(event)
|
|||||||
player.opened=center_frame
|
player.opened=center_frame
|
||||||
end
|
end
|
||||||
|
|
||||||
-- this is the default draw function if one is not provided
|
-- this is the default draw function if one is not provided, can be overriden
|
||||||
|
-- not recomented for direct use see Gui.center.open
|
||||||
function center._center:draw(frame)
|
function center._center:draw(frame)
|
||||||
Gui.bar(frame,510)
|
Gui.bar(frame,510)
|
||||||
local tab_bar = frame.add{
|
local tab_bar = frame.add{
|
||||||
@@ -131,17 +159,6 @@ function center._center:draw(frame)
|
|||||||
frame.parent.add{type='frame',name='temp'}.destroy()--recenter the GUI
|
frame.parent.add{type='frame',name='temp'}.destroy()--recenter the GUI
|
||||||
end
|
end
|
||||||
|
|
||||||
function center.open_tab(player,center,tab)
|
|
||||||
local player = Game.get_player(player)
|
|
||||||
if not Gui.center.open(player,center) then return false end
|
|
||||||
local name = center..'_'..tab
|
|
||||||
if not Gui._get_data('inputs_button')[name] then return false end
|
|
||||||
Gui._get_data('inputs_button')[name].events[defines.events.on_gui_click]{
|
|
||||||
element=Gui.center.get_flow(player)[center].tab_bar.tab_bar_scroll.tab_bar_scroll_flow[name],
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
--- If deafult draw is used then you can add tabs to the gui with this function
|
--- If deafult draw is used then you can add tabs to the gui with this function
|
||||||
-- @usage _center:add_tab('foo','Foo','Just a tab',function)
|
-- @usage _center:add_tab('foo','Foo','Just a tab',function)
|
||||||
-- @tparam string name this is the name of the tab
|
-- @tparam string name this is the name of the tab
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ function inputs.add_button(name,display,tooltip,callbacks)
|
|||||||
local keys = {alt=event.alt,ctrl=event.control,shift=event.shift}
|
local keys = {alt=event.alt,ctrl=event.control,shift=event.shift}
|
||||||
local element = event.element
|
local element = event.element
|
||||||
local callbacks = button.data._callbacks
|
local callbacks = button.data._callbacks
|
||||||
if is_type(callbacks,'function') then callbacks = {function(...) return true end,callbacks} end
|
if is_type(callbacks,'function') then callbacks = {{function(...) return true end,callbacks}} end
|
||||||
for _,data in pairs(callbacks) do
|
for _,data in pairs(callbacks) do
|
||||||
if is_type(data[1],'function') and is_type(data[2],'function') then
|
if is_type(data[1],'function') and is_type(data[2],'function') then
|
||||||
local success, err = pcall(data[1],player,mouse,keys,event)
|
local success, err = pcall(data[1],player,mouse,keys,event)
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ Discord: https://discord.gg/r6dC2uK
|
|||||||
local Sync = {}
|
local Sync = {}
|
||||||
local Sync_gui_functions = {}
|
local Sync_gui_functions = {}
|
||||||
|
|
||||||
-- only used as a faster way to get to the ranking function
|
--- Used as a faster way to get to the ranking function, overrides previous
|
||||||
|
-- @usage Sync.set_ranks{name=rank_name}
|
||||||
function Sync.set_ranks(...)
|
function Sync.set_ranks(...)
|
||||||
Ranking._base_preset(...)
|
Ranking._base_preset(...)
|
||||||
end
|
end
|
||||||
@@ -237,25 +238,36 @@ Event.register(defines.events.on_tick,function(event)
|
|||||||
if (event.tick%time)==0 then Sync.update() Sync.emit_data() end
|
if (event.tick%time)==0 then Sync.update() Sync.emit_data() end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
--- Adds a emeltent to the sever info gui
|
||||||
|
-- @usage Sync.add_to_gui('string') -- return trues
|
||||||
|
-- @param element see examples before for what can be used, it can also be a return from Gui.inputs.add
|
||||||
|
-- @treturn bolean based on weather it was successful or not
|
||||||
function Sync.add_to_gui(element,...)
|
function Sync.add_to_gui(element,...)
|
||||||
if game then return end
|
if game then return false end
|
||||||
if is_type(element,'function') then
|
if is_type(element,'function') then
|
||||||
table.insert(Sync_gui_functions,{'function',element,...})
|
table.insert(Sync_gui_functions,{'function',element,...})
|
||||||
elseif is_type(element,'table') then
|
elseif is_type(element,'table') then
|
||||||
if element.draw then table.insert(Sync_gui_functions,{'gui',element})
|
if element.draw then table.insert(Sync_gui_functions,{'gui',element})
|
||||||
else table.insert(Sync_gui_functions,{'table',element}) end
|
else table.insert(Sync_gui_functions,{'table',element}) end
|
||||||
else table.insert(Sync_gui_functions,{'string',element}) end
|
else table.insert(Sync_gui_functions,{'string',element}) end
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Examples for Sync.add_to_gui
|
-- Examples for Sync.add_to_gui
|
||||||
|
-- adds a basic string to the table
|
||||||
Sync.add_to_gui('Welcome to the Explosive Gaming comunity! This is one of many servers which we host.')
|
Sync.add_to_gui('Welcome to the Explosive Gaming comunity! This is one of many servers which we host.')
|
||||||
|
-- adds a string that can have depentant values
|
||||||
Sync.add_to_gui(function(player,frame)
|
Sync.add_to_gui(function(player,frame)
|
||||||
return 'This server will reset at: '..Sync.info().reset_time
|
return 'This server will reset at: '..Sync.info().reset_time
|
||||||
end)
|
end)
|
||||||
|
-- adds a string that can have depentant values
|
||||||
Sync.add_to_gui(function(player,frame)
|
Sync.add_to_gui(function(player,frame)
|
||||||
return 'You have been given the rank '..Ranking.get_rank(player).name..' from our Discord'
|
return 'You have been given the rank '..Ranking.get_rank(player).name..' from our Discord'
|
||||||
end)
|
end)
|
||||||
|
-- if readme is included then see addons/guis/readme.lua for more examples
|
||||||
|
|
||||||
|
-- used to load the gui infomation when _G.Gui is not yet loaded
|
||||||
|
-- internal use not recomend to be used
|
||||||
function Sync._load()
|
function Sync._load()
|
||||||
Gui.center.add{
|
Gui.center.add{
|
||||||
name='server-info',
|
name='server-info',
|
||||||
@@ -303,6 +315,7 @@ function Sync._load()
|
|||||||
end}
|
end}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- opens the server info gui for all new joins except admins
|
||||||
Event.register(defines.events.on_player_joined_game,function(event)
|
Event.register(defines.events.on_player_joined_game,function(event)
|
||||||
local player = Game.get_player(event)
|
local player = Game.get_player(event)
|
||||||
if not player.admin and player.online_time < 60 then
|
if not player.admin and player.online_time < 60 then
|
||||||
|
|||||||
Reference in New Issue
Block a user