this.preferencesFolder = preferencesFolder;
this.applicationFolders = applicationFolders;
updateSupportedLanguages();
Preferences preferences;
// From version 3.0 use portable preferences
PortablePreferences portablePreferences = new PortablePreferences();
// If portable preferences storage doesn't exist and default preferences folder is used
if (!portablePreferences.exist()
&& preferencesFolder == null) {
// Retrieve preferences from pre version 3.0
preferences = getPreferences();
} else {
preferences = portablePreferences;
}
setLanguage(preferences.get(LANGUAGE, getLanguage()));
// Fill default furniture catalog
setFurnitureCatalog(new DefaultFurnitureCatalog(this, getFurnitureLibrariesPluginFolders()));
// Read additional furniture
readFurnitureCatalog(preferences);
// Fill default textures catalog
setTexturesCatalog(new DefaultTexturesCatalog(this, getTexturesLibrariesPluginFolders()));
// Read additional textures
readTexturesCatalog(preferences);
DefaultUserPreferences defaultPreferences = new DefaultUserPreferences();
// Share same language settings
defaultPreferences.setLanguage(getLanguage());
// Fill default patterns catalog
PatternsCatalog patternsCatalog = defaultPreferences.getPatternsCatalog();
setPatternsCatalog(patternsCatalog);
// Read other preferences
setUnit(LengthUnit.valueOf(preferences.get(UNIT,
defaultPreferences.getLengthUnit().name())));
setFurnitureCatalogViewedInTree(preferences.getBoolean(FURNITURE_CATALOG_VIEWED_IN_TREE,
defaultPreferences.isFurnitureCatalogViewedInTree()));
setNavigationPanelVisible(preferences.getBoolean(NAVIGATION_PANEL_VISIBLE,
defaultPreferences.isNavigationPanelVisible()));
setMagnetismEnabled(preferences.getBoolean(MAGNETISM_ENABLED, true));
setRulersVisible(preferences.getBoolean(RULERS_VISIBLE,
defaultPreferences.isRulersVisible()));
setGridVisible(preferences.getBoolean(GRID_VISIBLE,
defaultPreferences.isGridVisible()));
setFurnitureViewedFromTop(preferences.getBoolean(FURNITURE_VIEWED_FROM_TOP,
defaultPreferences.isFurnitureViewedFromTop()));
setFloorColoredOrTextured(preferences.getBoolean(ROOM_FLOOR_COLORED_OR_TEXTURED,
defaultPreferences.isRoomFloorColoredOrTextured()));
try {
setWallPattern(patternsCatalog.getPattern(preferences.get(WALL_PATTERN,
defaultPreferences.getWallPattern().getName())));
} catch (IllegalArgumentException ex) {
// Ensure wall pattern always exists even if new patterns are added in future versions
setWallPattern(defaultPreferences.getWallPattern());
}
setNewWallThickness(preferences.getFloat(NEW_WALL_THICKNESS,
defaultPreferences.getNewWallThickness()));
setNewWallHeight(preferences.getFloat(NEW_WALL_HEIGHT,
defaultPreferences.getNewWallHeight()));
setAutoSaveDelayForRecovery(preferences.getInt(AUTO_SAVE_DELAY_FOR_RECOVERY,
defaultPreferences.getAutoSaveDelayForRecovery()));
setCurrency(defaultPreferences.getCurrency());
// Read recent homes list
List<String> recentHomes = new ArrayList<String>();
for (int i = 1; i <= getRecentHomesMaxCount(); i++) {
String recentHome = preferences.get(RECENT_HOMES + i, null);
if (recentHome != null) {
recentHomes.add(recentHome);
}
}
setRecentHomes(recentHomes);
// Read ignored action tips
for (int i = 1; ; i++) {
String ignoredActionTip = preferences.get(IGNORED_ACTION_TIP + i, "");
if (ignoredActionTip.length() == 0) {
break;
} else {
this.ignoredActionTips.put(ignoredActionTip, true);
}