GUI Element type: Window
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
GUI Element type: Window
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?
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
Agreed!
Re: GUI Element type: Window
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.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: GUI Element type: Window
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
The game re-centers them next time it loads. The core game only ever has 1 GUI window open at a time.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?
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.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: GUI Element type: Window
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.
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.
- DedlySpyder
- Filter Inserter
- Posts: 253
- Joined: Fri Jun 20, 2014 11:42 am
- Contact:
Re: GUI Element type: Window
Maybe when the game is reloaded with multiple windows open it staggers them like how Windows (and probably other OSs) does it.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.
Re: GUI Element type: Window
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.
.. 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.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: GUI Element type: Window
That's exactly what I want to use it for!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.
- aubergine18
- Smart Inserter
- Posts: 1264
- Joined: Fri Jul 22, 2016 8:51 pm
- Contact:
Re: GUI Element type: Window
+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?
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.
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: GUI Element type: Window
I think this needs a bump.
Re: GUI Element type: Window
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.
Re: GUI Element type: Window
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:
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
This has been implemented for the next version of 0.17. See viewtopic.php?f=65&t=46487#p443704