/** * Copyright (c)2000-2002 Sony Online Entertainment Inc. * All Rights Reserved * * Title: test_sui.script * Description: test script to view test SUI pages * @author $Author:$ * @version $Revision:$ */ /***** INCLUDES ********************************************************/ include library.sui; include library.utils; /***** CONSTANTS *******************************************************/ /***** TRIGGERS ********************************************************/ trigger OnAttach() { debugSpeakMsg(self, "test_sui: attached!"); debugServerConsoleMsg(self, "test_sui: attached!"); return SCRIPT_CONTINUE; } trigger OnDetach() { debugSpeakMsg(self, "test_sui: detached!"); debugServerConsoleMsg(self, "test_sui: detached!"); return SCRIPT_CONTINUE; } trigger OnSpeaking(string text) { if ( text.equals("msgbox") ) { debugSpeakMsg(self, "about to load msgbox"); //sui.msgbox(self, "old message box", "handleMsgBox"); sui.msgbox(self, new string_id("ui","ok")); } else if ( text.equals("complex msgbox") ) { debugSpeakMsg(self, "about to load msgbox"); sui.msgbox(self, self, "test test test", sui.YES_NO_CANCEL, "handleMsgBox", sui.MSG_NORMAL, "handleMsgBox"); } else if ( text.equals("inputbox") ) { debugSpeakMsg(self, "about to load normal styled inputbox"); sui.inputbox(self, "test test test", "handleInputBox"); } else if ( text.equals("combobox") ) { debugSpeakMsg(self, "about to load combo styled inputbox"); string[] d = new string[5]; for ( int i = 0; i < d.length; i++ ) { d[i] = "test_" + i; } sui.combobox(self, "test test test", d, "handleInputBox"); } else if ( text.equals("listbox") ) { debugSpeakMsg(self, "about to load listbox"); resizeable string[] d = new string[0]; for ( int i = 0; i < sui.MAX_ARRAY_SIZE * 2; i++ ) { d = utils.addElement(d, "test_" + i); //debugServerConsoleMsg(self, "test_sui - listbox: adding item = " + d[i]); } sui.listbox(self, "test test test", d, "handleListBox"); } else if ( text.equals("bank") ) { debugSpeakMsg(self, "loading transfer sui"); int cash = getCashBalance(self); int bank = getBankBalance(self); sui.transfer(self, self, "BANK PROMPT", "BANK TITLE", "Cash", cash, "Bank", bank, "handleBankTest"); } else if ( text.equals("test forceClose") ) { int time = 5; sendSystemMessageTestingOnly(self, "Loading SUI to test force close..."); int box = sui.msgbox(self, "force close test... closing box in " + time + " seconds"); dictionary d = new dictionary(); d.put("sui", box); messageTo(self, "testForceClose", d, time, false); } else if ( text.equals("nuke sui") ) { removeObjVar(self, "sui"); } return SCRIPT_CONTINUE; } /***** FUNCTIONS *******************************************************/ void outputPageCallbackDictionary(obj_id self, dictionary params) { obj_id player = params.getObjId("player"); int pId = params.getInt("pageId"); debugSpeakMsg(self, "outputPageCallbackDictionary: player = " + player); debugSpeakMsg(self, "outputPageCallbackDictionary: pageId = " + pId); debugSpeakMsg(self, "outputPageCallbackDictionary: buttonPressed = " + sui.getButtonPressed(params)); debugSpeakMsg(self, "outputPageCallbackDictionary: intButtonPressed = " + sui.getIntButtonPressed(params)); string[] props = params.getStringArray("propertyStrings"); //debugServerConsoleMsg(player, "outputPageCallbackDictionary: malformed dictionary test..."); debugSpeakMsg(self, "outputPageCallbackDictionary: " + params.toString()); if ( props == null ) { debugSpeakMsg(self, "outputPageCallbackDictionary: props = null"); } else { if ( props.length == 0 ) { debugServerConsoleMsg(player, "outputPageCallbackDictionary: no property strings!"); } else { for ( int i = 0; i < props.length; i++ ) { debugSpeakMsg(self, "outputPageCallbackDictionary: prop " + i + " = " + props[i]); } } } /* ORIGINAL TEST CODE - REMOVED FOR ALTERNATE DEBUG obj_id player = params.getObjId("player"); int pageId = -5; pageId = params.getInt("pageId"); debugServerConsoleMsg(player, "pageId = " + Integer.toString(pageId)); String[] props = params.getStringArray("propertyStrings"); for (int i = 0; i < props.length; ++i) { debugServerConsoleMsg(player, props[i]); } */ } /***** HANDLERS *******************************************************/ messageHandler handleMsgBox() { debugServerConsoleMsg(self, "callback handleMsgBox: triggered!"); outputPageCallbackDictionary(self, params); return SCRIPT_CONTINUE; } messageHandler handleInputBox() { debugServerConsoleMsg(self, "callback handleInputBox: triggered!"); outputPageCallbackDictionary(self,params); return SCRIPT_CONTINUE; } messageHandler handleListBox() { debugServerConsoleMsg(self, "callback handleListBox: triggered!"); outputPageCallbackDictionary(self,params); debugSpeakMsg(self, sui.LISTBOX_SELECTEDROW + " = " + utils.stringToInt(params.getString(sui.LISTBOX_SELECTEDROW))); return SCRIPT_CONTINUE; } messageHandler handleBankTest() { debugSpeakMsg(self, "callback handleBankTest: triggered!"); outputPageCallbackDictionary(self,params); debugSpeakMsg(self, "InputTo = " + sui.getTransferInputTo(params)); debugSpeakMsg(self, "InputFrom = " + sui.getTransferInputFrom(params)); return SCRIPT_CONTINUE; } messageHandler testForceClose() { if ( params == null || params.isEmpty() ) { return SCRIPT_CONTINUE; } int box = params.getInt("sui"); sendSystemMessageTestingOnly(self,"Attempting to force close sui #" + box); forceCloseSUIPage(box); return SCRIPT_CONTINUE; }