Browse Source

Add config functions.

Mark Sibly 7 years ago
parent
commit
df058d031c
1 changed files with 36 additions and 0 deletions
  1. 36 0
      modules/std/filesystem/filesystem.monkey2

+ 36 - 0
modules/std/filesystem/filesystem.monkey2

@@ -50,6 +50,8 @@ Function CopyFile:Bool( srcPath:String,dstPath:String )="bbFileSystem::copyFile"
 	
 	
 Private
 Private
 
 
+Global _config:=New StringMap<String>
+
 Function FixPath:String( path:String )
 Function FixPath:String( path:String )
 	
 	
 	Local root:=ExtractRootDir( path )
 	Local root:=ExtractRootDir( path )
@@ -175,6 +177,40 @@ Function SetEnv( name:String,value:String )
 	setenv( name,value,1 )
 	setenv( name,value,1 )
 End
 End
 
 
+#rem monkeydoc Gets a global config setting.
+
+See also [[SetConfig]] for a list of possible config settings.
+
+#end
+Function GetConfig:String( name:String,defaultValue:String="" )
+	
+	Return _config.Contains( name ) ? _config[name] Else defaultValue
+End
+
+#rem monkeydoc Sets a global config setting.
+
+Currently known built-in config settings:
+
+| Name								| More information
+|:----------------------------------|:----------------
+| "MOJO_OPENGL_PROFILE"				| [[mojo:mojo.app.AppInstance.New|AppInstance.New]]
+| "MOJO_OPENGL_VERSION_MAJOR"		| [[mojo:mojo.app.AppInstance.New|AppInstance.New]]
+| "MOJO_OPENGL_VERSION_MINOR"		| [[mojo:mojo.app.AppInstance.New|AppInstance.New]]
+| "MOJO_COLOR_BUFFER_BITS"			| [[mojo:mojo.app.AppInstance.New|AppInstance.New]]
+| "MOJO_DEPTH_BUFFER_BITS"			| [[mojo:mojo.app.AppInstance.New|AppInstance.New]]
+| "MOJO_STENCIL_BUFFER_BITS"		| [[mojo:mojo.app.AppInstance.New|AppInstance.New]]
+| "MOJO_TEXTURE_MAX_ANISOTROPY"		| [[mojo:mojo.graphics.Texture.New|Texture.New]]
+| "MOJO3D_DEFAULT_RENDERER"			| [[mojo3d:mojo3d.Renderer.GetCurrent|Renderer.GetCurrent]]
+| "MOJO3D_FORWARD_RENDERER_DIRECT"	| [[mojo3d:mojo3d.ForwardRenderer.New|ForwardRenderer.New]]
+
+See also: [[GetConfig]].
+
+#end
+Function SetConfig( name:String,value:String )
+	
+	If value _config[name]=value Else _config.Remove( name )
+End
+
 #rem monkeydoc Gets the filesystem directory of the app's assets directory.
 #rem monkeydoc Gets the filesystem directory of the app's assets directory.
 
 
 Note that only the desktop and web targets have an assets directory. Other targets will return an empty string.
 Note that only the desktop and web targets have an assets directory. Other targets will return an empty string.