ID:832426
 
(See the best response by Super Saiyan X.)
I'm designing an interface that requires the skins to support both http images and the click proc.

There are no skins (as far as I can tell) that support both http images and the Click proc.

Skins can't be made transparent, so I can't emulate the behavior I need.

I'm out of ideas. Does anyone have a solution?
Mardok wrote:
I'm designing an interface that requires the skins to support both http images and the click proc.

There are no skins (as far as I can tell) that support both http images and the Click proc.
you can use code to get images from website then set them as background.
Skins can't be made transparent, so I can't emulate the behavior I need.
as long as i know they can be made transparent.
I'm out of ideas. Does anyone have a solution?


You can use a button, save the http image to ur p.c then set the button background the the image and create a verb that wen clicked etc For example:
mob/verb/Finish_Char()
set hidden = 1//if u want it hidden
//what you want the verb to do and rememeber you dont have to call the click() proc because
//when you set the verb in the button command it will alreadly be called

Dont forget to take the () off when you are puttin the verb in the button command
In response to The Motto
The Motto wrote:
You can use a button, save the http image to ur p.c

It has to be grabbed from the web.
Wat u mean grabbed from a verb ?
Something like getting image from direct link, which can be changed over time during runtime
Best response
You can support HTTP images.
Just...in a unique way.
I just wrote this up, it works for me.

mob/verb/test(link as text)
winset(src, "some control or something", "image=[GetImage(link)]")
proc/GetImage(link)
var/img[] = world.Export(link)
if(findtext(img["CONTENT-TYPE"],"image"))
return img["CONTENT"]
In response to Super Saiyan X
Super Saiyan X wrote:
You can support HTTP images.
Just...in a unique way.
I just wrote this up, it works for me.

>
> mob/verb/test(link as text)
> winset(src, "some control or something", "image=[GetImage(link)]")
> proc/GetImage(link)
> var/img[] = world.Export(link)
> if(findtext(img["CONTENT-TYPE"],"image"))
> return img["CONTENT"]
>


Thank you, very much.

That works like a charm.
One last problem, is it possible to scale the image?

mob/verb/test(link as text)
winset(src, "button", "image=[GetImage(link)]")

proc/GetImage(link)
var/img[] = world.Export(link)
var/icon/webImage = img["CONTENT"]
//Scale webImage here
return webImage


Calling Scale on webImage doesn't work because, for some reason, webImage is null. But when the icon is returned with no manipulation, it works fine.
You might need to do:
var/icon/webImage = icon(img["CONTENT"])


I recommend keeping the "CONTENT-TYPE" check from my earlier example. That way, if the server is unable to reach a page without the proper content type of an image, it won't continue to pass the image it retrieved to whatever functions. It's better, if you want to stop errors. I'm pretty sure all images will return "CONTENT-TYPE" as "image/png" or whatever the type may be. So, a findtext() will check for the "image" there.


You might also want to check if img is null or not.
So, something like:

if(img&&findtext(img["CONTENT-TYPE"],"image"))
mob/verb/test(link as text)
winset(src, "button", "image=[GetImage(link)]")

proc/GetImage(link)
var/img[] = world.Export(link)
if(img && findtext(img["CONTENT-TYPE"], "image"))
var/icon/webIcon = icon(img["CONTENT"])
webIcon.Scale(50, 50)
return webIcon


After playing with this, it seems icon's don't like JPG's, and only accept PNG's.

The other problem is writing it as 'icon(img["CONTENT"])' makes it stop crashing, but nothing appears.

The program doesn't need to use the icon variable. The images are definitely restricted to skin's. Any other method to scale the image will do.
Hm. I had an issue like this when I was using icons in my skin.
If I recall, I did something like this:
mob/verb/test(link as text)
winset(src, "button", "image=\ref[fcopy_rsc(GetImage(link))]")

proc/GetImage(link)
var/img[] = world.Export(link)
if(img && findtext(img["CONTENT-TYPE"], "image"))
var/icon/webIcon = icon(img["CONTENT"])
webIcon.Scale(50, 50)
return webIcon
Because the file we originally got in the world.Export() is no longer the original data we got; it's now icon data, we have to push it the resource cache with fcopy_rsc, and use \ref to properly reference it.