Oolite
Loading...
Searching...
No Matches
OOJSGlobal.m File Reference
+ Include dependency graph for OOJSGlobal.m:

Go to the source code of this file.

Enumerations

enum  { kGlobal_galaxyNumber , kGlobal_global , kGlobal_guiScreen , kGlobal_timeAccelerationFactor }
 

Functions

static JSBool GlobalGetProperty (JSContext *context, JSObject *this, jsid propID, jsval *value)
 
static JSBool GlobalSetProperty (JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
 
static JSBool GlobalLog (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalExpandDescription (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalKeyBindingDescription (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalExpandMissionText (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalDisplayNameForCommodity (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalRandomName (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalRandomInhabitantsDescription (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalSetScreenBackground (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalSetScreenOverlay (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalGetScreenBackgroundForKey (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalSetScreenBackgroundForKey (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalAutoAIForRole (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalPauseGame (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalQuitGame (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalGetGuiColorSettingForKey (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalSetGuiColorSettingForKey (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalSetExtraGuiScreenKeys (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalClearExtraGuiScreenKeys (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalTakeSnapShot (JSContext *context, uintN argc, jsval *vp)
 
void CreateOOJSGlobal (JSContext *context, JSObject **outGlobal)
 
void SetUpOOJSGlobal (JSContext *context, JSObject *global)
 

Variables

static NSString *const kOOLogDebugMessage = @"script.debug.message"
 
static JSClass sGlobalClass
 
static JSPropertySpec sGlobalProperties []
 
static JSFunctionSpec sGlobalMethods []
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
kGlobal_galaxyNumber 
kGlobal_global 
kGlobal_guiScreen 
kGlobal_timeAccelerationFactor 

Definition at line 109 of file OOJSGlobal.m.

110{
111 // Property IDs
112 kGlobal_galaxyNumber, // galaxy number, integer, read-only
113 kGlobal_global, // global.global.global.global, integer, read-only
114 kGlobal_guiScreen, // current GUI screen, string, read-only
115#ifndef NDEBUG
116 kGlobal_timeAccelerationFactor // time acceleration, float, read/write
117#endif
118};
@ kGlobal_guiScreen
Definition OOJSGlobal.m:114
@ kGlobal_timeAccelerationFactor
Definition OOJSGlobal.m:116
@ kGlobal_global
Definition OOJSGlobal.m:113
@ kGlobal_galaxyNumber
Definition OOJSGlobal.m:112

Function Documentation

◆ CreateOOJSGlobal()

void CreateOOJSGlobal ( JSContext *  context,
JSObject **  outGlobal 
)

Definition at line 162 of file OOJSGlobal.m.

163{
164 assert(outGlobal != NULL);
165
166 *outGlobal = JS_NewCompartmentAndGlobalObject(context, &sGlobalClass, NULL);
167
168 JS_SetGlobalObject(context, *outGlobal);
169 JS_DefineProperty(context, *outGlobal, "global", OBJECT_TO_JSVAL(*outGlobal), NULL, NULL, OOJS_PROP_READONLY);
170}
static JSClass sGlobalClass
Definition OOJSGlobal.m:88
#define OOJS_PROP_READONLY

References OOJS_PROP_READONLY, and sGlobalClass.

◆ GlobalAutoAIForRole()

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

Definition at line 810 of file OOJSGlobal.m.

811{
812 OOJS_NATIVE_ENTER(context)
813
814 NSString *string = nil;
815
816 if (argc > 0) string = OOStringFromJSValue(context,OOJS_ARGV[0]);
817 if (string == nil)
818 {
819 OOJSReportBadArguments(context, nil, @"autoAIForRole", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
820 return NO;
821 }
822
823 NSDictionary *autoAIMap = [ResourceManager dictionaryFromFilesNamed:@"autoAImap.plist" inFolder:@"Config" andMerge:YES];
824 NSString *autoAI = [autoAIMap oo_stringForKey:string];
825
826 OOJS_RETURN_OBJECT(autoAI);
827
829}
#define OOJS_NATIVE_ENTER(cx)
#define OOJS_NATIVE_EXIT
#define OOJS_RETURN_OBJECT(o)
NSString * OOStringFromJSValue(JSContext *context, jsval value)
#define OOJS_ARGV
void OOJSReportBadArguments(JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, NSString *message, NSString *expectedArgsDescription)
#define MIN(A, B)
Definition OOMaths.h:111
return nil
NSDictionary * dictionaryFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)

References ResourceManager::dictionaryFromFilesNamed:inFolder:andMerge:, MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, OOJSReportBadArguments(), and OOStringFromJSValue().

+ Here is the call graph for this function:

◆ GlobalClearExtraGuiScreenKeys()

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

Definition at line 434 of file OOJSGlobal.m.

435{
436 OOJS_NATIVE_ENTER(context)
437
438 BOOL result = NO;
440
441 if (EXPECT_NOT(argc < 2))
442 {
443 OOJSReportBadArguments(context, nil, @"setExtraGuiScreenKeys", 0, OOJS_ARGV, nil, @"missing arguments");
444 return NO;
445 }
446
447 NSString *key = OOStringFromJSValue(context, OOJS_ARGV[0]);
448 if (EXPECT_NOT(key == nil || [key isEqualToString:@""]))
449 {
450 OOJSReportBadArguments(context, nil, @"clearExtraGuiScreenKeys", 1, OOJS_ARGV, nil, @"key");
451 return NO;
452 }
453
455 if (!gui)
456 {
457 OOJSReportBadArguments(context, nil, @"clearExtraGuiScreenKeys", 0, OOJS_ARGV, nil, @"guiScreen invalid entry");
458 return NO;
459 }
460
461 [player clearExtraGuiScreenKeys:gui key:key];
462
463 result = YES;
464 OOJS_RETURN_BOOL(result);
465
467}
OOINLINE OOGUIScreenID OOGUIScreenIDFromJSValue(JSContext *context, jsval value)
#define EXPECT_NOT(x)
PlayerEntity * OOPlayerForScripting(void)
Definition OOJSPlayer.m:191
#define OOJS_RETURN_BOOL(v)
OOGUIScreenID
void clearExtraGuiScreenKeys:key:(OOGUIScreenID gui,[key] NSString *key)

References PlayerEntity::clearExtraGuiScreenKeys:key:, EXPECT_NOT, nil, OOGUIScreenIDFromJSValue(), OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOPlayerForScripting(), and OOStringFromJSValue().

+ Here is the call graph for this function:

◆ GlobalDisplayNameForCommodity()

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

Definition at line 371 of file OOJSGlobal.m.

372{
373 OOJS_NATIVE_ENTER(context)
374
375 NSString *string = nil;
376
377 if (argc > 0) string = OOStringFromJSValue(context,OOJS_ARGV[0]);
378 if (string == nil)
379 {
380 OOJSReportBadArguments(context, nil, @"displayNameForCommodity", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
381 return NO;
382 }
384
386}
NSString * CommodityDisplayNameForSymbolicName(NSString *symbolicName)

References CommodityDisplayNameForSymbolicName(), MIN, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, OOJSReportBadArguments(), and OOStringFromJSValue().

+ Here is the call graph for this function:

◆ GlobalExpandDescription()

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

Definition at line 291 of file OOJSGlobal.m.

292{
293 OOJS_NATIVE_ENTER(context)
294
295 NSString *string = nil;
296 NSDictionary *overrides = nil;
297
298 if (argc > 0) string = OOStringFromJSValue(context, OOJS_ARGV[0]);
299 if (string == nil)
300 {
301 OOJSReportBadArguments(context, nil, @"expandDescription", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
302 return NO;
303 }
304 if (argc > 1)
305 {
306 overrides = OOJSDictionaryFromStringTable(context, OOJS_ARGV[1]);
307 }
308
312
313 OOJS_RETURN_OBJECT(string);
314
316}
#define OOJS_END_FULL_NATIVE
#define OOJS_BEGIN_FULL_NATIVE(context)
NSDictionary * OOJSDictionaryFromStringTable(JSContext *context, jsval value)
@ kOOExpandForJavaScript
Report warnings through JavaScript runtime system instead of normal logging.
@ kOOExpandGoodRNG
Use RANDROT for selecting from description arrays and for N expansion.
NSString * OOExpandDescriptionString(Random_Seed seed, NSString *string, NSDictionary *overrides, NSDictionary *legacyLocals, NSString *systemName, OOExpandOptions options)
const Random_Seed kNilRandomSeed

References kNilRandomSeed, kOOExpandForJavaScript, kOOExpandGoodRNG, MIN, nil, OOExpandDescriptionString(), OOJS_ARGV, OOJS_BEGIN_FULL_NATIVE, OOJS_END_FULL_NATIVE, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, OOJSDictionaryFromStringTable(), OOJSReportBadArguments(), and OOStringFromJSValue().

+ Here is the call graph for this function:

◆ GlobalExpandMissionText()

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

Definition at line 343 of file OOJSGlobal.m.

344{
345 OOJS_NATIVE_ENTER(context)
346
347 NSString *string = nil;
348 NSDictionary *overrides = nil;
349
350 if (argc > 0) string = OOStringFromJSValue(context, OOJS_ARGV[0]);
351 if (string == nil)
352 {
353 OOJSReportBadArguments(context, nil, @"expandMissionText", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
354 return NO;
355 }
356 if (argc > 1)
357 {
358 overrides = OOJSDictionaryFromStringTable(context, OOJS_ARGV[1]);
359 }
360
361 string = [[UNIVERSE missiontext] oo_stringForKey:string];
363
364 OOJS_RETURN_OBJECT(string);
365
367}
@ kOOExpandBackslashN
Convert literal "\\n"s to line breaks (used for missiontext.plist for historical reasons).

References kNilRandomSeed, kOOExpandBackslashN, kOOExpandForJavaScript, kOOExpandGoodRNG, MIN, nil, OOExpandDescriptionString(), OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, OOJSDictionaryFromStringTable(), OOJSReportBadArguments(), and OOStringFromJSValue().

+ Here is the call graph for this function:

◆ GlobalGetGuiColorSettingForKey()

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

Definition at line 686 of file OOJSGlobal.m.

687{
688 OOJS_NATIVE_ENTER(context)
689
690 if (EXPECT_NOT(argc == 0))
691 {
692 OOJSReportBadArguments(context, nil, @"getGuiColorForKey", 0, OOJS_ARGV, nil, @"missing arguments");
693 return NO;
694 }
695 NSString *key = OOStringFromJSValue(context, OOJS_ARGV[0]);
696 if (EXPECT_NOT(key == nil || [key isEqualToString:@""]))
697 {
698 OOJSReportBadArguments(context, nil, @"getGuiColorForKey", 0, OOJS_ARGV, nil, @"key");
699 return NO;
700 }
701 if ([key rangeOfString:@"color"].location == NSNotFound)
702 {
703 OOJSReportBadArguments(context, nil, @"getGuiColorForKey", 0, OOJS_ARGV, nil, @"valid color key setting");
704 return NO;
705 }
706
707 GuiDisplayGen *gui = [UNIVERSE gui];
708 OOColor *col = [gui colorFromSetting:key defaultValue:nil];
709
710 OOJS_RETURN_OBJECT([col normalizedArray]);
711
713}
OOColor * colorFromSetting:defaultValue:(NSString *setting,[defaultValue] OOColor *def)

References GuiDisplayGen::colorFromSetting:defaultValue:, EXPECT_NOT, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, OOJSReportBadArguments(), and OOStringFromJSValue().

+ Here is the call graph for this function:

◆ GlobalGetProperty()

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

Definition at line 180 of file OOJSGlobal.m.

181{
182 if (!JSID_IS_INT(propID)) return YES;
183
184 OOJS_NATIVE_ENTER(context)
185
187
188 switch (JSID_TO_INT(propID))
189 {
191 *value = INT_TO_JSVAL([player currentGalaxyID]);
192 return YES;
193
195 *value = OOJSValueFromGUIScreenID(context, [player guiScreen]);
196 return YES;
197
198#ifndef NDEBUG
200 return JS_NewNumberValue(context, [UNIVERSE timeAccelerationFactor], value);
201#endif
202
203 default:
204 OOJSReportBadPropertySelector(context, this, propID, sGlobalProperties);
205 return NO;
206 }
207
209}
OOINLINE jsval OOJSValueFromGUIScreenID(JSContext *context, OOGUIScreenID value)
static JSPropertySpec sGlobalProperties[]
Definition OOJSGlobal.m:121
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
#define UNIVERSE
Definition Universe.h:842

References kGlobal_galaxyNumber, kGlobal_guiScreen, kGlobal_timeAccelerationFactor, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadPropertySelector(), OOJSValueFromGUIScreenID(), OOPlayerForScripting(), sGlobalProperties, and UNIVERSE.

+ Here is the call graph for this function:

◆ GlobalGetScreenBackgroundForKey()

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

Definition at line 599 of file OOJSGlobal.m.

600{
601 OOJS_NATIVE_ENTER(context)
602
603 if (EXPECT_NOT(argc == 0))
604 {
605 OOJSReportBadArguments(context, nil, @"getScreenBackgroundDefault", 0, OOJS_ARGV, nil, @"missing arguments");
606 return NO;
607 }
608 NSString *key = OOStringFromJSValue(context, OOJS_ARGV[0]);
609 if (EXPECT_NOT(key == nil || [key isEqualToString:@""]))
610 {
611 OOJSReportBadArguments(context, nil, @"getScreenBackgroundDefault", 0, OOJS_ARGV, nil, @"key");
612 return NO;
613 }
614 NSDictionary *descriptor = [UNIVERSE screenTextureDescriptorForKey:key];
615
616 OOJS_RETURN_OBJECT(descriptor);
617
619}

References EXPECT_NOT, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, OOJSReportBadArguments(), and OOStringFromJSValue().

+ Here is the call graph for this function:

◆ GlobalKeyBindingDescription()

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

Definition at line 318 of file OOJSGlobal.m.

319{
320 OOJS_NATIVE_ENTER(context)
321
322 NSString *string = nil;
324
325 if (argc > 0) string = OOStringFromJSValue(context, OOJS_ARGV[0]);
326 if (string == nil)
327 {
328 OOJSReportBadArguments(context, nil, @"keyBindingDescription", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
329 return NO;
330 }
331
333 string = [player keyBindingDescription2:string];
335
336 OOJS_RETURN_OBJECT(string);
337
339}
NSString * keyBindingDescription2:(NSString *binding)

References PlayerEntity::keyBindingDescription2:, MIN, nil, OOJS_ARGV, OOJS_BEGIN_FULL_NATIVE, OOJS_END_FULL_NATIVE, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, OOJSReportBadArguments(), OOPlayerForScripting(), and OOStringFromJSValue().

+ Here is the call graph for this function:

◆ GlobalLog()

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

Definition at line 246 of file OOJSGlobal.m.

247{
248 OOJS_NATIVE_ENTER(context)
249
250 NSString *message = nil;
251 NSString *messageClass = nil;
252
253 if (EXPECT_NOT(argc < 1))
254 {
256 }
257 if (argc < 2)
258 {
259 messageClass = kOOLogDebugMessage;
260 message = OOStringFromJSValue(context, OOJS_ARGV[0]);
261 }
262 else
263 {
264 messageClass = OOStringFromJSValueEvenIfNull(context, OOJS_ARGV[0]);
265 if (!OOLogWillDisplayMessagesInClass(messageClass))
266 {
267 // Do nothing (and short-circuit) if message class is filtered out.
269 }
270
271 message = [NSString concatenationOfStringsFromJavaScriptValues:OOJS_ARGV + 1 count:argc - 1 separator:@", " inContext:context];
272 }
273
275 OOLog(messageClass, @"%@", message);
276
277#if OOJSENGINE_MONITOR_SUPPORT
278 [[OOJavaScriptEngine sharedEngine] sendMonitorLogMessage:message
279 withMessageClass:nil
280 inContext:context];
281#endif
283
285
287}
static NSString *const kOOLogDebugMessage
Definition OOJSGlobal.m:56
NSString * OOStringFromJSValueEvenIfNull(JSContext *context, jsval value)
#define OOJS_RETURN_VOID
BOOL OOLogWillDisplayMessagesInClass(NSString *inMessageClass)
Definition OOLogging.m:144
#define OOLog(class, format,...)
Definition OOLogging.h:88
OOJavaScriptEngine * sharedEngine()

References EXPECT_NOT, kOOLogDebugMessage, nil, OOJS_ARGV, OOJS_BEGIN_FULL_NATIVE, OOJS_END_FULL_NATIVE, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_VOID, OOLog, OOLogWillDisplayMessagesInClass(), OOStringFromJSValue(), OOStringFromJSValueEvenIfNull(), and OOJavaScriptEngine::sharedEngine.

+ Here is the call graph for this function:

◆ GlobalPauseGame()

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

Definition at line 832 of file OOJSGlobal.m.

833{
834 OOJS_NATIVE_ENTER(context)
835
836 BOOL result = NO;
837 PlayerEntity *player = PLAYER;
838
839 if (player)
840 {
841 OOGUIScreenID guiScreen = [player guiScreen];
842
843 if (guiScreen != GUI_SCREEN_LONG_RANGE_CHART &&
844 guiScreen != GUI_SCREEN_MISSION &&
845 guiScreen != GUI_SCREEN_REPORT &&
846 guiScreen != GUI_SCREEN_KEYBOARD_ENTRY &&
847 guiScreen != GUI_SCREEN_SAVE)
848 {
849 [UNIVERSE pauseGame];
850 result = YES;
851 }
852 }
853
854 OOJS_RETURN_BOOL(result);
855
857}
#define PLAYER
OOGUIScreenID guiScreen()

References PlayerEntity::guiScreen, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, and PLAYER.

+ Here is the call graph for this function:

◆ GlobalQuitGame()

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

Definition at line 860 of file OOJSGlobal.m.

861{
862 OOJS_NATIVE_ENTER(context)
863
864 OOLog(@"script.debug.quit", @"%@", @"Quit requested via JavaScript global.quitGame()");
865
866 [UNIVERSE quitGame];
867
868 OOJS_RETURN_BOOL(YES);
869
871}

References OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, and OOLog.

◆ GlobalRandomInhabitantsDescription()

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

Definition at line 412 of file OOJSGlobal.m.

413{
414 OOJS_NATIVE_ENTER(context)
415
416 NSString *string = nil;
417 Random_Seed aSeed;
418 JSBool isPlural = YES;
419
420 if (argc > 0 && !JS_ValueToBoolean(context, OOJS_ARGV[0], &isPlural))
421 {
422 OOJSReportBadArguments(context, nil, @"randomInhabitantsDescription", 1, OOJS_ARGV, nil, @"boolean");
423 return NO;
424 }
425
427 string = [UNIVERSE getSystemInhabitants:Ranrot()%OO_SYSTEMS_PER_GALAXY plural:isPlural];
428 OOJS_RETURN_OBJECT(string);
429
431}
void make_pseudo_random_seed(Random_Seed *seed_ptr)

References make_pseudo_random_seed(), nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, and OOJSReportBadArguments().

+ Here is the call graph for this function:

◆ GlobalRandomName()

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

Definition at line 390 of file OOJSGlobal.m.

391{
392 OOJS_NATIVE_ENTER(context)
393
394 /* Temporarily set the system generation seed to a "really random" seed,
395 so randomName() isn't repeatable.
396 */
397 RNG_Seed savedSeed = currentRandomSeed();
399
400 NSString *result = OOExpand(@"%N");
401
402 // Restore seed.
403 setRandomSeed(savedSeed);
404
405 OOJS_RETURN_OBJECT(result);
406
408}
#define OOExpand(string,...)
void setRandomSeed(RNG_Seed a_seed)
RNG_Seed currentRandomSeed(void)
unsigned Ranrot(void)

References currentRandomSeed(), OOExpand, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_OBJECT, Ranrot(), and setRandomSeed().

+ Here is the call graph for this function:

◆ GlobalSetExtraGuiScreenKeys()

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

Definition at line 469 of file OOJSGlobal.m.

470{
471 OOJS_NATIVE_ENTER(context)
472
473 BOOL result = NO;
474 jsval callback = JSVAL_NULL;
475 JSObject *callbackThis = NULL;
476 jsval value = JSVAL_NULL;
477 NSString *key = nil;
478 OOGUIScreenID gui;
479 NSDictionary *keydefs = NULL;
480 JSObject *params = NULL;
482
483 if (EXPECT_NOT(argc < 1))
484 {
485 OOJSReportBadArguments(context, nil, @"setExtraGuiScreenKeys", 0, OOJS_ARGV, nil, @"key, definition");
486 return NO;
487 }
488 key = OOStringFromJSValue(context, OOJS_ARGV[0]);
489
490 // Validate arguments.
491 if (argc < 2 || !JS_ValueToObject(context, OOJS_ARGV[1], &params))
492 {
493 OOJSReportBadArguments(context, @"global", @"setExtraGuiScreenKeys", 2, &OOJS_ARGV[1], nil, @"key, definition: definition is not a valid dictionary.");
494 return NO;
495 }
496
497 if (JS_GetProperty(context, params, "guiScreen", &value) == JS_FALSE || JSVAL_IS_VOID(value))
498 {
499 OOJSReportBadArguments(context, @"global", @"setExtraGuiScreenKeys", 2, &OOJS_ARGV[1], nil, @"key, definition: must have a 'guiScreen' property.");
500 return NO;
501 }
502
503 gui = OOGUIScreenIDFromJSValue(context, value);
504 // gui will be 0 for invalid screen id's as well as GUI_SCREEN_MAIN
505 if (gui == 0 || gui == GUI_SCREEN_LOAD || gui == GUI_SCREEN_SAVE || gui == GUI_SCREEN_STICKMAPPER || gui == GUI_SCREEN_OXZMANAGER ||
506 gui == GUI_SCREEN_NEWGAME || gui == GUI_SCREEN_SAVE_OVERWRITE || gui == GUI_SCREEN_KEYBOARD || gui == GUI_SCREEN_STICKPROFILE || gui == GUI_SCREEN_KEYBOARD_CONFIRMCLEAR ||
507 gui == GUI_SCREEN_KEYBOARD_CONFIG || gui == GUI_SCREEN_KEYBOARD_ENTRY || gui == GUI_SCREEN_KEYBOARD_LAYOUT)
508 {
509 OOJSReportBadArguments(context, @"global", @"setExtraGuiScreenKeys", 2, &OOJS_ARGV[1], nil, @"key, definition: 'guiScreen' property must be a permitted and valid GUI_SCREEN idenfifier.");
510 return NO;
511 }
512
513 if (JS_GetProperty(context, params, "registerKeys", &value) == JS_FALSE || JSVAL_IS_VOID(value))
514 {
515 OOJSReportBadArguments(context, @"global", @"setExtraGuiScreenKeys", 2, &OOJS_ARGV[1], nil, @"key, definition: must have a 'registerKeys' property.");
516 return NO;
517 }
518 if (!JSVAL_IS_NULL(value))
519 {
520 if (JSVAL_IS_OBJECT(value))
521 {
522 keydefs = OOJSNativeObjectFromJSObject(context, JSVAL_TO_OBJECT(value));
523 }
524 else
525 {
526 OOJSReportBadArguments(context, @"global", @"setExtraGuiScreenKeys", 2, &OOJS_ARGV[1], nil, @"key, definition: registerKeys is not a valid dictionary.");
527 return NO;
528 }
529 }
530
531 if (JS_GetProperty(context, params, "callback", &callback) == JS_FALSE || JSVAL_IS_VOID(callback))
532 {
533 OOJSReportBadArguments(context, @"global", @"setExtraGuiScreenKeys", 2, &OOJS_ARGV[1], NULL, @"key, definition; must have a 'callback' property.");
534 return NO;
535 }
536 if (!OOJSValueIsFunction(context,callback))
537 {
538 OOJSReportBadArguments(context, @"global", @"setExtraGuiScreenKeys", 2, &OOJS_ARGV[1], NULL, @"key, definition; 'callback' property must be a function.");
539 return NO;
540 }
541
542 OOJSGuiScreenKeyDefinition* definition = [[OOJSGuiScreenKeyDefinition alloc] init];
543 [definition setName:key];
544 [definition setRegisterKeys:keydefs];
545 [definition setCallback:callback];
546
547 // get callback 'this'
548 if (JS_GetProperty(context, params, "cbThis", &value) == JS_TRUE && !JSVAL_IS_VOID(value))
549 {
550 JS_ValueToObject(context, value, &callbackThis);
551 [definition setCallbackThis:callbackThis];
552 // can do .bind(this) for callback instead
553 }
554
555 result = [player setExtraGuiScreenKeys:gui definition:definition];
556 [definition release];
557
558 OOJS_RETURN_BOOL(result);
559
561}
id OOJSNativeObjectFromJSObject(JSContext *context, JSObject *object)
OOINLINE BOOL OOJSValueIsFunction(JSContext *context, jsval value)
void setRegisterKeys:(NSDictionary *registerKeys)
void setCallbackThis:(JSObject *callbackthis)
BOOL setExtraGuiScreenKeys:definition:(OOGUIScreenID gui,[definition] OOJSGuiScreenKeyDefinition *definition)

References EXPECT_NOT, nil, OOGUIScreenIDFromJSValue(), OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSNativeObjectFromJSObject(), OOJSReportBadArguments(), OOJSValueIsFunction(), OOPlayerForScripting(), OOStringFromJSValue(), OOJSGuiScreenKeyDefinition::setCallback:, OOJSGuiScreenKeyDefinition::setCallbackThis:, PlayerEntity::setExtraGuiScreenKeys:definition:, OOJSGuiScreenKeyDefinition::setName:, and OOJSGuiScreenKeyDefinition::setRegisterKeys:.

+ Here is the call graph for this function:

◆ GlobalSetGuiColorSettingForKey()

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

Definition at line 717 of file OOJSGlobal.m.

718{
719 OOJS_NATIVE_ENTER(context)
720
721 BOOL result = NO;
722 OOColor *col = nil;
723
724 if (EXPECT_NOT(argc != 2))
725 {
726 OOJSReportBadArguments(context, nil, @"setGuiColorForKey", 0, OOJS_ARGV, nil, @"missing arguments");
727 return NO;
728 }
729
730 NSString *key = OOStringFromJSValue(context, OOJS_ARGV[0]);
731 jsval value = OOJS_ARGV[1];
732 if (EXPECT_NOT(key == nil || [key isEqualToString:@""]))
733 {
734 OOJSReportBadArguments(context, nil, @"setGuiColorForKey", 0, OOJS_ARGV, nil, @"key");
735 return NO;
736 }
737 if ([key rangeOfString:@"color"].location == NSNotFound)
738 {
739 OOJSReportBadArguments(context, nil, @"setGuiColorForKey", 0, OOJS_ARGV, nil, @"valid color key setting");
740 return NO;
741 }
742
743 if (!JSVAL_IS_NULL(value))
744 {
745 col = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, value)];
746 if (col == nil)
747 {
748 OOJSReportBadArguments(context, nil, @"setGuiColorForKey", 1, OOJS_ARGV, nil, @"color descriptor");
749 return NO;
750 }
751 }
752
753 GuiDisplayGen *gui = [UNIVERSE gui];
754 [gui setGuiColorSettingFromKey:key color:col];
755 result = YES;
756
757 OOJS_RETURN_BOOL(result);
758
760}
void setGuiColorSettingFromKey:color:(NSString *key,[color] OOColor *col)
OOColor * colorWithDescription:(id description)
Definition OOColor.m:127

References OOColor::colorWithDescription:, EXPECT_NOT, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOStringFromJSValue(), and GuiDisplayGen::setGuiColorSettingFromKey:color:.

+ Here is the call graph for this function:

◆ GlobalSetProperty()

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

Definition at line 213 of file OOJSGlobal.m.

214{
215 if (!JSID_IS_INT(propID)) return YES;
216
217 OOJS_NATIVE_ENTER(context)
218
219 jsdouble fValue;
220
221 switch (JSID_TO_INT(propID))
222 {
224 if (JS_ValueToNumber(context, *value, &fValue))
225 {
226 [UNIVERSE setTimeAccelerationFactor:fValue];
227 return YES;
228 }
229 break;
230
231 default:
232 OOJSReportBadPropertySelector(context, this, propID, sGlobalProperties);
233 }
234
235 OOJSReportBadPropertyValue(context, this, propID, sGlobalProperties, *value);
236 return NO;
237
239}
void OOJSReportBadPropertyValue(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec, jsval value)

References kGlobal_timeAccelerationFactor, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJSReportBadPropertySelector(), OOJSReportBadPropertyValue(), and sGlobalProperties.

+ Here is the call graph for this function:

◆ GlobalSetScreenBackground()

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

Definition at line 565 of file OOJSGlobal.m.

566{
567 OOJS_NATIVE_ENTER(context)
568
569 BOOL result = NO;
570 jsval value = (argc > 0) ? OOJS_ARGV[0] : JSVAL_NULL;
571
572 if (EXPECT_NOT(argc == 0))
573 {
574 OOJSReportWarning(context, @"Usage error: %@() called with no arguments. Treating as %@(null). This call may fail in a future version of Oolite.", @"setScreenBackground", @"setScreenBackground");
575 }
576 else if (EXPECT_NOT(JSVAL_IS_VOID(value)))
577 {
578 OOJSReportBadArguments(context, nil, @"setScreenBackground", 1, &value, nil, @"GUI texture descriptor");
579 return NO;
580 }
581
582 if ([UNIVERSE viewDirection] == VIEW_GUI_DISPLAY)
583 {
584 GuiDisplayGen *gui = [UNIVERSE gui];
585 NSDictionary *descriptor = [gui textureDescriptorFromJSValue:value inContext:context callerDescription:@"setScreenBackground()"];
586
587 result = [gui setBackgroundTextureDescriptor:descriptor];
588
589 // add some permanence to the override if we're in the equip ship screen
590 if (result && [PLAYER guiScreen] == GUI_SCREEN_EQUIP_SHIP) [PLAYER setEquipScreenBackgroundDescriptor:descriptor];
591 }
592
593 OOJS_RETURN_BOOL(result);
594
596}
void OOJSReportWarning(JSContext *context, NSString *format,...)
NSDictionary * textureDescriptorFromJSValue:inContext:callerDescription:(jsval value,[inContext] JSContext *context,[callerDescription] NSString *callerDescription)
BOOL setBackgroundTextureDescriptor:(NSDictionary *descriptor)

References EXPECT_NOT, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOJSReportWarning(), PLAYER, GuiDisplayGen::setBackgroundTextureDescriptor:, GuiDisplayGen::textureDescriptorFromJSValue:inContext:callerDescription:, and UNIVERSE.

+ Here is the call graph for this function:

◆ GlobalSetScreenBackgroundForKey()

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

Definition at line 622 of file OOJSGlobal.m.

623{
624 OOJS_NATIVE_ENTER(context)
625
626 BOOL result = NO;
627
628 if (EXPECT_NOT(argc < 2))
629 {
630 OOJSReportBadArguments(context, nil, @"setScreenBackgroundDefault", 0, OOJS_ARGV, nil, @"missing arguments");
631 return NO;
632 }
633
634 NSString *key = OOStringFromJSValue(context, OOJS_ARGV[0]);
635 jsval value = OOJS_ARGV[1];
636 if (EXPECT_NOT(key == nil || [key isEqualToString:@""]))
637 {
638 OOJSReportBadArguments(context, nil, @"setScreenBackgroundDefault", 0, OOJS_ARGV, nil, @"key");
639 return NO;
640 }
641
642 GuiDisplayGen *gui = [UNIVERSE gui];
643 NSDictionary *descriptor = [gui textureDescriptorFromJSValue:value inContext:context callerDescription:@"setScreenBackgroundDefault()"];
644
645 [UNIVERSE setScreenTextureDescriptorForKey:key descriptor:descriptor];
646 result = YES;
647
648 OOJS_RETURN_BOOL(result);
649
651}

References EXPECT_NOT, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOStringFromJSValue(), and GuiDisplayGen::textureDescriptorFromJSValue:inContext:callerDescription:.

+ Here is the call graph for this function:

◆ GlobalSetScreenOverlay()

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

Definition at line 655 of file OOJSGlobal.m.

656{
657 OOJS_NATIVE_ENTER(context)
658
659 BOOL result = NO;
660 jsval value = (argc > 0) ? OOJS_ARGV[0] : JSVAL_NULL;
661
662 if (EXPECT_NOT(argc == 0))
663 {
664 OOJSReportWarning(context, @"Usage error: %@() called with no arguments. Treating as %@(null). This call may fail in a future version of Oolite.", @"setScreenOverlay", @"setScreenOverlay");
665 }
666 else if (EXPECT_NOT(JSVAL_IS_VOID(value)))
667 {
668 OOJSReportBadArguments(context, nil, @"setScreenOverlay", 1, &value, nil, @"GUI texture descriptor");
669 return NO;
670 }
671
672 if ([UNIVERSE viewDirection] == VIEW_GUI_DISPLAY)
673 {
674 GuiDisplayGen *gui = [UNIVERSE gui];
675 NSDictionary *descriptor = [gui textureDescriptorFromJSValue:value inContext:context callerDescription:@"setScreenOverlay()"];
676
677 result = [gui setForegroundTextureDescriptor:descriptor];
678 }
679
680 OOJS_RETURN_BOOL(result);
681
683}
BOOL setForegroundTextureDescriptor:(NSDictionary *descriptor)

References EXPECT_NOT, nil, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOJSReportWarning(), GuiDisplayGen::setForegroundTextureDescriptor:, GuiDisplayGen::textureDescriptorFromJSValue:inContext:callerDescription:, and UNIVERSE.

+ Here is the call graph for this function:

◆ GlobalTakeSnapShot()

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

Definition at line 765 of file OOJSGlobal.m.

766{
767 OOJS_NATIVE_ENTER(context)
768
769 NSString *value = nil;
770 NSMutableCharacterSet *allowedChars = (NSMutableCharacterSet *)[NSMutableCharacterSet alphanumericCharacterSet];
771 BOOL result = NO;
772
773 [allowedChars addCharactersInString:@"_-"];
774
775 if (argc > 0)
776 {
777 value = OOStringFromJSValue(context, OOJS_ARGV[0]);
778 if (EXPECT_NOT(value == nil || [value rangeOfCharacterFromSet:[allowedChars invertedSet]].location != NSNotFound))
779 {
780 OOJSReportBadArguments(context, nil, @"takeSnapShot", argc, OOJS_ARGV, nil, @"alphanumeric string");
781 return NO;
782 }
783 }
784
785 NSString *playerFileDirectory = [[NSFileManager defaultManager] defaultCommanderPath];
786 NSDictionary *attr = [[NSFileManager defaultManager] oo_fileSystemAttributesAtPath:playerFileDirectory];
787
788 if (attr != nil)
789 {
790 double freeSpace = [attr oo_doubleForKey:NSFileSystemFreeSize];
791 if (freeSpace < 1073741824) // less than 1 GB free on disk?
792 {
793 OOJSReportWarning(context, @"takeSnapShot: function disabled when free disk space is less than 1GB.");
795 }
796 }
797
798
800 result = [[UNIVERSE gameView] snapShot:value];
802
803 OOJS_RETURN_BOOL(result);
804
806}

References EXPECT_NOT, nil, OOJS_ARGV, OOJS_BEGIN_FULL_NATIVE, OOJS_END_FULL_NATIVE, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, OOJS_RETURN_BOOL, OOJSReportBadArguments(), OOJSReportWarning(), and OOStringFromJSValue().

+ Here is the call graph for this function:

◆ SetUpOOJSGlobal()

void SetUpOOJSGlobal ( JSContext *  context,
JSObject *  global 
)

Definition at line 173 of file OOJSGlobal.m.

174{
175 JS_DefineProperties(context, global, sGlobalProperties);
176 JS_DefineFunctions(context, global, sGlobalMethods);
177}
static JSFunctionSpec sGlobalMethods[]
Definition OOJSGlobal.m:133

References sGlobalMethods, and sGlobalProperties.

Variable Documentation

◆ kOOLogDebugMessage

NSString* const kOOLogDebugMessage = @"script.debug.message"
static

Definition at line 56 of file OOJSGlobal.m.

◆ sGlobalClass

JSClass sGlobalClass
static
Initial value:
=
{
"Global",
JSCLASS_GLOBAL_FLAGS,
JS_PropertyStub,
JS_PropertyStub,
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
JS_FinalizeStub
}
static JSBool GlobalGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
Definition OOJSGlobal.m:180
static JSBool GlobalSetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
Definition OOJSGlobal.m:213

Definition at line 88 of file OOJSGlobal.m.

89{
90 "Global",
91 JSCLASS_GLOBAL_FLAGS,
92
93 JS_PropertyStub,
94 JS_PropertyStub,
96#ifndef NDEBUG
98#else
99 // No writeable properties in non-debug builds
100 JS_StrictPropertyStub,
101#endif
102 JS_EnumerateStub,
103 JS_ResolveStub,
104 JS_ConvertStub,
105 JS_FinalizeStub
106};

Referenced by CreateOOJSGlobal().

◆ sGlobalMethods

JSFunctionSpec sGlobalMethods[]
static
Initial value:
=
{
{ "log", GlobalLog, 1 },
{ "autoAIForRole", GlobalAutoAIForRole, 1 },
{ "expandDescription", GlobalExpandDescription, 1 },
{ "expandMissionText", GlobalExpandMissionText, 1 },
{ "displayNameForCommodity", GlobalDisplayNameForCommodity, 1 },
{ "randomName", GlobalRandomName, 0 },
{ "randomInhabitantsDescription", GlobalRandomInhabitantsDescription, 1 },
{ "setScreenBackground", GlobalSetScreenBackground, 1 },
{ "getScreenBackgroundForKey", GlobalGetScreenBackgroundForKey, 1 },
{ "setScreenBackgroundForKey", GlobalSetScreenBackgroundForKey, 2 },
{ "setScreenOverlay", GlobalSetScreenOverlay, 1 },
{ "getGuiColorSettingForKey", GlobalGetGuiColorSettingForKey, 1 },
{ "setGuiColorSettingForKey", GlobalSetGuiColorSettingForKey, 2 },
{ "keyBindingDescription", GlobalKeyBindingDescription, 1 },
{ "setExtraGuiScreenKeys", GlobalSetExtraGuiScreenKeys, 2 },
{ "clearExtraGuiScreenKeys", GlobalClearExtraGuiScreenKeys, 2 },
{ "takeSnapShot", GlobalTakeSnapShot, 1 },
{ "quitGame", GlobalQuitGame, 0 },
{ "pauseGame", GlobalPauseGame, 0 },
{ 0 }
}
static JSBool GlobalSetScreenBackground(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:565
static JSBool GlobalExpandDescription(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:291
static JSBool GlobalPauseGame(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:832
static JSBool GlobalSetScreenOverlay(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:655
static JSBool GlobalGetScreenBackgroundForKey(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:599
static JSBool GlobalLog(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:246
static JSBool GlobalGetGuiColorSettingForKey(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:686
static JSBool GlobalExpandMissionText(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:343
static JSBool GlobalSetScreenBackgroundForKey(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:622
static JSBool GlobalKeyBindingDescription(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:318
static JSBool GlobalSetExtraGuiScreenKeys(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:469
static JSBool GlobalDisplayNameForCommodity(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:371
static JSBool GlobalRandomInhabitantsDescription(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:412
static JSBool GlobalTakeSnapShot(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:765
static JSBool GlobalClearExtraGuiScreenKeys(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:434
static JSBool GlobalQuitGame(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:860
static JSBool GlobalSetGuiColorSettingForKey(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:717
static JSBool GlobalAutoAIForRole(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:810
static JSBool GlobalRandomName(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:390

Definition at line 133 of file OOJSGlobal.m.

134{
135 // JS name Function min args
136 { "log", GlobalLog, 1 },
137 { "autoAIForRole", GlobalAutoAIForRole, 1 },
138 { "expandDescription", GlobalExpandDescription, 1 },
139 { "expandMissionText", GlobalExpandMissionText, 1 },
140 { "displayNameForCommodity", GlobalDisplayNameForCommodity, 1 },
141 { "randomName", GlobalRandomName, 0 },
142 { "randomInhabitantsDescription", GlobalRandomInhabitantsDescription, 1 },
143 { "setScreenBackground", GlobalSetScreenBackground, 1 },
144 { "getScreenBackgroundForKey", GlobalGetScreenBackgroundForKey, 1 },
145 { "setScreenBackgroundForKey", GlobalSetScreenBackgroundForKey, 2 },
146 { "setScreenOverlay", GlobalSetScreenOverlay, 1 },
147 { "getGuiColorSettingForKey", GlobalGetGuiColorSettingForKey, 1 },
148 { "setGuiColorSettingForKey", GlobalSetGuiColorSettingForKey, 2 },
149 { "keyBindingDescription", GlobalKeyBindingDescription, 1 },
150 { "setExtraGuiScreenKeys", GlobalSetExtraGuiScreenKeys, 2 },
151 { "clearExtraGuiScreenKeys", GlobalClearExtraGuiScreenKeys, 2 },
152
153#ifndef NDEBUG
154 { "takeSnapShot", GlobalTakeSnapShot, 1 },
155 { "quitGame", GlobalQuitGame, 0 },
156#endif
157 { "pauseGame", GlobalPauseGame, 0 },
158 { 0 }
159};

Referenced by SetUpOOJSGlobal().

◆ sGlobalProperties

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

Definition at line 121 of file OOJSGlobal.m.

122{
123 // JS name ID flags
124 { "galaxyNumber", kGlobal_galaxyNumber, OOJS_PROP_READONLY_CB },
126#ifndef NDEBUG
127 { "timeAccelerationFactor", kGlobal_timeAccelerationFactor, OOJS_PROP_READWRITE_CB },
128#endif
129 { 0 }
130};

Referenced by GlobalGetProperty(), GlobalSetProperty(), and SetUpOOJSGlobal().