Scaling sprite in GUI

Place to get help with not working mods / modding interface.
canidae
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Thu Feb 18, 2016 6:24 pm
Contact:

Scaling sprite in GUI

Post by canidae »

I'd like to add a sprite to my GUI, but I need to scale it. If I define my own button_style then the image is scaled just fine, but I don't need (nor want) a button with the sprite, just the image.
I tried this:

Code: Select all

data.raw["gui-style"].default["auto_research_sprite"] = {
    type = "image_style",
    width = 24,
    height = 24,
    top_padding = 0,
    right_padding = 0,
    bottom_padding = 0,
    left_padding = 0
}
This won't scale down a 32x32 sprite, it'll just crop it instead.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Scaling sprite in GUI

Post by aubergine18 »

There is a special 'sprite' GUI element and also a special 'sprite' prototype. I've not fully investigated yet, but here's some notes I jotted down:

* https://github.com/aubergine10/Style/issues/33
* https://github.com/aubergine10/Style/issues/34

The Foreman mod uses these sprites, I've no idea if they are scalable or not.

EDIT: I don't think I've seen an `image_style` used before - does that actually work? If so, how did you get it displayed in your GUI (regardless of scaling issues)?
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
canidae
Long Handed Inserter
Long Handed Inserter
Posts: 72
Joined: Thu Feb 18, 2016 6:24 pm
Contact:

Re: Scaling sprite in GUI

Post by canidae »

aubergine18 wrote:There is a special 'sprite' GUI element and also a special 'sprite' prototype. I've not fully investigated yet, but here's some notes I jotted down:

* https://github.com/aubergine10/Style/issues/33
* https://github.com/aubergine10/Style/issues/34

The Foreman mod uses these sprites, I've no idea if they are scalable or not.

EDIT: I don't think I've seen an `image_style` used before - does that actually work? If so, how did you get it displayed in your GUI (regardless of scaling issues)?
Quick response as I'm off for the night:
I've read some of your posts regarding this issue, but it seems like you didn't find a solution to the problem I wish to solve(?)
I don't know how I came across image_style, I tried a lot of stuff, maybe I just guessed. But it works (except the scaling issue). Take a look at Auto Research code.
Last edited by canidae on Fri Oct 07, 2016 6:07 am, edited 1 time in total.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Scaling sprite in GUI

Post by aubergine18 »

See if .scale or .scalable properties have any effect (either in the `image-style` or `sprite` protos).

From memory, .scalable is just something to do with game window resize, so probably not of any use.

However, .scale will sometimes work in image definitions (so hopefully in `sprite` definitions).

Failing that, you'd have to resize the image files themselves?
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Post Reply

Return to “Modding help”