Update of /cvsroot/arianne/stendhal/src/games/stendhal/client/update
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv31366/src/games/stendhal/client/update
Modified Files:
ClientGameConfiguration.java
Added Files:
DefaultGameProperties.java
Log Message:
moved default properties into a class so that default properties are retrieved even if the file misses
--- NEW FILE: DefaultGameProperties.java ---
package games.stendhal.client.update;
import java.util.Properties;
public class DefaultGameProperties extends Properties {
public DefaultGameProperties() {
super();
this.put("GAME_NAME", "Stendhal");
this.put("GAME_ICON", "data/gui/StendhalIcon.png");
this.put("GAME_SPLASH_BACKGROUND", "data/gui/StendhalSplash.jpg");
this.put("DEFAULT_SERVER", "stendhal.game-host.org");
this.put("DEFAULT_PORT", "32160");
this.put("UPDATE_ENABLE_AUTO_UPDATE", "true");
this.put("UPDATE_SERVER_FOLDER", "http://arianne.sourceforge.net/stendhal/updates");
this.put("UPDATE_VERSION_CHECK", "http://arianne.sourceforge.net/stendhal.version");
this.put("UPDATE_SIGNER_FILE_NAME", "META-INF/MIGUELAN.SF");
}
}
Index: ClientGameConfiguration.java
===================================================================
RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/client/update/ClientGameConfiguration.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** ClientGameConfiguration.java 12 Jul 2008 14:44:31 -0000 1.6
--- ClientGameConfiguration.java 19 May 2009 13:31:20 -0000 1.7
***************
*** 1,5 ****
package games.stendhal.client.update;
- import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
--- 1,4 ----
***************
*** 14,35 ****
private static ClientGameConfiguration instance;
! private Properties gameConfig;
private ClientGameConfiguration() {
! // Singleton pattern, hide constructor
! try {
! final Properties temp = new Properties();
! InputStream is = ClientGameConfiguration.class.getResourceAsStream("game-default.properties");
! temp.load(is);
! is.close();
! gameConfig = new Properties(temp);
! is = ClientGameConfiguration.class.getResourceAsStream("game.properties");
if (is != null) {
gameConfig.load(is);
is.close();
}
! } catch (final IOException e) {
! e.printStackTrace();
}
}
--- 13,35 ----
private static ClientGameConfiguration instance;
! private Properties gameConfig = getGameProperties();
private ClientGameConfiguration() {
! instance = this;
! }
! private Properties getGameProperties() {
! try {
! InputStream is = ClientGameConfiguration.class
! .getResourceAsStream("game.properties");
if (is != null) {
gameConfig.load(is);
is.close();
+ } else {
+ gameConfig = new DefaultGameProperties();
}
! return gameConfig;
! } catch (Exception e) {
! return new DefaultGameProperties();
}
}
|