com.jme.system
Class AbstractGameSettings
java.lang.Object
com.jme.system.AbstractGameSettings
- All Implemented Interfaces:
- GameSettings
- Direct Known Subclasses:
- PreferencesGameSettings, PropertiesGameSettings
public abstract class AbstractGameSettings
- extends java.lang.Object
- implements GameSettings
Code generally useful to all typical GameSettings implementations.
Admitted limitation of the static default* design is that we assume
only one "game" runs in the JVM.
I know of no use case that conflict with this.
A particularly useful feature of AbstractGameSettings is the optional
usage of game-specific (not session-specific) overrides.
You can override the DEFAULT_* settings defined in the GameSettings
interface, and you can also change values for settings without
GameSettings setters (i.e. settings not for end-user usage).
Here's a sample game-defaults.properties file:
# This overrides GameSettigns.DEFAULT_MUSIC
DEFAULT_MUSIC: false
# Similarly...
DEFAULT_SFX: false
# This assigns a resource which end-users can't modify.
SETTINGS_WIDGET_IMAGE: /jmetest/data/texture/spark.jpg
The defaults can also be changed programmatically instead of
declaratively, of course. See BaseGame.java for examples of that.
- Since:
- jME 2.0
- Version:
- $Revision: 4318 $, $Date: 2009-05-02 00:10:05 +0100 (Sat, 02 May 2009) $
- Author:
- Blaine Simpson (blaine dot simpson at admc dot com)
- See Also:
GameSettings
,
BaseGame
,
GameSettings
Fields inherited from interface com.jme.system.GameSettings |
DEFAULT_ALPHA_BITS, DEFAULT_DEPTH, DEFAULT_DEPTH_BITS, DEFAULT_FRAMERATE, DEFAULT_FREQUENCY, DEFAULT_FULLSCREEN, DEFAULT_HEIGHT, DEFAULT_MUSIC, DEFAULT_RENDERER, DEFAULT_SAMPLES, DEFAULT_SFX, DEFAULT_STENCIL_BITS, DEFAULT_VERTICAL_SYNC, DEFAULT_WIDTH |
Method Summary |
protected static void |
assignDefaults(java.lang.String propFileName)
Sets default* static variables according to GameSettings.DEFAULT_*
values and an optional .properties file. |
java.lang.String |
getDefaultSettingsWidgetImage()
This is only getting the "default" value, which may not be changed
by end-users. |
boolean |
isNew()
|
static java.lang.Boolean |
loadBoolean(java.lang.String name,
java.util.Properties props)
|
static java.lang.Integer |
loadInteger(java.lang.String name,
java.util.Properties props)
|
protected static java.lang.String |
normalizeName(java.lang.String inName)
|
void |
setIsNew(boolean isNew)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.jme.system.GameSettings |
clear, get, getAlphaBits, getBoolean, getByteArray, getDepth, getDepthBits, getDouble, getFloat, getFramerate, getFrequency, getHeight, getInt, getLong, getObject, getRenderer, getSamples, getStencilBits, getWidth, isFullscreen, isMusic, isSFX, isVerticalSync, save, set, setAlphaBits, setBoolean, setByteArray, setDepth, setDepthBits, setDouble, setFloat, setFramerate, setFrequency, setFullscreen, setHeight, setInt, setLong, setMusic, setObject, setRenderer, setSamples, setSFX, setStencilBits, setVerticalSync, setWidth |
isNew
protected boolean isNew
defaultWidth
protected static java.lang.Integer defaultWidth
defaultHeight
protected static java.lang.Integer defaultHeight
defaultDepth
protected static java.lang.Integer defaultDepth
defaultFrequency
protected static java.lang.Integer defaultFrequency
defaultFullscreen
protected static java.lang.Boolean defaultFullscreen
defaultRenderer
protected static java.lang.String defaultRenderer
defaultVerticalSync
protected static java.lang.Boolean defaultVerticalSync
defaultDepthBits
protected static java.lang.Integer defaultDepthBits
defaultAlphaBits
protected static java.lang.Integer defaultAlphaBits
defaultStencilBits
protected static java.lang.Integer defaultStencilBits
defaultSamples
protected static java.lang.Integer defaultSamples
defaultMusic
protected static java.lang.Boolean defaultMusic
defaultSFX
protected static java.lang.Boolean defaultSFX
defaultFramerate
protected static java.lang.Integer defaultFramerate
defaultSettingsWidgetImage
protected static java.lang.String defaultSettingsWidgetImage
AbstractGameSettings
public AbstractGameSettings()
getDefaultSettingsWidgetImage
public java.lang.String getDefaultSettingsWidgetImage()
- This is only getting the "default" value, which may not be changed
by end-users.
- Specified by:
getDefaultSettingsWidgetImage
in interface GameSettings
assignDefaults
protected static void assignDefaults(java.lang.String propFileName)
- Sets default* static variables according to GameSettings.DEFAULT_*
values and an optional .properties file.
Note that we are talking about defaults here, not
user-specific settings.
This method should be called once the game name is known to the
subclass.
To override any default with your subclass (as opposed to by using
a .properties file), just set the static variable before or after
calling this method (before or after depends on the precedence you
want among programmatic and declarative DEFAULT_*, default* settings).
Add new setting names by making your own method which does its own
thing and calls AbstractGameSettings.assignDefaults(propfilename).
Property file paths are relative to CLASSPATH element roots.
- Parameters:
propFileName
- Properties file read as CLASSPATH resource.
If you give null, no properties file will be loaded.
loadInteger
public static java.lang.Integer loadInteger(java.lang.String name,
java.util.Properties props)
loadBoolean
public static java.lang.Boolean loadBoolean(java.lang.String name,
java.util.Properties props)
normalizeName
protected static java.lang.String normalizeName(java.lang.String inName)
- Parameters:
inName
- Must be non-null
setIsNew
public void setIsNew(boolean isNew)
- See Also:
GameSettings.isNew()
isNew
public boolean isNew()
- Specified by:
isNew
in interface GameSettings
- See Also:
GameSettings.isNew()