ID:162914
 
I'm trying to set the image of a button to a certain icon graphic in a certain icon_state, but this fails. The image that appears in the button is the first state of whatever the icon is, and on top of that there is no transparency, just the standard gray background. What is up with that? I do have the latest version of byond, 4.11
Obs wrote:
I'm trying to set the image of a button to a certain icon graphic in a certain icon_state, but this fails. The image that appears in the button is the first state of whatever the icon is,

That's because an image does not equal an icon. An icon essentially is a whole collection of images; if you try to use one as an image in your skin it will appear as just a single image.

and on top of that there is no transparency, just the standard gray background.

At this time, buttons don't support transparency. That's on the to-do list.

Lummox JR
In response to Lummox JR
I tried making an image object with the icon_state I wanted for the button, but no image ever came up on it. Does this mean that every image displayed for a button will need it's own icon file? How exactly could I display one particular icon_state?
In response to Obs
Obs wrote:
I tried making an image object with the icon_state I wanted for the button, but no image ever came up on it. Does this mean that every image displayed for a button will need it's own icon file? How exactly could I display one particular icon_state?

var/icon/I = new('myicon.dmi', "button")
var/iconfile = fcopy_rsc(I)
winset(src, "window3.mybutton", "image=\ref[iconfile]")


That ought to work for you.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Obs wrote:
I tried making an image object with the icon_state I wanted for the button, but no image ever came up on it. Does this mean that every image displayed for a button will need it's own icon file? How exactly could I display one particular icon_state?

var/icon/I = new('myicon.dmi', "button")
> var/iconfile = fcopy_rsc(I)
> winset(src, "window3.mybutton", "image=\ref[iconfile]")

That ought to work for you.

Lummox JR

Haven't tried this yet but if it works it's basically making a new file in a resource cache? I can see how that works, but I'm thinking about efficiency now. When I'm going to change the button's graphic again will I have to manually delete this temporary iconfile that was created, or will byond do it automatically if there is no reference to it? I know dereferenced objects are deleted automatically but I don't know about files.

Ultimately I wouldn't want a server's resource cache filling up with hundreds of unused iconfiles, because the button images will be changing very frequently, and to many different graphics.
In response to Obs
You also can't do something like "background-color += [rgb(4,4,4)]" in the parameter of winset either right? It didn't seem to work correctly when I tried it.