mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
204 lines
5.1 KiB
Plaintext
204 lines
5.1 KiB
Plaintext
include library.utils;
|
|
include library.hue;
|
|
include library.sui;
|
|
include library.space_utils;
|
|
include library.space_transition;
|
|
|
|
|
|
const string STF = "texture_kit";
|
|
|
|
const string_id MNU_TEXTURE = new string_id("sui", "set_texture");
|
|
|
|
const string BTN_TEXTURE = "@" + STF + ":btn_texture";
|
|
const string PICK_A_SHIP_TITLE = "@" + STF + ":pick_a_ship_title";
|
|
const string PICK_A_SHIP = "@" + STF + ":pick_a_ship";
|
|
|
|
|
|
trigger OnAttach()
|
|
{
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnObjectMenuRequest(obj_id player, menu_info mi)
|
|
{
|
|
if ( !utils.isNestedWithin(self, player) )
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int mnuTexture = mi.addRootMenu(menu_info_types.SERVER_MENU1, MNU_TEXTURE);
|
|
if ( mnuTexture > -1 && (( getContainedBy(self) != getOwner(self) ) || isGod(player)) )
|
|
{
|
|
string template = utils.getTemplateFilenameNoPath(self);
|
|
}
|
|
|
|
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_MENU1 )
|
|
{
|
|
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)
|
|
{
|
|
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.isShipTextureable(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]);
|
|
}
|
|
}
|
|
|
|
//check to see if player has any ships
|
|
if (validControlDevices != null && validControlDevices.length > 0)
|
|
{
|
|
int pid = sui.listbox(self, player, PICK_A_SHIP, sui.OK_CANCEL, PICK_A_SHIP_TITLE, entries, "handleTextureShip", false, false);
|
|
|
|
if(pid > -1) {
|
|
|
|
utils.setScriptVar(player, "texture.scds", validControlDevices);
|
|
// Rename some buttons and show the sui
|
|
setSUIProperty(pid, sui.LISTBOX_BTN_OK, sui.PROP_TEXT, BTN_TEXTURE);
|
|
showSUIPage(pid);
|
|
|
|
}
|
|
else
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string_id message = new string_id(STF, "ships_not_paintable");
|
|
sendSystemMessage(player, message);
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
}
|
|
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler handleTextureShip()
|
|
{
|
|
obj_id player = sui.getPlayerId(params);
|
|
|
|
int texture = getIntObjVar(self, "texture_style");
|
|
|
|
int idx = sui.getListboxSelectedRow(params);
|
|
int bp = sui.getIntButtonPressed(params);
|
|
|
|
if (idx < 0 || idx > 5)
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if (bp == sui.BP_CANCEL)
|
|
{
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
obj_id[] devices = utils.getObjIdArrayScriptVar(player, "texture.scds");
|
|
utils.removeScriptVar(player, "texture.scds");
|
|
|
|
obj_id shipId = space_transition.getShipFromShipControlDevice(devices[idx]);
|
|
|
|
if (!isIdValid(shipId))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
string chassis = getShipChassisType(shipId);
|
|
|
|
if (!space_utils.isShipTextureable(shipId))
|
|
{
|
|
string_id message = new string_id(STF, "imperial");
|
|
sendSystemMessage(player, message);
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
if (hasObjVar(self, "texture_ship"))
|
|
{
|
|
string ship = getStringObjVar(self, "texture_ship");
|
|
|
|
if(ship.equals(chassis) || (ship.equals("player_xwing") && chassis.equals("player_advanced_xwing")))
|
|
{
|
|
if (utils.getContainingPlayer(shipId) == player && isIdValid(shipId))
|
|
{
|
|
string index = "/shared_owner/index_texture_1";
|
|
|
|
hue.setRangedIntCustomVar(shipId, index, texture);
|
|
string_id message = new string_id(STF, "changed_paint_job");
|
|
sendSystemMessage(player, message);
|
|
destroyObject(self);
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
else
|
|
{
|
|
string_id message = new string_id(STF, "cantpaint");
|
|
sendSystemMessage(player, message);
|
|
utils.removeScriptVar(self, "paint_kit.inuse");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
}
|
|
|
|
if (utils.getContainingPlayer(shipId) == player && isIdValid(shipId))
|
|
{
|
|
string index = "/shared_owner/index_texture_1";
|
|
|
|
if(chassis.equals("player_yt2400"))
|
|
{
|
|
index = "/private/index_texture_1";
|
|
}
|
|
|
|
hue.setRangedIntCustomVar(shipId, index, texture);
|
|
string_id message = new string_id(STF, "changed_paint_job");
|
|
sendSystemMessage(player, message);
|
|
destroyObject(self);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
|