LuaGui.overlay and LuaGuiElement.snap_to()

Post Reply
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

LuaGui.overlay and LuaGuiElement.snap_to()

Post by aubergine18 »

Ability to create floating panels and align them with other GUI elements. Would be very useful for custom dialogs, drop-downs, etc. For example, we could create re-usable circuit network panels, similar to what the game has, but with our own custom stuff in them.

Would work in much same way as any other panel, only it would appear in a separate 'gui.overlay' layer. The panels default to hidden, but can be shown and aligned with new GUI method such as:

Code: Select all

local overlay = game.players[somePLayer].gui.overlay
overlay.somePopUp.snap_to( anotherGuiElement, position )
overlay.somePopUp.style.visible = true
Where `anotherGuiElement` is any visible element for that player and `position` would be things like "bottom-left" (default), "top-right", "center", "bottom-center" etc.

This way, when a button is clicked we could easily show a popup panel aligned to that button, for example:

Code: Select all

-- note: could also trigger on custom-input events
script.on_event(defines.events.on_gui_click, function(event)
  local popup = game.players[event.player_index].gui.overlay.myPopUp
  popup.snap_to( event.element, "bottom-left" )
  popup.style.visible = not popup.visible
end )
With styling we could use such a feature to add drop-down menus, color pickers, drop down lists, recipe grids, etc...
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

User avatar
ssilk
Global Moderator
Global Moderator
Posts: 12888
Joined: Tue Apr 16, 2013 10:35 pm
Contact:

Re: LuaGui.overlay and LuaGuiElement.snap_to()

Post by ssilk »

Moved from Suggestions to Modding Interface Requests
Cool suggestion: Eatable MOUSE-pointers.
Have you used the Advanced Search today?
Need help, question? FAQ - Wiki - Forum help
I still like small signatures...

Boodals
Fast Inserter
Fast Inserter
Posts: 129
Joined: Sun Feb 11, 2018 7:10 pm
Contact:

Re: LuaGui.overlay and LuaGuiElement.snap_to()

Post by Boodals »

You can create popups using the LuaGui::screen that is coming out in the next version of 0.17.

Post Reply

Return to “Implemented mod requests”