Positioning relative to another CustomGui element

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 682
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Positioning relative to another CustomGui element

Post by raiguard »

This has been churning in my head for a while... The base game has several GUIs that appear relative to other elements (for example, choose-elem-buttons). It would be awesome if we could do this as well. Obviously the game has some way of knowing where an element is on-screen, so could this be extended to CustomGui as well?

I'm not sure how the implementation would be done. The return value would be a location that you would use on a frame in player.gui.screen, but I'm not sure how you would get the location. Or if it can even be done within gamestate.

Is this possible?
Don't forget, you're here forever.
User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5211
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Positioning relative to another CustomGui element

Post by eradicator »

LuaGuiElement.location allows you to read the position of elements in "screen" (only if it's been manually set according to doc). Location of non-screen elements is not part of gamestate as far as i know.

So as long as you only want to position stuff relative to guis you created youself it should already be possible?
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.
User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 682
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: Positioning relative to another CustomGui element

Post by raiguard »

I want to position stuff relative to any CustomGui element, whether that be a child in a frame stored in screen, or something in mod GUI. It's probably too much to ask for though.

As it is now I can just hardcode the relative locations of the children I want to position stuff relative to, but that's ugly.
Don't forget, you're here forever.
Post Reply

Return to “Modding interface requests”