Add Gui Inputs (Unable to test)

This commit is contained in:
Cooldude2606
2017-07-02 11:17:22 +01:00
parent 9241ef28ae
commit 45798b7b88
9 changed files with 248 additions and 2 deletions

View File

@@ -45,7 +45,7 @@ Event.register(defines.events.on_tick, function(event)
command=table.remove(global.sudo)
if command and command.fun and type(command.fun) == 'function' then
local args = command.var or {}
command.fun(args[1],args[2],args[3],args[4],args[5],args[6])
command.fun(unpack(args))
end
end
end)

View File

@@ -0,0 +1,23 @@
--[[
Explosive Gaming
This file can be used with permission but this and the credit below must remain in the file.
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.
Discord: https://discord.gg/XSsBV6b
The credit below may be used by another script do not remove.
]]
local credits = {{
name='File Header - ExpGaming-Core-GUI',
owner='Explosive Gaming',
dev='Cooldude2606',
description='Just A File Header To Organise Code',
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 Above This Line-----------------------------------------------------------
return credits

View File

@@ -0,0 +1,76 @@
--[[
Explosive Gaming
This file can be used with permission but this and the credit below must remain in the file.
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.
Discord: https://discord.gg/XSsBV6b
The credit below may be used by another script do not remove.
]]
local credits = {{
name='Gui Input Handler',
owner='Explosive Gaming',
dev='Cooldude2606',
description='Just A File Header To Organise Code',
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-----------------------------------------------------------
local add_input = ExpGui.add_input
local inputs = ExpGui.inputs
--allows defining of new buttons;;name how to call button;;default_display what is showen on the button;;default_tooltip the tooltip display;;event function(player,element) that runs on click
function add_input.button(name,default_display,default_tooltip,event)
table.insert(inputs.buttons,{name,default_display,default_tooltip,event})
end
--allows defining of text box inputs;;name how to call button;;default_display what is showen on the button;;event function(player,element) that runs on text change
function add_input.text(name,default_display,event)
table.insert(inputs.text,{name,default_display,event})
end
--draws the button into a gui;;frame the frame to draw to;;name name of button to draw;;display(opptinal) overides the default;;tooltip(opptinal) overides the default
function add_input.draw_button(frame,name,display,tooltip)
for _,btn in pairs(inputs.buttons) do
if btn[1] == name then
local display = display or btn[2]
local tooltip = tooltip or btn[3]
if frame.gui.is_valid_sprite_path(display) then
frame.add{name=name, type = "sprite-button", sprite=display, tooltip=tooltip, style = mod_gui.button_style}
else
frame.add{name=name, type = "button", caption=display, tooltip=tooltip, style = mod_gui.button_style}
end break
end
end
end
--draws the text into a gui;;frame the frame to draw to;;name name of button to draw;;display(opptinal) overides the default;;tooltip(opptinal) overides the default
function add_input.draw_button(frame,name,display)
for _,text in pairs(inputs.text) do
if text[1] == name then
local display = display or text[2]
frame.add{name=name, type='textfield', text=display}
break
end
end
end
--the magic behind the buttons
Event.register(defines.events.on_gui_click, function(event)
local player = game.players[event.player_index]
if event.element.type == 'button' or event.element.type == 'sprite-button' then
for _,btn in pairs(inputs.buttons) do
if btn[1] == event.element.name then
if btn[4] then btn[4](player,event.element) else rank_print('Button Without Function '..btn[1],'Mod') end break
end
end
end
end)
--the magic behind the text inputs
Event.register(defines.events.on_gui_text_changed, function(event)
local player = game.players[event.player_index]
for _,text in pairs(inputs.text) do
if text[1] == event.element.name then
if text[3] then text[3](player,event.element) end break
end
end
end)
--Please Only Edit Above This Line-----------------------------------------------------------
return credits

View File

@@ -0,0 +1,23 @@
--[[
Explosive Gaming
This file can be used with permission but this and the credit below must remain in the file.
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.
Discord: https://discord.gg/XSsBV6b
The credit below may be used by another script do not remove.
]]
local credits = {{
name='File Header - ExpGaming-Core-GUI',
owner='Explosive Gaming',
dev='Cooldude2606',
description='Just A File Header To Organise Code',
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 Above This Line-----------------------------------------------------------
return credits

View File

@@ -0,0 +1,49 @@
--[[
Explosive Gaming
This file can be used with permission but this and the credit below must remain in the file.
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.
Discord: https://discord.gg/XSsBV6b
The credit below may be used by another script do not remove.
]]
local credits = {{
name='Setup for the Gui Object',
owner='Explosive Gaming',
dev='Cooldude2606',
description='The very fondation of the Gui System',
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-----------------------------------------------------------
ExpGui = {
add_frame={
--center
--left
--popup
},
add_input={
--button
--text
--draw_button
--draw_text
},
toolbar={
--draw
--add_button
},
--add_player_table
inputs={
buttons={},
text={}
},
frames={
center={},
left={},
popup={}
}
}
--Please Only Edit Above This Line-----------------------------------------------------------
return credits

View File

@@ -0,0 +1,23 @@
--[[
Explosive Gaming
This file can be used with permission but this and the credit below must remain in the file.
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.
Discord: https://discord.gg/XSsBV6b
The credit below may be used by another script do not remove.
]]
local credits = {{
name='File Header - ExpGaming-Core-GUI',
owner='Explosive Gaming',
dev='Cooldude2606',
description='Just A File Header To Organise Code',
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 Above This Line-----------------------------------------------------------
return credits

View File

@@ -0,0 +1,23 @@
--[[
Explosive Gaming
This file can be used with permission but this and the credit below must remain in the file.
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.
Discord: https://discord.gg/XSsBV6b
The credit below may be used by another script do not remove.
]]
local credits = {{
name='File Header - ExpGaming-Core-GUI',
owner='Explosive Gaming',
dev='Cooldude2606',
description='Just A File Header To Organise Code',
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 Above This Line-----------------------------------------------------------
return credits

View File

@@ -0,0 +1,23 @@
--[[
Explosive Gaming
This file can be used with permission but this and the credit below must remain in the file.
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.
Discord: https://discord.gg/XSsBV6b
The credit below may be used by another script do not remove.
]]
local credits = {{
name='File Header - ExpGaming-Core-GUI',
owner='Explosive Gaming',
dev='Cooldude2606',
description='Just A File Header To Organise Code',
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 Above This Line-----------------------------------------------------------
return credits

View File

@@ -18,6 +18,12 @@ local credits = {{
}}
local function credit_loop(reg) for _,cred in pairs(reg) do table.insert(credits,cred) end end
--Please Only Edit Below This Line-----------------------------------------------------------
credit_loop(require("ExpGaming - Modlue Setup"))
credit_loop(require("ExpGaming - Inputs"))
credit_loop(require("ExpGaming - Toolbar"))
credit_loop(require("ExpGaming - Center Gui"))
credit_loop(require("ExpGaming - Left Gui"))
credit_loop(require("ExpGaming - Player Table"))
credit_loop(require("ExpGaming - Popup"))
--Please Only Edit Above This Line-----------------------------------------------------------
return credits