GUI Element type: Window

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

GUI Element type: Window

Post 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?
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: GUI Element type: Window

Post by Nexela »

Agreed!

Rseding91
Factorio Staff
Factorio Staff
Posts: 14142
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: GUI Element type: Window

Post 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.
If you want to get ahold of me I'm almost always on Discord.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: GUI Element type: Window

Post 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?
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Rseding91
Factorio Staff
Factorio Staff
Posts: 14142
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: GUI Element type: Window

Post 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.
If you want to get ahold of me I'm almost always on Discord.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: GUI Element type: Window

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: GUI Element type: Window

Post 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.

Xuerian
Inserter
Inserter
Posts: 36
Joined: Mon Nov 07, 2016 7:10 am
Contact:

Re: GUI Element type: Window

Post 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.

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: GUI Element type: Window

Post 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:
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

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

Re: GUI Element type: Window

Post 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?
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
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: GUI Element type: Window

Post by bobingabout »

I think this needs a bump.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

Rseding91
Factorio Staff
Factorio Staff
Posts: 14142
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: GUI Element type: Window

Post 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".
If you want to get ahold of me I'm almost always on Discord.

_npo6ka_
Fast Inserter
Fast Inserter
Posts: 102
Joined: Mon Sep 26, 2016 10:29 pm
Contact:

Re: GUI Element type: Window

Post 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)

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

Re: GUI Element type: Window

Post by Boodals »

This has been implemented for the next version of 0.17. See viewtopic.php?f=65&t=46487#p443704

Post Reply

Return to “Implemented mod requests”