mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Popup clean
This commit is contained in:
@@ -28,7 +28,7 @@ function add_frame.tab(name,default_display,default_tooltip,frame,event)
|
|||||||
ExpGui.add_input.button(name,default_display,default_tooltip,draw_frame.tab)
|
ExpGui.add_input.button(name,default_display,default_tooltip,draw_frame.tab)
|
||||||
end
|
end
|
||||||
--Draw the center GUI for the player; do not call manually, must use other functions to call
|
--Draw the center GUI for the player; do not call manually, must use other functions to call
|
||||||
ExpGui.add_input.button('close_center','Close','Close this GUI',function(player,element) element.parent.parent.parent.destroy() end)
|
ExpGui.add_input.button('close_center',{'expgui.close-button'},{'expgui.close-button-tooltip'},function(player,element) element.parent.parent.parent.destroy() end)
|
||||||
function draw_frame.center(player,element)
|
function draw_frame.center(player,element)
|
||||||
frame_data = frames.center[element.name]
|
frame_data = frames.center[element.name]
|
||||||
debug_write({'GUI','CENTER'},player.name..' '..frame_data.name)
|
debug_write({'GUI','CENTER'},player.name..' '..frame_data.name)
|
||||||
|
|||||||
@@ -5,24 +5,13 @@ This file can be used with permission but this and the credit below must remain
|
|||||||
Contact a member of management on our discord to seek permission to use our code.
|
Contact a member of management on our discord to seek permission to use our code.
|
||||||
Any changes that you may make to the code are yours but that does not make the script yours.
|
Any changes that you may make to the code are yours but that does not make the script yours.
|
||||||
Discord: https://discord.gg/XSsBV6b
|
Discord: https://discord.gg/XSsBV6b
|
||||||
|
|
||||||
The credit below may be used by another script do not remove.
|
|
||||||
]]
|
]]
|
||||||
local credits = {{
|
|
||||||
name='ExpGaming - Popup Gui',
|
|
||||||
owner='Explosive Gaming',
|
|
||||||
dev='Cooldude2606',
|
|
||||||
description='Small popups in the top left',
|
|
||||||
factorio_version='0.15.23',
|
|
||||||
show=false
|
|
||||||
}}
|
|
||||||
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
|
|
||||||
--Please Only Edit Below This Line-----------------------------------------------------------
|
--Please Only Edit Below This Line-----------------------------------------------------------
|
||||||
local add_frame = ExpGui.add_frame
|
local add_frame = ExpGui.add_frame
|
||||||
local frames = ExpGui.frames
|
local frames = ExpGui.frames
|
||||||
local draw_frame = ExpGui.draw_frame
|
local draw_frame = ExpGui.draw_frame
|
||||||
--used to draw the next popup frame
|
--used to draw the next popup 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',{'expgui.popup-close-tooltip'},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='frame',name=name..'_on_click',direction='horizontal',style=mod_gui.frame_style}
|
local flow = popups.add{type='frame',name=name..'_on_click',direction='horizontal',style=mod_gui.frame_style}
|
||||||
@@ -43,7 +32,7 @@ end
|
|||||||
function add_frame.popup(style,default_display,default_tooltip,on_click,event)
|
function add_frame.popup(style,default_display,default_tooltip,on_click,event)
|
||||||
if not style then error('Popup style requires a name') end
|
if not style then error('Popup style requires a name') end
|
||||||
if not event or type(event) ~= 'function' then error('Popup style requires a draw function') end
|
if not event or type(event) ~= 'function' then error('Popup style requires a draw function') end
|
||||||
table.insert(frames.popup,{style=style,display=default_display,on_click=on_click,event=event})
|
frames.popup[style] = {style=style,display=default_display,on_click=on_click,event=event})
|
||||||
if on_click and type(on_click) == 'function' then
|
if on_click and type(on_click) == 'function' then
|
||||||
ExpGui.toolbar.add_button(style,default_display,default_tooltip,draw_frame.popup_button)
|
ExpGui.toolbar.add_button(style,default_display,default_tooltip,draw_frame.popup_button)
|
||||||
end
|
end
|
||||||
@@ -51,8 +40,7 @@ end
|
|||||||
--draw the popup on_click GUI for the player; do not call manually must use other functions to call
|
--draw the popup on_click GUI for the player; do not call manually must use other functions to call
|
||||||
function draw_frame.popup_button(player,element)
|
function draw_frame.popup_button(player,element)
|
||||||
debug_write({'GUI','POPUP-BUTTON'},player.name)
|
debug_write({'GUI','POPUP-BUTTON'},player.name)
|
||||||
local frame_data = nil
|
local frame_data = frames.popup[element.name]
|
||||||
for _,frame in pairs(frames.popup) do if element.name == frame.style then frame_data = frame break end end
|
|
||||||
local popups = mod_gui.get_frame_flow(player).popups
|
local popups = mod_gui.get_frame_flow(player).popups
|
||||||
if popups[frame_data.style..'_on_click'] then popups[frame_data.style..'_on_click'].destroy() return end
|
if popups[frame_data.style..'_on_click'] then popups[frame_data.style..'_on_click'].destroy() return end
|
||||||
local frame = get_next_popup(popups,frame_data.style)
|
local frame = get_next_popup(popups,frame_data.style)
|
||||||
@@ -61,8 +49,7 @@ end
|
|||||||
--used to draw a popup style can be called at any time; can not be called from a button directly
|
--used to draw a popup style can be called at any time; can not be called from a button directly
|
||||||
function draw_frame.popup(style,args)
|
function draw_frame.popup(style,args)
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local frame_data = nil
|
local frame_data = frames.popup[style]
|
||||||
for _,frame in pairs(frames.popup) do if style == frame.style then frame_data = frame break end end
|
|
||||||
debug_write({'GUI','POPUP','STYLE'},style)
|
debug_write({'GUI','POPUP','STYLE'},style)
|
||||||
debug_write({'GUI','POPUP','ARGS'},args)
|
debug_write({'GUI','POPUP','ARGS'},args)
|
||||||
game.write_file('popups.log','\n'..game.tick..' Popup Style: '..style..' Was made with args of: '..table.tostring(args), true, 0)
|
game.write_file('popups.log','\n'..game.tick..' Popup Style: '..style..' Was made with args of: '..table.tostring(args), true, 0)
|
||||||
@@ -74,6 +61,4 @@ function draw_frame.popup(style,args)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
--used to make the popup area
|
--used to make the popup area
|
||||||
Event.register(defines.events.on_player_joined_game,function(event) if not mod_gui.get_frame_flow(game.players[event.player_index]).popups then mod_gui.get_frame_flow(game.players[event.player_index]).add{name='popups',type='flow',direction='vertical'} end end)
|
Event.register(defines.events.on_player_joined_game,function(event) if not mod_gui.get_frame_flow(game.players[event.player_index]).popups then mod_gui.get_frame_flow(game.players[event.player_index]).add{name='popups',type='flow',direction='vertical'} end end)
|
||||||
--Please Only Edit Above This Line-----------------------------------------------------------
|
|
||||||
return credits
|
|
||||||
@@ -20,4 +20,7 @@ sudo-info=At game tick: __1__ Queue Lenth: __2__ Number of temp vars: __3__
|
|||||||
[expgui]
|
[expgui]
|
||||||
button-no-display=No name
|
button-no-display=No name
|
||||||
button-no-tooltip=Ask some one what this does
|
button-no-tooltip=Ask some one what this does
|
||||||
text-no-display=BLANK
|
text-no-display=BLANK
|
||||||
|
close-button=Close
|
||||||
|
close-button-tooltip=Close this GUI
|
||||||
|
popup-close-tooltip=Close this Popup
|
||||||
Reference in New Issue
Block a user