Page 1 of 1

GUI Element type: Window

Posted: Tue Jul 26, 2016 9:39 am
by bobingabout
http://lua-api.factorio.com/0.13.11/LuaGuiElement.html

As a modder, I find the options for GUI creation, well, I'd say limited, but it is a very broad limit.

It just feels that all the GUI options available are aimed at creating what I'd call HUD elements, the onscreen GUI, like your map indicator, etc. you know, the fixed always on ones, and it's a bit lacking when it comes to creating a window, the closest option is frame.

So... My suggestion is to add another type of element, based on frame, which also has a few other window properties, such as:
Dragable.
The game treats it the same as most other windows, so it closes when you press E, or ESC (Like the Tech screen, and the inventory)

Actually, I think those 2 are it.

Alternatively, instead of a GUI element type, it could be another option on the GUI itself. http://lua-api.factorio.com/0.13.11/LuaGui.html
current options basically being Top, Left and Center, you could add a new position "window" that uses the same positioning as Center, but adds this functionality to whatever element is placed inside it.

What do you think?

Re: GUI Element type: Window

Posted: Tue Jul 26, 2016 10:01 am
by Nexela
Agreed!

Re: GUI Element type: Window

Posted: Tue Jul 26, 2016 2:17 pm
by Rseding91
It wouldn't be difficult to support it but saving the position of the window wouldn't be simple because it only really exists on the local player seeing the window.

Re: GUI Element type: Window

Posted: Tue Jul 26, 2016 4:44 pm
by bobingabout
How do you handle current windows that are open when saved, like when the game autosaves with your inventory open? Could you not just handle it the same way?

Re: GUI Element type: Window

Posted: Tue Jul 26, 2016 4:53 pm
by Rseding91
bobingabout wrote:How do you handle current windows that are open when saved, like when the game autosaves with your inventory open? Could you not just handle it the same way?
The game re-centers them next time it loads. The core game only ever has 1 GUI window open at a time.

If mods could add as many as they want then you'd end up with all of them on top of each other (which is fine) but it's not ideal.

Re: GUI Element type: Window

Posted: Tue Jul 26, 2016 4:57 pm
by bobingabout
Perhaps an additional parameter could be to specify default location (if more than one are supposed to exist at a time), but yes, I can see how some madness could happen.
My motivation behind the idea though is basically for a functionality similar to the main inventory, or entity GUIs, you're only supposed to have 1 or 2 on the screen at any one time, because most of the actions that would open one close another.

And as most things that already exist, it would be up to the modder to use the new power responsibly.

Re: GUI Element type: Window

Posted: Tue Jul 26, 2016 8:09 pm
by DedlySpyder
Rseding91 wrote:The game re-centers them next time it loads. The core game only ever has 1 GUI window open at a time.

If mods could add as many as they want then you'd end up with all of them on top of each other (which is fine) but it's not ideal.
Maybe when the game is reloaded with multiple windows open it staggers them like how Windows (and probably other OSs) does it.

Re: GUI Element type: Window

Posted: Mon Nov 07, 2016 7:24 am
by Xuerian
Amusingly enough I finally found this post before making a similar request.

.. So that I could add the functionality to Bob's inserters' window.

So yeah, this would be great. I've seen other mods in my brief bit of playing modded that could also benefit from this, and similar functionality is available for mods in other games like WoW (though I'm sure it's not a fair comparison), where windows can place themselves in a table to have a method called on them if they're currently visible when the equivalent of Close Windows is pressed.

Re: GUI Element type: Window

Posted: Mon Nov 07, 2016 9:08 am
by bobingabout
Xuerian wrote:Amusingly enough I finally found this post before making a similar request.

.. So that I could add the functionality to Bob's inserters' window.
That's exactly what I want to use it for! :lol:

Re: GUI Element type: Window

Posted: Tue Nov 08, 2016 5:08 am
by aubergine18
+1 for this.

Alternatively, can we get ability to have custom-input shortcuts that only apply to specific GUI elements and their child elements? Maybe done via a new scope on the custom-input, such as "gui", and the GUI element would have perhaps have some way to set which scopes are applicable?

Re: GUI Element type: Window

Posted: Mon Apr 24, 2017 9:58 am
by bobingabout
I think this needs a bump.

Re: GUI Element type: Window

Posted: Mon Apr 24, 2017 11:28 am
by Rseding91
This is definitely on my to do at some point - adding support for a mod to register a window as "close with the normal game 'close GUI' shortcuts".

Re: GUI Element type: Window

Posted: Thu Jun 08, 2017 9:29 am
by _npo6ka_
There is a bad method to close the window when you press the E key:

This method does not allow you to open simultaneously games gui and gui your mod:

Code: Select all

script.on_event(defines.events.on_tick, function(event)
  for _,player in pairs(game.players) do
    if player ~= nil and player.opened_gui_type ~= 0 and gui.is_gui_open(player) then
      gui.exit_from_gui(player)
      player.opened = nil
    end
  end
end)

Re: GUI Element type: Window

Posted: Mon Jul 22, 2019 9:35 am
by Boodals
This has been implemented for the next version of 0.17. See viewtopic.php?f=65&t=46487#p443704