|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--superwaba.ext.xplat.util.props.Properties | +--superwaba.ext.xplat.game.Options
The game options management class.
The options are stored in a waba Catalog object which is linked to the
application through the software creatorID. This causes the options
database deletion when the game with the same creatorID is erased.
The complete database name is composed by the game name 'appl' and its creatorID, both
provided during the engine initialization via the GameEngineClient interface.
The options database name is : ${appl}_OPT.${creatorID}.DATA
You can find a complete game API sample named 'Ping' in the SW examples folder.
Here is some sample code:
import superwaba.ext.xplat.game.*; import superwaba.ext.xplat.util.props.*; ... public class Ping extends GameEngine { // constructor public Ping() { waba.sys.Settings.setPalmOSStyle(true); // define the game API setup attributes gameName = "Ping"; // when not run on device, appCreatorId does not always return the same value. gameCreatorID = Settings.onDevice ? waba.sys.Settings.appCreatorId:"PiNg"; gameVersion = 100; // v1.00 gameHighscoresSize = 7; // store the best 7 highscores gameRefreshPeriod = 75; // 75 ms refresh periods gameIsDoubleBuffered = true; // used double buffering to prevent flashing display gameDoClearScreen = true; // screen is cleared before each frame display gameHasUI = false; // no UI elements, frame displays are optimized ... } // declare 2 game settings protected Properties.Str optUserName; protected Properties.Boolean optSound; //--------------------------------------------------------- // overload the API's game init event. // this function is called when the game is launched. //--------------------------------------------------------- public void onGameInit() { // access the game settings: 'username' & 'sound' // if the properties do not yet exist, the default values are used Options settings=getOptions(); optUserName = settings.declareString ("userName","noname"); optSound = settings.declareBoolean ("sound",false); ... if (optSound.value) Sound.tone(1520,10); } }
Inner classes inherited from class superwaba.ext.xplat.util.props.Properties |
Properties.Boolean,
Properties.Double,
Properties.Int,
Properties.Long,
Properties.Str,
Properties.Value |
Field Summary | |
int |
newVersion
The options database new version number. |
int |
oldVersion
The options database old version number. |
Constructor Summary | |
protected |
Options(GameEngine engine)
|
Method Summary | |
boolean |
close()
closes the settings database. |
Properties.Boolean |
declareBoolean(String name,
boolean value)
Declare a boolean option. This function tries to lookup the property in the Options database. If it fails, a new property with the default value specified is created. |
Properties.Double |
declareDouble(String name,
double value)
Declare a double option. This function tries to lookup the property in the Options database. If it fails, a new property with the default value specified is created. |
Properties.Int |
declareInteger(String name,
int value)
Declare an integer option. This function tries to lookup the property in the Options database. If it fails, a new property with the default value specified is created. |
Properties.Long |
declareLong(String name,
long value)
Declare a long option. This function tries to lookup the property in the Options database. If it fails, a new property with the default value specified is created. |
Properties.Str |
declareString(String name,
String value)
Declare a string option. This function tries to lookup the property in the Options database. If it fails, a new property with the default value specified is created. |
Properties.Value |
getProp(String key)
Get a property value given the key. |
boolean |
save()
stores the settings database. |
Methods inherited from class superwaba.ext.xplat.util.props.Properties |
clear,
get,
getKeys,
load,
put,
remove,
save,
size |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
toString,
wait,
wait |
Field Detail |
public int newVersion
public int oldVersion
Constructor Detail |
protected Options(GameEngine engine)
Method Detail |
public Properties.Boolean declareBoolean(String name, boolean value)
name
- the property name.value
- the property default value.public Properties.Long declareLong(String name, long value)
name
- the property name.value
- the property default value.public Properties.Int declareInteger(String name, int value)
name
- the property name.value
- the property default value.public Properties.Double declareDouble(String name, double value)
name
- the property name.value
- the property default value.public Properties.Str declareString(String name, String value)
name
- the property name.value
- the property default value.public Properties.Value getProp(String key)
key
- name of the propertytype
read-only property.public boolean save()
public boolean close()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |