mirror of
https://bitbucket.org/seefoe/dsrc.git
synced 2026-07-31 01:15:55 -04:00
2725 lines
80 KiB
Plaintext
2725 lines
80 KiB
Plaintext
/**
|
|
* Title: sui.scriptlib
|
|
* Description: library for generic server UI
|
|
*/
|
|
|
|
/***** INCLUDES ********************************************************/
|
|
|
|
include library.colors_hex;
|
|
|
|
/***** CONSTANTS *******************************************************/
|
|
|
|
const int MAX_INPUT_LENGTH = 127;
|
|
|
|
//default values
|
|
const string DEFAULT_TITLE = "@base_player:swg";
|
|
|
|
const string OWNER = "owner";
|
|
const string THIS = "this";
|
|
const string ASSOCIATE = "associate";
|
|
const string RANGE = "range";
|
|
|
|
const string TITLE = "title";
|
|
|
|
const string BUTTONS = "buttons";
|
|
|
|
const string HANDLER = "handler";
|
|
|
|
const string HANDLER_SUI = "handleSUI";
|
|
|
|
const string CTRL_TITLE = "bg.caption.lblTitle";
|
|
|
|
const string BTN_OK = "btnOk";
|
|
const string BTN_REVERT = "btnRevert";
|
|
const string BTN_CANCEL = "btnCancel";
|
|
|
|
//PROPERTY CONSTANTS
|
|
const string PROP_NAME = "Name";
|
|
|
|
const string PROP_TEXT = "Text";
|
|
const string PROP_LOCALTEXT = "LocalText";
|
|
|
|
const string PROP_SELECTEDROW = "SelectedRow";
|
|
const string PROP_SELECTEDTEXT = "SelectedText";
|
|
const string PROP_SELECTEDINDEX = "SelectedIndex";
|
|
const string PROP_LOGICALINDEX = "LogicalRowIndex";
|
|
|
|
const string PROP_TARGETID = "TargetNetworkId";
|
|
const string PROP_TARGETVAR = "TargetVariable";
|
|
const string PROP_TARGETRANGEMIN = "TargetRangeMin";
|
|
const string PROP_TARGETRANGEMAX = "TargetRangeMax";
|
|
|
|
const string PROP_BUTTONPRESSED = "buttonPressed";
|
|
|
|
const string PROP_VISIBLE = "visible";
|
|
|
|
const string PROP_AUTOSAVE = "autosave";
|
|
const string PROP_LOCATION = "Location";
|
|
const string PROP_SIZE = "Size";
|
|
const string PROP_SOUND = "sound";
|
|
|
|
const string PROP_TYPE = "Type";
|
|
const string PROP_LABEL = "Label";
|
|
const string PROP_VALUE = "Value";
|
|
|
|
//COLORPICKER CONSTANTS
|
|
const string SUI_COLORPICKER = "Script.ColorPicker";
|
|
|
|
const string COLORPICKER_PAGE_CAPTION = "bg.caption";
|
|
|
|
const string COLORPICKER_COLORPICKER = "ColorPicker";
|
|
const string COLORPICKER_TITLE = COLORPICKER_PAGE_CAPTION + ".lblTitle";
|
|
|
|
//MESSAGEBOX CONSTANTS
|
|
const string SUI_MSGBOX = "Script.messageBox";
|
|
|
|
const string MSGBOX_PAGE_PROMPT = "Prompt";
|
|
const string MSGBOX_PAGE_CAPTION = "bg.caption";
|
|
|
|
const string MSGBOX_BTN_REVERT = "btnRevert";
|
|
const string MSGBOX_BTN_CANCEL = "btnCancel";
|
|
const string MSGBOX_BTN_OK = "btnOk";
|
|
const string MSGBOX_PROMPT = MSGBOX_PAGE_PROMPT + ".lblPrompt";
|
|
const string MSGBOX_TITLE = MSGBOX_PAGE_CAPTION + ".lblTitle";
|
|
|
|
//COUNTDOWNTIMERSUI CONSTANTS
|
|
const string SUI_COUNTDOWNTIMER = "Script.CountdownTimerBar";
|
|
const string COUNTDOWNTIMER_PROMPT = "comp.text";
|
|
const string COUNTDOWNTIMER_TIMEVALUE = "countdownTimerTimeValue";
|
|
|
|
const string COUNTDOWNTIMER_VAR = "countdown_sui";
|
|
const string COUNTDOWNTIMER_OWNER_VAR = COUNTDOWNTIMER_VAR + ".owner";
|
|
const string COUNTDOWNTIMER_CALLBACK_VAR = COUNTDOWNTIMER_VAR + ".callback";
|
|
const string COUNTDOWNTIMER_FLAGS_VAR = COUNTDOWNTIMER_VAR + ".flags";
|
|
const string COUNTDOWNTIMER_SUI_VAR = COUNTDOWNTIMER_VAR + ".sui_pid";
|
|
|
|
const string COUNTDOWNTIMER_PLAYER_SCRIPT = "player.player_countdown";
|
|
|
|
const int COUNTDOWNTIMER_MAXTIMEVALUE = 86400; // 1 day
|
|
|
|
const int CD_EVENT_NONE = 0x00000000;
|
|
const int CD_EVENT_COMBAT = 0x00000001;
|
|
const int CD_EVENT_LOCOMOTION = 0x00000002;
|
|
const int CD_EVENT_POSTURE = 0x00000004;
|
|
const int CD_EVENT_INCAPACITATE = 0x00000008;
|
|
const int CD_EVENT_DAMAGED = 0x00000010;
|
|
const int CD_EVENT_STEALTHED = 0x00000020;
|
|
const int CD_EVENT_DAMAGE_IMMUNE = 0x00000040;
|
|
|
|
//INPUTBOX CONSTANTS
|
|
const string SUI_INPUTBOX = "Script.inputBox";
|
|
|
|
const string INPUTBOX_PAGE_PROMPT = "Prompt";
|
|
const string INPUTBOX_PAGE_CAPTION = "bg.caption";
|
|
|
|
const string INPUTBOX_BTN_CANCEL = "btnCancel";
|
|
const string INPUTBOX_BTN_OK = "btnOk";
|
|
const string INPUTBOX_PROMPT = INPUTBOX_PAGE_PROMPT + ".lblPrompt";
|
|
const string INPUTBOX_TITLE = INPUTBOX_PAGE_CAPTION + ".lblTitle";
|
|
const string INPUTBOX_INPUT = "txtInput";
|
|
const string INPUTBOX_COMBO = "cmbInput";
|
|
const string INPUTBOX_DATASOURCE = "dataInput";
|
|
|
|
const string INPUTBOX_INPUT_NAME = INPUTBOX_INPUT + "." + PROP_NAME;
|
|
const string INPUTBOX_INPUT_LOCALTEXT = INPUTBOX_INPUT + "." + PROP_LOCALTEXT;
|
|
|
|
const string INPUTBOX_COMBO_SELECTEDTEXT = INPUTBOX_INPUT + "." + PROP_SELECTEDTEXT;
|
|
const string INPUTBOX_COMBO_SELECTEDINDEX = INPUTBOX_INPUT + "." + PROP_SELECTEDINDEX;
|
|
|
|
//LISTBOX CONSTANTS
|
|
const string SUI_LISTBOX = "Script.listBox";
|
|
|
|
const string LISTBOX_PAGE_PROMPT = "Prompt";
|
|
const string LISTBOX_PAGE_CAPTION = "bg.caption";
|
|
const string LISTBOX_PAGE_LIST = "List";
|
|
|
|
const string LISTBOX_BTN_REVERT = "btnRevert";
|
|
const string LISTBOX_BTN_CANCEL = "btnCancel";
|
|
const string LISTBOX_BTN_OK = "btnOk";
|
|
const string LISTBOX_BTN_OTHER = "btnOther";
|
|
const string LISTBOX_TITLE = LISTBOX_PAGE_CAPTION + ".lblTitle";
|
|
const string LISTBOX_PROMPT = LISTBOX_PAGE_PROMPT + ".lblPrompt";
|
|
const string LISTBOX_LIST = LISTBOX_PAGE_LIST + ".lstList";
|
|
const string LISTBOX_DATASOURCE = LISTBOX_PAGE_LIST + ".dataList";
|
|
const string LISTBOX_SELECTEDROW = LISTBOX_LIST + "." + PROP_SELECTEDROW;
|
|
|
|
const string LISTBOX_PROP_OTHER_PRESSED = "otherPressed";
|
|
|
|
//TRANSFERBOX DEFINES
|
|
const string SUI_TRANSFER = "Script.transfer";
|
|
|
|
const string TRANSFER_PAGE_PROMPT = "Prompt";
|
|
const string TRANSFER_PAGE_CAPTION = "bg.caption";
|
|
const string TRANSFER_PAGE_TRANSACTION = "transaction";
|
|
|
|
const string TRANSFER_BTN_OK = "btnOk";
|
|
const string TRANSFER_BTN_CANCEL = "btnCancel";
|
|
const string TRANSFER_BTN_REVERT = "btnRevert";
|
|
|
|
const string TRANSFER_TITLE = TRANSFER_PAGE_CAPTION + ".lblTitle";
|
|
const string TRANSFER_PROMPT = TRANSFER_PAGE_PROMPT + ".lblPrompt";
|
|
const string TRANSFER_INPUT_FROM = TRANSFER_PAGE_TRANSACTION + ".txtInputFrom";
|
|
const string TRANSFER_INPUT_TO = TRANSFER_PAGE_TRANSACTION + ".txtInputTo";
|
|
const string TRANSFER_FROM = TRANSFER_PAGE_TRANSACTION + ".lblStartingFrom";
|
|
const string TRANSFER_TO = TRANSFER_PAGE_TRANSACTION + ".lblStartingTo";
|
|
const string TRANSFER_FROM_TEXT = TRANSFER_PAGE_TRANSACTION + ".lblFrom";
|
|
const string TRANSFER_TO_TEXT = TRANSFER_PAGE_TRANSACTION + ".lblTo";
|
|
const string TRANSFER_SLIDER = TRANSFER_PAGE_TRANSACTION + ".slider";
|
|
|
|
const string TRANSFER_INPUT_FROM_TEXT = TRANSFER_INPUT_FROM + "." + PROP_TEXT;
|
|
const string TRANSFER_INPUT_TO_TEXT = TRANSFER_INPUT_TO + "." + PROP_TEXT;
|
|
|
|
//const string PROP_CONVERSION_RATIO = "ConversionRatio";
|
|
const string PROP_CONVERSION_RATIO_FROM = "ConversionRatioFrom";
|
|
const string PROP_CONVERSION_RATIO_TO = "ConversionRatioTo";
|
|
|
|
//BANK (TRANSFERBOX OVERLOAD) DEFINES
|
|
const string MSG_BANK_TITLE = "@base_player:bank_title";
|
|
const string MSG_BANK_PROMPT = "@base_player:bank_prompt";
|
|
|
|
const string HANDLER_DEPOSIT_WITHDRAW = "handleDepositWithdraw";
|
|
|
|
//max values
|
|
const int MAX_ARRAY_SIZE = 50;
|
|
|
|
//button configurations
|
|
const int OK_ONLY = 0;
|
|
const int OK_CANCEL = 1;
|
|
const int YES_NO = 2;
|
|
const int YES_NO_CANCEL = 3;
|
|
const int YES_NO_MAYBE = 4;
|
|
const int YES_NO_ABSTAIN = 5;
|
|
const int RETRY_CANCEL = 6;
|
|
const int ABORT_RETRY_CANCEL = 7;
|
|
const int OK_REFRESH = 8;
|
|
const int OK_CANCEL_REFRESH = 9;
|
|
const int REFRESH_CANCEL = 10;
|
|
const int REFRESH_ONLY = 11;
|
|
const int OK_CANCEL_ALL = 12;
|
|
const int MOVEUP_MOVEDOWN_DONE = 13;
|
|
const int BET_MAX_BET_ONE_QUIT = 14;
|
|
const int BET_MAX_BET_ONE_SPIN = 15;
|
|
const int REFRESH_LEAVE_GAME = 16;
|
|
const int REMOVE_CANCEL = 17;
|
|
|
|
//messageBox styles
|
|
const int MSG_NORMAL = 0;
|
|
const int MSG_CRITICAL = 1;
|
|
const int MSG_EXCLAMATION = 2;
|
|
const int MSG_QUESTION = 3;
|
|
const int MSG_INFORMATION = 4;
|
|
|
|
//inputBox styles
|
|
const int INPUT_NORMAL = 0;
|
|
const int INPUT_COMBO = 1;
|
|
|
|
//BUTTON PRESSED DEFINES
|
|
const string OK = "Ok";
|
|
const string CANCEL = "Cancel";
|
|
const string REVERT = "Revert";
|
|
|
|
const int BP_OK = 0;
|
|
const int BP_CANCEL = 1;
|
|
const int BP_REVERT = 2;
|
|
|
|
//GENERAL STRING_ID DEFINES
|
|
const string_id PROSE_OVER_MAX_ENTRIES = new string_id("error_message","prose_over_max_entries");
|
|
const string_id OUT_OF_RANGE = new string_id("error_message","out_of_range");
|
|
|
|
//INPUT TEXT FILTERING
|
|
const string SCRIPT_FILTER_OWNER = "sui.filter.owner";
|
|
|
|
const string VAR_FILTER_BASE = "sui.filter";
|
|
const string VAR_FILTER_COUNT = VAR_FILTER_BASE + ".count";
|
|
|
|
const string HANDLER_FILTER_INPUT = "handleFilterInput";
|
|
|
|
// Table defines
|
|
const string SUI_TABLE = "Script.tablePage";
|
|
const string TABLE_CAPTION = "bg.caption";
|
|
const string TABLE_TITLE = TABLE_CAPTION + ".lblTitle";
|
|
const string TABLE_PAGE = "comp.TablePage";
|
|
const string TABLE_PROMPT = "comp.Prompt";
|
|
const string TABLE_PROMPT_TEXT = TABLE_PROMPT + ".lblPrompt";
|
|
const string TABLE_DATASOURCE = TABLE_PAGE + ".dataTable";
|
|
const string TABLE_TABLE = TABLE_PAGE + ".table";
|
|
const string TABLE_BTN_CANCEL = "btnCancel";
|
|
const string TABLE_BTN_OK = "btnOk";
|
|
const string TABLE_BTN_OTHER = "btnOther";
|
|
const string TABLE_BTN_EXPORT = "btnExport";
|
|
const string TABLE_PROP_OTHER_PRESSED = "otherPressed";
|
|
const string TABLE_PROP_EXPORT_PRESSED = "exportPressed";
|
|
|
|
/***** CURRENT FUNCTIONS *******************************************************/
|
|
int msgbox(obj_id target, string_id sid_prompt, dictionary params)
|
|
{
|
|
if ( !isIdValid(target) )
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
if ( sid_prompt == null )
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
int pid = createSUIPage(SUI_MSGBOX, target, target, HANDLER_SUI);
|
|
|
|
string prompt = utils.packStringId(sid_prompt);
|
|
|
|
setSUIProperty(pid, MSGBOX_PROMPT, PROP_TEXT, prompt);
|
|
setSUIProperty(pid, MSGBOX_TITLE, PROP_TEXT, DEFAULT_TITLE);
|
|
|
|
setPageProperties(pid, params);
|
|
|
|
trackSUI(target, pid, params);
|
|
|
|
showSUIPage(pid);
|
|
|
|
return pid;
|
|
}
|
|
|
|
int msgbox(obj_id target, string_id sid_prompt)
|
|
{
|
|
return msgbox(target, sid_prompt, null);
|
|
}
|
|
|
|
int countdownTimerSUI(obj_id owner, obj_id target, string type, string_id sid_prompt, int current_time, int total_time, string suiHandler)
|
|
{
|
|
if ( !isIdValid(owner) || !isIdValid(target) )
|
|
return -1;
|
|
|
|
if ( sid_prompt == null )
|
|
sid_prompt = new string_id("sui", "countdowntimer_default_prompt");
|
|
|
|
string prompt = utils.packStringId(sid_prompt);
|
|
if ( prompt == null || prompt.equals("") )
|
|
prompt = "@sui:countdowntimer_default_prompt";
|
|
|
|
if ( type == null || type.equals("") )
|
|
return -1;
|
|
|
|
if ( current_time < 0 )
|
|
return -1;
|
|
|
|
if ( total_time <= 0 )
|
|
return -1;
|
|
|
|
// limit timer to 1 day
|
|
if ( total_time > COUNTDOWNTIMER_MAXTIMEVALUE )
|
|
return -1;
|
|
|
|
if ( current_time >= total_time )
|
|
return -1;
|
|
|
|
if ( suiHandler == null || suiHandler.equals("") )
|
|
suiHandler = "noHandler";
|
|
|
|
int pid = createSUIPage(SUI_COUNTDOWNTIMER, owner, target, suiHandler);
|
|
|
|
if ( pid == -1 )
|
|
return -1;
|
|
|
|
if ( !setSUIProperty(pid, COUNTDOWNTIMER_PROMPT, PROP_TEXT, prompt) )
|
|
return -1;
|
|
|
|
if ( !setSUIProperty(pid, CTRL_TITLE, PROP_TEXT, type) )
|
|
return -1;
|
|
|
|
if ( !setSUIProperty(pid, THIS, COUNTDOWNTIMER_TIMEVALUE, current_time + "," + total_time) )
|
|
return -1;
|
|
|
|
if ( !showSUIPage(pid) )
|
|
return -1;
|
|
|
|
if ( owner != target )
|
|
setAssociateRange(target, pid, owner);
|
|
|
|
return pid;
|
|
}
|
|
|
|
/*
|
|
* The smart countdown timer SUI handles several functions of a countdown timer that may be needed by systems that are using the timer. It will send automatically
|
|
* handle the sending of successful or event cancellation messages (based on the event flags passed to the function).
|
|
*
|
|
* obj_id owner The item being manipulated (terminal being hacked, flower being picked, etc). This object will receive the suiHandler message.
|
|
* obj_id target The player that will be shown the SUI.
|
|
* string type A string used to group countdown timer SUI together, so that
|
|
* countdown timer SUI of the same type will get displayed at the
|
|
* at the last location/size that the player moved them to; for
|
|
* example, all quest related countdown timer SUI can have a type
|
|
* of "quest_countdown_timer" and all GCW base related countdown
|
|
* timer SUI can have a type of "GCW_base"
|
|
* (or "GCW_base_next_clone_time" and "GCW_base_time_to_complete_slice")
|
|
* string_id sid_prompt Text displayed on the timer window. ("Picking flowers...")
|
|
* int current_time The amount of time at which to start the countdown (if current_time is 12, and total_time is 30, countdown will start at 18)
|
|
* int total_time The total time being counted down
|
|
* string suiHandler The messageHandler, written by the designer, to catch and handle the results of the countdown timer
|
|
* float range If 'target' exceeds this distance from 'owner', the countdown timer window will close with a cancellation event
|
|
* int flags The player event flags to watch for which will cancel the countdown (See CD_EVENT constants above).
|
|
*
|
|
* To set multiple flags to look for, you can do something like the following:
|
|
*
|
|
* int flags = 0;
|
|
* flags |= sui.CD_EVENT_COMBAT;
|
|
* flags |= sui.CD_EVENT_LOCOMOTION;
|
|
*
|
|
* Pass this into the function to look for both combat and locomotion flags.
|
|
* The messages sent to the suiHandler will contain an ID in the params. This ID should be compared to one set on the player as a script var. If the IDs do not
|
|
* match, or if the player does not have a script var, then it can be assumed that the countdown that spawned the message was aborted or canceled, and can be ignored.
|
|
* The SUI window will not close itself when it has finished counting down, so it will be up to the message handler to close the window on success.
|
|
*
|
|
* See just below this function definition for a small, bare-bones example of what a handler for the smart countdown sui might look like.
|
|
*/
|
|
int smartCountdownTimerSUI(obj_id owner, obj_id target, string type, string_id sid_prompt, int current_time, int total_time, string suiHandler, float range, int flags)
|
|
{
|
|
if(!isIdValid(owner) || !isIdValid(target))
|
|
return -1;
|
|
|
|
if(sid_prompt == null)
|
|
sid_prompt = new string_id("sui", "countdowntimer_default_prompt");
|
|
|
|
string prompt = utils.packStringId(sid_prompt);
|
|
if(prompt == null || prompt.equals(""))
|
|
prompt = "@sui:countdowntimer_default_prompt";
|
|
|
|
if ( type == null || type.equals("") )
|
|
return -1;
|
|
|
|
if(current_time < 0)
|
|
return -1;
|
|
|
|
if(total_time <= 0)
|
|
return -1;
|
|
|
|
// limit timer to 1 day
|
|
if(total_time > COUNTDOWNTIMER_MAXTIMEVALUE)
|
|
return -1;
|
|
|
|
if(current_time >= total_time)
|
|
return -1;
|
|
|
|
if(suiHandler == null || suiHandler.equals(""))
|
|
suiHandler = "noHandler";
|
|
|
|
if(hasScript(target, COUNTDOWNTIMER_PLAYER_SCRIPT))
|
|
{
|
|
sendSystemMessage(target, new string_id("sui", "countdowntimer_too_busy"));
|
|
return -1;
|
|
}
|
|
|
|
int pid = createSUIPage(SUI_COUNTDOWNTIMER, owner, target, suiHandler);
|
|
|
|
if(pid == -1)
|
|
return -1;
|
|
|
|
if(!setSUIProperty(pid, COUNTDOWNTIMER_PROMPT, PROP_TEXT, prompt))
|
|
return -1;
|
|
|
|
if(!setSUIProperty(pid, CTRL_TITLE, PROP_TEXT, type))
|
|
return -1;
|
|
|
|
if(!setSUIProperty(pid, THIS, COUNTDOWNTIMER_TIMEVALUE, current_time + "," + total_time))
|
|
return -1;
|
|
|
|
if(!showSUIPage(pid))
|
|
return -1;
|
|
|
|
if(owner != target)
|
|
{
|
|
setSUIAssociatedObject(pid, owner);
|
|
setSUIMaxRangeToObject(pid, range);
|
|
}
|
|
else
|
|
{
|
|
setSUIAssociatedLocation(pid,owner);
|
|
setSUIMaxRangeToObject(pid, range);
|
|
}
|
|
|
|
flushSUIPage(pid);
|
|
|
|
if(pid > -1)
|
|
{
|
|
setObjVar(target, COUNTDOWNTIMER_SUI_VAR, pid);
|
|
|
|
utils.setScriptVar(target, COUNTDOWNTIMER_OWNER_VAR, owner);
|
|
utils.setScriptVar(target, COUNTDOWNTIMER_CALLBACK_VAR, suiHandler);
|
|
utils.setScriptVar(target, COUNTDOWNTIMER_FLAGS_VAR, flags);
|
|
|
|
attachScript(target, COUNTDOWNTIMER_PLAYER_SCRIPT);
|
|
|
|
dictionary d = new dictionary();
|
|
d.put("buttonPressed", OK);
|
|
d.put("player", target);
|
|
d.put("id", pid);
|
|
d.put("event", CD_EVENT_NONE);
|
|
|
|
int timeRemaining = total_time - current_time;
|
|
|
|
messageTo(owner, suiHandler, d, timeRemaining, false);
|
|
messageTo(target, "handleCountdownTimerCleanup", d, (timeRemaining + 2), false);
|
|
}
|
|
|
|
return pid;
|
|
}
|
|
|
|
/*
|
|
* EXAMPLE SMART COUNTDOWN SUI HANDLER:
|
|
*
|
|
|
|
messageHandler smartCountdownHandlerExample()
|
|
{
|
|
int pid = params.getInt("id");
|
|
obj_id player = params.getObjId("player");
|
|
|
|
if(!isIdValid(player))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int bp = sui.getIntButtonPressed(params);
|
|
|
|
// Cancel button is sent when player manually closes the countdown window,
|
|
// or when he/she moves out of range.
|
|
if(bp == sui.BP_CANCEL)
|
|
{
|
|
// Detaching the script cleans up all the data for us.
|
|
// Not necessary, but probably good practice.
|
|
detachScript(player, sui.COUNTDOWNTIMER_PLAYER_SCRIPT);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
// Revert button is sent when the timer is aborted due to one of the
|
|
// specified events.
|
|
else if(bp == sui.BP_REVERT)
|
|
{
|
|
// Gets the reason why the timer was aborted
|
|
int event = params.getInt("event");
|
|
|
|
// You can handle the situation differently depending on the reason
|
|
if(event == sui.CD_EVENT_COMBAT)
|
|
{
|
|
}
|
|
else if(event == sui.CD_EVENT_LOCOMOTION)
|
|
{
|
|
}
|
|
else if(event == sui.CD_EVENT_INCAPACITATE)
|
|
{
|
|
}
|
|
|
|
// The player abortion script handles the cleanup in this case, so we don't have to.
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// The OK button is sent on a successful message, but if we've gotten this
|
|
// far, then we know the timer wasn't aborted or cancelled.
|
|
|
|
// Get the ID off of the player. If it doesn't exist then this is an invalid message.
|
|
if(!hasObjVar(player, sui.COUNTDOWNTIMER_SUI_VAR))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int test_pid = getIntObjVar(player, sui.COUNTDOWNTIMER_SUI_VAR);
|
|
|
|
// If the IDs don't match, then this is an invalid message.
|
|
if(pid != test_pid)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
// Don't forget to close the window!
|
|
forceCloseSUIPage(pid);
|
|
|
|
// Cleanup!
|
|
detachScript(player, sui.COUNTDOWNTIMER_PLAYER_SCRIPT);
|
|
|
|
// DO SUCCESSFUL STUFF HERE!
|
|
}
|
|
|
|
*
|
|
* And now a winner is yuo!
|
|
*
|
|
*/
|
|
|
|
boolean updateCountdownTimerSUI(int pid, string_id sid_prompt, int current_time, int total_time)
|
|
{
|
|
if ( sid_prompt == null )
|
|
return false;
|
|
|
|
string prompt = utils.packStringId(sid_prompt);
|
|
if ( prompt == null || prompt.equals("") )
|
|
return false;
|
|
|
|
if ( current_time < 0 )
|
|
return false;
|
|
|
|
if ( total_time <= 0 )
|
|
return false;
|
|
|
|
// limit timer to 1 day
|
|
if ( total_time > COUNTDOWNTIMER_MAXTIMEVALUE )
|
|
return false;
|
|
|
|
if ( current_time >= total_time )
|
|
return false;
|
|
|
|
if ( !setSUIProperty(pid, COUNTDOWNTIMER_PROMPT, PROP_TEXT, prompt) )
|
|
return false;
|
|
|
|
if ( !setSUIProperty(pid, THIS, COUNTDOWNTIMER_TIMEVALUE, current_time + "," + total_time) )
|
|
return false;
|
|
|
|
if ( !flushSUIPage(pid) )
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
boolean setPageProperties(int pid, dictionary params)
|
|
{
|
|
if ( (params == null) || (params.isEmpty()) )
|
|
{
|
|
setButtonStyle(pid, OK_ONLY);
|
|
return true;
|
|
}
|
|
|
|
setPageTitle(pid, params);
|
|
|
|
setPageButtons(pid, params);
|
|
|
|
java.util.Enumeration keys = params.keys();
|
|
while ( keys.hasMoreElements() )
|
|
{
|
|
string key = (string)(keys.nextElement());
|
|
if ( key.indexOf('-') > -1 )
|
|
{
|
|
string[] s = split(key, '-');
|
|
if ( (s != null) && (s.length == 2) )
|
|
{
|
|
Object val = params.get(key);
|
|
string sVal = null;
|
|
|
|
if ( val != null )
|
|
{
|
|
if ( val instanceof string_id )
|
|
{
|
|
sVal = utils.packStringId((string_id)(val));
|
|
}
|
|
else if ( val instanceof string )
|
|
{
|
|
sVal = (string)(val);
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
|
|
if ( sVal != null )
|
|
{
|
|
setSUIProperty(pid, s[0], s[1], sVal);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
boolean setPageTitle(int pid, dictionary params)
|
|
{
|
|
if ( (params == null) || (params.isEmpty()) )
|
|
{
|
|
return false;
|
|
}
|
|
|
|
Object tmp = params.get(TITLE);
|
|
string title = null;
|
|
if ( tmp != null )
|
|
{
|
|
if ( tmp instanceof string_id )
|
|
{
|
|
title = utils.packStringId((string_id)(tmp));
|
|
}
|
|
else if ( tmp instanceof string )
|
|
{
|
|
title = (string)(tmp);
|
|
}
|
|
|
|
if ( title != null )
|
|
{
|
|
return setSUIProperty(pid, CTRL_TITLE, PROP_TEXT, DEFAULT_TITLE);
|
|
}
|
|
|
|
params.remove(TITLE);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
boolean setPageButtons(int pid, dictionary params)
|
|
{
|
|
if ( (params == null) || (params.isEmpty()) )
|
|
{
|
|
return false;
|
|
}
|
|
|
|
int btns = params.getInt(BUTTONS);
|
|
setButtonStyle(pid, btns);
|
|
return true;
|
|
}
|
|
|
|
void setButtonStyle(int pid, int btns)
|
|
{
|
|
switch ( btns )
|
|
{
|
|
case OK_ONLY:
|
|
hideBtnCancel(pid);
|
|
hideBtnRevert(pid);
|
|
break;
|
|
|
|
case OK_CANCEL:
|
|
hideBtnRevert(pid);
|
|
break;
|
|
|
|
case YES_NO:
|
|
hideBtnRevert(pid);
|
|
setSUIProperty(pid, BTN_CANCEL, PROP_TEXT,"@no");
|
|
setSUIProperty(pid, BTN_OK, PROP_TEXT,"@yes");
|
|
break;
|
|
|
|
case YES_NO_CANCEL:
|
|
setSUIProperty(pid, BTN_REVERT, PROP_TEXT,"@no");
|
|
setSUIProperty(pid, BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, BTN_OK, PROP_TEXT,"@yes");
|
|
break;
|
|
|
|
case YES_NO_MAYBE:
|
|
setSUIProperty(pid, BTN_REVERT, PROP_TEXT,"@maybe");
|
|
setSUIProperty(pid, BTN_CANCEL, PROP_TEXT,"@no");
|
|
setSUIProperty(pid, BTN_OK, PROP_TEXT,"@yes");
|
|
break;
|
|
|
|
case YES_NO_ABSTAIN:
|
|
setSUIProperty(pid, BTN_REVERT, PROP_TEXT,"@abstain");
|
|
setSUIProperty(pid, BTN_CANCEL, PROP_TEXT,"@no");
|
|
setSUIProperty(pid, BTN_OK, PROP_TEXT,"@yes");
|
|
break;
|
|
|
|
case RETRY_CANCEL:
|
|
hideBtnRevert(pid);
|
|
setSUIProperty(pid, BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, BTN_OK, PROP_TEXT,"@retry");
|
|
break;
|
|
|
|
case ABORT_RETRY_CANCEL:
|
|
setSUIProperty(pid, BTN_REVERT, PROP_TEXT,"@retry");
|
|
setSUIProperty(pid, BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, BTN_OK, PROP_TEXT,"@abort");
|
|
break;
|
|
|
|
case OK_REFRESH:
|
|
hideBtnRevert(pid);
|
|
setSUIProperty(pid, BTN_CANCEL, PROP_TEXT,"@refresh");
|
|
break;
|
|
|
|
case OK_CANCEL_REFRESH:
|
|
setSUIProperty(pid, BTN_REVERT, PROP_TEXT,"@refresh");
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void hideBtnCancel(int pid)
|
|
{
|
|
setSUIProperty(pid, BTN_CANCEL, "Enabled","False");
|
|
setSUIProperty(pid, BTN_CANCEL, "Visible","False");
|
|
}
|
|
|
|
void hideBtnRevert(int pid)
|
|
{
|
|
setSUIProperty(pid, BTN_REVERT, "Enabled","False");
|
|
setSUIProperty(pid, BTN_REVERT, "Visible","False");
|
|
}
|
|
|
|
boolean trackSUI(obj_id target, int pid, dictionary params)
|
|
{
|
|
if ( !isIdValid(target) )
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if ( (params == null) || (params.isEmpty()) )
|
|
{
|
|
trackSUI(target, pid, target, "noHandler");
|
|
return false;
|
|
}
|
|
|
|
obj_id owner = params.getObjId(OWNER);
|
|
if ( !isIdValid(owner) )
|
|
{
|
|
owner = target;
|
|
}
|
|
|
|
string handler = params.getString(HANDLER);
|
|
if ( (handler == null) || (handler.equals("")) )
|
|
{
|
|
handler = "noHandler";
|
|
}
|
|
|
|
return trackSUI(target, pid, owner, handler);
|
|
}
|
|
|
|
boolean trackSUI(obj_id target, int pid, obj_id owner, string handler)
|
|
{
|
|
if ( !isIdValid(target) || !isIdValid(owner) || (handler == null) || (handler.equals("")) )
|
|
{
|
|
return false;
|
|
}
|
|
|
|
string path = "sui." + pid;
|
|
utils.setScriptVar(target, path + ".owner", owner);
|
|
utils.setScriptVar(target, path + ".handler", handler);
|
|
|
|
return true;
|
|
}
|
|
|
|
/***** ORIGINAL FUNCTIONS *******************************************************/
|
|
/***** MSGBOX FUNCTIONS *******************************************************/
|
|
//SCRIPT.MESSAGEBOX WIDGET LIST
|
|
//
|
|
//btnLeft = button
|
|
//btnMiddle = button
|
|
//btnRight = button
|
|
//
|
|
//lblPrompt = text box
|
|
//lblTitle = text box
|
|
//
|
|
//imgIcon = image box
|
|
//
|
|
//vScroll = vertical scroll bar
|
|
//
|
|
|
|
|
|
/*****************************************************************
|
|
* @brief displays Script.messageBox page
|
|
*
|
|
* @param string prompt
|
|
* @param int buttons
|
|
* @param string box_title
|
|
* @param int style
|
|
*
|
|
* @return int pid; -1 on error
|
|
*****************************************************************/
|
|
int msgbox(obj_id owner, obj_id target, string prompt, int buttons, string box_title, int style, string suiHandler)
|
|
{
|
|
if ( !isIdValid(owner) || !isIdValid(target) )
|
|
return -1;
|
|
|
|
if ( prompt == null || prompt.equals("") )
|
|
return -1;
|
|
|
|
if ( suiHandler == null || suiHandler.equals("") )
|
|
suiHandler = "noHandler";
|
|
|
|
if ( box_title == null || box_title.equals("") )
|
|
box_title = DEFAULT_TITLE;
|
|
|
|
int pid = createSUIPage(SUI_MSGBOX, owner, target, suiHandler);
|
|
|
|
setSUIProperty(pid, MSGBOX_PROMPT, PROP_TEXT, prompt);
|
|
setSUIProperty(pid, MSGBOX_TITLE, PROP_TEXT, box_title);
|
|
|
|
msgboxButtonSetup(pid, buttons);
|
|
|
|
showSUIPage(pid);
|
|
|
|
if ( owner != target )
|
|
setAssociateRange(target, pid, owner);
|
|
|
|
return pid;
|
|
}
|
|
|
|
|
|
|
|
/***** MSGBOX SUPPORT FUNCTIONS *************************************************/
|
|
|
|
void msgboxButtonSetup(int pid, int buttons)
|
|
{
|
|
switch(buttons)
|
|
{
|
|
case OK_CANCEL:
|
|
msgboxHideBtnLeft(pid);
|
|
setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT,"@ok");
|
|
break;
|
|
case YES_NO:
|
|
msgboxHideBtnLeft(pid);
|
|
setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT,"@no");
|
|
setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT,"@yes");
|
|
break;
|
|
case YES_NO_CANCEL:
|
|
setSUIProperty(pid, MSGBOX_BTN_REVERT, PROP_TEXT,"@no");
|
|
setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT,"@yes");
|
|
break;
|
|
case YES_NO_MAYBE:
|
|
setSUIProperty(pid, MSGBOX_BTN_REVERT, PROP_TEXT,"@maybe");
|
|
setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT,"@no");
|
|
setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT,"@yes");
|
|
break;
|
|
case YES_NO_ABSTAIN:
|
|
setSUIProperty(pid, MSGBOX_BTN_REVERT, PROP_TEXT,"@abstain");
|
|
setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT,"@no");
|
|
setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT,"@yes");
|
|
break;
|
|
case RETRY_CANCEL:
|
|
msgboxHideBtnLeft(pid);
|
|
setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT,"@retry");
|
|
break;
|
|
case ABORT_RETRY_CANCEL:
|
|
setSUIProperty(pid, MSGBOX_BTN_REVERT, PROP_TEXT,"@retry");
|
|
setSUIProperty(pid, MSGBOX_BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT,"@abort");
|
|
break;
|
|
case OK_ONLY: //fallthru to default
|
|
default:
|
|
msgboxHideBtnLeft(pid);
|
|
msgboxHideBtnMiddle(pid);
|
|
setSUIProperty(pid, MSGBOX_BTN_OK, PROP_TEXT,"@ok");
|
|
break;
|
|
}
|
|
}
|
|
|
|
void msgboxHideBtnLeft(int pid)
|
|
{
|
|
setSUIProperty(pid, MSGBOX_BTN_REVERT, "Enabled","False");
|
|
setSUIProperty(pid, MSGBOX_BTN_REVERT, "Visible","False");
|
|
}
|
|
|
|
void msgboxHideBtnMiddle(int pid)
|
|
{
|
|
setSUIProperty(pid, MSGBOX_BTN_CANCEL, "Enabled","False");
|
|
setSUIProperty(pid, MSGBOX_BTN_CANCEL, "Visible","False");
|
|
}
|
|
|
|
|
|
/***** MSGBOX OVERLOAD FUNCTIONS **********************************************/
|
|
|
|
int msgbox(obj_id owner, obj_id target, string prompt, string suiHandler)
|
|
{
|
|
return msgbox(owner, target, prompt, OK_ONLY, DEFAULT_TITLE, MSG_NORMAL, suiHandler);
|
|
}
|
|
|
|
int msgbox(obj_id owner, string prompt, string suiHandler)
|
|
{
|
|
return msgbox(owner, owner, prompt, OK_ONLY, DEFAULT_TITLE, MSG_NORMAL, suiHandler);
|
|
}
|
|
|
|
int msgbox(obj_id owner, obj_id target, string prompt)
|
|
{
|
|
return msgbox(owner, target, prompt, OK_ONLY, DEFAULT_TITLE, MSG_NORMAL, "noHandler");
|
|
}
|
|
|
|
int msgbox(obj_id owner, string prompt)
|
|
{
|
|
return msgbox(owner, owner, prompt, OK_ONLY, DEFAULT_TITLE, MSG_NORMAL, "noHandler");
|
|
}
|
|
|
|
int msgbox(obj_id owner, obj_id target, string prompt, int buttons, string suiHandler)
|
|
{
|
|
return msgbox(owner, target, prompt, buttons, DEFAULT_TITLE, MSG_NORMAL, suiHandler);
|
|
}
|
|
|
|
int msgbox(obj_id owner, obj_id target, string prompt, int buttons, string box_title, string suiHandler)
|
|
{
|
|
return msgbox(owner, target, prompt, buttons, box_title, MSG_NORMAL, suiHandler);
|
|
}
|
|
|
|
int msgbox(obj_id owner, obj_id target, prose_package prompt, int buttons, string box_title, int style, string suiHandler)
|
|
{
|
|
string oob = packOutOfBandProsePackage(null, prompt);
|
|
return msgbox(owner, target, "\0" + oob, buttons, box_title, style, suiHandler);
|
|
}
|
|
|
|
int msgbox(obj_id owner, obj_id target, prose_package prompt, string suiHandler)
|
|
{
|
|
return msgbox(owner, target, prompt, OK_ONLY, DEFAULT_TITLE, MSG_NORMAL, suiHandler);
|
|
}
|
|
|
|
int msgbox(obj_id owner, prose_package prompt, string suiHandler)
|
|
{
|
|
return msgbox(owner, owner, prompt, OK_ONLY, DEFAULT_TITLE, MSG_NORMAL, suiHandler);
|
|
}
|
|
|
|
int msgbox(obj_id owner, obj_id target, prose_package prompt)
|
|
{
|
|
return msgbox(owner, target, prompt, OK_ONLY, DEFAULT_TITLE, MSG_NORMAL, "noHandler");
|
|
}
|
|
|
|
int msgbox(obj_id owner, prose_package prompt)
|
|
{
|
|
return msgbox(owner, owner, prompt, OK_ONLY, DEFAULT_TITLE, MSG_NORMAL, "noHandler");
|
|
}
|
|
|
|
int msgbox(obj_id owner, obj_id target, prose_package prompt, int buttons, string suiHandler)
|
|
{
|
|
return msgbox(owner, target, prompt, buttons, DEFAULT_TITLE, MSG_NORMAL, suiHandler);
|
|
}
|
|
|
|
int msgbox(obj_id owner, obj_id target, prose_package prompt, int buttons, string box_title, string suiHandler)
|
|
{
|
|
return msgbox(owner, target, prompt, buttons, box_title, MSG_NORMAL, suiHandler);
|
|
}
|
|
|
|
/***** INPUTBOX FUNCTIONS *******************************************************/
|
|
|
|
//SCRIPT.INPUTBOX WIDGET LIST
|
|
//
|
|
//btnMiddle = button
|
|
//btnRight = button
|
|
//
|
|
//lblPrompt = text box
|
|
//lblTitle = text box
|
|
//
|
|
//imgIcon = image box
|
|
//
|
|
//vScroll = vertical scroll bar
|
|
//
|
|
//txtInput = editable text box
|
|
//cmbInput = editable combo box (datasource = dataInput)
|
|
|
|
|
|
/*****************************************************************
|
|
* @brief displays Script.inputBox page
|
|
*
|
|
* @param string prompt
|
|
* @param int buttons
|
|
* @param string box_title
|
|
* @param int style
|
|
* @param string[] dsrc (note: ignored if style = 0/INPUT_NORMAL)
|
|
*
|
|
* @return int pid; -1 on error
|
|
*****************************************************************/
|
|
int inputbox(obj_id owner, obj_id target, string prompt, int buttons, string box_title, int style, string[] dsrc, string suiHandler, dictionary params)
|
|
{
|
|
if ( dsrc == null )
|
|
{
|
|
LOG("sui", "inputbox: dsrc = null & style = " + style);
|
|
}
|
|
|
|
if ( !isIdValid(owner) || !isIdValid(target) )
|
|
return -1;
|
|
|
|
if ( prompt == null || prompt.equals("") )
|
|
return -1;
|
|
|
|
if ( suiHandler == null || suiHandler.equals("") )
|
|
suiHandler = "noHandler";
|
|
|
|
if ( box_title.equals("") )
|
|
box_title = DEFAULT_TITLE;
|
|
|
|
int pid = createSUIPage(SUI_INPUTBOX, owner, target, suiHandler);
|
|
|
|
setSUIProperty(pid, INPUTBOX_PROMPT, PROP_TEXT, prompt);
|
|
setSUIProperty(pid, INPUTBOX_TITLE, PROP_TEXT, box_title);
|
|
|
|
inputboxButtonSetup(pid, buttons);
|
|
inputboxStyleSetup(pid, style);
|
|
|
|
if ( (style > INPUT_NORMAL) && (dsrc != null) )
|
|
{
|
|
LOG("sui", "sui.inputbox: entering data source modification");
|
|
int maxArraySize = utils.getIntConfigSetting("GameServer", "suiListLimit");
|
|
if ( maxArraySize == 0 )
|
|
{
|
|
CustomerServiceLog("sui", "WARNING: could not find config setting [GameServer] suiListLimit, "+
|
|
"using default value of " + MAX_ARRAY_SIZE);
|
|
maxArraySize = MAX_ARRAY_SIZE;
|
|
}
|
|
else if ( maxArraySize > MAX_ARRAY_SIZE )
|
|
{
|
|
CustomerServiceLog("sui", "WARNING: config setting [GameServer] suiListLimit = " + maxArraySize +
|
|
" greater than default value of " + MAX_ARRAY_SIZE + ", please verify that the sui system can handle the value");
|
|
}
|
|
if ( dsrc.length > maxArraySize )
|
|
{
|
|
LOG("sui", "inputbox: passed dsrc array too large!");
|
|
|
|
prose_package pp = prose.getPackage(PROSE_OVER_MAX_ENTRIES, "", maxArraySize);
|
|
sendSystemMessageProse(target, pp);
|
|
|
|
string[] newSrc = new string[maxArraySize];
|
|
for ( int i = 0; i < maxArraySize; i++ )
|
|
{
|
|
newSrc[i] = dsrc[i];
|
|
}
|
|
|
|
dsrc = newSrc;
|
|
}
|
|
|
|
LOG("sui", "inputbox: clearing datasource dataInput");
|
|
clearSUIDataSource(pid, INPUTBOX_DATASOURCE);
|
|
|
|
int ubound = dsrc.length;
|
|
for ( int i = 0; i < ubound; i++ )
|
|
{
|
|
addSUIDataItem(pid, INPUTBOX_DATASOURCE, "" + i);
|
|
setSUIProperty(pid, INPUTBOX_DATASOURCE + "." + i, PROP_TEXT, dsrc[i]);
|
|
//LOG("sui", "inputbox: added item #" + i + ": " + dsrc[i]);
|
|
}
|
|
}
|
|
|
|
setSUIProperty(pid, INPUTBOX_INPUT, "MaxLength", String.valueOf(MAX_INPUT_LENGTH));
|
|
setSUIProperty(pid, INPUTBOX_COMBO, "MaxLength", String.valueOf(MAX_INPUT_LENGTH));
|
|
|
|
if ( (params != null) && (!params.isEmpty()) )
|
|
{
|
|
java.util.Enumeration keys = params.keys();
|
|
while ( keys.hasMoreElements() )
|
|
{
|
|
string key = (string)(keys.nextElement());
|
|
string val = params.getString(key);
|
|
|
|
LOG("sui","inputbox set params: key = " + key + " val = " + val);
|
|
java.util.StringTokenizer st = new java.util.StringTokenizer(key,"-");
|
|
if ( st.countTokens() == 2 )
|
|
{
|
|
string control = st.nextToken();
|
|
string prop = st.nextToken();
|
|
|
|
LOG("sui","control = " + control + " prop = " + prop + " val = " + val);
|
|
setSUIProperty(pid, control, prop, val);
|
|
}
|
|
}
|
|
}
|
|
|
|
//make sure to get back the localized text string, since that's what gets set by the user typing
|
|
subscribeToSUIProperty(pid, INPUTBOX_INPUT, PROP_LOCALTEXT);
|
|
subscribeToSUIProperty(pid, INPUTBOX_COMBO, PROP_SELECTEDTEXT);
|
|
|
|
showSUIPage(pid);
|
|
|
|
if ( owner != target )
|
|
setAssociateRange(target, pid, owner);
|
|
|
|
return pid;
|
|
}
|
|
|
|
int inputbox(obj_id owner, obj_id target, string prompt, string box_title, string suiHandler, int maxLength, boolean filtered, string defaultText)
|
|
{
|
|
if ( !isIdValid(owner) || !isIdValid(target) )
|
|
return -1;
|
|
|
|
if ( prompt == null || prompt.equals("") )
|
|
return -1;
|
|
|
|
if ( suiHandler == null || suiHandler.equals("") )
|
|
return -1;
|
|
|
|
string scriptvar_pid = VAR_FILTER_BASE + "." + target + ".pid";
|
|
string scriptvar_handler = VAR_FILTER_BASE + "." + target + ".handler";
|
|
|
|
if ( utils.hasScriptVar(owner, scriptvar_pid) )
|
|
{
|
|
int oldpid = utils.getIntScriptVar(owner, scriptvar_pid);
|
|
if ( oldpid > -1 )
|
|
closeSUI(target, oldpid);
|
|
|
|
cleanupFilteredInputbox(owner, target);
|
|
}
|
|
|
|
dictionary params = null;
|
|
|
|
if ( maxLength < 1 )
|
|
{
|
|
maxLength = MAX_INPUT_LENGTH;
|
|
}
|
|
else
|
|
{
|
|
params = new dictionary();
|
|
params.put(INPUTBOX_INPUT + "-MaxLength", maxLength);
|
|
}
|
|
|
|
if ( !filtered )
|
|
return inputbox(owner, target, prompt, OK_CANCEL, box_title, INPUT_NORMAL, null, suiHandler, params);
|
|
|
|
attachScript(owner, SCRIPT_FILTER_OWNER);
|
|
|
|
int pid = createSUIPage(SUI_INPUTBOX, owner, target, HANDLER_FILTER_INPUT);
|
|
if ( pid > -1 )
|
|
{
|
|
trackFilteredInputbox(owner, target, pid, suiHandler, defaultText);
|
|
|
|
if ( box_title.equals("") )
|
|
box_title = DEFAULT_TITLE;
|
|
|
|
setSUIProperty(pid, INPUTBOX_PROMPT, PROP_TEXT, prompt);
|
|
setSUIProperty(pid, INPUTBOX_TITLE, PROP_TEXT, box_title);
|
|
|
|
inputboxButtonSetup(pid, OK_CANCEL);
|
|
inputboxStyleSetup(pid, INPUT_NORMAL);
|
|
|
|
setSUIProperty(pid, INPUTBOX_INPUT, "MaxLength", String.valueOf(MAX_INPUT_LENGTH));
|
|
|
|
if ( defaultText != null && !defaultText.equals("") )
|
|
setSUIProperty(pid, INPUTBOX_INPUT, PROP_TEXT, defaultText);
|
|
|
|
subscribeToSUIProperty(pid, INPUTBOX_PROMPT, PROP_TEXT);
|
|
subscribeToSUIProperty(pid, INPUTBOX_TITLE, PROP_TEXT);
|
|
subscribeToSUIProperty(pid, INPUTBOX_INPUT, "MaxLength");
|
|
|
|
subscribeToSUIProperty(pid, INPUTBOX_INPUT, PROP_LOCALTEXT);
|
|
|
|
showSUIPage(pid);
|
|
return pid;
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
int inputbox(obj_id owner, obj_id target, string prompt, string box_title, string suiHandler, string defaultText)
|
|
{
|
|
return inputbox(owner, target, prompt, box_title, suiHandler, 32, true, defaultText);
|
|
}
|
|
|
|
int filteredInputbox(obj_id owner, obj_id target, string prompt, string box_title, string suiHandler, string defaultText)
|
|
{
|
|
return inputbox(owner, target, prompt, box_title, suiHandler, defaultText);
|
|
}
|
|
|
|
void trackFilteredInputbox(obj_id owner, obj_id player, int pid, string suiHandler, string defaultText)
|
|
{
|
|
if ( !isIdValid(owner) || !isIdValid(player) )
|
|
return;
|
|
|
|
string scriptvar_pid = VAR_FILTER_BASE + "." + player + ".pid";
|
|
string scriptvar_handler = VAR_FILTER_BASE + "." + player + ".handler";
|
|
string scriptvar_default = VAR_FILTER_BASE + "." + player + ".defaultText";
|
|
|
|
utils.setScriptVar(owner, scriptvar_pid, pid);
|
|
utils.setScriptVar(owner, scriptvar_handler, suiHandler);
|
|
|
|
if ( defaultText != null && !defaultText.equals("") )
|
|
utils.setScriptVar(owner, scriptvar_default, defaultText);
|
|
|
|
if ( !hasScript(owner, SCRIPT_FILTER_OWNER) )
|
|
attachScript(owner, SCRIPT_FILTER_OWNER);
|
|
|
|
int cnt = utils.getIntScriptVar(owner, VAR_FILTER_COUNT);
|
|
cnt++;
|
|
|
|
utils.setScriptVar(owner, VAR_FILTER_COUNT, cnt);
|
|
}
|
|
|
|
void cleanupFilteredInputbox(obj_id owner, obj_id player)
|
|
{
|
|
if ( !isIdValid(owner) || !isIdValid(player) )
|
|
return;
|
|
|
|
string scriptvar_pid = VAR_FILTER_BASE + "." + player + ".pid";
|
|
string scriptvar_handler = VAR_FILTER_BASE + "." + player + ".handler";
|
|
string scriptvar_default = VAR_FILTER_BASE + "." + player + ".defaultText";
|
|
|
|
utils.removeScriptVar(owner, scriptvar_pid);
|
|
utils.removeScriptVar(owner, scriptvar_handler);
|
|
utils.removeScriptVar(owner, scriptvar_default);
|
|
|
|
int cnt = utils.getIntScriptVar(owner, VAR_FILTER_COUNT);
|
|
cnt--;
|
|
|
|
if ( cnt < 1 )
|
|
{
|
|
utils.removeScriptVar(owner, VAR_FILTER_COUNT);
|
|
detachScript(owner, SCRIPT_FILTER_OWNER);
|
|
}
|
|
else
|
|
{
|
|
utils.setScriptVar(owner, VAR_FILTER_COUNT, cnt);
|
|
}
|
|
}
|
|
|
|
/*****************************************************************
|
|
* @brief gets the inputbox input control text from the sui callback
|
|
*
|
|
* @param dictionary params
|
|
*
|
|
* @return string
|
|
*****************************************************************/
|
|
string getInputBoxText(dictionary params)
|
|
{
|
|
return params.getString(INPUTBOX_INPUT + "." + PROP_LOCALTEXT);
|
|
}
|
|
|
|
/*****************************************************************
|
|
* @brief gets the inputbox input control text from the sui callback
|
|
*
|
|
* @param dictionary params
|
|
*
|
|
* @return string
|
|
*****************************************************************/
|
|
string getInputBoxTitle(dictionary params)
|
|
{
|
|
return params.getString(INPUTBOX_TITLE + "." + PROP_TEXT);
|
|
}
|
|
|
|
/*****************************************************************
|
|
* @brief gets the inputbox input control text from the sui callback
|
|
*
|
|
* @param dictionary params
|
|
*
|
|
* @return string
|
|
*****************************************************************/
|
|
string getInputBoxPrompt(dictionary params)
|
|
{
|
|
return params.getString(INPUTBOX_PROMPT + "." + PROP_TEXT);
|
|
}
|
|
|
|
/*****************************************************************
|
|
* @brief gets the inputbox input control text from the sui callback
|
|
*
|
|
* @param dictionary params
|
|
*
|
|
* @return string
|
|
*****************************************************************/
|
|
int getInputBoxMaxLength(dictionary params)
|
|
{
|
|
return utils.stringToInt(params.getString(INPUTBOX_INPUT + ".MaxLength"));
|
|
}
|
|
|
|
/*****************************************************************
|
|
* @brief gets the inputbox combo control text from the sui callback
|
|
*
|
|
* @param dictionary params
|
|
*
|
|
* @return string
|
|
*****************************************************************/
|
|
string getComboBoxText(dictionary params)
|
|
{
|
|
return params.getString(INPUTBOX_COMBO + "." + PROP_SELECTEDTEXT);
|
|
}
|
|
|
|
/***** INPUTBOX SUPPORT FUNCTIONS *************************************************/
|
|
|
|
void inputboxButtonSetup(int pid, int buttons)
|
|
{
|
|
switch(buttons)
|
|
{
|
|
case OK_CANCEL:
|
|
setSUIProperty(pid, INPUTBOX_BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, INPUTBOX_BTN_OK, PROP_TEXT,"@ok");
|
|
break;
|
|
case OK_ONLY: //fallthru to default
|
|
default:
|
|
msgboxHideBtnMiddle(pid);
|
|
setSUIProperty(pid, INPUTBOX_BTN_OK, PROP_TEXT,"@ok");
|
|
break;
|
|
}
|
|
}
|
|
|
|
void inputboxHideBtnMiddle(int pid)
|
|
{
|
|
setSUIProperty(pid, INPUTBOX_BTN_CANCEL, "Enabled","False");
|
|
setSUIProperty(pid, INPUTBOX_BTN_CANCEL, "Visible","False");
|
|
}
|
|
|
|
void inputboxStyleSetup(int pid, int style)
|
|
{
|
|
switch(style)
|
|
{
|
|
case INPUT_COMBO:
|
|
setSUIProperty(pid, INPUTBOX_INPUT, "Enabled","false");
|
|
setSUIProperty(pid, INPUTBOX_INPUT, "Visible","false");
|
|
|
|
setSUIProperty(pid, INPUTBOX_COMBO, "Enabled","true");
|
|
setSUIProperty(pid, INPUTBOX_COMBO, "Visible","true");
|
|
break;
|
|
case INPUT_NORMAL: //fallthru to default
|
|
default:
|
|
setSUIProperty(pid, INPUTBOX_INPUT, "Enabled","true");
|
|
setSUIProperty(pid, INPUTBOX_INPUT, "Visible","true");
|
|
|
|
setSUIProperty(pid, INPUTBOX_COMBO, "Enabled","false");
|
|
setSUIProperty(pid, INPUTBOX_COMBO, "Visible","false");
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
/***** INPUTBOX OVERLOAD FUNCTIONS **********************************************/
|
|
|
|
int inputbox(obj_id owner, obj_id target, string prompt, int buttons, string box_title, int style, string[] dsrc, string suiHandler)
|
|
{
|
|
return inputbox(owner, target, prompt, buttons, box_title, style, dsrc, suiHandler, null);
|
|
}
|
|
|
|
int inputbox(obj_id owner, obj_id target, string prompt, string suiHandler)
|
|
{
|
|
return inputbox(owner, target, prompt, OK_ONLY, DEFAULT_TITLE, INPUT_NORMAL, null, suiHandler);
|
|
}
|
|
|
|
int inputbox(obj_id owner, string prompt, string suiHandler)
|
|
{
|
|
return inputbox(owner, owner, prompt, OK_ONLY, DEFAULT_TITLE, INPUT_NORMAL, null, suiHandler);
|
|
}
|
|
|
|
int inputbox(obj_id owner, obj_id target, string prompt)
|
|
{
|
|
return inputbox(owner, target, prompt, OK_ONLY, DEFAULT_TITLE, INPUT_NORMAL, null, "noHandler");
|
|
}
|
|
|
|
int inputbox(obj_id owner, string prompt)
|
|
{
|
|
return inputbox(owner, owner, prompt, OK_ONLY, DEFAULT_TITLE, INPUT_NORMAL, null, "noHandler");
|
|
}
|
|
|
|
int inputbox(obj_id owner, obj_id target, string prompt, string[] dsrc, string suiHandler)
|
|
{
|
|
return inputbox(owner, target, prompt, OK_ONLY, DEFAULT_TITLE, INPUT_COMBO, dsrc, suiHandler);
|
|
}
|
|
|
|
int combobox(obj_id owner, obj_id target, string prompt, string[] dsrc, string suiHandler) //rename of inputbox function
|
|
{
|
|
return inputbox(owner, target, prompt, OK_ONLY, DEFAULT_TITLE, INPUT_COMBO, dsrc, suiHandler);
|
|
}
|
|
|
|
int combobox(obj_id owner, string prompt, string[] dsrc, string suiHandler) //rename of inputbox function
|
|
{
|
|
return inputbox(owner, owner, prompt, OK_ONLY, DEFAULT_TITLE, INPUT_COMBO, dsrc, suiHandler);
|
|
}
|
|
|
|
/***** LISTBOX FUNCTIONS *******************************************************/
|
|
|
|
//SCRIPT.LISTBOX WIDGET LIST
|
|
//
|
|
//btnMiddle = button
|
|
//btnRight = button
|
|
//
|
|
//lblTitle = text box
|
|
//
|
|
//imgIcon = image box
|
|
//
|
|
//vScroll = vertical scroll bar
|
|
//
|
|
//lstList = list box (datasource = dataList)
|
|
|
|
|
|
int listbox(obj_id owner, obj_id target, string prompt, int buttons, string box_title, prose_package[] dsrc, string suiHandler, boolean show, boolean truncate)
|
|
{
|
|
if ( !isIdValid(owner) || !isIdValid(target) || suiHandler == null || suiHandler.equals("") || dsrc == null || dsrc.length == 0)
|
|
{
|
|
if ( !isIdValid(owner) )
|
|
LOG("sui", "sui.listbox: invalid owner");
|
|
if ( !isIdValid(target) )
|
|
LOG("sui", "sui.listbox: invalid target");
|
|
if ( suiHandler == null || suiHandler.equals(""))
|
|
LOG("sui", "sui.listbox: invalid suiHandler");
|
|
if ( dsrc == null || dsrc.length == 0 )
|
|
LOG("sui", "sui.listbox: invalid dsrc");
|
|
return -1;
|
|
}
|
|
|
|
if ( box_title.equals("") )
|
|
box_title = DEFAULT_TITLE;
|
|
|
|
int maxArraySize = utils.getIntConfigSetting("GameServer", "suiListLimit");
|
|
if ( maxArraySize == 0 )
|
|
{
|
|
CustomerServiceLog("sui", "WARNING: could not find config setting [GameServer] suiListLimit, "+
|
|
"using default value of " + MAX_ARRAY_SIZE);
|
|
maxArraySize = MAX_ARRAY_SIZE;
|
|
}
|
|
else if ( maxArraySize > MAX_ARRAY_SIZE )
|
|
{
|
|
CustomerServiceLog("sui", "WARNING: config setting [GameServer] suiListLimit = " + maxArraySize +
|
|
" greater than default value of " + MAX_ARRAY_SIZE + ", please verify that the sui system can handle the value");
|
|
}
|
|
if ( dsrc.length > maxArraySize && truncate )
|
|
{
|
|
LOG("sui", "sui.listbox: entering data source modification");
|
|
if ( dsrc.length > maxArraySize )
|
|
{
|
|
LOG("sui", "listbox: passed dsrc array too large!");
|
|
|
|
prose_package pp = prose.getPackage(PROSE_OVER_MAX_ENTRIES, "", maxArraySize);
|
|
sendSystemMessageProse(target, pp);
|
|
|
|
prose_package[] newSrc = new prose_package[maxArraySize];
|
|
for ( int i = 0; i < maxArraySize; i++ )
|
|
{
|
|
newSrc[i] = dsrc[i];
|
|
}
|
|
|
|
dsrc = newSrc;
|
|
}
|
|
}
|
|
|
|
int pid = createSUIPage(SUI_LISTBOX, owner, target, suiHandler);
|
|
if ( pid > -1 )
|
|
{
|
|
setSUIProperty(pid, LISTBOX_TITLE, PROP_TEXT, box_title);
|
|
setSUIProperty(pid, LISTBOX_PROMPT, PROP_TEXT, prompt);
|
|
|
|
listboxButtonSetup(pid, buttons);
|
|
|
|
if ( dsrc != null )
|
|
{
|
|
clearSUIDataSource(pid, LISTBOX_DATASOURCE);
|
|
|
|
int ubound = dsrc.length;
|
|
for ( int i = 0; i < ubound; i++ )
|
|
{
|
|
addSUIDataItem(pid, LISTBOX_DATASOURCE, "" + i);
|
|
string oob = "";
|
|
oob = packOutOfBandProsePackage(oob, -1, dsrc[i]);
|
|
setSUIPropertyOOB(pid, LISTBOX_DATASOURCE + "." + i, PROP_TEXT, oob);
|
|
}
|
|
}
|
|
|
|
subscribeToSUIProperty(pid, LISTBOX_LIST, PROP_SELECTEDROW);
|
|
subscribeToSUIProperty(pid, LISTBOX_TITLE, PROP_TEXT);
|
|
|
|
if (show)
|
|
{
|
|
showSUIPage(pid);
|
|
|
|
if ( owner != target )
|
|
setAssociateRange(target, pid, owner);
|
|
}
|
|
}
|
|
|
|
return pid;
|
|
}
|
|
|
|
/*****************************************************************
|
|
* @brief displays Script.listBox page
|
|
*
|
|
* @param string box_title
|
|
* @param int buttons
|
|
* @param string[] dsrc
|
|
*
|
|
* @return int pid; -1 on error
|
|
*****************************************************************/
|
|
int listbox(obj_id owner, obj_id target, string prompt, int buttons, string box_title, string[] dsrc, string suiHandler, boolean show, boolean truncate)
|
|
{
|
|
if ( !isIdValid(owner) || !isIdValid(target) || suiHandler == null || suiHandler.equals("") || dsrc == null || dsrc.length == 0)
|
|
{
|
|
if ( !isIdValid(owner) )
|
|
LOG("sui", "sui.listbox: invalid owner");
|
|
if ( !isIdValid(target) )
|
|
LOG("sui", "sui.listbox: invalid target");
|
|
if ( suiHandler == null || suiHandler.equals(""))
|
|
LOG("sui", "sui.listbox: invalid suiHandler");
|
|
if ( dsrc == null || dsrc.length == 0 )
|
|
LOG("sui", "sui.listbox: invalid dsrc");
|
|
return -1;
|
|
}
|
|
|
|
if ( box_title.equals("") )
|
|
box_title = DEFAULT_TITLE;
|
|
|
|
int maxArraySize = utils.getIntConfigSetting("GameServer", "suiListLimit");
|
|
if ( maxArraySize == 0 )
|
|
{
|
|
CustomerServiceLog("sui", "WARNING: could not find config setting [GameServer] suiListLimit, "+
|
|
"using default value of " + MAX_ARRAY_SIZE);
|
|
maxArraySize = MAX_ARRAY_SIZE;
|
|
}
|
|
else if ( maxArraySize > MAX_ARRAY_SIZE )
|
|
{
|
|
CustomerServiceLog("sui", "WARNING: config setting [GameServer] suiListLimit = " + maxArraySize +
|
|
" greater than default value of " + MAX_ARRAY_SIZE + ", please verify that the sui system can handle the value");
|
|
}
|
|
if ( dsrc.length > maxArraySize && truncate )
|
|
{
|
|
LOG("sui", "sui.listbox: entering data source modification");
|
|
if ( dsrc.length > maxArraySize )
|
|
{
|
|
LOG("sui", "listbox: passed dsrc array too large!");
|
|
|
|
prose_package pp = prose.getPackage(PROSE_OVER_MAX_ENTRIES, "", maxArraySize);
|
|
sendSystemMessageProse(target, pp);
|
|
|
|
string[] newSrc = new string[maxArraySize];
|
|
for ( int i = 0; i < maxArraySize; i++ )
|
|
{
|
|
newSrc[i] = dsrc[i];
|
|
}
|
|
|
|
dsrc = newSrc;
|
|
}
|
|
}
|
|
|
|
int pid = createSUIPage(SUI_LISTBOX, owner, target, suiHandler);
|
|
if ( pid > -1 )
|
|
{
|
|
setSUIProperty(pid, LISTBOX_TITLE, PROP_TEXT, box_title);
|
|
setSUIProperty(pid, LISTBOX_PROMPT, PROP_TEXT, prompt);
|
|
|
|
listboxButtonSetup(pid, buttons);
|
|
|
|
if ( dsrc != null )
|
|
{
|
|
clearSUIDataSource(pid, LISTBOX_DATASOURCE);
|
|
|
|
int ubound = dsrc.length;
|
|
for ( int i = 0; i < ubound; i++ )
|
|
{
|
|
addSUIDataItem(pid, LISTBOX_DATASOURCE, "" + i);
|
|
setSUIProperty(pid, LISTBOX_DATASOURCE + "." + i, PROP_TEXT, dsrc[i]);
|
|
}
|
|
}
|
|
|
|
subscribeToSUIProperty(pid, LISTBOX_LIST, PROP_SELECTEDROW);
|
|
subscribeToSUIProperty(pid, LISTBOX_TITLE, PROP_TEXT);
|
|
|
|
if (show)
|
|
{
|
|
showSUIPage(pid);
|
|
|
|
if ( owner != target )
|
|
setAssociateRange(target, pid, owner);
|
|
}
|
|
}
|
|
|
|
return pid;
|
|
}
|
|
|
|
/*****************************************************************
|
|
* @brief displays Script.listBox page
|
|
*
|
|
* @param string box_title
|
|
* @param int buttons
|
|
*
|
|
* @return int pid; -1 on error
|
|
*****************************************************************/
|
|
int emptylistbox(obj_id owner, obj_id target, string prompt, int buttons, string box_title, string suiHandler, boolean show)
|
|
{
|
|
if ( !isIdValid(owner) || !isIdValid(target) || suiHandler == null || suiHandler.equals(""))
|
|
{
|
|
if ( !isIdValid(owner) )
|
|
LOG("sui", "sui.emptylistbox: invalid owner");
|
|
if ( !isIdValid(target) )
|
|
LOG("sui", "sui.emptylistbox: invalid target");
|
|
if ( suiHandler == null || suiHandler.equals(""))
|
|
LOG("sui", "sui.emptylistbox: invalid suiHandler");
|
|
return -1;
|
|
}
|
|
|
|
if ( box_title.equals("") )
|
|
box_title = DEFAULT_TITLE;
|
|
|
|
int pid = createSUIPage(SUI_LISTBOX, owner, target, suiHandler);
|
|
if ( pid > -1 )
|
|
{
|
|
setSUIProperty(pid, LISTBOX_TITLE, PROP_TEXT, box_title);
|
|
setSUIProperty(pid, LISTBOX_PROMPT, PROP_TEXT, prompt);
|
|
|
|
listboxButtonSetup(pid, buttons);
|
|
|
|
clearSUIDataSource(pid, LISTBOX_DATASOURCE);
|
|
|
|
subscribeToSUIProperty(pid, LISTBOX_LIST, PROP_SELECTEDROW);
|
|
subscribeToSUIProperty(pid, LISTBOX_TITLE, PROP_TEXT);
|
|
|
|
if (show)
|
|
showSUIPage(pid);
|
|
}
|
|
|
|
return pid;
|
|
}
|
|
|
|
/*****************************************************************
|
|
* @brief gets the inputbox combo control text from the sui callback
|
|
*
|
|
* @param dictionary params
|
|
*
|
|
* @return int
|
|
*****************************************************************/
|
|
int getListboxSelectedRow(dictionary params)
|
|
{
|
|
return utils.stringToInt(params.getString(LISTBOX_LIST + "." + PROP_SELECTEDROW));
|
|
}
|
|
|
|
/*****************************************************************
|
|
* @brief gets the inputbox combo control text from the sui callback
|
|
*
|
|
* @param dictionary params
|
|
*
|
|
* @return string
|
|
*****************************************************************/
|
|
string getListboxTitle(dictionary params)
|
|
{
|
|
return params.getString(LISTBOX_TITLE + "." + PROP_TEXT);
|
|
}
|
|
|
|
|
|
/***** LISTBOX SUPPORT FUNCTIONS *************************************************/
|
|
|
|
void listboxButtonSetup(int pid, int buttons)
|
|
{
|
|
switch(buttons)
|
|
{
|
|
case OK_CANCEL:
|
|
setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT,"@ok");
|
|
break;
|
|
case YES_NO:
|
|
setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT,"@no");
|
|
setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT,"@yes");
|
|
break;
|
|
case OK_REFRESH:
|
|
setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT,"@refresh");
|
|
setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT,"@ok");
|
|
break;
|
|
case OK_CANCEL_REFRESH:
|
|
listboxUseOtherButton(pid, "@refresh");
|
|
setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT,"@ok");
|
|
break;
|
|
case REFRESH_CANCEL:
|
|
setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT,"@refresh");
|
|
setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
break;
|
|
case REFRESH_ONLY:
|
|
listboxHideBtnMiddle(pid);
|
|
setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT,"@refresh");
|
|
break;
|
|
case OK_CANCEL_ALL:
|
|
listboxUseOtherButton(pid, "@all");
|
|
setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT,"@ok");
|
|
break;
|
|
case MOVEUP_MOVEDOWN_DONE:
|
|
listboxUseOtherButton(pid, "@movedown");
|
|
setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT,"@done");
|
|
setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT,"@moveup");
|
|
break;
|
|
case BET_MAX_BET_ONE_QUIT:
|
|
listboxUseOtherButton(pid, "@bet_one");
|
|
setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT,"@quit");
|
|
setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT,"@bet_max");
|
|
break;
|
|
case BET_MAX_BET_ONE_SPIN:
|
|
listboxUseOtherButton(pid, "@bet_one");
|
|
setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT,"@spin");
|
|
setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT,"@bet_max");
|
|
break;
|
|
case REFRESH_LEAVE_GAME:
|
|
setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT,"@leave_game");
|
|
setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT,"@refresh");
|
|
break;
|
|
case REMOVE_CANCEL:
|
|
setSUIProperty(pid, LISTBOX_BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT,"@remove");
|
|
break;
|
|
case OK_ONLY: //fallthru to default
|
|
default:
|
|
msgboxHideBtnMiddle(pid);
|
|
setSUIProperty(pid, LISTBOX_BTN_OK, PROP_TEXT,"@ok");
|
|
break;
|
|
}
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void listboxHideBtnMiddle(int pid)
|
|
{
|
|
setSUIProperty(pid, LISTBOX_BTN_CANCEL, "Enabled","False");
|
|
setSUIProperty(pid, LISTBOX_BTN_CANCEL, "Visible","False");
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void listboxUseOtherButton (int pid, String caption)
|
|
{
|
|
setSUIProperty (pid, LISTBOX_BTN_OTHER, PROP_VISIBLE, "true");
|
|
setSUIProperty (pid, LISTBOX_BTN_OTHER, PROP_TEXT, caption);
|
|
subscribeToSUIProperty (pid, "this", LISTBOX_PROP_OTHER_PRESSED);
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
boolean getListboxOtherButtonPressed(dictionary params)
|
|
{
|
|
return Boolean.valueOf (params.getString("this." + LISTBOX_PROP_OTHER_PRESSED)).booleanValue ();
|
|
}
|
|
|
|
/***** LISTBOX OVERLOAD FUNCTIONS **********************************************/
|
|
|
|
int listbox(obj_id owner, obj_id target, string prompt, int buttons, string box_title, string[] dsrc, string suiHandler, boolean show)
|
|
{
|
|
return listbox(owner, target, prompt, buttons, box_title, dsrc, suiHandler, show, true);
|
|
}
|
|
|
|
int listbox(obj_id owner, obj_id target, string prompt, int buttons, string box_title, Vector dsrc, string suiHandler, boolean show)
|
|
{
|
|
if ( dsrc == null )
|
|
return -1;
|
|
|
|
string[] dsrcArray = new string[dsrc.size()];
|
|
dsrc.toArray(dsrcArray);
|
|
return listbox(owner, target, prompt, buttons, box_title, dsrcArray, suiHandler, show, true);
|
|
}
|
|
|
|
int listbox(obj_id owner, obj_id target, string prompt, int buttons, string box_title, Vector dsrc, string suiHandler, boolean show, boolean truncate)
|
|
{
|
|
if ( dsrc == null )
|
|
return -1;
|
|
|
|
string[] dsrcArray = new string[dsrc.size()];
|
|
dsrc.toArray(dsrcArray);
|
|
return listbox(owner, target, prompt, buttons, box_title, dsrcArray, suiHandler, show, truncate);
|
|
}
|
|
|
|
int listbox(obj_id owner, obj_id target, string prompt, int buttons, string box_title, string[] dsrc, string suiHandler)
|
|
{
|
|
return listbox (owner, target, prompt, buttons, box_title, dsrc, suiHandler, true, true);
|
|
}
|
|
|
|
int listbox(obj_id owner, obj_id target, string prompt, int buttons, string box_title, Vector dsrc, string suiHandler)
|
|
{
|
|
if ( dsrc == null )
|
|
return -1;
|
|
|
|
string[] dsrcArray = new string[dsrc.size()];
|
|
dsrc.toArray(dsrcArray);
|
|
return listbox (owner, target, prompt, buttons, box_title, dsrcArray, suiHandler, true, true);
|
|
}
|
|
|
|
int listbox(obj_id owner, obj_id target, string prompt, string[] dsrc, string suiHandler)
|
|
{
|
|
return listbox(owner, target, prompt, OK_ONLY, "", dsrc, suiHandler);
|
|
}
|
|
|
|
int listbox(obj_id owner, obj_id target, string prompt, Vector dsrc, string suiHandler)
|
|
{
|
|
if ( dsrc == null )
|
|
return -1;
|
|
|
|
string[] dsrcArray = new string[dsrc.size()];
|
|
dsrc.toArray(dsrcArray);
|
|
return listbox(owner, target, prompt, OK_ONLY, "", dsrcArray, suiHandler);
|
|
}
|
|
|
|
int listbox(obj_id owner, string prompt, string[] dsrc, string suiHandler)
|
|
{
|
|
return listbox(owner, owner, prompt, OK_ONLY, "", dsrc, suiHandler);
|
|
}
|
|
|
|
int listbox(obj_id owner, string prompt, Vector dsrc, string suiHandler)
|
|
{
|
|
if ( dsrc == null )
|
|
return -1;
|
|
|
|
string[] dsrcArray = new string[dsrc.size()];
|
|
dsrc.toArray(dsrcArray);
|
|
return listbox(owner, owner, prompt, OK_ONLY, "", dsrcArray, suiHandler);
|
|
}
|
|
|
|
int listbox(obj_id owner, obj_id target, string prompt, string[] dsrc)
|
|
{
|
|
return listbox(owner, target, prompt, OK_ONLY, "", dsrc, "noHandler");
|
|
}
|
|
|
|
int listbox(obj_id owner, obj_id target, string prompt, Vector dsrc)
|
|
{
|
|
if ( dsrc == null )
|
|
return -1;
|
|
|
|
string[] dsrcArray = new string[dsrc.size()];
|
|
dsrc.toArray(dsrcArray);
|
|
return listbox(owner, target, prompt, OK_ONLY, "", dsrc, "noHandler");
|
|
}
|
|
|
|
int listbox(obj_id owner, string prompt, string[] dsrc)
|
|
{
|
|
return listbox(owner, owner, prompt, OK_ONLY, "", dsrc, "noHandler");
|
|
}
|
|
|
|
int listbox(obj_id owner, string prompt, Vector dsrc)
|
|
{
|
|
if ( dsrc == null )
|
|
return -1;
|
|
|
|
string[] dsrcArray = new string[dsrc.size()];
|
|
dsrc.toArray(dsrcArray);
|
|
return listbox(owner, owner, prompt, OK_ONLY, "", dsrcArray, "noHandler");
|
|
}
|
|
|
|
int listbox(obj_id owner, obj_id target, string prompt, string title, string[] dsrc, string suiHandler)
|
|
{
|
|
return listbox(owner, target, prompt, OK_ONLY, title, dsrc, suiHandler);
|
|
}
|
|
|
|
int listbox(obj_id owner, obj_id target, string prompt, string title, Vector dsrc, string suiHandler)
|
|
{
|
|
if ( dsrc == null )
|
|
return -1;
|
|
|
|
string[] dsrcArray = new string[dsrc.size()];
|
|
dsrc.toArray(dsrcArray);
|
|
return listbox(owner, target, prompt, OK_ONLY, title, dsrcArray, suiHandler);
|
|
}
|
|
|
|
int listbox(obj_id owner, string prompt, string title, string[] dsrc, string suiHandler)
|
|
{
|
|
return listbox(owner, owner, prompt, OK_ONLY, title, dsrc, suiHandler);
|
|
}
|
|
|
|
int listbox(obj_id owner, string prompt, string title, Vector dsrc, string suiHandler)
|
|
{
|
|
if ( dsrc == null )
|
|
return -1;
|
|
|
|
string[] dsrcArray = new string[dsrc.size()];
|
|
dsrc.toArray(dsrcArray);
|
|
return listbox(owner, owner, prompt, OK_ONLY, title, dsrcArray, suiHandler);
|
|
}
|
|
|
|
int listbox(obj_id owner, obj_id target, string prompt, string title, string[] dsrc)
|
|
{
|
|
return listbox(owner, target, prompt, OK_ONLY, title, dsrc, "noHandler");
|
|
}
|
|
|
|
int listbox(obj_id owner, obj_id target, string prompt, string title, Vector dsrc)
|
|
{
|
|
if ( dsrc == null )
|
|
return -1;
|
|
|
|
string[] dsrcArray = new string[dsrc.size()];
|
|
dsrc.toArray(dsrcArray);
|
|
return listbox(owner, target, prompt, OK_ONLY, title, dsrcArray, "noHandler");
|
|
}
|
|
|
|
int listbox(obj_id owner, string prompt, string title, string[] dsrc)
|
|
{
|
|
return listbox(owner, owner, prompt, OK_ONLY, title, dsrc, "noHandler");
|
|
}
|
|
|
|
int listbox(obj_id owner, string prompt, string title, Vector dsrc)
|
|
{
|
|
if ( dsrc == null )
|
|
return -1;
|
|
|
|
string[] dsrcArray = new string[dsrc.size()];
|
|
dsrc.toArray(dsrcArray);
|
|
return listbox(owner, owner, prompt, OK_ONLY, title, dsrcArray, "noHandler");
|
|
}
|
|
|
|
int listbox(obj_id owner, string prompt, string title, int btn, string[] dsrc)
|
|
{
|
|
return listbox(owner, owner, prompt, btn, title, dsrc, "noHandler");
|
|
}
|
|
|
|
int listbox(obj_id owner, string prompt, string title, int btn, Vector dsrc)
|
|
{
|
|
if ( dsrc == null )
|
|
return -1;
|
|
|
|
string[] dsrcArray = new string[dsrc.size()];
|
|
dsrc.toArray(dsrcArray);
|
|
return listbox(owner, owner, prompt, btn, title, dsrcArray, "noHandler");
|
|
}
|
|
|
|
|
|
/***** TRANSFER FUNCTIONS *******************************************************/
|
|
|
|
//SCRIPT.TRANSFER WIDGET LIST
|
|
//
|
|
//btnOk = button
|
|
//btnCancel = button
|
|
//btnRevert = button
|
|
//
|
|
//lblTitle = text box
|
|
//
|
|
//lblInputFrom = text box
|
|
//lblInputTo = text box
|
|
//
|
|
//txtFrom = input box
|
|
//txtTo = input box
|
|
|
|
/*****************************************************************
|
|
* @brief displays Script.transfer page
|
|
*
|
|
* @param string box_title
|
|
* @param int buttons
|
|
* @param string[] dsrc
|
|
*
|
|
* @return int pid; -1 on error
|
|
*****************************************************************/
|
|
int transfer(obj_id owner, obj_id target, string prompt, string box_title, string lblFrom, int inputFrom, string lblTo, int inputTo, string suiHandler, int conversionFrom, int conversionTo)
|
|
{
|
|
if ( ( owner == null ) || ( target == null ) || ( suiHandler == "" ) || conversionFrom <= 0 || conversionTo <= 0 )
|
|
return -1;
|
|
|
|
if ( box_title.equals("") )
|
|
box_title = DEFAULT_TITLE;
|
|
|
|
int pid = createSUIPage(SUI_TRANSFER, owner, target, suiHandler);
|
|
|
|
setSUIProperty(pid, TRANSFER_TITLE, PROP_TEXT, box_title);
|
|
setSUIProperty(pid, TRANSFER_PROMPT, PROP_TEXT, prompt);
|
|
|
|
|
|
//pass in "cash" and "bank", or whatever here, EAS
|
|
setSUIProperty(pid, TRANSFER_FROM_TEXT, PROP_TEXT, lblFrom);
|
|
setSUIProperty(pid, TRANSFER_TO_TEXT, PROP_TEXT, lblTo);
|
|
|
|
setSUIProperty(pid, TRANSFER_FROM, PROP_TEXT, Integer.toString(inputFrom));
|
|
setSUIProperty(pid, TRANSFER_TO, PROP_TEXT, Integer.toString(inputTo));
|
|
|
|
setSUIProperty(pid, TRANSFER_INPUT_FROM, PROP_TEXT, Integer.toString(inputFrom));
|
|
setSUIProperty(pid, TRANSFER_INPUT_TO, PROP_TEXT, Integer.toString(inputTo));
|
|
|
|
//SET RATIO VALUE HERE!!
|
|
setSUIProperty(pid, TRANSFER_PAGE_TRANSACTION, PROP_CONVERSION_RATIO_FROM, Integer.toString(conversionFrom));
|
|
setSUIProperty(pid, TRANSFER_PAGE_TRANSACTION, PROP_CONVERSION_RATIO_TO, Integer.toString(conversionTo));
|
|
|
|
subscribeToSUIProperty(pid, TRANSFER_INPUT_FROM, PROP_TEXT);
|
|
subscribeToSUIProperty(pid, TRANSFER_INPUT_TO, PROP_TEXT);
|
|
|
|
showSUIPage(pid);
|
|
|
|
if ( owner != target )
|
|
setAssociateRange(target, pid, owner);
|
|
|
|
return pid;
|
|
}
|
|
|
|
int transfer(obj_id owner, obj_id target, string prompt, string box_title, string lblFrom, int inputFrom, string lblTo, int inputTo, string suiHandler)
|
|
{
|
|
return transfer(owner, target, prompt, box_title, lblFrom, inputFrom, lblTo, inputTo, suiHandler, 1, 1);
|
|
}
|
|
|
|
/***** TRANSFER SUPPORT FUNCTIONS *************************************************/
|
|
/*****************************************************************
|
|
* @brief gets the inputbox combo control text from the sui callback
|
|
*
|
|
* @param dictionary params
|
|
*
|
|
* @return int
|
|
*****************************************************************/
|
|
int getTransferInputTo(dictionary params)
|
|
{
|
|
return utils.stringToInt(params.getString(TRANSFER_INPUT_TO + "." + PROP_TEXT));
|
|
}
|
|
|
|
/*****************************************************************
|
|
* @brief gets the inputbox combo control text from the sui callback
|
|
*
|
|
* @param dictionary params
|
|
*
|
|
* @return int
|
|
*****************************************************************/
|
|
int getTransferInputFrom(dictionary params)
|
|
{
|
|
return utils.stringToInt(params.getString(TRANSFER_INPUT_FROM + "." + PROP_TEXT));
|
|
}
|
|
|
|
|
|
/***** TRANSFER OVERLOAD FUNCTIONS **********************************************/
|
|
int bank(obj_id player)
|
|
{
|
|
if ( player == null )
|
|
return -1;
|
|
|
|
int cash = getCashBalance(player);
|
|
int bank = getBankBalance(player);
|
|
return transfer(player, player, MSG_BANK_PROMPT, MSG_BANK_TITLE, "Cash", cash, "Bank", bank, HANDLER_DEPOSIT_WITHDRAW);
|
|
}
|
|
|
|
/***** COLORIZE FUNCTIONS **********************************************/
|
|
int colorize(obj_id owner, obj_id player, obj_id target, String customizationVar, string handler)
|
|
{
|
|
if ((player == null) || (target == null) || (customizationVar == "") )
|
|
return -1;
|
|
|
|
customizationVar = customizationVar.trim();
|
|
if ( customizationVar.startsWith("/") )
|
|
{
|
|
customizationVar = customizationVar.substring(1);
|
|
}
|
|
|
|
LOG("sui", "colorize: customizationVar = " + customizationVar + "<>");
|
|
|
|
int pid = createSUIPage (SUI_COLORPICKER, owner, player, handler);
|
|
if ( pid > -1 )
|
|
{
|
|
setSUIProperty (pid, COLORPICKER_COLORPICKER, PROP_TARGETID, target.toString());
|
|
setSUIProperty (pid, COLORPICKER_COLORPICKER, PROP_TARGETVAR, customizationVar);
|
|
setSUIProperty (pid, COLORPICKER_COLORPICKER, PROP_TARGETRANGEMAX, "500");
|
|
|
|
setSUIProperty (pid, COLORPICKER_TITLE, PROP_TEXT, DEFAULT_TITLE);
|
|
|
|
subscribeToSUIProperty (pid, COLORPICKER_COLORPICKER, PROP_SELECTEDINDEX);
|
|
showSUIPage (pid);
|
|
}
|
|
|
|
return pid;
|
|
}
|
|
|
|
int getColorPickerIndex(dictionary params)
|
|
{
|
|
if ( params == null || params.isEmpty() )
|
|
return -1;
|
|
|
|
return utils.stringToInt(params.getString(COLORPICKER_COLORPICKER + "." + PROP_SELECTEDINDEX));
|
|
}
|
|
|
|
/***** MISC SUPPORT FUNCTIONS **********************************************/
|
|
/*****************************************************************
|
|
* @brief gets the button pressed from the sui callback
|
|
*
|
|
* @param dictionary params
|
|
*
|
|
* @return string
|
|
*****************************************************************/
|
|
string getButtonPressed(dictionary params)
|
|
{
|
|
return params.getString(PROP_BUTTONPRESSED);
|
|
}
|
|
|
|
/*****************************************************************
|
|
* @brief gets the button pressed from the sui callback
|
|
*
|
|
* @param dictionary params
|
|
*
|
|
* @return string
|
|
*****************************************************************/
|
|
int getIntButtonPressed(dictionary params)
|
|
{
|
|
string bp = params.getString(PROP_BUTTONPRESSED);
|
|
if ( (bp == null) || (bp.equals("")) )
|
|
{
|
|
|
|
}
|
|
else if ( bp.equals(OK) )
|
|
{
|
|
if ( params.containsKey("this.otherPressed") )
|
|
{
|
|
if ( params.getString("this.otherPressed").equals("true") )
|
|
return BP_REVERT;
|
|
}
|
|
|
|
return BP_OK;
|
|
}
|
|
else if ( bp.equals(REVERT) )
|
|
{
|
|
return BP_REVERT;
|
|
}
|
|
|
|
return BP_CANCEL;
|
|
}
|
|
|
|
/*****************************************************************
|
|
* @brief gets the player id from the sui callback
|
|
*
|
|
* @param dictionary params
|
|
*
|
|
* @return string
|
|
*****************************************************************/
|
|
obj_id getPlayerId(dictionary params)
|
|
{
|
|
return params.getObjId("player");
|
|
}
|
|
|
|
|
|
boolean setSUIObjVars(obj_id target, int pid, dictionary params)
|
|
{
|
|
java.util.Enumeration keys = params.keys();
|
|
|
|
while ( keys.hasMoreElements() )
|
|
{
|
|
Object key = keys.nextElement();
|
|
Object value = params.get(key);
|
|
|
|
if ( value instanceof Integer )
|
|
{
|
|
int v = ((Integer)value).intValue();
|
|
setObjVar(target, "sui." + pid + "." + key, v);
|
|
}
|
|
else if ( value instanceof int[] )
|
|
{
|
|
int[] v = (int[])value;
|
|
if(v.length > 0) // Zero length array check
|
|
setObjVar(target, "sui." + pid + "." + key, v);
|
|
}
|
|
else if ( value instanceof Float )
|
|
{
|
|
float v = ((Float)value).floatValue();
|
|
setObjVar(target, "sui." + pid + "." + key, v); // Suppress linting - incorrect lint script catch
|
|
}
|
|
else if ( value instanceof float[] )
|
|
{
|
|
float[] v = (float[])value;
|
|
if(v.length > 0) // Zero length array check
|
|
setObjVar(target, "sui." + pid + "." + key, v);
|
|
}
|
|
else if ( value instanceof string )
|
|
{
|
|
string v = (string)value;
|
|
setObjVar(target, "sui." + pid + "." + key, v); // Suppress linting - incorrect lint script catch
|
|
}
|
|
else if ( value instanceof string[] )
|
|
{
|
|
string[] v = (string[])value;
|
|
if(v.length > 0) // Zero length array check
|
|
setObjVar(target, "sui." + pid + "." + key, v);
|
|
}
|
|
else if ( value instanceof obj_id )
|
|
{
|
|
obj_id v = (obj_id)value;
|
|
setObjVar(target, "sui." + pid + "." + key, v); // Suppress linting - incorrect lint script catch
|
|
}
|
|
else if ( value instanceof obj_id[] )
|
|
{
|
|
obj_id[] v = (obj_id[])value;
|
|
if(v.length > 0) // Zero length array check
|
|
setObjVar(target, "sui." + pid + "." + key, v);
|
|
}
|
|
else if ( value instanceof location )
|
|
{
|
|
location v = (location)value;
|
|
setObjVar(target, "sui." + pid + "." + key, v); // Suppress linting - incorrect lint script catch
|
|
}
|
|
else if ( value instanceof location[] )
|
|
{
|
|
location[] v = (location[])value;
|
|
if(v.length > 0) // Zero length array check
|
|
setObjVar(target, "sui." + pid + "." + key, v);
|
|
}
|
|
else if ( value instanceof string_id )
|
|
{
|
|
string_id v = (string_id)value;
|
|
setObjVar(target, "sui." + pid + "." + key, v); // Suppress linting - incorrect lint script catch
|
|
}
|
|
else if ( value instanceof string_id[] )
|
|
{
|
|
string_id[] v = (string_id[])value;
|
|
if(v.length > 0) // Zero length array check
|
|
setObjVar(target, "sui." + pid + "." + key, v);
|
|
}
|
|
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void clearSUIObjVar(obj_id target, int pid)
|
|
{
|
|
removeObjVar(target, "sui." + pid);
|
|
}
|
|
|
|
void closeSUI(obj_id target, int pid)
|
|
{
|
|
if ( !isIdValid(target) )
|
|
return;
|
|
|
|
dictionary params = new dictionary();
|
|
params.put("pid", pid);
|
|
messageTo(target, "handleCloseSui", params, 0, false);
|
|
}
|
|
|
|
void setAssociateRange(obj_id player, int pid, obj_id target, float range)
|
|
{
|
|
if ( !isIdValid(player) )
|
|
{
|
|
LOG("sui", "sui.setAssociateRange: invalid player");
|
|
return;
|
|
}
|
|
|
|
if ( !isIdValid(target) )
|
|
{
|
|
LOG("sui", "sui.setAssociateRange: invalid target");
|
|
return;
|
|
}
|
|
|
|
if ( pid < 0 )
|
|
{
|
|
LOG("sui", "sui.setAssociateRange: pid < 0");
|
|
return;
|
|
}
|
|
|
|
if ( range <= 0f )
|
|
{
|
|
LOG("sui", "sui.setAssociateRange: invalid range <= 0f");
|
|
return;
|
|
}
|
|
|
|
setSUIAssociatedObject(pid, target);
|
|
setSUIMaxRangeToObject(pid, range);
|
|
}
|
|
|
|
void setAssociateRange(obj_id player, int pid, obj_id target)
|
|
{
|
|
setAssociateRange(player, pid, target, 16f);
|
|
}
|
|
|
|
void setAssociateRange(obj_id player, int pid, obj_id target, string key)
|
|
{
|
|
float range = 16f;
|
|
|
|
string tbl = "datatables/sui/associate_range.iff";
|
|
float dta = dataTableGetFloat(tbl, key, "RANGE");
|
|
if ( dta > 0f )
|
|
range = dta;
|
|
|
|
setAssociateRange(player, pid, target, range);
|
|
}
|
|
|
|
void setAutosaveProperty(int pid, boolean autosave)
|
|
{
|
|
setSUIProperty(pid, THIS, PROP_AUTOSAVE, autosave ? "true" : "false");
|
|
}
|
|
|
|
void setSizeProperty(int pid, int width, int height)
|
|
{
|
|
if (width < 0)
|
|
{
|
|
LOG("sui", "setSizeProperty: Invalid size. width = " + width);
|
|
return;
|
|
}
|
|
|
|
if (height < 0)
|
|
{
|
|
LOG("sui", "setSizeProperty: Invalid size. height = " + height);
|
|
return;
|
|
}
|
|
|
|
setSUIProperty(pid, THIS, PROP_SIZE, width + "," + height);
|
|
}
|
|
|
|
void setLocationProperty(int pid, int x, int y)
|
|
{
|
|
setSUIProperty(pid, THIS, PROP_LOCATION, x + "," + y);
|
|
}
|
|
|
|
void setSoundProperty(int pid, String sound)
|
|
{
|
|
setSUIProperty(pid, THIS, PROP_SOUND, sound == null ? "" : sound);
|
|
}
|
|
|
|
boolean hasPid(obj_id player, string pidName)
|
|
{
|
|
if(!isIdValid(player) || !exists(player))
|
|
return false;
|
|
|
|
if(pidName == null || pidName.equals(""))
|
|
return false;
|
|
|
|
return utils.hasScriptVar(player, "pid." + pidName);
|
|
}
|
|
|
|
void setPid(obj_id player, int pid, string pidName)
|
|
{
|
|
if(!isIdValid(player) || !exists(player))
|
|
return;
|
|
|
|
if(pidName == null || pidName.equals(""))
|
|
return;
|
|
|
|
if(pid == 0)
|
|
return;
|
|
|
|
utils.setScriptVar(player, "pid." + pidName, pid);
|
|
}
|
|
|
|
void removePid(obj_id player, string pidName)
|
|
{
|
|
if(!isIdValid(player) || !exists(player))
|
|
return;
|
|
|
|
if(pidName == null || pidName.equals(""))
|
|
return;
|
|
|
|
utils.removeScriptVar(player, "pid." + pidName);
|
|
}
|
|
|
|
int getPid(obj_id player, string pidName)
|
|
{
|
|
if(!isIdValid(player) || !exists(player))
|
|
return 0;
|
|
|
|
if(pidName == null || pidName.equals(""))
|
|
return 0;
|
|
|
|
return utils.getIntScriptVar(player, "pid." + pidName);
|
|
}
|
|
|
|
//use for terminals/suis where you want to set a range for the sui to no longer be valid
|
|
boolean outOfRange(obj_id object, obj_id player, float range, boolean message)
|
|
{
|
|
if(!isIdValid(object))
|
|
return false;
|
|
|
|
if(!isIdValid(player))
|
|
return false;
|
|
|
|
location a = getLocation(object);
|
|
location b = getLocation(player);
|
|
if (a.cell == b.cell && a.distance(b) < range)
|
|
return false;
|
|
|
|
if (message)
|
|
sendSystemMessage(player, OUT_OF_RANGE);
|
|
|
|
return true;
|
|
}
|
|
|
|
//Color functions for coloring text in custom SUIs
|
|
string colorGreen()
|
|
{
|
|
return "\\#99FF33";
|
|
}
|
|
|
|
string colorRed()
|
|
{
|
|
return "\\#FF3300";
|
|
}
|
|
|
|
string colorOrange()
|
|
{
|
|
return "\\#FFCC66";
|
|
}
|
|
|
|
string colorWhite()
|
|
{
|
|
return "\\#FFFFFF";
|
|
}
|
|
|
|
string colorBlue()
|
|
{
|
|
return "\\#0099FF";
|
|
}
|
|
|
|
string newLine()
|
|
{
|
|
return newLine(1);
|
|
}
|
|
|
|
string newLine(int n)
|
|
{
|
|
string returnString = "";
|
|
for(int i = 0; i < n; i++)
|
|
returnString += "\n";
|
|
|
|
return returnString;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
/*****************************************************************
|
|
* @brief Creates a SUI Table with the data passed in. The data
|
|
* can be in either column major or row major form.
|
|
*
|
|
* (For the following examples, assume we have columns for Name, Age, and Weight.)
|
|
* Column major data looks like this:
|
|
*
|
|
* {{John, Adam, Steve},
|
|
* {20, 21, 30},
|
|
* {150, 190, 175}}
|
|
*
|
|
* Row major data looks like this (using the same example as above):
|
|
*
|
|
* {{John, 20, 150},
|
|
* {Adam, 21, 190},
|
|
* {Steve,30, 175}}
|
|
*
|
|
*
|
|
*
|
|
* @param obj_id owner
|
|
* @param obj_id target
|
|
* @param int buttons
|
|
* @param string box_title
|
|
* @param string suiHandler
|
|
* @param string prompt
|
|
* @param string[] columnNames
|
|
* @param string[] columnTypes
|
|
* @param string[][] tableData
|
|
* @param boolean rowMajor
|
|
* @param boolean allowExport
|
|
*
|
|
* @return int
|
|
*****************************************************************/
|
|
|
|
|
|
int table(obj_id owner, obj_id target, int buttons, string box_title, string suiHandler, string prompt, string[] columnNames, string[] columnTypes, string[][] tableData, boolean rowMajor, boolean allowExport)
|
|
{
|
|
if ( !isIdValid(owner) || !isIdValid(target) )
|
|
return -1;
|
|
|
|
if ( suiHandler == null || suiHandler.equals("") )
|
|
suiHandler = "noHandler";
|
|
|
|
if (columnNames.length != columnTypes.length)
|
|
return -1;
|
|
|
|
int pid = createSUIPage(SUI_TABLE, owner, target, suiHandler);
|
|
|
|
if(pid != -1)
|
|
{
|
|
tableButtonSetup(pid, buttons);
|
|
|
|
setSUIProperty(pid, TABLE_TITLE, PROP_TEXT, box_title);
|
|
|
|
if(prompt == null || prompt.equals(""))
|
|
{
|
|
setSUIProperty(pid, TABLE_PROMPT, "Visible", "False");
|
|
}
|
|
else
|
|
{
|
|
setSUIProperty(pid, TABLE_PROMPT_TEXT, PROP_TEXT, prompt);
|
|
}
|
|
|
|
TableAllowExport(pid, allowExport);
|
|
|
|
if ( tableData != null )
|
|
{
|
|
clearSUIDataSource(pid, TABLE_DATASOURCE);
|
|
|
|
if(!rowMajor) // Column Major
|
|
{
|
|
|
|
|
|
int ubound = columnNames.length;
|
|
for ( int i = 0; i < ubound; i++ )
|
|
{
|
|
string key = columnNames[i];
|
|
addSUIDataSource(pid, TABLE_DATASOURCE, "" + i);
|
|
|
|
setSUIProperty(pid, TABLE_DATASOURCE + "." + i, PROP_LABEL, key);
|
|
|
|
setSUIProperty(pid, TABLE_DATASOURCE + "." + i, PROP_TYPE, columnTypes[i]);
|
|
|
|
|
|
for(int k = 0; k < tableData[i].length; ++k)
|
|
{
|
|
addSUIDataItem(pid, TABLE_DATASOURCE + "." + i, "data" + k);
|
|
|
|
setSUIProperty(pid, TABLE_DATASOURCE + "." + i + ".data" + k, PROP_VALUE, tableData[i][k]);
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
else // Row Major
|
|
{
|
|
int ubound = columnNames.length;
|
|
for ( int i = 0; i < ubound; i++ )
|
|
{
|
|
string key = columnNames[i];
|
|
addSUIDataSource(pid, TABLE_DATASOURCE, "" + i);
|
|
|
|
setSUIProperty(pid, TABLE_DATASOURCE + "." + i, PROP_LABEL, key);
|
|
|
|
setSUIProperty(pid, TABLE_DATASOURCE + "." + i, PROP_TYPE, columnTypes[i]);
|
|
}
|
|
|
|
for ( int i = 0; i < ubound; i++ )
|
|
{
|
|
//string key = columnNames[i];
|
|
for(int k = 0; k < tableData.length; ++k)
|
|
{
|
|
addSUIDataItem(pid, TABLE_DATASOURCE + "." + i, "data" + k);
|
|
|
|
setSUIProperty(pid, TABLE_DATASOURCE + "." + i + ".data" + k, PROP_VALUE, tableData[k][i]);
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
subscribeToSUIProperty(pid, TABLE_TABLE, PROP_LOGICALINDEX);
|
|
subscribeToSUIProperty(pid, TABLE_TABLE, PROP_SELECTEDROW);
|
|
|
|
}
|
|
|
|
showSUIPage(pid);
|
|
|
|
if ( owner != target )
|
|
setAssociateRange(target, pid, owner);
|
|
}
|
|
|
|
return pid;
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
int tableColumnMajor(obj_id owner, obj_id target, int buttons, string box_title, string suiHandler, string prompt, string[] columnNames,string[] columnTypes, string[][] tableData)
|
|
{
|
|
return table(owner, target, buttons, box_title, suiHandler, prompt, columnNames, columnTypes, tableData, false, false);
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
int tableColumnMajor(obj_id owner, obj_id target, int buttons, string box_title, string suiHandler, string prompt, string[] columnNames,string[] columnTypes, string[][] tableData, boolean allowExport)
|
|
{
|
|
return table(owner, target, buttons, box_title, suiHandler, prompt, columnNames, columnTypes, tableData, false, allowExport);
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
int tableRowMajor(obj_id owner, obj_id target, int buttons, string box_title, string suiHandler, string prompt, string[] columnNames, string[] columnTypes, string[][] tableData)
|
|
{
|
|
return table(owner, target, buttons, box_title, suiHandler, prompt, columnNames, columnTypes, tableData, true, false);
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
int tableRowMajor(obj_id owner, obj_id target, int buttons, string box_title, string suiHandler, string prompt, string[] columnNames, string[] columnTypes, string[][] tableData, boolean allowExport)
|
|
{
|
|
return table(owner, target, buttons, box_title, suiHandler, prompt, columnNames, columnTypes, tableData, true, allowExport);
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void tableButtonSetup(int pid, int buttons)
|
|
{
|
|
switch(buttons)
|
|
{
|
|
case OK_CANCEL:
|
|
setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT,"@ok");
|
|
break;
|
|
case YES_NO:
|
|
setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT,"@no");
|
|
setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT,"@yes");
|
|
break;
|
|
case OK_REFRESH:
|
|
setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT,"@refresh");
|
|
setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT,"@ok");
|
|
break;
|
|
case OK_CANCEL_REFRESH:
|
|
TableUseOtherButton(pid, "@refresh");
|
|
setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT,"@ok");
|
|
break;
|
|
case REFRESH_CANCEL:
|
|
setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT,"@refresh");
|
|
setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
break;
|
|
case REFRESH_ONLY:
|
|
TableHideBtnMiddle(pid);
|
|
setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT,"@refresh");
|
|
break;
|
|
case OK_CANCEL_ALL:
|
|
TableUseOtherButton(pid, "@all");
|
|
setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT,"@ok");
|
|
break;
|
|
case MOVEUP_MOVEDOWN_DONE:
|
|
TableUseOtherButton(pid, "@movedown");
|
|
setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT,"@done");
|
|
setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT,"@moveup");
|
|
break;
|
|
case REFRESH_LEAVE_GAME:
|
|
setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT,"@leave_game");
|
|
setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT,"@refresh");
|
|
break;
|
|
case REMOVE_CANCEL:
|
|
setSUIProperty(pid, TABLE_BTN_CANCEL, PROP_TEXT,"@cancel");
|
|
setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT,"@remove");
|
|
break;
|
|
case OK_ONLY: //fallthru to default
|
|
default:
|
|
msgboxHideBtnMiddle(pid);
|
|
setSUIProperty(pid, TABLE_BTN_OK, PROP_TEXT,"@ok");
|
|
break;
|
|
}
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void TableHideBtnMiddle(int pid)
|
|
{
|
|
setSUIProperty(pid, TABLE_BTN_CANCEL, "Enabled","False");
|
|
setSUIProperty(pid, TABLE_BTN_CANCEL, "Visible","False");
|
|
}
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void TableUseOtherButton (int pid, String caption)
|
|
{
|
|
setSUIProperty (pid, TABLE_BTN_OTHER, PROP_VISIBLE, "true");
|
|
setSUIProperty (pid, TABLE_BTN_OTHER, PROP_TEXT, caption);
|
|
subscribeToSUIProperty (pid, "this", TABLE_PROP_OTHER_PRESSED);
|
|
}
|
|
|
|
void TableAllowExport (int pid, boolean allow)
|
|
{
|
|
if(allow)
|
|
{
|
|
setSUIProperty (pid, TABLE_BTN_EXPORT, PROP_VISIBLE, "true");
|
|
}
|
|
else
|
|
{
|
|
setSUIProperty (pid, TABLE_BTN_EXPORT, PROP_VISIBLE, "false");
|
|
}
|
|
}
|
|
|
|
// The VISUALLY selected row.
|
|
int getTableSelectedRow(dictionary params)
|
|
{
|
|
return utils.stringToInt(params.getString(TABLE_TABLE + "." + PROP_SELECTEDROW));
|
|
}
|
|
|
|
// The LOGICALLY selected row. This is the index into array of data you passed in to create the table.
|
|
int getTableLogicalIndex(dictionary params)
|
|
{
|
|
return utils.stringToInt(params.getString(TABLE_TABLE + "." + PROP_LOGICALINDEX));
|
|
}
|
|
|
|
string getEventType(dictionary params)
|
|
{
|
|
string eventType = params.getString("eventType");
|
|
return eventType;
|
|
}
|
|
|
|
|
|
void cancelCountdownTimer(obj_id self, int event)
|
|
{
|
|
if(!hasObjVar(self, sui.COUNTDOWNTIMER_SUI_VAR))
|
|
{
|
|
detachScript(self, sui.COUNTDOWNTIMER_PLAYER_SCRIPT);
|
|
return;
|
|
}
|
|
|
|
int pid = getIntObjVar(self, sui.COUNTDOWNTIMER_SUI_VAR);
|
|
|
|
if(!utils.hasScriptVar(self, sui.COUNTDOWNTIMER_OWNER_VAR) || !utils.hasScriptVar(self, sui.COUNTDOWNTIMER_CALLBACK_VAR))
|
|
{
|
|
detachScript(self, sui.COUNTDOWNTIMER_PLAYER_SCRIPT);
|
|
return;
|
|
}
|
|
|
|
obj_id owner = utils.getObjIdScriptVar(self, sui.COUNTDOWNTIMER_OWNER_VAR);
|
|
string callback = utils.getStringScriptVar(self, sui.COUNTDOWNTIMER_CALLBACK_VAR);
|
|
|
|
if(!isIdValid(owner) || callback == null || callback.equals(""))
|
|
{
|
|
detachScript(self, sui.COUNTDOWNTIMER_PLAYER_SCRIPT);
|
|
return;
|
|
}
|
|
|
|
dictionary d = new dictionary();
|
|
d.put("buttonPressed", sui.REVERT);
|
|
d.put("player", self);
|
|
d.put("id", pid);
|
|
d.put("event", event);
|
|
|
|
messageTo(owner, callback, d, 0.0f, false);
|
|
|
|
detachScript(self, sui.COUNTDOWNTIMER_PLAYER_SCRIPT);
|
|
forceCloseSUIPage(pid);
|
|
|
|
}
|
|
|
|
boolean hasEventFlag(obj_id self, int flag)
|
|
{
|
|
if(!utils.hasScriptVar(self, sui.COUNTDOWNTIMER_FLAGS_VAR))
|
|
return false;
|
|
|
|
int flags = utils.getIntScriptVar(self, sui.COUNTDOWNTIMER_FLAGS_VAR);
|
|
|
|
return ((flags & flag) > 0);
|
|
}
|