ID:1472636
 
So I'm trying to do-away with the basic looking alert proc. I have a pane set on the interface thats invisible, and when the player "talks" to an NPC or if they want to confirm yes or no to buying an item I use winshow() to make the pane appear.

My question is; how do i make a universal system that I can use for any alert/input using this single interface pane?

The pane itself is set up with an Exit button, a label for information, and three buttons(Accept, Decline, and Other. naturally).

I basically want to replace all alerts/inputs with this single pane. I understand the interface side of it, but I'm not sure how to actually change the button commands while in the game.

I'll try to explain better..

A player can talk to a Shopkeeper, and if they want to buy an item I want the pane to pop up and say "Are you sure?" with the buttons labeled "Yes" or "No", and clicking the buttons would do as such.

I want to use the same window when talking to a quest giver, where the alert(pane) pops up to say "Would you like to accept this quest?", and the buttons would be "What do I get?", "Yes", and "No". Where the first option would spark further conversation between you and the NPC, and the interface window would change accordingly.

I want to use the same interface window for both of these. Is this possible? Would I have to make Accept(), Decline(), and Other() verbs and make everything run through those three verbs? Or is there an actual way to replace the alert() with the interface pane? I've seen it done using browsers, but I'd like to use interfaces to keep with the consistency of a project I'm working on.

Of course it is possible. You just need to run a check inside the verb the buttons call to see what/who they are talking to and determine the appropriate action.

You can use winset() to change a button's command parameter at runtime.
I have done something similar, and recently updated it to use the Dynamic Interfaces library so you don't have to create a new pane for your alert box. Here is a small demo:

https://dl.dropboxusercontent.com/u/3010721/jazz/other/ DIL%20-%20Dynamic%20Interface%20Library_src.zip

and link to the original library, the one I include has some small modifications:
http://www.byond.com/developer/KingCold999/ DynamicInterfaceLibrary
A simple approach to this:

proc
interface_alert(client/client,msg,title)
if(istype(responder,/mob))
var/mob/m = client
client = m.client
if(!client)
return null
var/pos = 4
var/btns = ""
while(pos<=args.len)
btns += "alertwin.responsebtn[pos-3].text=\"[args[pos]]\";alertwin.responsebtn[pos-3].command=\"alertresponse [args[pos]]\";"
winset(client,"alertwin.title=\"[title]\";alertwin.label1.text=\"[msg]\";alertwin.visibility=true;[btns]")
while(!client.pending_alert)
sleep(1)
. = client.pending_alert
client.pending_alert = null

client
var/tmp
pending_alert = null
verb
alertresponse(msg as text)
set hidden = 1
pending_alert = msg


This sets up a function more or less identical to alert, you just need to set up your own window to use it.