For the really curious, here is the (mostly) functioning code for the video options tab. The game quality section is the only part not hooked up to real settings. The rest is 100% functional and works like one would expect to allow changing the video settings at runtime.
[java]
section( “Options” ) {
tab( "Video" ) {
section( "Display" ) {
label( "Display Info" ).onInit {
name = DisplaySettings.instance.rendererName.take(30);
name += "\n" + DisplaySettings.instance.vendor
name += "\nOpenGL:" + DisplaySettings.instance.openGlVersion
name += " GLSL:" + DisplaySettings.instance.glslVersion
name += "\nGPU: " + DisplaySettings.instance.adapter
name += " ver: " + DisplaySettings.instance.driverVersion;
}
columns {
checkbox( name:"Full Screen", checked:app.fullScreen ).onChange {
def resolutions = getElement( "Options.Video.Display.Resolution" )
if( checked ) {
resolutions.options = DisplaySettings.instance.screenResolutions
resolutions.defaultValue = DisplaySettings.instance.defaultScreenResolution
} else {
resolutions.options = DisplaySettings.instance.windowedResolutions
resolutions.defaultValue = DisplaySettings.instance.defaultWindowedResolution
}
app.setFullScreen( checked );
getElement( "Options.Video.Display.Apply" )?.fireChange()
}
checkbox( name:"V-sync", checked:app.VSync ).onChange {
app.setVSync( checked );
getElement( "Options.Video.Display.Apply" )?.fireChange()
}
}
slider( name:"Resolution", options:DisplaySettings.instance.windowedResolutions, defaultValue:DisplaySettings.instance.defaultWindowedResolution ).onChange {
app.setResolution( value );
getElement( "Options.Video.Display.Apply" )?.fireChange()
}
slider( name:"Anti-aliasing", options:["Off", "x2", "x4", "x6", "x8", "x16"], value:app.aaString, defaultValue:"Off" ).onChange {
app.setAaString( value );
getElement( "Options.Video.Display.Apply" )?.fireChange()
}
action( name:"Apply", enabled:false ).onChange {
// Check the UI settings against the real current settings and
// set enabled state if they are different.
enabled = !app.areSettingsCurrent();
}.onClick {
app.applySettings()
fireChange()
}
}
section( "Game Quality" ) {
checkbox( "Low Quality Shaders" )
slider( name:"Clip", options:["64 m", "96 m", "128 m", "160 m", "192 m"], defaultValue:"128 m" )
}
}
…
[/java]
You can kind of see how powerful this level of abstraction is. Directly hooking up the abstract structure and events to real code.