Page 1 of 1

[0.16.51] Style.width/height is incorret.

Posted: Fri Nov 09, 2018 12:44 pm
by eradicator
What
Applying LuaGuiElement.style.height/width = 128 for example does not make a 128x128 element.
not128.png
not128.png (99.37 KiB) Viewed 2102 times
Reproduce

Code: Select all

/c
game.player.gui.center.clear()
x = game.player.gui.center.add{type='frame'}
x.style.width = 128
x.style.height=128
At standard zoom (F9) the problem is quite obvious even in the in-game grid. Though i discovered it by measuring pixels on a screenshot. The deviation seems to depend on the size of factorios game window.

Why?
I'm trying to get a screen-sized window but using display_resolution makes it larger than the screen.

Code: Select all

/c
game.player.gui.center.clear()
x = game.player.gui.center.add{type='frame'}
x.style.width = game.player.display_resolution.width
x.style.height=game.player.display_resolution.height

Re: [0.16.51] Style.width/height is incorret.

Posted: Fri Nov 09, 2018 12:49 pm
by Bilka
Is your gui scale set to 1 and your resolution 720p? Only then the width/height is actually 1:1 the pixel width/height, otherwise it's not.

Re: [0.16.51] Style.width/height is incorret.

Posted: Fri Nov 09, 2018 12:59 pm
by eradicator
Bilka wrote: Fri Nov 09, 2018 12:49 pm Is your gui scale set to 1 and your resolution 720p? Only then the width/height is actually 1:1 the pixel width/height, otherwise it's not.
Scale 1 yes, 720p..no? Who plays at 720p in this age. And the point is that display_resolution is meaningless if i can't use it to make precisely sized windows.

Re: [0.16.51] Style.width/height is incorret.

Posted: Fri Nov 09, 2018 1:04 pm
by Klonan
It does some internal hidden scaling, which is removed for 0.17.

Until then, you can disable the auto scaling by setting:
https://lua-api.factorio.com/latest/Lua ... .scaleable
to false

Re: [0.16.51] Style.width/height is incorret.

Posted: Fri Nov 09, 2018 1:13 pm
by eradicator
Klonan wrote: Fri Nov 09, 2018 1:04 pm It does some internal hidden scaling, which is removed for 0.17.

Until then, you can disable the auto scaling by setting:
https://lua-api.factorio.com/latest/Lua ... .scaleable
to false
That seems to work. Thank you. This was quite frustrating.

Re: [0.16.51] Style.width/height is incorret.

Posted: Fri Nov 09, 2018 2:21 pm
by eradicator
Klonan wrote: Fri Nov 09, 2018 1:04 pm It does some internal hidden scaling, which is removed for 0.17.
Hm...can you please post the source for the scaling (or the formula)?
It looks like i might need to mimick it to get the elements precisely the size i want (i.e. the size of the vanilla gui elements next to it).