ID:156072
 
When I do:
params["image"] = 'filename.png'

The image shows up as it should

But when I do:
params["image"] = file("filename.png")

No image is shown

I've tried setting the path to the image but it still doesn't work. If I'm doing this wrong or if there is another way of doing it please let me know.
Well I might be able to find your solution for you if I had the full code pertaining to setting the button image that you're using.

This here shows the innermost code that gets the image shown but I am talking about including any calls to winset, winget, etc... & where you define which control your trying to set.

Something like that will allow people to test using the exact calls you are in their enirety to maybe get errors that could be occuring due to a byond bug, etc...weirder things have happened than a possible byond bug using certain control names, etc....causing an issue.

--I ask that because I got similar than what you are asking for to work easily but maybe because of something you haven't shown is causing a problem with it.
In response to Superbike32
The code file is in ./Code and the Graphics folder is in ./Graphics if that matters with this function.

client/proc/setupButtons(path, x, y)
var/list/params = new
//Label
params["parent"] = "Tools"
params["type"] = "label"
params["text"] = "[path]"
params["pos"] = "[x],[y]"
params["font-style"] = "underline,bold"
params["size"] = "100x20"
params["anchor1"] = "0,0"
winset(src, "[path]", list2params(params))
y += 21
//Buttons
for(var/f in flist("./Graphics/Buttons/[path]/"))if(!findtextEx(f, "2"))
params = list()
params["parent"] = "Tools"
params["type"] = "button"
params["image"] = Files["[f]"]
params["command"] = "say \"[f]\""
params["pos"] = "[x],[y]"
params["is-flat"] = "true"
params["size"] = "25x21"
params["anchor1"] = "0,0"
winset(src, "[f]", list2params(params))
x += 25
if(x >= 90)
x = 0
y += 21
sleep(1)
y += 21
return y


Where it says Files["[f]"] is where file(f) should be. I generated a list of all the files which I would rather not do.

    Files["Custom Axis.png"] = 'Custom Axis.png'
Files["Custom Axis2.png"] = 'Custom Axis2.png'
Files["Custom X.png"] = 'Custom X.png'
Files["Custom X2.png"] = 'Custom X2.png'
Files["Custom Y.png"] = 'Custom Y.png'
Files["Custom Y2.png"] = 'Custom Y2.png'
Files["Custom Z.png"] = 'Custom Z.png'
Files["Custom Z2.png"] = 'Custom Z2.png'
Files["Global X.png"] = 'Global X.png'
[...]
In response to Zaltron
OK Zaltron I figured out a working code, kinda messy work-around but it will do what you want.

        var/obj/a=new
a.icon=file("file name.file extension")
var/list/b=new
b["image"]=a.icon
winset(src,"button1",list2params(b))


However you need to remember to get rid of the new obj for garbage collection to take care of it.

I was unable to get anything else to work, no matter what else I tried, I was only able to get it to set it correctly when it was like your first example or I got the reference from an icon/image from something that WOULD accept stuff like you were trying to do in the first place like the new objects icon.

Hope this helps.
In response to Superbike32
I just figured out another work around right as you posted yours which is weird that it works.

Add this line of code after you create the button:
winset(src, "[f]", "image='[f]'")



When you try setting

params["image"] = "'[f]'"


It doesn't work.
In response to Zaltron
I am glad to hear you got it working I will also note it for myself & is definitely much better than what I came up with.

I did try your second which didn't work but never did think to try & type out the variables name to winset directly since I was trying to keep by your original code as much as possible.
In response to Superbike32
Well I just tried the work-around you came up with maybe you could clarify exactly how it was because I tried the following & I couldn't get it to work.

        var/a=file("file name.file extension")
winset(src,"button1","image='[a]'")


How exactly did you get it to work, looks like to me you had a file reference & used winset to set the image like I did but it's not working.
In response to Zaltron
For the record you could just use this:

winset(src, "window.element", "image=\ref[fcopy_rsc(file("image file.extension"))]")


Pretty sure the reason it never worked was because you never copied the image into the resources :).
In response to ExPixel
Anyways ExPixel this isn't the case because I can use the image for other icons in-game, etc... while trying to do it for a button but it wont display in the button when using code like shown unless you use '' instead of trying to use "" so you can set images equal to a variable or something when there could be a lot of different images to pick from to display.
In response to Superbike32
Superbike32 wrote:
Well I just tried the work-around you came up with maybe you could clarify exactly how it was because I tried the following & I couldn't get it to work.

>       var/a=file("file name.file extension")
> winset(src,"button1","image='[a]'")
>

How exactly did you get it to work, looks like to me you had a file reference & used winset to set the image like I did but it's not working.

winset(src,"button1","image='filename.png'")


You just put in the file name as text with single quotes around it. It won't be the file itself.
In response to Superbike32
For some reason when I took out the predefined icons:

var/Files[0]

proc/setupFileList()
Files["Custom Axis.png"] = 'Custom Axis.png'
Files["Custom Axis2.png"] = 'Custom Axis2.png'
Files["Custom X.png"] = 'Custom X.png'
Files["Custom X2.png"] = 'Custom X2.png'
Files["Custom Y.png"] = 'Custom Y.png'
Files["Custom Y2.png"] = 'Custom Y2.png'
Files["Custom Z.png"] = 'Custom Z.png'
Files["Custom Z2.png"] = 'Custom Z2.png'
Files["Global X.png"] = 'Global X.png'
Files["Global X2.png"] = 'Global X2.png'
Files["Global Y.png"] = 'Global Y.png'


It doesn't show the button icons. The weird thing is, I don't reference those anywhere nor do I call that function to setup that list.
In response to Zaltron
Zaltron it's probably because the file's aren't being included with the game, I was mistakenly thinking anything in the folder was included with the resource files but thats not true, u have to make a direct reference to the .bmp image for it to be included or find a way to add it directly through an include statement or something else.
In response to Superbike32
What you just said made absolutely no sense to me...
In response to Superbike32
If you do not have a direct reference that includes a specific resource, Dream Maker will exclude it from the .rsc file. If this is the case, just simply including it along with the "host files", will resolve the issue.