TL;DR
Allow mods to create windows that behave similarly to built-in game windows.What ?
A window can be added only to `player.gui.screen` GUI root. A window behaves similarly to built-in game windows like inventory or entity details. In particular:- It has a close button in the top-right corner.
- It is automatically closed when another window is opened, e.g. when the player presses “E”.
- It is closed if the player presses “Escape”.
Why ?
Many mods need to create windows, this is a popular request: viewtopic.php?t=44378, viewtopic.php?t=29876. It was partially fixed in version 0.17.59 when `LuaGui::screen` was added. The suggested solution was to add a “frame” GUI element to the “screen” root in order to create a window. This does solve part of the problem: the created window is draggable and in many respects behaves as one would expect. However it doesn't have the properties mentioned above:- Close button needs to be added manually and it's quite tiresome (if you want it you basically cannot use “caption” to set window title and need to re-implement the title bar by hand).
- Closing the window when another window is opened also needs to be done manually.
- Overriding “Escape” is outright impossible if I understand correctly.