Some questions about GUIs

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
asdff45
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Sun Aug 07, 2016 1:23 pm
Contact:

Some questions about GUIs

Post by asdff45 »

Hi,

im currently trying to create my own GUI, but its hard and not really documented :(

So 2 questions:
1. How to instantiate a Filler? Those lined things, that are in the normal uis, where the ui can be dragged. Those agui:Filler objects.
https://pasteboard.co/IgI1sGA.png

2. Is it possible to change things in the "Production Statistics" and the "Trains-Overview" UI? I want to add additional information and dont find a way to manipulate those UIs.

Bilka
Factorio Staff
Factorio Staff
Posts: 3123
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: Some questions about GUIs

Post by Bilka »

No and no.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

asdff45
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Sun Aug 07, 2016 1:23 pm
Contact:

Re: Some questions about GUIs

Post by asdff45 »

Hm, thats unfortunate. I have to make it differently :(
Thanks for the short and precise answer.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Some questions about GUIs

Post by eradicator »

1) A standard frame will have a visual filler. But you can't use it to drag/drop the window because mod guis can't be moved.

Code: Select all

/c x = game.player.gui.center.add{type='frame',caption='whateverrrr'} x.style.width  = 500 x.style.height = 500
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.

asdff45
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Sun Aug 07, 2016 1:23 pm
Contact:

Re: Some questions about GUIs

Post by asdff45 »

ok, next question:

I want to have a max-height of around 80% of window-height. How to define a percentage of screen-heigth. Or even better, how to get the current window-height?


User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Some questions about GUIs

Post by eradicator »

You have to divide display_resolution by display_scale btw, or else it'll be wrong if someone plays i.e. on a 4k screen with 200% scale.
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.

asdff45
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Sun Aug 07, 2016 1:23 pm
Contact:

Re: Some questions about GUIs

Post by asdff45 »

Thanks for the help so far.
Next question:
Does a on_focus event exist? and how can i find out, if an element is focused?

eduran
Filter Inserter
Filter Inserter
Posts: 344
Joined: Fri May 09, 2014 2:52 pm
Contact:

Re: Some questions about GUIs

Post by eduran »

asdff45 wrote:
Wed Jun 12, 2019 2:07 pm
Thanks for the help so far.
Next question:
Does a on_focus event exist? and how can i find out, if an element is focused?
No, at least not directly, and you can't. A lot of GUI related stuff (mouse position, cursor position in a text field, the focused element) is not part of the game state and therefore not readable. You can set the focused element using LuaGuiElement.focus().

asdff45
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Sun Aug 07, 2016 1:23 pm
Contact:

Re: Some questions about GUIs

Post by asdff45 »

Is it possible to change the design of a button? Or set the button to "active" state?

Post Reply

Return to “Modding discussion”