ID:155607
 
mob
Stat()
if(src.Dueling)
if(src.Deck.len)
statpanel("Deck")
for(var/obj/Card/A in src.Deck)
stat(A)

Is there any way to show A's Name var(not the default name var) followed by its icon?
I also need to keep the ability to Click() on the icon or the name.
Anthropophagite wrote:
mob
> Stat()
> if(src.Dueling)
> if(src.Deck.len)
> statpanel("Deck")
> for(var/obj/Card/A in src.Deck)
> stat(A)

Is there any way to show A's Name var(not the default name var) followed by its icon?
I also need to keep the ability to Click() on the icon or the name.


I can help you out with some of this. Here's an example

mob/Stat()
statpanel("Statisitics")
stat(Name:","[src.Name]")

See how that works? Once you create var that shows the user's name, you can put it in a statpanel like so. And I forgot how to make icons appear in a statpanel. I'll get back to you.

In response to Gtgoku55
Thanks, I have the name and the icon being output now with
stat("[A.Name]","\icon[A]")
but I still have no idea how I would make them clickable.
In response to Anthropophagite
In order for it to be clickable, it has to be an atom of some sort, not text. If setting the name of the card to its Name instead won't work, you'll need to create a new obj that has its Name that will forward any click events to the card, and just display that instead.

obj/click_forwarder
// The object that we will call Click() on:
var/atom/listener
New(var/atom/O)
..()
listener = O
Click(location, control, params)
if(listener)
listener.Click(location, control, params)

obj/card
var/obj/click_forwarder/statpanel_face
New()
..()
statpanel_face = new(src)

// You'd have to do this whenever you change Name, actually. It's probably not useful right here:
statpanel_face.name = src.Name

mob/Stat()
for(var/obj/card/A)
stat(A.statpanel_face)


Note: due to the joys of the New() function, the click_forwarder object will have its location set to the card upon creation, because any atom provided as the first argument to new() is assumed to be the location to create it at, with no way of overriding this behavior. It shouldn't really affect anything, though.