ID:149413
 
I can't find a way to display different icon_states of dmi files in the browser.

<IMG CLASS=icon SRC=\ref[icon] ICONSTATE='[icon_state]'>
is supposed to be the equivilent of \icon[src] in the text area, but does not work in the browser. Nor does
<IMG SRC=[icon] ICONSTATE='[icon_state]'>



        var/image/I = image(icon,src)
usr << browse_rsc(I)
var/html = "<IMG SRC=[I]>"

gives a bad resource error on the browse_rsc() line, and predictably gives a broken image link in the browser if the browse_rsc() line is removed.
        var/icon/I = new(icon,icon_state)
usr << browse_rsc(I)
var/html = "<IMG SRC=[I]>"

also produces a broken image link.

(Yes, usr is used properly in the above snippets. The original snippet displayed icons in their default icon_state.)
I'm not too sure about this, but:

obj
images
someimage
icon = 'someicon.dmi'
icon_state = "some icon state"

mob
verb
showicon_state()
var/someicon = /obj/images/someimage
usr << browse_rsc(someicon,"someimage.dmi")
usr << browse("<img src=someimage.dmi>")


It's not tested, just a guess, worth a try =P
In response to Nadrew
No, that doesn't work.
In response to Shadowdarke
I know it's something like that, I've done it before; I'll do a little testing later.
In response to Nadrew
Nadrew wrote:
I'm not too sure about this, but:

obj
images
someimage
icon = 'someicon.dmi'
icon_state = "some icon state"

mob
verb
showicon_state()
var/someicon = /obj/images/someimage
usr << browse_rsc(someicon,"someimage.dmi")
usr << browse("")

You're setting someicon to a type path; that will never work in browse_rsc().

Lummox JR
In response to Lummox JR
I tried several varieties in the same theme. Creating a new instance of the obj, sending the icon to the browse_rsc, and using the obj in the IMG tag seemed most likely to work, but it doesn't (with or without a \ref text macro.)
Shadowdarke wrote:
I can't find a way to display different icon_states of dmi files in the browser.

<IMG CLASS=icon SRC=\ref[icon] ICONSTATE='[icon_state]'>
is supposed to be the equivilent of \icon[src] in the text area, but does not work in the browser. Nor does
<IMG SRC=[icon] ICONSTATE='[icon_state]'>



        var/image/I = image(icon,src)
usr << browse_rsc(I)
var/html = "<IMG SRC=[I]>"

gives a bad resource error on the browse_rsc() line, and predictably gives a broken image link in the browser if the browse_rsc() line is removed.

You're close on that, but what you really need is /icon, not /image. With /icon you can strip an icon down to one state at creation time. Although in most cases you'd then have to use fcopy_rsc() to use the /icon, browse_rsc() has been set up in such a way that it knows an /icon should be converted to a .png.
var/icon/ic = new(icon,icon_state)
usr << browse_rsc(ic,"[ckey(name)].png")
var/html = "<IMG SRC='[ckey(name)].png' WIDTH=32 HEIGHT=32>"

You can use .dmi as the file name too. There was a time when BYOND cared which one you used, because otherwise it didn't convert correctly; the image converted via browse_rsc() is a PNG format either way.

The reason, incidentally, that the text-window format doesn't work in the mini-browser is that the text window is basically displaying HTML on its own, whereas the mini-browser uses IE. IE doesn't understand BYOND's special syntax for icons.

Lummox JR
In response to Lummox JR
That works perfectly. Thanks, Lummox! Using an icon was one of the methods I tried, but I didn't assign a filename in the browse_rsc() and addressing it directly as I didn't work.

Lummox JR wrote:
The reason, incidentally, that the text-window format doesn't work in the mini-browser is that the text window is basically displaying HTML on its own, whereas the mini-browser uses IE. IE doesn't understand BYOND's special syntax for icons.

Yes. I realized that, but thought it was worth a shot anyway. :)