Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOJSVisualEffect.m File Reference
+ Include dependency graph for OOJSVisualEffect.m:

Go to the source code of this file.

Macros

#define GET_THIS_EFFECT(THISENT)
 

Enumerations

enum  {
  kVisualEffect_beaconCode , kVisualEffect_beaconLabel , kVisualEffect_dataKey , kVisualEffect_hullHeatLevel ,
  kVisualEffect_isBreakPattern , kVisualEffect_scaleX , kVisualEffect_scaleY , kVisualEffect_scaleZ ,
  kVisualEffect_scannerDisplayColor1 , kVisualEffect_scannerDisplayColor2 , kVisualEffect_script , kVisualEffect_scriptInfo ,
  kVisualEffect_shaderFloat1 , kVisualEffect_shaderFloat2 , kVisualEffect_shaderInt1 , kVisualEffect_shaderInt2 ,
  kVisualEffect_shaderVector1 , kVisualEffect_shaderVector2 , kVisualEffect_subEntities , kVisualEffect_vectorForward ,
  kVisualEffect_vectorRight , kVisualEffect_vectorUp
}
 

Functions

static BOOL JSVisualEffectGetVisualEffectEntity (JSContext *context, JSObject *stationObj, OOVisualEffectEntity **outEntity)
 
static JSBool VisualEffectGetProperty (JSContext *context, JSObject *this, jsid propID, jsval *value)
 
static JSBool VisualEffectSetProperty (JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
 
static JSBool VisualEffectRemove (JSContext *context, uintN argc, jsval *vp)
 
static JSBool VisualEffectGetShaders (JSContext *context, uintN argc, jsval *vp)
 
static JSBool VisualEffectSetShaders (JSContext *context, uintN argc, jsval *vp)
 
static JSBool VisualEffectGetMaterials (JSContext *context, uintN argc, jsval *vp)
 
static JSBool VisualEffectSetMaterials (JSContext *context, uintN argc, jsval *vp)
 
static JSBool VisualEffectScale (JSContext *context, uintN argc, jsval *vp)
 
static JSBool VisualEffectRestoreSubEntities (JSContext *context, uintN argc, jsval *vp)
 
static JSBool VisualEffectSetMaterialsInternal (JSContext *context, uintN argc, jsval *vp, OOVisualEffectEntity *thisEnt, BOOL fromShaders)
 
void InitOOJSVisualEffect (JSContext *context, JSObject *global)
 

Variables

static JSObject * sVisualEffectPrototype
 
static JSClass sVisualEffectClass
 
static JSPropertySpec sVisualEffectProperties []
 
static JSFunctionSpec sVisualEffectMethods []
 

Macro Definition Documentation

◆ GET_THIS_EFFECT

#define GET_THIS_EFFECT ( THISENT)
Value:
do { \
if (EXPECT_NOT(!JSVisualEffectGetVisualEffectEntity(context, OOJS_THIS, &THISENT))) return NO; /* Exception */ \
} while (0)
#define EXPECT_NOT(x)
OOINLINE BOOL OOIsStaleEntity(Entity *entity)
Definition OOJSEntity.h:71
static BOOL JSVisualEffectGetVisualEffectEntity(JSContext *context, JSObject *stationObj, OOVisualEffectEntity **outEntity)
#define OOJS_THIS
#define OOJS_RETURN_VOID

Definition at line 492 of file OOJSVisualEffect.m.

492#define GET_THIS_EFFECT(THISENT) do { \
493 if (EXPECT_NOT(!JSVisualEffectGetVisualEffectEntity(context, OOJS_THIS, &THISENT))) return NO; /* Exception */ \
494 if (OOIsStaleEntity(THISENT)) OOJS_RETURN_VOID; \
495} while (0)

Referenced by OOVisualEffectEntity(OOJavaScriptExtensions)::getJSClass:andPrototype:, VisualEffectGetMaterials(), VisualEffectGetShaders(), VisualEffectRemove(), VisualEffectScale(), VisualEffectSetMaterials(), VisualEffectSetMaterialsInternal(), and VisualEffectSetShaders().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kVisualEffect_beaconCode 
kVisualEffect_beaconLabel 
kVisualEffect_dataKey 
kVisualEffect_hullHeatLevel 
kVisualEffect_isBreakPattern 
kVisualEffect_scaleX 
kVisualEffect_scaleY 
kVisualEffect_scaleZ 
kVisualEffect_scannerDisplayColor1 
kVisualEffect_scannerDisplayColor2 
kVisualEffect_script 
kVisualEffect_scriptInfo 
kVisualEffect_shaderFloat1 
kVisualEffect_shaderFloat2 
kVisualEffect_shaderInt1 
kVisualEffect_shaderInt2 
kVisualEffect_shaderVector1 
kVisualEffect_shaderVector2 
kVisualEffect_subEntities 
kVisualEffect_vectorForward 
kVisualEffect_vectorRight 
kVisualEffect_vectorUp 

Definition at line 71 of file OOJSVisualEffect.m.

72{
73 // Property IDs
96};
@ kVisualEffect_isBreakPattern
@ kVisualEffect_vectorUp
@ kVisualEffect_shaderFloat1
@ kVisualEffect_beaconCode
@ kVisualEffect_hullHeatLevel
@ kVisualEffect_scannerDisplayColor2
@ kVisualEffect_scannerDisplayColor1
@ kVisualEffect_beaconLabel
@ kVisualEffect_vectorRight
@ kVisualEffect_subEntities
@ kVisualEffect_shaderFloat2
@ kVisualEffect_scaleY
@ kVisualEffect_scaleZ
@ kVisualEffect_script
@ kVisualEffect_dataKey
@ kVisualEffect_scriptInfo
@ kVisualEffect_shaderInt1
@ kVisualEffect_shaderVector1
@ kVisualEffect_vectorForward
@ kVisualEffect_shaderInt2
@ kVisualEffect_scaleX
@ kVisualEffect_shaderVector2

Function Documentation

◆ InitOOJSVisualEffect()

void InitOOJSVisualEffect ( JSContext * context,
JSObject * global )

Definition at line 143 of file OOJSVisualEffect.m.

144{
148}
OOINLINE JSClass * JSEntityClass(void)
Definition OOJSEntity.h:42
OOINLINE JSObject * JSEntityPrototype(void)
Definition OOJSEntity.h:43
static JSFunctionSpec sVisualEffectMethods[]
static JSObject * sVisualEffectPrototype
static JSClass sVisualEffectClass
static JSPropertySpec sVisualEffectProperties[]
void OOJSRegisterObjectConverter(JSClass *theClass, OOJSClassConverterCallback converter)
JSBool OOJSUnconstructableConstruct(JSContext *context, uintN argc, jsval *vp)
void OOJSRegisterSubclass(JSClass *subclass, JSClass *superclass)
id OOJSBasicPrivateObjectConverter(JSContext *context, JSObject *object)

References JSEntityClass(), JSEntityPrototype(), OOJSBasicPrivateObjectConverter(), OOJSRegisterObjectConverter(), OOJSRegisterSubclass(), OOJSUnconstructableConstruct(), sVisualEffectClass, sVisualEffectMethods, sVisualEffectProperties, and sVisualEffectPrototype.

+ Here is the call graph for this function:

◆ JSVisualEffectGetVisualEffectEntity()

static BOOL JSVisualEffectGetVisualEffectEntity ( JSContext * context,
JSObject * stationObj,
OOVisualEffectEntity ** outEntity )
static

Definition at line 151 of file OOJSVisualEffect.m.

152{
154
155 BOOL result;
156 Entity *entity = nil;
157
158 if (outEntity == NULL) return NO;
159 *outEntity = nil;
160
161 result = OOJSEntityGetEntity(context, visualEffectObj, &entity);
162 if (!result) return NO;
163
164 if (![entity isKindOfClass:[OOVisualEffectEntity class]]) return NO;
165
166 *outEntity = (OOVisualEffectEntity *)entity;
167 return YES;
168
170}
#define OOJS_PROFILE_EXIT
#define OOJS_PROFILE_ENTER
return nil

References nil, OOJS_PROFILE_ENTER, and OOJS_PROFILE_EXIT.

Referenced by VisualEffectGetProperty(), and VisualEffectSetProperty().

+ Here is the caller graph for this function:

◆ VisualEffectGetMaterials()

static JSBool VisualEffectGetMaterials ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 522 of file OOJSVisualEffect.m.

523{
525
526 NSObject *result = nil;
527 OOVisualEffectEntity *thisEnt = nil;
528
529 GET_THIS_EFFECT(thisEnt);
530
531 result = [[thisEnt mesh] materials];
532 if (result == nil) result = [NSDictionary dictionary];
533 OOJS_RETURN_OBJECT(result);
534
536}
#define GET_THIS_EFFECT(THISENT)
#define OOJS_RETURN_OBJECT(o)
OOMaterial * materials[kOOMeshMaxMaterials]
Definition OOMesh.h:115

References GET_THIS_EFFECT, OOMesh::materials, OOVisualEffectEntity::mesh, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, and OOJS_RETURN_OBJECT.

+ Here is the call graph for this function:

◆ VisualEffectGetProperty()

static JSBool VisualEffectGetProperty ( JSContext * context,
JSObject * this,
jsid propID,
jsval * value )
static

Definition at line 200 of file OOJSVisualEffect.m.

201{
202 if (!JSID_IS_INT(propID)) return YES;
203
204 OOJS_NATIVE_ENTER(context)
205
206 OOVisualEffectEntity *entity = nil;
207 id result = nil;
208
209 if (!JSVisualEffectGetVisualEffectEntity(context, this, &entity)) return NO;
210 if (entity == nil) { *value = JSVAL_VOID; return YES; }
211
212 switch (JSID_TO_INT(propID))
213 {
215 result = [entity beaconCode];
216 break;
217
219 result = [entity beaconLabel];
220 break;
221
223 result = [entity effectKey];
224 break;
225
227 *value = OOJSValueFromBOOL([entity isBreakPattern]);
228
229 return YES;
230
232 return VectorToJSValue(context, [entity rightVector], value);
233
235 return VectorToJSValue(context, [entity forwardVector], value);
236
238 return VectorToJSValue(context, [entity upVector], value);
239
241 return JS_NewNumberValue(context, [entity scaleX], value);
242
244 return JS_NewNumberValue(context, [entity scaleY], value);
245
247 return JS_NewNumberValue(context, [entity scaleZ], value);
248
250 result = [[entity scannerDisplayColor1] normalizedArray];
251 break;
252
254 result = [[entity scannerDisplayColor2] normalizedArray];
255 break;
256
258 return JS_NewNumberValue(context, [entity hullHeatLevel], value);
259
261 return JS_NewNumberValue(context, [entity shaderFloat1], value);
262
264 return JS_NewNumberValue(context, [entity shaderFloat2], value);
265
267 *value = INT_TO_JSVAL([entity shaderInt1]);
268 return YES;
269
271 *value = INT_TO_JSVAL([entity shaderInt2]);
272 return YES;
273
275 return VectorToJSValue(context, [entity shaderVector1], value);
276
278 return VectorToJSValue(context, [entity shaderVector2], value);
279
281 result = [entity subEntitiesForScript];
282 break;
283
284
286 result = [entity script];
287 break;
288
290 result = [entity scriptInfo];
291 if (result == nil) result = [NSDictionary dictionary]; // empty rather than null
292 break;
293
294 default:
296 return NO;
297 }
298
299 *value = OOJSValueFromNativeObject(context, result);
300 return YES;
301
303}
#define OOJS_NATIVE_ENTER(cx)
#define OOJS_NATIVE_EXIT
BOOL VectorToJSValue(JSContext *context, Vector vector, jsval *outValue) NONNULL_FUNC
Definition OOJSVector.m:185
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
OOINLINE jsval OOJSValueFromBOOL(int b) INLINE_CONST_FUNC
NSArray * normalizedArray()
Definition OOColor.m:511

References OOVisualEffectEntity::beaconCode, OOVisualEffectEntity::beaconLabel, OOVisualEffectEntity::effectKey, JSVisualEffectGetVisualEffectEntity(), kVisualEffect_beaconCode, kVisualEffect_beaconLabel, kVisualEffect_dataKey, kVisualEffect_hullHeatLevel, kVisualEffect_isBreakPattern, kVisualEffect_scaleX, kVisualEffect_scaleY, kVisualEffect_scaleZ, kVisualEffect_scannerDisplayColor1, kVisualEffect_scannerDisplayColor2, kVisualEffect_script, kVisualEffect_scriptInfo, kVisualEffect_shaderFloat1, kVisualEffect_shaderFloat2, kVisualEffect_shaderInt1, kVisualEffect_shaderInt2, kVisualEffect_shaderVector1, kVisualEffect_shaderVector2, kVisualEffect_subEntities, kVisualEffect_vectorForward, kVisualEffect_vectorRight, kVisualEffect_vectorUp, nil, OOColor::normalizedArray, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadPropertySelector(), OOJSValueFromBOOL(), OOJSValueFromNativeObject(), OOVisualEffectEntity::scannerDisplayColor1, OOVisualEffectEntity::scannerDisplayColor2, OOVisualEffectEntity::script, OOVisualEffectEntity::scriptInfo, OOVisualEffectEntity::subEntitiesForScript, sVisualEffectProperties, and VectorToJSValue().

+ Here is the call graph for this function:

◆ VisualEffectGetShaders()

static JSBool VisualEffectGetShaders ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 539 of file OOJSVisualEffect.m.

540{
542
543 NSObject *result = nil;
544 OOVisualEffectEntity *thisEnt = nil;
545
546 GET_THIS_EFFECT(thisEnt);
547
548 result = [[thisEnt mesh] shaders];
549 if (result == nil) result = [NSDictionary dictionary];
550 OOJS_RETURN_OBJECT(result);
551
553}
NSDictionary * shaders()
Definition OOMesh.m:617

References GET_THIS_EFFECT, OOVisualEffectEntity::mesh, nil, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_OBJECT, and OOMesh::shaders.

+ Here is the call graph for this function:

◆ VisualEffectRemove()

static JSBool VisualEffectRemove ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 498 of file OOJSVisualEffect.m.

499{
500 OOJS_NATIVE_ENTER(context)
501
502 OOVisualEffectEntity *thisEnt = nil;
503 GET_THIS_EFFECT(thisEnt);
504
505 if ([thisEnt isSubEntity])
506 {
507 OOVisualEffectEntity *parent = [thisEnt owner];
508 [parent removeSubEntity:thisEnt];
509 }
510 else
511 {
512 [thisEnt remove];
513 }
514
516
518}
id owner()
Definition Entity.m:583
void removeSubEntity:(Entity< OOSubEntity > *sub)

References GET_THIS_EFFECT, nil, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, Entity::owner, OOVisualEffectEntity::remove, and OOVisualEffectEntity::removeSubEntity:.

+ Here is the call graph for this function:

◆ VisualEffectRestoreSubEntities()

static JSBool VisualEffectRestoreSubEntities ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 718 of file OOJSVisualEffect.m.

719{
720 OOJS_NATIVE_ENTER(context)
721
722 OOVisualEffectEntity *thisEnt = nil;
723 NSUInteger numSubEntitiesRestored = 0U;
724
725 GET_THIS_EFFECT(thisEnt);
726
727 NSUInteger subCount = [[thisEnt subEntitiesForScript] count];
728
729 [thisEnt clearSubEntities];
730 [thisEnt setUpSubEntities];
731
732 if ([[thisEnt subEntitiesForScript] count] - subCount > 0) numSubEntitiesRestored = [[thisEnt subEntitiesForScript] count] - subCount;
733
734 OOJS_RETURN_BOOL(numSubEntitiesRestored > 0);
735
737}
#define OOJS_RETURN_BOOL(v)
unsigned count

◆ VisualEffectScale()

static JSBool VisualEffectScale ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 684 of file OOJSVisualEffect.m.

685{
686 OOJS_NATIVE_ENTER(context)
687
688 OOVisualEffectEntity *thisEnt = nil;
689 GET_THIS_EFFECT(thisEnt);
690 jsdouble scale;
691 BOOL gotScale;
692
693 if (argc < 1)
694 {
695 OOJSReportBadArguments(context, @"VisualEffect", @"scale", argc, OOJS_ARGV, nil, @"scale factor needed");
696 return NO;
697 }
698
699 gotScale = JS_ValueToNumber(context, OOJS_ARGV[0], &scale);
700 if (EXPECT_NOT(scale <= 0.0 || !gotScale))
701 {
702 OOJSReportBadArguments(context, @"VisualEffect", @"scale", argc, OOJS_ARGV, nil, @"scale factor must be positive");
703 return NO;
704 }
705
706 // set all three scales
707 [thisEnt setScaleX:scale];
708 [thisEnt setScaleY:scale];
709 [thisEnt setScaleZ:scale];
710
711 return YES;
713
714}
#define OOJS_ARGV
void OOJSReportBadArguments(JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, NSString *message, NSString *expectedArgsDescription)
void setScaleZ:(GLfloat factor)
void setScaleY:(GLfloat factor)
void setScaleX:(GLfloat factor)

References EXPECT_NOT, GET_THIS_EFFECT, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadArguments(), OOVisualEffectEntity::setScaleX:, OOVisualEffectEntity::setScaleY:, and OOVisualEffectEntity::setScaleZ:.

+ Here is the call graph for this function:

◆ VisualEffectSetMaterials()

static JSBool VisualEffectSetMaterials ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 557 of file OOJSVisualEffect.m.

558{
559 OOJS_NATIVE_ENTER(context)
560
561 OOVisualEffectEntity *thisEnt = nil;
562
563 if (argc < 1)
564 {
565 OOJSReportBadArguments(context, @"VisualEffect", @"setMaterials", 0, OOJS_ARGV, nil, @"parameter object");
566 return NO;
567 }
568
569 GET_THIS_EFFECT(thisEnt);
570
571 return VisualEffectSetMaterialsInternal(context, argc, vp, thisEnt, NO);
572
574}
static JSBool VisualEffectSetMaterialsInternal(JSContext *context, uintN argc, jsval *vp, OOVisualEffectEntity *thisEnt, BOOL fromShaders)

References GET_THIS_EFFECT, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadArguments(), and VisualEffectSetMaterialsInternal().

+ Here is the call graph for this function:

◆ VisualEffectSetMaterialsInternal()

static JSBool VisualEffectSetMaterialsInternal ( JSContext * context,
uintN argc,
jsval * vp,
OOVisualEffectEntity * thisEnt,
BOOL fromShaders )
static

Definition at line 611 of file OOJSVisualEffect.m.

612{
614
615 JSObject *params = NULL;
616 NSDictionary *materials;
617 NSDictionary *shaders;
618 BOOL withShaders = NO;
619 BOOL success = NO;
620
621 GET_THIS_EFFECT(thisEnt);
622
623 if (JSVAL_IS_NULL(OOJS_ARGV[0]) || (!JSVAL_IS_NULL(OOJS_ARGV[0]) && !JSVAL_IS_OBJECT(OOJS_ARGV[0])))
624 {
625 OOJSReportWarning(context, @"VisualEffect.%@: expected %@ instead of '%@'.", @"setMaterials", @"object", OOStringFromJSValueEvenIfNull(context, OOJS_ARGV[0]));
627 }
628
629 if (argc > 1)
630 {
631 withShaders = YES;
632 if (JSVAL_IS_NULL(OOJS_ARGV[1]) || (!JSVAL_IS_NULL(OOJS_ARGV[1]) && !JSVAL_IS_OBJECT(OOJS_ARGV[1])))
633 {
634 OOJSReportWarning(context, @"VisualEffect.%@: expected %@ instead of '%@'.", @"setMaterials", @"object as second parameter", OOStringFromJSValueEvenIfNull(context, OOJS_ARGV[1]));
635 withShaders = NO;
636 }
637 }
638
639 if (fromShaders)
640 {
641 materials = [[thisEnt mesh] materials];
642 params = JSVAL_TO_OBJECT(OOJS_ARGV[0]);
643 shaders = OOJSNativeObjectFromJSObject(context, params);
644 }
645 else
646 {
647 params = JSVAL_TO_OBJECT(OOJS_ARGV[0]);
648 materials = OOJSNativeObjectFromJSObject(context, params);
649 if (withShaders)
650 {
651 params = JSVAL_TO_OBJECT(OOJS_ARGV[1]);
652 shaders = OOJSNativeObjectFromJSObject(context, params);
653 }
654 else
655 {
656 shaders = [[thisEnt mesh] shaders];
657 }
658 }
659
661 NSDictionary *effectDict = [thisEnt effectInfoDictionary];
662
663 // First we test to see if we can create the mesh.
664 OOMesh *mesh = [OOMesh meshWithName:[effectDict oo_stringForKey:@"model"]
665 cacheKey:nil
666 materialDictionary:materials
667 shadersDictionary:shaders
668 smooth:[effectDict oo_boolForKey:@"smooth" defaultValue:NO]
669 shaderMacros:[[ResourceManager materialDefaults] oo_dictionaryForKey:@"ship-prefix-macros"]
670 shaderBindingTarget:thisEnt];
671
672 if (mesh != nil)
673 {
674 [thisEnt setMesh:mesh];
675 success = YES;
676 }
678
679 OOJS_RETURN_BOOL(success);
680
682}
#define OOJS_END_FULL_NATIVE
#define OOJS_BEGIN_FULL_NATIVE(context)
void OOJSReportWarning(JSContext *context, NSString *format,...)
id OOJSNativeObjectFromJSObject(JSContext *context, JSObject *object)
NSString * OOStringFromJSValueEvenIfNull(JSContext *context, jsval value)
instancetype meshWithName:cacheKey:materialDictionary:shadersDictionary:smooth:shaderMacros:shaderBindingTarget:(NSString *name,[cacheKey] NSString *cacheKey,[materialDictionary] NSDictionary *materialDict,[shadersDictionary] NSDictionary *shadersDict,[smooth] BOOL smooth,[shaderMacros] NSDictionary *macros,[shaderBindingTarget] id< OOWeakReferenceSupport > object)
Definition OOMesh.m:233
NSDictionary * effectInfoDictionary()
NSDictionary * materialDefaults()

References OOVisualEffectEntity::effectInfoDictionary, GET_THIS_EFFECT, ResourceManager::materialDefaults, OOMesh::materials, OOVisualEffectEntity::mesh, OOMesh::meshWithName:cacheKey:materialDictionary:shadersDictionary:smooth:shaderMacros:shaderBindingTarget:, nil, OOJS_ARGV, OOJS_BEGIN_FULL_NATIVE, OOJS_END_FULL_NATIVE, OOJS_PROFILE_ENTER, OOJS_PROFILE_EXIT, OOJS_RETURN_BOOL, OOJSNativeObjectFromJSObject(), OOJSReportWarning(), OOStringFromJSValueEvenIfNull(), OOVisualEffectEntity::setMesh:, and OOMesh::shaders.

Referenced by VisualEffectSetMaterials(), and VisualEffectSetShaders().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ VisualEffectSetProperty()

static JSBool VisualEffectSetProperty ( JSContext * context,
JSObject * this,
jsid propID,
JSBool strict,
jsval * value )
static

Definition at line 306 of file OOJSVisualEffect.m.

307{
308 if (!JSID_IS_INT(propID)) return YES;
309
310 OOJS_NATIVE_ENTER(context)
311
312 OOVisualEffectEntity *entity = nil;
313 JSBool bValue;
314 OOColor *colorForScript;
315 int32 iValue;
316 jsdouble fValue;
317 Vector vValue;
318 NSString *sValue = nil;
319
320
321 if (!JSVisualEffectGetVisualEffectEntity(context, this, &entity)) return NO;
322 if (entity == nil) return YES;
323
324 switch (JSID_TO_INT(propID))
325 {
327 sValue = OOStringFromJSValue(context,*value);
328 if (sValue == nil || [sValue length] == 0)
329 {
330 if ([entity isBeacon])
331 {
332 [UNIVERSE clearBeacon:entity];
333 if ([PLAYER nextBeacon] == entity)
334 {
335 [PLAYER setCompassMode:COMPASS_MODE_PLANET];
336 }
337 }
338 }
339 else
340 {
341 if ([entity isBeacon])
342 {
343 [entity setBeaconCode:sValue];
344 }
345 else // Universe needs to update beacon lists in this case only
346 {
347 [entity setBeaconCode:sValue];
348 [UNIVERSE setNextBeacon:entity];
349 }
350 }
351 return YES;
352 break;
353
355 sValue = OOStringFromJSValue(context,*value);
356 if (sValue != nil)
357 {
358 [entity setBeaconLabel:sValue];
359 return YES;
360 }
361 break;
362
364 if (JS_ValueToBoolean(context, *value, &bValue))
365 {
366 [entity setIsBreakPattern:bValue];
367 return YES;
368 }
369 break;
370
372 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
373 if (colorForScript != nil || JSVAL_IS_NULL(*value))
374 {
375 [entity setScannerDisplayColor1:colorForScript];
376 return YES;
377 }
378 break;
379
381 colorForScript = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, *value)];
382 if (colorForScript != nil || JSVAL_IS_NULL(*value))
383 {
384 [entity setScannerDisplayColor2:colorForScript];
385 return YES;
386 }
387 break;
388
390 if (JS_ValueToNumber(context, *value, &fValue))
391 {
392 if (fValue > 0.0)
393 {
394 [entity setScaleX:fValue];
395 return YES;
396 }
397 }
398 break;
399
401 if (JS_ValueToNumber(context, *value, &fValue))
402 {
403 if (fValue > 0.0)
404 {
405 [entity setScaleY:fValue];
406 return YES;
407 }
408 }
409 break;
410
412 if (JS_ValueToNumber(context, *value, &fValue))
413 {
414 if (fValue > 0.0)
415 {
416 [entity setScaleZ:fValue];
417 return YES;
418 }
419 }
420 break;
421
423 if (JS_ValueToNumber(context, *value, &fValue))
424 {
425 [entity setHullHeatLevel:fValue];
426 return YES;
427 }
428 break;
429
431 if (JS_ValueToNumber(context, *value, &fValue))
432 {
433 [entity setShaderFloat1:fValue];
434 return YES;
435 }
436 break;
437
439 if (JS_ValueToNumber(context, *value, &fValue))
440 {
441 [entity setShaderFloat2:fValue];
442 return YES;
443 }
444 break;
445
447 if (JS_ValueToInt32(context, *value, &iValue))
448 {
449 [entity setShaderInt1:iValue];
450 return YES;
451 }
452 break;
453
455 if (JS_ValueToInt32(context, *value, &iValue))
456 {
457 [entity setShaderInt2:iValue];
458 return YES;
459 }
460 break;
461
463 if (JSValueToVector(context, *value, &vValue))
464 {
465 [entity setShaderVector1:vValue];
466 return YES;
467 }
468 break;
469
471 if (JSValueToVector(context, *value, &vValue))
472 {
473 [entity setShaderVector2:vValue];
474 return YES;
475 }
476 break;
477
478 default:
480 return NO;
481 }
482
483 OOJSReportBadPropertyValue(context, this, propID, sVisualEffectProperties, *value);
484 return NO;
485
487}
BOOL JSValueToVector(JSContext *context, jsval value, Vector *outVector) NONNULL_FUNC
Definition OOJSVector.m:259
NSString * OOStringFromJSValue(JSContext *context, jsval value)
void OOJSReportBadPropertyValue(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec, jsval value)
#define PLAYER
OOColor * colorWithDescription:(id description)
Definition OOColor.m:127
void setShaderVector2:(Vector value)
void setShaderVector1:(Vector value)
void setScannerDisplayColor1:(OOColor *color)
void setShaderFloat2:(GLfloat value)
void setScannerDisplayColor2:(OOColor *color)
void setBeaconLabel:(NSString *blabel)
void setShaderFloat1:(GLfloat value)
void setHullHeatLevel:(GLfloat value)
void setBeaconCode:(NSString *bcode)

References OOColor::colorWithDescription:, JSValueToVector(), JSVisualEffectGetVisualEffectEntity(), kVisualEffect_beaconCode, kVisualEffect_beaconLabel, kVisualEffect_hullHeatLevel, kVisualEffect_isBreakPattern, kVisualEffect_scaleX, kVisualEffect_scaleY, kVisualEffect_scaleZ, kVisualEffect_scannerDisplayColor1, kVisualEffect_scannerDisplayColor2, kVisualEffect_shaderFloat1, kVisualEffect_shaderFloat2, kVisualEffect_shaderInt1, kVisualEffect_shaderInt2, kVisualEffect_shaderVector1, kVisualEffect_shaderVector2, nil, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadPropertySelector(), OOJSReportBadPropertyValue(), OOStringFromJSValue(), PLAYER, OOVisualEffectEntity::setBeaconCode:, OOVisualEffectEntity::setBeaconLabel:, OOVisualEffectEntity::setHullHeatLevel:, OOVisualEffectEntity::setIsBreakPattern:, OOVisualEffectEntity::setScaleX:, OOVisualEffectEntity::setScaleY:, OOVisualEffectEntity::setScaleZ:, OOVisualEffectEntity::setScannerDisplayColor1:, OOVisualEffectEntity::setScannerDisplayColor2:, OOVisualEffectEntity::setShaderFloat1:, OOVisualEffectEntity::setShaderFloat2:, OOVisualEffectEntity::setShaderInt1:, OOVisualEffectEntity::setShaderInt2:, OOVisualEffectEntity::setShaderVector1:, OOVisualEffectEntity::setShaderVector2:, and sVisualEffectProperties.

+ Here is the call graph for this function:

◆ VisualEffectSetShaders()

static JSBool VisualEffectSetShaders ( JSContext * context,
uintN argc,
jsval * vp )
static

Definition at line 578 of file OOJSVisualEffect.m.

579{
580 OOJS_NATIVE_ENTER(context)
581
582 OOVisualEffectEntity *thisEnt = nil;
583
584 GET_THIS_EFFECT(thisEnt);
585
586 if (argc < 1)
587 {
588 OOJSReportBadArguments(context, @"VisualEffect", @"setShaders", 0, OOJS_ARGV, nil, @"parameter object");
589 return NO;
590 }
591
592 if (JSVAL_IS_NULL(OOJS_ARGV[0]) || (!JSVAL_IS_NULL(OOJS_ARGV[0]) && !JSVAL_IS_OBJECT(OOJS_ARGV[0])))
593 {
594 // EMMSTRAN: JS_ValueToObject() and normal error handling here.
595 OOJSReportWarning(context, @"VisualEffect.%@: expected %@ instead of '%@'.", @"setShaders", @"object", OOStringFromJSValueEvenIfNull(context, OOJS_ARGV[0]));
597 }
598
599 OOJS_ARGV[1] = OOJS_ARGV[0];
600 return VisualEffectSetMaterialsInternal(context, argc, vp, thisEnt, YES);
601
603}

References GET_THIS_EFFECT, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOJSReportWarning(), OOStringFromJSValueEvenIfNull(), and VisualEffectSetMaterialsInternal().

+ Here is the call graph for this function:

Variable Documentation

◆ sVisualEffectClass

JSClass sVisualEffectClass
static
Initial value:
=
{
"VisualEffect",
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
JSCLASS_NO_OPTIONAL_MEMBERS
}
static JSBool VisualEffectGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
static JSBool VisualEffectSetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)

Definition at line 54 of file OOJSVisualEffect.m.

55{
56 "VisualEffect",
57 JSCLASS_HAS_PRIVATE,
58
59 JS_PropertyStub, // addProperty
60 JS_PropertyStub, // delProperty
61 VisualEffectGetProperty, // getProperty
62 VisualEffectSetProperty, // setProperty
63 JS_EnumerateStub, // enumerate
64 JS_ResolveStub, // resolve
65 JS_ConvertStub, // convert
67 JSCLASS_NO_OPTIONAL_MEMBERS
68};

Referenced by InitOOJSVisualEffect().

◆ sVisualEffectMethods

JSFunctionSpec sVisualEffectMethods[]
static
Initial value:
=
{
{ "getMaterials", VisualEffectGetMaterials, 0 },
{ "getShaders", VisualEffectGetShaders, 0 },
{ "remove", VisualEffectRemove, 0 },
{ "restoreSubEntities", VisualEffectRestoreSubEntities, 0 },
{ "scale", VisualEffectScale, 1 },
{ "setMaterials", VisualEffectSetMaterials, 1 },
{ "setShaders", VisualEffectSetShaders, 2 },
{ 0 }
}
static JSBool VisualEffectRemove(JSContext *context, uintN argc, jsval *vp)
static JSBool VisualEffectRestoreSubEntities(JSContext *context, uintN argc, jsval *vp)
static JSBool VisualEffectSetMaterials(JSContext *context, uintN argc, jsval *vp)
static JSBool VisualEffectScale(JSContext *context, uintN argc, jsval *vp)
static JSBool VisualEffectGetMaterials(JSContext *context, uintN argc, jsval *vp)
static JSBool VisualEffectSetShaders(JSContext *context, uintN argc, jsval *vp)
static JSBool VisualEffectGetShaders(JSContext *context, uintN argc, jsval *vp)

Definition at line 128 of file OOJSVisualEffect.m.

129{
130 // JS name Function min args
131 { "getMaterials", VisualEffectGetMaterials, 0 },
132 { "getShaders", VisualEffectGetShaders, 0 },
133 { "remove", VisualEffectRemove, 0 },
134 { "restoreSubEntities", VisualEffectRestoreSubEntities, 0 },
135 { "scale", VisualEffectScale, 1 },
136 { "setMaterials", VisualEffectSetMaterials, 1 },
137 { "setShaders", VisualEffectSetShaders, 2 },
138
139 { 0 }
140};

Referenced by InitOOJSVisualEffect().

◆ sVisualEffectProperties

JSPropertySpec sVisualEffectProperties[]
static
Initial value:
=
{
{ 0 }
}
#define OOJS_PROP_READWRITE_CB
#define OOJS_PROP_READONLY_CB

Definition at line 99 of file OOJSVisualEffect.m.

100{
101 // JS name ID flags
124 { 0 }
125};

Referenced by InitOOJSVisualEffect(), VisualEffectGetProperty(), and VisualEffectSetProperty().

◆ sVisualEffectPrototype

JSObject* sVisualEffectPrototype
static

Definition at line 35 of file OOJSVisualEffect.m.

Referenced by InitOOJSVisualEffect().