mirror of
https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git
synced 2025-01-07 23:01:35 +02:00
Added Esc key to close top-left GUI and fixed issue where you could be typing into the notepad when it's closed.
This commit is contained in:
parent
c73863de21
commit
b447c77517
@ -426,3 +426,12 @@ script.on_event(defines.events.on_gui_text_changed, function(event)
|
|||||||
NotepadOnGuiTextChange(event)
|
NotepadOnGuiTextChange(event)
|
||||||
SharedElectricityPlayerGuiValueChange(event)
|
SharedElectricityPlayerGuiValueChange(event)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
----------------------------------------
|
||||||
|
-- On Gui Closed
|
||||||
|
-- For capturing player escaping custom GUI so we can close it using ESC key.
|
||||||
|
----------------------------------------
|
||||||
|
script.on_event(defines.events.on_gui_closed, function(event)
|
||||||
|
OarcGuiOnGuiClosedEvent(event)
|
||||||
|
end)
|
@ -79,10 +79,18 @@ function DoesOarcGuiExist(player)
|
|||||||
return (mod_gui.get_frame_flow(player)[OARC_GUI] ~= nil)
|
return (mod_gui.get_frame_flow(player)[OARC_GUI] ~= nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function IsOarcGuiVisible(player)
|
||||||
|
local of = mod_gui.get_frame_flow(player)[OARC_GUI]
|
||||||
|
return (of.visible)
|
||||||
|
end
|
||||||
|
|
||||||
function ToggleOarcGuiVisible(player)
|
function ToggleOarcGuiVisible(player)
|
||||||
local of = mod_gui.get_frame_flow(player)[OARC_GUI]
|
local of = mod_gui.get_frame_flow(player)[OARC_GUI]
|
||||||
if (of ~= nil) then
|
if (of ~= nil) then
|
||||||
of.visible = not of.visible
|
of.visible = not of.visible
|
||||||
|
if (of.visible) then
|
||||||
|
player.opened = of -- This allows us to indicate the player has this GUI open and when they press Esc we'll get an event!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -111,8 +119,10 @@ function ClickOarcGuiButton(event)
|
|||||||
CreateOarcGuiTabsPane(player)
|
CreateOarcGuiTabsPane(player)
|
||||||
else
|
else
|
||||||
ToggleOarcGuiVisible(player)
|
ToggleOarcGuiVisible(player)
|
||||||
|
if (IsOarcGuiVisible(player)) then
|
||||||
FakeTabChangeEventOarcGui(player)
|
FakeTabChangeEventOarcGui(player)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function TabChangeOarcGui(event)
|
function TabChangeOarcGui(event)
|
||||||
@ -265,3 +275,9 @@ function SwitchOarcGuiTab(player, tab_name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function OarcGuiOnGuiClosedEvent(event)
|
||||||
|
if (event.element.name == "oarc_gui") then
|
||||||
|
ToggleOarcGuiVisible(game.players[event.player_index])
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user