From: <aki...@us...> - 2008-07-07 06:58:51
|
Revision: 4250 http://gridarta.svn.sourceforge.net/gridarta/?rev=4250&view=rev Author: akirschbaum Date: 2008-07-06 23:40:46 -0700 (Sun, 06 Jul 2008) Log Message: ----------- Make loading of embedded crossfire.0 file work again. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-07-06 21:48:15 UTC (rev 4249) +++ trunk/crossfire/ChangeLog 2008-07-07 06:40:46 UTC (rev 4250) @@ -1,3 +1,7 @@ +2008-07-07 Andreas Kirschbaum + + * Make loading of embedded crossfire.0 file work again. + 2008-07-06 Andreas Kirschbaum * Replace some characters in auto-generated thumbnail and icon Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-07-06 21:48:15 UTC (rev 4249) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-07-07 06:40:46 UTC (rev 4250) @@ -20,6 +20,7 @@ package cfeditor.gameobject.face; import cfeditor.IGUIConstants; +import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; @@ -37,6 +38,7 @@ import net.sf.gridarta.gameobject.face.DuplicateFaceException; import net.sf.gridarta.gameobject.face.FaceObject; import net.sf.gridarta.gameobject.face.FaceObjectProviders; +import net.sf.gridarta.io.IOUtils; import net.sf.gridarta.utils.ArrayUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.misc.Progress; @@ -61,11 +63,12 @@ /** {@inheritDoc} */ public void loadFacesCollection(final File faceFile, final File treeFile) throws IOException, FileNotFoundException, DuplicateFaceException { - FaceObjectProviders.setNormal(new CollectedFaceProvider(faceFile)); - final String actualFilename = faceFile.toString(); + final File tmpFaceFile = makeTmpFaceFile(faceFile); + FaceObjectProviders.setNormal(new CollectedFaceProvider(tmpFaceFile)); + final String actualFilename = tmpFaceFile.toString(); final byte[] data; - final InputStream inputStream = new FileInputStream(faceFile); - final ByteArrayOutputStream bufOut = new ByteArrayOutputStream((int) faceFile.length()); + final InputStream inputStream = new FileInputStream(tmpFaceFile); + final ByteArrayOutputStream bufOut = new ByteArrayOutputStream((int) tmpFaceFile.length()); try { final byte[] buf = new byte[4096]; for (; ;) { @@ -145,6 +148,50 @@ } } + /** + * Returns a file that is a regular file on the file system. Returns the + * passed file if it is a regular file. Otherwise copies the passed file + * into a temporary regular file and returns the copy. + * @param faceFile the input file + * @return the output file which is a regular file on the file system + * @todo remove this method when CrossfireEditor does not anymore embed crossfire.0 + */ + private static File makeTmpFaceFile(final File faceFile) { + if (faceFile.exists()) { + return faceFile; + } + + final File tmpFaceFile; + try { + tmpFaceFile = File.createTempFile("gridarta", null); + tmpFaceFile.deleteOnExit(); + final BufferedInputStream inputStream = IOUtils.createStream(null, faceFile.getPath()); + try { + final FileOutputStream outputStream = new FileOutputStream(tmpFaceFile); + try { + final byte[] buf = new byte[65536]; + for (;;) { + final int len = inputStream.read(buf); + if (len == -1) { + break; + } + + outputStream.write(buf, 0, len); + } + } + finally { + outputStream.close(); + } + } + finally { + inputStream.close(); + } + } catch (final IOException ex) { + return faceFile; + } + return tmpFaceFile; + } + /** {@inheritDoc} */ @Override protected String getPngFile() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-15 19:14:17
|
Revision: 4342 http://gridarta.svn.sourceforge.net/gridarta/?rev=4342&view=rev Author: akirschbaum Date: 2008-07-15 12:13:03 -0700 (Tue, 15 Jul 2008) Log Message: ----------- Add tool selector. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/build.xml trunk/crossfire/src/cfeditor/gui/ObjectChooser.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-07-15 18:11:35 UTC (rev 4341) +++ trunk/crossfire/ChangeLog 2008-07-15 19:13:03 UTC (rev 4342) @@ -1,3 +1,7 @@ +2008-07-15 Andreas Kirschbaum + + * Add tool selector. + 2008-07-07 Andreas Kirschbaum * Make loading of embedded crossfire.0 file work again. Modified: trunk/crossfire/build.xml =================================================================== --- trunk/crossfire/build.xml 2008-07-15 18:11:35 UTC (rev 4341) +++ trunk/crossfire/build.xml 2008-07-15 19:13:03 UTC (rev 4342) @@ -134,6 +134,7 @@ <fileset dir="../src/app" excludes="**/*.java,**/package.html,**/overview.html" /> <fileset dir="../resource"> <include name="system/**"/> + <include name="toolbarButtonGraphics/**/*.*"/> </fileset> <zipfileset src="../lib/log4j-1.2.13.jar" /> <zipfileset src="${lib.dir}/jdom.jar" excludes="META-INF/**" /> Modified: trunk/crossfire/src/cfeditor/gui/ObjectChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ObjectChooser.java 2008-07-15 18:11:35 UTC (rev 4341) +++ trunk/crossfire/src/cfeditor/gui/ObjectChooser.java 2008-07-15 19:13:03 UTC (rev 4342) @@ -26,11 +26,13 @@ import cfeditor.map.MapArchObject; import java.awt.BorderLayout; import java.util.List; +import javax.swing.JSplitPane; import javax.swing.JTabbedPane; import javax.swing.SwingConstants; import net.sf.gridarta.MapManager; import net.sf.gridarta.gui.AbstractObjectChooser; import net.sf.gridarta.gui.ArchNPickChangeListener; +import net.sf.gridarta.gui.GSplitPane; import net.sf.gridarta.gui.ObjectChoiceDisplay; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserListener; @@ -109,7 +111,10 @@ // this listener informs the mainview which panel is active: archlist or pickmaps? archAndPickPane.addChangeListener(new ArchNPickChangeListener(this, archAndPickPane)); - add(archAndPickPane, BorderLayout.CENTER); + // TODO: introduce a tool registry + final JSplitPane splitPane = new GSplitPane(JSplitPane.VERTICAL_SPLIT, toolPalette, archAndPickPane); + splitPane.setContinuousLayout(true); + add(splitPane, BorderLayout.CENTER); add(objectChoiceDisplay, BorderLayout.SOUTH); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |