mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 04:21:41 +09:00
Fixed Popup
This commit is contained in:
@@ -23,10 +23,12 @@ local frames = ExpGui.frames
|
||||
local draw_frame = ExpGui.draw_frame
|
||||
--left guis are always present and only have their visabilty toggled
|
||||
--adds a frame to the left bar; event(player,frame) must be present for left guis as there is no default
|
||||
function add_frame.left(name,default_display,default_tooltip,restriction,event)
|
||||
--vis must be true must be true or false based on the default stae of the gui
|
||||
function add_frame.left(name,default_display,default_tooltip,restriction,vis,event)
|
||||
if not name then error('Frame requires a name') end
|
||||
if not event or type(event) ~= 'function' then error('Frame requires a draw function') end
|
||||
table.insert(frames.left,{name,default_display,event})
|
||||
local vis = vis or false
|
||||
table.insert(frames.left,{name,default_display,event,vis})
|
||||
ExpGui.toolbar.add_button(name,default_display,default_tooltip,restriction,draw_frame.left)
|
||||
end
|
||||
--draw the left gui for the player; do not call manuley must use other functions to call
|
||||
@@ -35,8 +37,19 @@ function draw_frame.left(player,element)
|
||||
for _,frame in pairs(frames.left) do if element.name == frame[1] then frame_data = frame break end end
|
||||
local left = mod_gui.get_frame_flow(player)
|
||||
if left[frame_data[1]] then ExpGui.toggleVisable(left[frame_data[1]]) return end
|
||||
local frame = left.add{name=frame_data[1],type='frame',capption=frame_data[2],direction='vertical'}
|
||||
local frame = left.add{name=frame_data[1],type='frame',capption=frame_data[2],direction='vertical',style=mod_gui.frame_style}
|
||||
frame_data[3](player,frame)
|
||||
end
|
||||
--used to load all left guis
|
||||
Event.register(defines.events.on_player_joined_game,function(event)
|
||||
local player = game.players[event.player_index]
|
||||
for _,frame_data in pairs(frames.left) do
|
||||
local left = mod_gui.get_frame_flow(player)
|
||||
if left[frame_data[1]] then ExpGui.toggleVisable(left[frame_data[1]]) return end
|
||||
local frame = left.add{name=frame_data[1],type='frame',capption=frame_data[2],direction='vertical',style=mod_gui.frame_style}
|
||||
frame_data[3](player,frame)
|
||||
frame.style.visible = frame_data[4]
|
||||
end
|
||||
end)
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
@@ -25,21 +25,16 @@ local draw_frame = ExpGui.draw_frame
|
||||
ExpGui.add_input.button('close_popup','X','Close This Popup',function(player,element) element.parent.destroy() end)
|
||||
local function get_next_popup(popups,name)
|
||||
if name then
|
||||
local flow = popups.add{type='flow',name=name..'_on_click',direction='horizontal'}
|
||||
local frame = flow.add{name='popup_frame',type='frame',direction='vertical'}
|
||||
local flow = popups.add{type='frame',name=name..'_on_click',direction='horizontal',style=mod_gui.frame_style}
|
||||
local frame = flow.add{name='popup_frame',type='flow',direction='vertical'}
|
||||
ExpGui.add_input.draw_button(flow,'close_popup') return frame
|
||||
end
|
||||
local current = #popups.children
|
||||
for _,p in pairs(popups.children) do
|
||||
if p.name == 'popup'..current then current = current+1 else
|
||||
local flow = popups.add{type='flow',name='popup'..current,direction='horizontal'}
|
||||
local frame = flow.add{name='popup_frame',type='frame',direction='vertical'}
|
||||
ExpGui.add_input.draw_button(flow,'close_popup') return frame end
|
||||
end
|
||||
if #popups.children == 0 then
|
||||
local flow = popups.add{type='flow',name='popup'..current,direction='horizontal'}
|
||||
local frame = flow.add{name='popup_frame',type='frame',direction='vertical'}
|
||||
ExpGui.add_input.draw_button(flow,'close_popup') return frame end
|
||||
local current = 0
|
||||
while true do if popups['popup'..current] then current = current+1 else break end end
|
||||
local flow = popups.add{type='frame',name='popup'..current,direction='horizontal',style=mod_gui.frame_style}
|
||||
local frame = flow.add{name='popup_frame',type='flow',direction='vertical'}
|
||||
ExpGui.add_input.draw_button(flow,'close_popup')
|
||||
return frame
|
||||
end
|
||||
--adds a frame to the popup flow;restriction is the power need to use the on_click function
|
||||
--on_click(player,element) is what is called when button is clicked if nil no button is made
|
||||
@@ -57,7 +52,7 @@ end
|
||||
function draw_frame.popup_button(player,element)
|
||||
local frame_data = nil
|
||||
for _,frame in pairs(frames.popup) do if element.name == frame[1] then frame_data = frame break end end
|
||||
local popups = mod_gui.get_frame_flow(player).popups or mod_gui.get_frame_flow(player).add{name='popups',type='flow',direction='vertical'}
|
||||
local popups = mod_gui.get_frame_flow(player).popups
|
||||
if popups[frame_data[1]..'_on_click'] then popups[frame_data[1]..'_on_click'].destroy() return end
|
||||
local frame = get_next_popup(popups,frame_data[1])
|
||||
frame_data[3](player,frame)
|
||||
@@ -68,10 +63,12 @@ function draw_frame.popup(style,args)
|
||||
local frame_data = nil
|
||||
for _,frame in pairs(frames.popup) do if style == frame[1] then frame_data = frame break end end
|
||||
for _,player in pairs(game.connected_players) do
|
||||
local popups = mod_gui.get_frame_flow(player).popups or mod_gui.get_frame_flow(player).add{name='popups',type='flow',direction='vertical'}
|
||||
local popups = mod_gui.get_frame_flow(player).popups
|
||||
local frame = get_next_popup(popups)
|
||||
frame_data[4](player,frame,args)
|
||||
end
|
||||
end
|
||||
--used to make the popup area
|
||||
Event.register(defines.events.on_player_joined_game,function(event) mod_gui.get_frame_flow(game.players[event.player_index]).add{name='popups',type='flow',direction='vertical'} end)
|
||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||
return credits
|
||||
Reference in New Issue
Block a user