mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Fixed Popup
This commit is contained in:
10
control.lua
10
control.lua
@@ -28,5 +28,11 @@ Event.register(-1,function() global.credits = credits end)
|
|||||||
ExpGui.add_frame.center('Test','Test','A Simple Gui',5)
|
ExpGui.add_frame.center('Test','Test','A Simple Gui',5)
|
||||||
ExpGui.add_frame.tab('testing','Long Tab','Just Like any other',5,'Test',function(player,tab) for i=0,100 do tab.add{type='label',name=i,caption=player.name} end end)
|
ExpGui.add_frame.tab('testing','Long Tab','Just Like any other',5,'Test',function(player,tab) for i=0,100 do tab.add{type='label',name=i,caption=player.name} end end)
|
||||||
ExpGui.add_frame.tab('just_a_tab','A Tab','Just Like any other',5,'Test',function(player,tab) tab.add{type='label',name='temp',caption=player.name} end)
|
ExpGui.add_frame.tab('just_a_tab','A Tab','Just Like any other',5,'Test',function(player,tab) tab.add{type='label',name='temp',caption=player.name} end)
|
||||||
ExpGui.add_frame.left('left_test','Player Name','Just Like any other',5,function(player,frame) for i=0,10 do frame.add{type='label',name=i,caption=player.name..'\n'} end end)
|
ExpGui.add_frame.left('left_test','Player Name','Just Like any other',5,true,function(player,frame) for i=0,10 do frame.add{type='label',name=i,caption=player.name..'\n'} end end)
|
||||||
ExpGui.add_frame.popup('Message','Message','Just A ToolTip',5,function(player,frame) frame.add{name='TEST',type='label',caption=player.name} end,function(player,frame,args) frame.add{name='Message',type='label',caption=args[1]..' '..args[2]} end)
|
ExpGui.add_input.button('make_message','Messgaes','Lots of messages',function() for i = 1,10 do ExpGui.draw_frame.popup('Message',{'Just A Message',i}) end end)
|
||||||
|
ExpGui.add_frame.popup('Message','Message','Just A ToolTip',5,
|
||||||
|
function(player,frame)
|
||||||
|
ExpGui.add_input.draw_button(frame,'make_message') end,
|
||||||
|
function(player,frame,args)
|
||||||
|
frame.add{name='Message',type='label',caption=args[1]..' '..args[2]}
|
||||||
|
end)
|
||||||
|
|||||||
@@ -23,10 +23,12 @@ local frames = ExpGui.frames
|
|||||||
local draw_frame = ExpGui.draw_frame
|
local draw_frame = ExpGui.draw_frame
|
||||||
--left guis are always present and only have their visabilty toggled
|
--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
|
--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 name then error('Frame requires a name') end
|
||||||
if not event or type(event) ~= 'function' then error('Frame requires a draw function') 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)
|
ExpGui.toolbar.add_button(name,default_display,default_tooltip,restriction,draw_frame.left)
|
||||||
end
|
end
|
||||||
--draw the left gui for the player; do not call manuley must use other functions to call
|
--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
|
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)
|
local left = mod_gui.get_frame_flow(player)
|
||||||
if left[frame_data[1]] then ExpGui.toggleVisable(left[frame_data[1]]) return end
|
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)
|
frame_data[3](player,frame)
|
||||||
end
|
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-----------------------------------------------------------
|
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||||
return credits
|
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)
|
ExpGui.add_input.button('close_popup','X','Close This Popup',function(player,element) element.parent.destroy() end)
|
||||||
local function get_next_popup(popups,name)
|
local function get_next_popup(popups,name)
|
||||||
if name then
|
if name then
|
||||||
local flow = popups.add{type='flow',name=name..'_on_click',direction='horizontal'}
|
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='frame',direction='vertical'}
|
local frame = flow.add{name='popup_frame',type='flow',direction='vertical'}
|
||||||
ExpGui.add_input.draw_button(flow,'close_popup') return frame
|
ExpGui.add_input.draw_button(flow,'close_popup') return frame
|
||||||
end
|
end
|
||||||
local current = #popups.children
|
local current = 0
|
||||||
for _,p in pairs(popups.children) do
|
while true do if popups['popup'..current] then current = current+1 else break end end
|
||||||
if p.name == 'popup'..current then current = current+1 else
|
local flow = popups.add{type='frame',name='popup'..current,direction='horizontal',style=mod_gui.frame_style}
|
||||||
local flow = popups.add{type='flow',name='popup'..current,direction='horizontal'}
|
local frame = flow.add{name='popup_frame',type='flow',direction='vertical'}
|
||||||
local frame = flow.add{name='popup_frame',type='frame',direction='vertical'}
|
ExpGui.add_input.draw_button(flow,'close_popup')
|
||||||
ExpGui.add_input.draw_button(flow,'close_popup') return frame end
|
return frame
|
||||||
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
|
|
||||||
end
|
end
|
||||||
--adds a frame to the popup flow;restriction is the power need to use the on_click function
|
--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
|
--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)
|
function draw_frame.popup_button(player,element)
|
||||||
local frame_data = nil
|
local frame_data = nil
|
||||||
for _,frame in pairs(frames.popup) do if element.name == frame[1] then frame_data = frame break end end
|
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
|
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])
|
local frame = get_next_popup(popups,frame_data[1])
|
||||||
frame_data[3](player,frame)
|
frame_data[3](player,frame)
|
||||||
@@ -68,10 +63,12 @@ function draw_frame.popup(style,args)
|
|||||||
local frame_data = nil
|
local frame_data = nil
|
||||||
for _,frame in pairs(frames.popup) do if style == frame[1] then frame_data = frame break end end
|
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
|
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)
|
local frame = get_next_popup(popups)
|
||||||
frame_data[4](player,frame,args)
|
frame_data[4](player,frame,args)
|
||||||
end
|
end
|
||||||
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-----------------------------------------------------------
|
--Please Only Edit Above This Line-----------------------------------------------------------
|
||||||
return credits
|
return credits
|
||||||
Reference in New Issue
Block a user