mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
410 lines
11 KiB
Plaintext
410 lines
11 KiB
Plaintext
include library.utils;
|
|
include library.hue;
|
|
include library.sui;
|
|
include library.space_utils;
|
|
include library.space_transition;
|
|
|
|
const string_id MNU_COLOR = new string_id("sui", "set_color");
|
|
const string_id MNU_COLOR_ONE = new string_id("sui", "color_ship_one");
|
|
const string_id MNU_COLOR_TWO = new string_id("sui", "color_ship_two");
|
|
|
|
const string SCRIPTVAR_SHIP_PID = "ship_customization.pid";
|
|
const string SCRIPTVAR_REHUE_ID = "ship_customization.id";
|
|
|
|
const string STF = "color_kit";
|
|
|
|
const string BTN_COLOR = "@" + STF + ":btn_color";
|
|
const string PICK_A_SHIP_TITLE = "@" + STF + ":pick_a_ship_title";
|
|
const string PICK_A_SHIP = "@" + STF + ":pick_a_ship";
|
|
|
|
|
|
trigger OnAttach()
|
|
{
|
|
setObjVar(self, "ship_customization.usedOne", 0);
|
|
setObjVar(self, "ship_customization.usedTwo", 0);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
if ( !utils.isNestedWithin(self, player) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int mnuColor = mi.addRootMenu(menu_info_types.SERVER_MENU1, MNU_COLOR);
|
|
if ( mnuColor > -1 && (( getContainedBy(self) != getOwner(self) ) || isGod(player)) )
|
|
{
|
|
string template = utils.getTemplateFilenameNoPath(self);
|
|
|
|
if (getIntObjVar(self, "ship_customization.usedOne") == 0)
|
|
{
|
|
int mnuColorFrame = mi.addSubMenu(mnuColor, menu_info_types.SERVER_MENU2, MNU_COLOR_ONE);
|
|
}
|
|
if (getIntObjVar(self, "ship_customization.usedTwo") == 0)
|
|
{
|
|
int mnuColorLens = mi.addSubMenu(mnuColor, menu_info_types.SERVER_MENU3, MNU_COLOR_TWO);
|
|
}
|
|
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuSelect(obj_id player, int item)
|
|
{
|
|
if ( !utils.isNestedWithin(self, player) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
string template = utils.getTemplateFilenameNoPath(self);
|
|
|
|
if ( item == menu_info_types.SERVER_MENU2 ) //color one
|
|
{
|
|
if (isSpaceScene() == true)
|
|
{
|
|
sendSystemMessage(player, new string_id(STF, "inspace"));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (utils.getBooleanScriptVar(self, "paint_kit.inuse") == true)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
utils.setScriptVar(self, "paint_kit.inuse", true);
|
|
obj_id[] shipControlDevices = space_transition.findShipControlDevicesForPlayer(player);
|
|
if (shipControlDevices == null || shipControlDevices.length <= 0)
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
resizeable obj_id[] validControlDevices = new obj_id[0];
|
|
|
|
for(int i = 0; i < shipControlDevices.length; i++)
|
|
{
|
|
obj_id objShip = space_transition.getShipFromShipControlDevice(shipControlDevices[i]);
|
|
|
|
if(space_utils.isShipPaintable(objShip))
|
|
{
|
|
validControlDevices = utils.addElement(validControlDevices, shipControlDevices[i]);
|
|
}
|
|
}
|
|
|
|
string entries[] = new string[validControlDevices.length];
|
|
|
|
//get names of ships
|
|
for (int i = 0; i < validControlDevices.length; i++)
|
|
{
|
|
entries[i] = getAssignedName(validControlDevices[i]);
|
|
if (entries[i] == null || entries[i].equals(""))
|
|
{
|
|
entries[i] = "@"+getName(validControlDevices[i]);
|
|
}
|
|
}
|
|
if (validControlDevices != null && validControlDevices.length > 0)
|
|
{
|
|
int pid = sui.listbox(self, player, PICK_A_SHIP, sui.OK_CANCEL, PICK_A_SHIP_TITLE, entries, "handleKitColorizeOne", false, false);
|
|
if(pid > -1) {
|
|
|
|
utils.setScriptVar(player, "color.scds", validControlDevices);
|
|
// Rename some buttons and show the sui
|
|
setSUIProperty(pid, sui.LISTBOX_BTN_OK, sui.PROP_TEXT, BTN_COLOR);
|
|
showSUIPage(pid);
|
|
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
string_id message = new string_id(STF, "ships_not_paintable");
|
|
sendSystemMessage(player, message);
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
}
|
|
|
|
}
|
|
if ( item == menu_info_types.SERVER_MENU3 ) //color two
|
|
{
|
|
if (isSpaceScene() == true)
|
|
{
|
|
sendSystemMessage(player, new string_id(STF, "inspace"));
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
if (utils.getBooleanScriptVar(self, "paint_kit.inuse") == true)
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
utils.setScriptVar(self, "paint_kit.inuse", true);
|
|
|
|
obj_id[] shipControlDevices = space_transition.findShipControlDevicesForPlayer(player);
|
|
|
|
if (shipControlDevices == null || shipControlDevices.length <= 0)
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
resizeable obj_id[] validControlDevices = new obj_id[0];
|
|
|
|
for(int i = 0; i < shipControlDevices.length; i++)
|
|
{
|
|
obj_id objShip = space_transition.getShipFromShipControlDevice(shipControlDevices[i]);
|
|
|
|
if(space_utils.isShipPaintable(objShip))
|
|
{
|
|
validControlDevices = utils.addElement(validControlDevices, shipControlDevices[i]);
|
|
}
|
|
}
|
|
|
|
string entries[] = new string[validControlDevices.length];
|
|
|
|
//get names of ships
|
|
for (int i = 0; i < validControlDevices.length; i++)
|
|
{
|
|
entries[i] = getAssignedName(validControlDevices[i]);
|
|
if (entries[i] == null || entries[i].equals(""))
|
|
{
|
|
entries[i] = "@"+getName(validControlDevices[i]);
|
|
}
|
|
}
|
|
if (validControlDevices != null && validControlDevices.length > 0)
|
|
{
|
|
int pid = sui.listbox(self, player, PICK_A_SHIP, sui.OK_CANCEL, PICK_A_SHIP_TITLE, entries, "handleKitColorizeTwo", false, false);
|
|
if(pid > -1) {
|
|
|
|
utils.setScriptVar(player, "color.scds", validControlDevices);
|
|
// Rename some buttons and show the sui
|
|
setSUIProperty(pid, sui.LISTBOX_BTN_OK, sui.PROP_TEXT, BTN_COLOR);
|
|
showSUIPage(pid);
|
|
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
string_id message = new string_id(STF, "ships_not_paintable");
|
|
sendSystemMessage(player, message);
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
}
|
|
}
|
|
|
|
//destroyObject(self);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
messageHandler handleKitColorizeOne()
|
|
{
|
|
int bp = sui.getIntButtonPressed(params);
|
|
int idx = sui.getListboxSelectedRow(params);
|
|
|
|
if ( bp == sui.BP_CANCEL )
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
else
|
|
{
|
|
|
|
obj_id player = sui.getPlayerId(params);
|
|
|
|
if (idx == -1)
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if ( !isIdValid(player) )
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
string template = utils.getTemplateFilenameNoPath(self);
|
|
string index = "/shared_owner/index_color_1";
|
|
string index2 = "/shared_owner/index_color_2";
|
|
|
|
obj_id[] shipControlDevices = utils.getObjIdArrayScriptVar(player, "color.scds");
|
|
utils.removeScriptVar(player, "color.scds");
|
|
if (shipControlDevices != null && shipControlDevices.length > 0)
|
|
{
|
|
obj_id objShip = space_transition.getShipFromShipControlDevice(shipControlDevices[idx]);
|
|
|
|
if ( index != null && !index.equals("") && !index.equals("none") )
|
|
{
|
|
if (isIdValid(objShip))
|
|
{
|
|
string chassis = getShipChassisType(objShip);
|
|
if (!space_utils.isShipPaintable(objShip))
|
|
{
|
|
string_id message = new string_id(STF, "imperial");
|
|
sendSystemMessage(player, message);
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
utils.setScriptVar(player, "color.shipId", objShip);
|
|
sui.colorize(self, player, objShip, index, "handleFirstColorize");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleKitColorizeTwo()
|
|
{
|
|
int bp = sui.getIntButtonPressed(params);
|
|
int idx = sui.getListboxSelectedRow(params);
|
|
|
|
if ( bp == sui.BP_CANCEL )
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
|
|
obj_id player = sui.getPlayerId(params);
|
|
|
|
if (idx == -1)
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
if ( !isIdValid(player) )
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
string template = utils.getTemplateFilenameNoPath(self);
|
|
string index = "/shared_owner/index_color_1";
|
|
string index2 = "/shared_owner/index_color_2";
|
|
|
|
obj_id[] shipControlDevices = utils.getObjIdArrayScriptVar(player, "color.scds");
|
|
utils.removeScriptVar(player, "color.scds");
|
|
if (shipControlDevices != null && shipControlDevices.length > 0)
|
|
{
|
|
obj_id objShip = space_transition.getShipFromShipControlDevice(shipControlDevices[idx]);
|
|
|
|
if ( index != null && !index.equals("") && !index.equals("none") )
|
|
{
|
|
if (isIdValid(objShip))
|
|
{
|
|
string chassis = getShipChassisType(objShip);
|
|
if (chassis.equals("player_basic_tiefighter") ||
|
|
chassis.equals("player_decimator") ||
|
|
chassis.equals("player_tieadvanced") ||
|
|
chassis.equals("player_tieaggressor") ||
|
|
chassis.equals("player_tiebomber") ||
|
|
chassis.equals("player_tiefighter") ||
|
|
chassis.equals("player_tie_in") ||
|
|
chassis.equals("player_tieinterceptor") ||
|
|
chassis.equals("player_tie_light_duty") ||
|
|
chassis.equals("player_tieoppressor"))
|
|
{
|
|
string_id message = new string_id(STF, "imperial");
|
|
sendSystemMessage(player, message);
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
utils.setScriptVar(player, "color.shipId", objShip);
|
|
sui.colorize(self, player, objShip, index2, "handleSecondColorize");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|
|
messageHandler handleFirstColorize()
|
|
{
|
|
|
|
int idx = sui.getColorPickerIndex(params);
|
|
int bp = sui.getIntButtonPressed(params);
|
|
obj_id player = sui.getPlayerId(params);
|
|
if ( bp == sui.BP_CANCEL )
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_OVERRIDE;
|
|
}
|
|
|
|
obj_id objShip = utils.getObjIdScriptVar(player, "color.shipId");
|
|
string index = "/shared_owner/index_color_1";
|
|
if ( idx > -1 )
|
|
{
|
|
if (isIdValid(objShip))
|
|
{
|
|
hue.setColor(objShip, index, idx);
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
setObjVar(self, "ship_customization.usedOne", 1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
}
|
|
if (getIntObjVar(self, "ship_customization.usedOne") == 1 && getIntObjVar(self, "ship_customization.usedTwo") == 1)
|
|
{
|
|
destroyObject(self);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleSecondColorize()
|
|
{
|
|
int idx = sui.getColorPickerIndex(params);
|
|
int bp = sui.getIntButtonPressed(params);
|
|
obj_id player = sui.getPlayerId(params);
|
|
if ( bp == sui.BP_CANCEL )
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
obj_id objShip = utils.getObjIdScriptVar(player, "color.shipId");
|
|
utils.removeScriptVar(player, "color.shipId");
|
|
string index = "/shared_owner/index_color_2";
|
|
if ( idx > -1 )
|
|
{
|
|
if (isIdValid(objShip))
|
|
{
|
|
hue.setColor(objShip, index, idx);
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
setObjVar(self, "ship_customization.usedTwo", 1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
}
|
|
if (getIntObjVar(self, "ship_customization.usedOne") == 1 && getIntObjVar(self, "ship_customization.usedTwo") == 1)
|
|
{
|
|
destroyObject(self);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
} |