Add hostile scanner display colours

ship.scannerHostileDisplayColor1, ship.scannerHostileDisplayColor2
or shipdata.plist
scanner_hostile_display_color1, scanner_hostile_display_color2
This commit is contained in:
cim 2015-01-12 20:00:14 +00:00
parent 6b6502c3b1
commit 0ba0363db5
4 changed files with 108 additions and 4 deletions

View File

@ -230,6 +230,8 @@ typedef enum
OOColor *exhaust_emissive_color;
OOColor *scanner_display_color1;
OOColor *scanner_display_color2;
OOColor *scanner_display_color_hostile1;
OOColor *scanner_display_color_hostile2;
// per ship-type variables
//
@ -709,11 +711,15 @@ typedef enum
- (void) updateTrackingCurve;
- (void) calculateTrackingCurve;
- (GLfloat *) scannerDisplayColorForShip:(ShipEntity*)otherShip :(BOOL)isHostile :(BOOL)flash :(OOColor *)scannerDisplayColor1 :(OOColor *)scannerDisplayColor2;
- (GLfloat *) scannerDisplayColorForShip:(ShipEntity*)otherShip :(BOOL)isHostile :(BOOL)flash :(OOColor *)scannerDisplayColor1 :(OOColor *)scannerDisplayColor2 :(OOColor *)scannerDisplayColorH1 :(OOColor *)scannerDisplayColorH2;
- (void)setScannerDisplayColor1:(OOColor *)color1;
- (void)setScannerDisplayColor2:(OOColor *)color2;
- (OOColor *)scannerDisplayColor1;
- (OOColor *)scannerDisplayColor2;
- (void)setScannerDisplayColorHostile1:(OOColor *)color1;
- (void)setScannerDisplayColorHostile2:(OOColor *)color2;
- (OOColor *)scannerDisplayColorHostile1;
- (OOColor *)scannerDisplayColorHostile2;
- (BOOL)isCloaked;
- (void)setCloaked:(BOOL)cloak;

View File

@ -639,6 +639,10 @@ static ShipEntity *doOctreesCollide(ShipEntity *prime, ShipEntity *other);
// these are the colors used for the "lollipop" of the ship. Any of the two (or both, for flash effect) can be defined. nil means use default from shipData.
[self setScannerDisplayColor1:nil];
[self setScannerDisplayColor2:nil];
// and the same for the "hostile" colours
[self setScannerDisplayColorHostile1:nil];
[self setScannerDisplayColorHostile2:nil];
// Populate the missiles here. Must come after scanClass.
_missileRole = [shipDict oo_stringForKey:@"missile_role"];
@ -1058,6 +1062,8 @@ static ShipEntity *doOctreesCollide(ShipEntity *prime, ShipEntity *other);
DESTROY(exhaust_emissive_color);
DESTROY(scanner_display_color1);
DESTROY(scanner_display_color2);
DESTROY(scanner_display_color_hostile1);
DESTROY(scanner_display_color_hostile2);
DESTROY(script);
DESTROY(aiScript);
DESTROY(previousCondition);
@ -6353,8 +6359,37 @@ static GLfloat mascem_color1[4] = { 0.3, 0.3, 0.3, 1.0}; // dark gray
static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
static GLfloat scripted_color[4] = { 0.0, 0.0, 0.0, 0.0}; // to be defined by script
- (GLfloat *) scannerDisplayColorForShip:(ShipEntity*)otherShip :(BOOL)isHostile :(BOOL)flash :(OOColor *)scannerDisplayColor1 :(OOColor *)scannerDisplayColor2
- (GLfloat *) scannerDisplayColorForShip:(ShipEntity*)otherShip :(BOOL)isHostile :(BOOL)flash :(OOColor *)scannerDisplayColor1 :(OOColor *)scannerDisplayColor2 :(OOColor *)scannerDisplayColorH1 :(OOColor *)scannerDisplayColorH2
{
if (isHostile)
{
/* if there are any scripted scanner hostile display colours
* for the ship, use them - otherwise fall through to the
* normal scripted colours, then the scan class colours */
if (scannerDisplayColorH1 || scannerDisplayColorH2)
{
if (scannerDisplayColorH1 && !scannerDisplayColorH2)
{
[scannerDisplayColorH1 getRed:&scripted_color[0] green:&scripted_color[1] blue:&scripted_color[2] alpha:&scripted_color[3]];
}
if (!scannerDisplayColorH1 && scannerDisplayColorH2)
{
[scannerDisplayColorH2 getRed:&scripted_color[0] green:&scripted_color[1] blue:&scripted_color[2] alpha:&scripted_color[3]];
}
if (scannerDisplayColorH1 && scannerDisplayColorH2)
{
if (flash)
[scannerDisplayColorH1 getRed:&scripted_color[0] green:&scripted_color[1] blue:&scripted_color[2] alpha:&scripted_color[3]];
else
[scannerDisplayColorH2 getRed:&scripted_color[0] green:&scripted_color[1] blue:&scripted_color[2] alpha:&scripted_color[3]];
}
return scripted_color;
}
}
// if there are any scripted scanner display colors for the ship, use them
if (scannerDisplayColor1 || scannerDisplayColor2)
{
@ -6466,6 +6501,36 @@ static GLfloat scripted_color[4] = { 0.0, 0.0, 0.0, 0.0}; // to be defined by s
}
- (void)setScannerDisplayColorHostile1:(OOColor *)color
{
DESTROY(scanner_display_color_hostile1);
if (color == nil) color = [OOColor colorWithDescription:[[self shipInfoDictionary] objectForKey:@"scanner_hostile_display_color1"]];
scanner_display_color_hostile1 = [color retain];
}
- (void)setScannerDisplayColorHostile2:(OOColor *)color
{
DESTROY(scanner_display_color_hostile2);
if (color == nil) color = [OOColor colorWithDescription:[[self shipInfoDictionary] objectForKey:@"scanner_hostile_display_color2"]];
scanner_display_color_hostile2 = [color retain];
}
- (OOColor *)scannerDisplayColorHostile1
{
return [[scanner_display_color_hostile1 retain] autorelease];
}
- (OOColor *)scannerDisplayColorHostile2
{
return [[scanner_display_color_hostile2 retain] autorelease];
}
- (BOOL)isCloaked
{
return cloaking_device_active;

View File

@ -1262,7 +1262,10 @@ static void prefetchData(NSDictionary *info, struct CachedInfo *data)
{
ShipEntity *ship = (ShipEntity *)scannedEntity;
isHostile = (([ship hasHostileTarget])&&([ship primaryTarget] == PLAYER));
GLfloat *base_col = [ship scannerDisplayColorForShip:PLAYER :isHostile :flash :[ship scannerDisplayColor1] :[ship scannerDisplayColor2]];
GLfloat *base_col = [ship scannerDisplayColorForShip:PLAYER :isHostile :flash
:[ship scannerDisplayColor1] :[ship scannerDisplayColor2]
:[ship scannerDisplayColorHostile1] :[ship scannerDisplayColorHostile2]
];
col[0] = base_col[0]; col[1] = base_col[1]; col[2] = base_col[2]; col[3] = alpha * base_col[3];
}
else if ([scannedEntity isVisualEffect])
@ -3449,7 +3452,7 @@ static void hudDrawReticleOnTarget(Entity *target, PlayerEntity *player1, GLfloa
{
ShipEntity *ship = (ShipEntity *)target;
BOOL isHostile = (([ship hasHostileTarget])&&([ship primaryTarget] == PLAYER));
GLColorWithOverallAlpha([ship scannerDisplayColorForShip:PLAYER :isHostile :flash :[ship scannerDisplayColor1] :[ship scannerDisplayColor2]],alpha);
GLColorWithOverallAlpha([ship scannerDisplayColorForShip:PLAYER :isHostile :flash :[ship scannerDisplayColor1] :[ship scannerDisplayColor2] :[ship scannerDisplayColorHostile1] :[ship scannerDisplayColorHostile2]],alpha);
}
else if ([target isVisualEffect])
{

View File

@ -290,6 +290,8 @@ enum
kShip_scanDescription, // STE scan class label, string, read/write
kShip_scannerDisplayColor1, // color of lollipop shown on scanner, array, read/write
kShip_scannerDisplayColor2, // color of lollipop shown on scanner when flashing, array, read/write
kShip_scannerHostileDisplayColor1, // color of lollipop shown on scanner, array, read/write
kShip_scannerHostileDisplayColor2, // color of lollipop shown on scanner when flashing, array, read/write
kShip_scannerRange, // scanner range, double, read-only
kShip_script, // script, Script, read-only
kShip_scriptedMisjump, // next jump will miss if set to true, boolean, read/write
@ -439,6 +441,8 @@ static JSPropertySpec sShipProperties[] =
{ "scanDescription", kShip_scanDescription, OOJS_PROP_READWRITE_CB },
{ "scannerDisplayColor1", kShip_scannerDisplayColor1, OOJS_PROP_READWRITE_CB },
{ "scannerDisplayColor2", kShip_scannerDisplayColor2, OOJS_PROP_READWRITE_CB },
{ "scannerHostileDisplayColor1", kShip_scannerHostileDisplayColor1, OOJS_PROP_READWRITE_CB },
{ "scannerHostileDisplayColor2", kShip_scannerHostileDisplayColor2, OOJS_PROP_READWRITE_CB },
{ "scannerRange", kShip_scannerRange, OOJS_PROP_READONLY_CB },
{ "script", kShip_script, OOJS_PROP_READONLY_CB },
{ "scriptedMisjump", kShip_scriptedMisjump, OOJS_PROP_READWRITE_CB },
@ -1100,6 +1104,14 @@ static JSBool ShipGetProperty(JSContext *context, JSObject *this, jsid propID, j
case kShip_scannerDisplayColor2:
result = [[entity scannerDisplayColor2] normalizedArray];
break;
case kShip_scannerHostileDisplayColor1:
result = [[entity scannerDisplayColorHostile1] normalizedArray];
break;
case kShip_scannerHostileDisplayColor2:
result = [[entity scannerDisplayColorHostile2] normalizedArray];
break;
case kShip_exhaustEmissiveColor:
result = [[entity exhaustEmissiveColor] normalizedArray];
@ -1566,6 +1578,24 @@ static JSBool ShipSetProperty(JSContext *context, JSObject *this, jsid propID, J
}
break;
case kShip_scannerHostileDisplayColor1:
colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
if (colorForScript != nil || JSVAL_IS_NULL(*value))
{
[entity setScannerDisplayColorHostile1:colorForScript];
return YES;
}
break;
case kShip_scannerHostileDisplayColor2:
colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
if (colorForScript != nil || JSVAL_IS_NULL(*value))
{
[entity setScannerDisplayColorHostile2:colorForScript];
return YES;
}
break;
case kShip_exhaustEmissiveColor:
colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
if (colorForScript != nil || JSVAL_IS_NULL(*value))