📄 propertiesgamesettings.java
字号:
}
/**
* If the properties file does not contain the setting or was not read
* properly, the default value is returned.
*
* @see GameSettings#getSamples()
* @throws InternalError in all cases
*/
public int getSamples() {
String s = prop.getProperty("SAMPLES");
return (s == null) ? defaultSamples : Integer.parseInt(s);
}
/**
* If the properties file does not contain the setting or was not read
* properly, the default value is returned.
*
* @see GameSettings#getStencilBits()
* @throws InternalError in all cases
*/
public int getStencilBits() {
String s = prop.getProperty("STENCIL_BITS");
return (s == null) ? defaultStencilBits : Integer.parseInt(s);
}
/**
* If the properties file does not contain the setting or was not read
* properly, the default value is returned.
*
* @see GameSettings#isMusic()
* @throws InternalError in all cases
*/
public boolean isMusic() {
String s = prop.getProperty("MUSIC");
return (s == null) ? defaultMusic : Boolean.parseBoolean(s);
}
/**
* If the properties file does not contain the setting or was not read
* properly, the default value is returned.
*
* @see GameSettings#isSFX()
* @throws InternalError in all cases
*/
public boolean isSFX() {
String s = prop.getProperty("SFX");
return (s == null) ? defaultSFX : Boolean.parseBoolean(s);
}
/**
* If the properties file does not contain the setting or was not read
* properly, the default value is returned.
*
* @see GameSettings#isVerticalSync()
* @throws InternalError in all cases
*/
public boolean isVerticalSync() {
String s = prop.getProperty("VERTICAL_SYNC");
return (s == null) ? defaultVerticalSync : Boolean.parseBoolean(s);
}
/**
* Legacy method.
*
* @deprecated Use method getFrequency instead.
* @see #getFrequency()
*/
public int getFreq() {
return getFrequency();
}
/**
* Legacy method.
*
* @deprecated Use method isFullscreen instead.
* @see #isFullscreen()
*/
public boolean getFullscreen() {
return isFullscreen();
}
/**
* @see GameSettings#getBoolean(String, boolean)
*/
public boolean getBoolean(String name, boolean defaultValue) {
String stringValue = get(name);
return (stringValue == null)
? defaultValue : Boolean.parseBoolean(stringValue);
}
/**
* @see GameSettings#getByteArray(String, byte[])
*/
public byte[] getByteArray(String name, byte[] defaultValue) {
String stringValue = get(name);
return (stringValue == null)
? defaultValue : stringValue.getBytes();
}
/**
* @see GameSettings#getDouble(String, double)
*/
public double getDouble(String name, double defaultValue) {
String stringValue = get(name);
return (stringValue == null)
? defaultValue : Double.parseDouble(stringValue);
}
/**
* @see GameSettings#getFloat(String, float)
*/
public float getFloat(String name, float defaultValue) {
String stringValue = get(name);
return (stringValue == null)
? defaultValue : Float.parseFloat(stringValue);
}
/**
* @see GameSettings#getInt(String, int)
*/
public int getInt(String name, int defaultValue) {
String stringValue = get(name);
return (stringValue == null)
? defaultValue : Integer.parseInt(stringValue);
}
/**
* @see GameSettings#getLong(String, long)
*/
public long getLong(String name, long defaultValue) {
String stringValue = get(name);
return (stringValue == null)
? defaultValue : Long.parseLong(stringValue);
}
/**
* @see GameSettings#getObject(String, Object)
*/
public Object getObject(String name, Object defaultValue) {
String stringValue = get(name);
return (stringValue == null) ? defaultValue : stringValue;
}
/**
* Removes specified property, if present.
*/
public void remove(String name) {
prop.remove(name);
}
/**
* Sets a property.
*
* @see GameSettings#set(String, String)
*/
public void set(String name, String value) {
prop.setProperty(name, value);
}
/**
* save() method which throws only a RuntimeExceptin.
*
* @throws RuntimeSetting for IO failure
* @see #save()
*/
public void wrappedSave() {
try {
save();
} catch (IOException ioe) {
logger.log(Level.WARNING,
"Failed to persist properties", ioe);
throw new RuntimeException(ioe);
}
}
/**
* @see #set(String, String)
* @see PreferencesGameSettings#setBoolean(String, boolean)
* @throws RuntimeSetting for IO failure
*/
public void setBoolean(String name, boolean value) {
set(name, Boolean.toString(value));
}
/**
* @see #set(String, String)
* @see PreferencesGameSettings#setByteArray(String, byte[])
* @throws RuntimeSetting for IO failure
*/
public void setByteArray(String name, byte[] value) {
set(name, new String(value));
}
/**
* @see #set(String, String)
* @see PreferencesGameSettings#setDouble(String, double)
* @throws RuntimeSetting for IO failure
*/
public void setDouble(String name, double value) {
set(name, Double.toString(value));
}
/**
* @see #set(String, String)
* @see PreferencesGameSettings#setFloat(String, float)
* @throws RuntimeSetting for IO failure
*/
public void setFloat(String name, float value) {
set(name, Float.toString(value));
}
/**
* @see #set(String, String)
* @see PreferencesGameSettings#setInt(String, int)
* @throws RuntimeSetting for IO failure
*/
public void setInt(String name, int value) {
set(name, Integer.toString(value));
}
/**
* @see #set(String, String)
* @see PreferencesGameSettings#setLong(String, long)
* @throws RuntimeSetting for IO failure
*/
public void setLong(String name, long value) {
set(name, Long.toString(value));
}
/**
* Not implemented.
* Properties can not store an arbitrary Object in human-readable format.
* Use set(String, String) instead.
*
* @see PreferencesGameSettings#setObject(String, boolean)
* @see #set(String, String)
* @throws InternalError in all cases
*/
public void setObject(String name, Object value) {
throw new InternalError(getClass().getName()
+ " Can't store arbitrary objects. "
+ "If there is a toString() method for your Object, and it is "
+ "Properties-compatible, use " + getClass().getName()
+ ".set(String, String).");
}
/**
* @see GameSettings#setWidth(int)
*/
public void setWidth(int width) {
setInt("WIDTH", width);
}
/**
* @see GameSettings#setHeight(int)
*/
public void setHeight(int height) {
setInt("HEIGHT", height);
}
/**
* @see GameSettings#setDepth(int)
*/
public void setDepth(int depth) {
setInt("DEPTH", depth);
}
/**
* @see GameSettings#setFrequency(int)
*/
public void setFrequency(int freq) {
setInt("FREQ", freq);
}
/**
* @see GameSettings#setFullscreen(boolean)
*/
public void setFullscreen(boolean fullscreen) {
setBoolean("FULLSCREEN", fullscreen);
}
/**
* @see GameSettings#setRenderer(String)
*/
public void setRenderer(String renderer) {
set("RENDERER", renderer);
}
/**
* @see GameSettings#setAlphaBits(int)
* @throws InternalError in all cases
*/
public void setAlphaBits(int alphaBits) {
setInt("ALPHA_BITS", alphaBits);
}
/**
* @see GameSettings#setDepthBits(int)
* @throws InternalError in all cases
*/
public void setDepthBits(int depthBits) {
setInt("DEPTH_BITS", depthBits);
}
/**
* @see GameSettings#setFramerate(int)
* @throws InternalError in all cases
*/
public void setFramerate(int framerate) {
setInt("FRAMERATE", framerate);
}
/**
* @see GameSettings#setMusic(boolean)
* @throws InternalError in all cases
*/
public void setMusic(boolean music) {
setBoolean("MUSIC", music);
}
/**
* @see GameSettings#setSamples(int)
* @throws InternalError in all cases
*/
public void setSamples(int samples) {
setInt("SAMPLES", samples);
}
/**
* @see GameSettings#setSFX(boolean)
* @throws InternalError in all cases
*/
public void setSFX(boolean sfx) {
setBoolean("SFX", sfx);
}
/**
* @see GameSettings#setStencilBits(int)
* @throws InternalError in all cases
*/
public void setStencilBits(int stencilBits) {
setInt("STENCIL_BITS", stencilBits);
}
/**
* @see GameSettings#setVerticalSync(boolean)
* @throws InternalError in all cases
*/
public void setVerticalSync(boolean verticalSync) {
setBoolean("VERTICAL_SYNC", verticalSync);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -