Better Server INfo Gui

This commit is contained in:
Cooldude2606
2018-10-16 21:29:23 +01:00
parent 070f49b5ae
commit b64dd778da
5 changed files with 33 additions and 9 deletions

View File

@@ -61,6 +61,24 @@ function Gui.bar(frame,width)
return line
end
--- Adds a lable that is centered
-- @usage Gui.centered_label(frane, 'Hello, world!')
-- @tparam LuaGuiElement frame the parent frame to add the label to
-- @tparam string string the string that the lable will have
function Gui.centered_label(frane, string)
local flow = frame.add {frame = 'flow'}
local flow_style = flow.style
flow_style.align = 'center'
flow_style.horizontally_stretchable = true
local label = flow.add {type = 'label', caption = string}
local label_style = label.style
label_style.align = 'center'
label_style.single_line = false
return label
end
--- Used to set the index of a drop down to a certian item
-- @usage Gui.set_dropdown_index(dropdown,player.name) -- will select the index with the players name as the value
-- @param dropdown the dropdown that is to be effected

View File

@@ -1,4 +1,5 @@
return {
'server-info',
'readme',
'science',
'rockets',

View File

@@ -309,7 +309,7 @@ script.on_event('on_pre_player_left_game',Sync.emit_update)
script.on_event('on_rocket_launched',Sync.emit_update)
function Sync:on_init()
if loaded_modules['ExpGamingCore.Gui'] then verbose('ExpGamingCore.Gui is installed; Loading gui src') require(module_path..'/src/gui',{Sync=Sync}) end
if loaded_modules['ExpGamingCore.Gui'] then verbose('ExpGamingCore.Gui is installed; Loading gui src') require(module_path..'/src/gui',{Sync=Sync,module_path=module_path}) end
if loaded_modules['ExpGamingCore.Role'] then verbose('ExpGamingCore.Role is installed; Loading role src') require(module_path..'/src/ranking',{Sync=Sync}) end
if loaded_modules['ExpGamingCore.Server'] then require('ExpGamingCore.Server').add_module_to_interface('Sync','ExpGamingCore.Sync') end
end

View File

@@ -12,6 +12,7 @@ local Gui = require('ExpGamingCore.Gui@^4.0.0')
local Sync = Sync -- this is to force sync to remain in the ENV
local Sync_gui_functions = {}
local logo_sprite_path = 'file'..string.sub(module_path,2)..'/src/logo.png'
--- Adds a emeltent to the sever info gui
-- @usage Sync.add_to_gui('string') -- return true
@@ -43,24 +44,28 @@ end
-- @gui server-info
Sync.info_gui = Gui.center{
name='server-info',
caption='Server Info',
caption=logo_sprite_path,
tooltip='Basic info about the current server',
draw=function(self,frame)
frame.caption = ''
local info = Sync.info
local frame = frame.add{type='flow',direction='vertical'}
local _flow = frame.add{type='flow'}
Gui.bar(_flow,200)
local h_flow = frame.add{type='flow'}
h_flow.add{type='sprite',sprite=logo_sprite_path}
local v_flow = h_flow.add{type='flow',direction='vertical'}
h_flow.add{type='sprite',sprite=logo_sprite_path}
local _flow = v_flow.add{type='flow'}
label_format(v_flow.add{
type='label',
caption=info.server_description,style='description_label'
},412)
Gui.bar(_flow,110)
label_format(_flow.add{
type='label',
caption='Welcome To '..info.server_name,
style='caption_label'
},180)
Gui.bar(_flow,200)
label_format(frame.add{
type='label',
caption=info.server_description,style='description_label'
},600)
Gui.bar(_flow,110)
Gui.bar(frame,600)
local _frame = frame
local frame = frame.add{

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB