Fixed Alot Of Stuff For Info Window

This commit is contained in:
Cooldude2606
2018-04-08 16:02:19 +01:00
parent 5b10126c44
commit e28fedb70a
4 changed files with 39 additions and 22 deletions

View File

@@ -31,6 +31,15 @@ function center.get_flow(player)
return player.gui.center.exp_center or player.gui.center.add{name='exp_center',type='flow'}
end
-- used to open any center gui
function center.open(player,center)
local player = Game.get_player(player)
Gui._get_data('center')[center].open{
element={name=center},
player_index=player.index
}
end
-- used to clear the center frame of the player, used mainly in script
function center.clear(player)
local player = Game.get_player(player)

View File

@@ -18,8 +18,9 @@ Pass a table with the names of the objects you want and it will be return in tha
local StdExpCoreLib = {}
require '/commands'
StdExpCoreLib.Server = require '/server'
StdExpCoreLib.Ranking = require '/ranking'
StdExpCoreLib.Server = require '/server'
StdExpCoreLib.Sync = require '/sync'
StdExpCoreLib.Gui = require '/gui'
StdExpCoreLib.Gui:_load_parts{
'inputs',
@@ -28,7 +29,6 @@ StdExpCoreLib.Gui:_load_parts{
'left',
'popup'
}
StdExpCoreLib.Sync = require '/sync'
return function(rtn)
local _return = {}

View File

@@ -252,29 +252,42 @@ function Sync._load()
caption='Server Info',
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)
_flow.add{type='label',caption='Welcome To '..info.server_name,style='caption_label'}.style.width = 185
_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
if info.description then frame.add{
type='label',
caption=info.description,style='description_label'
} end
Gui.bar(frame,600)
local frame = frame.add{
type='frame',
direction='vertical',
style='image_frame'
}
frame.style.width = 600
local text_flow = frame.add{type='flow',direction='vertical'}
local button_flow = frame.add{type='table',column_count=3}
for _,element in pairs(Sync_gui_functions) do
local type = table.remove(element,1)
if type == 'function' then
local success, err = pcall(table.remove(element,1),unpack(element))
local _type = table.remove(element,1)
if _type == 'function' then
local success, err = pcall(table.remove(element,1),frame.player_index,frame,unpack(element))
if not success then error(err) else
if is_type(err,'table') then
if element.draw then element:draw(button_flow)
else text_flow.add{type='label',caption=table.to_string(element)} end
else text_flow.add{type='label',caption=tostring(element)} end
else text_flow.add{type='label',caption=table.to_string(err)} end
else text_flow.add{type='label',caption=tostring(err)} end
end
elseif type == 'gui' then element:draw(button_flow)
elseif type == 'string' then text_flow.add{type='label',caption=tostring(element)}
elseif type == 'table' then text_flow.add{type='label',caption=table.to_string(element)} end
elseif _type == 'gui' then element:draw(button_flow)
elseif _type == 'string' then text_flow.add{type='label',caption=tostring(element)}
elseif _type == 'table' then text_flow.add{type='label',caption=table.to_string(element)} end
end
end}
end
@@ -282,16 +295,7 @@ 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
})
Gui.center.open(player,'server-info')
end
end)