mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Gui Looks Nice
This commit is contained in:
@@ -20,7 +20,6 @@ local StdExpCoreLib = {}
|
|||||||
require '/commands'
|
require '/commands'
|
||||||
StdExpCoreLib.Server = require '/server'
|
StdExpCoreLib.Server = require '/server'
|
||||||
StdExpCoreLib.Ranking = require '/ranking'
|
StdExpCoreLib.Ranking = require '/ranking'
|
||||||
StdExpCoreLib.Sync = require '/sync'
|
|
||||||
StdExpCoreLib.Gui = require '/gui'
|
StdExpCoreLib.Gui = require '/gui'
|
||||||
StdExpCoreLib.Gui:_load_parts{
|
StdExpCoreLib.Gui:_load_parts{
|
||||||
'inputs',
|
'inputs',
|
||||||
@@ -29,6 +28,7 @@ StdExpCoreLib.Gui:_load_parts{
|
|||||||
'left',
|
'left',
|
||||||
'popup'
|
'popup'
|
||||||
}
|
}
|
||||||
|
StdExpCoreLib.Sync = require '/sync'
|
||||||
|
|
||||||
return function(rtn)
|
return function(rtn)
|
||||||
local _return = {}
|
local _return = {}
|
||||||
|
|||||||
@@ -241,26 +241,25 @@ function Sync.add_to_gui(element,...)
|
|||||||
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
|
if element.draw then table.insert(Sync_gui_functions,{'gui',element})
|
||||||
table.insert(Sync_gui_functions,{'gui',element})
|
else table.insert(Sync_gui_functions,{'table',element}) end
|
||||||
else
|
else table.insert(Sync_gui_functions,{'string',element}) end
|
||||||
table.insert(Sync_gui_functions,{'table',element})
|
|
||||||
end
|
|
||||||
else
|
|
||||||
table.insert(Sync_gui_functions,{'string',element})
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Gui.center.add{
|
function Sync._load()
|
||||||
|
Gui.center.add{
|
||||||
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',
|
||||||
draw=function(self,frame)
|
draw=function(self,frame)
|
||||||
local info = Sync.info()
|
local info = Sync.info()
|
||||||
Gui.bar(frame,200)
|
local frame = frame.add{type='flow',direction='vertical'}
|
||||||
frame.add{type='lable',caption='Welcome To '..info.server_name,style='caption_label'}
|
local _flow = frame.add{type='flow'}
|
||||||
if info.description then frame.add{type='lable',caption=info.description,style='description_label'} end
|
Gui.bar(_flow,200)
|
||||||
Gui.bar(frame,200)
|
_flow.add{type='label',caption='Welcome To '..info.server_name,style='caption_label'}.style.width = 185
|
||||||
|
Gui.bar(_flow,200)
|
||||||
|
if info.description then frame.add{type='label',caption=info.description,style='description_label'} end
|
||||||
|
Gui.bar(frame,600)
|
||||||
local text_flow = frame.add{type='flow',direction='vertical'}
|
local text_flow = frame.add{type='flow',direction='vertical'}
|
||||||
local button_flow = frame.add{type='table',column_count=3}
|
local button_flow = frame.add{type='table',column_count=3}
|
||||||
for _,element in pairs(Sync_gui_functions) do
|
for _,element in pairs(Sync_gui_functions) do
|
||||||
@@ -270,12 +269,29 @@ Gui.center.add{
|
|||||||
if not success then error(err) else
|
if not success then error(err) else
|
||||||
if is_type(err,'table') then
|
if is_type(err,'table') then
|
||||||
if element.draw then element:draw(button_flow)
|
if element.draw then element:draw(button_flow)
|
||||||
else text_flow.add{type='lable',caption=table.to_string(element)} end
|
else text_flow.add{type='label',caption=table.to_string(element)} end
|
||||||
else text_flow.add{type='lable',caption=tostring(element)} end
|
else text_flow.add{type='label',caption=tostring(element)} end
|
||||||
end
|
end
|
||||||
elseif type == 'gui' then element:draw(button_flow)
|
elseif type == 'gui' then element:draw(button_flow)
|
||||||
elseif type == 'string' then text_flow.add{type='lable',caption=tostring(element)}
|
elseif type == 'string' then text_flow.add{type='label',caption=tostring(element)}
|
||||||
elseif type == 'table' then text_flow.add{type='lable',caption=table.to_string(element)} end
|
elseif type == 'table' then text_flow.add{type='label',caption=table.to_string(element)} end
|
||||||
|
end
|
||||||
|
end}
|
||||||
|
end
|
||||||
|
|
||||||
|
Event.register(defines.events.on_player_joined_game,function(event)
|
||||||
|
local player = Game.get_player(event)
|
||||||
|
if not player.admin and player.online_time < 60 then
|
||||||
|
script.raise_event(defines.events.on_gui_click,{
|
||||||
|
name=defines.events.on_gui_click,
|
||||||
|
tick=event.tick,
|
||||||
|
element=mod_gui.get_button_flow(player)['server-info'],
|
||||||
|
player_index=player.index,
|
||||||
|
button=defines.mouse_button_type.left,
|
||||||
|
alt=false,
|
||||||
|
control=false,
|
||||||
|
shift=false
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ Ranking, Sync, Server, Gui = require('/ExpCore/load'){'Ranking','Sync','Server',
|
|||||||
local success,err = pcall(require,'/ExpCore/GuiParts/test')
|
local success,err = pcall(require,'/ExpCore/GuiParts/test')
|
||||||
if success then Gui.test = err end
|
if success then Gui.test = err end
|
||||||
if Gui.popup then Gui.popup._load() end
|
if Gui.popup then Gui.popup._load() end
|
||||||
|
if Sync._load then Sync._load() end
|
||||||
-- this loads the ranks that Ranking uses
|
-- this loads the ranks that Ranking uses
|
||||||
require('/ExpCore/ranks')
|
require('/ExpCore/ranks')
|
||||||
-- this loads any edits that are not need in core pcall as file may not be preset
|
-- this loads any edits that are not need in core pcall as file may not be preset
|
||||||
|
|||||||
Reference in New Issue
Block a user