Files
dsrc/sku.0/sys.server/compiled/game/script/space/characters/transfer_auth.script
T
2013-09-10 23:17:15 -07:00

154 lines
3.9 KiB
Plaintext

//------------------------------------------------
// transfer_auth.script
// Brandon Reinhart
//
// Script for the signable Authorization of Transfer form.
//------------------------------------------------
//------------------------------------------------
// Includes
//------------------------------------------------
include library.sui;
//------------------------------------------------
// Constants
//------------------------------------------------
const string_id SID_READ = new string_id("space/quest", "read");
const string_id SID_SYS_NOT_IN_INV = new string_id("space/quest", "not_in_inv");
const string_id SID_SIGNED = new string_id("space/quest", "signed");
const string SID_SIGN = "@space/quest:sign";
const string SID_CLOSE = "@space/quest:close";
//------------------------------------------------
// OnObjectMenuRequest
//------------------------------------------------
trigger OnObjectMenuRequest( obj_id player, menu_info mi )
{
mi.addRootMenu( menu_info_types.SERVER_MENU1, SID_READ );
return SCRIPT_CONTINUE;
}
//------------------------------------------------
// OnObjectMenuSelect
//------------------------------------------------
trigger OnObjectMenuSelect( obj_id player, int item )
{
if ( item == menu_info_types.SERVER_MENU1 )
{
displayDialog( self, player );
}
return SCRIPT_CONTINUE;
}
//------------------------------------------------
// displayDialog
//------------------------------------------------
void displayDialog( obj_id self, obj_id player )
{
// Make sure we are in the player's inventory.
obj_id inventory = getObjectInSlot( player, "inventory" );
if ( !contains( inventory, self ) )
{
sendSystemMessage( player, SID_SYS_NOT_IN_INV );
return;
}
string text = "@space/quest:ta_text";
string title = "@space/quest:ta_title";
string signed = getStringObjVar( self, "signature" );
if ( signed != null )
{
text += "\n Signed: " + signed + "\n";
}
// Create the dialog page.
int pid = sui.createSUIPage( sui.SUI_MSGBOX, self, player, "handleDialogInput" );
// Add elements text.
sui.setSUIProperty( pid, sui.MSGBOX_PROMPT, sui.PROP_TEXT, text );
sui.setSUIProperty (pid, sui.MSGBOX_TITLE, sui.PROP_TEXT, title );
// Add buttons.
sui.msgboxButtonSetup( pid, sui.OK_CANCEL );
sui.setSUIProperty( pid, sui.MSGBOX_BTN_CANCEL, sui.PROP_TEXT, SID_SIGN );
sui.setSUIProperty( pid, sui.MSGBOX_BTN_OK, sui.PROP_TEXT, SID_CLOSE );
// Show dialog.
sui.showSUIPage( pid );
return;
}
//------------------------------------------------
// handleDialogInput
//------------------------------------------------
messageHandler handleDialogInput()
{
if ( (params == null) || (params.isEmpty()) )
{
return SCRIPT_CONTINUE;
}
// Determine which button was pressed.
obj_id player = sui.getPlayerId( params );
int bp = sui.getIntButtonPressed( params );
switch ( bp )
{
case sui.BP_CANCEL: // "Sign"
signForm( self, player );
return SCRIPT_CONTINUE;
case sui.BP_OK: // "Close"
return SCRIPT_CONTINUE;
}
return SCRIPT_CONTINUE;
}
//------------------------------------------------
// signForm
//------------------------------------------------
void signForm( obj_id self, obj_id player )
{
sui.inputbox( self, player, "@space/quest:ta_sign", sui.OK_CANCEL, "@space/quest:ta_sign_title", sui.MSG_NORMAL, null, "handleSignedForm", null );
}
//------------------------------------------------
// handleSignedForm
//------------------------------------------------
messageHandler handleSignedForm()
{
if ( (params == null) || (params.isEmpty()) )
{
return SCRIPT_CONTINUE;
}
// Determine which button was pressed.
obj_id player = sui.getPlayerId( params );
int bp = sui.getIntButtonPressed( params );
string text = sui.getInputBoxText( params );
switch ( bp )
{
case sui.BP_CANCEL:
return SCRIPT_CONTINUE;
case sui.BP_OK:
// Store what they signed with.
setObjVar( self, "signature", text );
sendSystemMessage( player, SID_SIGNED );
return SCRIPT_CONTINUE;
}
return SCRIPT_CONTINUE;
}