33#import "MyOpenGLView.h"
37static JSBool
OoliteGetProperty(JSContext *context, JSObject *
this, jsid propID, jsval *value);
38static JSBool
OoliteSetProperty(JSContext *context, JSObject *
this, jsid propID, JSBool strict, jsval *value);
119 if (!JSID_IS_INT(propID))
return YES;
126 switch (JSID_TO_INT(propID))
137 *value = INT_TO_JSVAL(JS_GetVersion(context));
141 *value = STRING_TO_JSVAL(JS_NewStringCopyZ(context, JS_VersionToString(JS_GetVersion(context))));
145 result = [UNIVERSE gameSettings];
154 return JS_NewNumberValue(context, [gameView colorSaturation], value);
157 *value = INT_TO_JSVAL([
UNIVERSE currentPostFX]);
162 NSString *toneMapperStr =
@"OOHDR_TONEMAPPER_UNDEFINED";
164 if ([gameView hdrOutput])
169 result = toneMapperStr;
175 NSString *toneMapperStr =
@"OOSDR_TONEMAPPER_UNDEFINED";
176 if (![gameView hdrOutput])
180 result = toneMapperStr;
186 return JS_NewNumberValue(context, [
UNIVERSE timeAccelerationFactor], value);
201static JSBool
OoliteSetProperty(JSContext *context, JSObject *
this, jsid propID, JSBool strict, jsval *value)
203 if (!JSID_IS_INT(propID))
return YES;
209 NSString *sValue =
nil;
212 switch (JSID_TO_INT(propID))
215 if (JS_ValueToNumber(context, *value, &fValue))
224 if (JS_ValueToInt32(context, *value, &iValue))
226 iValue =
MAX(iValue, 0);
227 [UNIVERSE setCurrentPostFX:iValue];
233 if (!JSVAL_IS_STRING(*value))
break;
238 if ([gameView hdrOutput]) [gameView setHDRToneMapper:OOHDRToneMapperFromString(sValue)];
239 else OOJSReportWarning(context,
@"hdrToneMapper cannot be set if not running in HDR mode");
246 if (!JSVAL_IS_STRING(*value))
break;
250 if (![gameView hdrOutput]) [gameView
setSDRToneMapper:OOSDRToneMapperFromString(sValue)];
251 else OOJSReportWarning(context,
@"sdrToneMapper cannot be set if not running in SDR mode");
258 if (JS_ValueToNumber(context, *value, &fValue))
260 [UNIVERSE setTimeAccelerationFactor:fValue];
280 return [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
302 NSEnumerator *componentEnum =
nil;
308 if ([components isKindOfClass:[NSArray
class]])
311 for (componentEnum = [components objectEnumerator]; (component = [componentEnum nextObject]); )
313 if (![component isKindOfClass:[NSNumber
class]])
320 else if ([components isKindOfClass:[NSString
class]])
324 else components =
nil;
326 if (components !=
nil)
NSString * OOStringFromHDRToneMapper(OOHDRToneMapper toneMapper)
NSString * OOStringFromSDRToneMapper(OOSDRToneMapper toneMapper)
#define OOJS_NATIVE_ENTER(cx)
static JSBool OoliteGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
static JSFunctionSpec sOoliteMethods[]
static JSBool OoliteSetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
@ kOolite_timeAccelerationFactor
@ kOolite_colorSaturation
@ kOolite_jsVersionString
static JSPropertySpec sOoliteProperties[]
static JSClass sOoliteClass
static JSBool OoliteCompareVersion(JSContext *context, uintN argc, jsval *vp)
void InitOOJSOolite(JSContext *context, JSObject *global)
static NSString * VersionString(void)
static NSArray * VersionComponents(void)
id OOJSNativeObjectFromJSValue(JSContext *context, jsval value)
void OOJSReportWarning(JSContext *context, NSString *format,...)
#define OOJS_PROP_READWRITE_CB
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
NSString * OOStringFromJSValue(JSContext *context, jsval value)
JSBool OOJSUnconstructableConstruct(JSContext *context, uintN argc, jsval *vp)
#define OOJS_PROP_READONLY
void OOJSReportBadPropertyValue(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec, jsval value)
#define OOJS_PROP_READONLY_CB
#define OOJS_RETURN_INT(v)
NSArray * ComponentsFromVersionString(NSString *string)
NSComparisonResult CompareVersions(NSArray *version1, NSArray *version2)
void adjustColorSaturation:(float colorSaturationAdjustment)
void setSDRToneMapper:(OOSDRToneMapper newToneMapper)
NSArray * maskUserNameInPathArray:(NSArray *inputPathArray)