From: <aki...@us...> - 2008-11-01 05:54:29
|
Revision: 5621 http://gridarta.svn.sourceforge.net/gridarta/?rev=5621&view=rev Author: akirschbaum Date: 2008-11-01 05:54:22 +0000 (Sat, 01 Nov 2008) Log Message: ----------- Remove dependency to archetype directory from collection code; fixes issues with implicitly generated animation names. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-01 05:33:11 UTC (rev 5620) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-11-01 05:54:22 UTC (rev 5621) @@ -162,7 +162,7 @@ archetypeSet.setLoadedFromArchive(false); // don't load from the collected files fname = globalSettings.getArchDirectory(); final File dir = new File(fname); - loadArchetypesFromFiles(archetypeParser, dir, null, dir, 0, "default", "default", false, invObjects, parent); // load arches & images from individual files + loadArchetypesFromFiles(archetypeParser, null, dir, 0, "default", "default", false, invObjects, parent); // load arches & images from individual files } archetypeSet.reportErrors(parent); @@ -219,7 +219,6 @@ * Loads all archetypes and faces by recursing through the * <code>arch/</code> directory tree. * @param archetypeParser the archetype parser to use - * @param baseDir the base directory to strip from filenames * @param path the base directory relative path of <code>f</code> * @param f file path where we currently are * @param folderLevel level of the folder @@ -230,7 +229,7 @@ * @param invObjects collects all inventory objects * @param parent the parent component for error messages */ - private void loadArchetypesFromFiles(@NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final File baseDir, @Nullable final String path, @NotNull final File f, final int folderLevel, @NotNull final String panelName, @NotNull final String folderName, final boolean noPanel, @NotNull final List<GameObject> invObjects, @NotNull final Component parent) { + private void loadArchetypesFromFiles(@NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @Nullable final String path, @NotNull final File f, final int folderLevel, @NotNull final String panelName, @NotNull final String folderName, final boolean noPanel, @NotNull final List<GameObject> invObjects, @NotNull final Component parent) { final String name = f.getName(); if (f.isDirectory()) { // now, setup the arch panels @@ -242,7 +241,7 @@ final String thisFolderName = folderLevel == 1 || folderLevel == 2 ? name : folderName; final String newPath = path == null ? "" : path + "/" + name; for (final String entry : entries) { - loadArchetypesFromFiles(archetypeParser, baseDir, newPath, new File(f, entry), folderLevel + 1, thisPanelName, thisFolderName, false, invObjects, parent); + loadArchetypesFromFiles(archetypeParser, newPath, new File(f, entry), folderLevel + 1, thisPanelName, thisFolderName, false, invObjects, parent); } } else { log.warn("Cannot read directory: " + f); @@ -254,7 +253,7 @@ archetypeParser.parseArchetype(f.getPath(), panelName, folderName, invObjects); } else if (name.endsWith(".png")) { if (archetypeSet.getImageSet() == null || name.contains("." + archetypeSet.getImageSet() + ".")) { - addPNGFace(baseDir, f.getAbsolutePath(), name, parent); + addPNGFace(f.getAbsolutePath(), path, name, parent); } } else if (name.endsWith(".face")) { parseDefFace(f.getAbsolutePath(), path); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-01 05:33:11 UTC (rev 5620) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-11-01 05:54:22 UTC (rev 5621) @@ -179,8 +179,8 @@ animFiles = new ArrayList<Pair<String, File>>(); fname = globalSettings.getArchDirectory(); final File dir = new File(fname); - addPNGFace(dir, new File(dir, "dev/editor/bug.101.png").getAbsolutePath(), "bug.101.png", parent); - loadArchetypesFromFiles(archetypeParser, dir, null, dir, 0, "default", "default", false, invObjects, parent); // load arches & images from individual files + addPNGFace(new File(dir, "dev/editor/bug.101.png").getAbsolutePath(), "/dev/editor", "bug.101.png", parent); + loadArchetypesFromFiles(archetypeParser, null, dir, 0, "default", "default", false, invObjects, parent); // load arches & images from individual files loadAnimsFromFiles(); } archetypeSet.reportErrors(parent); @@ -237,7 +237,6 @@ * Loads all archetypes and faces by recursing through the * <code>arch/</code> directory tree. * @param archetypeParser the archetype parser to use - * @param baseDir the base directory to strip from filenames * @param path the base directory relative path for <code>f</code> * @param f file path where we currently are * @param folderLevel level of the folder @@ -248,7 +247,7 @@ * @param invObjects collects all inventory objects * @param parent the parent component for error messages */ - private void loadArchetypesFromFiles(@NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final File baseDir, @Nullable final String path, final File f, final int folderLevel, @Nullable final String panelName, @NotNull final String folderName, final boolean noPanel, @NotNull final List<GameObject> invObjects, @NotNull final Component parent) { + private void loadArchetypesFromFiles(@NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @Nullable final String path, final File f, final int folderLevel, @Nullable final String panelName, @NotNull final String folderName, final boolean noPanel, @NotNull final List<GameObject> invObjects, @NotNull final Component parent) { final String name = f.getName(); if (f.isDirectory()) { // now, setup the arch panels @@ -260,7 +259,7 @@ final String thisFolderName = folderLevel == 1 || folderLevel == 2 ? name : folderName; final String newPath = path == null ? "" : path + "/" + name; for (final String entry : entries) { - loadArchetypesFromFiles(archetypeParser, baseDir, newPath, new File(f, entry), folderLevel + 1, thisPanelName, thisFolderName, noPanel || name.equalsIgnoreCase("intern"), invObjects, parent); + loadArchetypesFromFiles(archetypeParser, newPath, new File(f, entry), folderLevel + 1, thisPanelName, thisFolderName, noPanel || name.equalsIgnoreCase("intern"), invObjects, parent); } } else { log.warn("Cannot read directory: " + f); @@ -271,7 +270,7 @@ archetypeSet.setCurrentFile(f); archetypeParser.parseArchetype(f.getPath(), panelName, folderName, invObjects); } else if (name.endsWith(".png")) { - addPNGFace(baseDir, f.getAbsolutePath(), name, parent); + addPNGFace(f.getAbsolutePath(), path, name, parent); } else if (name.endsWith(".anim")) { animFiles.add(new Pair(path, f)); } Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java 2008-11-01 05:33:11 UTC (rev 5620) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSetLoader.java 2008-11-01 05:54:22 UTC (rev 5621) @@ -108,17 +108,16 @@ /** * 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 path the path name of <code>name</code> * @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) { + protected void addPNGFace(@NotNull final String filename, @NotNull final String path, @NotNull 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('\\', '/'), 0, (int) new File(filename).length()); + faceObjects.addFaceObject(facename, path + "/" + facename, 0, (int) new File(filename).length()); } catch (final DuplicateFaceException e) { ACTION_FACTORY.showMessageDialog(parent, "loadDuplicateFace", e.getDuplicate().getFaceName(), e.getDuplicate().getOriginalFilename(), e.getExisting().getOriginalFilename()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |