|
From: <ste...@us...> - 2010-07-25 22:45:40
|
Revision: 1360
http://rails.svn.sourceforge.net/rails/?rev=1360&view=rev
Author: stefanfrey
Date: 2010-07-25 22:45:34 +0000 (Sun, 25 Jul 2010)
Log Message:
-----------
Further update of configuration
Modified Paths:
--------------
trunk/18xx/LocalisedText.properties
trunk/18xx/data/Properties.xml
trunk/18xx/default.profiles
trunk/18xx/rails/ui/swing/ConfigWindow.java
trunk/18xx/rails/util/Config.java
trunk/18xx/rails/util/ConfigItem.java
trunk/18xx/rails/util/LocalText.java
Added Paths:
-----------
trunk/18xx/data/profiles/
trunk/18xx/data/profiles/default.profile
trunk/18xx/data/profiles/test.profile
Removed Paths:
-------------
trunk/18xx/test/test.properties
Modified: trunk/18xx/LocalisedText.properties
===================================================================
--- trunk/18xx/LocalisedText.properties 2010-07-25 19:27:21 UTC (rev 1359)
+++ trunk/18xx/LocalisedText.properties 2010-07-25 22:45:34 UTC (rev 1360)
@@ -54,6 +54,7 @@
BuysTrainUsingSP={0} buys a {1}-train from {2} for {3} using {4}.
BYFloatsAt=Bayern floats at
CASH=Cash
+CANCEL=Cancel
CanOperate={0} can operate this round
CannotOperate={0} cannot operate this round
CannotBuyAnything={0} cannot buy anything
@@ -64,7 +65,17 @@
CLOSE_WINDOW=Do you really want to exit the game?
COMPANY=Company
COMPANY_DETAILS=Company details
-CONFIG_CURRENT_PROFILE=Active profile = {0} (based on = {1})
+CONFIG=Configuration
+CONFIG_CURRENT_PROFILE=Active profile = {0} (based on = {1})
+CONFIG_DEFAULT_TITLE=Default profile
+CONFIG_DEFAULT_MESSAGE=Select a template for settings
+CONFIG_NEW_MESSAGE=Select a name of the new profile
+CONFIG_NEW_TITLE=Create profile
+CONFIG_SELECT_PROFILE=Select profile ->
+CONFIG_SETTINGS=Profile settings
+CONFIG_SAVE_MESSAGE=Active profile {0} was saved
+CONFIG_SAVE_TITLE=Save confirmation
+CONFIG_WINDOW_TITLE=Rails Configuration
CORRECT_CASH=Cash Correction
CORRECT_MAP=Map Correction
CURRENT=Current
@@ -440,6 +451,7 @@
RunsWithBorrowedTrain={0} runs with a borrowed {1}-train and must withhold revenue
RustsTrains=Rusts {0}-trains
SAVE=Save
+SAVEAS=Save As ...
SaveFailed=Save failed, reason: {0}
Select=Select
SelectCompanyToMergeMinorInto=Select major company to merge minor {0} into
Modified: trunk/18xx/data/Properties.xml
===================================================================
--- trunk/18xx/data/Properties.xml 2010-07-25 19:27:21 UTC (rev 1359)
+++ trunk/18xx/data/Properties.xml 2010-07-25 22:45:34 UTC (rev 1360)
@@ -4,13 +4,14 @@
-->
<Properties>
<Panel name="General">
- <Property name="locale" type="LIST" values="en_US,te_ST" helpText="Language Selection" />
+ <Property name="locale" type="LIST" values="en_US,te_ST" toolTip="Language Selection"
+ initClass="rails.util.LocalText" initMethod="setLocale" initParameter="yes"/>
</Panel>
<Panel name="Save">
- <Property name="save.dir" type="DIRECTORY" helpText="Default save file directory" />
-
+ <Property name="save.directory" type="DIRECTORY" toolTip="Default save file directory" />
+ <Property name="save.filename.date_time_pattern" type="STRING" toolTip="Datetime pattern for filename" />
</Panel>
<Panel name="Colors">
- <Property name="route.colour.1" type="COLOR"/>
+ <Property name="route.colour.1" type="COLOR" toolTip="Route color of first train" />
</Panel>
</Properties>
\ No newline at end of file
Added: trunk/18xx/data/profiles/default.profile
===================================================================
--- trunk/18xx/data/profiles/default.profile (rev 0)
+++ trunk/18xx/data/profiles/default.profile 2010-07-25 22:45:34 UTC (rev 1360)
@@ -0,0 +1,7 @@
+locale=en_US
+save.directory=
+save.filename.date_time_pattern=yyyyMMdd_HHmm
+save.filename.date_time_zone=UTC
+save.filename.suffix=NEXT_PLAYER
+save.filename.extension=rails
+
Copied: trunk/18xx/data/profiles/test.profile (from rev 1351, trunk/18xx/test/test.properties)
===================================================================
--- trunk/18xx/data/profiles/test.profile (rev 0)
+++ trunk/18xx/data/profiles/test.profile 2010-07-25 22:45:34 UTC (rev 1360)
@@ -0,0 +1,124 @@
+####################### Test preferences ################################
+#
+# Those are the settings used for automated testing
+#
+########################################################################
+#
+# Preferred tile format.
+# The only currently supported format is svg. Anything else is ignored.
+#tile.format_preference=svg
+# Root directory for the tile images (just above directory 'tiles').
+# Not required if tile images are provided included in the Rails jar file.
+#tile.root_directory=
+
+### Locale ####
+# Language: two-letter ISO code (lower case; default is en=English).
+# Country: two-letter ISO code (upper case; specifies country
+# (implying a language variant of that country; no default).
+# Locale: concatenation of the above. If present, overrides any of the above.
+# Examples: en, en_US, en_UK, fr_FR, fr_CA.
+locale=te_st
+#language=
+#country=
+
+### Money display ###
+# Each game has a specific format for monetary amounts (e.g. $100, 100M).
+# An overriding format can be specified here, but then applies to all games.
+# The @ character must be present and is replaced by the amount.
+# Example: \xA3@ to specify a pound sign prefix: \xA3100.
+#money_format=$@
+
+### Save file directory
+# If the below entry exists, is not empty, and specifies an existing
+# directory, that directory is used as a starting point for any
+# file choosing action for the Save and Load commands.
+# The path may be relative or absolute.
+save.directory=test/data
+# The default Save filename is <gamename>_<datetimepattern>.<extension>
+# This name will be initially proposed.
+# As soon as that proposal has been changed once in a Save action,
+# the last used name is always proposed in stead.
+# The default date/time pattern is yyyyMMdd_HHmm
+# The pattern codes are as defined in the Java class
+# SimpleDateFormat (just Google that name to find the codes).
+#save.filename.date_time_pattern=yyyyMMdd_HHmm
+# The default timezone is local time.
+# A specific timezone (such as UTC) can be set; the value must be a Java timezone ID
+#save.filename.date_time_zone=UTC
+# Optionally, a suffix (e.g. player name) can be added after the time stamp
+# with a preceding underscore (which is automatically added)
+# The special value NEXT_PLAYER puts the next moving player name into this spot.
+#save.filename.suffix=NEXT_PLAYER
+# The default extension is .rails
+save.filename.extension=rails
+
+### Game report directory
+# If the below entry exists, is not empty, and specifies an existing
+# directory, a copy of the Game Report (as displayed in the Report Window)
+# will be saved there. The path may be relative or absolute.
+#report.directory=log
+# The default file name includes the game name and the game start time:
+# 18XX_yyyymmdd_hhmm.txt where 18XX is the game name.
+# You can specify different values for the date/time part and teh extension here.
+# The date/time pattern must be as defined in the Java SimpleDateFormat class.
+#report.filename.date_time_pattern=yyyyMMdd
+report.filename.extension=report
+
+### Windows
+## Report window visibility
+# By default the report window is hidden when starting or loading a game.
+# This property allows to open it automatically.
+# Valid values are yes and no (default).
+#report.window.open=yes
+## Report window editability
+# Specify if the report window is editable, so you can add your own comments.
+# Valid values are yes and no (default).
+#report.window.editable=yes
+## Stock Chart window visibility
+# By default the stock chart hides at the end of an SR.
+# By specifying "yes" here, the window will not be automatically hidden any more
+#stockchart.window.open=yes
+
+### Player info
+## Default players
+# Comma-separated list of player names.
+# Useful for game testing purposes.
+#default_players=Alice,Bob,Charlie
+#
+## Local player name
+# Useful for distributed usage (Internet, PBEM, cloud storage/dropbox)
+# Required for "request turn" facility with cloud storage (dropbox)
+#local.player.name=Alice
+
+### Default game
+# Name of game selected in the game selection window.
+# Useful for game testing purposes.
+#default_game=1830
+
+### Various options
+# Show simple (ORx) or composite (ORx.x) OR number.
+# Valid values: "simple" and "composite" (default)
+#or.number_format=simple
+
+####################### Log4J properties ##############################
+# For information on how to customise log4j logging, see for instance
+# http://www.vipan.com/htdocs/log4jhelp.html
+# It's a bit outdated: Category is now named Logger,
+# and Priority is now named Level.
+# But it's the best intro I know on how to configure Appenders. (EV)
+#######################################################################
+# Set root logger level to DEBUG and use appender F(file)
+#log4j.debug=true
+log4j.rootLogger=DEBUG, F
+
+# Define the Log file appender
+log4j.appender.F=org.apache.log4j.FileAppender
+
+# Log file properties
+log4j.appender.F.File=test/test.log
+log4j.appender.F.append=false
+
+# Log file layout
+log4j.appender.F.layout=org.apache.log4j.PatternLayout
+log4j.appender.F.layout.ConversionPattern=%-5p %m%n
+################## End of Log4J properties #############################
\ No newline at end of file
Modified: trunk/18xx/default.profiles
===================================================================
--- trunk/18xx/default.profiles 2010-07-25 19:27:21 UTC (rev 1359)
+++ trunk/18xx/default.profiles 2010-07-25 22:45:34 UTC (rev 1360)
@@ -1,2 +1,2 @@
-default=my.properties
-test=test/test.properties
+default=data/profiles/default.profile
+.test=data/profiles/test.profile
Modified: trunk/18xx/rails/ui/swing/ConfigWindow.java
===================================================================
--- trunk/18xx/rails/ui/swing/ConfigWindow.java 2010-07-25 19:27:21 UTC (rev 1359)
+++ trunk/18xx/rails/ui/swing/ConfigWindow.java 2010-07-25 22:45:34 UTC (rev 1360)
@@ -53,7 +53,7 @@
ConfigWindow() {
// JFrame properties
- setTitle(LocalText.getText("ConfigWindowTitle"));
+ setTitle(LocalText.getText("CONFIG_WINDOW_TITLE"));
// setSize(400,300);
// add profile panel
@@ -96,7 +96,7 @@
Border titled = BorderFactory.createTitledBorder(etched, LocalText.getText("CONFIG_CURRENT_PROFILE", activeProfile, defaultProfile));
profilePanel.setBorder(titled);
- JLabel userLabel = new JLabel(LocalText.getText("CONFIG_SELECT_USER"));
+ JLabel userLabel = new JLabel(LocalText.getText("CONFIG_SELECT_PROFILE"));
profilePanel.add(userLabel);
final JComboBox comboBoxUser = new JComboBox(Config.getUserProfiles().toArray());
comboBoxUser.setSelectedItem(Config.getActiveProfileName());
@@ -151,17 +151,17 @@
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridwidth = 1;
gbc.gridheight = 1;
- gbc.gridx = 0;
gbc.weightx = 0.8;
gbc.weighty = 0.8;
gbc.insets = new Insets(10,10,10,10);
gbc.anchor = GridBagConstraints.WEST;
+ int y = 0;
for (ConfigItem item:configPanels.get(panelName)) {
gbc.gridx = 0;
+ gbc.gridy = y++;
defineElement(newPanel, item, gbc);
- gbc.gridy ++;
}
- configPane.addTab(panelName, newPanel);
+ configPane.addTab(LocalText.getText("Config.panel." + panelName), newPanel);
}
}
@@ -175,7 +175,7 @@
// standard components
final String configValue = item.getCurrentValue();
- final String toolTip = item.helpText;
+ final String toolTip = item.toolTip;
// item label
JLabel label = new JLabel(LocalText.getText("Config." + item.name));
@@ -329,8 +329,10 @@
if (Util.hasValue(newProfile)) {
String defaultProfile = (String)JOptionPane.showInputDialog(ConfigWindow.this, LocalText.getText("CONFIG_DEFAULT_MESSAGE"),
LocalText.getText("CONFIG_DEFAULT_TITLE"), JOptionPane.QUESTION_MESSAGE, null,
- Config.getDefaultProfiles().toArray(), Config.getDefaultProfileSelection());
+ Config.getDefaultProfiles(true).toArray(), Config.getDefaultProfileSelection());
+ if (Util.hasValue(defaultProfile)) {
Config.createUserProfile(newProfile, defaultProfile);
+ }
}
EventQueue.invokeLater(new Runnable() {
public void run() {
@@ -378,7 +380,7 @@
private void saveConfig() {
Config.updateProfile(); // transfer the configitem to the active profile
Config.saveActiveProfile();
- JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_SAVE_MESSAGE"),
+ JOptionPane.showMessageDialog(ConfigWindow.this, LocalText.getText("CONFIG_SAVE_MESSAGE", Config.getActiveProfileName()),
LocalText.getText("CONFIG_SAVE_TITLE"), JOptionPane.INFORMATION_MESSAGE);
}
Modified: trunk/18xx/rails/util/Config.java
===================================================================
--- trunk/18xx/rails/util/Config.java 2010-07-25 19:27:21 UTC (rev 1359)
+++ trunk/18xx/rails/util/Config.java 2010-07-25 22:45:34 UTC (rev 1360)
@@ -32,7 +32,6 @@
protected static Logger log;
/** Commandline options */
- private static final String LOG4J_CMDLINE = "log4j";
private static final String CONFIGFILE_CMDLINE = "configfile";
private static final String PROFILE_CMDLINE = "profile";
@@ -52,7 +51,7 @@
private static String userProfilesFile = "user.profiles";
private static Properties userProfiles = new Properties();
private static boolean profilesLoaded = false;
- private static final String TEST_PROFILE_SELECTION = "test";
+ private static final String TEST_PROFILE_SELECTION = ".test";
private static final String DEFAULT_PROFILE_SELECTION = "default";
private static final String STANDARD_PROFILE_SELECTION = "user";
private static final String DEFAULTPROFILE_PROPERTY = "default.profile";
@@ -128,6 +127,7 @@
for (ConfigItem item:items) {
if (!item.hasNewValue() || item.getNewValue().equals(defaultProperties.get(item.name))) continue;
userProperties.setProperty(item.name, item.getNewValue());
+ item.callInitMethod();
log.debug("Changed property name = " + item.name + " to value = " + item.getNewValue());
item.setNewValue(null);
}
@@ -210,9 +210,10 @@
}
- private static Map<String, String> convertProperties(Properties properties) {
+ private static Map<String, String> convertProperties(Properties properties, boolean visibleOnly) {
Map<String, String> converted = new HashMap<String, String>();
for (Object key:properties.keySet()) {
+ if (visibleOnly && ((String)key).substring(0,1).equals(".")) continue;
converted.put((String) key, (String) properties.get(key));
}
return converted;
@@ -221,8 +222,8 @@
/**
* get all default profiles
*/
- public static List<String> getDefaultProfiles() {
- List<String> profiles = new ArrayList<String>(convertProperties(defaultProfiles).keySet());
+ public static List<String> getDefaultProfiles(boolean visibleOnly) {
+ List<String> profiles = new ArrayList<String>(convertProperties(defaultProfiles, visibleOnly).keySet());
Collections.sort(profiles);
return profiles;
}
@@ -235,7 +236,7 @@
* get all user profiles
*/
public static List<String> getUserProfiles() {
- List<String> profiles = new ArrayList<String>(convertProperties(userProfiles).keySet());
+ List<String> profiles = new ArrayList<String>(convertProperties(userProfiles, true).keySet());
Collections.sort(profiles);
return profiles;
}
@@ -509,4 +510,5 @@
defaultProperties.put("save.directory", System.getProperty("user.dir"));
}
}
+
}
Modified: trunk/18xx/rails/util/ConfigItem.java
===================================================================
--- trunk/18xx/rails/util/ConfigItem.java 2010-07-25 19:27:21 UTC (rev 1359)
+++ trunk/18xx/rails/util/ConfigItem.java 2010-07-25 22:45:34 UTC (rev 1360)
@@ -1,5 +1,6 @@
package rails.util;
+import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
@@ -29,8 +30,15 @@
public final ConfigType type;
public final List<String> allowedValues;
public final String formatMask;
+ public final String toolTip;
public final String helpText;
+ // method call attributes
+ private final String initClass;
+ private final String initMethod;
+ private final boolean initParameter;
+
+
// dynamic attributes
private String newValue;
@@ -67,9 +75,16 @@
// optional: formatMask
formatMask = tag.getAttributeAsString("formatMask");
- // optional: helpText
+ // optional: helpText and toolTip
+ toolTip = tag.getAttributeAsString("toolTip");
helpText = tag.getAttributeAsString("helpText");
+
+ // optional: init method attributes
+ initClass = tag.getAttributeAsString("initClass");
+ initMethod = tag.getAttributeAsString("initMethod");
+ initParameter = tag.getAttributeAsBoolean("initParameter", false);
+ // initialize newValue
newValue = null;
}
@@ -99,6 +114,25 @@
return Config.get(this.name);
}
+ void callInitMethod() {
+ if (initClass == null || initMethod == null) return;
+
+ // call without parameter
+ try {
+ Class<?> clazz = Class.forName(initClass);
+
+ if (initParameter) {
+ clazz.getMethod(initMethod, String.class).invoke(null, newValue);
+
+ } else {
+ clazz.getMethod(initMethod).invoke(null);
+ }
+ } catch (Exception e) {
+ log.error("Config profile: cannot call initMethod");
+ }
+ }
+
+
public String toString() {
StringBuffer s = new StringBuffer();
s.append("Configuration Item: name = " + name + ", type = " + type);
Modified: trunk/18xx/rails/util/LocalText.java
===================================================================
--- trunk/18xx/rails/util/LocalText.java 2010-07-25 19:27:21 UTC (rev 1359)
+++ trunk/18xx/rails/util/LocalText.java 2010-07-25 22:45:34 UTC (rev 1360)
@@ -117,7 +117,9 @@
String[] codes = localeCode.split("_");
if (codes.length > 0) language = codes[0];
if (codes.length > 1) country = codes[1];
-
+
+ // reset localised text
+ localisedText = null;
}
public Enumeration<String> getKeys() {
Deleted: trunk/18xx/test/test.properties
===================================================================
--- trunk/18xx/test/test.properties 2010-07-25 19:27:21 UTC (rev 1359)
+++ trunk/18xx/test/test.properties 2010-07-25 22:45:34 UTC (rev 1360)
@@ -1,124 +0,0 @@
-####################### Test preferences ################################
-#
-# Those are the settings used for automated testing
-#
-########################################################################
-#
-# Preferred tile format.
-# The only currently supported format is svg. Anything else is ignored.
-#tile.format_preference=svg
-# Root directory for the tile images (just above directory 'tiles').
-# Not required if tile images are provided included in the Rails jar file.
-#tile.root_directory=
-
-### Locale ####
-# Language: two-letter ISO code (lower case; default is en=English).
-# Country: two-letter ISO code (upper case; specifies country
-# (implying a language variant of that country; no default).
-# Locale: concatenation of the above. If present, overrides any of the above.
-# Examples: en, en_US, en_UK, fr_FR, fr_CA.
-locale=te_st
-#language=
-#country=
-
-### Money display ###
-# Each game has a specific format for monetary amounts (e.g. $100, 100M).
-# An overriding format can be specified here, but then applies to all games.
-# The @ character must be present and is replaced by the amount.
-# Example: \xA3@ to specify a pound sign prefix: \xA3100.
-#money_format=$@
-
-### Save file directory
-# If the below entry exists, is not empty, and specifies an existing
-# directory, that directory is used as a starting point for any
-# file choosing action for the Save and Load commands.
-# The path may be relative or absolute.
-save.directory=test/data
-# The default Save filename is <gamename>_<datetimepattern>.<extension>
-# This name will be initially proposed.
-# As soon as that proposal has been changed once in a Save action,
-# the last used name is always proposed in stead.
-# The default date/time pattern is yyyyMMdd_HHmm
-# The pattern codes are as defined in the Java class
-# SimpleDateFormat (just Google that name to find the codes).
-#save.filename.date_time_pattern=yyyyMMdd_HHmm
-# The default timezone is local time.
-# A specific timezone (such as UTC) can be set; the value must be a Java timezone ID
-#save.filename.date_time_zone=UTC
-# Optionally, a suffix (e.g. player name) can be added after the time stamp
-# with a preceding underscore (which is automatically added)
-# The special value NEXT_PLAYER puts the next moving player name into this spot.
-#save.filename.suffix=NEXT_PLAYER
-# The default extension is .rails
-save.filename.extension=rails
-
-### Game report directory
-# If the below entry exists, is not empty, and specifies an existing
-# directory, a copy of the Game Report (as displayed in the Report Window)
-# will be saved there. The path may be relative or absolute.
-#report.directory=log
-# The default file name includes the game name and the game start time:
-# 18XX_yyyymmdd_hhmm.txt where 18XX is the game name.
-# You can specify different values for the date/time part and teh extension here.
-# The date/time pattern must be as defined in the Java SimpleDateFormat class.
-#report.filename.date_time_pattern=yyyyMMdd
-report.filename.extension=report
-
-### Windows
-## Report window visibility
-# By default the report window is hidden when starting or loading a game.
-# This property allows to open it automatically.
-# Valid values are yes and no (default).
-#report.window.open=yes
-## Report window editability
-# Specify if the report window is editable, so you can add your own comments.
-# Valid values are yes and no (default).
-#report.window.editable=yes
-## Stock Chart window visibility
-# By default the stock chart hides at the end of an SR.
-# By specifying "yes" here, the window will not be automatically hidden any more
-#stockchart.window.open=yes
-
-### Player info
-## Default players
-# Comma-separated list of player names.
-# Useful for game testing purposes.
-#default_players=Alice,Bob,Charlie
-#
-## Local player name
-# Useful for distributed usage (Internet, PBEM, cloud storage/dropbox)
-# Required for "request turn" facility with cloud storage (dropbox)
-#local.player.name=Alice
-
-### Default game
-# Name of game selected in the game selection window.
-# Useful for game testing purposes.
-#default_game=1830
-
-### Various options
-# Show simple (ORx) or composite (ORx.x) OR number.
-# Valid values: "simple" and "composite" (default)
-#or.number_format=simple
-
-####################### Log4J properties ##############################
-# For information on how to customise log4j logging, see for instance
-# http://www.vipan.com/htdocs/log4jhelp.html
-# It's a bit outdated: Category is now named Logger,
-# and Priority is now named Level.
-# But it's the best intro I know on how to configure Appenders. (EV)
-#######################################################################
-# Set root logger level to DEBUG and use appender F(file)
-#log4j.debug=true
-log4j.rootLogger=DEBUG, F
-
-# Define the Log file appender
-log4j.appender.F=org.apache.log4j.FileAppender
-
-# Log file properties
-log4j.appender.F.File=test/test.log
-log4j.appender.F.append=false
-
-# Log file layout
-log4j.appender.F.layout=org.apache.log4j.PatternLayout
-log4j.appender.F.layout.ConversionPattern=%-5p %m%n
-################## End of Log4J properties #############################
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|