Page 1 of 1

Modify existing GUI? Also, not all GUI present in LUA. :/

Posted: Tue Aug 04, 2020 9:19 am
by Lime
1. Is it possible to modify existing GUI of, for example, a chest or a car?

2. If not, is there a way to add new GUI elements on top of car GUI?

3. Where are all the GUIs defined? I can't find GUI definition for a locomotive, why isn't it present in LUA code?

Re: Modify existing GUI? Also, not all GUI present in LUA. :/

Posted: Tue Aug 04, 2020 10:30 am
by mrvn
1) No. The GUI isn't accessible from LUA.

2) No. You can add new elements but the Z-ordering is chaotic. Whatever opens last (which is the original GUI) is on top. Except that order isn't preserved when saving and loading. So initially your new elements would be below the original GUI but might come to the front if you save and load.

What you can do is open elements besides the original GUI. For example Bob's adjustable inserter opens a second window at the left side of the display with additional inserter configurations.

3) I believe the LUA GUI elements are just a set of building blocks for mods that people have requested or the devs found reasonable to provide. The c++ code uses the underlying GUI toolset directly and can do more.



What you can also do is replace the original GUI completely by writing (your GUI element) to player.opened. This then closes the original GUI (you get an event for that too) leaving just yours open. But good luck rebuilding the Locomotive GUI in LUA from scratch.

Re: Modify existing GUI? Also, not all GUI present in LUA. :/

Posted: Tue Aug 04, 2020 10:45 am
by Lime
Pity. I wanted to make a car with coordinate assignments akin to Locomotive... :) Seems like GUI API is still extremely basic...
Thanks, though.

PS. You've mentioned "open elements besides the original GUI" — do I understand correctly that there is a way to find size and coords of the original UI and position your own GUI relative to it?

Re: Modify existing GUI? Also, not all GUI present in LUA. :/

Posted: Tue Aug 04, 2020 11:54 am
by mrvn
I don't think you can get the size of the original GUI since that hasn't even been constructed yet as far as I know. Bob's adjustable inserters places the extra window at the left side of the screen, not left of the original GUI.

Re: Modify existing GUI? Also, not all GUI present in LUA. :/

Posted: Tue Aug 04, 2020 12:04 pm
by Lime
I see. Thanks! It's really a pity there's no good official resources on GUIs, so one have to literally dissect other people's mods to figure out things...

Re: Modify existing GUI? Also, not all GUI present in LUA. :/

Posted: Tue Aug 04, 2020 1:22 pm
by eradicator
Lime wrote: Tue Aug 04, 2020 10:45 am do I understand correctly that there is a way to find size and coords of the original UI and position your own GUI relative to it?
No. The vanilla gui can not at all be interacted with by mods. But all the sizes and positions are hardcoded, and gui scale and resolution are accessible via the mod api. So while you can't ask the engine to give you the position it should be possible to take a very good guess... until the player decides to drag the window around - then you're out of luck.

Re: Modify existing GUI? Also, not all GUI present in LUA. :/

Posted: Tue Aug 04, 2020 3:01 pm
by mrvn
eradicator wrote: Tue Aug 04, 2020 1:22 pm
Lime wrote: Tue Aug 04, 2020 10:45 am do I understand correctly that there is a way to find size and coords of the original UI and position your own GUI relative to it?
No. The vanilla gui can not at all be interacted with by mods. But all the sizes and positions are hardcoded, and gui scale and resolution are accessible via the mod api. So while you can't ask the engine to give you the position it should be possible to take a very good guess... until the player decides to drag the window around - then you're out of luck.
Don't some of them resize when you change the backer name or something you can't predict?

Anyway, using hardcoded sizes will break the next time they change the dialog. Then the user has to drag the overlapping dialogs every time they open. Balance that against having to move the mouse to the side of the screen instead of having the frames next to each other.

PS: would be nice if there were a flow that contains the original dialog that you could add yours too.