From: <aki...@us...> - 2008-10-19 08:05:14
|
Revision: 5561 http://gridarta.svn.sourceforge.net/gridarta/?rev=5561&view=rev Author: akirschbaum Date: 2008-10-19 08:05:04 +0000 (Sun, 19 Oct 2008) Log Message: ----------- Move ArchetypeSetLoader.addPNGFace() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties trunk/crossfire/src/cfeditor/messages_fr.properties trunk/crossfire/src/cfeditor/messages_sv.properties trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java trunk/daimonin/src/daieditor/messages.properties trunk/daimonin/src/daieditor/messages_de.properties trunk/daimonin/src/daieditor/messages_fr.properties trunk/daimonin/src/daieditor/messages_sv.properties trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_sv.properties Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-10-19 07:48:26 UTC (rev 5560) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-10-19 08:05:04 UTC (rev 5561) @@ -134,7 +134,7 @@ * @param throwableHandler the throwable handler to use */ public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final String configurationDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler) { - super(collectedDirectory, animationObjects, throwableHandler); + super(collectedDirectory, animationObjects, throwableHandler, faceObjects); this.globalSettings = globalSettings; this.gameObjectParser = gameObjectParser; this.collectedDirectory = collectedDirectory; @@ -286,31 +286,10 @@ } } - /** - * Load a png from the file, convert it to IconImage and attach it to the - * facelist. - * @param baseDir the base directory to strip from filenames - * @param filename filename, absolute path - * @param name name of the png (e.g. blocked.111.png) - * @param parent the parent component for error messages - */ - private void addPNGFace(@NotNull final File baseDir, final String filename, final String name, @NotNull final Component parent) { - final String facename = generateFaceName(name); - ((ArchFaceProvider) FaceObjectProviders.normal).addInfo(facename, filename); - final int stripPath = baseDir.getAbsolutePath().length(); - try { - faceObjects.addFaceObject(facename, filename.substring(stripPath, filename.length() - 4).replace('\\', '/'), filename, 0, (int) new File(filename).length()); - } catch (final DuplicateFaceException e) { - ACTION_FACTORY.showMessageDialog(parent, "loadDuplicateFace", e.getDuplicate().getFaceName(), e.getDuplicate().getOriginalFilename(), e.getExisting().getOriginalFilename()); - } - } - - /** - * Generate the facename for a face. - * @param name filename to generate facename from - * @return facename generated from <var>name</var> - */ - private String generateFaceName(final String name) { + /** {@inheritDoc} */ + @NotNull + @Override + protected String generateFaceName(@NotNull final String name) { if (archetypeSet.getImageSet() != null) { // we have to snip out the imageset-information here from // the 'name', and the ".png": (e.g. blocked.base.111.png -> blocked.111) Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2008-10-19 07:48:26 UTC (rev 5560) +++ trunk/crossfire/src/cfeditor/messages.properties 2008-10-19 08:05:04 UTC (rev 5561) @@ -30,8 +30,6 @@ ########## # Dialogs -loadDuplicateFace.title=Error: Duplicate face -loadDuplicateFace.message=Warning!\n\nDuplicate face: ''{0}''\nFiles: ''{1}''\nand ''{2}''\nI will ignore this duplicate. # Map Properties mapParametersTabTitle=Parameters Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2008-10-19 07:48:26 UTC (rev 5560) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2008-10-19 08:05:04 UTC (rev 5561) @@ -26,8 +26,6 @@ ########## # Dialogs -loadDuplicateFace.title=Fehler: doppelte Grafik -loadDuplicateFace.message=Warning!\n\nDopplete Grafik: ''{0}''\nDateien: ''{1}''\nund ''{2}''\nDie doppelte Grafik wird ignoriert. # Map Properties mapParametersTabTitle=Parameter Modified: trunk/crossfire/src/cfeditor/messages_fr.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_fr.properties 2008-10-19 07:48:26 UTC (rev 5560) +++ trunk/crossfire/src/cfeditor/messages_fr.properties 2008-10-19 08:05:04 UTC (rev 5561) @@ -27,8 +27,6 @@ ########## # Dialogs -#loadDuplicateFace.title= -#loadDuplicateFace.message= # Map Properties #mapParametersTabTitle= Modified: trunk/crossfire/src/cfeditor/messages_sv.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_sv.properties 2008-10-19 07:48:26 UTC (rev 5560) +++ trunk/crossfire/src/cfeditor/messages_sv.properties 2008-10-19 08:05:04 UTC (rev 5561) @@ -26,8 +26,6 @@ ########## # Dialogs -loadDuplicateFace.title=Fel: duplicerad bild -loadDuplicateFace.message=Varning!\n\nDuplicerad bild: ''{0}''\nFiler: ''{1}''\noch ''{2}''\nJag kommer att ignorera detta duplikat. # Map Properties #mapParametersTabTitle= Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-10-19 07:48:26 UTC (rev 5560) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-10-19 08:05:04 UTC (rev 5561) @@ -149,7 +149,7 @@ * @param throwableHandler the throwable handler to use */ public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final String configurationDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler) { - super(collectedDirectory, animationObjects, throwableHandler); + super(collectedDirectory, animationObjects, throwableHandler, faceObjects); this.globalSettings = globalSettings; this.gameObjectParser = gameObjectParser; this.collectedDirectory = collectedDirectory; @@ -397,31 +397,10 @@ } } - /** - * Load a png from the file, convert it to IconImage and attach it to the - * facelist. - * @param baseDir the base directory to strip from filenames - * @param filename filename, absolute path - * @param name name of the png (e.g. blocked.111.png) - * @param parent the parent component for error messages - */ - private void addPNGFace(@NotNull final File baseDir, final String filename, final String name, @NotNull final Component parent) { - final String facename = generateFaceName(name); - ((ArchFaceProvider) FaceObjectProviders.normal).addInfo(facename, filename); - final int stripPath = baseDir.getAbsolutePath().length(); - try { - faceObjects.addFaceObject(facename, filename.substring(stripPath, filename.length() - 4).replace('\\', '/'), filename, 0, (int) new File(filename).length()); - } catch (final DuplicateFaceException e) { - ACTION_FACTORY.showMessageDialog(parent, "loadDuplicateFace", e.getDuplicate().getFaceName(), e.getDuplicate().getOriginalFilename(), e.getExisting().getOriginalFilename()); - } - } - - /** - * Generate the facename for a face. - * @param name filename to generate facename from - * @return facename generated from <var>name</var> - */ - private static String generateFaceName(final String name) { + /** {@inheritDoc} */ + @NotNull + @Override + protected String generateFaceName(@NotNull final String name) { return name.substring(0, name.length() - 4); } Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2008-10-19 07:48:26 UTC (rev 5560) +++ trunk/daimonin/src/daieditor/messages.properties 2008-10-19 08:05:04 UTC (rev 5561) @@ -31,9 +31,6 @@ mapUnsaved.title=Map Not Saved mapUnsaved.message=Please save this map first. -loadDuplicateFace.title=Error: Duplicate face -loadDuplicateFace.message=Warning!\n\nDuplicate face: ''{0}''\nFiles: ''{1}''\nand ''{2}''\nI will ignore this duplicate. - # Map Properties mapMap=Map mapSound=Background sound Modified: trunk/daimonin/src/daieditor/messages_de.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_de.properties 2008-10-19 07:48:26 UTC (rev 5560) +++ trunk/daimonin/src/daieditor/messages_de.properties 2008-10-19 08:05:04 UTC (rev 5561) @@ -31,9 +31,6 @@ #mapUnsaved.title= #mapUnsaved.message= -loadDuplicateFace.title=Fehler: doppelte Grafik -loadDuplicateFace.message=Warning!\n\nDopplete Grafik: ''{0}''\nDateien: ''{1}''\nund ''{2}''\nDie doppelte Grafik wird ignoriert. - # Map Properties mapMap=Karte #mapSound= Modified: trunk/daimonin/src/daieditor/messages_fr.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_fr.properties 2008-10-19 07:48:26 UTC (rev 5560) +++ trunk/daimonin/src/daieditor/messages_fr.properties 2008-10-19 08:05:04 UTC (rev 5561) @@ -32,9 +32,6 @@ #mapUnsaved.title= #mapUnsaved.message= -#loadDuplicateFace.title= -#loadDuplicateFace.message= - # Map Properties #mapMap= #mapSound= Modified: trunk/daimonin/src/daieditor/messages_sv.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_sv.properties 2008-10-19 07:48:26 UTC (rev 5560) +++ trunk/daimonin/src/daieditor/messages_sv.properties 2008-10-19 08:05:04 UTC (rev 5561) @@ -31,9 +31,6 @@ mapUnsaved.title=Kartan har inte sparats. mapUnsaved.message=Var v\xE4nlig och spara den h\xE4r kartan f\xF6rst. -loadDuplicateFace.title=Fel: duplicerad bild -loadDuplicateFace.message=Varning!\n\nDuplicerad bild: ''{0}''\nFiler: ''{1}''\noch ''{2}''\nJag kommer att ignorera detta duplikat. - # Map Properties mapMap=Karta mapSound=Bakgrundsljud Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java 2008-10-19 07:48:26 UTC (rev 5560) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java 2008-10-19 08:05:04 UTC (rev 5561) @@ -19,6 +19,7 @@ package net.sf.gridarta.gameobject; +import java.awt.Component; import java.io.File; import java.io.IOException; import java.io.Reader; @@ -26,7 +27,12 @@ import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.anim.AnimationParseException; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; +import net.sf.gridarta.gameobject.face.ArchFaceProvider; +import net.sf.gridarta.gameobject.face.DuplicateFaceException; +import net.sf.gridarta.gameobject.face.FaceObjectProviders; +import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.utils.IOUtils; +import net.sf.japi.swing.ActionFactory; import net.sf.japi.util.ThrowableHandler; import org.jetbrains.annotations.NotNull; @@ -39,6 +45,9 @@ */ public abstract class AbstractArchetypeSetLoader { + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + /** * The collected directory. */ @@ -58,15 +67,23 @@ private final ThrowableHandler<Throwable> throwableHandler; /** + * The face objects instance. + */ + @NotNull + private final FaceObjects faceObjects; + + /** * Creates a new instance. * @param collectedDirectory the collected directory * @param animationObjects the animation objects instance * @param throwableHandler the throwable handler to use + * @param faceObjects the face ojects instance */ - protected AbstractArchetypeSetLoader(@NotNull final String collectedDirectory, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler) { + protected AbstractArchetypeSetLoader(@NotNull final String collectedDirectory, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler, @NotNull final FaceObjects faceObjects) { this.collectedDirectory = collectedDirectory; this.animationObjects = animationObjects; this.throwableHandler = throwableHandler; + this.faceObjects = faceObjects; } /** Loading all animations from the big collected animations file. */ @@ -88,4 +105,31 @@ } } + /** + * Load a png from the file, convert it to IconImage and attach it to the + * facelist. + * @param baseDir the base directory to strip from filenames + * @param filename filename, absolute path + * @param name name of the png (e.g. blocked.111.png) + * @param parent the parent component for error messages + */ + protected void addPNGFace(@NotNull final File baseDir, final String filename, final String name, @NotNull final Component parent) { + final String facename = generateFaceName(name); + ((ArchFaceProvider) FaceObjectProviders.normal).addInfo(facename, filename); + final int stripPath = baseDir.getAbsolutePath().length(); + try { + faceObjects.addFaceObject(facename, filename.substring(stripPath, filename.length() - 4).replace('\\', '/'), filename, 0, (int) new File(filename).length()); + } catch (final DuplicateFaceException e) { + ACTION_FACTORY.showMessageDialog(parent, "loadDuplicateFace", e.getDuplicate().getFaceName(), e.getDuplicate().getOriginalFilename(), e.getExisting().getOriginalFilename()); + } + } + + /** + * Generate the facename for a face. + * @param name filename to generate facename from + * @return facename generated from <var>name</var> + */ + @NotNull + protected abstract String generateFaceName(@NotNull final String name); + } // class AbstractArchetypeSetLoader Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-10-19 07:48:26 UTC (rev 5560) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-10-19 08:05:04 UTC (rev 5561) @@ -382,6 +382,9 @@ loadDuplicateArch.message.2.title.2=File loadDuplicateArch.message.3=I will ignore these duplicates. +loadDuplicateFace.title=Error: Duplicate face +loadDuplicateFace.message=Warning!\n\nDuplicate face: ''{0}''\nFiles: ''{1}''\nand ''{2}''\nI will ignore this duplicate. + # Map Properties mapTitle={0} ({1}) - Map Properties mapHelp.text=Help Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-10-19 07:48:26 UTC (rev 5560) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-10-19 08:05:04 UTC (rev 5561) @@ -365,6 +365,9 @@ loadDuplicateArch.message.2.title.2=Datei loadDuplicateArch.message.3=Diese Archetypen werden ignoriert. +loadDuplicateFace.title=Fehler: doppelte Grafik +loadDuplicateFace.message=Warning!\n\nDopplete Grafik: ''{0}''\nDateien: ''{1}''\nund ''{2}''\nDie doppelte Grafik wird ignoriert. + # Map Properties mapTitle={0} ({1}) - Karteneigenschaften mapHelp.text=Hilfe Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-10-19 07:48:26 UTC (rev 5560) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-10-19 08:05:04 UTC (rev 5561) @@ -364,6 +364,9 @@ #loadDuplicateArch.message.2.title.2= #loadDuplicateArch.message.3= +#loadDuplicateFace.title= +#loadDuplicateFace.message= + # Map Properties mapTitle={0} ({1}) - Propri\xE9t\xE9s de la carte #mapHelp.text= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-10-19 07:48:26 UTC (rev 5560) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-10-19 08:05:04 UTC (rev 5561) @@ -368,6 +368,9 @@ loadDuplicateArch.message.2.title.2=Fil loadDuplicateArch.message.3=Jag kommer att ignorera detta duplikat. +loadDuplicateFace.title=Fel: duplicerad bild +loadDuplicateFace.message=Varning!\n\nDuplicerad bild: ''{0}''\nFiler: ''{1}''\noch ''{2}''\nJag kommer att ignorera detta duplikat. + # Map Properties mapTitle={0} ({1}) - Kartegenskaper mapHelp.text=Hj\xE4lp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |