|
From: Stefan F. <ste...@us...> - 2012-02-17 13:44:40
|
data/profiles/ORDocking.profile | 3 +
data/profiles/default.profile | 61 ----------------------
data/profiles/default.profiles | 7 ++
data/profiles/prettyUI.profile | 9 +++
data/profiles/root.profile | 62 ++++++++++++++++++++++
data/profiles/test.profile | 110 ----------------------------------------
rails/common/parser/Config.java | 15 ++++-
7 files changed, 93 insertions(+), 174 deletions(-)
New commits:
commit 0e0a46edc14d03cf2a07bd12cde541f93af47a12
Author: Stefan Frey <ste...@we...>
Date: Fri Feb 17 14:43:51 2012 +0100
added new profiles and a 3-tier structure for the configuration profiles
diff --git a/data/profiles/ORDocking.profile b/data/profiles/ORDocking.profile
new file mode 100644
index 0000000..e5f8d80
--- /dev/null
+++ b/data/profiles/ORDocking.profile
@@ -0,0 +1,3 @@
+### ORDocking profile
+### activates the docking framework
+or.window.dockablePanels=yes
diff --git a/data/profiles/default.profile b/data/profiles/default.profile
index b4e4cb9..03d7a58 100644
--- a/data/profiles/default.profile
+++ b/data/profiles/default.profile
@@ -1,59 +1,2 @@
-### Panel General
-locale=en_US
-default_game=1830
-default_players=
-local.player.names=
-
-### Panel Save
-save.directory=
-save.filename.date_time_pattern=yyyyMMdd_HHmm
-save.filename.date_time_zone=UTC
-save.filename.suffix=NEXT_PLAYER
-save.filename.extension=rails
-save.recovery.active=no
-save.recovery.filepath=18xx_autosave.rails
-
-### Panel Font
-font.ui.scale=1
-font.ui.name=
-font.ui.style=bold
-
-### Panel Map
-map.autoscroll=yes
-map.defaultZoomFitOption=none
-map.displayCurrentRoutes=yes
-map.highlightHexes=yes
-map.image.display=no
-map.zoomstep=10
-
-### Panel Windows
-or.window.dockablePanels=no
-report.window.type=dynamic
-report.window.open=yes
-report.window.editable=no
-stockchart.window.open=yes
-
-### Panel Format
-money_format=
-or.number_format=composite
-
-### Panel Appearance
-button.iconText=text and icon
-button.iconSize=small
-button.iconPosition=left
-gridPanel.tableBorders=enabled
-route.colour.1=00ffff
-route.colour.2=ffc0cb
-route.colour.3=ffa500
-route.colour.4=808080
-
-### Panel Log
-#report.directory=log
-#report.filename.date_time_pattern=yyyyMMdd
-#report.filename.extension=log
-
-### Panel Music
-sound.backgroundMusic=disabled
-
-### Panel SFX
-sound.sfx=disabled
+### Default profile currently is identical to root.profile
+### so no change here
\ No newline at end of file
diff --git a/data/profiles/default.profiles b/data/profiles/default.profiles
index 66511a9..9cedd38 100644
--- a/data/profiles/default.profiles
+++ b/data/profiles/default.profiles
@@ -1,2 +1,7 @@
-default=data/profiles/default.profile
+### This is the list of (predefined) profiles and their file locations
+### A dot (".") before the profilename prevents displaying those to the user selection
+.root=data/profiles/root.profile
.test=data/profiles/test.profile
+default=data/profiles/default.profile
+prettyUI=data/profiles/prettyUI.profile
+ORDocking=data/profiles/ORDocking.profile
diff --git a/data/profiles/prettyUI.profile b/data/profiles/prettyUI.profile
new file mode 100644
index 0000000..a537864
--- /dev/null
+++ b/data/profiles/prettyUI.profile
@@ -0,0 +1,9 @@
+### prettyUI profile
+### activates the new UI options of Frederick
+button.iconPosition=left
+button.iconText=text and icon
+button.iconSize=small
+gridPanel.tableBorders=enabled
+map.image.display=yes
+map.displayCurrentRoutes=yes
+map.highlightHexes=yes
diff --git a/data/profiles/root.profile b/data/profiles/root.profile
new file mode 100644
index 0000000..a553e4c
--- /dev/null
+++ b/data/profiles/root.profile
@@ -0,0 +1,62 @@
+### Root profile defines the settings used for all (predefined) default profiles
+### All others define only deviations
+
+### Panel General
+locale=en_US
+default_game=1830
+default_players=
+local.player.names=
+
+### Panel Save
+save.directory=
+save.filename.date_time_pattern=yyyyMMdd_HHmm
+save.filename.date_time_zone=UTC
+save.filename.suffix=NEXT_PLAYER
+save.filename.extension=rails
+save.recovery.active=no
+save.recovery.filepath=18xx_autosave.rails
+
+### Panel Font
+font.ui.scale=1
+font.ui.name=
+font.ui.style=bold
+
+### Panel Map
+map.autoscroll=yes
+map.defaultZoomFitOption=none
+map.displayCurrentRoutes=no
+map.highlightHexes=no
+map.image.display=no
+map.zoomstep=10
+
+### Panel Windows
+or.window.dockablePanels=no
+report.window.type=dynamic
+report.window.open=yes
+report.window.editable=no
+stockchart.window.open=yes
+
+### Panel Format
+money_format=
+or.number_format=composite
+
+### Panel Appearance
+button.iconText=only text
+button.iconSize=small
+button.iconPosition=left
+gridPanel.tableBorder=disabled
+route.colour.1=00ffff
+route.colour.2=ffc0cb
+route.colour.3=ffa500
+route.colour.4=808080
+
+### Panel Log
+#report.directory=log
+#report.filename.date_time_pattern=yyyyMMdd
+#report.filename.extension=log
+
+### Panel Music
+sound.backgroundMusic=disabled
+
+### Panel SFX
+sound.sfx=disabled
diff --git a/data/profiles/test.profile b/data/profiles/test.profile
index 2b39565..897ee6d 100644
--- a/data/profiles/test.profile
+++ b/data/profiles/test.profile
@@ -3,123 +3,13 @@
# 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: �@ to specify a pound sign prefix: �100.
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
failed.filename.extension=failed
-
-### 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
diff --git a/rails/common/parser/Config.java b/rails/common/parser/Config.java
index 107e888..296fcb3 100644
--- a/rails/common/parser/Config.java
+++ b/rails/common/parser/Config.java
@@ -55,6 +55,7 @@ public final class Config {
private static Properties userProfiles = new Properties();
private static boolean profilesLoaded = false;
private static String DEFAULT_PROFILE_SELECTION = "default"; // can be overwritten
+ private static final String ROOT_PROFILE_SELECTION = ".root"; // used for the 3-tier structure: ROOT-DEFAULT-USER
private static final String TEST_PROFILE_SELECTION = ".test"; // used as default profile for integration tests
private static final String STANDARD_PROFILE_SELECTION = "user";
private static final String DEFAULTPROFILE_PROPERTY = "default.profile";
@@ -65,7 +66,8 @@ public final class Config {
private static boolean legacyConfigFile;
/** properties storage. */
- private static Properties defaultProperties = new Properties();
+ private static Properties rootProperties = null;
+ private static Properties defaultProperties = null;
private static Properties userProperties = new Properties();
private static boolean propertiesLoaded = false;
@@ -191,6 +193,7 @@ public final class Config {
}
if (userProperties.containsKey(key)) return userProperties.getProperty(key).trim();
if (defaultProperties.containsKey(key)) return defaultProperties.getProperty(key).trim();
+ if (rootProperties.containsKey(key)) return rootProperties.getProperty(key).trim();
return defaultValue;
}
@@ -497,9 +500,8 @@ public final class Config {
* if not defined or loadable, creates a default user profile
*/
private static void loadProfile(String userProfile) {
- // reset properties
+ // reset user properties
userProperties = new Properties();
- defaultProperties = new Properties();
String userConfigFile = null;
if (Util.hasValue(userProfile)) {
@@ -524,7 +526,7 @@ public final class Config {
/**
* loads the associated default profile
- * if none is defined, uses standard default profile
+ * the default profile is defined as delta to the root profile
*/
private static void loadDefaultProfile() {
String defaultConfigFile = null;
@@ -536,6 +538,11 @@ public final class Config {
defaultConfigFile = defaultProfiles.getProperty(DEFAULT_PROFILE_SELECTION);
userProperties.setProperty(DEFAULTPROFILE_PROPERTY, DEFAULT_PROFILE_SELECTION);
}
+ if (rootProperties == null) {
+ rootProperties = new Properties();
+ loadPropertyFile(rootProperties, defaultProfiles.getProperty(ROOT_PROFILE_SELECTION), true);
+ }
+ defaultProperties = new Properties();
loadPropertyFile(defaultProperties, defaultConfigFile, true);
}
|