mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 19:45:22 +09:00
Added Player List
This commit is contained in:
@@ -13,6 +13,8 @@ local Gui = require 'expcore.gui.core'
|
||||
Gui._prototype:debug_name(name) --- Sets a debug alias for the define
|
||||
Gui._prototype:set_caption(caption) --- Sets the caption for the element define
|
||||
Gui._prototype:set_tooltip(tooltip) --- Sets the tooltip for the element define
|
||||
Gui._prototype:set_style(style,callback) --- Sets the style for the element define
|
||||
Gui._prototype:set_embeded_flow(state) --- Sets the element to be drawn inside a nameless flow, can be given a name using a function
|
||||
Gui._prototype:on_element_update(callback) --- Add a hander to run on the general value update event, different classes will handle this event differently
|
||||
|
||||
Gui._prototype:set_pre_authenticator(callback) --- Sets an authenticator that blocks the draw function if check fails
|
||||
@@ -34,6 +36,7 @@ local Gui = require 'expcore.gui.core'
|
||||
|
||||
Gui.toggle_enable(element) --- Will toggle the enabled state of an element
|
||||
Gui.toggle_visible(element) --- Will toggle the visiblity of an element
|
||||
Gui.set_padding(element,up,down,left,right) --- Sets the padding for a gui element
|
||||
]]
|
||||
|
||||
local Instances = require 'expcore.gui.instances'
|
||||
@@ -195,6 +198,7 @@ Gui.classes.left_frames = LeftFrames
|
||||
|
||||
LeftFrames.new_frame(permision_name) --- Creates a new left frame define
|
||||
LeftFrames._prototype:set_open_by_default(state) --- Sets if the frame is visible when a player joins, can also be a function to return a boolean
|
||||
LeftFrames._prototype:set_direction(direction) --- Sets the direction of the frame, either vertical or horizontal
|
||||
LeftFrames._prototype:get_frame(player) --- Gets the frame for this define from the left frame flow
|
||||
LeftFrames._prototype:is_open(player) --- Returns if the player currently has this define visible
|
||||
LeftFrames._prototype:toggle(player) --- Toggles the visiblty of the left frame
|
||||
|
||||
@@ -128,6 +128,8 @@
|
||||
Gui._prototype:debug_name(name) --- Sets a debug alias for the define
|
||||
Gui._prototype:set_caption(caption) --- Sets the caption for the element define
|
||||
Gui._prototype:set_tooltip(tooltip) --- Sets the tooltip for the element define
|
||||
Gui._prototype:set_style(style,callback) --- Sets the style for the element define
|
||||
Gui._prototype:set_embeded_flow(state) --- Sets the element to be drawn inside a nameless flow, can be given a name using a function
|
||||
Gui._prototype:on_element_update(callback) --- Add a hander to run on the general value update event, different classes will handle this event differently
|
||||
|
||||
Gui._prototype:set_pre_authenticator(callback) --- Sets an authenticator that blocks the draw function if check fails
|
||||
@@ -149,6 +151,8 @@
|
||||
|
||||
Gui.toggle_enable(element) --- Will toggle the enabled state of an element
|
||||
Gui.toggle_visible(element) --- Will toggle the visiblity of an element
|
||||
Gui.set_padding(element,up,down,left,right) --- Sets the padding for a gui element
|
||||
Gui.set_padding_style(style,up,down,left,right) --- Sets the padding for a gui style
|
||||
]]
|
||||
local Gui = require 'utils.gui'
|
||||
local Game = require 'utils.game'
|
||||
@@ -316,6 +320,28 @@ function Gui._prototype:set_tooltip(tooltip)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Sets the style for the element define
|
||||
-- @tparam style string the style that will be used for this element when drawn
|
||||
-- @tapram[opt] callback function function is called when element is drawn to alter its style
|
||||
-- @treturn self the element define to allow chaining
|
||||
function Gui._prototype:set_style(style,callback)
|
||||
self.draw_data.style = style
|
||||
self.events.on_style = callback
|
||||
return self
|
||||
end
|
||||
|
||||
--- Sets the element to be drawn inside a nameless flow, can be given a name using a function
|
||||
-- @tparam state ?boolean|function when true a padless flow is created to contain the element
|
||||
-- @treturn self the element define to allow chaining
|
||||
function Gui._prototype:set_embeded_flow(state)
|
||||
if state == false or type(state) == 'function' then
|
||||
self.embeded_flow = state
|
||||
else
|
||||
self.embeded_flow = true
|
||||
end
|
||||
return self
|
||||
end
|
||||
|
||||
--- Sets an authenticator that blocks the draw function if check fails
|
||||
-- @tparam callback function the function that will be ran to test if the element should be drawn or not
|
||||
-- callback param - player LuaPlayer - the player that the element is being drawn to
|
||||
@@ -358,8 +384,21 @@ function Gui._prototype:draw_to(element,...)
|
||||
if not self.pre_authenticator(player,self.name) then return end
|
||||
end
|
||||
|
||||
if self.embeded_flow then
|
||||
local embeded_name
|
||||
if type(self.embeded_flow) == 'function' then
|
||||
embeded_name = self.embeded_flow(element,...)
|
||||
end
|
||||
element = element.add{type='flow',name=embeded_name}
|
||||
Gui.set_padding(element)
|
||||
end
|
||||
|
||||
local new_element = element.add(self.draw_data)
|
||||
|
||||
if self.events.on_style then
|
||||
self.events.on_style(new_element.style)
|
||||
end
|
||||
|
||||
if self.post_authenticator then
|
||||
new_element.enabled = self.post_authenticator(player,self.name)
|
||||
end
|
||||
@@ -510,4 +549,17 @@ function Gui.set_padding(element,up,down,left,right)
|
||||
style.right_padding = right or 0
|
||||
end
|
||||
|
||||
--- Sets the padding for a gui style
|
||||
-- @tparam element LuaStyle the element to set the padding for
|
||||
-- @tparam[opt=0] up number the amount of padding on the top
|
||||
-- @tparam[opt=0] down number the amount of padding on the bottom
|
||||
-- @tparam[opt=0] left number the amount of padding on the left
|
||||
-- @tparam[opt=0] right number the amount of padding on the right
|
||||
function Gui.set_padding_style(style,up,down,left,right)
|
||||
style.top_padding = up or 0
|
||||
style.bottom_padding = down or 0
|
||||
style.left_padding = left or 0
|
||||
style.right_padding = right or 0
|
||||
end
|
||||
|
||||
return Gui
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
LeftFrames.new_frame(permision_name) --- Creates a new left frame define
|
||||
LeftFrames._prototype:set_open_by_default(state) --- Sets if the frame is visible when a player joins, can also be a function to return a boolean
|
||||
LeftFrames._prototype:set_direction(direction) --- Sets the direction of the frame, either vertical or horizontal
|
||||
LeftFrames._prototype:get_frame(player) --- Gets the frame for this define from the left frame flow
|
||||
LeftFrames._prototype:is_open(player) --- Returns if the player currently has this define visible
|
||||
LeftFrames._prototype:toggle(player) --- Toggles the visiblty of the left frame
|
||||
@@ -159,6 +160,13 @@ function LeftFrames._prototype:set_open_by_default(state)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Sets the direction of the frame, either vertical or horizontal
|
||||
-- @tparam direction string the direction to have the elements be added to thef frame
|
||||
function LeftFrames._prototype:set_direction(direction)
|
||||
self.direction = direction
|
||||
return self
|
||||
end
|
||||
|
||||
--- Gets the frame for this define from the left frame flow
|
||||
-- @tparam player LuaPlayer the player to get the frame of
|
||||
-- @treturn LuaGuiElement the frame in the left frame flow for this define
|
||||
@@ -212,7 +220,7 @@ end
|
||||
-- @tparam player LuaPlayer the player to update the frame of
|
||||
function LeftFrames._prototype:redraw(player)
|
||||
local frame = self:get_frame(player)
|
||||
frame.claer()
|
||||
frame.clear()
|
||||
if self.events.on_draw then
|
||||
self.events.on_draw(player,frame)
|
||||
end
|
||||
@@ -263,7 +271,8 @@ Event.add(defines.events.on_player_created,function(event)
|
||||
for _,define in pairs(LeftFrames.frames) do
|
||||
local frame = flow.add{
|
||||
type='frame',
|
||||
name=define.name
|
||||
name=define.name,
|
||||
direction=define.direction
|
||||
}
|
||||
|
||||
if define.events.on_draw then
|
||||
|
||||
Reference in New Issue
Block a user