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

Place to get help with not working mods / modding interface.
User avatar
Lime
Inserter
Inserter
Posts: 34
Joined: Tue Dec 23, 2014 1:50 pm
Contact:

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

Post 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?
Image
mrvn
Smart Inserter
Smart Inserter
Posts: 5969
Joined: Mon Sep 05, 2016 9:10 am
Contact:

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

Post 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.
User avatar
Lime
Inserter
Inserter
Posts: 34
Joined: Tue Dec 23, 2014 1:50 pm
Contact:

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

Post 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?
Image
mrvn
Smart Inserter
Smart Inserter
Posts: 5969
Joined: Mon Sep 05, 2016 9:10 am
Contact:

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

Post 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.
User avatar
Lime
Inserter
Inserter
Posts: 34
Joined: Tue Dec 23, 2014 1:50 pm
Contact:

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

Post 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...
Image
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

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

Post 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.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.
mrvn
Smart Inserter
Smart Inserter
Posts: 5969
Joined: Mon Sep 05, 2016 9:10 am
Contact:

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

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

Return to “Modding help”