Oolite 1.91.0.7604-240417-a536cbe
Loading...
Searching...
No Matches
Enumerations | Functions | Variables
OOJSGlobal.m File Reference
import "OOJSGlobal.h"
import "OOJavaScriptEngine.h"
import "OOJSPlayer.h"
import "PlayerEntityScriptMethods.h"
import "OOStringExpander.h"
import "OOConstToString.h"
import "OOConstToJSString.h"
import "OOCollectionExtractors.h"
import "OOTexture.h"
import "GuiDisplayGen.h"
import "MyOpenGLView.h"
import "ResourceManager.h"
import "OOSystemDescriptionManager.h"
import "NSFileManagerOOExtensions.h"
import "OOJSGuiScreenKeyDefinition.h"
+ Include dependency graph for OOJSGlobal.m:

Go to the source code of this file.

Enumerations

enum  {
  kGlobal_galaxyNumber , kGlobal_global , kGlobal_guiScreen , kGlobal_postFX ,
  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 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 GlobalGetColorSaturation (JSContext *context, uintN argc, jsval *vp)
 
static JSBool GlobalSetColorSaturation (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_postFX 
kGlobal_timeAccelerationFactor 

Definition at line 110 of file OOJSGlobal.m.

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

Function Documentation

◆ CreateOOJSGlobal()

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

Definition at line 166 of file OOJSGlobal.m.

167{
168 assert(outGlobal != NULL);
169
170 *outGlobal = JS_NewCompartmentAndGlobalObject(context, &sGlobalClass, NULL);
171
172 JS_SetGlobalObject(context, *outGlobal);
173 JS_DefineProperty(context, *outGlobal, "global", OBJECT_TO_JSVAL(*outGlobal), NULL, NULL, OOJS_PROP_READONLY);
174}
static JSClass sGlobalClass
Definition OOJSGlobal.m:89
#define OOJS_PROP_READONLY

References OOJS_PROP_READONLY, and sGlobalClass.

◆ GlobalAutoAIForRole()

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

Definition at line 858 of file OOJSGlobal.m.

859{
860 OOJS_NATIVE_ENTER(context)
861
862 NSString *string = nil;
863
864 if (argc > 0) string = OOStringFromJSValue(context,OOJS_ARGV[0]);
865 if (string == nil)
866 {
867 OOJSReportBadArguments(context, nil, @"autoAIForRole", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
868 return NO;
869 }
870
871 NSDictionary *autoAIMap = [ResourceManager dictionaryFromFilesNamed:@"autoAImap.plist" inFolder:@"Config" andMerge:YES];
872 NSString *autoAI = [autoAIMap oo_stringForKey:string];
873
874 OOJS_RETURN_OBJECT(autoAI);
875
877}
#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 452 of file OOJSGlobal.m.

453{
454 OOJS_NATIVE_ENTER(context)
455
456 BOOL result = NO;
458
459 if (EXPECT_NOT(argc < 2))
460 {
461 OOJSReportBadArguments(context, nil, @"setExtraGuiScreenKeys", 0, OOJS_ARGV, nil, @"missing arguments");
462 return NO;
463 }
464
465 NSString *key = OOStringFromJSValue(context, OOJS_ARGV[0]);
466 if (EXPECT_NOT(key == nil || [key isEqualToString:@""]))
467 {
468 OOJSReportBadArguments(context, nil, @"clearExtraGuiScreenKeys", 1, OOJS_ARGV, nil, @"key");
469 return NO;
470 }
471
473 if (!gui)
474 {
475 OOJSReportBadArguments(context, nil, @"clearExtraGuiScreenKeys", 0, OOJS_ARGV, nil, @"guiScreen invalid entry");
476 return NO;
477 }
478
479 [player clearExtraGuiScreenKeys:gui key:key];
480
481 result = YES;
482 OOJS_RETURN_BOOL(result);
483
485}
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 389 of file OOJSGlobal.m.

390{
391 OOJS_NATIVE_ENTER(context)
392
393 NSString *string = nil;
394
395 if (argc > 0) string = OOStringFromJSValue(context,OOJS_ARGV[0]);
396 if (string == nil)
397 {
398 OOJSReportBadArguments(context, nil, @"displayNameForCommodity", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
399 return NO;
400 }
402
404}
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 309 of file OOJSGlobal.m.

310{
311 OOJS_NATIVE_ENTER(context)
312
313 NSString *string = nil;
314 NSDictionary *overrides = nil;
315
316 if (argc > 0) string = OOStringFromJSValue(context, OOJS_ARGV[0]);
317 if (string == nil)
318 {
319 OOJSReportBadArguments(context, nil, @"expandDescription", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
320 return NO;
321 }
322 if (argc > 1)
323 {
324 overrides = OOJSDictionaryFromStringTable(context, OOJS_ARGV[1]);
325 }
326
330
331 OOJS_RETURN_OBJECT(string);
332
334}
#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 361 of file OOJSGlobal.m.

362{
363 OOJS_NATIVE_ENTER(context)
364
365 NSString *string = nil;
366 NSDictionary *overrides = nil;
367
368 if (argc > 0) string = OOStringFromJSValue(context, OOJS_ARGV[0]);
369 if (string == nil)
370 {
371 OOJSReportBadArguments(context, nil, @"expandMissionText", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
372 return NO;
373 }
374 if (argc > 1)
375 {
376 overrides = OOJSDictionaryFromStringTable(context, OOJS_ARGV[1]);
377 }
378
379 string = [[UNIVERSE missiontext] oo_stringForKey:string];
381
382 OOJS_RETURN_OBJECT(string);
383
385}
@ 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:

◆ GlobalGetColorSaturation()

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

Definition at line 782 of file OOJSGlobal.m.

783{
784 OOJS_NATIVE_ENTER(context)
785
786 OOJS_RETURN_OBJECT([NSNumber numberWithFloat:[[UNIVERSE gameView] colorSaturation]]);
787
789}
#define UNIVERSE
Definition Universe.h:833

References OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, and OOJS_RETURN_OBJECT.

◆ GlobalGetGuiColorSettingForKey()

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

Definition at line 704 of file OOJSGlobal.m.

705{
706 OOJS_NATIVE_ENTER(context)
707
708 if (EXPECT_NOT(argc == 0))
709 {
710 OOJSReportBadArguments(context, nil, @"getGuiColorForKey", 0, OOJS_ARGV, nil, @"missing arguments");
711 return NO;
712 }
713 NSString *key = OOStringFromJSValue(context, OOJS_ARGV[0]);
714 if (EXPECT_NOT(key == nil || [key isEqualToString:@""]))
715 {
716 OOJSReportBadArguments(context, nil, @"getGuiColorForKey", 0, OOJS_ARGV, nil, @"key");
717 return NO;
718 }
719 if ([key rangeOfString:@"color"].location == NSNotFound)
720 {
721 OOJSReportBadArguments(context, nil, @"getGuiColorForKey", 0, OOJS_ARGV, nil, @"valid color key setting");
722 return NO;
723 }
724
725 GuiDisplayGen *gui = [UNIVERSE gui];
726 OOColor *col = [gui colorFromSetting:key defaultValue:nil];
727
728 OOJS_RETURN_OBJECT([col normalizedArray]);
729
731}
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 184 of file OOJSGlobal.m.

185{
186 if (!JSID_IS_INT(propID)) return YES;
187
188 OOJS_NATIVE_ENTER(context)
189
191
192 switch (JSID_TO_INT(propID))
193 {
195 *value = INT_TO_JSVAL([player currentGalaxyID]);
196 return YES;
197
199 *value = OOJSValueFromGUIScreenID(context, [player guiScreen]);
200 return YES;
201
202 case kGlobal_postFX:
203 *value = INT_TO_JSVAL([UNIVERSE currentPostFX]);
204 return YES;
205
206#ifndef NDEBUG
208 return JS_NewNumberValue(context, [UNIVERSE timeAccelerationFactor], value);
209#endif
210
211 default:
212 OOJSReportBadPropertySelector(context, this, propID, sGlobalProperties);
213 return NO;
214 }
215
217}
OOINLINE jsval OOJSValueFromGUIScreenID(JSContext *context, OOGUIScreenID value)
static JSPropertySpec sGlobalProperties[]
Definition OOJSGlobal.m:123
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)

References kGlobal_galaxyNumber, kGlobal_guiScreen, kGlobal_postFX, 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 617 of file OOJSGlobal.m.

618{
619 OOJS_NATIVE_ENTER(context)
620
621 if (EXPECT_NOT(argc == 0))
622 {
623 OOJSReportBadArguments(context, nil, @"getScreenBackgroundDefault", 0, OOJS_ARGV, nil, @"missing arguments");
624 return NO;
625 }
626 NSString *key = OOStringFromJSValue(context, OOJS_ARGV[0]);
627 if (EXPECT_NOT(key == nil || [key isEqualToString:@""]))
628 {
629 OOJSReportBadArguments(context, nil, @"getScreenBackgroundDefault", 0, OOJS_ARGV, nil, @"key");
630 return NO;
631 }
632 NSDictionary *descriptor = [UNIVERSE screenTextureDescriptorForKey:key];
633
634 OOJS_RETURN_OBJECT(descriptor);
635
637}

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 336 of file OOJSGlobal.m.

337{
338 OOJS_NATIVE_ENTER(context)
339
340 NSString *string = nil;
342
343 if (argc > 0) string = OOStringFromJSValue(context, OOJS_ARGV[0]);
344 if (string == nil)
345 {
346 OOJSReportBadArguments(context, nil, @"keyBindingDescription", MIN(argc, 1U), OOJS_ARGV, nil, @"string");
347 return NO;
348 }
349
351 string = [player keyBindingDescription2:string];
353
354 OOJS_RETURN_OBJECT(string);
355
357}
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 264 of file OOJSGlobal.m.

265{
266 OOJS_NATIVE_ENTER(context)
267
268 NSString *message = nil;
269 NSString *messageClass = nil;
270
271 if (EXPECT_NOT(argc < 1))
272 {
274 }
275 if (argc < 2)
276 {
277 messageClass = kOOLogDebugMessage;
278 message = OOStringFromJSValue(context, OOJS_ARGV[0]);
279 }
280 else
281 {
282 messageClass = OOStringFromJSValueEvenIfNull(context, OOJS_ARGV[0]);
283 if (!OOLogWillDisplayMessagesInClass(messageClass))
284 {
285 // Do nothing (and short-circuit) if message class is filtered out.
287 }
288
289 message = [NSString concatenationOfStringsFromJavaScriptValues:OOJS_ARGV + 1 count:argc - 1 separator:@", " inContext:context];
290 }
291
293 OOLog(messageClass, @"%@", message);
294
295#if OOJSENGINE_MONITOR_SUPPORT
296 [[OOJavaScriptEngine sharedEngine] sendMonitorLogMessage:message
297 withMessageClass:nil
298 inContext:context];
299#endif
301
303
305}
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 880 of file OOJSGlobal.m.

881{
882 OOJS_NATIVE_ENTER(context)
883
884 BOOL result = NO;
885 PlayerEntity *player = PLAYER;
886
887 if (player)
888 {
889 OOGUIScreenID guiScreen = [player guiScreen];
890
891 if (guiScreen != GUI_SCREEN_LONG_RANGE_CHART &&
892 guiScreen != GUI_SCREEN_MISSION &&
893 guiScreen != GUI_SCREEN_REPORT &&
894 guiScreen != GUI_SCREEN_KEYBOARD_ENTRY &&
895 guiScreen != GUI_SCREEN_SAVE)
896 {
897 [UNIVERSE pauseGame];
898 result = YES;
899 }
900 }
901
902 OOJS_RETURN_BOOL(result);
903
905}
#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:

◆ GlobalRandomInhabitantsDescription()

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

Definition at line 430 of file OOJSGlobal.m.

431{
432 OOJS_NATIVE_ENTER(context)
433
434 NSString *string = nil;
435 Random_Seed aSeed;
436 JSBool isPlural = YES;
437
438 if (argc > 0 && !JS_ValueToBoolean(context, OOJS_ARGV[0], &isPlural))
439 {
440 OOJSReportBadArguments(context, nil, @"randomInhabitantsDescription", 1, OOJS_ARGV, nil, @"boolean");
441 return NO;
442 }
443
445 string = [UNIVERSE getSystemInhabitants:Ranrot()%OO_SYSTEMS_PER_GALAXY plural:isPlural];
446 OOJS_RETURN_OBJECT(string);
447
449}
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 408 of file OOJSGlobal.m.

409{
410 OOJS_NATIVE_ENTER(context)
411
412 /* Temporarily set the system generation seed to a "really random" seed,
413 so randomName() isn't repeatable.
414 */
415 RNG_Seed savedSeed = currentRandomSeed();
417
418 NSString *result = OOExpand(@"%N");
419
420 // Restore seed.
421 setRandomSeed(savedSeed);
422
423 OOJS_RETURN_OBJECT(result);
424
426}
#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:

◆ GlobalSetColorSaturation()

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

Definition at line 793 of file OOJSGlobal.m.

794{
795 OOJS_NATIVE_ENTER(context)
796
797 jsdouble desiredColorSaturation = 0;
798
799 if (argc < 1 || EXPECT_NOT(!JS_ValueToNumber(context, OOJS_ARGV[0], &desiredColorSaturation))) return NO;
800
801 MyOpenGLView *gameView = [UNIVERSE gameView];
802 float currentColorSaturation = [gameView colorSaturation];
803 [gameView adjustColorSaturation:desiredColorSaturation - currentColorSaturation];
804
806
808}
void adjustColorSaturation:(float colorSaturationAdjustment)
float colorSaturation()

References MyOpenGLView::adjustColorSaturation:, MyOpenGLView::colorSaturation, EXPECT_NOT, OOJS_ARGV, OOJS_NATIVE_ENTER, OOJS_NATIVE_EXIT, and OOJS_RETURN_VOID.

+ Here is the call graph for this function:

◆ GlobalSetExtraGuiScreenKeys()

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

Definition at line 487 of file OOJSGlobal.m.

488{
489 OOJS_NATIVE_ENTER(context)
490
491 BOOL result = NO;
492 jsval callback = JSVAL_NULL;
493 JSObject *callbackThis = NULL;
494 jsval value = JSVAL_NULL;
495 NSString *key = nil;
496 OOGUIScreenID gui;
497 NSDictionary *keydefs = NULL;
498 JSObject *params = NULL;
500
501 if (EXPECT_NOT(argc < 1))
502 {
503 OOJSReportBadArguments(context, nil, @"setExtraGuiScreenKeys", 0, OOJS_ARGV, nil, @"key, definition");
504 return NO;
505 }
506 key = OOStringFromJSValue(context, OOJS_ARGV[0]);
507
508 // Validate arguments.
509 if (argc < 2 || !JS_ValueToObject(context, OOJS_ARGV[1], &params))
510 {
511 OOJSReportBadArguments(context, @"global", @"setExtraGuiScreenKeys", 2, &OOJS_ARGV[1], nil, @"key, definition: definition is not a valid dictionary.");
512 return NO;
513 }
514
515 if (JS_GetProperty(context, params, "guiScreen", &value) == JS_FALSE || JSVAL_IS_VOID(value))
516 {
517 OOJSReportBadArguments(context, @"global", @"setExtraGuiScreenKeys", 2, &OOJS_ARGV[1], nil, @"key, definition: must have a 'guiScreen' property.");
518 return NO;
519 }
520
521 gui = OOGUIScreenIDFromJSValue(context, value);
522 // gui will be 0 for invalid screen id's as well as GUI_SCREEN_MAIN
523 if (gui == 0 || gui == GUI_SCREEN_LOAD || gui == GUI_SCREEN_SAVE || gui == GUI_SCREEN_STICKMAPPER || gui == GUI_SCREEN_OXZMANAGER ||
524 gui == GUI_SCREEN_NEWGAME || gui == GUI_SCREEN_SAVE_OVERWRITE || gui == GUI_SCREEN_KEYBOARD || gui == GUI_SCREEN_STICKPROFILE || gui == GUI_SCREEN_KEYBOARD_CONFIRMCLEAR ||
525 gui == GUI_SCREEN_KEYBOARD_CONFIG || gui == GUI_SCREEN_KEYBOARD_ENTRY || gui == GUI_SCREEN_KEYBOARD_LAYOUT)
526 {
527 OOJSReportBadArguments(context, @"global", @"setExtraGuiScreenKeys", 2, &OOJS_ARGV[1], nil, @"key, definition: 'guiScreen' property must be a permitted and valid GUI_SCREEN idenfifier.");
528 return NO;
529 }
530
531 if (JS_GetProperty(context, params, "registerKeys", &value) == JS_FALSE || JSVAL_IS_VOID(value))
532 {
533 OOJSReportBadArguments(context, @"global", @"setExtraGuiScreenKeys", 2, &OOJS_ARGV[1], nil, @"key, definition: must have a 'registerKeys' property.");
534 return NO;
535 }
536 if (!JSVAL_IS_NULL(value))
537 {
538 if (JSVAL_IS_OBJECT(value))
539 {
540 keydefs = OOJSNativeObjectFromJSObject(context, JSVAL_TO_OBJECT(value));
541 }
542 else
543 {
544 OOJSReportBadArguments(context, @"global", @"setExtraGuiScreenKeys", 2, &OOJS_ARGV[1], nil, @"key, definition: registerKeys is not a valid dictionary.");
545 return NO;
546 }
547 }
548
549 if (JS_GetProperty(context, params, "callback", &callback) == JS_FALSE || JSVAL_IS_VOID(callback))
550 {
551 OOJSReportBadArguments(context, @"global", @"setExtraGuiScreenKeys", 2, &OOJS_ARGV[1], NULL, @"key, definition; must have a 'callback' property.");
552 return NO;
553 }
554 if (!OOJSValueIsFunction(context,callback))
555 {
556 OOJSReportBadArguments(context, @"global", @"setExtraGuiScreenKeys", 2, &OOJS_ARGV[1], NULL, @"key, definition; 'callback' property must be a function.");
557 return NO;
558 }
559
560 OOJSGuiScreenKeyDefinition* definition = [[OOJSGuiScreenKeyDefinition alloc] init];
561 [definition setName:key];
562 [definition setRegisterKeys:keydefs];
563 [definition setCallback:callback];
564
565 // get callback 'this'
566 if (JS_GetProperty(context, params, "cbThis", &value) == JS_TRUE && !JSVAL_IS_VOID(value))
567 {
568 JS_ValueToObject(context, value, &callbackThis);
569 [definition setCallbackThis:callbackThis];
570 // can do .bind(this) for callback instead
571 }
572
573 result = [player setExtraGuiScreenKeys:gui definition:definition];
574 [definition release];
575
576 OOJS_RETURN_BOOL(result);
577
579}
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 735 of file OOJSGlobal.m.

736{
737 OOJS_NATIVE_ENTER(context)
738
739 BOOL result = NO;
740 OOColor *col = nil;
741
742 if (EXPECT_NOT(argc != 2))
743 {
744 OOJSReportBadArguments(context, nil, @"setGuiColorForKey", 0, OOJS_ARGV, nil, @"missing arguments");
745 return NO;
746 }
747
748 NSString *key = OOStringFromJSValue(context, OOJS_ARGV[0]);
749 jsval value = OOJS_ARGV[1];
750 if (EXPECT_NOT(key == nil || [key isEqualToString:@""]))
751 {
752 OOJSReportBadArguments(context, nil, @"setGuiColorForKey", 0, OOJS_ARGV, nil, @"key");
753 return NO;
754 }
755 if ([key rangeOfString:@"color"].location == NSNotFound)
756 {
757 OOJSReportBadArguments(context, nil, @"setGuiColorForKey", 0, OOJS_ARGV, nil, @"valid color key setting");
758 return NO;
759 }
760
761 if (!JSVAL_IS_NULL(value))
762 {
763 col = [OOColor colorWithDescription:OOJSNativeObjectFromJSValue(context, value)];
764 if (col == nil)
765 {
766 OOJSReportBadArguments(context, nil, @"setGuiColorForKey", 1, OOJS_ARGV, nil, @"color descriptor");
767 return NO;
768 }
769 }
770
771 GuiDisplayGen *gui = [UNIVERSE gui];
772 [gui setGuiColorSettingFromKey:key color:col];
773 result = YES;
774
775 OOJS_RETURN_BOOL(result);
776
778}
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 221 of file OOJSGlobal.m.

222{
223 if (!JSID_IS_INT(propID)) return YES;
224
225 OOJS_NATIVE_ENTER(context)
226
227 jsdouble fValue;
228 int32 iValue;
229
230 switch (JSID_TO_INT(propID))
231 {
232 case kGlobal_postFX:
233 if (JS_ValueToInt32(context, *value, &iValue))
234 {
235 iValue = MAX(iValue, 0);
236 [UNIVERSE setCurrentPostFX:iValue];
237 return YES;
238 }
239 break;
240
242 if (JS_ValueToNumber(context, *value, &fValue))
243 {
244 [UNIVERSE setTimeAccelerationFactor:fValue];
245 return YES;
246 }
247 break;
248
249 default:
250 OOJSReportBadPropertySelector(context, this, propID, sGlobalProperties);
251 }
252
253 OOJSReportBadPropertyValue(context, this, propID, sGlobalProperties, *value);
254 return NO;
255
257}
void OOJSReportBadPropertyValue(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec, jsval value)
#define MAX(A, B)
Definition OOMaths.h:114

References kGlobal_postFX, kGlobal_timeAccelerationFactor, MAX, 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 583 of file OOJSGlobal.m.

584{
585 OOJS_NATIVE_ENTER(context)
586
587 BOOL result = NO;
588 jsval value = (argc > 0) ? OOJS_ARGV[0] : JSVAL_NULL;
589
590 if (EXPECT_NOT(argc == 0))
591 {
592 OOJSReportWarning(context, @"Usage error: %@() called with no arguments. Treating as %@(null). This call may fail in a future version of Oolite.", @"setScreenBackground", @"setScreenBackground");
593 }
594 else if (EXPECT_NOT(JSVAL_IS_VOID(value)))
595 {
596 OOJSReportBadArguments(context, nil, @"setScreenBackground", 1, &value, nil, @"GUI texture descriptor");
597 return NO;
598 }
599
600 if ([UNIVERSE viewDirection] == VIEW_GUI_DISPLAY)
601 {
602 GuiDisplayGen *gui = [UNIVERSE gui];
603 NSDictionary *descriptor = [gui textureDescriptorFromJSValue:value inContext:context callerDescription:@"setScreenBackground()"];
604
605 result = [gui setBackgroundTextureDescriptor:descriptor];
606
607 // add some permanence to the override if we're in the equip ship screen
608 if (result && [PLAYER guiScreen] == GUI_SCREEN_EQUIP_SHIP) [PLAYER setEquipScreenBackgroundDescriptor:descriptor];
609 }
610
611 OOJS_RETURN_BOOL(result);
612
614}
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 640 of file OOJSGlobal.m.

641{
642 OOJS_NATIVE_ENTER(context)
643
644 BOOL result = NO;
645
646 if (EXPECT_NOT(argc < 2))
647 {
648 OOJSReportBadArguments(context, nil, @"setScreenBackgroundDefault", 0, OOJS_ARGV, nil, @"missing arguments");
649 return NO;
650 }
651
652 NSString *key = OOStringFromJSValue(context, OOJS_ARGV[0]);
653 jsval value = OOJS_ARGV[1];
654 if (EXPECT_NOT(key == nil || [key isEqualToString:@""]))
655 {
656 OOJSReportBadArguments(context, nil, @"setScreenBackgroundDefault", 0, OOJS_ARGV, nil, @"key");
657 return NO;
658 }
659
660 GuiDisplayGen *gui = [UNIVERSE gui];
661 NSDictionary *descriptor = [gui textureDescriptorFromJSValue:value inContext:context callerDescription:@"setScreenBackgroundDefault()"];
662
663 [UNIVERSE setScreenTextureDescriptorForKey:key descriptor:descriptor];
664 result = YES;
665
666 OOJS_RETURN_BOOL(result);
667
669}

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 673 of file OOJSGlobal.m.

674{
675 OOJS_NATIVE_ENTER(context)
676
677 BOOL result = NO;
678 jsval value = (argc > 0) ? OOJS_ARGV[0] : JSVAL_NULL;
679
680 if (EXPECT_NOT(argc == 0))
681 {
682 OOJSReportWarning(context, @"Usage error: %@() called with no arguments. Treating as %@(null). This call may fail in a future version of Oolite.", @"setScreenOverlay", @"setScreenOverlay");
683 }
684 else if (EXPECT_NOT(JSVAL_IS_VOID(value)))
685 {
686 OOJSReportBadArguments(context, nil, @"setScreenOverlay", 1, &value, nil, @"GUI texture descriptor");
687 return NO;
688 }
689
690 if ([UNIVERSE viewDirection] == VIEW_GUI_DISPLAY)
691 {
692 GuiDisplayGen *gui = [UNIVERSE gui];
693 NSDictionary *descriptor = [gui textureDescriptorFromJSValue:value inContext:context callerDescription:@"setScreenOverlay()"];
694
695 result = [gui setForegroundTextureDescriptor:descriptor];
696 }
697
698 OOJS_RETURN_BOOL(result);
699
701}
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 813 of file OOJSGlobal.m.

814{
815 OOJS_NATIVE_ENTER(context)
816
817 NSString *value = nil;
818 NSMutableCharacterSet *allowedChars = (NSMutableCharacterSet *)[NSMutableCharacterSet alphanumericCharacterSet];
819 BOOL result = NO;
820
821 [allowedChars addCharactersInString:@"_-"];
822
823 if (argc > 0)
824 {
825 value = OOStringFromJSValue(context, OOJS_ARGV[0]);
826 if (EXPECT_NOT(value == nil || [value rangeOfCharacterFromSet:[allowedChars invertedSet]].location != NSNotFound))
827 {
828 OOJSReportBadArguments(context, nil, @"takeSnapShot", argc, OOJS_ARGV, nil, @"alphanumeric string");
829 return NO;
830 }
831 }
832
833 NSString *playerFileDirectory = [[NSFileManager defaultManager] defaultCommanderPath];
834 NSDictionary *attr = [[NSFileManager defaultManager] oo_fileSystemAttributesAtPath:playerFileDirectory];
835
836 if (attr != nil)
837 {
838 double freeSpace = [attr oo_doubleForKey:NSFileSystemFreeSize];
839 if (freeSpace < 1073741824) // less than 1 GB free on disk?
840 {
841 OOJSReportWarning(context, @"takeSnapShot: function disabled when free disk space is less than 1GB.");
843 }
844 }
845
846
848 result = [[UNIVERSE gameView] snapShot:value];
850
851 OOJS_RETURN_BOOL(result);
852
854}

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 177 of file OOJSGlobal.m.

178{
179 JS_DefineProperties(context, global, sGlobalProperties);
180 JS_DefineFunctions(context, global, sGlobalMethods);
181}
static JSFunctionSpec sGlobalMethods[]
Definition OOJSGlobal.m:136

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:184
static JSBool GlobalSetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
Definition OOJSGlobal.m:221

Definition at line 89 of file OOJSGlobal.m.

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

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 },
{ "getColorSaturation", GlobalGetColorSaturation, 0 },
{ "setColorSaturation", GlobalSetColorSaturation, 1 },
{ "setExtraGuiScreenKeys", GlobalSetExtraGuiScreenKeys, 2 },
{ "clearExtraGuiScreenKeys", GlobalClearExtraGuiScreenKeys, 2 },
{ "takeSnapShot", GlobalTakeSnapShot, 1 },
{ "pauseGame", GlobalPauseGame, 0 },
{ 0 }
}
static JSBool GlobalSetScreenBackground(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:583
static JSBool GlobalExpandDescription(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:309
static JSBool GlobalPauseGame(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:880
static JSBool GlobalSetScreenOverlay(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:673
static JSBool GlobalGetScreenBackgroundForKey(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:617
static JSBool GlobalLog(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:264
static JSBool GlobalGetGuiColorSettingForKey(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:704
static JSBool GlobalExpandMissionText(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:361
static JSBool GlobalSetColorSaturation(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:793
static JSBool GlobalSetScreenBackgroundForKey(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:640
static JSBool GlobalKeyBindingDescription(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:336
static JSBool GlobalSetExtraGuiScreenKeys(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:487
static JSBool GlobalDisplayNameForCommodity(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:389
static JSBool GlobalRandomInhabitantsDescription(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:430
static JSBool GlobalTakeSnapShot(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:813
static JSBool GlobalClearExtraGuiScreenKeys(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:452
static JSBool GlobalSetGuiColorSettingForKey(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:735
static JSBool GlobalAutoAIForRole(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:858
static JSBool GlobalGetColorSaturation(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:782
static JSBool GlobalRandomName(JSContext *context, uintN argc, jsval *vp)
Definition OOJSGlobal.m:408

Definition at line 136 of file OOJSGlobal.m.

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

Referenced by SetUpOOJSGlobal().

◆ sGlobalProperties

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

Definition at line 123 of file OOJSGlobal.m.

124{
125 // JS name ID flags
126 { "galaxyNumber", kGlobal_galaxyNumber, OOJS_PROP_READONLY_CB },
129#ifndef NDEBUG
130 { "timeAccelerationFactor", kGlobal_timeAccelerationFactor, OOJS_PROP_READWRITE_CB },
131#endif
132 { 0 }
133};

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