You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(103) |
Jun
(121) |
Jul
(16) |
Aug
(67) |
Sep
(126) |
Oct
(161) |
Nov
(164) |
Dec
(588) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(394) |
Feb
(181) |
Mar
(131) |
Apr
(180) |
May
(255) |
Jun
(11) |
Jul
(79) |
Aug
(70) |
Sep
(274) |
Oct
(138) |
Nov
(195) |
Dec
(8) |
2008 |
Jan
(3) |
Feb
(142) |
Mar
(162) |
Apr
(124) |
May
(148) |
Jun
(157) |
Jul
(425) |
Aug
(373) |
Sep
(264) |
Oct
(315) |
Nov
(225) |
Dec
(6) |
2009 |
Jan
(67) |
Feb
(78) |
Mar
(279) |
Apr
(294) |
May
(92) |
Jun
(65) |
Jul
(134) |
Aug
(41) |
Sep
(138) |
Oct
(125) |
Nov
(126) |
Dec
(122) |
2010 |
Jan
(15) |
Feb
(48) |
Mar
(9) |
Apr
(195) |
May
(373) |
Jun
(507) |
Jul
(42) |
Aug
(16) |
Sep
(38) |
Oct
(81) |
Nov
(64) |
Dec
(18) |
2011 |
Jan
(13) |
Feb
(12) |
Mar
(39) |
Apr
(1) |
May
(2) |
Jun
(27) |
Jul
(27) |
Aug
(31) |
Sep
(14) |
Oct
(102) |
Nov
(20) |
Dec
(37) |
2012 |
Jan
(22) |
Feb
(1) |
Mar
(1) |
Apr
(2) |
May
(2) |
Jun
(18) |
Jul
(6) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
(47) |
Jun
(7) |
Jul
(107) |
Aug
|
Sep
|
Oct
(112) |
Nov
(31) |
Dec
(17) |
2014 |
Jan
(29) |
Feb
(111) |
Mar
(34) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(18) |
Dec
(10) |
From: <aki...@us...> - 2010-05-29 19:04:02
|
Revision: 8035 http://gridarta.svn.sourceforge.net/gridarta/?rev=8035&view=rev Author: akirschbaum Date: 2010-05-29 19:03:56 +0000 (Sat, 29 May 2010) Log Message: ----------- Fix incorrect resource path names on Windows machines. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/model/settings/AbstractConfigSource.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-05-29 07:26:23 UTC (rev 8034) +++ trunk/atrinik/ChangeLog 2010-05-29 19:03:56 UTC (rev 8035) @@ -1,3 +1,7 @@ +2010-05-29 Andreas Kirschbaum + + * Fix incorrect resource path names on Windows machines. + 2010-05-26 Andreas Kirschbaum * Retain customized attributes when replacing with multi-part game Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-05-29 07:26:23 UTC (rev 8034) +++ trunk/crossfire/ChangeLog 2010-05-29 19:03:56 UTC (rev 8035) @@ -1,3 +1,7 @@ +2010-05-29 Andreas Kirschbaum + + * Fix incorrect resource path names on Windows machines. + 2010-05-26 Andreas Kirschbaum * Retain customized attributes when replacing with multi-part game Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-05-29 07:26:23 UTC (rev 8034) +++ trunk/daimonin/ChangeLog 2010-05-29 19:03:56 UTC (rev 8035) @@ -1,3 +1,7 @@ +2010-05-29 Andreas Kirschbaum + + * Fix incorrect resource path names on Windows machines. + 2010-05-26 Andreas Kirschbaum * Retain customized attributes when replacing with multi-part game Modified: trunk/src/app/net/sf/gridarta/model/settings/AbstractConfigSource.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/settings/AbstractConfigSource.java 2010-05-29 07:26:23 UTC (rev 8034) +++ trunk/src/app/net/sf/gridarta/model/settings/AbstractConfigSource.java 2010-05-29 19:03:56 UTC (rev 8035) @@ -78,7 +78,7 @@ } else { throw new IOException("unknown variable '${" + group + "} in '" + key + "=" + spec + "'"); } - matcher.appendReplacement(sb, replacement); + matcher.appendReplacement(sb, Matcher.quoteReplacement(replacement)); } matcher.appendTail(sb); final String result = sb.toString(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-29 07:26:29
|
Revision: 8034 http://gridarta.svn.sourceforge.net/gridarta/?rev=8034&view=rev Author: akirschbaum Date: 2010-05-29 07:26:23 +0000 (Sat, 29 May 2010) Log Message: ----------- Remove dependency Recent -> GlobalSettings. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/misc/Recent.java trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java Modified: trunk/src/app/net/sf/gridarta/gui/misc/Recent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/Recent.java 2010-05-29 07:17:04 UTC (rev 8033) +++ trunk/src/app/net/sf/gridarta/gui/misc/Recent.java 2010-05-29 07:26:23 UTC (rev 8034) @@ -32,7 +32,6 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; -import net.sf.gridarta.model.settings.GlobalSettings; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import org.jetbrains.annotations.NotNull; @@ -68,12 +67,6 @@ private final String title; /** - * The global settings instance. - */ - @NotNull - private final GlobalSettings globalSettings; - - /** * The {@link MapViewsManager} instance. */ @NotNull @@ -101,54 +94,32 @@ * Create a Recent. * @param title title (map name) * @param mapFile the map file - * @param globalSettings the global settings instance + * @param mapsDirectory the maps directory * @param mapViewsManager the map views manager instance * @param mapImageCache the map image cache instance * @param fileControl the file control */ - Recent(@NotNull final String title, @NotNull final File mapFile, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl) { + Recent(@NotNull final String title, @NotNull final File mapFile, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl) { super(title); this.mapFile = mapFile; this.title = title; - this.globalSettings = globalSettings; this.mapViewsManager = mapViewsManager; this.mapImageCache = mapImageCache; this.fileControl = fileControl; - putValue(SHORT_DESCRIPTION, ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, getShortFileName())); + putValue(SHORT_DESCRIPTION, ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, getShortMapFile(mapsDirectory, mapFile))); putValue(SMALL_ICON, getIcon()); putValue(NAME, title); putValue(MNEMONIC_KEY, null); } /** - * Create a Recent from preferences. - * @param index index (starting with 1) - * @param globalSettings the global settings instance - * @param mapViewsManager the map views manager instance - * @param mapImageCache the map image cache instance - * @param fileControl the file control + * Returns the base name of a map file. + * @param mapsDirectory the maps directory + * @param mapFile the map file + * @return the base name */ - Recent(final int index, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl) { - this.globalSettings = globalSettings; - this.mapViewsManager = mapViewsManager; - this.mapImageCache = mapImageCache; - this.fileControl = fileControl; - title = preferences.get("recentTitle[" + Integer.toString(index - 1) + ']', null); - mapFile = new File(preferences.get("recentFilename[" + Integer.toString(index - 1) + ']', null)); - putValue(SHORT_DESCRIPTION, ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, getShortFileName())); - putValue(SMALL_ICON, getIcon()); - putValue(NAME, title); - putValue(MNEMONIC_KEY, null); - setIndex(index); - } - - /** - * Get the short filename. - * @return short filename - */ @NotNull - private String getShortFileName() { - final File mapsDirectory = globalSettings.getMapsDirectory(); + private static String getShortMapFile(@NotNull final File mapsDirectory, @NotNull final File mapFile) { String canonicalMapFile; String canonicalMapsDirectory; try { @@ -167,6 +138,27 @@ } /** + * Create a Recent from preferences. + * @param index index (starting with 1) + * @param mapsDirectory the maps directory + * @param mapViewsManager the map views manager instance + * @param mapImageCache the map image cache instance + * @param fileControl the file control + */ + Recent(final int index, @NotNull final File mapsDirectory, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl) { + this.mapViewsManager = mapViewsManager; + this.mapImageCache = mapImageCache; + this.fileControl = fileControl; + title = preferences.get("recentTitle[" + Integer.toString(index - 1) + ']', null); + mapFile = new File(preferences.get("recentFilename[" + Integer.toString(index - 1) + ']', null)); + putValue(SHORT_DESCRIPTION, ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, getShortMapFile(mapsDirectory, mapFile))); + putValue(SMALL_ICON, getIcon()); + putValue(NAME, title); + putValue(MNEMONIC_KEY, null); + setIndex(index); + } + + /** * Set the index used for title, key strokes and such. * @param index index (starting with 1) */ Modified: trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-29 07:17:04 UTC (rev 8033) +++ trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-29 07:26:23 UTC (rev 8034) @@ -179,7 +179,7 @@ } final String title = mapModel.getMapArchObject().getMapName(); - final Recent<G, A, R> recent = new Recent<G, A, R>(title, mapFile, globalSettings, mapViewsManager, mapImageCache, fileControl); + final Recent<G, A, R> recent = new Recent<G, A, R>(title, mapFile, globalSettings.getMapsDirectory(), mapViewsManager, mapImageCache, fileControl); recents.remove(recent); // remove old entry to get new entry at first pos. recents.addFirst(recent); // Now remove those that are too many. @@ -218,9 +218,10 @@ * Initializes the recent state. */ public void initRecent() { + final File mapsDirectory = globalSettings.getMapsDirectory(); final int numRecents = preferences.getInt("recentNum", 0); for (int i = 0; i < numRecents; i++) { - recents.add(new Recent<G, A, R>(i + 1, globalSettings, mapViewsManager, mapImageCache, fileControl)); + recents.add(new Recent<G, A, R>(i + 1, mapsDirectory, mapViewsManager, mapImageCache, fileControl)); } updateRecent(recents); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-29 07:17:10
|
Revision: 8033 http://gridarta.svn.sourceforge.net/gridarta/?rev=8033&view=rev Author: akirschbaum Date: 2010-05-29 07:17:04 +0000 (Sat, 29 May 2010) Log Message: ----------- Remove DefaultGlobalSettings.configSourceFactory. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java Modified: trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java 2010-05-29 07:16:17 UTC (rev 8032) +++ trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java 2010-05-29 07:17:04 UTC (rev 8033) @@ -130,12 +130,6 @@ private final String imageSetDefault; /** - * The {@link ConfigSourceFactory} to use. - */ - @NotNull - private final ConfigSourceFactory configSourceFactory; - - /** * The default value for the archetype directory. */ @NotNull @@ -206,7 +200,6 @@ mediaDirectoryDefault = ActionBuilderUtils.getString(ACTION_BUILDER, "mediaDirectoryDefault", ""); hasImageSet = ActionBuilderUtils.getBoolean(ACTION_BUILDER, "imageSet"); imageSetDefault = ActionBuilderUtils.getString(ACTION_BUILDER, "imageSetDefault", "none"); - this.configSourceFactory = configSourceFactory; final PreferenceChangeListener preferenceChangeListener = new PreferenceChangeListener() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-29 07:16:25
|
Revision: 8032 http://gridarta.svn.sourceforge.net/gridarta/?rev=8032&view=rev Author: akirschbaum Date: 2010-05-29 07:16:17 +0000 (Sat, 29 May 2010) Log Message: ----------- Remove DefaultGlobalSettings.preferenceChangeListener. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java Modified: trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java 2010-05-29 07:15:37 UTC (rev 8031) +++ trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java 2010-05-29 07:16:17 UTC (rev 8032) @@ -196,32 +196,6 @@ private boolean autoPopupDocumentation = false; /** - * The {@link PreferenceChangeListener} used to detect settings changes. - */ - @NotNull - private final PreferenceChangeListener preferenceChangeListener = new PreferenceChangeListener() { - - /** {@inheritDoc} */ - @Override - public void preferenceChange(final PreferenceChangeEvent evt) { - if (evt.getKey().equals(SHOW_MAIN_TOOLBAR_KEY)) { - fireShowMainToolbarChanged(); - } else if (evt.getKey().equals(ARCH_DIRECTORY_KEY)) { - archDirectory = new File(preferences.get(ARCH_DIRECTORY_KEY, archDirectoryDefault)); - } else if (evt.getKey().equals(MAP_DIRECTORY_KEY)) { - mapsDirectory = new File(preferences.get(MAP_DIRECTORY_KEY, mapsDirectoryDefault)); - } else if (evt.getKey().equals(MEDIA_DIRECTORY_KEY)) { - mediaDirectory = new File(preferences.get(MEDIA_DIRECTORY_KEY, mediaDirectoryDefault)); - } else if (evt.getKey().equals(IMAGE_SET_KEY)) { - imageSet = preferences.get(IMAGE_SET_KEY, imageSetDefault); - } else if (evt.getKey().equals(CONFIG_SOURCE_KEY)) { - configSource = configSourceFactory.getConfigSource(preferences.get(CONFIG_SOURCE_KEY, "")); - } - } - - }; - - /** * Creates a new instance. * @param configSourceFactory the configuration source factory to use */ @@ -233,7 +207,30 @@ hasImageSet = ActionBuilderUtils.getBoolean(ACTION_BUILDER, "imageSet"); imageSetDefault = ActionBuilderUtils.getString(ACTION_BUILDER, "imageSetDefault", "none"); this.configSourceFactory = configSourceFactory; + + final PreferenceChangeListener preferenceChangeListener = new PreferenceChangeListener() { + + /** {@inheritDoc} */ + @Override + public void preferenceChange(final PreferenceChangeEvent evt) { + if (evt.getKey().equals(SHOW_MAIN_TOOLBAR_KEY)) { + fireShowMainToolbarChanged(); + } else if (evt.getKey().equals(ARCH_DIRECTORY_KEY)) { + archDirectory = new File(preferences.get(ARCH_DIRECTORY_KEY, archDirectoryDefault)); + } else if (evt.getKey().equals(MAP_DIRECTORY_KEY)) { + mapsDirectory = new File(preferences.get(MAP_DIRECTORY_KEY, mapsDirectoryDefault)); + } else if (evt.getKey().equals(MEDIA_DIRECTORY_KEY)) { + mediaDirectory = new File(preferences.get(MEDIA_DIRECTORY_KEY, mediaDirectoryDefault)); + } else if (evt.getKey().equals(IMAGE_SET_KEY)) { + imageSet = preferences.get(IMAGE_SET_KEY, imageSetDefault); + } else if (evt.getKey().equals(CONFIG_SOURCE_KEY)) { + configSource = configSourceFactory.getConfigSource(preferences.get(CONFIG_SOURCE_KEY, "")); + } + } + + }; preferences.addPreferenceChangeListener(preferenceChangeListener); + archDirectory = new File(preferences.get(ARCH_DIRECTORY_KEY, archDirectoryDefault)); mapsDirectory = new File(preferences.get(MAP_DIRECTORY_KEY, mapsDirectoryDefault)); mediaDirectory = new File(preferences.get(MEDIA_DIRECTORY_KEY, mediaDirectoryDefault)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-29 07:15:44
|
Revision: 8031 http://gridarta.svn.sourceforge.net/gridarta/?rev=8031&view=rev Author: akirschbaum Date: 2010-05-29 07:15:37 +0000 (Sat, 29 May 2010) Log Message: ----------- Rename variable name. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/misc/Recent.java Modified: trunk/src/app/net/sf/gridarta/gui/misc/Recent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/Recent.java 2010-05-29 07:15:15 UTC (rev 8030) +++ trunk/src/app/net/sf/gridarta/gui/misc/Recent.java 2010-05-29 07:15:37 UTC (rev 8031) @@ -154,7 +154,7 @@ try { canonicalMapFile = mapFile.getCanonicalPath(); canonicalMapsDirectory = mapsDirectory.getCanonicalPath(); - } catch (final IOException e) { + } catch (final IOException ignored) { canonicalMapFile = mapFile.getAbsolutePath(); canonicalMapsDirectory = mapsDirectory.getAbsolutePath(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-29 07:15:21
|
Revision: 8030 http://gridarta.svn.sourceforge.net/gridarta/?rev=8030&view=rev Author: akirschbaum Date: 2010-05-29 07:15:15 +0000 (Sat, 29 May 2010) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/misc/Recent.java Modified: trunk/src/app/net/sf/gridarta/gui/misc/Recent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/Recent.java 2010-05-29 07:12:23 UTC (rev 8029) +++ trunk/src/app/net/sf/gridarta/gui/misc/Recent.java 2010-05-29 07:15:15 UTC (rev 8030) @@ -148,19 +148,22 @@ */ @NotNull private String getShortFileName() { + final File mapsDirectory = globalSettings.getMapsDirectory(); + String canonicalMapFile; + String canonicalMapsDirectory; try { - if (mapFile.getCanonicalPath().startsWith(globalSettings.getMapsDirectory().getCanonicalPath())) { - return mapFile.getCanonicalPath().substring(globalSettings.getMapsDirectory().getCanonicalPath().length()).replace('\\', '/'); - } else { - return mapFile.getCanonicalPath().replace('\\', '/'); - } + canonicalMapFile = mapFile.getCanonicalPath(); + canonicalMapsDirectory = mapsDirectory.getCanonicalPath(); } catch (final IOException e) { - if (mapFile.getAbsolutePath().startsWith(globalSettings.getMapsDirectory().getAbsolutePath())) { - return mapFile.getAbsolutePath().substring(globalSettings.getMapsDirectory().getAbsolutePath().length()).replace('\\', '/'); - } else { - return mapFile.getAbsolutePath().replace('\\', '/'); - } + canonicalMapFile = mapFile.getAbsolutePath(); + canonicalMapsDirectory = mapsDirectory.getAbsolutePath(); } + + if (canonicalMapFile.startsWith(canonicalMapsDirectory)) { + return canonicalMapFile.substring(canonicalMapsDirectory.length()).replace('\\', '/'); + } else { + return canonicalMapFile.replace('\\', '/'); + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-29 07:12:30
|
Revision: 8029 http://gridarta.svn.sourceforge.net/gridarta/?rev=8029&view=rev Author: akirschbaum Date: 2010-05-29 07:12:23 +0000 (Sat, 29 May 2010) Log Message: ----------- Fix typos. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/maparchobject/DefaultMapArchObjectFactory.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/maparchobject/DefaultMapArchObjectFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/maparchobject/DefaultMapArchObjectFactory.java trunk/gridarta.ipr trunk/src/app/net/sf/gridarta/gui/misc/Recent.java trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java trunk/src/app/net/sf/gridarta/gui/prefs/MiscPrefs.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/app/net/sf/gridarta/model/map/mapcontrol/DefaultMapControl.java trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java trunk/src/app/net/sf/gridarta/model/settings/GlobalSettings.java trunk/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/maparchobject/DefaultMapArchObjectFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/maparchobject/DefaultMapArchObjectFactory.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/maparchobject/DefaultMapArchObjectFactory.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -51,7 +51,7 @@ public MapArchObject newMapArchObject(final boolean addDefaultAttributes) { final MapArchObject mapArchObject = new MapArchObject(); if (addDefaultAttributes) { - mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + globalSettings.getUsername()); + mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + globalSettings.getUserName()); mapArchObject.setDarkness(-1); } return mapArchObject; Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/maparchobject/DefaultMapArchObjectFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/maparchobject/DefaultMapArchObjectFactory.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/maparchobject/DefaultMapArchObjectFactory.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -51,7 +51,7 @@ public MapArchObject newMapArchObject(final boolean addDefaultAttributes) { final MapArchObject mapArchObject = new MapArchObject(); if (addDefaultAttributes) { - mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + globalSettings.getUsername()); + mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + globalSettings.getUserName()); } return mapArchObject; } Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/maparchobject/DefaultMapArchObjectFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/maparchobject/DefaultMapArchObjectFactory.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/maparchobject/DefaultMapArchObjectFactory.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -51,7 +51,7 @@ public MapArchObject newMapArchObject(final boolean addDefaultAttributes) { final MapArchObject mapArchObject = new MapArchObject(); if (addDefaultAttributes) { - mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + globalSettings.getUsername()); + mapArchObject.addText("Created: " + String.format("%tF", System.currentTimeMillis()) + " " + globalSettings.getUserName()); mapArchObject.setDarkness(-1); } return mapArchObject; Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/gridarta.ipr 2010-05-29 07:12:23 UTC (rev 8029) @@ -1163,11 +1163,13 @@ <w>pickmaps</w> <w>plugins</w> <w>popup</w> + <w>recents</w> <w>resize</w> <w>resized</w> <w>resizes</w> <w>rethrown</w> <w>shortdescription</w> + <w>shortdescriptionformat</w> <w>startup</w> <w>teleporter</w> <w>teleporters</w> Modified: trunk/src/app/net/sf/gridarta/gui/misc/Recent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/Recent.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/app/net/sf/gridarta/gui/misc/Recent.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -59,7 +59,7 @@ * The {@link Preferences}. */ @NotNull - private static final Preferences prefs = Preferences.userNodeForPackage(RecentManager.class); + private static final Preferences preferences = Preferences.userNodeForPackage(RecentManager.class); /** * Title = map name. @@ -133,8 +133,8 @@ this.mapViewsManager = mapViewsManager; this.mapImageCache = mapImageCache; this.fileControl = fileControl; - title = prefs.get("recentTitle[" + Integer.toString(index - 1) + ']', null); - mapFile = new File(prefs.get("recentFilename[" + Integer.toString(index - 1) + ']', null)); + title = preferences.get("recentTitle[" + Integer.toString(index - 1) + ']', null); + mapFile = new File(preferences.get("recentFilename[" + Integer.toString(index - 1) + ']', null)); putValue(SHORT_DESCRIPTION, ACTION_BUILDER.format("recentItem.shortdescriptionformat", title, getShortFileName())); putValue(SMALL_ICON, getIcon()); putValue(NAME, title); @@ -168,8 +168,8 @@ * @param index index (starting with 1) */ public void setIndex(final int index) { - prefs.put("recentTitle[" + Integer.toString(index - 1) + ']', title); - prefs.put("recentFilename[" + Integer.toString(index - 1) + ']', mapFile.getPath()); + preferences.put("recentTitle[" + Integer.toString(index - 1) + ']', title); + preferences.put("recentFilename[" + Integer.toString(index - 1) + ']', mapFile.getPath()); } /** Modified: trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -59,7 +59,7 @@ * Preferences. */ @NotNull - private static final Preferences prefs = Preferences.userNodeForPackage(RecentManager.class); + private static final Preferences preferences = Preferences.userNodeForPackage(RecentManager.class); /** * The {@link MapViewsManager} instance. @@ -183,7 +183,7 @@ recents.remove(recent); // remove old entry to get new entry at first pos. recents.addFirst(recent); // Now remove those that are too many. - // Please keep this while loop as the constant 10 might be replaced by a prefs var + // Please keep this while loop as the constant 10 might be replaced by a preferences var int i = 0; for (final ListIterator<Recent<G, A, R>> it = recents.listIterator(); it.hasNext();) { it.next().setIndex(it.nextIndex()); // this looks bogus but it's intentionally currentIndex + 1 @@ -191,7 +191,7 @@ it.remove(); } } - prefs.putInt("recentNum", recents.size()); + preferences.putInt("recentNum", recents.size()); updateRecent(recents); } @@ -218,7 +218,7 @@ * Initializes the recent state. */ public void initRecent() { - final int numRecents = prefs.getInt("recentNum", 0); + final int numRecents = preferences.getInt("recentNum", 0); for (int i = 0; i < numRecents; i++) { recents.add(new Recent<G, A, R>(i + 1, globalSettings, mapViewsManager, mapImageCache, fileControl)); } Modified: trunk/src/app/net/sf/gridarta/gui/prefs/MiscPrefs.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/prefs/MiscPrefs.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/app/net/sf/gridarta/gui/prefs/MiscPrefs.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -130,7 +130,7 @@ */ @Override public void apply() { - globalSettings.setUsername(userField.getText()); + globalSettings.setUserName(userField.getText()); MapFileFilter.setPerformingRealChecks(checkMaps.isSelected()); exitConnectorModel.setAutoCreateExit(autoCreateExit.isSelected()); exitConnectorModel.setPasteExitName(pasteExitName.isSelected()); @@ -142,7 +142,7 @@ */ @Override public void revert() { - userField.setText(globalSettings.getUsername()); + userField.setText(globalSettings.getUserName()); checkMaps.setSelected(MapFileFilter.isPerformingRealChecks()); autoCreateExit.setSelected(exitConnectorModel.isAutoCreateExit()); pasteExitName.setSelected(exitConnectorModel.isPasteExitName()); @@ -154,7 +154,7 @@ */ @Override public void defaults() { - userField.setText(globalSettings.getUsernameDefault()); + userField.setText(globalSettings.getUserNameDefault()); checkMaps.setSelected(true); autoCreateExit.setSelected(ExitConnectorModel.AUTO_CREATE_EXIT_DEFAULT); pasteExitName.setSelected(ExitConnectorModel.PASTE_EXIT_NAME_DEFAULT); @@ -166,7 +166,7 @@ */ @Override public boolean isChanged() { - return !(userField.getText().equals(globalSettings.getUsername()) && checkMaps.isSelected() == MapFileFilter.isPerformingRealChecks() && autoCreateExit.isSelected() == exitConnectorModel.isAutoCreateExit() && pasteExitName.isSelected() == exitConnectorModel.isPasteExitName() && exitArchetypeName.getText().equals(exitConnectorModel.getExitArchetypeName())); + return !(userField.getText().equals(globalSettings.getUserName()) && checkMaps.isSelected() == MapFileFilter.isPerformingRealChecks() && autoCreateExit.isSelected() == exitConnectorModel.isAutoCreateExit() && pasteExitName.isSelected() == exitConnectorModel.isPasteExitName() && exitArchetypeName.getText().equals(exitConnectorModel.getExitArchetypeName())); } /** @@ -177,7 +177,7 @@ final JComponent panel = new JPanel(new GridBagLayout()); final PreferencesHelper preferencesHelper = new PreferencesHelper(panel); panel.setBorder(createTitledBorder(ACTION_BUILDER.getString("optionsUser"))); - userField = new JTextField(globalSettings.getUsername()); + userField = new JTextField(globalSettings.getUserName()); preferencesHelper.addComponent(userField); return panel; } Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -539,11 +539,11 @@ new ArchetypeValidator(animationObjects, faceObjects, errorView).validate(archetypeSet); new AnimationValidator(faceObjects, errorView).validate(animationObjects); - if (globalSettings.isAutoPopupDocu()) { + if (globalSettings.isAutoPopupDocumentation()) { // do an automated help popup because the docu version has increased // (people won't notice the docu otherwise - nobody expects a docu in opensource) helpActions.showHelp(); - globalSettings.setAutoPopupDocu(false); + globalSettings.setAutoPopupDocumentation(false); } editorFactory.deleteLibraries(mainViewFrame); Modified: trunk/src/app/net/sf/gridarta/model/map/mapcontrol/DefaultMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/map/mapcontrol/DefaultMapControl.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/app/net/sf/gridarta/model/map/mapcontrol/DefaultMapControl.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -174,7 +174,7 @@ } if (mapModel.isModified()) { - mapModel.getMapArchObject().updateModifiedAttribute(globalSettings.getUsername()); + mapModel.getMapArchObject().updateModifiedAttribute(globalSettings.getUserName()); } encodeMapFile(file); } Modified: trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -66,28 +66,28 @@ private static final String IMAGE_SET_KEY = "useImageSet"; /** - * The preferences key for storing the last known docu version. + * The preferences key for storing the last known documentation version. */ @NotNull - private static final String DOCU_VERSION_KEY = "docuVersion"; + private static final String DOCUMENTATION_VERSION_KEY = "docuVersion"; /** - * Key for info whether the main windows's toolbar is shown. + * Key for info whether the main window's toolbar is shown. */ @NotNull private static final String SHOW_MAIN_TOOLBAR_KEY = "ShowMainToolbar"; /** - * Preferences key for username. + * Preferences key for user name. */ @NotNull - private static final String PREFS_USERNAME = "username"; + private static final String PREFERENCES_USER_NAME = "username"; /** - * Preferences default value for username. + * Preferences default value for user name. */ @NotNull - private static final String PREFS_USERNAME_DEFAULT = System.getProperty("user.name"); + private static final String PREFERENCES_USER_NAME_DEFAULT = System.getProperty("user.name"); /** * The preferences key for configuration source. @@ -99,7 +99,7 @@ * Preferences. */ @NotNull - private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); + private static final Preferences preferences = Preferences.userNodeForPackage(MainControl.class); /** * The default value for the maps directory. @@ -191,9 +191,9 @@ private boolean hasChangedDir = false; /** - * Time for an automated docu popup. + * Time for an automated documentation popup. */ - private boolean autoPopupDocu = false; + private boolean autoPopupDocumentation = false; /** * The {@link PreferenceChangeListener} used to detect settings changes. @@ -207,15 +207,15 @@ if (evt.getKey().equals(SHOW_MAIN_TOOLBAR_KEY)) { fireShowMainToolbarChanged(); } else if (evt.getKey().equals(ARCH_DIRECTORY_KEY)) { - archDirectory = new File(prefs.get(ARCH_DIRECTORY_KEY, archDirectoryDefault)); + archDirectory = new File(preferences.get(ARCH_DIRECTORY_KEY, archDirectoryDefault)); } else if (evt.getKey().equals(MAP_DIRECTORY_KEY)) { - mapsDirectory = new File(prefs.get(MAP_DIRECTORY_KEY, mapsDirectoryDefault)); + mapsDirectory = new File(preferences.get(MAP_DIRECTORY_KEY, mapsDirectoryDefault)); } else if (evt.getKey().equals(MEDIA_DIRECTORY_KEY)) { - mediaDirectory = new File(prefs.get(MEDIA_DIRECTORY_KEY, mediaDirectoryDefault)); + mediaDirectory = new File(preferences.get(MEDIA_DIRECTORY_KEY, mediaDirectoryDefault)); } else if (evt.getKey().equals(IMAGE_SET_KEY)) { - imageSet = prefs.get(IMAGE_SET_KEY, imageSetDefault); + imageSet = preferences.get(IMAGE_SET_KEY, imageSetDefault); } else if (evt.getKey().equals(CONFIG_SOURCE_KEY)) { - configSource = configSourceFactory.getConfigSource(prefs.get(CONFIG_SOURCE_KEY, "")); + configSource = configSourceFactory.getConfigSource(preferences.get(CONFIG_SOURCE_KEY, "")); } } @@ -233,18 +233,18 @@ hasImageSet = ActionBuilderUtils.getBoolean(ACTION_BUILDER, "imageSet"); imageSetDefault = ActionBuilderUtils.getString(ACTION_BUILDER, "imageSetDefault", "none"); this.configSourceFactory = configSourceFactory; - prefs.addPreferenceChangeListener(preferenceChangeListener); - archDirectory = new File(prefs.get(ARCH_DIRECTORY_KEY, archDirectoryDefault)); - mapsDirectory = new File(prefs.get(MAP_DIRECTORY_KEY, mapsDirectoryDefault)); - mediaDirectory = new File(prefs.get(MEDIA_DIRECTORY_KEY, mediaDirectoryDefault)); - imageSet = prefs.get(IMAGE_SET_KEY, imageSetDefault); - configSource = configSourceFactory.getConfigSource(prefs.get(CONFIG_SOURCE_KEY, "")); - final int docuVersion = ActionBuilderUtils.getInt(ACTION_BUILDER, "docuVersion", 0); - if (docuVersion > 0 && prefs.getInt(DOCU_VERSION_KEY, 0) < docuVersion) { - // remember to open docu - autoPopupDocu = true; - // update docu version right now, because we want the help popup only one time - prefs.putInt(DOCU_VERSION_KEY, docuVersion); + preferences.addPreferenceChangeListener(preferenceChangeListener); + archDirectory = new File(preferences.get(ARCH_DIRECTORY_KEY, archDirectoryDefault)); + mapsDirectory = new File(preferences.get(MAP_DIRECTORY_KEY, mapsDirectoryDefault)); + mediaDirectory = new File(preferences.get(MEDIA_DIRECTORY_KEY, mediaDirectoryDefault)); + imageSet = preferences.get(IMAGE_SET_KEY, imageSetDefault); + configSource = configSourceFactory.getConfigSource(preferences.get(CONFIG_SOURCE_KEY, "")); + final int documentationVersion = ActionBuilderUtils.getInt(ACTION_BUILDER, "docuVersion", 0); + if (documentationVersion > 0 && preferences.getInt(DOCUMENTATION_VERSION_KEY, 0) < documentationVersion) { + // remember to open documentation + autoPopupDocumentation = true; + // update documentation version right now, because we want the help popup only one time + preferences.putInt(DOCUMENTATION_VERSION_KEY, documentationVersion); } } @@ -276,7 +276,7 @@ } this.archDirectory = archDirectory; - prefs.put(ARCH_DIRECTORY_KEY, archDirectory.toString()); + preferences.put(ARCH_DIRECTORY_KEY, archDirectory.toString()); } /** @@ -307,7 +307,7 @@ } this.mapsDirectory = mapsDirectory; - prefs.put(MAP_DIRECTORY_KEY, mapsDirectory.toString()); + preferences.put(MAP_DIRECTORY_KEY, mapsDirectory.toString()); } /** @@ -366,7 +366,7 @@ } this.mediaDirectory = mediaDirectory; - prefs.put(MEDIA_DIRECTORY_KEY, mediaDirectory.getPath()); + preferences.put(MEDIA_DIRECTORY_KEY, mediaDirectory.getPath()); } /** @@ -408,7 +408,7 @@ } this.imageSet = imageSet; - prefs.put(IMAGE_SET_KEY, imageSet); + preferences.put(IMAGE_SET_KEY, imageSet); } /** @@ -447,7 +447,7 @@ } this.configSource = configSource; - prefs.put(CONFIG_SOURCE_KEY, configSource.getName()); + preferences.put(CONFIG_SOURCE_KEY, configSource.getName()); } /** @@ -470,16 +470,16 @@ * {@inheritDoc} */ @Override - public boolean isAutoPopupDocu() { - return autoPopupDocu; + public boolean isAutoPopupDocumentation() { + return autoPopupDocumentation; } /** * {@inheritDoc} */ @Override - public void setAutoPopupDocu(final boolean autoPopupDocu) { - this.autoPopupDocu = autoPopupDocu; + public void setAutoPopupDocumentation(final boolean autoPopupDocumentation) { + this.autoPopupDocumentation = autoPopupDocumentation; } /** @@ -488,7 +488,7 @@ */ @Override public boolean isShowMainToolbar() { - return prefs.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT); + return preferences.getBoolean(SHOW_MAIN_TOOLBAR_KEY, SHOW_MAIN_TOOLBAR_DEFAULT); } /** @@ -496,7 +496,7 @@ */ @Override public void setShowMainToolbar(final boolean selected) { - prefs.putBoolean(SHOW_MAIN_TOOLBAR_KEY, selected); + preferences.putBoolean(SHOW_MAIN_TOOLBAR_KEY, selected); } /** @@ -504,8 +504,8 @@ */ @NotNull @Override - public String getUsername() { - return prefs.get(PREFS_USERNAME, PREFS_USERNAME_DEFAULT); + public String getUserName() { + return preferences.get(PREFERENCES_USER_NAME, PREFERENCES_USER_NAME_DEFAULT); } /** @@ -513,16 +513,16 @@ */ @NotNull @Override - public String getUsernameDefault() { - return PREFS_USERNAME_DEFAULT; + public String getUserNameDefault() { + return PREFERENCES_USER_NAME_DEFAULT; } /** * {@inheritDoc} */ @Override - public void setUsername(@NotNull final String username) { - prefs.put(PREFS_USERNAME, username); + public void setUserName(@NotNull final String userName) { + preferences.put(PREFERENCES_USER_NAME, userName); } } // class DefaultGlobalSettings Modified: trunk/src/app/net/sf/gridarta/model/settings/GlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/settings/GlobalSettings.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/app/net/sf/gridarta/model/settings/GlobalSettings.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -28,7 +28,7 @@ public interface GlobalSettings { /** - * Default value for whether the main windows's toolbar is shown. + * Default value for whether the main window's toolbar is shown. */ boolean SHOW_MAIN_TOOLBAR_DEFAULT = true; @@ -102,9 +102,9 @@ void setChangedDir(boolean hasChangedDir); - boolean isAutoPopupDocu(); + boolean isAutoPopupDocumentation(); - void setAutoPopupDocu(boolean autoPopupDocu); + void setAutoPopupDocumentation(boolean autoPopupDocumentation); @NotNull File getCurrentDirectory(); @@ -198,24 +198,24 @@ void setShowMainToolbar(boolean selected); /** - * Returns the username. - * @return the username + * Returns the user name. + * @return the user name */ @NotNull - String getUsername(); + String getUserName(); /** - * Returns the default username. - * @return the default username + * Returns the default user name. + * @return the default user name */ @NotNull - String getUsernameDefault(); + String getUserNameDefault(); /** - * Sets the username. - * @param username the username + * Sets the user name. + * @param userName the user name */ - void setUsername(@NotNull String username); + void setUserName(@NotNull String userName); /** * Adds a {@link GlobalSettingsListener} to be notified of changes. Modified: trunk/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java 2010-05-29 06:50:41 UTC (rev 8028) +++ trunk/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java 2010-05-29 07:12:23 UTC (rev 8029) @@ -134,7 +134,7 @@ * {@inheritDoc} */ @Override - public boolean isAutoPopupDocu() { + public boolean isAutoPopupDocumentation() { throw new AssertionError(); } @@ -142,7 +142,7 @@ * {@inheritDoc} */ @Override - public void setAutoPopupDocu(final boolean autoPopupDocu) { + public void setAutoPopupDocumentation(final boolean autoPopupDocumentation) { throw new AssertionError(); } @@ -276,7 +276,7 @@ */ @NotNull @Override - public String getUsername() { + public String getUserName() { throw new AssertionError(); } @@ -285,7 +285,7 @@ */ @NotNull @Override - public String getUsernameDefault() { + public String getUserNameDefault() { throw new AssertionError(); } @@ -293,7 +293,7 @@ * {@inheritDoc} */ @Override - public void setUsername(@NotNull final String username) { + public void setUserName(@NotNull final String userName) { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-29 06:50:47
|
Revision: 8028 http://gridarta.svn.sourceforge.net/gridarta/?rev=8028&view=rev Author: akirschbaum Date: 2010-05-29 06:50:41 +0000 (Sat, 29 May 2010) Log Message: ----------- Add @NotNull/@Nullable annotations. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/misc/Recent.java trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java trunk/src/app/net/sf/gridarta/model/settings/AbstractGlobalSettings.java trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java trunk/src/app/net/sf/gridarta/model/settings/GlobalSettings.java trunk/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java Modified: trunk/src/app/net/sf/gridarta/gui/misc/Recent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/Recent.java 2010-05-29 06:42:33 UTC (rev 8027) +++ trunk/src/app/net/sf/gridarta/gui/misc/Recent.java 2010-05-29 06:50:41 UTC (rev 8028) @@ -52,16 +52,19 @@ /** * The {@link ActionBuilder}. */ + @NotNull private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); /** * The {@link Preferences}. */ + @NotNull private static final Preferences prefs = Preferences.userNodeForPackage(RecentManager.class); /** * Title = map name. */ + @NotNull private final String title; /** @@ -103,7 +106,7 @@ * @param mapImageCache the map image cache instance * @param fileControl the file control */ - Recent(final String title, final File mapFile, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl) { + Recent(@NotNull final String title, @NotNull final File mapFile, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapImageCache<G, A, R> mapImageCache, @NotNull final FileControl<G, A, R> fileControl) { super(title); this.mapFile = mapFile; this.title = title; @@ -143,6 +146,7 @@ * Get the short filename. * @return short filename */ + @NotNull private String getShortFileName() { try { if (mapFile.getCanonicalPath().startsWith(globalSettings.getMapsDirectory().getCanonicalPath())) { @@ -172,7 +176,7 @@ * {@inheritDoc} */ @Override - public void actionPerformed(final ActionEvent e) { + public void actionPerformed(@NotNull final ActionEvent e) { try { mapViewsManager.openMapFileWithView(mapFile, null); } catch (final IOException ex) { @@ -202,7 +206,7 @@ * {@inheritDoc} */ @Override - public boolean equals(final Object obj) { + public boolean equals(@Nullable final Object obj) { return obj != null && obj instanceof Recent && mapFile.equals(((Recent<?, ?, ?>) obj).mapFile); } @@ -217,6 +221,7 @@ /** * {@inheritDoc} */ + @NotNull @Override protected Object clone() { try { Modified: trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-29 06:42:33 UTC (rev 8027) +++ trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-29 06:50:41 UTC (rev 8028) @@ -58,6 +58,7 @@ /** * Preferences. */ + @NotNull private static final Preferences prefs = Preferences.userNodeForPackage(RecentManager.class); /** @@ -69,6 +70,7 @@ /** * List with recents. */ + @NotNull private final LinkedList<Recent<G, A, R>> recents = new LinkedList<Recent<G, A, R>>(); /** @@ -227,7 +229,7 @@ * Update the recent menu. * @param recents current recents */ - private void updateRecent(final Iterable<Recent<G, A, R>> recents) { + private void updateRecent(@NotNull final Iterable<Recent<G, A, R>> recents) { if (recentMenu == null) { return; } Modified: trunk/src/app/net/sf/gridarta/model/settings/AbstractGlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/settings/AbstractGlobalSettings.java 2010-05-29 06:42:33 UTC (rev 8027) +++ trunk/src/app/net/sf/gridarta/model/settings/AbstractGlobalSettings.java 2010-05-29 06:50:41 UTC (rev 8028) @@ -20,6 +20,7 @@ package net.sf.gridarta.model.settings; import net.sf.gridarta.utils.EventListenerList2; +import org.jetbrains.annotations.NotNull; /** * Abstract base class for {@link GlobalSettings} implementations. @@ -30,13 +31,14 @@ /** * The {@link GlobalSettingsListener}s to inform of changes. */ + @NotNull private final EventListenerList2<GlobalSettingsListener> listenerList = new EventListenerList2<GlobalSettingsListener>(GlobalSettingsListener.class); /** * {@inheritDoc} */ @Override - public void addGlobalSettingsListener(final GlobalSettingsListener listener) { + public void addGlobalSettingsListener(@NotNull final GlobalSettingsListener listener) { listenerList.add(listener); } @@ -44,7 +46,7 @@ * {@inheritDoc} */ @Override - public void removeGlobalSettingsListener(final GlobalSettingsListener listener) { + public void removeGlobalSettingsListener(@NotNull final GlobalSettingsListener listener) { listenerList.remove(listener); } Modified: trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java 2010-05-29 06:42:33 UTC (rev 8027) +++ trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java 2010-05-29 06:50:41 UTC (rev 8028) @@ -38,16 +38,19 @@ /** * The {@link ActionBuilder}. */ + @NotNull private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); /** * The preferences key for the archetype directory. */ + @NotNull private static final String MAP_DIRECTORY_KEY = "mapDirectory"; /** * The preferences key for the archetype directory. */ + @NotNull private static final String ARCH_DIRECTORY_KEY = "archDirectory"; /** @@ -65,31 +68,37 @@ /** * The preferences key for storing the last known docu version. */ + @NotNull private static final String DOCU_VERSION_KEY = "docuVersion"; /** * Key for info whether the main windows's toolbar is shown. */ + @NotNull private static final String SHOW_MAIN_TOOLBAR_KEY = "ShowMainToolbar"; /** * Preferences key for username. */ + @NotNull private static final String PREFS_USERNAME = "username"; /** * Preferences default value for username. */ + @NotNull private static final String PREFS_USERNAME_DEFAULT = System.getProperty("user.name"); /** * The preferences key for configuration source. */ + @NotNull private static final String CONFIG_SOURCE_KEY = "configSource"; /** * Preferences. */ + @NotNull private static final Preferences prefs = Preferences.userNodeForPackage(MainControl.class); /** @@ -159,12 +168,14 @@ /** * The current main directory. */ + @NotNull private File currentDirectory = new File(System.getProperty("user.dir")); /** * The image directory. By default, created images are stored in this * directory. */ + @NotNull private File imageDirectory; /** @@ -187,6 +198,7 @@ /** * The {@link PreferenceChangeListener} used to detect settings changes. */ + @NotNull private final PreferenceChangeListener preferenceChangeListener = new PreferenceChangeListener() { /** {@inheritDoc} */ @@ -301,6 +313,7 @@ /** * {@inheritDoc} */ + @NotNull @Override public File getCurrentDirectory() { return currentDirectory; @@ -310,7 +323,7 @@ * {@inheritDoc} */ @Override - public void setCurrentDirectory(final File currentDirectory) { + public void setCurrentDirectory(@NotNull final File currentDirectory) { this.currentDirectory = currentDirectory; } @@ -401,6 +414,7 @@ /** * {@inheritDoc} */ + @NotNull @Override public File getImageDirectory() { return imageDirectory; @@ -410,7 +424,7 @@ * {@inheritDoc} */ @Override - public void setImageDirectory(final File imageDirectory) { + public void setImageDirectory(@NotNull final File imageDirectory) { this.imageDirectory = imageDirectory; } Modified: trunk/src/app/net/sf/gridarta/model/settings/GlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/settings/GlobalSettings.java 2010-05-29 06:42:33 UTC (rev 8027) +++ trunk/src/app/net/sf/gridarta/model/settings/GlobalSettings.java 2010-05-29 06:50:41 UTC (rev 8028) @@ -76,12 +76,13 @@ * Sets the directory to save created image to. * @param imageDirectory the image directory */ - void setImageDirectory(File imageDirectory); + void setImageDirectory(@NotNull File imageDirectory); /** * Returns the directory to save images to. * @return the image directory */ + @NotNull File getImageDirectory(); /** @@ -105,9 +106,10 @@ void setAutoPopupDocu(boolean autoPopupDocu); + @NotNull File getCurrentDirectory(); - void setCurrentDirectory(File currentDirectory); + void setCurrentDirectory(@NotNull File currentDirectory); /** * Returns the pickmap directory. @@ -219,12 +221,12 @@ * Adds a {@link GlobalSettingsListener} to be notified of changes. * @param listener the listener */ - void addGlobalSettingsListener(GlobalSettingsListener listener); + void addGlobalSettingsListener(@NotNull GlobalSettingsListener listener); /** * Removes a {@link GlobalSettingsListener} to be notified of changes. * @param listener the listener */ - void removeGlobalSettingsListener(GlobalSettingsListener listener); + void removeGlobalSettingsListener(@NotNull GlobalSettingsListener listener); } // interface GlobalSettings Modified: trunk/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java 2010-05-29 06:42:33 UTC (rev 8027) +++ trunk/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java 2010-05-29 06:50:41 UTC (rev 8028) @@ -84,13 +84,14 @@ * {@inheritDoc} */ @Override - public void setImageDirectory(final File imageDirectory) { + public void setImageDirectory(@NotNull final File imageDirectory) { throw new AssertionError(); } /** * {@inheritDoc} */ + @NotNull @Override public File getImageDirectory() { throw new AssertionError(); @@ -148,6 +149,7 @@ /** * {@inheritDoc} */ + @NotNull @Override public File getCurrentDirectory() { throw new AssertionError(); @@ -157,7 +159,7 @@ * {@inheritDoc} */ @Override - public void setCurrentDirectory(final File currentDirectory) { + public void setCurrentDirectory(@NotNull final File currentDirectory) { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-29 06:42:40
|
Revision: 8027 http://gridarta.svn.sourceforge.net/gridarta/?rev=8027&view=rev Author: akirschbaum Date: 2010-05-29 06:42:33 +0000 (Sat, 29 May 2010) Log Message: ----------- Remove RecentManager.mapManagerListener. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java Modified: trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-27 18:45:21 UTC (rev 8026) +++ trunk/src/app/net/sf/gridarta/gui/misc/RecentManager.java 2010-05-29 06:42:33 UTC (rev 8027) @@ -104,49 +104,6 @@ private final Map<MapControl<G, A, R>, MapTracker> mapTrackers = new IdentityHashMap<MapControl<G, A, R>, MapTracker>(); /** - * The {@link MapManagerListener}. - */ - private final MapManagerListener<G, A, R> mapManagerListener = new MapManagerListener<G, A, R>() { - - /** {@inheritDoc} */ - @Override - public void currentMapChanged(@Nullable final MapControl<G, A, R> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - @Override - public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { - if (interactive) { - addRecent(mapControl.getMapModel(), null); - final MapTracker mapTracker = new MapTracker(mapControl.getMapModel()); - if (mapTrackers.put(mapControl, mapTracker) != null) { - assert false; - } - mapControl.addMapControlListener(mapTracker); - mapControl.getMapModel().addMapModelListener(mapTracker); - } - } - - /** {@inheritDoc} */ - @Override - public void mapClosing(@NotNull final MapControl<G, A, R> mapControl) { - // ignore - } - - /** {@inheritDoc} */ - @Override - public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) { - final MapTracker mapTracker = mapTrackers.remove(mapControl); - if (mapTracker != null) { - mapControl.getMapModel().removeMapModelListener(mapTracker); - mapControl.removeMapControlListener(mapTracker); - } - } - - }; - - /** * Create a new instance. * @param mapManager the map manager instance * @param mapViewsManager the map views manager instance @@ -161,6 +118,46 @@ this.globalSettings = globalSettings; this.mapImageCache = mapImageCache; this.fileControl = fileControl; + + final MapManagerListener<G, A, R> mapManagerListener = new MapManagerListener<G, A, R>() { + + /** {@inheritDoc} */ + @Override + public void currentMapChanged(@Nullable final MapControl<G, A, R> mapControl) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { + if (interactive) { + addRecent(mapControl.getMapModel(), null); + final MapTracker mapTracker = new MapTracker(mapControl.getMapModel()); + if (mapTrackers.put(mapControl, mapTracker) != null) { + assert false; + } + mapControl.addMapControlListener(mapTracker); + mapControl.getMapModel().addMapModelListener(mapTracker); + } + } + + /** {@inheritDoc} */ + @Override + public void mapClosing(@NotNull final MapControl<G, A, R> mapControl) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) { + final MapTracker mapTracker = mapTrackers.remove(mapControl); + if (mapTracker != null) { + mapControl.getMapModel().removeMapModelListener(mapTracker); + mapControl.removeMapControlListener(mapTracker); + } + } + + }; mapManager.addMapManagerListener(mapManagerListener); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-27 18:45:27
|
Revision: 8026 http://gridarta.svn.sourceforge.net/gridarta/?rev=8026&view=rev Author: akirschbaum Date: 2010-05-27 18:45:21 +0000 (Thu, 27 May 2010) Log Message: ----------- Fix typo. Modified Paths: -------------- trunk/gridarta.ipr Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2010-05-27 18:43:10 UTC (rev 8025) +++ trunk/gridarta.ipr 2010-05-27 18:45:21 UTC (rev 8026) @@ -1153,6 +1153,7 @@ <w>japi</w> <w>javac</w> <w>longdescription</w> + <w>magicmap</w> <w>matchers</w> <w>mmorpg</w> <w>multi</w> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-27 18:43:17
|
Revision: 8025 http://gridarta.svn.sourceforge.net/gridarta/?rev=8025&view=rev Author: akirschbaum Date: 2010-05-27 18:43:10 +0000 (Thu, 27 May 2010) Log Message: ----------- Simplify code. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 18:38:36 UTC (rev 8024) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 18:43:10 UTC (rev 8025) @@ -108,14 +108,12 @@ LOOP: while (true) { - while (true) { if (thisLine2 == null) { break LOOP; } final String thisLine = thisLine2.trim(); - if (thisLine.startsWith("#") || thisLine.length() == 0) { thisLine2 = in.readLine(); continue; @@ -149,18 +147,15 @@ initParseArchetype(); - thisLine2 = in.readLine(); - @Nullable String editorFolder = null; while (true) { + thisLine2 = in.readLine(); if (thisLine2 == null) { break LOOP; } final String thisLine = thisLine2.trim(); - if (thisLine.startsWith("#") || thisLine.length() == 0) { - thisLine2 = in.readLine(); continue; } @@ -197,8 +192,6 @@ } else { archetypeBuilder.addObjectText(thisLine); } - - thisLine2 = in.readLine(); } final R archetype = archetypeBuilder.finish(); @@ -206,27 +199,23 @@ if (firstArch != null) { firstArch.addTailPart(archetype); finishParseArchetypePart(firstArch, archetype, errorViewCollector); - } else { - if (addToPanel(isInternPath, editorFolder, archetype)) { - final String panel; - final String folder; - if (!archetypeSet.isLoadedFromArchive() || archName != null) { - panel = panelName; - folder = folderName; - } else { - if (editorFolder == null) { - panel = "default"; - folder = "default"; - } else { - final String[] names = editorFolder.split("/", 3); - panel = names[0]; - folder = names.length >= 2 ? names[1] : names[0]; - } - } - archetype.setEditorFolder(panel + "/" + folder); + } else if (addToPanel(isInternPath, editorFolder, archetype)) { + final String panel; + final String folder; + if (!archetypeSet.isLoadedFromArchive() || archName != null) { + panel = panelName; + folder = folderName; + } else if (editorFolder == null) { + panel = "default"; + folder = "default"; } else { - archetype.setEditorFolder(GameObject.EDITOR_FOLDER_INTERN); + final String[] names = editorFolder.split("/", 3); + panel = names[0]; + folder = names.length >= 2 ? names[1] : names[0]; } + archetype.setEditorFolder(panel + "/" + folder); + } else { + archetype.setEditorFolder(GameObject.EDITOR_FOLDER_INTERN); } try { archetypeSet.addArchetype(archetype); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-27 18:38:42
|
Revision: 8024 http://gridarta.svn.sourceforge.net/gridarta/?rev=8024&view=rev Author: akirschbaum Date: 2010-05-27 18:38:36 +0000 (Thu, 27 May 2010) Log Message: ----------- Avoid duplicate work when parsing Atrinik or Daimonin multi-part archetypes. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java 2010-05-27 18:28:24 UTC (rev 8023) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java 2010-05-27 18:38:36 UTC (rev 8024) @@ -143,8 +143,8 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archMore) { - if (archMore) { + protected void finishParseArchetype(@NotNull final Archetype archetype) { + if (archetype.isMulti()) { calcLowestMulti(archetype); } } @@ -162,8 +162,6 @@ * because in ISO view, the big image is drawn for it's lowest part, in * order to get the overlapping correct. <p/> * @param arch last tail part of this multi - * @todo This method is called repeatedly for each multi-part. It would be - * better if it was called only once per multi-part. */ private void calcLowestMulti(final net.sf.gridarta.model.archetype.Archetype<GameObject, MapArchObject, Archetype> arch) { final Archetype head = arch.getHead(); Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:28:24 UTC (rev 8023) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:38:36 UTC (rev 8024) @@ -161,7 +161,7 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archMore) { + protected void finishParseArchetype(@NotNull final Archetype archetype) { } /** Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java 2010-05-27 18:28:24 UTC (rev 8023) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java 2010-05-27 18:38:36 UTC (rev 8024) @@ -142,8 +142,8 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archMore) { - if (archMore) { + protected void finishParseArchetype(@NotNull final Archetype archetype) { + if (archetype.isMulti()) { calcLowestMulti(archetype); } } @@ -161,8 +161,6 @@ * because in ISO view, the big image is drawn for it's lowest part, in * order to get the overlapping correct. <p/> * @param arch last tail part of this multi - * @todo This method is called repeatedly for each multi-part. It would be - * better if it was called only once per multi-part. */ private void calcLowestMulti(final net.sf.gridarta.model.archetype.Archetype<GameObject, MapArchObject, Archetype> arch) { final Archetype head = arch.getHead(); Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 18:28:24 UTC (rev 8023) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 18:38:36 UTC (rev 8024) @@ -141,6 +141,9 @@ final String archetypeName = archName != null ? archName : thisLine2.trim().substring(7); archetypeBuilder.reinit(archetypeName); if (!archMore) { + if (firstArch != null) { + finishParseArchetype(firstArch); + } firstArch = null; } @@ -231,7 +234,6 @@ errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ex.getMessage()); } - finishParseArchetype(archetype, archMore); archMore = false; if (archName != null) { @@ -246,6 +248,10 @@ thisLine2 = in.readLine(); } + + if (firstArch != null) { + finishParseArchetype(firstArch); + } } /** @@ -351,13 +357,10 @@ protected abstract void finishParseArchetypePart(@NotNull final R firstArch, @NotNull final R archetype, @NotNull final ErrorViewCollector errorViewCollector); /** - * Called after the "end" line. For tail parts {@link - * #finishParseArchetypePart(Archetype, Archetype, ErrorViewCollector)} is - * called first. + * Called after all parts of an archetype have been processed. * @param archetype the archetype - * @param archMore whether another part follows */ - protected abstract void finishParseArchetype(@NotNull final R archetype, final boolean archMore); + protected abstract void finishParseArchetype(@NotNull final R archetype); /** * Returns whether an archetype should be added to the archetype chooser. Modified: trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java 2010-05-27 18:28:24 UTC (rev 8023) +++ trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java 2010-05-27 18:38:36 UTC (rev 8024) @@ -79,7 +79,7 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final TestArchetype archetype, final boolean archMore) { + protected void finishParseArchetype(@NotNull final TestArchetype archetype) { } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-27 18:28:31
|
Revision: 8023 http://gridarta.svn.sourceforge.net/gridarta/?rev=8023&view=rev Author: akirschbaum Date: 2010-05-27 18:28:24 +0000 (Thu, 27 May 2010) Log Message: ----------- Extract code into functions. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:21:39 UTC (rev 8022) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:28:24 UTC (rev 8023) @@ -101,23 +101,7 @@ } if (line.equals("lore")) { - final StringBuilder loreText = new StringBuilder(); - while (true) { - final String thisLine = in.readLine(); - if (thisLine == null) { - errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated archetype: lore not terminated by endlore"); - break; - } - - if (thisLine.trim().equals("endlore")) { - break; - } - - // keep leading whitespace - loreText.append(thisLine).append("\n"); - } - - archetypeBuilder.setLoreText(loreText.toString()); + parseLore(in, archetypeBuilder, errorViewCollector); return true; } @@ -139,6 +123,34 @@ } /** + * Parses a "lore..endlore" block. + * @param in the reader to read from + * @param archetypeBuilder the archetype builder to update + * @param errorViewCollector the error view collector for reporting errors + * @throws IOException if an I/O error occurs + */ + private static void parseLore(@NotNull final BufferedReader in, @NotNull final DefaultArchetypeBuilder archetypeBuilder, @NotNull final ErrorViewCollector errorViewCollector) throws IOException { + final StringBuilder loreText = new StringBuilder(); + + while (true) { + final String thisLine = in.readLine(); + if (thisLine == null) { + errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated archetype: lore not terminated by endlore"); + return; + } + + if (thisLine.trim().equals("endlore")) { + break; + } + + // keep leading whitespace + loreText.append(thisLine).append("\n"); + } + + archetypeBuilder.setLoreText(loreText.toString()); + } + + /** * {@inheritDoc} */ @Override Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 18:21:39 UTC (rev 8022) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 18:28:24 UTC (rev 8023) @@ -168,57 +168,9 @@ } else if (thisLine.equals("end")) { break; } else if (thisLine.equals("msg")) { - final StringBuilder msgText = new StringBuilder(); - - while (true) { - thisLine2 = in.readLine(); - if (thisLine2 == null) { - errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated archetype: msg not terminated by endmsg"); - break LOOP; - } - - final String thisLine3 = thisLine2.trim(); - if (thisLine3.equals("endmsg")) { - break; - } - - // keep leading whitespace - msgText.append(thisLine2).append("\n"); - } - - if (msgText.length() > 0) { - archetypeBuilder.setMsgText(msgText.toString()); - } + parseMsg(in, errorViewCollector); } else if (thisLine.equals("anim")) { - final StringBuilder animText = new StringBuilder(); - - while (true) { - thisLine2 = in.readLine(); - if (thisLine2 == null) { - errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated animation: anim not terminated by mina"); - break LOOP; - } - - final String thisLine3 = thisLine2.trim(); - if (thisLine3.startsWith("#") || thisLine3.length() == 0) { - continue; - } - - if (thisLine3.equals("mina")) { - break; - } - - animText.append(thisLine3).append("\n"); - } - - final String animationName = "_" + archetypeBuilder.getArchetypeName(); - try { - animationObjects.addAnimationObject(animationName, animText.toString(), path + animationName); - } catch (final DuplicateAnimationException e) { - errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logDuplicateAnimation", e.getDuplicate().getAnimName())); - } catch (final IllegalAnimationException ex) { - errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "illegal animation: " + ex.getAnimationObject().getPath()); - } + parseAnim(in, errorViewCollector, path); } else if (thisLine.startsWith("visibility ")) { errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "Ignoring obsolete 'visibility' attribute: " + archetypeBuilder.getArchetypeName()); } else if (thisLine.startsWith("magicmap ")) { @@ -297,6 +249,75 @@ } /** + * Parses a "msg..endmsg" block. + * @param in the reader to read from + * @param errorViewCollector the error view collector for reporting errors + * @throws IOException if an I/O error occurs + */ + private void parseMsg(@NotNull final BufferedReader in, @NotNull final ErrorViewCollector errorViewCollector) throws IOException { + final StringBuilder msgText = new StringBuilder(); + + while (true) { + final String thisLine2 = in.readLine(); + if (thisLine2 == null) { + errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated archetype: msg not terminated by endmsg"); + return; + } + + final String thisLine3 = thisLine2.trim(); + if (thisLine3.equals("endmsg")) { + break; + } + + // keep leading whitespace + msgText.append(thisLine2).append("\n"); + } + + if (msgText.length() > 0) { + archetypeBuilder.setMsgText(msgText.toString()); + } + } + + /** + * Parses an "anim..mina" block. + * @param in the reader to read from + * @param errorViewCollector the error view collector for reporting errors + * @param path the archetype's path name + * @throws IOException if an I/O error occurs + */ + private void parseAnim(@NotNull final BufferedReader in, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final String path) throws IOException { + final StringBuilder animText = new StringBuilder(); + + while (true) { + final String thisLine2 = in.readLine(); + if (thisLine2 == null) { + errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated animation: anim not terminated by mina"); + return; + } + + final String thisLine3 = thisLine2.trim(); + if (thisLine3.startsWith("#") || thisLine3.length() == 0) { + continue; + } + + if (thisLine3.equals("mina")) { + break; + } + + animText.append(thisLine3).append("\n"); + } + + final String animationName = "_" + archetypeBuilder.getArchetypeName(); + try { + animationObjects.addAnimationObject(animationName, animText.toString(), path + animationName); + } catch (final DuplicateAnimationException e) { + errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logDuplicateAnimation", e.getDuplicate().getAnimName())); + } catch (final IllegalAnimationException ex) { + errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "illegal animation: " + ex.getAnimationObject().getPath()); + } + } + + /** * Called when a new archetype starts. */ protected abstract void initParseArchetype(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-27 18:21:46
|
Revision: 8022 http://gridarta.svn.sourceforge.net/gridarta/?rev=8022&view=rev Author: akirschbaum Date: 2010-05-27 18:21:39 +0000 (Thu, 27 May 2010) Log Message: ----------- Fix typos. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java 2010-05-27 18:18:21 UTC (rev 8021) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/archetype/ArchetypeParser.java 2010-05-27 18:21:39 UTC (rev 8022) @@ -97,7 +97,7 @@ @Override protected boolean processLine(@NotNull final BufferedReader in, @NotNull final String line, @NotNull final String line2, @NotNull final DefaultArchetypeBuilder archetypeBuilder, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final List<GameObject> invObjects) { if (line.startsWith("mpart_id ")) { - // shape ID for multiparts + // shape ID for multi-parts try { multiShapeID = Integer.parseInt(line.substring(9).trim()); @@ -112,7 +112,7 @@ } if (line.startsWith("mpart_nr ")) { - // part nr for multiparts + // part nr for multi-parts try { final int i = Integer.parseInt(line.substring(9).trim()); archetypeBuilder.setMultiPartNr(i); @@ -143,8 +143,8 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archmore) { - if (archmore) { + protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archMore) { + if (archMore) { calcLowestMulti(archetype); } } @@ -160,16 +160,16 @@ /** * Calculate the lowest part of this multi-arch. This lowest part is needed * because in ISO view, the big image is drawn for it's lowest part, in - * order to get the overlappings correct. <p/> + * order to get the overlapping correct. <p/> * @param arch last tail part of this multi - * @todo This method is called repeatedly for each multipart. It would be - * better if it was called only once per multipart. + * @todo This method is called repeatedly for each multi-part. It would be + * better if it was called only once per multi-part. */ private void calcLowestMulti(final net.sf.gridarta.model.archetype.Archetype<GameObject, MapArchObject, Archetype> arch) { final Archetype head = arch.getHead(); int minYOffset = multiPositionData.getYOffset(head.getMultiShapeID(), head.getMultiPartNr()); - // 1.step: find the maximal y-offest + // 1.step: find the maximal y-offset for (net.sf.gridarta.model.archetype.Archetype<GameObject, MapArchObject, Archetype> tail = head.getMultiNext(); tail != null; tail = tail.getMultiNext()) { final int t = multiPositionData.getYOffset(tail.getMultiShapeID(), tail.getMultiPartNr()); if (t < minYOffset) { Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:18:21 UTC (rev 8021) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:21:39 UTC (rev 8022) @@ -149,7 +149,7 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archmore) { + protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archMore) { } /** Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java 2010-05-27 18:18:21 UTC (rev 8021) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/archetype/ArchetypeParser.java 2010-05-27 18:21:39 UTC (rev 8022) @@ -96,7 +96,7 @@ @Override protected boolean processLine(@NotNull final BufferedReader in, @NotNull final String line, @NotNull final String line2, @NotNull final DefaultArchetypeBuilder archetypeBuilder, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final List<GameObject> invObjects) { if (line.startsWith("mpart_id ")) { - // shape ID for multiparts + // shape ID for multi-parts try { multiShapeID = Integer.parseInt(line.substring(9).trim()); @@ -111,7 +111,7 @@ } if (line.startsWith("mpart_nr ")) { - // part nr for multiparts + // part nr for multi-parts try { final int i = Integer.parseInt(line.substring(9).trim()); archetypeBuilder.setMultiPartNr(i); @@ -142,8 +142,8 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archmore) { - if (archmore) { + protected void finishParseArchetype(@NotNull final Archetype archetype, final boolean archMore) { + if (archMore) { calcLowestMulti(archetype); } } @@ -159,16 +159,16 @@ /** * Calculate the lowest part of this multi-arch. This lowest part is needed * because in ISO view, the big image is drawn for it's lowest part, in - * order to get the overlappings correct. <p/> + * order to get the overlapping correct. <p/> * @param arch last tail part of this multi - * @todo This method is called repeatedly for each multipart. It would be - * better if it was called only once per multipart. + * @todo This method is called repeatedly for each multi-part. It would be + * better if it was called only once per multi-part. */ private void calcLowestMulti(final net.sf.gridarta.model.archetype.Archetype<GameObject, MapArchObject, Archetype> arch) { final Archetype head = arch.getHead(); int minYOffset = multiPositionData.getYOffset(head.getMultiShapeID(), head.getMultiPartNr()); - // 1.step: find the maximal y-offest + // 1.step: find the maximal y-offset for (Archetype tail = head.getMultiNext(); tail != null; tail = tail.getMultiNext()) { final int t = multiPositionData.getYOffset(tail.getMultiShapeID(), tail.getMultiPartNr()); if (t < minYOffset) { Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 18:18:21 UTC (rev 8021) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 18:21:39 UTC (rev 8022) @@ -297,7 +297,7 @@ } /** - * Called whan a new archetype starts. + * Called when a new archetype starts. */ protected abstract void initParseArchetype(); @@ -334,9 +334,9 @@ * #finishParseArchetypePart(Archetype, Archetype, ErrorViewCollector)} is * called first. * @param archetype the archetype - * @param archmore whether another part follows + * @param archMore whether another part follows */ - protected abstract void finishParseArchetype(@NotNull final R archetype, final boolean archmore); + protected abstract void finishParseArchetype(@NotNull final R archetype, final boolean archMore); /** * Returns whether an archetype should be added to the archetype chooser. Modified: trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java 2010-05-27 18:18:21 UTC (rev 8021) +++ trunk/src/test/net/sf/gridarta/model/archetype/TestArchetypeParser.java 2010-05-27 18:21:39 UTC (rev 8022) @@ -79,7 +79,7 @@ * {@inheritDoc} */ @Override - protected void finishParseArchetype(@NotNull final TestArchetype archetype, final boolean archmore) { + protected void finishParseArchetype(@NotNull final TestArchetype archetype, final boolean archMore) { } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-27 18:18:29
|
Revision: 8021 http://gridarta.svn.sourceforge.net/gridarta/?rev=8021&view=rev Author: akirschbaum Date: 2010-05-27 18:18:21 +0000 (Thu, 27 May 2010) Log Message: ----------- Do not ignore caught exception. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:17:06 UTC (rev 8020) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:18:21 UTC (rev 8021) @@ -127,7 +127,7 @@ try { smoothFaces.add(new SmoothFace(tmp[0], tmp[1])); } catch (final DuplicateSmoothFaceException ex) { - errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, archetypeBuilder.getArchetypeName() + ": duplicate smoothface info: " + line); + errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, archetypeBuilder.getArchetypeName() + ": duplicate smoothface '" + ex.getMessage() + "': " + line); } } else { errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, archetypeBuilder.getArchetypeName() + ": invalid smoothface info: " + line); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-27 18:17:12
|
Revision: 8020 http://gridarta.svn.sourceforge.net/gridarta/?rev=8020&view=rev Author: akirschbaum Date: 2010-05-27 18:17:06 +0000 (Thu, 27 May 2010) Log Message: ----------- Cleanup archetype parser: replace loreText flag with control flow. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:16:41 UTC (rev 8019) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/archetype/ArchetypeParser.java 2010-05-27 18:17:06 UTC (rev 8020) @@ -60,13 +60,6 @@ private final SmoothFaces smoothFaces; /** - * The text of the currently parsing "lore..endlore" block. Set to - * <code>null</code> if not parsing a lore block. - */ - @Nullable - private StringBuilder loreText = null; - - /** * Creates an ArchetypeParser. * @param gameObjectParser the game object parser instance to use * @param animationObjects the animation objects instance to use @@ -85,7 +78,6 @@ */ @Override protected void initParseArchetype() { - loreText = null; } /** @@ -101,18 +93,6 @@ */ @Override protected boolean processLine(@NotNull final BufferedReader in, @NotNull final String line, @NotNull final String line2, @NotNull final DefaultArchetypeBuilder archetypeBuilder, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final List<GameObject> invObjects) throws IOException { - if (loreText != null) { - if (line.equals("endlore")) { - assert loreText != null; - archetypeBuilder.setLoreText(loreText.toString()); - loreText = null; - } else { - assert loreText != null; - loreText.append(line2).append("\n"); // thisLine2 allows leading whitespaces - } - return true; - } - if (line.startsWith("arch ")) { final GameObject invObject = gameObjectParser.load(in, line, invObjects); assert invObject != null; @@ -121,7 +101,23 @@ } if (line.equals("lore")) { - loreText = new StringBuilder(); + final StringBuilder loreText = new StringBuilder(); + while (true) { + final String thisLine = in.readLine(); + if (thisLine == null) { + errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated archetype: lore not terminated by endlore"); + break; + } + + if (thisLine.trim().equals("endlore")) { + break; + } + + // keep leading whitespace + loreText.append(thisLine).append("\n"); + } + + archetypeBuilder.setLoreText(loreText.toString()); return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-27 18:16:47
|
Revision: 8019 http://gridarta.svn.sourceforge.net/gridarta/?rev=8019&view=rev Author: akirschbaum Date: 2010-05-27 18:16:41 +0000 (Thu, 27 May 2010) Log Message: ----------- Whitespace changes. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java Modified: trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java 2010-05-27 18:07:07 UTC (rev 8018) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/ArchetypeTypeParser.java 2010-05-27 18:16:41 UTC (rev 8019) @@ -404,14 +404,14 @@ final Attr nameAttribute = ignoreListElement.getAttributeNode(XML_IGNORE_LIST_NAME); if (nameAttribute == null) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_IGNORE + ": section of type " + typeName + ": "+ XML_ELEMENT_IGNORE_LIST + " missing '" + XML_IGNORE_LIST_NAME + "'."); + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_IGNORE + ": section of type " + typeName + ": " + XML_ELEMENT_IGNORE_LIST + " missing '" + XML_IGNORE_LIST_NAME + "'."); continue; } final String name = nameAttribute.getValue(); final Iterable<String> ignoreList = ignorelistsDefinition.get(name); if (ignoreList == null) { - errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_IGNORE + ": section of type " + typeName + ": " + XML_ELEMENT_IGNORE_LIST + " with "+ XML_IGNORE_LIST_NAME + " \"" + name + "\" is undefined."); + errorViewCollector.addWarning(ErrorViewCategory.TYPES_ENTRY_INVALID, XML_ELEMENT_IGNORE + ": section of type " + typeName + ": " + XML_ELEMENT_IGNORE_LIST + " with " + XML_IGNORE_LIST_NAME + " \"" + name + "\" is undefined."); continue; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-27 18:07:14
|
Revision: 8018 http://gridarta.svn.sourceforge.net/gridarta/?rev=8018&view=rev Author: akirschbaum Date: 2010-05-27 18:07:07 +0000 (Thu, 27 May 2010) Log Message: ----------- Cleanup archetype parser: replace msgFlag flag with control flow. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeBuilder.java trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeBuilder.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeBuilder.java 2010-05-27 17:54:40 UTC (rev 8017) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeBuilder.java 2010-05-27 18:07:07 UTC (rev 8018) @@ -92,8 +92,8 @@ attributes.clear(); } - public void addMsgTextLine(@NotNull final String line) { - archetype.addMsgTextLine(line); + public void setMsgText(@NotNull final String msgText) { + archetype.setMsgText(msgText); } @NotNull Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 17:54:40 UTC (rev 8017) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 18:07:07 UTC (rev 8018) @@ -148,37 +148,47 @@ thisLine2 = in.readLine(); - boolean msgFlag = false; @Nullable String editorFolder = null; while (true) { if (thisLine2 == null) { - if (msgFlag) { - errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated archetype: msg not terminted by endmsg"); - } break LOOP; } final String thisLine = thisLine2.trim(); - if (!msgFlag && (thisLine.startsWith("#") || thisLine.length() == 0)) { + if (thisLine.startsWith("#") || thisLine.length() == 0) { thisLine2 = in.readLine(); continue; } - if (msgFlag) { - if (thisLine.equals("endmsg")) { - msgFlag = false; - } else { - archetypeBuilder.addMsgTextLine(thisLine2); - } - } else if (processLine(in, thisLine, thisLine2, archetypeBuilder, errorViewCollector, invObjects)) { + if (processLine(in, thisLine, thisLine2, archetypeBuilder, errorViewCollector, invObjects)) { // ignore } else if (isStartLine(thisLine)) { errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logInventoryInDefArch", thisLine)); } else if (thisLine.equals("end")) { break; } else if (thisLine.equals("msg")) { - msgFlag = true; + final StringBuilder msgText = new StringBuilder(); + + while (true) { + thisLine2 = in.readLine(); + if (thisLine2 == null) { + errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated archetype: msg not terminated by endmsg"); + break LOOP; + } + + final String thisLine3 = thisLine2.trim(); + if (thisLine3.equals("endmsg")) { + break; + } + + // keep leading whitespace + msgText.append(thisLine2).append("\n"); + } + + if (msgText.length() > 0) { + archetypeBuilder.setMsgText(msgText.toString()); + } } else if (thisLine.equals("anim")) { final StringBuilder animText = new StringBuilder(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-27 17:54:47
|
Revision: 8017 http://gridarta.svn.sourceforge.net/gridarta/?rev=8017&view=rev Author: akirschbaum Date: 2010-05-27 17:54:40 +0000 (Thu, 27 May 2010) Log Message: ----------- Cleanup archetype parser: replace animText flag with control flow. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 17:39:37 UTC (rev 8016) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 17:54:40 UTC (rev 8017) @@ -150,7 +150,6 @@ boolean msgFlag = false; @Nullable String editorFolder = null; - @Nullable StringBuilder animText = null; while (true) { if (thisLine2 == null) { if (msgFlag) { @@ -172,23 +171,6 @@ } else { archetypeBuilder.addMsgTextLine(thisLine2); } - } else if (animText != null) { - if (thisLine.equals("mina")) { - final String animationName = "_" + archetypeBuilder.getArchetypeName(); - try { - animationObjects.addAnimationObject(animationName, animText.toString(), path + animationName); - } catch (final DuplicateAnimationException e) { - errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logDuplicateAnimation", e.getDuplicate().getAnimName())); - } catch (final IllegalAnimationException ex) { - errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "illegal animation: " + ex.getAnimationObject().getPath()); - } - - archetypeBuilder.addObjectText("animation " + animationName); - - animText = null; - } else { - animText.append(thisLine).append("\n"); - } } else if (processLine(in, thisLine, thisLine2, archetypeBuilder, errorViewCollector, invObjects)) { // ignore } else if (isStartLine(thisLine)) { @@ -198,7 +180,35 @@ } else if (thisLine.equals("msg")) { msgFlag = true; } else if (thisLine.equals("anim")) { - animText = new StringBuilder(); + final StringBuilder animText = new StringBuilder(); + + while (true) { + thisLine2 = in.readLine(); + if (thisLine2 == null) { + errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated animation: anim not terminated by mina"); + break LOOP; + } + + final String thisLine3 = thisLine2.trim(); + if (thisLine3.startsWith("#") || thisLine3.length() == 0) { + continue; + } + + if (thisLine3.equals("mina")) { + break; + } + + animText.append(thisLine3).append("\n"); + } + + final String animationName = "_" + archetypeBuilder.getArchetypeName(); + try { + animationObjects.addAnimationObject(animationName, animText.toString(), path + animationName); + } catch (final DuplicateAnimationException e) { + errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logDuplicateAnimation", e.getDuplicate().getAnimName())); + } catch (final IllegalAnimationException ex) { + errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "illegal animation: " + ex.getAnimationObject().getPath()); + } } else if (thisLine.startsWith("visibility ")) { errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "Ignoring obsolete 'visibility' attribute: " + archetypeBuilder.getArchetypeName()); } else if (thisLine.startsWith("magicmap ")) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-27 17:39:43
|
Revision: 8016 http://gridarta.svn.sourceforge.net/gridarta/?rev=8016&view=rev Author: akirschbaum Date: 2010-05-27 17:39:37 +0000 (Thu, 27 May 2010) Log Message: ----------- Cleanup archetype parser: replace parsearch flag with control flow. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java Modified: trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-26 21:45:52 UTC (rev 8015) +++ trunk/src/app/net/sf/gridarta/model/archetype/AbstractArchetypeParser.java 2010-05-27 17:39:37 UTC (rev 8016) @@ -102,154 +102,177 @@ initParseArchetype(); @Nullable R firstArch = null; - boolean archmore = false; - boolean parsearch = false; - boolean msgflag = false; - @Nullable String editorFolder = null; - @Nullable StringBuilder animText = null; - - R archlast = null; + boolean archMore = false; + R lastArch = null; boolean reportError = true; - while (thisLine2 != null) { - final String thisLine = thisLine2.trim(); - if (!msgflag && (thisLine.startsWith("#") || thisLine.length() == 0)) { - // skip comments (only outside msges) - thisLine2 = in.readLine(); - continue; - } +LOOP: + while (true) { - if (!parsearch) { + while (true) { + if (thisLine2 == null) { + break LOOP; + } + + final String thisLine = thisLine2.trim(); + + if (thisLine.startsWith("#") || thisLine.length() == 0) { + thisLine2 = in.readLine(); + continue; + } + if (thisLine.equals("More")) { if (firstArch == null) { - firstArch = archlast; + firstArch = lastArch; } - archmore = true; + archMore = true; } else if (isStartLine(thisLine)) { - final String archetypeName = archName != null ? archName : thisLine.substring(7); - archetypeBuilder.reinit(archetypeName); - parsearch = true; - if (!archmore) { - firstArch = null; - } - - initParseArchetype(); - editorFolder = null; + break; } else if (thisLine.length() > 0 && thisLine.charAt(0) != '#') { if (reportError) { reportError = false; errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "unexpected line: " + thisLine); } } - } else if (msgflag) { - if (thisLine.equals("endmsg")) { - msgflag = false; - } else { - archetypeBuilder.addMsgTextLine(thisLine2); // thisLine2 allows leading whitespaces + + thisLine2 = in.readLine(); + } + + final String archetypeName = archName != null ? archName : thisLine2.trim().substring(7); + archetypeBuilder.reinit(archetypeName); + if (!archMore) { + firstArch = null; + } + + initParseArchetype(); + + thisLine2 = in.readLine(); + + boolean msgFlag = false; + @Nullable String editorFolder = null; + @Nullable StringBuilder animText = null; + while (true) { + if (thisLine2 == null) { + if (msgFlag) { + errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated archetype: msg not terminted by endmsg"); + } + break LOOP; } - } else if (animText != null) { - if (thisLine.equals("mina")) { - final String animationName = "_" + archetypeBuilder.getArchetypeName(); - try { - animationObjects.addAnimationObject(animationName, animText.toString(), path + animationName); - } catch (final DuplicateAnimationException e) { - errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logDuplicateAnimation", e.getDuplicate().getAnimName())); - } catch (final IllegalAnimationException ex) { - errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "illegal animation: " + ex.getAnimationObject().getPath()); + + final String thisLine = thisLine2.trim(); + + if (!msgFlag && (thisLine.startsWith("#") || thisLine.length() == 0)) { + thisLine2 = in.readLine(); + continue; + } + + if (msgFlag) { + if (thisLine.equals("endmsg")) { + msgFlag = false; + } else { + archetypeBuilder.addMsgTextLine(thisLine2); } + } else if (animText != null) { + if (thisLine.equals("mina")) { + final String animationName = "_" + archetypeBuilder.getArchetypeName(); + try { + animationObjects.addAnimationObject(animationName, animText.toString(), path + animationName); + } catch (final DuplicateAnimationException e) { + errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logDuplicateAnimation", e.getDuplicate().getAnimName())); + } catch (final IllegalAnimationException ex) { + errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "illegal animation: " + ex.getAnimationObject().getPath()); + } - archetypeBuilder.addObjectText("animation " + animationName); + archetypeBuilder.addObjectText("animation " + animationName); - animText = null; + animText = null; + } else { + animText.append(thisLine).append("\n"); + } + } else if (processLine(in, thisLine, thisLine2, archetypeBuilder, errorViewCollector, invObjects)) { + // ignore + } else if (isStartLine(thisLine)) { + errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logInventoryInDefArch", thisLine)); + } else if (thisLine.equals("end")) { + break; + } else if (thisLine.equals("msg")) { + msgFlag = true; + } else if (thisLine.equals("anim")) { + animText = new StringBuilder(); + } else if (thisLine.startsWith("visibility ")) { + errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "Ignoring obsolete 'visibility' attribute: " + archetypeBuilder.getArchetypeName()); + } else if (thisLine.startsWith("magicmap ")) { + errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "Ignoring obsolete 'magicmap' attribute: " + archetypeBuilder.getArchetypeName()); + } else if (thisLine.startsWith("x ")) { + if (!archMore && !archetypeBuilder.getArchetypeName().equals(STARTARCH_NAME)) { + errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logFoundCoordInDefArchSingleSquareOrHead", "x", archetypeBuilder.getArchetypeName())); + archetypeBuilder.addObjectText(thisLine); + } else { + archetypeBuilder.setMultiX(Integer.parseInt(thisLine.substring(2))); + } + } else if (thisLine.startsWith("y ")) { + if (!archMore && !archetypeBuilder.getArchetypeName().equals(STARTARCH_NAME)) { + errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logFoundCoordInDefArchSingleSquareOrHead", "y", archetypeBuilder.getArchetypeName())); + archetypeBuilder.addObjectText(thisLine); + } else { + archetypeBuilder.setMultiY(Integer.parseInt(thisLine.substring(2))); + } + } else if (thisLine.startsWith("editor_folder ")) { + editorFolder = thisLine.substring(14).trim(); } else { - animText.append(thisLine).append("\n"); + archetypeBuilder.addObjectText(thisLine); } - } else if (processLine(in, thisLine, thisLine2, archetypeBuilder, errorViewCollector, invObjects)) { - // ignore - } else if (isStartLine(thisLine)) { - errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logInventoryInDefArch", thisLine)); - } else if (thisLine.equals("end")) { - final R archetype = archetypeBuilder.finish(); - // we got full arch - parsearch = false; // we write this sucker - if (firstArch != null) { - // add to head our x/y position so he can setup refmax - firstArch.addTailPart(archetype); - finishParseArchetypePart(firstArch, archetype, errorViewCollector); - } else { - // add arch to the archpanel - only if it is not the map arch and not in the intern folder - if (addToPanel(isInternPath, editorFolder, archetype)) { - final String panel; - final String folder; - if (!archetypeSet.isLoadedFromArchive() || archName != null) { - panel = panelName; - folder = folderName; + thisLine2 = in.readLine(); + } + + final R archetype = archetypeBuilder.finish(); + + if (firstArch != null) { + firstArch.addTailPart(archetype); + finishParseArchetypePart(firstArch, archetype, errorViewCollector); + } else { + if (addToPanel(isInternPath, editorFolder, archetype)) { + final String panel; + final String folder; + if (!archetypeSet.isLoadedFromArchive() || archName != null) { + panel = panelName; + folder = folderName; + } else { + if (editorFolder == null) { + panel = "default"; + folder = "default"; } else { - if (editorFolder == null) { - editorFolder = "default"; - } final String[] names = editorFolder.split("/", 3); panel = names[0]; folder = names.length >= 2 ? names[1] : names[0]; } - archetype.setEditorFolder(panel + "/" + folder); - } else { - archetype.setEditorFolder(GameObject.EDITOR_FOLDER_INTERN); } + archetype.setEditorFolder(panel + "/" + folder); + } else { + archetype.setEditorFolder(GameObject.EDITOR_FOLDER_INTERN); } - try { - archetypeSet.addArchetype(archetype); - } catch (final DuplicateArchetypeException ex) { - errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ex.getMessage()); - } + } + try { + archetypeSet.addArchetype(archetype); + } catch (final DuplicateArchetypeException ex) { + errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ex.getMessage()); + } - finishParseArchetype(archetype, archmore); - archmore = false; // we assume this is last... but perhaps.. + finishParseArchetype(archetype, archMore); + archMore = false; - // if this arch was from Artifacts file - return here: - if (archName != null) { - archetype.setArtifact(true); - // here we add all unchanged arch text lines from defArch back to arch - if (prototype != null) { - archetype.addObjectText(AttributeListUtils.diffArchTextKeys(archetype, prototype)); - } - break; + if (archName != null) { + archetype.setArtifact(true); + if (prototype != null) { + archetype.addObjectText(AttributeListUtils.diffArchTextKeys(archetype, prototype)); } - archlast = archetype; - reportError = true; - } else if (thisLine.equals("msg")) { - msgflag = true; - } else if (thisLine.equals("anim")) { - animText = new StringBuilder(); - } else if (thisLine.startsWith("visibility ")) { - errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "Ignoring obsolete 'visibility' attribute: " + archetypeBuilder.getArchetypeName()); - } else if (thisLine.startsWith("magicmap ")) { - errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, "Ignoring obsolete 'magicmap' attribute: " + archetypeBuilder.getArchetypeName()); - } else if (thisLine.startsWith("x ")) { - if (!archmore && !archetypeBuilder.getArchetypeName().equals(STARTARCH_NAME)) { - errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logFoundCoordInDefArchSingleSquareOrHead", "x", archetypeBuilder.getArchetypeName())); - archetypeBuilder.addObjectText(thisLine); - } else { - archetypeBuilder.setMultiX(Integer.parseInt(thisLine.substring(2))); - } - } else if (thisLine.startsWith("y ")) { - if (!archmore && !archetypeBuilder.getArchetypeName().equals(STARTARCH_NAME)) { - errorViewCollector.addWarning(ErrorViewCategory.ARCHETYPE_INVALID, ACTION_BUILDER.format("logFoundCoordInDefArchSingleSquareOrHead", "y", archetypeBuilder.getArchetypeName())); - archetypeBuilder.addObjectText(thisLine); - } else { - archetypeBuilder.setMultiY(Integer.parseInt(thisLine.substring(2))); - } - } else if (thisLine.startsWith("editor_folder ")) { - editorFolder = thisLine.substring(14).trim(); - } else { - archetypeBuilder.addObjectText(thisLine); + break; } + lastArch = archetype; + reportError = true; + thisLine2 = in.readLine(); - } // while loop ends here - - if (msgflag) { - errorViewCollector.addError(ErrorViewCategory.ARCHETYPE_INVALID, "Truncated archetype: msg not terminted by endmsg"); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-26 21:45:59
|
Revision: 8015 http://gridarta.svn.sourceforge.net/gridarta/?rev=8015&view=rev Author: akirschbaum Date: 2010-05-26 21:45:52 +0000 (Wed, 26 May 2010) Log Message: ----------- Accelerate map loading. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/utils/NumberUtils.java Modified: trunk/src/app/net/sf/gridarta/utils/NumberUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/utils/NumberUtils.java 2010-05-26 21:35:09 UTC (rev 8014) +++ trunk/src/app/net/sf/gridarta/utils/NumberUtils.java 2010-05-26 21:45:52 UTC (rev 8015) @@ -49,6 +49,10 @@ * @return the integer value or the default value if value not readable */ public static int parseInt(@NotNull final String s, final int defaultValue) { + if (s.isEmpty()) { + return defaultValue; + } + try { return Integer.parseInt(s); } catch (final NumberFormatException ignored) { @@ -62,6 +66,10 @@ * @return the long value or zero if value not readable */ public static long parseLong(@NotNull final String s) { + if (s.isEmpty()) { + return 0L; + } + try { return Long.parseLong(s); } catch (final NumberFormatException ignored) { @@ -75,6 +83,10 @@ * @return the double value or zero if value not readable */ public static double parseDouble(@NotNull final String s) { + if (s.isEmpty()) { + return 0.0; + } + try { return Double.parseDouble(s); } catch (final NumberFormatException ignored) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-26 21:35:16
|
Revision: 8014 http://gridarta.svn.sourceforge.net/gridarta/?rev=8014&view=rev Author: akirschbaum Date: 2010-05-26 21:35:09 +0000 (Wed, 26 May 2010) Log Message: ----------- Extract duplicated code into NumberUtils. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java trunk/src/app/net/sf/gridarta/gui/newmap/AbstractMapsizeNewMapDialog.java trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java trunk/src/app/net/sf/gridarta/model/archetypetype/AttributeBitmask.java trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java trunk/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java trunk/src/app/net/sf/gridarta/script/parameter/DoubleParameter.java trunk/src/app/net/sf/gridarta/utils/ActionBuilderUtils.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/utils/NumberUtils.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.Formatter; import net.sf.gridarta.model.io.AbstractMapArchObjectParser; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.var.atrinik.model.maparchobject.MapArchObject; import org.jetbrains.annotations.NotNull; @@ -129,72 +130,72 @@ @Override protected boolean parseLine(@NotNull final String line, @NotNull final MapArchObject mapArchObject) { if (line.startsWith("no_save ")) { - mapArchObject.setNoSave(parseInteger(line.substring(8)) != 0); + mapArchObject.setNoSave(NumberUtils.parseInt(line.substring(8)) != 0); return true; } if (line.startsWith("no_magic ")) { - mapArchObject.setNoMagic(parseInteger(line.substring(9)) != 0); + mapArchObject.setNoMagic(NumberUtils.parseInt(line.substring(9)) != 0); return true; } if (line.startsWith("no_priest ")) { - mapArchObject.setNoPriest(parseInteger(line.substring(10)) != 0); + mapArchObject.setNoPriest(NumberUtils.parseInt(line.substring(10)) != 0); return true; } if (line.startsWith("no_summon ")) { - mapArchObject.setNoSummon(parseInteger(line.substring(10)) != 0); + mapArchObject.setNoSummon(NumberUtils.parseInt(line.substring(10)) != 0); return true; } if (line.startsWith("no_harm ")) { - mapArchObject.setNoHarm(parseInteger(line.substring(8)) != 0); + mapArchObject.setNoHarm(NumberUtils.parseInt(line.substring(8)) != 0); return true; } if (line.startsWith("fixed_login ")) { - mapArchObject.setFixedLogin(parseInteger(line.substring(12)) != 0); + mapArchObject.setFixedLogin(NumberUtils.parseInt(line.substring(12)) != 0); return true; } if (line.startsWith("perm_death ")) { - mapArchObject.setPermDeath(parseInteger(line.substring(11)) != 0); + mapArchObject.setPermDeath(NumberUtils.parseInt(line.substring(11)) != 0); return true; } if (line.startsWith("ultra_death ")) { - mapArchObject.setUltraDeath(parseInteger(line.substring(12)) != 0); + mapArchObject.setUltraDeath(NumberUtils.parseInt(line.substring(12)) != 0); return true; } if (line.startsWith("ultimate_death ")) { - mapArchObject.setUltimateDeath(parseInteger(line.substring(15)) != 0); + mapArchObject.setUltimateDeath(NumberUtils.parseInt(line.substring(15)) != 0); return true; } if (line.startsWith("pvp ")) { - mapArchObject.setPvp(parseInteger(line.substring(4)) != 0); + mapArchObject.setPvp(NumberUtils.parseInt(line.substring(4)) != 0); return true; } if (line.startsWith("plugins ")) { - mapArchObject.setPlugins(parseInteger(line.substring(8)) != 0); + mapArchObject.setPlugins(NumberUtils.parseInt(line.substring(8)) != 0); return true; } if (line.startsWith("tileset_id ")) { - mapArchObject.setTilesetId(parseInteger(line.substring(11))); + mapArchObject.setTilesetId(NumberUtils.parseInt(line.substring(11))); return true; } if (line.startsWith("tileset_x ")) { - mapArchObject.setTilesetX(parseInteger(line.substring(10))); + mapArchObject.setTilesetX(NumberUtils.parseInt(line.substring(10))); return true; } if (line.startsWith("tileset_y ")) { - mapArchObject.setTilesetY(parseInteger(line.substring(10))); + mapArchObject.setTilesetY(NumberUtils.parseInt(line.substring(10))); return true; } Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -23,6 +23,7 @@ import java.io.IOException; import java.util.Formatter; import net.sf.gridarta.model.io.AbstractMapArchObjectParser; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.var.crossfire.model.maparchobject.MapArchObject; import org.jetbrains.annotations.NotNull; @@ -170,17 +171,17 @@ } if (line.startsWith("unique ")) { - mapArchObject.setUnique(parseInteger(line.substring(7)) != 0); + mapArchObject.setUnique(NumberUtils.parseInt(line.substring(7)) != 0); return true; } if (line.startsWith("template ")) { - mapArchObject.setTemplate(parseInteger(line.substring(9)) != 0); + mapArchObject.setTemplate(NumberUtils.parseInt(line.substring(9)) != 0); return true; } if (line.startsWith("nosmooth ")) { - mapArchObject.setNosmooth(parseInteger(line.substring(9)) != 0); + mapArchObject.setNosmooth(NumberUtils.parseInt(line.substring(9)) != 0); return true; } @@ -195,47 +196,47 @@ } if (line.startsWith("shopmin ")) { - mapArchObject.setShopMin(parseInteger(line.substring(8))); + mapArchObject.setShopMin(NumberUtils.parseInt(line.substring(8))); return true; } if (line.startsWith("shopmax ")) { - mapArchObject.setShopMax(parseInteger(line.substring(8))); + mapArchObject.setShopMax(NumberUtils.parseInt(line.substring(8))); return true; } if (line.startsWith("shopgreed ")) { - mapArchObject.setShopGreed(parseDouble(line.substring(10))); + mapArchObject.setShopGreed(NumberUtils.parseDouble(line.substring(10))); return true; } if (line.startsWith("temp ")) { - mapArchObject.setTemp(parseInteger(line.substring(5))); + mapArchObject.setTemp(NumberUtils.parseInt(line.substring(5))); return true; } if (line.startsWith("pressure ")) { - mapArchObject.setPressure(parseInteger(line.substring(9))); + mapArchObject.setPressure(NumberUtils.parseInt(line.substring(9))); return true; } if (line.startsWith("humid ")) { - mapArchObject.setHumid(parseInteger(line.substring(6))); + mapArchObject.setHumid(NumberUtils.parseInt(line.substring(6))); return true; } if (line.startsWith("windspeed ")) { - mapArchObject.setWindspeed(parseInteger(line.substring(10))); + mapArchObject.setWindspeed(NumberUtils.parseInt(line.substring(10))); return true; } if (line.startsWith("winddir ")) { - mapArchObject.setWinddir(parseInteger(line.substring(8))); + mapArchObject.setWinddir(NumberUtils.parseInt(line.substring(8))); return true; } if (line.startsWith("sky ")) { - mapArchObject.setSky(parseInteger(line.substring(4))); + mapArchObject.setSky(NumberUtils.parseInt(line.substring(4))); return true; } Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -22,6 +22,7 @@ import java.io.IOException; import java.util.Formatter; import net.sf.gridarta.model.io.AbstractMapArchObjectParser; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.var.daimonin.model.maparchobject.MapArchObject; import org.jetbrains.annotations.NotNull; @@ -126,67 +127,67 @@ @Override protected boolean parseLine(@NotNull final String line, @NotNull final MapArchObject mapArchObject) { if (line.startsWith("no_save ")) { - mapArchObject.setNoSave(parseInteger(line.substring(8)) != 0); + mapArchObject.setNoSave(NumberUtils.parseInt(line.substring(8)) != 0); return true; } if (line.startsWith("no_magic ")) { - mapArchObject.setNoMagic(parseInteger(line.substring(9)) != 0); + mapArchObject.setNoMagic(NumberUtils.parseInt(line.substring(9)) != 0); return true; } if (line.startsWith("no_priest ")) { - mapArchObject.setNoPriest(parseInteger(line.substring(10)) != 0); + mapArchObject.setNoPriest(NumberUtils.parseInt(line.substring(10)) != 0); return true; } if (line.startsWith("no_summon ")) { - mapArchObject.setNoSummon(parseInteger(line.substring(10)) != 0); + mapArchObject.setNoSummon(NumberUtils.parseInt(line.substring(10)) != 0); return true; } if (line.startsWith("no_harm ")) { - mapArchObject.setNoHarm(parseInteger(line.substring(8)) != 0); + mapArchObject.setNoHarm(NumberUtils.parseInt(line.substring(8)) != 0); return true; } if (line.startsWith("fixed_login ")) { - mapArchObject.setFixedLogin(parseInteger(line.substring(12)) != 0); + mapArchObject.setFixedLogin(NumberUtils.parseInt(line.substring(12)) != 0); return true; } if (line.startsWith("perm_death ")) { - mapArchObject.setPermDeath(parseInteger(line.substring(11)) != 0); + mapArchObject.setPermDeath(NumberUtils.parseInt(line.substring(11)) != 0); return true; } if (line.startsWith("ultra_death ")) { - mapArchObject.setUltraDeath(parseInteger(line.substring(12)) != 0); + mapArchObject.setUltraDeath(NumberUtils.parseInt(line.substring(12)) != 0); return true; } if (line.startsWith("ultimate_death ")) { - mapArchObject.setUltimateDeath(parseInteger(line.substring(15)) != 0); + mapArchObject.setUltimateDeath(NumberUtils.parseInt(line.substring(15)) != 0); return true; } if (line.startsWith("pvp ")) { - mapArchObject.setPvp(parseInteger(line.substring(4)) != 0); + mapArchObject.setPvp(NumberUtils.parseInt(line.substring(4)) != 0); return true; } if (line.startsWith("tileset_id ")) { - mapArchObject.setTilesetId(parseInteger(line.substring(11))); + mapArchObject.setTilesetId(NumberUtils.parseInt(line.substring(11))); return true; } if (line.startsWith("tileset_x ")) { - mapArchObject.setTilesetX(parseInteger(line.substring(10))); + mapArchObject.setTilesetX(NumberUtils.parseInt(line.substring(10))); return true; } if (line.startsWith("tileset_y ")) { - mapArchObject.setTilesetY(parseInteger(line.substring(10))); + mapArchObject.setTilesetY(NumberUtils.parseInt(line.substring(10))); return true; } Modified: trunk/src/app/net/sf/gridarta/gui/newmap/AbstractMapsizeNewMapDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/AbstractMapsizeNewMapDialog.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/gui/newmap/AbstractMapsizeNewMapDialog.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -28,6 +28,7 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.utils.Size2D; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -240,17 +241,9 @@ */ private int getMapWidth() { final String text = mapWidthField.getText(); - final int width; - try { - width = Integer.parseInt(text); - } catch (final NumberFormatException ignored) { - return -1; - } - if (width < 1) { - return -1; - } + final int width = NumberUtils.parseInt(text); + return width < 1 ? -1 : width; - return width; } /** @@ -259,17 +252,9 @@ */ private int getMapHeight() { final String text = mapHeightField.getText(); - final int height; - try { - height = Integer.parseInt(text); - } catch (final NumberFormatException ignored) { - return -1; - } - if (height < 1) { - return -1; - } + final int height = NumberUtils.parseInt(text); + return height < 1 ? -1 : height; - return height; } } // class AbstractMapsizeNewMapDialog Modified: trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/gui/newmap/NewMapDialog.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -31,6 +31,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.maparchobject.MapArchObjectFactory; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.utils.Size2D; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -217,12 +218,7 @@ */ private int getDifficulty() { final String text = mapDifficultyField.getText(); - final int difficulty; - try { - difficulty = Integer.parseInt(text); - } catch (final NumberFormatException ignored) { - return -1; - } + final int difficulty = NumberUtils.parseInt(text); return difficulty >= 1 ? difficulty : -1; } Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -69,6 +69,7 @@ import net.sf.gridarta.utils.ActionUtils; import net.sf.gridarta.utils.Exiter; import net.sf.gridarta.utils.ExiterListener; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.utils.Size2D; import net.sf.gridarta.validation.DelegatingMapValidator; import net.sf.japi.swing.action.ActionBuilder; @@ -1543,12 +1544,7 @@ return -1; } - int rand; - try { - rand = Integer.parseInt(input); - } catch (final NumberFormatException ignored) { - rand = -1; - } + final int rand = NumberUtils.parseInt(input); if (rand < 1 || rand > 100) { JOptionPane.showMessageDialog(parent, "The fill density must be between 1-100.", "Illegal Value.", JOptionPane.ERROR_MESSAGE); } else { Modified: trunk/src/app/net/sf/gridarta/model/archetypetype/AttributeBitmask.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/archetypetype/AttributeBitmask.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/model/archetypetype/AttributeBitmask.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -25,6 +25,7 @@ import java.util.List; import java.util.Map; import java.util.regex.Pattern; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.utils.WrappingStringBuilder; import org.apache.log4j.Category; import org.apache.log4j.Logger; @@ -199,11 +200,7 @@ */ public int decodeValue(@NotNull final String encodedValue) { if (!isNamed) { - try { - return Integer.parseInt(encodedValue); - } catch (final NumberFormatException ignored) { - return 0; - } + return NumberUtils.parseInt(encodedValue); } if (encodedValue.length() == 0) { Modified: trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -29,6 +29,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.MultiArchData; import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.utils.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -295,18 +296,7 @@ */ @Override public int getAttributeInt(@NotNull final String attributeName, final boolean queryArchetype) { - final String str = getAttributeString(attributeName, queryArchetype); - if (str.length() <= 0) { - return 0; - } - - try { - return Integer.parseInt(str); - } catch (final NumberFormatException ignore) { - // ignore - } - - return 0; + return NumberUtils.parseInt(getAttributeString(attributeName, queryArchetype)); } /** @@ -322,13 +312,7 @@ */ @Override public long getAttributeLong(@NotNull final String attributeName, final boolean queryArchetype) { - long result = 0L; - try { - result = Long.parseLong(getAttributeString(attributeName, queryArchetype)); - } catch (final NumberFormatException ignore) { - // ignore - } - return result; + return NumberUtils.parseLong(getAttributeString(attributeName, queryArchetype)); } /** @@ -344,13 +328,7 @@ */ @Override public double getAttributeDouble(@NotNull final String attributeName, final boolean queryArchetype) { - double result = 0.0; - try { - result = Double.parseDouble(getAttributeString(attributeName, queryArchetype)); - } catch (final NumberFormatException ignore) { - // ignore - } - return result; + return NumberUtils.parseDouble(getAttributeString(attributeName, queryArchetype)); } /** Modified: trunk/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -22,6 +22,7 @@ import java.io.BufferedReader; import java.io.IOException; import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; @@ -77,27 +78,27 @@ } else if (line.startsWith("name ")) { mapArchObject.setMapName(line.substring(5)); } else if (line.startsWith("width ")) { - width = parseInteger(line.substring(6)); + width = NumberUtils.parseInt(line.substring(6)); } else if (line.startsWith("height ")) { - height = parseInteger(line.substring(7)); + height = NumberUtils.parseInt(line.substring(7)); } else if (line.startsWith("enter_x ")) { - mapArchObject.setEnterX(parseInteger(line.substring(8))); + mapArchObject.setEnterX(NumberUtils.parseInt(line.substring(8))); } else if (line.startsWith("enter_y ")) { - mapArchObject.setEnterY(parseInteger(line.substring(8))); + mapArchObject.setEnterY(NumberUtils.parseInt(line.substring(8))); } else if (line.startsWith("reset_timeout ")) { - mapArchObject.setResetTimeout(parseInteger(line.substring(14))); + mapArchObject.setResetTimeout(NumberUtils.parseInt(line.substring(14))); } else if (line.startsWith("swap_time ")) { - mapArchObject.setSwapTime(parseInteger(line.substring(10))); + mapArchObject.setSwapTime(NumberUtils.parseInt(line.substring(10))); } else if (line.startsWith("difficulty ")) { - mapArchObject.setDifficulty(parseInteger(line.substring(11))); + mapArchObject.setDifficulty(NumberUtils.parseInt(line.substring(11))); } else if (line.startsWith("darkness ")) { - mapArchObject.setDarkness(parseInteger(line.substring(9))); + mapArchObject.setDarkness(NumberUtils.parseInt(line.substring(9))); } else if (line.startsWith("fixed_resettime ")) { - if (parseInteger(line.substring(16)) != 0) { + if (NumberUtils.parseInt(line.substring(16)) != 0) { mapArchObject.setFixedReset(true); } } else if (line.startsWith("outdoor ")) { - if (parseInteger(line.substring(8)) != 0) { + if (NumberUtils.parseInt(line.substring(8)) != 0) { mapArchObject.setOutdoor(true); } } else if (line.startsWith("tile_path_")) { @@ -130,32 +131,6 @@ } /** - * Parse an integer string. - * @param s The string to parse. - * @return The integer value, or zero if value not readable. - */ - protected static int parseInteger(@NotNull final String s) { - try { - return Integer.parseInt(s); - } catch (final NumberFormatException ignored) { - return 0; - } - } - - /** - * Parse a double string. - * @param s The string to parse. - * @return The double value, or zero if value not readable. - */ - protected static double parseDouble(@NotNull final String s) { - try { - return Double.parseDouble(s); - } catch (final NumberFormatException ignored) { - return 0.0; - } - } - - /** * Parse a line for this editor type. * @param line The line to parse. * @param mapArchObject The map arch object to update. Modified: trunk/src/app/net/sf/gridarta/script/parameter/DoubleParameter.java =================================================================== --- trunk/src/app/net/sf/gridarta/script/parameter/DoubleParameter.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/script/parameter/DoubleParameter.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -22,6 +22,7 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.utils.NumberUtils; import org.jdom.Element; import org.jetbrains.annotations.NotNull; @@ -42,12 +43,7 @@ public void fromXML(@NotNull final Element e) { super.fromXML(e); final String val = e.getChildText("value"); - try { - final Double iVal = Double.parseDouble(val); - setValue(iVal); - } catch (final NumberFormatException ignored) { - setValue(0.0); - } + setValue(NumberUtils.parseDouble(val)); final DoubleConfig o = new DoubleConfig(); try { o.setMin(Double.parseDouble(e.getChildTextTrim("minimum"))); Modified: trunk/src/app/net/sf/gridarta/utils/ActionBuilderUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/utils/ActionBuilderUtils.java 2010-05-26 21:34:40 UTC (rev 8013) +++ trunk/src/app/net/sf/gridarta/utils/ActionBuilderUtils.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -58,11 +58,7 @@ return defaultValue; } - try { - return Integer.parseInt(value); - } catch (final NumberFormatException ignored) { - return defaultValue; - } + return NumberUtils.parseInt(value, defaultValue); } /** Added: trunk/src/app/net/sf/gridarta/utils/NumberUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/utils/NumberUtils.java (rev 0) +++ trunk/src/app/net/sf/gridarta/utils/NumberUtils.java 2010-05-26 21:35:09 UTC (rev 8014) @@ -0,0 +1,85 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.utils; + +import org.jetbrains.annotations.NotNull; + +/** + * Utility class for parsing strings into numbers. + * @author Andreas Kirschbaum + */ +public class NumberUtils { + + /** + * Private constructor to prevent instantiation. + */ + private NumberUtils() { + } + + /** + * Parses an integer string. + * @param s the string to parse + * @return the integer value or zero if value not readable + */ + public static int parseInt(@NotNull final String s) { + return parseInt(s, 0); + } + + /** + * Parses an integer string. + * @param s the string to parse + * @param defaultValue the default value + * @return the integer value or the default value if value not readable + */ + public static int parseInt(@NotNull final String s, final int defaultValue) { + try { + return Integer.parseInt(s); + } catch (final NumberFormatException ignored) { + return defaultValue; + } + } + + /** + * Parses a long string. + * @param s the string to parse + * @return the long value or zero if value not readable + */ + public static long parseLong(@NotNull final String s) { + try { + return Long.parseLong(s); + } catch (final NumberFormatException ignored) { + return 0L; + } + } + + /** + * Parses a double string. + * @param s the string to parse + * @return the double value or zero if value not readable + */ + public static double parseDouble(@NotNull final String s) { + try { + return Double.parseDouble(s); + } catch (final NumberFormatException ignored) { + return 0.0; + } + } + +} // class NumberUtils Property changes on: trunk/src/app/net/sf/gridarta/utils/NumberUtils.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-26 21:34:46
|
Revision: 8013 http://gridarta.svn.sourceforge.net/gridarta/?rev=8013&view=rev Author: akirschbaum Date: 2010-05-26 21:34:40 +0000 (Wed, 26 May 2010) Log Message: ----------- Suppress incorrect warning. Modified Paths: -------------- trunk/gridarta.ipr Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2010-05-26 21:10:35 UTC (rev 8012) +++ trunk/gridarta.ipr 2010-05-26 21:34:40 UTC (rev 8013) @@ -374,7 +374,7 @@ <option name="IGNORE_DEPRECATED" value="true" /> <option name="IGNORE_JAVADOC_PERIOD" value="false" /> <option name="IGNORE_DUPLICATED_THROWS" value="false" /> - <option name="myAdditionalJavadocTags" value="fixme invariant note retval todo val warning" /> + <option name="myAdditionalJavadocTags" value="default fixme invariant note retval todo val warning" /> </inspection_tool> <inspection_tool class="JavaLangImport" enabled="true" level="WARNING" enabled_by_default="true" /> <inspection_tool class="LengthOneStringInIndexOf" enabled="true" level="WARNING" enabled_by_default="true" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-26 21:10:42
|
Revision: 8012 http://gridarta.svn.sourceforge.net/gridarta/?rev=8012&view=rev Author: akirschbaum Date: 2010-05-26 21:10:35 +0000 (Wed, 26 May 2010) Log Message: ----------- Extract duplicated code into function. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java Modified: trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2010-05-26 20:48:36 UTC (rev 8011) +++ trunk/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2010-05-26 21:10:35 UTC (rev 8012) @@ -422,12 +422,7 @@ protected void updateArchetype() { beginGameObjectChange(); try { - direction = getAttributeInt(DIRECTION); - setFaceName(getAttributeString(FACE)); - setAnimName(getAttributeString(ANIMATION)); - setTypeNo(getAttributeInt(TYPE)); - setObjName(getAttributeString(NAME)); - setObjectFace(); + updateCachedAttributes(); if (multi != null) { final int multiShapeID = getArchetype().getMultiShapeID(); assert multi != null; @@ -782,12 +777,7 @@ beginGameObjectChange(); try { gameObjectText.addObjectText(line); - direction = getAttributeInt(DIRECTION); - setFaceName(getAttributeString(FACE)); - setAnimName(getAttributeString(ANIMATION)); - setTypeNo(getAttributeInt(TYPE)); - setObjName(getAttributeString(NAME)); - setObjectFace(); + updateCachedAttributes(); } finally { endGameObjectChange(); } @@ -805,12 +795,7 @@ beginGameObjectChange(); try { gameObjectText.setObjectText(objectText); - direction = getAttributeInt(DIRECTION); - setFaceName(getAttributeString(FACE)); - setAnimName(getAttributeString(ANIMATION)); - setTypeNo(getAttributeInt(TYPE)); - setObjName(getAttributeString(NAME)); - setObjectFace(); + updateCachedAttributes(); } finally { endGameObjectChange(); } @@ -1091,4 +1076,17 @@ @NotNull protected abstract T getThis(); + /** + * Updates attribute values that are cached. This function is called + * whenever the object text has changed. + */ + private void updateCachedAttributes() { + direction = getAttributeInt(DIRECTION); + setFaceName(getAttributeString(FACE)); + setAnimName(getAttributeString(ANIMATION)); + setTypeNo(getAttributeInt(TYPE)); + setObjName(getAttributeString(NAME)); + setObjectFace(); + } + } // interface GameObject This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-05-26 20:48:43
|
Revision: 8011 http://gridarta.svn.sourceforge.net/gridarta/?rev=8011&view=rev Author: akirschbaum Date: 2010-05-26 20:48:36 +0000 (Wed, 26 May 2010) Log Message: ----------- Retain customized attributes when replacing with multi-part game objects from pickmaps. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/replacedialog/ReplaceDialog.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-05-26 20:42:15 UTC (rev 8010) +++ trunk/atrinik/ChangeLog 2010-05-26 20:48:36 UTC (rev 8011) @@ -1,5 +1,8 @@ 2010-05-26 Andreas Kirschbaum + * Retain customized attributes when replacing with multi-part game + objects from pickmaps. + * Make sure the updater dialogs are displayed in front of the main window. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-05-26 20:42:15 UTC (rev 8010) +++ trunk/crossfire/ChangeLog 2010-05-26 20:48:36 UTC (rev 8011) @@ -1,5 +1,8 @@ 2010-05-26 Andreas Kirschbaum + * Retain customized attributes when replacing with multi-part game + objects from pickmaps. + * Make sure the updater dialogs are displayed in front of the main window. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-05-26 20:42:15 UTC (rev 8010) +++ trunk/daimonin/ChangeLog 2010-05-26 20:48:36 UTC (rev 8011) @@ -1,5 +1,8 @@ 2010-05-26 Andreas Kirschbaum + * Retain customized attributes when replacing with multi-part game + objects from pickmaps. + * Make sure the updater dialogs are displayed in front of the main window. Modified: trunk/src/app/net/sf/gridarta/gui/replacedialog/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/replacedialog/ReplaceDialog.java 2010-05-26 20:42:15 UTC (rev 8010) +++ trunk/src/app/net/sf/gridarta/gui/replacedialog/ReplaceDialog.java 2010-05-26 20:48:36 UTC (rev 8011) @@ -493,10 +493,7 @@ } // insert replacement object if (randomArch.isMulti()) { - // multi's cannot be inserted properly, so we just put them ontop - mapModel.insertBaseObject(randomArch.getArchetype(), new Point(square.getMapX(), square.getMapY()), false, false, insertionModeSet.getTopmostInsertionMode()); - - // TODO: if from pickmap it could have special attributes -> copy them + mapModel.insertBaseObject(randomArch, new Point(square.getMapX(), square.getMapY()), false, false, insertionModeSet.getTopmostInsertionMode()); } else { mapModel.insertArchToMap(randomArch, prevArch, new Point(square.getMapX(), square.getMapY()), false); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |