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: <chr...@us...> - 2006-11-12 18:08:05
|
Revision: 659 http://svn.sourceforge.net/gridarta/?rev=659&view=rev Author: christianhujer Date: 2006-11-12 10:07:57 -0800 (Sun, 12 Nov 2006) Log Message: ----------- Changed CommonConstants to be a class instead of an interface. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/CommonConstants.java Modified: trunk/src/app/net/sf/gridarta/CommonConstants.java =================================================================== --- trunk/src/app/net/sf/gridarta/CommonConstants.java 2006-11-12 12:46:34 UTC (rev 658) +++ trunk/src/app/net/sf/gridarta/CommonConstants.java 2006-11-12 18:07:57 UTC (rev 659) @@ -27,16 +27,21 @@ import static java.io.File.separator; /** - * Interface with constants used in Gridarta and derivates. + * Class with constants used in Gridarta and derivates. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @deprecated This uses the constant interface anti pattern */ -@Deprecated public interface CommonConstants { +public abstract class CommonConstants { /** The directory that contains all (html) help files. */ - String HELP_DIR = "resource" + separator + "HelpFiles"; + public static final String HELP_DIR = "resource" + separator + "HelpFiles"; /** Python menu definitions. */ - String PYTHONMENU_FILE = "cfpython_menu.def"; + public static final String PYTHONMENU_FILE = "cfpython_menu.def"; + /** + * Don't instanciate. + */ + private CommonConstants() { + } + } // interface CommonConstants This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-12 12:46:57
|
Revision: 658 http://svn.sourceforge.net/gridarta/?rev=658&view=rev Author: christianhujer Date: 2006-11-12 04:46:34 -0800 (Sun, 12 Nov 2006) Log Message: ----------- Made server data collection independent of ArchetypeSet and extracted it into a class of its own. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java Added Paths: ----------- trunk/daimonin/src/daieditor/gameobject/Collector.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-11-12 00:15:19 UTC (rev 657) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-11-12 12:46:34 UTC (rev 658) @@ -522,7 +522,9 @@ } } - /** {@inheritDoc} */ + /** + * Start collecting the Archetypes and other resource files to create an archive. + */ public void collectArchetypes() { collectCrossfireArchetypes(); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-11-12 00:15:19 UTC (rev 657) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-11-12 12:46:34 UTC (rev 658) @@ -31,6 +31,8 @@ import daieditor.gameobject.ArchetypeParser; import daieditor.gameobject.ArchetypeSet; import daieditor.gameobject.GameObject; +import daieditor.gameobject.Collectable; +import daieditor.gameobject.Collector; import daieditor.gameobject.anim.AnimationObjects; import daieditor.gameobject.face.FaceFacade; import daieditor.gameobject.face.FaceObjects; @@ -515,7 +517,15 @@ /** Collect CF arches, animations and faces. */ @ActionMethod public void collectArches() { - archetypeSet.collectArchetypes(); + final List<Collectable> collectables = new ArrayList<Collectable>(); + final Collector collector = new Collector(); + collectables.add(getArchetypeSet()); + collectables.add(getAnimationObjects()); + collectables.add(getFaceObjects()); + collector.setCollectables(collectables); + collector.setParent(getMainView()); + collector.setDestDir(new File(getArchDefaultFolder())); + collector.start(); } /** Collect Spells. */ Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-11-12 00:15:19 UTC (rev 657) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-11-12 12:46:34 UTC (rev 658) @@ -55,7 +55,6 @@ import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; import net.sf.japi.swing.Progress; -import net.sf.japi.swing.ProgressDisplay; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -72,9 +71,6 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); - /** Size of the image buffer. */ - private static final int IMAGE_BUFFER_SIZE = 50 * 1024; - private final CMainControl mainControl; private int folderLevel; @@ -124,7 +120,7 @@ //throw new DuplicateArchetypeException(data); } - /** load the arches */ + /** {@inheritDoc} */ public void loadArchetypes() { final long timeStart = System.currentTimeMillis(); setLoadStatus(LoadStatus.LOADING); // status: loading @@ -457,37 +453,10 @@ } } - /** {@inheritDoc} */ - public void collectArchetypes() { - new Thread(archCollector).start(); - } - - /** Thread code for collecting the arches. */ - private final Runnable archCollector = new Runnable() { - /* - * Collect the existing arches and create archive-files for editor use as - * well as the Daimonin server. The arches also get a special path variable - * included which is used in the editor to categorize the arches. - * <p/> - * Output is: "archetypes", "daimonin.0", "animations", "bmaps" - */ - /** {@inheritDoc} */ - public void run() { - final Progress pbar = new ProgressDisplay(mainControl.getMainView(), ""/*FIXME*/, getArchetypeCount(), ACTION_FACTORY.getString("archCollectArches")); - final File dir = new File(mainControl.getArchDefaultFolder()); - for (final Collectable collectable : new Collectable[] { ArchetypeSet.this, mainControl.getAnimationObjects(), mainControl.getFaceObjects() }) { - try { - collectable.collect(pbar, dir); - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", "arches, animations and animtree, images", e); - } - } - pbar.finished(); - mainControl.setStatusText(ACTION_FACTORY.getString("archCollectDone")); - } - }; // Runnable archCollector - - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * Collects the Archetypes. + */ public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { final File dfile = new File(dir, IGUIConstants.ARCH_FILE); // now open the output-stream Added: trunk/daimonin/src/daieditor/gameobject/Collector.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/Collector.java (rev 0) +++ trunk/daimonin/src/daieditor/gameobject/Collector.java 2006-11-12 12:46:34 UTC (rev 658) @@ -0,0 +1,90 @@ +package daieditor.gameobject; + +import java.util.List; +import java.util.ArrayList; +import java.util.Collection; +import java.io.File; +import java.io.IOException; +import javax.swing.JFrame; +import net.sf.japi.swing.Progress; +import net.sf.japi.swing.ProgressDisplay; +import net.sf.japi.swing.ActionFactory; + +/** + * A Collector is capable of iterating over a collection of {@link Collectable}s and collecting them in a separate Thread with a nice GUI. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class Collector implements Runnable { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); + + /** The Collectables. */ + private List<Collectable> collectables = new ArrayList<Collectable>(); + + /** The Component to show the progress dialog on. */ + private JFrame parent; + + /** The destination directory to write files to. */ + private File destDir; + + /** + * Create a Collector. + */ + public Collector() { + } + + /** + * Sets the Collectables to collect. + * @param collectables Collectables to collect. + */ + public void setCollectables(final Collection<Collectable> collectables) { + this.collectables.clear(); + this.collectables.addAll(collectables); + } + + /** + * Sets the parent component to show the progress dialog on. + * @param parent Parent component. + */ + public void setParent(final JFrame parent) { + this.parent = parent; + } + + /** + * Sets the destination directory to write files to. + * @param destDir Destination directory to write files to. + */ + public void setDestDir(final File destDir) { + this.destDir = destDir; + } + + /** + * Starts collecting. + */ + public void start() { + new Thread(this).start(); + } + + /* + * Collect the existing arches and create archive-files for editor use as + * well as the Daimonin server. The arches also get a special path variable + * included which is used in the editor to categorize the arches. + * <p/> + * Output is: "archetypes", "daimonin.0", "animations", "bmaps" + */ + /** {@inheritDoc} */ + public void run() { + final Progress progress = new ProgressDisplay(parent, ""/*FIXME*/, 0, ACTION_FACTORY.getString("archCollectArches")); + for (final Collectable collectable : collectables) { + try { + collectable.collect(progress, destDir); + } catch (final IOException e) { + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorIOException", "arches, animations and animtree, images", e); + } + } + progress.finished(); + //mainControl.setStatusText(ACTION_FACTORY.getString("archCollectDone")); + } + +} // class Collector Property changes on: trunk/daimonin/src/daieditor/gameobject/Collector.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2006-11-12 00:15:19 UTC (rev 657) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2006-11-12 12:46:34 UTC (rev 658) @@ -213,7 +213,12 @@ } } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * Collects the Animations. + * The animation data is written to "animations". + * The tree information for the editor is written to "animtree". + */ public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { final BufferedWriter animations = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, "animations")), IOUtils.MAP_ENCODING)); try { Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2006-11-12 00:15:19 UTC (rev 657) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2006-11-12 12:46:34 UTC (rev 658) @@ -195,6 +195,11 @@ /** * {@inheritDoc} + * Collects the faces. + * The graphics information is written to "daimonin.0". + * The meta information (offsets etc.) is written to "bmaps". + * The tree information for the editor is written to "facetree". + * <p /> * Theoretically it would also be possible to recode the images. * But the Java image encoder isn't as good as that of gimp in many cases (yet much better as the old visualtek's). * @todo I/O handling sucks here, this could be nicer. Modified: trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java 2006-11-12 00:15:19 UTC (rev 657) +++ trunk/src/app/net/sf/gridarta/gameobject/ArchetypeSet.java 2006-11-12 12:46:34 UTC (rev 658) @@ -47,12 +47,7 @@ */ void loadArchetypes(); - /** - * Start collecting the Archetypes and other resource files to create an archive. - */ - void collectArchetypes(); - /** * The load status of the ArchetypeSet. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-12 00:15:35
|
Revision: 657 http://svn.sourceforge.net/gridarta/?rev=657&view=rev Author: christianhujer Date: 2006-11-11 16:15:19 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Added missing final keywords at catch parameters. Modified Paths: -------------- trunk/crossfire/src/cfeditor/AutojoinList.java trunk/crossfire/src/cfeditor/CFArchTypeList.java trunk/crossfire/src/cfeditor/PluginParameterFactory.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/gui/ScriptManager.java trunk/crossfire/src/cfeditor/parameter/BooleanParameter.java trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java trunk/crossfire/src/cfeditor/parameter/IntegerParameter.java trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java Modified: trunk/crossfire/src/cfeditor/AutojoinList.java =================================================================== --- trunk/crossfire/src/cfeditor/AutojoinList.java 2006-11-12 00:10:18 UTC (rev 656) +++ trunk/crossfire/src/cfeditor/AutojoinList.java 2006-11-12 00:15:19 UTC (rev 657) @@ -167,12 +167,12 @@ } finally { stream.close(); } - } catch (FileNotFoundException e) { + } catch (final FileNotFoundException e) { if (log.isInfoEnabled()) { log.info("Autojoin definitions file '" + filename + "' not found."); } return false; - } catch (IOException e) { + } catch (final IOException e) { log.warn("Read error in file '" + filename + "'."); return false; } Modified: trunk/crossfire/src/cfeditor/CFArchTypeList.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-11-12 00:10:18 UTC (rev 656) +++ trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-11-12 00:15:19 UTC (rev 657) @@ -200,9 +200,9 @@ } finally { fread.close(); } - } catch (JDOMException e) { + } catch (final JDOMException e) { log.error("Parsing error in '" + IGUIConstants.TYPEDEF_FILE, e); - } catch (IOException e) { + } catch (final IOException e) { log.error("Cannot read file '" + IGUIConstants.TYPEDEF_FILE + "'!", e); } @@ -231,7 +231,7 @@ num = elem.getAttribute("value").getIntValue(); list.addElement(new Integer(num)); list.addElement(" " + elem.getAttribute("name").getValue().trim()); - } catch (DataConversionException e) { + } catch (final DataConversionException e) { log.warn("In '" + IGUIConstants.TYPEDEF_FILE + "', list " + root.getAttribute("name").getValue() + ": value '" + elem.getAttribute("value").getValue() + "' is not an integer."); } } @@ -336,7 +336,7 @@ spellNum[i] = spellElem.getAttribute("id").getIntValue(); spellName[i] = spellElem.getAttribute("name").getValue().trim(); i++; - } catch (DataConversionException de) { + } catch (final DataConversionException de) { log.error("in '" + IGUIConstants.SPELL_FILE + "': spell id '" + spellElem.getAttribute("id").getValue() + "' is not an integer."); } } @@ -356,9 +356,9 @@ } finally { reader.close(); } - } catch (JDOMException e) { + } catch (final JDOMException e) { log.error("Parsing error in '" + IGUIConstants.SPELL_FILE + "'", e); - } catch (IOException e) { + } catch (final IOException e) { log.error("Cannot read file '" + IGUIConstants.SPELL_FILE + "'!"); } } @@ -452,16 +452,16 @@ list.insertElementAt((counter + " " + name), list.size()); } } - } catch (FileNotFoundException e) { + } catch (final FileNotFoundException e) { log.error("File '" + spellfile.getAbsolutePath() + "' not found!"); - } catch (EOFException e) { + } catch (final EOFException e) { // end of file/spell struct reached try { fileReader.close(); bufferedReader.close(); - } catch (IOException ioe) { + } catch (final IOException ioe) { } - } catch (IOException e) { + } catch (final IOException e) { log.error("Cannot read file '" + spellfile.getAbsolutePath() + "'!"); } } @@ -515,7 +515,7 @@ bufferedWriter.close(); fileWriter.close(); return list.size(); - } catch (IOException e) { + } catch (final IOException e) { log.error("Cannot write file '" + dfile.getAbsolutePath() + "'!"); } } Modified: trunk/crossfire/src/cfeditor/PluginParameterFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/PluginParameterFactory.java 2006-11-12 00:10:18 UTC (rev 656) +++ trunk/crossfire/src/cfeditor/PluginParameterFactory.java 2006-11-12 00:15:19 UTC (rev 657) @@ -87,7 +87,7 @@ final PluginParameter p = c.newInstance(); p.fromXML(parameterNode); return p; - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); return null; } Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-11-12 00:10:18 UTC (rev 656) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-11-12 00:15:19 UTC (rev 657) @@ -512,7 +512,7 @@ if (line.length() > 0 && (test == null || c == '\n')) { result = result.concat(line + "\n"); } - } catch (StringIndexOutOfBoundsException e) { + } catch (final StringIndexOutOfBoundsException e) { } } @@ -867,7 +867,7 @@ // close streams sstream.close(); sread.close(); - } catch (IOException e) { + } catch (final IOException e) { log.error("in getSyntaxErrors: Cannot close StringReader", e); } Modified: trunk/crossfire/src/cfeditor/gui/ScriptManager.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ScriptManager.java 2006-11-12 00:10:18 UTC (rev 656) +++ trunk/crossfire/src/cfeditor/gui/ScriptManager.java 2006-11-12 00:15:19 UTC (rev 657) @@ -80,7 +80,7 @@ @Nullable public Object getElementAt(final int index) { try { return ctrl.getScript(index); - } catch (Exception e) { + } catch (final Exception e) { return null; } } Modified: trunk/crossfire/src/cfeditor/parameter/BooleanParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/BooleanParameter.java 2006-11-12 00:10:18 UTC (rev 656) +++ trunk/crossfire/src/cfeditor/parameter/BooleanParameter.java 2006-11-12 00:15:19 UTC (rev 657) @@ -62,7 +62,7 @@ try { final Boolean iVal = Boolean.valueOf(val); setValue(iVal); - } catch (Exception ex) { + } catch (final Exception ex) { setValue(new Boolean(false)); } ; Modified: trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java 2006-11-12 00:10:18 UTC (rev 656) +++ trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java 2006-11-12 00:15:19 UTC (rev 657) @@ -62,18 +62,18 @@ try { final Double iVal = new Double(Double.parseDouble(val)); setValue(iVal); - } catch (Exception ex) { + } catch (final Exception ex) { setValue(new Double(0)); } ; final DoubleConfig o = new DoubleConfig(); try { o.setMin(Double.parseDouble(e.getChildTextTrim("minimum"))); - } catch (Exception ex) { + } catch (final Exception ex) { } try { o.setMax(Double.parseDouble(e.getChildTextTrim("maximum"))); - } catch (Exception ex) { + } catch (final Exception ex) { } setConfig(o); } Modified: trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java 2006-11-12 00:10:18 UTC (rev 656) +++ trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java 2006-11-12 00:15:19 UTC (rev 657) @@ -98,13 +98,13 @@ value = new TooltipSpinner(mdl); try { value.setValue(param.getValue()); - } catch (Exception e) { + } catch (final Exception e) { } value.addChangeListener(new ChangeListener() { public void stateChanged(final ChangeEvent e) { try { parameter.setValue((Double) ((SpinnerNumberModel) value.getModel()).getNumber()); - } catch (Exception ex) { + } catch (final Exception ex) { ex.printStackTrace(); } } @@ -140,7 +140,7 @@ ((SpinnerNumberModel) value.getModel()).setMinimum(new Double(parameter.getMin())); ((SpinnerNumberModel) value.getModel()).setMaximum(new Double(parameter.getMax())); updateTooltip(); - } catch (Exception ex) { + } catch (final Exception ex) { JOptionPane.showMessageDialog(null, "Could not change Double configuration"); } } Modified: trunk/crossfire/src/cfeditor/parameter/IntegerParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/IntegerParameter.java 2006-11-12 00:10:18 UTC (rev 656) +++ trunk/crossfire/src/cfeditor/parameter/IntegerParameter.java 2006-11-12 00:15:19 UTC (rev 657) @@ -60,17 +60,17 @@ try { final Integer iVal = new Integer(Integer.parseInt(val)); setValue(iVal); - } catch (Exception ex) { + } catch (final Exception ex) { setValue(new Integer(0)); } final IntegerConfig o = new IntegerConfig(); try { o.setMin(Integer.parseInt(e.getChildTextTrim("minimum"))); - } catch (Exception ex) { + } catch (final Exception ex) { } try { o.setMax(Integer.parseInt(e.getChildTextTrim("maximum"))); - } catch (Exception ex) { + } catch (final Exception ex) { } setConfig(o); } Modified: trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java 2006-11-12 00:10:18 UTC (rev 656) +++ trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java 2006-11-12 00:15:19 UTC (rev 657) @@ -95,13 +95,13 @@ value = new TooltipSpinner(mdl); try { value.setValue(param.getValue()); - } catch (Exception e) { + } catch (final Exception e) { } value.addChangeListener(new ChangeListener() { public void stateChanged(final ChangeEvent e) { try { parameter.setValue((Integer) ((SpinnerNumberModel) value.getModel()).getNumber()); - } catch (Exception ex) { + } catch (final Exception ex) { ex.printStackTrace(); } } @@ -136,7 +136,7 @@ ((SpinnerNumberModel) value.getModel()).setMinimum(new Integer(parameter.getMin())); ((SpinnerNumberModel) value.getModel()).setMaximum(new Integer(parameter.getMax())); updateTooltip(); - } catch (Exception ex) { + } catch (final Exception ex) { JOptionPane.showMessageDialog(null, "Could not change integer configuration"); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-12 00:10:37
|
Revision: 656 http://svn.sourceforge.net/gridarta/?rev=656&view=rev Author: christianhujer Date: 2006-11-11 16:10:18 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Optimized imports. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/daimonin/src/daieditor/gameobject/Collectable.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java trunk/src/app/net/sf/gridarta/io/AbstractMapWriter.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-11-12 00:06:05 UTC (rev 655) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-11-12 00:10:18 UTC (rev 656) @@ -27,9 +27,9 @@ import cfeditor.filter.AttributeFilter; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; +import cfeditor.gui.MapView; import cfeditor.map.MapControl; import cfeditor.map.MapModel; -import cfeditor.gui.MapView; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-11-12 00:06:05 UTC (rev 655) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-11-12 00:10:18 UTC (rev 656) @@ -25,10 +25,10 @@ package cfeditor; import cfeditor.gameobject.GameObject; +import cfeditor.gui.MapView; import cfeditor.map.MapControl; import cfeditor.menu.MenuHelper; import cfeditor.menu.MenuManager; -import cfeditor.gui.MapView; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Point; Modified: trunk/daimonin/src/daieditor/gameobject/Collectable.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/Collectable.java 2006-11-12 00:06:05 UTC (rev 655) +++ trunk/daimonin/src/daieditor/gameobject/Collectable.java 2006-11-12 00:10:18 UTC (rev 656) @@ -1,8 +1,8 @@ package daieditor.gameobject; +import java.io.File; +import java.io.IOException; import net.sf.japi.swing.Progress; -import java.io.IOException; -import java.io.File; import org.jetbrains.annotations.NotNull; /** Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2006-11-12 00:06:05 UTC (rev 655) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2006-11-12 00:10:18 UTC (rev 656) @@ -23,28 +23,28 @@ import daieditor.CMainControl; import daieditor.IGUIConstants; +import daieditor.gameobject.Collectable; import daieditor.gameobject.NamedObjects; -import daieditor.gameobject.Collectable; +import daieditor.icons.ArchFaceProvider; import daieditor.icons.DaimoninFaceProvider; -import daieditor.icons.ArchFaceProvider; +import java.io.BufferedOutputStream; import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; -import java.io.BufferedWriter; -import java.io.FileOutputStream; -import java.io.BufferedOutputStream; -import java.io.FileWriter; -import java.io.DataOutputStream; import java.io.OutputStreamWriter; import java.util.logging.Level; import java.util.logging.Logger; +import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; import net.sf.japi.swing.Progress; -import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; /** Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2006-11-12 00:06:05 UTC (rev 655) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2006-11-12 00:10:18 UTC (rev 656) @@ -1,10 +1,10 @@ package net.sf.gridarta; +import java.util.Random; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gameobject.ArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeSet; import org.jetbrains.annotations.NotNull; -import java.util.Random; /** * This interface is only for unification. Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java 2006-11-12 00:06:05 UTC (rev 655) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java 2006-11-12 00:10:18 UTC (rev 656) @@ -2,9 +2,9 @@ import java.io.BufferedReader; import java.io.IOException; +import java.util.Collections; import java.util.Comparator; import java.util.List; -import java.util.Collections; import org.apache.log4j.Logger; /** Modified: trunk/src/app/net/sf/gridarta/io/AbstractMapWriter.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/AbstractMapWriter.java 2006-11-12 00:06:05 UTC (rev 655) +++ trunk/src/app/net/sf/gridarta/io/AbstractMapWriter.java 2006-11-12 00:10:18 UTC (rev 656) @@ -1,5 +1,6 @@ package net.sf.gridarta.io; +import java.awt.Point; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; @@ -7,11 +8,10 @@ import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.UnsupportedEncodingException; -import java.awt.Point; +import net.sf.gridarta.Size2D; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.Size2D; import org.jetbrains.annotations.NotNull; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-12 00:06:16
|
Revision: 655 http://svn.sourceforge.net/gridarta/?rev=655&view=rev Author: christianhujer Date: 2006-11-11 16:06:05 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Removed dependency on CMainControl by changing Collectable interface to provide the destination directory for the collection. Modified Paths: -------------- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/Collectable.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-11-11 23:58:22 UTC (rev 654) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-11-12 00:06:05 UTC (rev 655) @@ -474,9 +474,10 @@ /** {@inheritDoc} */ public void run() { final Progress pbar = new ProgressDisplay(mainControl.getMainView(), ""/*FIXME*/, getArchetypeCount(), ACTION_FACTORY.getString("archCollectArches")); + final File dir = new File(mainControl.getArchDefaultFolder()); for (final Collectable collectable : new Collectable[] { ArchetypeSet.this, mainControl.getAnimationObjects(), mainControl.getFaceObjects() }) { try { - collectable.collect(pbar); + collectable.collect(pbar, dir); } catch (final IOException e) { ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", "arches, animations and animtree, images", e); } @@ -487,8 +488,8 @@ }; // Runnable archCollector /** {@inheritDoc} */ - public void collect(@NotNull final Progress progress) throws IOException { - final File dfile = new File(mainControl.getArchDefaultFolder(), IGUIConstants.ARCH_FILE); + public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { + final File dfile = new File(dir, IGUIConstants.ARCH_FILE); // now open the output-stream final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dfile), IOUtils.MAP_ENCODING)); try { Modified: trunk/daimonin/src/daieditor/gameobject/Collectable.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/Collectable.java 2006-11-11 23:58:22 UTC (rev 654) +++ trunk/daimonin/src/daieditor/gameobject/Collectable.java 2006-11-12 00:06:05 UTC (rev 655) @@ -2,6 +2,7 @@ import net.sf.japi.swing.Progress; import java.io.IOException; +import java.io.File; import org.jetbrains.annotations.NotNull; /** @@ -14,8 +15,9 @@ /** * Collect information. * @param progress Progress to report progress to. + * @param dir Destination directory to collect data to. * @throws IOException in case of I/O problems during collection */ - void collect(@NotNull final Progress progress) throws IOException; + void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException; } // interface Collectable Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2006-11-11 23:58:22 UTC (rev 654) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2006-11-12 00:06:05 UTC (rev 655) @@ -25,30 +25,29 @@ package daieditor.gameobject.anim; -import daieditor.gameobject.NamedObjects; +import daieditor.IGUIConstants; import daieditor.gameobject.Collectable; +import daieditor.gameobject.NamedObjects; import daieditor.io.PathManager; -import daieditor.IGUIConstants; -import daieditor.CMainControl; import java.io.BufferedReader; +import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; -import java.io.Reader; -import java.io.FileOutputStream; -import java.io.BufferedWriter; import java.io.OutputStreamWriter; +import java.io.Reader; import java.util.HashMap; import java.util.Map; import net.sf.gridarta.gameobject.anim.AnimationParseException; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.io.IOUtils; -import net.sf.japi.swing.Progress; import net.sf.japi.swing.ActionFactory; -import org.jetbrains.annotations.Nullable; +import net.sf.japi.swing.Progress; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** @@ -215,10 +214,10 @@ } /** {@inheritDoc} */ - public void collect(@NotNull final Progress progress) throws IOException { - final BufferedWriter animations = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(CMainControl.getInstance().getArchDefaultFolder(), "animations")), IOUtils.MAP_ENCODING)); + public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { + final BufferedWriter animations = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, "animations")), IOUtils.MAP_ENCODING)); try { - final BufferedWriter animtree = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(new File(CMainControl.getInstance().getArchDefaultFolder(), IGUIConstants.CONFIG_DIR), IGUIConstants.ANIMTREE_FILE)), IOUtils.MAP_ENCODING)); + final BufferedWriter animtree = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(new File(dir, IGUIConstants.CONFIG_DIR), IGUIConstants.ANIMTREE_FILE)), IOUtils.MAP_ENCODING)); try { progress.setLabel(ACTION_FACTORY.getString("archCollectAnimations"), size()); int counter = 0; // counter for progress bar Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2006-11-11 23:58:22 UTC (rev 654) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2006-11-12 00:06:05 UTC (rev 655) @@ -199,19 +199,18 @@ * But the Java image encoder isn't as good as that of gimp in many cases (yet much better as the old visualtek's). * @todo I/O handling sucks here, this could be nicer. */ - public void collect(@NotNull final Progress progress) throws IOException { - final CMainControl mainControl = CMainControl.getInstance(); + public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { DataOutputStream binFile = null; BufferedWriter textFile = null; BufferedWriter treeFile = null; - final int stripPath = new File(mainControl.getArchDefaultFolder()).getAbsolutePath().length(); + final int stripPath = dir.getAbsolutePath().length(); try { // create the resource-directorys if they don't exist yet - textFile = new BufferedWriter(new FileWriter(new File(mainControl.getArchDefaultFolder(), IGUIConstants.BMAPS_FILE))); - treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(new File(mainControl.getArchDefaultFolder(), IGUIConstants.CONFIG_DIR), IGUIConstants.FACETREE_FILE)), "us-ascii")); + textFile = new BufferedWriter(new FileWriter(new File(dir, IGUIConstants.BMAPS_FILE))); + treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(new File(dir, IGUIConstants.CONFIG_DIR), IGUIConstants.FACETREE_FILE)), "us-ascii")); - final File dfile = new File(mainControl.getArchDefaultFolder(), IGUIConstants.PNG_FILE); + final File dfile = new File(dir, IGUIConstants.PNG_FILE); binFile = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(dfile))); // write number 0 dummy entry @@ -220,7 +219,7 @@ final String numstring = def.substring(0, 5 - num.length()) + num; int numBytes = 0; - final String path = mainControl.getArchDefaultFolder() + "/dev/editor/bug.101.png"; + final String path = dir + "/dev/editor/bug.101.png"; FileInputStream fin = null; // XXX: This code limits image support to an image size of 1024 * 50 bytes = 50k final byte[] imgBuffer = new byte[IMAGE_BUFFER_SIZE]; @@ -251,11 +250,10 @@ treeFile.append("/dev/editor/bug.101.png\n"); // now write all pngs into the file - final FaceObjects faceObjects = mainControl.getFaceObjects(); - final int numOfFaceObjects = faceObjects.size(); + final int numOfFaceObjects = size(); progress.setLabel(ACTION_FACTORY.getString("archCollectImages"), numOfFaceObjects); int i = 0; - for (final FaceObject faceObject : faceObjects) { + for (final FaceObject faceObject : this) { final String face = faceObject.getFaceName(); numBytes = 0; final String num2 = Integer.toString(++i); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-11 23:58:34
|
Revision: 654 http://svn.sourceforge.net/gridarta/?rev=654&view=rev Author: christianhujer Date: 2006-11-11 15:58:22 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Refactored collection code by decentralizing it and introducing an interface. Modified Paths: -------------- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java Added Paths: ----------- trunk/daimonin/src/daieditor/gameobject/Collectable.java Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-11-11 23:57:39 UTC (rev 653) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-11-11 23:58:22 UTC (rev 654) @@ -30,23 +30,16 @@ import daieditor.CMainControl; import daieditor.CPickmapPanel; import daieditor.IGUIConstants; -import daieditor.gameobject.anim.AnimationObject; import daieditor.gameobject.anim.AnimationObjects; import daieditor.gameobject.face.DuplicateFaceException; import daieditor.gameobject.face.FaceFacade; -import daieditor.gameobject.face.FaceObject; -import daieditor.gameobject.face.FaceObjects; import daieditor.icons.ArchFaceProvider; -import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.BufferedWriter; -import java.io.DataOutputStream; import java.io.File; -import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileReader; -import java.io.FileWriter; import java.io.FilenameFilter; import java.io.IOException; import java.io.OutputStreamWriter; @@ -54,7 +47,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Map; import javax.swing.ImageIcon; import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.gridarta.gameobject.anim.AnimationParseException; @@ -65,6 +57,7 @@ import net.sf.japi.swing.Progress; import net.sf.japi.swing.ProgressDisplay; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; /** * The <code>ArchetypeSet</code> contains all the Archetypes. @@ -72,7 +65,7 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public final class ArchetypeSet extends AbstractArchetypeSet<GameObject> { +public final class ArchetypeSet extends AbstractArchetypeSet<GameObject> implements Collectable { private static final Logger log = Logger.getLogger(ArchetypeSet.class); @@ -136,7 +129,7 @@ final long timeStart = System.currentTimeMillis(); setLoadStatus(LoadStatus.LOADING); // status: loading if (log.isInfoEnabled()) { - log.info("Start to collect archetypes..."); + log.info("Start to load archetypes..."); } mainControl.setStatusText(" Loading Archetypes... "); @@ -147,12 +140,12 @@ // here we go... if (mainControl.isArchLoadedFromCollection()) { - loadArchFromCollected(); // collect arches & images from collection + loadArchFromCollected(); // load arches & images from collection } else { FaceFacade.setNormal(new ArchFaceProvider()); setLoadedFromArchive(false); // don't load from the collected files animFiles = new ArrayList<File>(); - loadArchFromFiles(new File(mainControl.getArchDefaultFolder()), 0, false); // collect arches & images from individual files + loadArchFromFiles(new File(mainControl.getArchDefaultFolder()), 0, false); // load arches & images from individual files loadAnimsFromFiles(); } @@ -172,7 +165,7 @@ setLoadStatus(LoadStatus.EMPTY); // status: stack is empty ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "loadArchesNoArchfiles"); } else { - // display the time it took to collect arches: + // display the time it took to load arches: setLoadStatus(LoadStatus.COMPLETE); // status: stack completed if (log.isInfoEnabled()) { log.info("Arch loading took " + (System.currentTimeMillis() - timeStart) / 1000.0 + " Seconds"); @@ -481,36 +474,20 @@ /** {@inheritDoc} */ public void run() { final Progress pbar = new ProgressDisplay(mainControl.getMainView(), ""/*FIXME*/, getArchetypeCount(), ACTION_FACTORY.getString("archCollectArches")); - try { - collectDaimoninArchetypes(pbar); - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", "arches", e); + for (final Collectable collectable : new Collectable[] { ArchetypeSet.this, mainControl.getAnimationObjects(), mainControl.getFaceObjects() }) { + try { + collectable.collect(pbar); + } catch (final IOException e) { + ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", "arches, animations and animtree, images", e); + } } - try { - collectDaimoninAnimations(pbar); - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", "animations", e); - } - try { - collectDaimoninAnimationTree(pbar); - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", IGUIConstants.ANIMTREE_FILE, e); - } - try { - collectDaimoninImages(pbar); - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", "images", e); - } pbar.finished(); mainControl.setStatusText(ACTION_FACTORY.getString("archCollectDone")); } }; // Runnable archCollector - /** - * Collect arches. - * @param pbar progress bar to update - */ - private void collectDaimoninArchetypes(final Progress pbar) throws IOException { + /** {@inheritDoc} */ + public void collect(@NotNull final Progress progress) throws IOException { final File dfile = new File(mainControl.getArchDefaultFolder(), IGUIConstants.ARCH_FILE); // now open the output-stream final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dfile), IOUtils.MAP_ENCODING)); @@ -604,7 +581,7 @@ for (GameObject tail = arch.getMultiNext(); tail != null; tail = tail.getMultiNext()) { if (tail.isHead()) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectWarningMultipartTooShort"); + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectWarningMultipartTooShort"); } out.append("More\n"); @@ -653,204 +630,25 @@ out.append("end\n"); count++; if (count % 100 == 0) { - pbar.setValue(count); + progress.setValue(count); } } } } count++; if (count % 100 == 0) { - pbar.setValue(count); + progress.setValue(count); } } // check if we still missed any arches if ((count + artifactCount) - getArchetypeCount() != 0) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectWarningMissed", getArchetypeCount() - count); + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectWarningMissed", getArchetypeCount() - count); } - pbar.setValue(count); + progress.setValue(count); } finally { out.close(); } } - /** - * Collect Animations. - * @param pbar progress bar to update - */ - private void collectDaimoninAnimations(final Progress pbar) throws IOException { - final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(mainControl.getArchDefaultFolder(), "animations")), IOUtils.MAP_ENCODING)); - try { - final AnimationObjects animationObjects = mainControl.getAnimationObjects(); - pbar.setLabel(ACTION_FACTORY.getString("archCollectAnimations"), animationObjects.size()); - int counter = 0; // counter for progress bar - for (final AnimationObject anim : animationObjects) { - out - .append("anim ") - .append(anim.getAnimName()) - .append('\n') - .append(anim.getAnimList()) - .append("mina\n"); - if (++counter % 100 == 0) { - pbar.setValue(counter); - } - } - } finally { - out.close(); - } - } - - /** - * Collect Animation Tree. - * @param pbar progress bar to update - * @throws IOException in case of I/O errors - */ - private void collectDaimoninAnimationTree(final Progress pbar) throws IOException { - final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(new File(mainControl.getArchDefaultFolder(), IGUIConstants.CONFIG_DIR), IGUIConstants.ANIMTREE_FILE)), IOUtils.MAP_ENCODING)); - try { - final AnimationObjects animationObjects = mainControl.getAnimationObjects(); - final Map<String, String> tree = animationObjects.getAnimPathTree(); - pbar.setLabel(ACTION_FACTORY.getString("archCollectAnimationTree"), animationObjects.size()); - int counter = 0; // counter for progress bar - for (String path : tree.values()) { - out - .append(path) - .append('\n'); - if (++counter % 100 == 0) { - pbar.setValue(counter); - } - } - } finally { - out.close(); - } - } - - /** - * Collect Images. - * Theoretically it would also be possible to recode the images. - * But the Java image encoder isn't as good as that of gimp in many cases (yet much better as the old visualtek's). - * @param pbar progress bar to update - * @throws IOException in case of I/O errors - * @todo I/O handling sucks here, this could be nicer. - */ - private void collectDaimoninImages(final Progress pbar) throws IOException { - DataOutputStream binFile = null; - BufferedWriter textFile = null; - BufferedWriter treeFile = null; - final int stripPath = new File(mainControl.getArchDefaultFolder()).getAbsolutePath().length(); - - try { - // create the resource-directorys if they don't exist yet - textFile = new BufferedWriter(new FileWriter(new File(mainControl.getArchDefaultFolder(), IGUIConstants.BMAPS_FILE))); - treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(new File(mainControl.getArchDefaultFolder(), IGUIConstants.CONFIG_DIR), IGUIConstants.FACETREE_FILE)), "us-ascii")); - - final File dfile = new File(mainControl.getArchDefaultFolder(), IGUIConstants.PNG_FILE); - binFile = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(dfile))); - - // write number 0 dummy entry - final String num = Integer.toString(0); - final String def = "00000"; - final String numstring = def.substring(0, 5 - num.length()) + num; - int numBytes = 0; - - final String path = mainControl.getArchDefaultFolder() + "/dev/editor/bug.101.png"; - FileInputStream fin = null; - // XXX: This code limits image support to an image size of 1024 * 50 bytes = 50k - final byte[] imgBuffer = new byte[IMAGE_BUFFER_SIZE]; - try { - fin = new FileInputStream(path); - numBytes = fin.read(imgBuffer, 0, IMAGE_BUFFER_SIZE); - } catch (final FileNotFoundException e) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorFileNotFound", path); - return; - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", path, e); - return; - } finally { - try { - fin.close(); - } catch (final Exception e) { /* ignore */ } finally { - fin = null; - } - } - - if (numBytes == -1) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorFileUnexpectedEOF", path); - return; - } - binFile.writeBytes("IMAGE " + numstring + ' ' + numBytes + " bug.101\n"); - binFile.write(imgBuffer, 0, numBytes); - textFile.write(numstring + " bug.101\n"); - treeFile.append("/dev/editor/bug.101.png\n"); - - // now write all pngs into the file - final FaceObjects faceObjects = mainControl.getFaceObjects(); - final int numOfFaceObjects = faceObjects.size(); - pbar.setLabel(ACTION_FACTORY.getString("archCollectImages"), numOfFaceObjects); - int i = 0; - for (final FaceObject faceObject : faceObjects) { - final String face = faceObject.getFaceName(); - numBytes = 0; - final String num2 = Integer.toString(++i); - final String numstring2 = def.substring(0, 5 - num2.length()) + num2; - final String path2 = ((ArchFaceProvider) FaceFacade.normal).getFilename(face); - - try { - // try to open the png image file - fin = new FileInputStream(path2); - // 50000 isn't a nice constant. But there won't be pngs larger than this. - try { - numBytes = fin.read(imgBuffer, 0, IMAGE_BUFFER_SIZE); - } finally { - fin.close(); - fin = null; - } - } catch (final FileNotFoundException e) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorFileNotFound", path2); - return; - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", path2, e); - return; - } - - if (numBytes == -1) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorFileUnexpectedEOF", path2); - return; - } - - // create path string - // final String pname = "./arch"+faceObjects[i].getPath().substring(mainControl.getArchDefaultFolder().length()).replace('\\', '/'); - // pname = pname.substring(0, pname.lastIndexOf("/")+1); - - // now write this png data into the big collected png file - // binFile.writeBytes("IMAGE "+numstring2+" "+numBytes+" "+pname+faceObjects[i].getName()+'\n'); - binFile.writeBytes("IMAGE " + numstring2 + ' ' + numBytes + ' ' + face + '\n'); - binFile.write(imgBuffer, 0, numBytes); - textFile.write(numstring2 + ' ' + face + '\n'); - treeFile.append(path2.substring(stripPath, path2.length() - 4).replace('\\', '/')).append('\n'); - - if (i % 100 == 0) { - pbar.setValue(i); - } - } - pbar.setValue(numOfFaceObjects); // finished - } finally { - try { - binFile.close(); - } catch (final Exception e) { /* ignore */ } finally { - binFile = null; - } - try { - textFile.close(); - } catch (final Exception e) { /* ignore */ } finally { - textFile = null; - } - try { - treeFile.close(); - } catch (final Exception e) { /* ignore */ } finally { - treeFile = null; - } - } - } - } // class ArchetypeSet Added: trunk/daimonin/src/daieditor/gameobject/Collectable.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/Collectable.java (rev 0) +++ trunk/daimonin/src/daieditor/gameobject/Collectable.java 2006-11-11 23:58:22 UTC (rev 654) @@ -0,0 +1,21 @@ +package daieditor.gameobject; + +import net.sf.japi.swing.Progress; +import java.io.IOException; +import org.jetbrains.annotations.NotNull; + +/** + * A Collectable has information that can be collected. + * This is used during the "arch collection" process to gather information into files suitable for the server. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface Collectable { + + /** + * Collect information. + * @param progress Progress to report progress to. + * @throws IOException in case of I/O problems during collection + */ + void collect(@NotNull final Progress progress) throws IOException; + +} // interface Collectable Property changes on: trunk/daimonin/src/daieditor/gameobject/Collectable.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2006-11-11 23:57:39 UTC (rev 653) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2006-11-11 23:58:22 UTC (rev 654) @@ -26,7 +26,10 @@ package daieditor.gameobject.anim; import daieditor.gameobject.NamedObjects; +import daieditor.gameobject.Collectable; import daieditor.io.PathManager; +import daieditor.IGUIConstants; +import daieditor.CMainControl; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -34,12 +37,18 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; +import java.io.FileOutputStream; +import java.io.BufferedWriter; +import java.io.OutputStreamWriter; import java.util.HashMap; import java.util.Map; import net.sf.gridarta.gameobject.anim.AnimationParseException; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.io.IOUtils; +import net.sf.japi.swing.Progress; +import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; /** @@ -49,8 +58,11 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ @SuppressWarnings({"HardcodedFileSeparator"}) -public final class AnimationObjects extends NamedObjects<AnimationObject> implements net.sf.gridarta.gameobject.anim.AnimationObjects<AnimationObject> { +public final class AnimationObjects extends NamedObjects<AnimationObject> implements net.sf.gridarta.gameobject.anim.AnimationObjects<AnimationObject>, Collectable { + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); + /** * This Map holds (anim object name, path to arc file) pairs. * The object name is included in the path. @@ -202,4 +214,34 @@ } } + /** {@inheritDoc} */ + public void collect(@NotNull final Progress progress) throws IOException { + final BufferedWriter animations = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(CMainControl.getInstance().getArchDefaultFolder(), "animations")), IOUtils.MAP_ENCODING)); + try { + final BufferedWriter animtree = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(new File(CMainControl.getInstance().getArchDefaultFolder(), IGUIConstants.CONFIG_DIR), IGUIConstants.ANIMTREE_FILE)), IOUtils.MAP_ENCODING)); + try { + progress.setLabel(ACTION_FACTORY.getString("archCollectAnimations"), size()); + int counter = 0; // counter for progress bar + for (final AnimationObject anim : this) { + animations + .append("anim ") + .append(anim.getAnimName()) + .append('\n') + .append(anim.getAnimList()) + .append("mina\n"); + animtree + .append(anim.getPath()) + .append('\n'); + if (++counter % 128 == 0) { + progress.setValue(counter); + } + } + } finally { + animtree.close(); + } + } finally { + animations.close(); + } + } + } // class AnimationObjects Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2006-11-11 23:57:39 UTC (rev 653) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2006-11-11 23:58:22 UTC (rev 654) @@ -22,8 +22,11 @@ package daieditor.gameobject.face; import daieditor.CMainControl; +import daieditor.IGUIConstants; import daieditor.gameobject.NamedObjects; +import daieditor.gameobject.Collectable; import daieditor.icons.DaimoninFaceProvider; +import daieditor.icons.ArchFaceProvider; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; @@ -31,16 +34,31 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; +import java.io.BufferedWriter; +import java.io.FileOutputStream; +import java.io.BufferedOutputStream; +import java.io.FileWriter; +import java.io.DataOutputStream; +import java.io.OutputStreamWriter; import java.util.logging.Level; import java.util.logging.Logger; import static net.sf.japi.swing.ActionFactory.getFactory; +import net.sf.japi.swing.Progress; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; /** * This class manages the FaceObjects. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public final class FaceObjects extends NamedObjects<FaceObject> { +public final class FaceObjects extends NamedObjects<FaceObject> implements Collectable { + /** Size of the image buffer. */ + private static final int IMAGE_BUFFER_SIZE = 50 * 1024; + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); + /** * Create an FaceObjects container. * @param name localized name (see {@link NamedObjects#NamedObjects(String)}) @@ -175,4 +193,130 @@ } } + /** + * {@inheritDoc} + * Theoretically it would also be possible to recode the images. + * But the Java image encoder isn't as good as that of gimp in many cases (yet much better as the old visualtek's). + * @todo I/O handling sucks here, this could be nicer. + */ + public void collect(@NotNull final Progress progress) throws IOException { + final CMainControl mainControl = CMainControl.getInstance(); + DataOutputStream binFile = null; + BufferedWriter textFile = null; + BufferedWriter treeFile = null; + final int stripPath = new File(mainControl.getArchDefaultFolder()).getAbsolutePath().length(); + + try { + // create the resource-directorys if they don't exist yet + textFile = new BufferedWriter(new FileWriter(new File(mainControl.getArchDefaultFolder(), IGUIConstants.BMAPS_FILE))); + treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(new File(mainControl.getArchDefaultFolder(), IGUIConstants.CONFIG_DIR), IGUIConstants.FACETREE_FILE)), "us-ascii")); + + final File dfile = new File(mainControl.getArchDefaultFolder(), IGUIConstants.PNG_FILE); + binFile = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(dfile))); + + // write number 0 dummy entry + final String num = Integer.toString(0); + final String def = "00000"; + final String numstring = def.substring(0, 5 - num.length()) + num; + int numBytes = 0; + + final String path = mainControl.getArchDefaultFolder() + "/dev/editor/bug.101.png"; + FileInputStream fin = null; + // XXX: This code limits image support to an image size of 1024 * 50 bytes = 50k + final byte[] imgBuffer = new byte[IMAGE_BUFFER_SIZE]; + try { + fin = new FileInputStream(path); + numBytes = fin.read(imgBuffer, 0, IMAGE_BUFFER_SIZE); + } catch (final FileNotFoundException e) { + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorFileNotFound", path); + return; + } catch (final IOException e) { + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorIOException", path, e); + return; + } finally { + try { + fin.close(); + } catch (final Exception e) { /* ignore */ } finally { + fin = null; + } + } + + if (numBytes == -1) { + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorFileUnexpectedEOF", path); + return; + } + binFile.writeBytes("IMAGE " + numstring + ' ' + numBytes + " bug.101\n"); + binFile.write(imgBuffer, 0, numBytes); + textFile.write(numstring + " bug.101\n"); + treeFile.append("/dev/editor/bug.101.png\n"); + + // now write all pngs into the file + final FaceObjects faceObjects = mainControl.getFaceObjects(); + final int numOfFaceObjects = faceObjects.size(); + progress.setLabel(ACTION_FACTORY.getString("archCollectImages"), numOfFaceObjects); + int i = 0; + for (final FaceObject faceObject : faceObjects) { + final String face = faceObject.getFaceName(); + numBytes = 0; + final String num2 = Integer.toString(++i); + final String numstring2 = def.substring(0, 5 - num2.length()) + num2; + final String path2 = ((ArchFaceProvider) FaceFacade.normal).getFilename(face); + + try { + // try to open the png image file + fin = new FileInputStream(path2); + // 50000 isn't a nice constant. But there won't be pngs larger than this. + try { + numBytes = fin.read(imgBuffer, 0, IMAGE_BUFFER_SIZE); + } finally { + fin.close(); + fin = null; + } + } catch (final FileNotFoundException e) { + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorFileNotFound", path2); + return; + } catch (final IOException e) { + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorIOException", path2, e); + return; + } + + if (numBytes == -1) { + ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorFileUnexpectedEOF", path2); + return; + } + + // create path string + // final String pname = "./arch"+faceObjects[i].getPath().substring(mainControl.getArchDefaultFolder().length()).replace('\\', '/'); + // pname = pname.substring(0, pname.lastIndexOf("/")+1); + + // now write this png data into the big collected png file + // binFile.writeBytes("IMAGE "+numstring2+" "+numBytes+" "+pname+faceObjects[i].getName()+'\n'); + binFile.writeBytes("IMAGE " + numstring2 + ' ' + numBytes + ' ' + face + '\n'); + binFile.write(imgBuffer, 0, numBytes); + textFile.write(numstring2 + ' ' + face + '\n'); + treeFile.append(path2.substring(stripPath, path2.length() - 4).replace('\\', '/')).append('\n'); + + if (i % 100 == 0) { + progress.setValue(i); + } + } + progress.setValue(numOfFaceObjects); // finished + } finally { + try { + binFile.close(); + } catch (final Exception e) { /* ignore */ } finally { + binFile = null; + } + try { + textFile.close(); + } catch (final Exception e) { /* ignore */ } finally { + textFile = null; + } + try { + treeFile.close(); + } catch (final Exception e) { /* ignore */ } finally { + treeFile = null; + } + } + } } // class FaceObjects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-11 23:57:45
|
Revision: 653 http://svn.sourceforge.net/gridarta/?rev=653&view=rev Author: christianhujer Date: 2006-11-11 15:57:39 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Cosmetic: final. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-11-11 23:07:58 UTC (rev 652) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-11-11 23:57:39 UTC (rev 653) @@ -310,7 +310,7 @@ } try { mainControl.getAnimationObjects().addAnimationObject(animName, animText); - } catch (DuplicateAnimationException e) { + } catch (final DuplicateAnimationException e) { log.warn("Duplicate Animation " + animName, e); } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-11 23:08:06
|
Revision: 652 http://svn.sourceforge.net/gridarta/?rev=652&view=rev Author: christianhujer Date: 2006-11-11 15:07:58 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Changed some I/O handling. Modified Paths: -------------- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-11-11 23:07:45 UTC (rev 651) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-11-11 23:07:58 UTC (rev 652) @@ -175,7 +175,7 @@ // display the time it took to collect arches: setLoadStatus(LoadStatus.COMPLETE); // status: stack completed if (log.isInfoEnabled()) { - log.info("Arch collect took " + (System.currentTimeMillis() - timeStart) / 1000.0 + " Seconds"); + log.info("Arch loading took " + (System.currentTimeMillis() - timeStart) / 1000.0 + " Seconds"); } // load pickmaps @@ -481,10 +481,26 @@ /** {@inheritDoc} */ public void run() { final Progress pbar = new ProgressDisplay(mainControl.getMainView(), ""/*FIXME*/, getArchetypeCount(), ACTION_FACTORY.getString("archCollectArches")); - collectDaimoninArchetypes(pbar); - collectDaimoninAnimations(pbar); - collectDaimoninAnimationTree(pbar); - collectDaimoninImages(pbar); + try { + collectDaimoninArchetypes(pbar); + } catch (final IOException e) { + ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", "arches", e); + } + try { + collectDaimoninAnimations(pbar); + } catch (final IOException e) { + ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", "animations", e); + } + try { + collectDaimoninAnimationTree(pbar); + } catch (final IOException e) { + ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", IGUIConstants.ANIMTREE_FILE, e); + } + try { + collectDaimoninImages(pbar); + } catch (final IOException e) { + ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", "images", e); + } pbar.finished(); mainControl.setStatusText(ACTION_FACTORY.getString("archCollectDone")); } @@ -494,172 +510,167 @@ * Collect arches. * @param pbar progress bar to update */ - private void collectDaimoninArchetypes(final Progress pbar) { - // WARNING: do not use out.println() because the server will crash if it's not "\n" but e.g. "\r"! + private void collectDaimoninArchetypes(final Progress pbar) throws IOException { + final File dfile = new File(mainControl.getArchDefaultFolder(), IGUIConstants.ARCH_FILE); + // now open the output-stream + final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dfile), IOUtils.MAP_ENCODING)); try { - final File dfile = new File(mainControl.getArchDefaultFolder(), IGUIConstants.ARCH_FILE); - // now open the output-stream - final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dfile), IOUtils.MAP_ENCODING)); - try { - int artifactCount = 0; + int artifactCount = 0; - int count = 0; // count how much arches we've collected + int count = 0; // count how much arches we've collected - for (final GameObject arch : getArchetypes()) { + for (final GameObject arch : getArchetypes()) { - // exclude arches generated from artifacts file from collection - if (arch.isArtifact()) { - artifactCount++; - continue; - } - if (arch.getArchetypeName().compareTo(ArchetypeParser.STARTARCH_NAME) == 0) { - // process map arch + // exclude arches generated from artifacts file from collection + if (arch.isArtifact()) { + artifactCount++; + continue; + } + if (arch.getArchetypeName().compareTo(ArchetypeParser.STARTARCH_NAME) == 0) { + // process map arch - out.append("Object ").append(arch.getArchetypeName()).append('\n'); + out.append("Object ").append(arch.getArchetypeName()).append('\n'); - // map object hack: x/y is normally a reference for multi - // part arches - i include this hack until we rework the - // arch objects with more useful script names - if (arch.getArchetypeName().equals(ArchetypeParser.STARTARCH_NAME)) { - out.append("x ").append(Integer.toString(arch.getMultiX())).append('\n'); - out.append("y ").append(Integer.toString(arch.getMultiY())).append('\n'); - } + // map object hack: x/y is normally a reference for multi + // part arches - i include this hack until we rework the + // arch objects with more useful script names + if (arch.getArchetypeName().equals(ArchetypeParser.STARTARCH_NAME)) { + out.append("x ").append(Integer.toString(arch.getMultiX())).append('\n'); + out.append("y ").append(Integer.toString(arch.getMultiY())).append('\n'); + } - if (arch.getObjName() != null) { - out.append("name ").append(arch.getObjName()).append('\n'); - } - //if(arch.getFaceName() != null) { - // out.append("face ").append(arch.getFaceNAme()).append('\n'); - //} - if (arch.getArchTypNr() > 0) { - out.append("type ").append(Integer.toString(arch.getArchTypNr())).append('\n'); - } + if (arch.getObjName() != null) { + out.append("name ").append(arch.getObjName()).append('\n'); + } + //if(arch.getFaceName() != null) { + // out.append("face ").append(arch.getFaceNAme()).append('\n'); + //} + if (arch.getArchTypNr() > 0) { + out.append("type ").append(Integer.toString(arch.getArchTypNr())).append('\n'); + } - out.append(arch.getObjectText()); - if (arch.getObjectText().lastIndexOf(0x0a) != arch.getObjectText().length() - 1) { - out.append('\n'); - } - out.append("end\n"); - } else { + out.append(arch.getObjectText()); + if (arch.getObjectText().lastIndexOf(0x0a) != arch.getObjectText().length() - 1) { + out.append('\n'); + } + out.append("end\n"); + } else { - if (arch.isTail()) { - continue; - //ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), WARNING_MESSAGE, "archCollectWarningMultipartTailInPanel"); - } - out.append("Object ").append(arch.getArchetypeName()).append('\n'); + if (arch.isTail()) { + continue; + //ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), WARNING_MESSAGE, "archCollectWarningMultipartTailInPanel"); + } + out.append("Object ").append(arch.getArchetypeName()).append('\n'); - if (arch.getObjName() != null) { - out.append("name ").append(arch.getObjName()).append('\n'); - } - //if(arch.getFaceName() != null) { - // out.append("face ").append(arch.getFaceName()).append('\n'); - //} - if (arch.getArchTypNr() > 0) { - out.append("type ").append(Integer.toString(arch.getArchTypNr())).append('\n'); - } - if (arch.getMultiShapeID() > 0) { - out.append("mpart_id ").append(Integer.toString(arch.getMultiShapeID())).append('\n'); - } - if (arch.getMultiPartNr() > 0) { - out.append("mpart_nr ").append(Integer.toString(arch.getMultiPartNr())).append('\n'); - } + if (arch.getObjName() != null) { + out.append("name ").append(arch.getObjName()).append('\n'); + } + //if(arch.getFaceName() != null) { + // out.append("face ").append(arch.getFaceName()).append('\n'); + //} + if (arch.getArchTypNr() > 0) { + out.append("type ").append(Integer.toString(arch.getArchTypNr())).append('\n'); + } + if (arch.getMultiShapeID() > 0) { + out.append("mpart_id ").append(Integer.toString(arch.getMultiShapeID())).append('\n'); + } + if (arch.getMultiPartNr() > 0) { + out.append("mpart_nr ").append(Integer.toString(arch.getMultiPartNr())).append('\n'); + } - if (arch.getMsgText() != null) { - out.append("msg").append('\n'); - if (arch.getMsgText().length() > 1) { - out.append(arch.getMsgText()); - if (arch.getMsgText().lastIndexOf('\n') != arch.getMsgText().length() - 1) { - out.append('\n'); - } + if (arch.getMsgText() != null) { + out.append("msg").append('\n'); + if (arch.getMsgText().length() > 1) { + out.append(arch.getMsgText()); + if (arch.getMsgText().lastIndexOf('\n') != arch.getMsgText().length() - 1) { + out.append('\n'); } - out.append("endmsg\n"); } + out.append("endmsg\n"); + } - // special: add a string-attribute with the display-category - out.append("editor_folder ").append(arch.getEditorFolder()).append('\n'); + // special: add a string-attribute with the display-category + out.append("editor_folder ").append(arch.getEditorFolder()).append('\n'); - out.append(arch.getObjectText()); - if (arch.getObjectText().lastIndexOf('\n') != arch.getObjectText().length() - 1) { - out.append('\n'); - } - out.append("end\n"); + out.append(arch.getObjectText()); + if (arch.getObjectText().lastIndexOf('\n') != arch.getObjectText().length() - 1) { + out.append('\n'); + } + out.append("end\n"); - // if multi-head, we must attach the tail - if (arch.isMulti()) { - // process the multipart tail: - for (GameObject tail = arch.getMultiNext(); tail != null; tail = tail.getMultiNext()) { + // if multi-head, we must attach the tail + if (arch.isMulti()) { + // process the multipart tail: + for (GameObject tail = arch.getMultiNext(); tail != null; tail = tail.getMultiNext()) { - if (tail.isHead()) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectWarningMultipartTooShort"); - } + if (tail.isHead()) { + ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectWarningMultipartTooShort"); + } - out.append("More\n"); + out.append("More\n"); - out.append("Object ").append(tail.getArchetypeName()).append('\n'); + out.append("Object ").append(tail.getArchetypeName()).append('\n'); - if (tail.getObjName() != null) { - out.append("name ").append(tail.getObjName()).append('\n'); - } - //if(arch.getFaceName() != null) { - // out.append("face ").append(arch.getFaceName()).append('\n'); - //} - if (tail.getArchTypNr() > 0) { - out.append("type ").append(Integer.toString(tail.getArchTypNr())).append('\n'); - } - if (tail.getMultiShapeID() > 0) { - out.append("mpart_id ").append(Integer.toString(tail.getMultiShapeID())).append('\n'); - } - if (tail.getMultiPartNr() > 0) { - out.append("mpart_nr ").append(Integer.toString(tail.getMultiPartNr())).append('\n'); - } + if (tail.getObjName() != null) { + out.append("name ").append(tail.getObjName()).append('\n'); + } + //if(arch.getFaceName() != null) { + // out.append("face ").append(arch.getFaceName()).append('\n'); + //} + if (tail.getArchTypNr() > 0) { + out.append("type ").append(Integer.toString(tail.getArchTypNr())).append('\n'); + } + if (tail.getMultiShapeID() > 0) { + out.append("mpart_id ").append(Integer.toString(tail.getMultiShapeID())).append('\n'); + } + if (tail.getMultiPartNr() > 0) { + out.append("mpart_nr ").append(Integer.toString(tail.getMultiPartNr())).append('\n'); + } - if (tail.getMsgText() != null) { - out.append("msg\n"); - if (tail.getMsgText().length() > 1) { - out.append(tail.getMsgText()); - if (tail.getMsgText().lastIndexOf('\n') != tail.getMsgText().length() - 1) { - out.append('\n'); - } + if (tail.getMsgText() != null) { + out.append("msg\n"); + if (tail.getMsgText().length() > 1) { + out.append(tail.getMsgText()); + if (tail.getMsgText().lastIndexOf('\n') != tail.getMsgText().length() - 1) { + out.append('\n'); } - out.append("endmsg\n"); } + out.append("endmsg\n"); + } - out.append(tail.getObjectText()); - if (tail.getObjectText().lastIndexOf(0x0a) != tail.getObjectText().length() - 1) { - out.append('\n'); - } + out.append(tail.getObjectText()); + if (tail.getObjectText().lastIndexOf(0x0a) != tail.getObjectText().length() - 1) { + out.append('\n'); + } - // position of multi relative to head - if (tail.getMultiX() != 0) { - out.append("x ").append(Integer.toString(tail.getMultiX())).append('\n'); - } - if (tail.getMultiY() != 0) { - out.append("y ").append(Integer.toString(tail.getMultiY())).append('\n'); - } - out.append("end\n"); - count++; - if (count % 100 == 0) { - pbar.setValue(count); - } + // position of multi relative to head + if (tail.getMultiX() != 0) { + out.append("x ").append(Integer.toString(tail.getMultiX())).append('\n'); } + if (tail.getMultiY() != 0) { + out.append("y ").append(Integer.toString(tail.getMultiY())).append('\n'); + } + out.append("end\n"); + count++; + if (count % 100 == 0) { + pbar.setValue(count); + } } } - count++; - if (count % 100 == 0) { - pbar.setValue(count); - } } - - // check if we still missed any arches - if ((count + artifactCount) - getArchetypeCount() != 0) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectWarningMissed", getArchetypeCount() - count); + count++; + if (count % 100 == 0) { + pbar.setValue(count); } - pbar.setValue(count); - } finally { - out.close(); } - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", "arches", e); + + // check if we still missed any arches + if ((count + artifactCount) - getArchetypeCount() != 0) { + ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectWarningMissed", getArchetypeCount() - count); + } + pbar.setValue(count); + } finally { + out.close(); } } @@ -667,57 +678,50 @@ * Collect Animations. * @param pbar progress bar to update */ - private void collectDaimoninAnimations(final Progress pbar) { + private void collectDaimoninAnimations(final Progress pbar) throws IOException { + final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(mainControl.getArchDefaultFolder(), "animations")), IOUtils.MAP_ENCODING)); try { - final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(mainControl.getArchDefaultFolder(), "animations")), IOUtils.MAP_ENCODING)); - try { - final AnimationObjects animationObjects = mainControl.getAnimationObjects(); - pbar.setLabel(ACTION_FACTORY.getString("archCollectAnimations"), animationObjects.size()); - int counter = 0; // counter for progress bar - for (final AnimationObject anim : animationObjects) { - out - .append("anim ") - .append(anim.getAnimName()) - .append('\n') - .append(anim.getAnimList()) - .append("mina\n"); - if (++counter % 100 == 0) { - pbar.setValue(counter); - } + final AnimationObjects animationObjects = mainControl.getAnimationObjects(); + pbar.setLabel(ACTION_FACTORY.getString("archCollectAnimations"), animationObjects.size()); + int counter = 0; // counter for progress bar + for (final AnimationObject anim : animationObjects) { + out + .append("anim ") + .append(anim.getAnimName()) + .append('\n') + .append(anim.getAnimList()) + .append("mina\n"); + if (++counter % 100 == 0) { + pbar.setValue(counter); } - } finally { - out.close(); } - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", "animations", e); + } finally { + out.close(); } } /** * Collect Animation Tree. * @param pbar progress bar to update + * @throws IOException in case of I/O errors */ - private void collectDaimoninAnimationTree(final Progress pbar) { + private void collectDaimoninAnimationTree(final Progress pbar) throws IOException { + final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(new File(mainControl.getArchDefaultFolder(), IGUIConstants.CONFIG_DIR), IGUIConstants.ANIMTREE_FILE)), IOUtils.MAP_ENCODING)); try { - final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(new File(mainControl.getArchDefaultFolder(), IGUIConstants.CONFIG_DIR), IGUIConstants.ANIMTREE_FILE)), IOUtils.MAP_ENCODING)); - try { - final AnimationObjects animationObjects = mainControl.getAnimationObjects(); - final Map<String, String> tree = animationObjects.getAnimPathTree(); - pbar.setLabel(ACTION_FACTORY.getString("archCollectAnimationTree"), animationObjects.size()); - int counter = 0; // counter for progress bar - for (String path : tree.values()) { - out - .append(path) - .append('\n'); - if (++counter % 100 == 0) { - pbar.setValue(counter); - } + final AnimationObjects animationObjects = mainControl.getAnimationObjects(); + final Map<String, String> tree = animationObjects.getAnimPathTree(); + pbar.setLabel(ACTION_FACTORY.getString("archCollectAnimationTree"), animationObjects.size()); + int counter = 0; // counter for progress bar + for (String path : tree.values()) { + out + .append(path) + .append('\n'); + if (++counter % 100 == 0) { + pbar.setValue(counter); } - } finally { - out.close(); } - } catch (final IOException e) { - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", IGUIConstants.ANIMTREE_FILE, e); + } finally { + out.close(); } } @@ -726,9 +730,10 @@ * Theoretically it would also be possible to recode the images. * But the Java image encoder isn't as good as that of gimp in many cases (yet much better as the old visualtek's). * @param pbar progress bar to update + * @throws IOException in case of I/O errors * @todo I/O handling sucks here, this could be nicer. */ - private void collectDaimoninImages(final Progress pbar) { + private void collectDaimoninImages(final Progress pbar) throws IOException { DataOutputStream binFile = null; BufferedWriter textFile = null; BufferedWriter treeFile = null; @@ -829,9 +834,6 @@ } } pbar.setValue(numOfFaceObjects); // finished - } catch (final IOException e) { - // TOOD: find out which file threw the exception - ACTION_FACTORY.showMessageDialog(pbar.getParentComponent(), "archCollectErrorIOException", "images", e); } finally { try { binFile.close(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-11 23:07:51
|
Revision: 651 http://svn.sourceforge.net/gridarta/?rev=651&view=rev Author: christianhujer Date: 2006-11-11 15:07:45 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Improved arch loading speed output. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-11-11 21:22:42 UTC (rev 650) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-11-11 23:07:45 UTC (rev 651) @@ -47,7 +47,6 @@ import java.io.InputStream; import java.util.Arrays; import java.util.Collection; -import java.util.Date; import java.util.HashMap; import java.util.Map; import javax.swing.BorderFactory; @@ -130,7 +129,7 @@ /** load the arches */ public void loadArchetypes() { - final Date timeStart = new Date(); // get starting time + final long timeStart = System.currentTimeMillis(); setLoadStatus(LoadStatus.LOADING); // status: loading if (log.isInfoEnabled()) { log.info("Start to collect archetypes..."); @@ -171,10 +170,8 @@ } else { // display the time it took to collect arches: setLoadStatus(LoadStatus.COMPLETE); // status: stack completed - final Date timeFinish = new Date(); // get finishing time - final long diff = timeFinish.getTime() - timeStart.getTime(); if (log.isInfoEnabled()) { - log.info("Arch collect took " + diff / 1000.0 + " Seconds"); + log.info("Arch loading took " + (System.currentTimeMillis() - timeStart) / 1000.0 + " Seconds"); } // load pickmaps This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-11 21:22:46
|
Revision: 650 http://svn.sourceforge.net/gridarta/?rev=650&view=rev Author: christianhujer Date: 2006-11-11 13:22:42 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Fixed schroedinbug: some attributes where parsed without the required whitespace, and prototype wasn't checked for null. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-11-11 21:16:10 UTC (rev 649) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-11-11 21:22:42 UTC (rev 650) @@ -320,7 +320,9 @@ if (archName != null) { archetype.setArtifact(true); // here we add all unchanged arch text lines from defArch back to arch - archetype.addObjectText(archetype.diffArchText(prototype.getObjectText(), true)); + if (prototype != null) { + archetype.addObjectText(archetype.diffArchText(prototype.getObjectText(), true)); + } return archetype; } archlast = archetype; @@ -328,9 +330,9 @@ } else { if (thisLine.startsWith("msg")) { msgflag = true; - } else if (thisLine.startsWith("animation")) { + } else if (thisLine.startsWith("animation ")) { archetype.addObjectText(thisLine); - } else if (thisLine.startsWith("anim_speed")) { + } else if (thisLine.startsWith("anim_speed ")) { archetype.addObjectText(thisLine); } else if (thisLine.startsWith("anim")) { animflag = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-11 21:16:25
|
Revision: 649 http://svn.sourceforge.net/gridarta/?rev=649&view=rev Author: christianhujer Date: 2006-11-11 13:16:10 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Some more ArchetypeParser unification. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-11-11 21:15:26 UTC (rev 648) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-11-11 21:16:10 UTC (rev 649) @@ -186,27 +186,25 @@ thisLine2 = line; // pre read "Object" from artifacts file loader } - boolean msgflag = false; - boolean loreflag = false; - boolean animflag = false; - boolean parsearch = false; - boolean archmore = false; - String oldCat = "<xxx>"; boolean isNewCategory = true; + String oldCat = "<xxx>"; GameObject firstArch = null; + boolean archmore = false; + boolean parsearch = false; + boolean animflag = false; + boolean msgflag = false; + boolean loreflag = false; String newCat = "no category info"; - int archmoreCount = 0; while (thisLine2 != null) { final String thisLine = thisLine2.trim(); - if (thisLine.startsWith("#")) { - // skip comments + if (!msgflag && thisLine.startsWith("#")) { + // skip comments (only outside msges) thisLine2 = in.readLine(); continue; } if (!parsearch) { - if (thisLine.startsWith("More")) { if (firstArch == null) { firstArch = archlast; Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2006-11-11 21:15:26 UTC (rev 648) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2006-11-11 21:16:10 UTC (rev 649) @@ -120,6 +120,7 @@ } else { thisLine2 = line; // pre read "Object" from artifacts file loader } + boolean isNewCategory = true; String oldCat = null; String oldMainFolder = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-11 21:15:39
|
Revision: 648 http://svn.sourceforge.net/gridarta/?rev=648&view=rev Author: christianhujer Date: 2006-11-11 13:15:26 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Some new entries, some changes and some translation of tip of the days. Modified Paths: -------------- trunk/daimonin/src/daieditor/tod.properties trunk/daimonin/src/daieditor/tod_de.properties Modified: trunk/daimonin/src/daieditor/tod.properties =================================================================== --- trunk/daimonin/src/daieditor/tod.properties 2006-11-11 19:22:56 UTC (rev 647) +++ trunk/daimonin/src/daieditor/tod.properties 2006-11-11 21:15:26 UTC (rev 648) @@ -12,14 +12,14 @@ tod.text.7=<html>You can quickly move through tiled attached maps.<p>Hold <kbd>Ctrl</kbd> and use the numpad with the same directions as the client. tod.text.8=<html>How to use the mouse?<ul><li>To <em>select</em> tiles, use the left mouse button.<li>To <em>paint</em> (insert arches), use the right mouse button or hold shift and use the left mouse button.<li>To <em>delete</em>, use the middle mouse button or hold Ctrl and use the left mouse button.</ul> tod.text.9=<html>You can select all tiles of a map at once.<p>Menu: <code>Edit -> Select All</code><br>Keyboard: <kbd>Ctrl-A</kbd>. -tod.text.10=<html>You can random paint by selecting a pickmap and then paint?<p>Try this:<br>Select the "plants1" pickmap,<br>then paint with the right mouse button. +tod.text.10=<html>You can random paint by selecting a pickmap and painting.<p>Try this:<br>Select the "plants1" pickmap,<br>then paint with the right mouse button. tod.text.11=<html>All tiled maps of Daimonin are of size 24\xD724?<p>Your maps should be 24\xD724 as well. tod.text.12=<html>You can create random maps quite fast? Try this:<ol><li>Create a new map.<li>Select the entire map using Edit -> Select All or Ctrl-A<li>Select the "gras" pickmap (do not select a tile in the pickmap)<li>Use Edit -> Random Fill Above or Ctrl-D<li>When asked for a fill seed value, simply press OK or Return (enter nothing).<li>Select the "trees1" pickmap (do not select a tile in the pickmap)<li>Use Edit -> Random Fill Above or Ctrl-D<li>When asked for a fill seed value, now enter 3.</ol>Nice, isn't it? tod.text.13=<html>Maps can be tiled using absolute and relative paths.<p><em>Relative paths</em> are good for paths to maps from the same mapset.<br><em>Absolute paths</em> are good for paths to maps from another mapset.<p>The "RA"-Switch in the Map Properties can be used to indvidually convert absolute to relative paths and vice versa. tod.text.14=<html>The editor runs better on Linux than on Windows.\nIt runs faster and smoother on Linux. tod.text.15=<html>You can control the client.<p>Menu: <code>Tools -> Control Client</code>.<p>There you can start and stop the client as well as see its console output. tod.text.16=<html>You can control the server.<p>Menu: <code>Tools -> Control Server</code>.<p><em><strong>Warning</strong>: This feature is experimental and might result in stale servers (zombies).</em> -tod.text.17=<html>The editor was developed on Linux, mainly using vim and Ant.<p>Additionally, NetBeans 4.1, Eclipse 3.1 and <em>IntelliJ IDEA 5</em> were used to develop the editor.<p>JetBrains (<a href="http://www.jetbrains.com/">http://www.jetbrains.com/</a>) gave us a license for IntelliJ IDEA.<br>Thanks alot, JetBrains! +tod.text.17=<html>The editor was developed on Linux, mainly using vim, Ant and <em>IntelliJ IDEA 5</em>.<p>JetBrains (<a href="http://www.jetbrains.com/">http://www.jetbrains.com/</a>) gave us a license for IntelliJ IDEA. Thanks alot, JetBrains!<br><img src="http://www.jetbrains.com/idea/opensource/img/banners/idea88x31_blue.gif" alt="JetBrains"> tod.text.18=<html>You can easily make a false wall.<p>Change the Special attribute "blocking passage" to false or set <code>no_pass 0</code>. tod.text.19=<html>The difference between an exit and a teleporter:<p>An exit always works while a teleporter needs a connection to be activated. tod.text.20=<html>You can make anything glow (emit light), even mob.<p>Set the "glow radius" attribute (<code>glow_radius 1</code> for instance).<p>If you want to have a mob glow, be sure to set glow radius on the mob, not the spawn point. @@ -33,3 +33,5 @@ tod.text.28=<html>Many features have tooltips to help you.<p>Just hover the mouse over the thing you want to know about for a while. tod.text.29=<html>To attach a map to other maps, you must save it first. tod.text.30=<html>The editor runs even better when using Java 6.0 (Java2 1.6). +tod.text.31=<html>You should stick to the default map size (24\xD724).<br>That map size is also best for the server. +tod.text.32=<html>Beware when editing large maps. You might run out of memory.<br>Be sure to increase the heap size (-Xmx parameter) of Gridarta's Virtual Machine<br>When editing large maps (e.g. 240\xD7240). Modified: trunk/daimonin/src/daieditor/tod_de.properties =================================================================== --- trunk/daimonin/src/daieditor/tod_de.properties 2006-11-11 19:22:56 UTC (rev 647) +++ trunk/daimonin/src/daieditor/tod_de.properties 2006-11-11 21:15:26 UTC (rev 648) @@ -7,4 +7,27 @@ tod.text.2=<html>Dieses Tips-Fenster ist nicht modal.<p>Das bedeutet, Sie k\xF6nnen es offen lassen, w\xE4hrend Sie den Editor verwenden. tod.text.3=<html>Sie k\xF6nnen den Editor online aktualisieren, um die neueste Version zu erhalten.<p>Men\xFC: <code>Hilfe -> Aktualisieren</code>.<br>Tastatur: <kbd>Strg-U</kbd>.<p>Das wird den Editor auf die neueste verf\xFCgbare Version aktualisieren (nightly build). tod.text.4=<html>Sie k\xF6nnen schnell zwischen ge\xF6ffneten Fenstern wechseln.<p>Men\xFC: <code>Ansicht->Vorheriges / N\xE4chstes Fenster.</code>.<br>Tastatur: <kbd>Umschalt-Bild Auf</kbd> / <kbd>Umschalt-Bild Ab</kbd>. -tod.text.17=<html>Der Editor wurde unter Linux entwickelt, haupts\xE4chlich mit vim und Ant.<p>Zus\xE4tzlich wurden NetBeans 4.1, Eclipse 3.1 und <em>IntelliJ IDEA 5</em> verwendet.<p>JetBrains (<a href="http://www.jetbrains.com/">http://www.jetbrains.com/</a>) gaben uns eine kostenlose Lizenz f\xFCr IntelliJ IDEA.<br>Vielen Dank, JetBrains! +tod.text.5=<html>Sie k\xF6nnen halbhohe W\xE4nde genauso wie der Client gestapelt anzeigen lassen.<p>Men\xFC: <code>Ansicht->Zeichne doppelte Grafiken</code><br>Tastatur: <kbd>Strg+Umschalt-G</kbd>. +tod.text.6=<html>Auf den meisten Systemen l\xE4uft <em>Gridarta am schnellsten in 32 Bit Farbtiefe</em>.<p>Das ist so weil der Editor Transparenz verwendet (Alpha-Kanal). +tod.text.7=<html>Sie k\xF6nnen sich schnell durch verbundene Karten bewegen.<p>Halten Sie <kbd>Strg</kbd> gedr\xFCckt und verwenden Sie den Ziffernblock wie im Client. +tod.text.8=<html>Wie man die Maus benutzt?<ul><li>Zum <em>Selektieren</em>, linke Maustaste.<li>Zum <em>Einf\xFCgen</em>, rechte Maustaste.<li>Zum L\xF6schen: mittlere Maustaste.</ul> +tod.text.9=<html>Sie k\xF6nnen alle Felder einer Karte gleichzeitig selektieren.<p>Men\xFC: <code>Bearbeiten -> Alles ausw\xE4hlen</code><br>Tastatur: <kbd>Strg-A</kbd>. +tod.text.10=<html>Sie k\xF6nnen zuf\xE4llige Objekte aus einer Pickmap einf\xFCgen.<p>Versuchen Sie's:<br>W\xE4hlen Sie die "plants1" pickmap,<br>malen Sie dann mit der rechten Maustaste. +tod.text.11=<html>Alle verbundenen Karten von Daimonin sind 24\xD724 gro\xDF.<p>Ihre Karten sollten auch 24\xD724 gro\xDF sein. +tod.text.12=<html>Man kann zuf\xE4llige Karten sehr schnell erstellen.<ol><li>Leere Karte erstellen.<li>Die ganze Karte ausw\xE4hlen<li>Die "gras" pickmap ausw\xE4hlen (kein Feld in der Pickmap ausw\xE4hlen!)<li>Verwenden Sie Bearbeiten -> Zuf\xE4llig oben f\xFCllen<li>Wenn nach dem Prozentsatz gefragt wird, einfach OK dr\xFCcken.<li>W\xE4hlen Sie die "trees1" pickmap.<li>Benutzen Sie wieder zuf\xE4llig oben f\xFCllen, diesmal mit dem Wert 3.</ol>Sch\xF6n, nicht wahr? +tod.text.17=<html>Der Editor wurde unter Linux entwickelt, haupts\xE4chlich mit vim, Ant und <em>IntelliJ IDEA 6</em>.<p>JetBrains (<a href="http://www.jetbrains.com/">http://www.jetbrains.com/</a>) gaben uns eine kostenlose Lizenz f\xFCr IntelliJ IDEA. Vielen Dank, JetBrains!<br><img src="http://www.jetbrains.com/idea/opensource/img/banners/idea88x31_blue.gif" alt="JetBrains"> +tod.text.18=<html>You can easily make a false wall.<p>Change the Special attribute "blocking passage" to false or set <code>no_pass 0</code>. +tod.text.19=<html>The difference between an exit and a teleporter:<p>An exit always works while a teleporter needs a connection to be activated. +tod.text.20=<html>You can make anything glow (emit light), even mob.<p>Set the "glow radius" attribute (<code>glow_radius 1</code> for instance).<p>If you want to have a mob glow, be sure to set glow radius on the mob, not the spawn point. +tod.text.21=<html>To create a spawn point that spawns a mob, do this:<ol><li>Select "spawn_point" from the mobs Arch List.<li>Insert the spawn point.<li>Choose the mob you want to spawn from the mobs Arch List.<li>Use "Add Inv" to put the mob in the spawn point</ol>Done. +tod.text.22=<html>Pickmaps are an often underestimated feature. +tod.text.23=<html>The 10 most recently opened maps are quickly accessible.<p>Menu: <code>File -> Recent -> ...</code><br>Keyboard: <kbd>Alt-n</kbd> with n being a digit (1..9, 0) +tod.text.24=<html>To collect arches for your server, do this:<ol><li>Change the settings to not load arches from collection (<code>File -> Options, Global)<li>Restart the editor<li>Use <code>Resources -> Collect Arches<li>Run the install script of the server</ol> +tod.text.25=<html>How can you speed up the editor?<ul><li>Load arches from the collection<li>Use Linux<li>Use the latest Java version available<li>Use 32 Bit colour depth</ul> +tod.text.26=<html>The editor does not load all images at startup.<p>Instead, it loads images as needed.<p>This is called "lazy image loading". +tod.text.27=<html>Der Editor wurde unter Linux entwickelt, haupts\xE4chlich mit vim und Ant.<p>Zus\xE4tzlich wurden NetBeans 4.1, Eclipse 3.1 und <em>IntelliJ IDEA 5</em> verwendet.<p>JetBrains (<a href="http://www.jetbrains.com/">http://www.jetbrains.com/</a>) gaben uns eine kostenlose Lizenz f\xFCr IntelliJ IDEA.<br>Vielen Dank, JetBrains! +tod.text.28=<html>Many features have tooltips to help you.<p>Just hover the mouse over the thing you want to know about for a while. +tod.text.29=<html>To attach a map to other maps, you must save it first. +tod.text.30=<html>The editor runs even better when using Java 6.0 (Java2 1.6). +tod.text.31=<html>You should stick to the default map size (24\xD724).<br>That map size is also best for the server. +tod.text.32=<html>Beware when editing large maps. You might run out of memory.<br>Be sure to increase the heap size (-Xmx parameter) of Gridarta's Virtual Machine<br>When editing large maps (e.g. 240\xD7240). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-11 19:23:15
|
Revision: 647 http://svn.sourceforge.net/gridarta/?rev=647&view=rev Author: christianhujer Date: 2006-11-11 11:22:56 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Some ArchetypeParser unification. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java trunk/src/app/net/sf/gridarta/gameobject/Archetype.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-11-11 17:59:16 UTC (rev 646) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-11-11 19:22:56 UTC (rev 647) @@ -30,11 +30,10 @@ import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; -import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; +import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; @@ -54,7 +53,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ @SuppressWarnings({"HardcodedFileSeparator"}) -public final class ArchetypeParser implements net.sf.gridarta.gameobject.ArchetypeParser<GameObject> { +public final class ArchetypeParser extends AbstractArchetypeParser<GameObject> { /** Logger. */ private static final Logger log = Logger.getLogger(ArchetypeParser.class); @@ -168,295 +167,241 @@ } /** {@inheritDoc} */ - public void parseArchetypeFromStream(final BufferedReader in, final int index, final String fname) { - parseArchetypeFromStream(in, null, null, null, index, fname); - } - - /** {@inheritDoc} */ @Nullable - public GameObject parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject prototype, final String line, final String archName, int index, final String fname) { + public GameObject parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject prototype, final String line, final String archName, int index, final String fname) throws IOException { + // start with new clean GameObject instance + GameObject archetype; + GameObject archlast = null; + if (prototype == null) { + archetype = new GameObject(); + } else { + archetype = prototype.createClone(0, 0); + } + archetype.resetObjectText(); - //Open the file for reading - try { + String thisLine2; + if (line == null) { + thisLine2 = in.readLine(); + } else { + thisLine2 = line; // pre read "Object" from artifacts file loader + } - // start with new clean GameObject instance - GameObject archetype; - GameObject archlast = null; - if (prototype == null) { - archetype = new GameObject(); - } else { - archetype = prototype.createClone(0, 0); - } - archetype.resetObjectText(); + boolean msgflag = false; + boolean loreflag = false; + boolean animflag = false; + boolean parsearch = false; + boolean archmore = false; + String oldCat = "<xxx>"; + boolean isNewCategory = true; + GameObject firstArch = null; + String newCat = "no category info"; + int archmoreCount = 0; + while (thisLine2 != null) { + final String thisLine = thisLine2.trim(); - String thisLine2; - if (line == null) { + if (thisLine.startsWith("#")) { + // skip comments thisLine2 = in.readLine(); - } else { - thisLine2 = line; // pre read "Object" from artifacts file loader + continue; } - boolean msgflag = false; - boolean loreflag = false; - boolean animflag = false; - boolean parsearch = false; - boolean archmore = false; - String oldCat = "<xxx>"; - boolean isNewCategory = true; - GameObject firstArch = null; - String newCat = "no category info"; - int archmoreCount = 0; - while (thisLine2 != null) { - final String thisLine = thisLine2.trim(); + if (!parsearch) { - if (thisLine.startsWith("#")) { - // skip comments - thisLine2 = in.readLine(); - continue; - } + if (thisLine.startsWith("More")) { + if (firstArch == null) { + firstArch = archlast; + } + archmore = true; + } else if (thisLine.startsWith("Object")) { + if (archetype == null) { + archetype = new GameObject(); + } - if (!parsearch) { + parsearch = true; + if (!archmore) { + firstArch = null; + } - if (thisLine.startsWith("More")) { - if (firstArch == null) { - firstArch = archlast; + if (archName == null) { + archetype.setArchetypeName(thisLine.substring(7)); + } else { + archetype.setArchetypeName(archName); + } + } + } else { + if (msgflag) { + if (thisLine.startsWith("endmsg")) { + msgflag = false; + } else { + archetype.addMsgText(thisLine2 + "\n"); // thisLine2 allows leading whitespaces + } + } else if (animflag) { + if (thisLine.startsWith("mina")) { + try { + mainControl.getAnimationObjects().addAnimationObject(archetype.getArchetypeName(), archetype.getAnimText()); + } catch (final DuplicateAnimationException e) { + log.warn("Duplicate Animation " + archetype.getArchetypeName(), e); } - archmore = true; - } else if (thisLine.startsWith("Object")) { - if (archetype == null) { - archetype = new GameObject(); - } - parsearch = true; - if (!archmore) { - firstArch = null; - } - - if (archName == null) { - archetype.setArchetypeName(thisLine.substring(7)); - } else { - archetype.setArchetypeName(archName); - } + archetype.addObjectText("animation " + archetype.getArchetypeName()); + // here we must add this to AnimationObject + // and add Animation cmd here! + animflag = false; + } else { + archetype.addAnimText(thisLine + "\n"); } - } else { - if (msgflag) { - if (thisLine.startsWith("endmsg")) { - msgflag = false; - } else { - archetype.addMsgText(thisLine2 + "\n"); // thisLine2 allows leading whitespaces - } - } else if (animflag) { - if (thisLine.startsWith("mina")) { - try { - mainControl.getAnimationObjects().addAnimationObject(archetype.getArchetypeName(), archetype.getAnimText()); - } catch (final DuplicateAnimationException e) { - log.warn("Duplicate Animation " + archetype.getArchetypeName(), e); - } + } else if (loreflag) { + if (thisLine.startsWith("endlore")) { + loreflag = false; + } else { + archetype.addLoreText(thisLine + "\n"); + } + } else if (thisLine.startsWith("Object")) { + log.error("Find inventory Object in def arch: " + thisLine); + } else if (thisLine.startsWith("end")) { + //if (arch.getArchTypNr() == 0) { + if (log.isDebugEnabled()) { + log.debug("Arch " + archetype.getArchetypeName() + " has no type info!"); + } + //} + // we got full arch + parsearch = false; // we write this sucker - archetype.addObjectText("animation " + archetype.getArchetypeName()); - // here we must add this to AnimationObject - // and add Animation cmd here! - animflag = false; - } else { - archetype.addAnimText(thisLine + "\n"); - } - } else if (loreflag) { - if (thisLine.startsWith("endlore")) { - loreflag = false; - } else { - archetype.addLoreText(thisLine + "\n"); - } - } else if (thisLine.startsWith("Object")) { - log.error("Find inventory Object in def arch: " + thisLine); - } else if (thisLine.startsWith("end")) { - //if (arch.getArchTypNr() == 0) { - if (log.isDebugEnabled()) { - log.debug("Arch " + archetype.getArchetypeName() + " has no type info!"); - } - //} - // 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); + } else { + // add arch to the archpanel - only if it is not the map arch + if (!archetype.getArchetypeName().equals(STARTARCH_NAME)) { + if (!mainControl.getArchetypeSet().isLoadedFromArchive() || archName != null) { + // loading from individual files, so we simply add it to list + // ArchetypeSet.loadArchFromFiles() takes care of the panels + mainControl.addArchPanelArch(archetype.getArchetypeName(), index); + } else { + // loading from collected files, so we need process panels here + if (isNewCategory) { + String folder = newCat; // main folder of new category + if (newCat.indexOf("/") > 0) { + folder = newCat.substring(0, newCat.indexOf("/")); + } - if (firstArch != null) { - // add to head our x/y position so he can setup refmax - firstArch.addTailPart(archetype); - } else { - // add arch to the archpanel - only if it is not the map arch - if (!archetype.getArchetypeName().equals(STARTARCH_NAME)) { - if (!mainControl.getArchetypeSet().isLoadedFromArchive() || archName != null) { - // loading from individual files, so we simply add it to list - // ArchetypeSet.loadArchFromFiles() takes care of the panels - mainControl.addArchPanelArch(archetype.getArchetypeName(), index); - } else { - // loading from collected files, so we need process panels here - if (isNewCategory) { - String folder = newCat; // main folder of new category - if (newCat.indexOf("/") > 0) { - folder = newCat.substring(0, newCat.indexOf("/")); - } + if (!oldCat.startsWith(folder)) { + // an entire new panel must be opened + mainControl.addArchPanel(folder); + mainControl.addArchPanelCombo("show all"); + mainControl.addArchPanelCombo(folder); + index = 1; + } - if (!oldCat.startsWith(folder)) { - // an entire new panel must be opened - mainControl.addArchPanel(folder); - mainControl.addArchPanelCombo("show all"); - mainControl.addArchPanelCombo(folder); - index = 1; - } - - if (newCat.indexOf("/") > 0) { - folder = newCat.substring(newCat.indexOf("/") + 1); - if (newCat.startsWith(folder)) { - index = 1; // add to the base folder - } else if (!oldCat.endsWith(folder)) { - // a new JComboBox must be added - index = mainControl.addArchPanelCombo(folder); - } - } else { + if (newCat.indexOf("/") > 0) { + folder = newCat.substring(newCat.indexOf("/") + 1); + if (newCat.startsWith(folder)) { index = 1; // add to the base folder + } else if (!oldCat.endsWith(folder)) { + // a new JComboBox must be added + index = mainControl.addArchPanelCombo(folder); } - - isNewCategory = false; - oldCat = newCat; + } else { + index = 1; // add to the base folder } - mainControl.addArchPanelArch(archetype.getArchetypeName(), index); + + isNewCategory = false; + oldCat = newCat; } + mainControl.addArchPanelArch(archetype.getArchetypeName(), index); } } - postParseArchetype(archetype); - archetype.setIsArchetype(); - mainControl.getArchetypeSet().addArchetype(archetype); + } + postParseArchetype(archetype); + archetype.setIsArchetype(); + mainControl.getArchetypeSet().addArchetype(archetype); - archmore = false; // we assume this is last... but perhaps.. + archmore = false; // we assume this is last... but perhaps.. - // 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 - archetype.addObjectText(archetype.diffArchText(prototype.getObjectText(), true)); - return archetype; + // 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 + archetype.addObjectText(archetype.diffArchText(prototype.getObjectText(), true)); + return archetype; + } + archlast = archetype; + archetype = null; + } else { + if (thisLine.startsWith("msg")) { + msgflag = true; + } else if (thisLine.startsWith("animation")) { + archetype.addObjectText(thisLine); + } else if (thisLine.startsWith("anim_speed")) { + archetype.addObjectText(thisLine); + } else if (thisLine.startsWith("anim")) { + animflag = true; + } else if (thisLine.equals("lore")) { + loreflag = true; + } else if (thisLine.startsWith("visibility ")) { + if (log.isDebugEnabled()) { + log.debug("Remove visibility: " + archetype.getArchetypeName()); } - archlast = archetype; - archetype = null; - } else { - if (thisLine.startsWith("msg")) { - msgflag = true; - } else if (thisLine.startsWith("animation")) { + } else if (thisLine.startsWith("magicmap ")) { + if (log.isDebugEnabled()) { + log.debug("Remove magicmap: " + archetype.getArchetypeName()); + } + } else if (thisLine.startsWith("color_fg ")) { + if (log.isDebugEnabled()) { + log.debug("Remove color_fg: " + archetype.getArchetypeName()); + } + } else if (thisLine.startsWith("color_bg ")) { + if (log.isDebugEnabled()) { + log.debug("Remove color_bg: " + archetype.getArchetypeName()); + } + } else if (thisLine.startsWith("x ")) { + if (!archmore && !archetype.getArchetypeName().equals(STARTARCH_NAME)) { + log.warn("Find x cmd in single tile or head (add it to arch text): " + archetype.getArchetypeName()); archetype.addObjectText(thisLine); - } else if (thisLine.startsWith("anim_speed")) { + } + archetype.setMultiX(Integer.parseInt(thisLine.substring(2))); + } else if (thisLine.startsWith("y ")) { + if (!archmore && !archetype.getArchetypeName().equals(STARTARCH_NAME)) { + log.warn("Find y cmd in single tile or head (add it to arch text): " + archetype.getArchetypeName()); archetype.addObjectText(thisLine); - } else if (thisLine.startsWith("anim")) { - animflag = true; - } else if (thisLine.equals("lore")) { - loreflag = true; - } else if (thisLine.startsWith("visibility ")) { - if (log.isDebugEnabled()) { - log.debug("Remove visibility: " + archetype.getArchetypeName()); + } + archetype.setMultiY(Integer.parseInt(thisLine.substring(2))); + } else if (thisLine.startsWith("type ")) { + try { + final int i = Integer.parseInt(thisLine.substring(5)); + archetype.setArchTypNr(i); + if (i == 0) { + log.warn("Arch " + archetype.getArchetypeName() + " type number is zero. (" + thisLine.substring(5) + ")"); } - } else if (thisLine.startsWith("magicmap ")) { - if (log.isDebugEnabled()) { - log.debug("Remove magicmap: " + archetype.getArchetypeName()); + } catch (final Exception e) { + log.warn("Arch " + archetype.getArchetypeName() + " has a invalid type nr. (" + thisLine.substring(5) + ")"); + archetype.addObjectText(thisLine); + } + } else if (thisLine.startsWith("face ")) { + int x; + for (x = 4; x < thisLine.length(); x++) { + if (thisLine.charAt(x) != ' ') { + break; } - } else if (thisLine.startsWith("color_fg ")) { - if (log.isDebugEnabled()) { - log.debug("Remove color_fg: " + archetype.getArchetypeName()); - } - } else if (thisLine.startsWith("color_bg ")) { - if (log.isDebugEnabled()) { - log.debug("Remove color_bg: " + archetype.getArchetypeName()); - } - } else if (thisLine.startsWith("x ")) { - if (!archmore && !archetype.getArchetypeName().equals(STARTARCH_NAME)) { - log.warn("Find x cmd in single tile or head (add it to arch text): " + archetype.getArchetypeName()); - archetype.addObjectText(thisLine); - } - archetype.setMultiX(Integer.parseInt(thisLine.substring(2))); - } else if (thisLine.startsWith("y ")) { - if (!archmore && !archetype.getArchetypeName().equals(STARTARCH_NAME)) { - log.warn("Find y cmd in single tile or head (add it to arch text): " + archetype.getArchetypeName()); - archetype.addObjectText(thisLine); - } - archetype.setMultiY(Integer.parseInt(thisLine.substring(2))); - } else if (thisLine.startsWith("type ")) { - try { - final int i = Integer.parseInt(thisLine.substring(5)); - archetype.setArchTypNr(i); - if (i == 0) { - log.warn("Arch " + archetype.getArchetypeName() + " type number is zero. (" + thisLine.substring(5) + ")"); - } - } catch (final Exception e) { - log.warn("Arch " + archetype.getArchetypeName() + " has a invalid type nr. (" + thisLine.substring(5) + ")"); - archetype.addObjectText(thisLine); - } - } else if (thisLine.startsWith("face ")) { - int x; - for (x = 4; x < thisLine.length(); x++) { - if (thisLine.charAt(x) != ' ') { - break; - } - } - archetype.setFaceFlag(false); // we HAVE a face - archetype.setFaceName(thisLine.substring(x, thisLine.length())); - } else if (thisLine.startsWith("editor_folder ")) { - // the display category (= "folder" the arch belongs to) - newCat = thisLine.substring(14).trim(); - if (!newCat.equals(oldCat)) { - isNewCategory = true; // this arch has a new category - } } - archetype.addObjectText(thisLine); - if (log.isDebugEnabled()) { - log.debug("add String: " + thisLine); + archetype.setFaceFlag(false); // we HAVE a face + archetype.setFaceName(thisLine.substring(x, thisLine.length())); + } else if (thisLine.startsWith("editor_folder ")) { + // the display category (= "folder" the arch belongs to) + newCat = thisLine.substring(14).trim(); + if (!newCat.equals(oldCat)) { + isNewCategory = true; // this arch has a new category } } - } - thisLine2 = in.readLine(); - } // while loop ends here - } catch (final IOException e) { - log.error("Error: ", e); - } - return null; - } - - /** {@inheritDoc} */ - public void postParseArchetype(final GameObject archetype) { - final String text = archetype.getObjectText(); - archetype.resetObjectText(); - final int len = text.length(); - - // if no type was set, zero is taken - if (archetype.getArchTypNr() == GameObject.TYPE_UNSET) { - archetype.setArchTypNr(0); - } - - boolean scriptflag = false; - for (int i = 0, s = 0; i < len; i++) { - - if (text.charAt(i) == '\n') { - if (i - s > 0) { - if (scriptflag) { - archetype.addObjectText(text.substring(s, i)); - if (text.regionMatches(s, "end_script_", 0, 11)) { - scriptflag = false; - } - } else if (text.regionMatches(s, "start_script_", 0, 13)) { - archetype.addObjectText(text.substring(s, i)); - scriptflag = true; - } else if (text.regionMatches(s, "editable ", 0, 9)) { - archetype.setEditType(Integer.parseInt(text.substring(s + 9, i))); - } else if (text.regionMatches(s, "name ", 0, 5)) { - archetype.setObjName(text.substring(s + 5, i)); - } else { - archetype.addObjectText(text.substring(s, i)); + archetype.addObjectText(thisLine); + if (log.isDebugEnabled()) { + log.debug("add String: " + thisLine); } - } - s = i + 1; } - } - - // default arches don't get an editType (not worth the time) - // they get one assigned as soon as put on a map though. - archetype.setEditType(IGUIConstants.TILE_EDIT_NONE); + thisLine2 = in.readLine(); + } // while loop ends here + return null; } /** {@inheritDoc} */ @@ -520,44 +465,4 @@ } } - /** {@inheritDoc} */ - public void expandMulti(final GameObject gameObject, final List<GameObject> objects) { - // TODO: Couldn't we simply invoke archetype = gameObject.getArchetype() here? - final GameObject archetype = mainControl.getArchetype(gameObject.getArchetypeName()); - - // is it a multi head? - if (archetype != null && archetype.isMulti() && gameObject.getMultiRefCount() <= 1) { - // we have a multi head and need to insert his tail now - - // do insertion for all non-head parts of the multi - for (GameObject oldPart = archetype.getMultiNext(); oldPart != null; oldPart = oldPart.getMultiNext()) { - final GameObject newarch = oldPart.createArch(); - - gameObject.addTailPart(newarch); - objects.add(newarch); - - // set map position (x, y) - newarch.setMapX(gameObject.getMapX() + newarch.getMultiX()); - newarch.setMapY(gameObject.getMapY() + newarch.getMultiY()); - - // now attach the default arch and stuff - // (don't need edit type as we copy from head) - mainControl.getArchetypeParser().postParseGameObject(newarch, 0); - } - } - } - - /** {@inheritDoc} */ - public void sortTempList(final List<GameObject> objects) { - final Comparator<GameObject> sorter = new Comparator<GameObject>() { - /** {@inheritDoc} */ - public int compare(final GameObject o1, final GameObject o2) { - final boolean b1 = o1.isMulti(); - final boolean b2 = o2.isMulti(); - return b1 == b2 ? 0 : b2 ? -1 : 1; - } - }; - Collections.sort(objects, sorter); - } - } // class ArchetypeParser Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2006-11-11 17:59:16 UTC (rev 646) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2006-11-11 19:22:56 UTC (rev 647) @@ -26,7 +26,6 @@ package daieditor.gameobject; import daieditor.CMainControl; -import daieditor.IGUIConstants; import daieditor.MultiPositionData; import daieditor.io.PathManager; import java.io.BufferedReader; @@ -34,11 +33,9 @@ import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; -import static java.util.Collections.sort; -import java.util.Comparator; -import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import org.jetbrains.annotations.Nullable; @@ -51,7 +48,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ @SuppressWarnings({"HardcodedFileSeparator"}) -public final class ArchetypeParser implements net.sf.gridarta.gameobject.ArchetypeParser<GameObject> { +public final class ArchetypeParser extends AbstractArchetypeParser<GameObject> { /** Logger. */ private static final Logger log = Logger.getLogger("daieditor"); @@ -85,11 +82,6 @@ } /** {@inheritDoc} */ - public void parseArchetypeFromStream(final BufferedReader in, final int index, final String fname) throws IOException { - parseArchetypeFromStream(in, null, null, null, index, fname); - } - - /** {@inheritDoc} */ @Nullable @SuppressWarnings({"StringContatenationInLoop", "ObjectAllocationInLoop"}) public GameObject parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject prototype, @Nullable final String line, @Nullable final String archName, /* TODO: final*/ int index, final String fname) throws IOException { // start with new clean GameObject instance @@ -161,10 +153,10 @@ } parsearch = true; - if (archmore) { - // System.err.println("multi part object: part "+ archmore_count); - } else { + if (!archmore) { firstArch = null; + } else { + // System.err.println("multi part object: part "+ archmore_count); } if (archName == null) { @@ -396,49 +388,6 @@ } /** {@inheritDoc} */ - public void postParseArchetype(final GameObject archetype) { - final String text = archetype.getObjectText(); - archetype.resetObjectText(); - final int len = text.length(); - - // if no type was set, zero is taken - if (archetype.getArchTypNr() == GameObject.TYPE_UNSET) { - archetype.setArchTypNr(0); - } - - boolean scriptflag = false; - for (int i = 0, s = 0; i < len; i++) { - - if (text.charAt(i) == '\n') { - if (i - s > 0) { - if (scriptflag) { - archetype.addObjectText(text.substring(s, i)); - if (text.regionMatches(s, "end_script_", 0, 11)) { - scriptflag = false; - } - } else if (text.regionMatches(s, "start_script_", 0, 13)) { - archetype.addObjectText(text.substring(s, i)); - scriptflag = true; - } else if (text.regionMatches(s, "editable ", 0, 9)) { - archetype.setEditType(Integer.parseInt(text.substring(s + 9, i))); - } else if (text.regionMatches(s, "name ", 0, 5)) { - archetype.setObjName(text.substring(s + 5, i)); - } else { - archetype.addObjectText(text.substring(s, i)); - } - - } - s = i + 1; - } - } - - // default arches don't get an editType (not worth the time) - // they get one assigned as soon as put on a map though. - // TODO: This should be changed. - archetype.setEditType(IGUIConstants.TILE_EDIT_NONE); - } - - /** {@inheritDoc} */ public void postParseGameObject(final GameObject gameObject, final int editType) { if (!gameObject.hasArchetype()) { return; @@ -503,50 +452,6 @@ } } - /** {@inheritDoc} */ - public void expandMulti(final GameObject gameObject, final List<GameObject> objects) { - - if (gameObject.isInContainer()) { - return; - } - - final GameObject archetype = gameObject.getArchetype(); // default arch - - // is it a multi head? - if (archetype != null && archetype.isMulti() && gameObject.getMultiRefCount() <= 1) { - // we have a multi head and need to insert his tail now - - // do insertion for all non-head parts of the multi - for (GameObject oldPart = archetype.getMultiNext(); oldPart != null; oldPart = oldPart.getMultiNext()) { - final GameObject newarch = oldPart.createArch(); - - gameObject.addTailPart(newarch); - objects.add(newarch); - - // set map position (x, y) - newarch.setMapX(gameObject.getMapX() + newarch.getMultiX()); - newarch.setMapY(gameObject.getMapY() + newarch.getMultiY()); - - // now attach the default arch and stuff - // (don't need edit type as we copy from head) - postParseGameObject(newarch, 0); - } - } - } - - /** {@inheritDoc} */ - public void sortTempList(final List<GameObject> objects) { - final Comparator<GameObject> sorter = new Comparator<GameObject>() { - /** {@inheritDoc} */ - public int compare(final GameObject o1, final GameObject o2) { - final boolean b1 = o1.isMulti(); - final boolean b2 = o2.isMulti(); - return b1 == b2 ? 0 : b2 ? -1 : 1; - } - }; - sort(objects, sorter); - } - /** * 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 Added: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java 2006-11-11 19:22:56 UTC (rev 647) @@ -0,0 +1,117 @@ +package net.sf.gridarta.gameobject; + +import java.io.BufferedReader; +import java.io.IOException; +import java.util.Comparator; +import java.util.List; +import java.util.Collections; +import org.apache.log4j.Logger; + +/** + * Abstract base implementation of {@link net.sf.gridarta.gameobject.ArchetypeParser}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class AbstractArchetypeParser<G extends GameObject<G>> implements ArchetypeParser<G> { + + /** Logger. */ + private static final Logger log = Logger.getLogger(AbstractArchetypeParser.class); + + /** + * Create an AbstractArchetypeParser. + */ + protected AbstractArchetypeParser() { + } + + /** {@inheritDoc} */ + public void parseArchetypeFromStream(final BufferedReader in, final int index, final String fname) throws IOException { + parseArchetypeFromStream(in, null, null, null, index, fname); + } + + /** {@inheritDoc} */ + public void postParseArchetype(final G archetype) { + final String text = archetype.getObjectText(); + archetype.resetObjectText(); + final int len = text.length(); + + // if no type was set, zero is taken + if (archetype.getArchTypNr() == GameObject.TYPE_UNSET) { + archetype.setArchTypNr(0); + } + + boolean scriptflag = false; + for (int i = 0, s = 0; i < len; i++) { + + if (text.charAt(i) == '\n') { + if (i - s > 0) { + if (scriptflag) { + archetype.addObjectText(text.substring(s, i)); + if (text.regionMatches(s, "end_script_", 0, 11)) { + scriptflag = false; + } + } else if (text.regionMatches(s, "start_script_", 0, 13)) { + archetype.addObjectText(text.substring(s, i)); + scriptflag = true; + } else if (text.regionMatches(s, "editable ", 0, 9)) { + archetype.setEditType(Integer.parseInt(text.substring(s + 9, i))); + } else if (text.regionMatches(s, "name ", 0, 5)) { + archetype.setObjName(text.substring(s + 5, i)); + } else { + archetype.addObjectText(text.substring(s, i)); + } + + } + s = i + 1; + } + } + + // default arches don't get an editType (not worth the time) + // they get one assigned as soon as put on a map though. + // TODO: This should be changed. + archetype.setEditType(0x10000 /*IGUIConstants.TILE_EDIT_NONE*/); + } + + /** {@inheritDoc} */ + public void expandMulti(final G gameObject, final List<G> objects) { + if (gameObject.isInContainer()) { + log.warn("Multipart expansion for a GameObject inside a container requested."); + return; + } + + final G archetype = gameObject.getArchetype(); + + // is it a multi head? + if (archetype != null && archetype.isMulti() && gameObject.getMultiRefCount() <= 1) { + // we have a multi head and need to insert his tail now + + // do insertion for all non-head parts of the multi + for (G oldPart = archetype.getMultiNext(); oldPart != null; oldPart = oldPart.getMultiNext()) { + final G newarch = oldPart.createArch(); + + gameObject.addTailPart(newarch); + objects.add(newarch); + + // set map position (x, y) + newarch.setMapX(gameObject.getMapX() + newarch.getMultiX()); + newarch.setMapY(gameObject.getMapY() + newarch.getMultiY()); + + // now attach the default arch and stuff + // (don't need edit type as we copy from head) + postParseGameObject(newarch, 0); + } + } + } + + /** {@inheritDoc} */ + public void sortTempList(final List<G> objects) { + final Comparator<G> sorter = new Comparator<G>() { + /** {@inheritDoc} */ + public int compare(final G o1, final G o2) { + final boolean b1 = o1.isMulti(); + final boolean b2 = o2.isMulti(); + return b1 == b2 ? 0 : b2 ? -1 : 1; + } + }; + Collections.sort(objects, sorter); + } + +} // class AbstractArchetypeParser Property changes on: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeParser.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gameobject/Archetype.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2006-11-11 17:59:16 UTC (rev 646) +++ trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2006-11-11 19:22:56 UTC (rev 647) @@ -118,6 +118,12 @@ int getArchTypNr(); /** + * Sets the type number of this Archetype. + * @param typNr Type number of this Archetype. + */ + void setArchTypNr(int typNr); + + /** * CFEditor only: Returns the name of the face. * @return The name of the face of this Archetype. * @deprecated compatibility method Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-11-11 17:59:16 UTC (rev 646) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-11-11 19:22:56 UTC (rev 647) @@ -659,6 +659,8 @@ */ public abstract G createArch(); + public abstract void addTailPart(final G tail); + /** * Return the head part of a multi-part object. For single-part objects it * is the object itself. @@ -681,6 +683,13 @@ @Nullable public abstract G getMultiNext(); /** + * Returns number of parts for multipart heads. (*.getMultiRefCount() > 0) + * is often used as way to find multi-heads. + * @return number of parts + */ + public abstract int getMultiRefCount(); + + /** * {@inheritDoc} * Implementations must not provide substitute clones of a different class. * I.e. implementations MUST return an object created by super.clone() or their own constructor. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-11 17:59:29
|
Revision: 646 http://svn.sourceforge.net/gridarta/?rev=646&view=rev Author: christianhujer Date: 2006-11-11 09:59:16 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Added FAQ. Modified Paths: -------------- trunk/FAQ trunk/build.xml trunk/src/doc/start.xhtml Added Paths: ----------- trunk/src/doc/faq.xhtml Modified: trunk/FAQ =================================================================== --- trunk/FAQ 2006-11-11 17:29:44 UTC (rev 645) +++ trunk/FAQ 2006-11-11 17:59:16 UTC (rev 646) @@ -1,4 +1,14 @@ -FAQ ---- +Gridarta FAQ -No faq yet. +Note: This file is auto-generated from src/doc/faq.xhtml using src/doc/faq2txt.xslt. + If you want to change the faq, please make your changes in src/doc/faq.xhtml. + + +Question: +Will featurexyzbe implemented in Gridarta? + +Answer: +Please use ourfeature request tracker <https://sourceforge.net/tracker/?group_id=166996&atid=841185>. +Also take a look at ourTODO list <http://gridarta.sourceforge.net/dev/todo>. + + Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2006-11-11 17:29:44 UTC (rev 645) +++ trunk/build.xml 2006-11-11 17:59:16 UTC (rev 646) @@ -173,6 +173,19 @@ <xmlcatalog refid="commonDTDs" /> <transformation stylesheet="src/doc/xhtml2html.xslt" /> </megaxslt> + <megaxslt + srcdir="src/doc" + destdir="." + includes="faq.xhtml" + validatesource="true" + validatedest="false" + ending="" + transformerFactoryImplementationClassName="net.sf.saxon.TransformerFactoryImpl" + > + <xmlcatalog refid="commonDTDs" /> + <transformation stylesheet="src/doc/faq2txt.xslt" /> + </megaxslt> + <copy file="faq" tofile="FAQ" /> <copy todir="dest/doc" > Added: trunk/src/doc/faq.xhtml =================================================================== --- trunk/src/doc/faq.xhtml (rev 0) +++ trunk/src/doc/faq.xhtml 2006-11-11 17:59:16 UTC (rev 646) @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- $Id: start.xhtml,v 1.12 2006/03/29 22:20:33 christianhujer Exp $ --> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de"> + <head> + <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" /> + <meta name="Date" content="$Date$" /> + <title>Gridarta FAQ</title> + </head> + <body> + <h1>Gridarta FAQ</h1> + <dl> + <dt>Will feature <var>xyz</var> be implemented in Gridarta?</dt> + <dd> + Please use our <a href="https://sourceforge.net/tracker/?group_id=166996&atid=841185">feature request tracker</a>. + <p/> + Also take a look at our <a href="http://gridarta.sourceforge.net/dev/todo">TODO list</a>. + </dd> + </dl> + </body> +</html> Property changes on: trunk/src/doc/faq.xhtml ___________________________________________________________________ Name: svn:mime-type + text/xml Name: svn:keywords + Date Name: svn:eol-style + LF Modified: trunk/src/doc/start.xhtml =================================================================== --- trunk/src/doc/start.xhtml 2006-11-11 17:29:44 UTC (rev 645) +++ trunk/src/doc/start.xhtml 2006-11-11 17:59:16 UTC (rev 646) @@ -38,6 +38,7 @@ <h2>Gridarta Documentation</h2> <ul> <li><a href="news/">Gridarta Project News</a></li> + <li><a href="faq">Gridarta FAQ</a> (Frequently Asked Questions)</li> <li><a href="dev/">Gridarta Developer Documentation</a> Information for Gridarta Developers</li> <li><a href="subversion">Accessing Gridarta's Subversion Repository</a></li> <li><a href="history">History of Gridarta</a></li> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-11 17:30:35
|
Revision: 645 http://svn.sourceforge.net/gridarta/?rev=645&view=rev Author: christianhujer Date: 2006-11-11 09:29:44 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Improved naming of map i/o classes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CPickmapPanel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CPickmapPanel.java Added Paths: ----------- trunk/crossfire/src/cfeditor/io/CMapReader.java trunk/crossfire/src/cfeditor/io/CMapWriter.java trunk/daimonin/src/daieditor/io/CMapReader.java trunk/daimonin/src/daieditor/io/CMapWriter.java trunk/src/app/net/sf/gridarta/io/AbstractMapReader.java trunk/src/app/net/sf/gridarta/io/AbstractMapWriter.java trunk/src/app/net/sf/gridarta/io/MapReader.java trunk/src/app/net/sf/gridarta/io/MapWriter.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/io/CMapFileDecode.java trunk/crossfire/src/cfeditor/io/CMapFileEncode.java trunk/daimonin/src/daieditor/io/CMapFileDecode.java trunk/daimonin/src/daieditor/io/CMapFileEncode.java trunk/src/app/net/sf/gridarta/io/AbstractMapFileDecode.java trunk/src/app/net/sf/gridarta/io/AbstractMapFileEncode.java trunk/src/app/net/sf/gridarta/io/MapFileDecode.java trunk/src/app/net/sf/gridarta/io/MapFileEncode.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-11 17:24:41 UTC (rev 644) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-11 17:29:44 UTC (rev 645) @@ -28,8 +28,8 @@ import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; import cfeditor.gameobject.anim.AnimationObjects; -import cfeditor.io.CMapFileDecode; -import cfeditor.io.CMapFileEncode; +import cfeditor.io.CMapReader; +import cfeditor.io.CMapWriter; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import cfeditor.map.MapModel; @@ -867,7 +867,7 @@ final List<GameObject> objects; final MapArchObject maparch; try { - final CMapFileDecode decoder = new CMapFileDecode(file); + final CMapReader decoder = new CMapReader(file); objects = decoder.decodeMapFile(); // parse mapfile maparch = decoder.getMapArch(); // get map arch } catch (final IOException e) { @@ -925,7 +925,7 @@ public void encodeMapFile(@NotNull final File file, final MapModel mapModel) { final String fname = file.getAbsolutePath(); try { - final CMapFileEncode mapFileEncoder = new CMapFileEncode(file); + final CMapWriter mapFileEncoder = new CMapWriter(file); try { mapFileEncoder.encodeMapFile(mapModel); } finally { Modified: trunk/crossfire/src/cfeditor/CPickmapPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CPickmapPanel.java 2006-11-11 17:24:41 UTC (rev 644) +++ trunk/crossfire/src/cfeditor/CPickmapPanel.java 2006-11-11 17:29:44 UTC (rev 645) @@ -25,7 +25,7 @@ package cfeditor; import cfeditor.gameobject.GameObject; -import cfeditor.io.CMapFileDecode; +import cfeditor.io.CMapReader; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import java.io.File; @@ -135,7 +135,7 @@ final MapArchObject maparch; try { - final CMapFileDecode decoder = new CMapFileDecode(mapFile); + final CMapReader decoder = new CMapReader(mapFile); final List<GameObject> objects = decoder.decodeMapFile(); // parse mapfile maparch = decoder.getMapArch(); // get map arch Deleted: trunk/crossfire/src/cfeditor/io/CMapFileDecode.java =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapFileDecode.java 2006-11-11 17:24:41 UTC (rev 644) +++ trunk/crossfire/src/cfeditor/io/CMapFileDecode.java 2006-11-11 17:29:44 UTC (rev 645) @@ -1,239 +0,0 @@ -/* - * Crossfire Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package cfeditor.io; - -import cfeditor.gameobject.GameObject; -import cfeditor.map.MapArchObject; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.List; -import net.sf.gridarta.io.AbstractMapFileDecode; -import org.apache.log4j.Logger; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * A MapFileDecoder reads a map file and provides access to the information read from the map file. - * This class handles the reading of a mapfile and parsing the data - * into a list of ArchObjects. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class CMapFileDecode extends AbstractMapFileDecode<GameObject, MapArchObject> { - - private static final Logger log = Logger.getLogger(CMapFileDecode.class); - - /** - * The maximum x position of all data read from the file. - * It's used to automatically expand a map to the size of its contents in case of a map with wrongly set size. - */ - private int maxxlen; - - /** - * The maximum y position of all data read from the file. - * It's used to automatically expand a map to the size of its contents in case of a map with wrongly set size. - */ - private int maxylen; - - /** - * Open a resource for reading it as a map. - * @param uri URI of resource to open. - * @throws FileNotFoundException in case the resource was not found. - */ - public CMapFileDecode(final String uri) throws FileNotFoundException { - super(uri); - } - - /** - * Open a file for reading it as a map. - * @param file File to open. - * @throws FileNotFoundException in case the file was not found. - */ - public CMapFileDecode(final File file) throws FileNotFoundException { - super(file); - } - - /** {@inheritDoc} */ - protected MapArchObject createMapArchObject() { - return new MapArchObject(); - } - - /** - * Loading a map from the given mapfile. - * This method returns a list of GameObjects. - * @return first <code>GameObject</code> in the list - * @throws FileNotFoundException in case the requested map file was not found - * @throws IOException in case the file couldn't be read or is in wrong format - * @todo create a separate exception for the wrong format - */ - @NotNull public List<GameObject> decodeMapFile() throws IOException { - final List<GameObject> objects = super.decodeMapFile(); - // finally... here we go - // last action: if the map is bigger than the specified size in - // the maparch, we set the true size: the maxxlen/maxylen counters. - maparch.ensureMapSize(maxxlen + 1, maxylen + 1); - - return objects; // return first arch of the list - } - - /** - * Our recursive accessible arch reader. - * <p/> - * WARNING: this implementation should fail with multi head settings - * if there are multi part items in the inventory (but this is not yet - * included in CF!) - * @param thisLine first line of text, belonging to this new arch - * @return the new parsed <code>GameObject</code> - * @throws IOException when an I/O-error occured during file reading - * @fixme I'm too long, make me shorter. - * @todo Attributes not relevant during map parsing shouldn't be evaluated here, but in GameObject / ArchetypeParser instead. - * @todo Convince crossfire people of removing "More" as it seems to be pointless now. - * @todo Find out whether effectively also trimming msg contents didn't break anything. - */ - // Note for programmers from Daimonin: Crossfire still has to support "More" which was used for multipart objects in the past. - @Nullable protected GameObject readArch(String thisLine) throws IOException { - boolean msgflag = false; - boolean archflag = false; - boolean archmore = false; - GameObject gameObject = null; - do { - thisLine = thisLine.trim(); - - if (!archflag) { - if (thisLine.startsWith("More")) { - // All arches started with "More" are ignored. We load only - // the heads and expand them according to the defaults. - archmore = true; - } else // format violation for better diff - if (thisLine.startsWith("arch ")) { - archflag = true; // from now on we are inside an arch - - if (!archmore) { - gameObject = new GameObject(); // create a new instance - gameObject.setArchetypeName(thisLine.substring(5).trim()); - } - } - } else if (!archmore) { - // here we are inside of an arch object (but not "More")... - if (msgflag) { - if (thisLine.startsWith("endmsg")) { - msgflag = false; - } else { - gameObject.addMsgText(thisLine + '\n'); - } - } else if (thisLine.startsWith("arch ")) { - // ok, we had a full arch... don't care here about map or object - // now we test for a new arch - thats stuf in inventory - // or the end... thats the end of this shit - if (log.isDebugEnabled()) { - log.debug("GO INVENTORY: " + gameObject + " - " + thisLine); - } - gameObject.addLast(readArch(thisLine)); - if (log.isDebugEnabled()) { - log.debug("GO INVENTORY2: " + gameObject + " - " + thisLine); - } - } else if (thisLine.equals("end")) { - objects.add(gameObject); - archflag = false; - archmore = false; - - if (log.isDebugEnabled()) { - log.debug("LEAVE!: " + gameObject + " - " + thisLine); - } - return gameObject; - } else if (thisLine.startsWith("msg")) { - // gameObject.addArchText(thisLine + "\n"); - gameObject.addMsgText(""); // this init the msg text buffer - // in the case of msg/endmsg - // with no content to overrule def msg - msgflag = true; - // this is a MUST, because we overrule "anim" test - } else if (thisLine.startsWith("animation")) { - gameObject.addObjectText(thisLine); - } else if (thisLine.startsWith("anim_speed")) { - gameObject.addObjectText(thisLine); - } else if (thisLine.startsWith("event_")) { - // here's something about a scripted event - final int i = thisLine.indexOf("_plugin"); - final int k = thisLine.indexOf("_options"); - final int space = thisLine.indexOf(" "); - if (space > 0) { - if (i > 0) { - // expecting: "event_type_plugin Name" - final String type = thisLine.substring(6, i); - final String plname = thisLine.substring(space + 1).trim(); - gameObject.addEventPlugin(type, plname); - } else if (k > 0) { - // expecting: "event_type_options Name" - final String type = thisLine.substring(6, k); - final String eventopt = thisLine.substring(space + 1).trim(); - gameObject.addEventOptions(type, eventopt); - } else { - // expecting: "event_type filepath" - final String type = thisLine.substring(6, space); - final String path = thisLine.substring(space + 1).trim(); - gameObject.addEventScript(type, path); - } - } else { - log.warn("Arch " + gameObject.getArchetypeName() + " has incorrect event code '" + thisLine + "'"); - gameObject.addObjectText(thisLine); // keep line, it might have a meaning after all - } - } else if (thisLine.startsWith("x ")) { - final int temp = Integer.parseInt(thisLine.substring(2)); - if (temp > maxxlen) { - maxxlen = temp; - } - gameObject.setMapX(temp); - } else if (thisLine.startsWith("y ")) { - final int temp = Integer.parseInt(thisLine.substring(2)); - if (temp > maxylen) { - maxylen = temp; - } - gameObject.setMapY(temp); - } else if (thisLine.startsWith("type ")) { - // Arches in maps can override their default arch's type - gameObject.setArchTypNr(Integer.parseInt(thisLine.substring(5))); - // don't load it into the archtext! (why?) - } else if (thisLine.startsWith("face ")) { - gameObject.setFaceFlag(false); - gameObject.setFaceName(thisLine.substring(5).trim()); - } else { - gameObject.addObjectText(thisLine); - } - } else { - // We are in a multipart tail arch ("more"), so we skip it: - if (thisLine.regionMatches(0, "end", 0, 3)) { - archflag = false; - archmore = false; - } - } - } while ((thisLine = readLine()) != null); - - return null; // this happens when the file end is reached - } - -} // class CMapFileDecode Deleted: trunk/crossfire/src/cfeditor/io/CMapFileEncode.java =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapFileEncode.java 2006-11-11 17:24:41 UTC (rev 644) +++ trunk/crossfire/src/cfeditor/io/CMapFileEncode.java 2006-11-11 17:29:44 UTC (rev 645) @@ -1,476 +0,0 @@ -/* - * Crossfire Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package cfeditor.io; - -import cfeditor.gameobject.GameObject; -import cfeditor.map.MapArchObject; -import cfeditor.map.MapModel; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.StringReader; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Map; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.io.AbstractMapFileEncode; -import org.apache.log4j.Logger; -import org.jetbrains.annotations.NotNull; - -/** - * The <code>CMapFileEncode</code> is used to write a map to a file. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class CMapFileEncode extends AbstractMapFileEncode<GameObject, MapArchObject, MapModel> { - - private static final Logger log = Logger.getLogger(CMapFileEncode.class); - - /** - * Create a CMapFileEncode instance. - * @param file File to open. - * @throws FileNotFoundException in case the file couldn't be opened for writing - */ - public CMapFileEncode(@NotNull final File file) throws FileNotFoundException { - super(file); - } - - /** - * Writes a single GameObject. - * @param gameObject <code>GameObject</code> to be written into the map - * @param x X position of gameObject (0 if <var>gameObject</var> is inside an inventory) - * @param y Y position of gameObject (0 if <var>gameObject</var> is inside an inventory) - * @throws IOException in case of I/O problems - */ - protected void writeGameObject(final GameObject gameObject, final int x, final int y) throws IOException { - final Archetype<GameObject> archetype = gameObject.getArchetype(); - - // Collect all fields to write. - final Map<String, String> fields = new HashMap<String, String>(); // String key -> String value - - final String name = gameObject.getObjName(); - if (name != null) { - fields.put("name", name); - } - - final String face = gameObject.getFaceName(); - if (face != null) { - fields.put("face", face); - } - - if (gameObject.isScripted()) { - final String events = gameObject.getMapArchEventData(); - if (!events.equals("")) { - final String[] tmp = events.split("\n"); - for (final String aTmp : tmp) { - final String[] line = aTmp.split(" +", 2); - if (line.length != 2) { - log.warn("writeMapArch: ignoring invalid event line: " + aTmp); - } else { - fields.put(line[0], line[1]); - } - } - } - } - - if (gameObject.getMsgText() != null && !gameObject.getMsgText().trim().equals((archetype == null || archetype.getMsgText() == null) ? "" : archetype.getMsgText().trim())) { - String msg = ""; - if (gameObject.getMsgText().trim().length() > 0) { - msg = gameObject.getMsgText(); - if (!msg.endsWith("\n")) { - msg += "\n"; - } - } - fields.put("msg", msg + "endmsg"); - } - - if (archetype != null && gameObject.getArchTypNr() != archetype.getArchTypNr()) { - // this arch has special type - if (gameObject.getObjectText().indexOf("type ") >= 0) { - // oh oh - there might also be a type in the archtext which - // is conflicting. remove the type from the archtext - - // open a reading stream for the archText - final StringReader sread = new StringReader(gameObject.getObjectText()); - final BufferedReader sstream = new BufferedReader(sread); - String newArchtext = ""; - - try { - for (String line; (line = sstream.readLine()) != null && line.length() > 0;) { - line = line.trim(); - - if (line.startsWith("type ")) { - // ommit this line - } else { - newArchtext += line + "\n"; // append this line - } - } - - // close streams - sstream.close(); - sread.close(); - - if (newArchtext.trim().length() == 0) { - gameObject.setObjectText(""); - } else { - gameObject.setObjectText(newArchtext.trim() + "\n"); - } - } catch (final IOException e) { - log.error("getSyntaxErrors: Cannot close StringReader"); - } - } - - // now append the type to the archtext - fields.put("type", Integer.toString(gameObject.getArchTypNr())); - } - - final String text = gameObject.getObjectText(); - if (!text.equals("")) { - final String[] tmp = text.split("\n"); - for (final String aTmp : tmp) { - final String[] line = aTmp.split(" +", 2); - if (line.length != 2) { - log.warn("writeMapArch: ignoring invalid arch line: " + aTmp); - } else { - fields.put(line[0], line[1]); - } - } - } - - // map coordinates only belong into map arches (not inventory arches) - if (x != 0) { - fields.put("x", Integer.toString(x)); - } - if (y != 0) { - fields.put("y", Integer.toString(y)); - } - - // Sort fields to match server/crossedit order. - final String[] keys = (String[]) fields.keySet().toArray(new String[0]); - Arrays.sort(keys, keyOrderComparator); - - // Actually write the fields. - append("arch " + gameObject.getArchetypeName() + "\n"); - for (int i = 0; i < keys.length; i++) { - final String value = (String) fields.get(keys[i]); - if (value != null) { - final String key = keys[i]; - if (key.equals("msg") || key.equals("lore")) { - append(key + "\n" + value + "\n"); - } else { - append(key + " " + value + "\n"); - } - } - } - - for (final GameObject inventoryItem : gameObject) { - writeGameObject(inventoryItem, 0, 0); - } - - append("end\n"); - } - - /** - * Comparator to compare two object fields. The comparator sorts the fields - * in the order in which they should be written to disk. - */ - private static final Comparator<String> keyOrderComparator = new Comparator<String>() { - - /** {@inheritDoc} */ - public int compare(final String o1, final String o2) { - final Integer i1 = keys.get(o1); - final Integer i2 = keys.get(o2); - final int v1 = i1 == null ? Integer.MAX_VALUE : i1.intValue(); - final int v2 = i2 == null ? Integer.MAX_VALUE : i2.intValue(); - if (v1 < v2) { - return -1; - } - if (v1 > v2) { - return +1; - } - assert v1 == v2; - return 0; - } - }; - - /** - * Determines the field order when writing objects to a file. The key is - * the field name, the value is an Integer that describes the order. Lower - * values are written first. - */ - private static final Map<String, Integer> keys = new HashMap<String, Integer>(); - - /* - * Initialize {@link keys} array. - * @todo this information should be read from a file. - */ - static { - addKey("name"); - addKey("name_pl"); - addKey("custom_name"); - addKey("title"); - addKey("race"); - addKey("slaying"); - addKey("skill"); - addKey("msg"); - addKey("lore"); - addKey("other_arch"); - addKey("face"); - addKey("animation"); - addKey("is_animated"); - addKey("Str"); - addKey("Dex"); - addKey("Con"); - addKey("Wis"); - addKey("Pow"); - addKey("Cha"); - addKey("Int"); - addKey("hp"); - addKey("maxhp"); - addKey("sp"); - addKey("maxsp"); - addKey("grace"); - addKey("maxgrace"); - addKey("exp"); - addKey("perm_exp"); - addKey("expmul"); - addKey("food"); - addKey("dam"); - addKey("luck"); - addKey("wc"); - addKey("ac"); - addKey("x"); - addKey("y"); - addKey("speed"); - addKey("speed_left"); - addKey("move_state"); - addKey("attack_movement"); - addKey("nrof"); - addKey("level"); - addKey("direction"); - addKey("type"); - addKey("subtype"); - addKey("attacktype"); - addKey("resist_physical"); - addKey("resist_magic"); - addKey("resist_fire"); - addKey("resist_electricity"); - addKey("resist_cold"); - addKey("resist_confusion"); - addKey("resist_acid"); - addKey("resist_drain"); - addKey("resist_weaponmagic"); - addKey("resist_ghosthit"); - addKey("resist_poison"); - addKey("resist_slow"); - addKey("resist_paralyze"); - addKey("resist_turn_undead"); - addKey("resist_fear"); - addKey("resist_cancellation"); - addKey("resist_deplete"); - addKey("resist_death"); - addKey("resist_chaos"); - addKey("resist_counterspell"); - addKey("resist_godpower"); - addKey("resist_holyword"); - addKey("resist_blind"); - addKey("resist_internal"); - addKey("resist_life_stealing"); - addKey("resist_disease"); - addKey("path_attuned"); - addKey("path_repelled"); - addKey("path_denied"); - addKey("material"); - addKey("materialname"); - addKey("value"); - addKey("carrying"); - addKey("weight"); - addKey("invisible"); - addKey("state"); - addKey("magic"); - addKey("last_heal"); - addKey("last_sp"); - addKey("last_grace"); - addKey("last_eat"); - addKey("connected"); - addKey("glow_radius"); - addKey("randomitems"); - addKey("npc_status"); - addKey("npc_program"); - addKey("run_away"); - addKey("pick_up"); - addKey("container"); - addKey("will_apply"); - addKey("smoothlevel"); - addKey("map_layer"); - addKey("current_weapon_script"); - addKey("weapontype"); - addKey("tooltype"); - addKey("elevation"); - addKey("client_type"); - addKey("item_power"); - addKey("duration"); - addKey("range"); - addKey("range_modifier"); - addKey("duration_modifier"); - addKey("dam_modifier"); - addKey("gen_sp_armour"); - addKey("move_type"); - addKey("move_block"); - addKey("move_allow"); - addKey("move_on"); - addKey("move_off"); - addKey("move_slow"); - addKey("move_slow_penalty"); - addKey("alive"); - addKey("wiz"); - addKey("was_wiz"); - addKey("applied"); - addKey("unpaid"); - addKey("can_use_shield"); - addKey("no_pick"); - addKey("walk_on"); - addKey("no_pass"); - addKey("is_animated"); - addKey("slow_move"); - addKey("flying"); - addKey("monster"); - addKey("friendly"); - addKey("generator"); - addKey("is_thrown"); - addKey("auto_apply"); - addKey("treasure"); - addKey("player sold"); - addKey("see_invisible"); - addKey("can_roll"); - addKey("overlay_floor"); - addKey("is_turnable"); - addKey("walk_off"); - addKey("fly_on"); - addKey("fly_off"); - addKey("is_used_up"); - addKey("identified"); - addKey("reflecting"); - addKey("changing"); - addKey("splitting"); - addKey("hitback"); - addKey("startequip"); - addKey("blocksview"); - addKey("undead"); - addKey("scared"); - addKey("unaggressive"); - addKey("reflect_missile"); - addKey("reflect_spell"); - addKey("no_magic"); - addKey("no_fix_player"); - addKey("is_lightable"); - addKey("tear_down"); - addKey("run_away"); - addKey("pass_thru"); - addKey("can_pass_thru"); - addKey("pick_up"); - addKey("unique"); - addKey("no_drop"); - addKey("wizcast"); - addKey("can_cast_spell"); - addKey("can_use_scroll"); - addKey("can_use_range"); - addKey("can_use_bow"); - addKey("can_use_armour"); - addKey("can_use_weapon"); - addKey("can_use_ring"); - addKey("has_ready_range"); - addKey("has_ready_bow"); - addKey("xrays"); - addKey("is_floor"); - addKey("lifesave"); - addKey("no_strength"); - addKey("sleep"); - addKey("stand_still"); - addKey("random_move"); - addKey("only_attack"); - addKey("confused"); - addKey("stealth"); - addKey("cursed"); - addKey("damned"); - addKey("see_anywhere"); - addKey("known_magical"); - addKey("known_cursed"); - addKey("can_use_skill"); - addKey("been_applied"); - addKey("has_ready_scroll"); - addKey("can_use_rod"); - addKey("can_use_horn"); - addKey("make_invisible"); - addKey("inv_locked"); - addKey("is_wooded"); - addKey("is_hilly"); - addKey("has_ready_skill"); - addKey("has_ready_weapon"); - addKey("no_skill_ident"); - addKey("is_blind"); - addKey("can_see_in_dark"); - addKey("is_cauldron"); - addKey("is_dust"); - addKey("no_steal"); - addKey("one_hit"); - addKey("berserk"); - addKey("neutral"); - addKey("no_attack"); - addKey("no_damage"); - addKey("activate_on_push"); - addKey("activate_on_release"); - addKey("is_water"); - addKey("use_content_on_gen"); - addKey("is_buildable"); - addKey("body_range"); - addKey("body_arm"); - addKey("body_torso"); - addKey("body_head"); - addKey("body_neck"); - addKey("body_skill"); - addKey("body_finger"); - addKey("body_shoulder"); - addKey("body_foot"); - addKey("body_hand"); - addKey("body_wrist"); - addKey("body_waist"); - } - - /** The next key added via {@link #addKey(String)} is assigned this id. */ - private static int idKey = 1; - - /** - * Add a new key to {@link #keys}. The order in which the keys are added is - * the order in which the objects fields are written out. - */ - private static void addKey(final String key) { - keys.put(key, idKey++); - } - -} // class CMapFileEncode Copied: trunk/crossfire/src/cfeditor/io/CMapReader.java (from rev 644, trunk/crossfire/src/cfeditor/io/CMapFileDecode.java) =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapReader.java (rev 0) +++ trunk/crossfire/src/cfeditor/io/CMapReader.java 2006-11-11 17:29:44 UTC (rev 645) @@ -0,0 +1,239 @@ +/* + * Crossfire Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package cfeditor.io; + +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapArchObject; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.List; +import net.sf.gridarta.io.AbstractMapReader; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A MapFileDecoder reads a map file and provides access to the information read from the map file. + * This class handles the reading of a mapfile and parsing the data + * into a list of ArchObjects. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public final class CMapReader extends AbstractMapReader<GameObject, MapArchObject> { + + private static final Logger log = Logger.getLogger(CMapReader.class); + + /** + * The maximum x position of all data read from the file. + * It's used to automatically expand a map to the size of its contents in case of a map with wrongly set size. + */ + private int maxxlen; + + /** + * The maximum y position of all data read from the file. + * It's used to automatically expand a map to the size of its contents in case of a map with wrongly set size. + */ + private int maxylen; + + /** + * Open a resource for reading it as a map. + * @param uri URI of resource to open. + * @throws FileNotFoundException in case the resource was not found. + */ + public CMapReader(final String uri) throws FileNotFoundException { + super(uri); + } + + /** + * Open a file for reading it as a map. + * @param file File to open. + * @throws FileNotFoundException in case the file was not found. + */ + public CMapReader(final File file) throws FileNotFoundException { + super(file); + } + + /** {@inheritDoc} */ + protected MapArchObject createMapArchObject() { + return new MapArchObject(); + } + + /** + * Loading a map from the given mapfile. + * This method returns a list of GameObjects. + * @return first <code>GameObject</code> in the list + * @throws FileNotFoundException in case the requested map file was not found + * @throws IOException in case the file couldn't be read or is in wrong format + * @todo create a separate exception for the wrong format + */ + @NotNull public List<GameObject> decodeMapFile() throws IOException { + final List<GameObject> objects = super.decodeMapFile(); + // finally... here we go + // last action: if the map is bigger than the specified size in + // the maparch, we set the true size: the maxxlen/maxylen counters. + maparch.ensureMapSize(maxxlen + 1, maxylen + 1); + + return objects; // return first arch of the list + } + + /** + * Our recursive accessible arch reader. + * <p/> + * WARNING: this implementation should fail with multi head settings + * if there are multi part items in the inventory (but this is not yet + * included in CF!) + * @param thisLine first line of text, belonging to this new arch + * @return the new parsed <code>GameObject</code> + * @throws IOException when an I/O-error occured during file reading + * @fixme I'm too long, make me shorter. + * @todo Attributes not relevant during map parsing shouldn't be evaluated here, but in GameObject / ArchetypeParser instead. + * @todo Convince crossfire people of removing "More" as it seems to be pointless now. + * @todo Find out whether effectively also trimming msg contents didn't break anything. + */ + // Note for programmers from Daimonin: Crossfire still has to support "More" which was used for multipart objects in the past. + @Nullable protected GameObject readArch(String thisLine) throws IOException { + boolean msgflag = false; + boolean archflag = false; + boolean archmore = false; + GameObject gameObject = null; + do { + thisLine = thisLine.trim(); + + if (!archflag) { + if (thisLine.startsWith("More")) { + // All arches started with "More" are ignored. We load only + // the heads and expand them according to the defaults. + archmore = true; + } else // format violation for better diff + if (thisLine.startsWith("arch ")) { + archflag = true; // from now on we are inside an arch + + if (!archmore) { + gameObject = new GameObject(); // create a new instance + gameObject.setArchetypeName(thisLine.substring(5).trim()); + } + } + } else if (!archmore) { + // here we are inside of an arch object (but not "More")... + if (msgflag) { + if (thisLine.startsWith("endmsg")) { + msgflag = false; + } else { + gameObject.addMsgText(thisLine + '\n'); + } + } else if (thisLine.startsWith("arch ")) { + // ok, we had a full arch... don't care here about map or object + // now we test for a new arch - thats stuf in inventory + // or the end... thats the end of this shit + if (log.isDebugEnabled()) { + log.debug("GO INVENTORY: " + gameObject + " - " + thisLine); + } + gameObject.addLast(readArch(thisLine)); + if (log.isDebugEnabled()) { + log.debug("GO INVENTORY2: " + gameObject + " - " + thisLine); + } + } else if (thisLine.equals("end")) { + objects.add(gameObject); + archflag = false; + archmore = false; + + if (log.isDebugEnabled()) { + log.debug("LEAVE!: " + gameObject + " - " + thisLine); + } + return gameObject; + } else if (thisLine.startsWith("msg")) { + // gameObject.addArchText(thisLine + "\n"); + gameObject.addMsgText(""); // this init the msg text buffer + // in the case of msg/endmsg + // with no content to overrule def msg + msgflag = true; + // this is a MUST, because we overrule "anim" test + } else if (thisLine.startsWith("animation")) { + gameObject.addObjectText(thisLine); + } else if (thisLine.startsWith("anim_speed")) { + gameObject.addObjectText(thisLine); + } else if (thisLine.startsWith("event_")) { + // here's something about a scripted event + final int i = thisLine.indexOf("_plugin"); + final int k = thisLine.indexOf("_options"); + final int space = thisLine.indexOf(" "); + if (space > 0) { + if (i > 0) { + // expecting: "event_type_plugin Name" + final String type = thisLine.substring(6, i); + final String plname = thisLine.substring(space + 1).trim(); + gameObject.addEventPlugin(type, plname); + } else if (k > 0) { + // expecting: "event_type_options Name" + final String type = thisLine.substring(6, k); + final String eventopt = thisLine.substring(space + 1).trim(); + gameObject.addEventOptions(type, eventopt); + } else { + // expecting: "event_type filepath" + final String type = thisLine.substring(6, space); + final String path = thisLine.substring(space + 1).trim(); + gameObject.addEventScript(type, path); + } + } else { + log.warn("Arch " + gameObject.getArchetypeName() + " has incorrect event code '" + thisLine + "'"); + gameObject.addObjectText(thisLine); // keep line, it might have a meaning after all + } + } else if (thisLine.startsWith("x ")) { + final int temp = Integer.parseInt(thisLine.substring(2)); + if (temp > maxxlen) { + maxxlen = temp; + } + gameObject.setMapX(temp); + } else if (thisLine.startsWith("y ")) { + final int temp = Integer.parseInt(thisLine.substring(2)); + if (temp > maxylen) { + maxylen = temp; + } + gameObject.setMapY(temp); + } else if (thisLine.startsWith("type ")) { + // Arches in maps can override their default arch's type + gameObject.setArchTypNr(Integer.parseInt(thisLine.substring(5))); + // don't load it into the archtext! (why?) + } else if (thisLine.startsWith("face ")) { + gameObject.setFaceFlag(false); + gameObject.setFaceName(thisLine.substring(5).trim()); + } else { + gameObject.addObjectText(thisLine); + } + } else { + // We are in a multipart tail arch ("more"), so we skip it: + if (thisLine.regionMatches(0, "end", 0, 3)) { + archflag = false; + archmore = false; + } + } + } while ((thisLine = readLine()) != null); + + return null; // this happens when the file end is reached + } + +} // class CMapFileDecode Property changes on: trunk/crossfire/src/cfeditor/io/CMapReader.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Copied: trunk/crossfire/src/cfeditor/io/CMapWriter.java (from rev 644, trunk/crossfire/src/cfeditor/io/CMapFileEncode.java) =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapWriter.java (rev 0) +++ trunk/crossfire/src/cfeditor/io/CMapWriter.java 2006-11-11 17:29:44 UTC (rev 645) @@ -0,0 +1,476 @@ +/* + * Crossfire Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package cfeditor.io; + +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapArchObject; +import cfeditor.map.MapModel; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.StringReader; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.io.AbstractMapWriter; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; + +/** + * The <code>CMapFileEncode</code> is used to write a map to a file. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public final class CMapWriter extends AbstractMapWriter<GameObject, MapArchObject, MapModel> { + + private static final Logger log = Logger.getLogger(CMapWriter.class); + + /** + * Create a CMapFileEncode instance. + * @param file File to open. + * @throws FileNotFoundException in case the file couldn't be opened for writing + */ + public CMapWriter(@NotNull final File file) throws FileNotFoundException { + super(file); + } + + /** + * Writes a single GameObject. + * @param gameObject <code>GameObject</code> to be written into the map + * @param x X position of gameObject (0 if <var>gameObject</var> is inside an inventory) + * @param y Y position of gameObject (0 if <var>gameObject</var> is inside an inventory) + * @throws IOException in case of I/O problems + */ + protected void writeGameObject(final GameObject gameObject, final int x, final int y) throws IOException { + final Archetype<GameObject> archetype = gameObject.getArchetype(); + + // Collect all fields to write. + final Map<String, String> fields = new HashMap<String, String>(); // String key -> String value + + final String name = gameObject.getObjName(); + if (name != null) { + fields.put("name", name); + } + + final String face = gameObject.getFaceName(); + if (face != null) { + fields.put("face", face); + } + + if (gameObject.isScripted()) { + final String events = gameObject.getMapArchEventData(); + if (!events.equals("")) { + final String[] tmp = events.split("\n"); + for (final String aTmp : tmp) { + final String[] line = aTmp.split(" +", 2); + if (line.length != 2) { + log.warn("writeMapArch: ignoring invalid event line: " + aTmp); + } else { + fields.put(line[0], line[1]); + } + } + } + } + + if (gameObject.getMsgText() != null && !gameObject.getMsgText().trim().equals((archetype == null || archetype.getMsgText() == null) ? "" : archetype.getMsgText().trim())) { + String msg = ""; + if (gameObject.getMsgText().trim().length() > 0) { + msg = gameObject.getMsgText(); + if (!msg.endsWith("\n")) { + msg += "\n"; + } + } + fields.put("msg", msg + "endmsg"); + } + + if (archetype != null && gameObject.getArchTypNr() != archetype.getArchTypNr()) { + // this arch has special type + if (gameObject.getObjectText().indexOf("type ") >= 0) { + // oh oh - there might also be a type in the archtext which + // is conflicting. remove the type from the archtext + + // open a reading stream for the archText + final StringReader sread = new StringReader(gameObject.getObjectText()); + final BufferedReader sstream = new BufferedReader(sread); + String newArchtext = ""; + + try { + for (String line; (line = sstream.readLine()) != null && line.length() > 0;) { + line = line.trim(); + + if (line.startsWith("type ")) { + // ommit this line + } else { + newArchtext += line + "\n"; // append this line + } + } + + // close streams + sstream.close(); + sread.close(); + + if (newArchtext.trim().length() == 0) { + gameObject.setObjectText(""); + } else { + gameObject.setObjectText(newArchtext.trim() + "\n"); + } + } catch (final IOException e) { + log.error("getSyntaxErrors: Cannot close StringReader"); + } + } + + // now append the type to the archtext + fields.put("type", Integer.toString(gameObject.getArchTypNr())); + } + + final String text = gameObject.getObjectText(); + if (!text.equals("")) { + final String[] tmp = text.split("\n"); + for (final String aTmp : tmp) { + final String[] line = aTmp.split(" +", 2); + if (line.length != 2) { + log.warn("writeMapArch: ignoring invalid arch line: " + aTmp); + } else { + fields.put(line[0], line[1]); + } + } + } + + // map coordinates only belong into map arches (not inventory arches) + if (x != 0) { + fields.put("x", Integer.toString(x)); + } + if (y != 0) { + fields.put("y", Integer.toString(y)); + } + + // Sort fields to match server/crossedit order. + final String[] keys = (String[]) fields.keySet().toArray(new String[0]); + Arrays.sort(keys, keyOrderComparator); + + // Actually write the fields. + append("arch " + gameObject.getArchetypeName() + "\n"); + for (int i = 0; i < keys.length; i++) { + final String value = (String) fields.get(keys[i]); + if (value != null) { + final String key = keys[i]; + if (key.equals("msg") || key.equals("lore")) { + append(key + "\n" + value + "\n"); + } else { + append(key + " " + value + "\n"); + } + } + } + + for (final GameObject inventoryItem : gameObject) { + writeGameObject(inventoryItem, 0, 0); + } + + append("end\n"); + } + + /** + * Comparator to compare two object fields. The comparator sorts the fields + * in the order in which they should be written to disk. + */ + private static final Comparator<String> keyOrderComparator = new Comparator<String>() { + + /** {@inheritDoc} */ + public int compare(final String o1, final String o2) { + final Integer i1 = keys.get(o1); + final Integer i2 = keys.get(o2); + final int v1 = i1 == null ? Integer.MAX_VALUE : i1.intValue(); + final int v2 = i2 == null ? Integer.MAX_VALUE : i2.intValue(); + if (v1 < v2) { + return -1; + } + if (v1 > v2) { + return +1; + } + assert v1 == v2; + return 0; + } + }; + + /** + * Determines the field order when writing objects to a file. The key is + * the field name, the value is an Integer that describes the order. Lower + * values are written first. + */ + private static final Map<String, Integer> keys = new HashMap<String, Integer>(); + + /* + * Initialize {@link keys} array. + * @todo this information should be read from a file. + */ + static { + addKey("name"); + addKey("name_pl"); + addKey("custom_name"); + addKey("title"); + addKey("race"); + addKey("slaying"); + addKey("skill"); + addKey("msg"); + addKey("lore"); + addKey("other_arch"); + addKey("face"); + addKey("animation"); + addKey("is_animated"); + addKey("Str"); + addKey("Dex"); + addKey("Con"); + addKey("Wis"); + addKey("Pow"); + addKey("Cha"); + addKey("Int"); + addKey("hp"); + addKey("maxhp"); + addKey("sp"); + addKey("maxsp"); + addKey("grace"); + addKey("maxgrace"); + addKey("exp"); + addKey("perm_exp"); + addKey("expmul"); + addKey("food"); + addKey("dam"); + addKey("luck"); + addKey("wc"); + addKey("ac"); + addKey("x"); + addKey("y"); + addKey("speed"); + addKey("speed_left"); + addKey("move_state"); + addKey("attack_movement"); + addKey("nrof"); + addKey("level"); + addKey("direction"); + addKey("type"); + addKey("subtype"); + addKey("attacktype"); + addKey("resist_physical"); + addKey("resist_magic"); + addKey("resist_fire"); + addKey("resist_electricity"); + addKey("resist_cold"); + addKey("resist_confusion"); + addKey("resist_acid"); + addKey("resist_drain"); + addKey("resist_weaponmagic"); + addKey("resist_ghosthit"); + addKey("resist_poison"); + addKey("resist_slow"); + addKey("resist_paralyze"); + addKey("resist_turn_undead"); + addKey("resist_fear"); + addKey("resist_cancellation"); + addKey("resist_deplete"); + addKey("resist_death"); + addKey("resist_chaos"); + addKey("resist_counterspell"); + addKey("resist_godpower"); + addKey("resist_holyword"); + addKey("resist_blind"); + addKey("resist_internal"); + addKey("resist_life_stealing"); + addKey("resist_disease"); + addKey("path_attuned"); + addKey("path_repelled"); + addKey("path_denied"); + addKey("material"); + addKey("materialname"); + addKey("value"); + addKey("carrying"); + addKey("weight"); + addKey("invisible"); + addKey("state"); + addKey("magic"); + addKey("last_heal"); + addKey("last_sp"); + addKey("last_grace"); + addKey("last_eat"); + addKey("connected"); + addKey("glow_radius"); + addKey("randomitems"); + addKey("npc_status"); + addKey("npc_program"); + addKey("run_away"); + addKey("pick_up"); + addKey("container"); + addKey("will_apply"); + addKey("smoothlevel"); + addKey("map_layer"); + addKey("current_weapon_script"); + addKey("weapontype"); + addKey("tooltype"); + addKey("elevation"); + addKey("client_type"); + addKey("item_power"); + addKey("duration"); + addKey("range"); + addKey("range_modifier"); + addKey("duration_modifier"); + addKey("dam_modifier"); + addKey("gen_sp_armour"); + addKey("move_type"); + addKey("move_block"); + addKey("move_allow"); + addKey("move_on"); + addKey("move_off"); + addKey("move_slow"); + addKey("move_slow_penalty"); + addKey("alive"); + addKey("wiz"); + addKey("was_wiz"); + addKey("applied"); + addKey("unpaid"); + addKey("can_use_shield"); + addKey("no_pick"); + addKey("walk_on"); + addKey("no_pass"); + addKey("is_animated"); + addKey("slow_move"); + addKey("flying"); + addKey("monster"); + addKey("friendly"); + addKey("generator"); + addKey("is_thrown"); + addKey("auto_apply"); + addKey("treasure"); + addKey("player sold"); + addKey("see_invisible"); + addKey("can_roll"); + addKey("overlay_floor"); + addKey("is_turnable"); + addKey("walk_off"); + addKey("fly_on"); + addKey("fly_off"); + addKey("is_used_up"); + addKey("identified"); + addKey("reflecting"); + addKey("changing"); + addKey("splitting"); + addKey("hitback"); + addKey("startequip"); + addKey("blocksview"); + addKey("undead"); + addKey("scared"); + addKey("unaggressive"); + addKey("reflect_missile"); + addKey("reflect_spell"); + addKey("no_magic"); + addKey("no_fix_player"); + addKey("is_lightable"); + addKey("tear_down"); + addKey("run_away"); + addKey("pass_thru"); + addKey("can_pass_thru"); + addKey("pick_up"); + addKey("unique"); + addKey("no_drop"); + addKey("wizcast"); + addKey("can_cast_spell"); + addKey("can_use_scroll"); + addKey("can_use_range"); + addKey("can_use_bow"); + addKey("can_use_armour"); + addKey("can_use_weapon"); + addKey("can_use_ring"); + addKey("has_ready_range"); + addKey("has_ready_bow"); + addKey("xrays"); + addKey("is_floor"); + addKey("lifesave"); + addKey("no_strength"); + addKey("sleep"); + addKey("stand_still"); + addKey("random_move"); + addKey("only_attack"); + addKey("confused"); + addKey("stealth"); + addKey("cursed"); + addKey("damned"); + addKey("see_anywhere"); + addKey("known_magical"); + addKey("known_cursed"); + addKey("can_use_skill"); + addKey("been_applied"); + addKey("has_ready_scroll"); + addKey("can_use_rod"); + addKey("can_use_horn"); + addKey("make_invisible"); + addKey("inv_locked"); + addKey("is_wooded"); + addKey("is_hilly"); + addKey("has_ready_skill"); + addKey("has_ready_weapon"); + addKey("no_skill_ident"); + addKey("is_blind"); + addKey("can_see_in_dark"); + addKey("is_cauldron"); + addKey("is_dust"); + addKey("no_steal"); + addKey("one_hit"); + addKey("berserk"); + addKey("neutral"); + addKey("no_attack"); + addKey("no_damage"); + addKey("activate_on_push"); + addKey("activate_on_release"); + addKey("is_water"); + addKey("use_content_on_gen"); + addKey("is_buildable"); + addKey("body_range"); + addKey("body_arm"); + addKey("body_torso"); + addKey("body_head"); + addKey("body_neck"); + addKey("body_skill"); + addKey("body_finger"); + addKey("body_shoulder"); + addKey("body_foot"); + addKey("body_hand"); + addKey("body_wrist"); + addKey("body_waist"); + } + + /** The next key added via {@link #addKey(String)} is assigned this id. */ + private static int idKey = 1; + + /** + * Add a new key to {@link #keys}. The order in which the keys are added is + * the order in which the objects fields are written out. + */ + private static void addKey(final String key) { + keys.put(key, idKey++); + } + +} // class CMapFileEncode Property changes on: trunk/crossfire/src/cfeditor/io/CMapW... [truncated message content] |
From: <chr...@us...> - 2006-11-11 17:25:13
|
Revision: 644 http://svn.sourceforge.net/gridarta/?rev=644&view=rev Author: christianhujer Date: 2006-11-11 09:24:41 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Changed CMapFileEncode to Java I/O style. Unified CMapFileEncode and its usages. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/io/CMapFileEncode.java trunk/crossfire/src/cfeditor/map/MapArchObject.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/io/CMapFileEncode.java trunk/daimonin/src/daieditor/map/MapArchObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/io/AbstractMapFileDecode.java trunk/src/app/net/sf/gridarta/io/MapFileEncode.java trunk/src/app/net/sf/gridarta/map/MapArchObject.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/io/AbstractMapFileEncode.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-11 15:46:16 UTC (rev 643) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-11 17:24:41 UTC (rev 644) @@ -43,7 +43,6 @@ import java.util.Enumeration; import java.util.Iterator; import java.util.List; -import java.util.Random; import java.util.Vector; import javax.swing.ImageIcon; import javax.swing.JFileChooser; @@ -108,8 +107,6 @@ /** Bit field of edit types to show only. */ private int tileEdit; - private CMapFileEncode mapFileEncoder; - private ArchetypeParser archetypeParser; /** The Animation Objects. */ @@ -233,9 +230,6 @@ autoPopupDocu = false; } - // attach map encoder and decoder - mapFileEncoder = new CMapFileEncode(); - // our global object parser archetypeParser = new ArchetypeParser(this); animationObjects = new AnimationObjects(); @@ -931,7 +925,12 @@ public void encodeMapFile(@NotNull final File file, final MapModel mapModel) { final String fname = file.getAbsolutePath(); try { - mapFileEncoder.encodeMapFile(file, mapModel); + final CMapFileEncode mapFileEncoder = new CMapFileEncode(file); + try { + mapFileEncoder.encodeMapFile(mapModel); + } finally { + mapFileEncoder.close(); + } } catch (final FileNotFoundException e) { showMessage("Error Save Map", "Error writing file " + fname + "\n"); } catch (final IOException e) { Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-11-11 15:46:16 UTC (rev 643) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-11-11 17:24:41 UTC (rev 644) @@ -387,16 +387,6 @@ } /** - * Determine if this part is the head part. For single-part objects this is - * always true. - * - * @return <code>true</code> iff this part if a head part - */ - public boolean isHead() { - return getHead() == this; - } - - /** * Determine if this part is a tail part. For single-part objects this is * never true. * Modified: trunk/crossfire/src/cfeditor/io/CMapFileEncode.java =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapFileEncode.java 2006-11-11 15:46:16 UTC (rev 643) +++ trunk/crossfire/src/cfeditor/io/CMapFileEncode.java 2006-11-11 17:24:41 UTC (rev 644) @@ -27,93 +27,47 @@ import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; import cfeditor.map.MapModel; -import java.awt.Point; import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.File; import java.io.FileNotFoundException; -import java.io.FileWriter; import java.io.IOException; import java.io.StringReader; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.Map; -import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.io.MapFileEncode; +import net.sf.gridarta.io.AbstractMapFileEncode; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; /** - * The <code>CMapFileEncode</code> + * The <code>CMapFileEncode</code> is used to write a map to a file. * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public final class CMapFileEncode implements MapFileEncode<MapModel> { +public final class CMapFileEncode extends AbstractMapFileEncode<GameObject, MapArchObject, MapModel> { private static final Logger log = Logger.getLogger(CMapFileEncode.class); - private BufferedWriter bufferedWriter; - - private String fname; - - /** Create a CMapFileEncode instance. */ - public CMapFileEncode() { + /** + * Create a CMapFileEncode instance. + * @param file File to open. + * @throws FileNotFoundException in case the file couldn't be opened for writing + */ + public CMapFileEncode(@NotNull final File file) throws FileNotFoundException { + super(file); } - /** {@inheritDoc} */ - public void encodeMapFile(@NotNull final File file, @NotNull final MapModel mapModel) throws FileNotFoundException, IOException { - final MapArchObject mapArch = mapModel.getMapArchObject(); - - try { - fname = file.getAbsolutePath(); - bufferedWriter = new BufferedWriter(new FileWriter(file)); - //GameObject multi; - - // write map header: map arch - mapArch.writeMapArch(bufferedWriter); - - // first, write all one tile parts - final Size2D mapSize = mapArch.getMapSize(); - final Point pos = new Point(); - for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { - for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { - for (final GameObject gameObject : mapModel.getMapSquare(pos)) { - // only non multi suckers - if (!gameObject.isMulti()) { - writeGameObject(gameObject, false); - } - } // node - } // y - } // x - - // second, we drop the multi part suckers out - for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { - for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { - for (final GameObject gameObject : mapModel.getMapSquare(pos)) { - // search only for heads! - if (gameObject.isMulti() && gameObject.isHead()) { - // only the heads get stored in the mapfile - // (that's much more efficient) - writeGameObject(gameObject, false); - } - } // node - } // y - } // x - } finally { - bufferedWriter.close(); - bufferedWriter = null; - } - } - /** - * Here the map arch gets written into the file. - * @param gameObject <code>GameObject</code> to be written into the map - * @param isInventory is 'arch' inside a container? true/false - * @return true if arch was written successfully + * Writes a single GameObject. + * @param gameObject <code>GameObject</code> to be written into the map + * @param x X position of gameObject (0 if <var>gameObject</var> is inside an inventory) + * @param y Y position of gameObject (0 if <var>gameObject</var> is inside an inventory) + * @throws IOException in case of I/O problems */ - void writeGameObject(final GameObject gameObject, final boolean isInventory) throws IOException { + protected void writeGameObject(final GameObject gameObject, final int x, final int y) throws IOException { final Archetype<GameObject> archetype = gameObject.getArchetype(); // Collect all fields to write. @@ -208,42 +162,37 @@ } } - if (!isInventory) { - // map coordinates only belong into map arches (not inventory arches) - final int x = gameObject.getMapX(); - if (x != 0) { - fields.put("x", Integer.toString(x)); - } - - final int y = gameObject.getMapY(); - if (y != 0) { - fields.put("y", Integer.toString(y)); - } + // map coordinates only belong into map arches (not inventory arches) + if (x != 0) { + fields.put("x", Integer.toString(x)); } + if (y != 0) { + fields.put("y", Integer.toString(y)); + } // Sort fields to match server/crossedit order. final String[] keys = (String[]) fields.keySet().toArray(new String[0]); Arrays.sort(keys, keyOrderComparator); // Actually write the fields. - bufferedWriter.write("arch " + gameObject.getArchetypeName() + "\n"); + append("arch " + gameObject.getArchetypeName() + "\n"); for (int i = 0; i < keys.length; i++) { final String value = (String) fields.get(keys[i]); if (value != null) { final String key = keys[i]; if (key.equals("msg") || key.equals("lore")) { - bufferedWriter.write(key + "\n" + value + "\n"); + append(key + "\n" + value + "\n"); } else { - bufferedWriter.write(key + " " + value + "\n"); + append(key + " " + value + "\n"); } } } for (final GameObject inventoryItem : gameObject) { - writeGameObject(inventoryItem, true); + writeGameObject(inventoryItem, 0, 0); } - bufferedWriter.write("end\n"); + append("end\n"); } /** Modified: trunk/crossfire/src/cfeditor/map/MapArchObject.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapArchObject.java 2006-11-11 15:46:16 UTC (rev 643) +++ trunk/crossfire/src/cfeditor/map/MapArchObject.java 2006-11-11 17:24:41 UTC (rev 644) @@ -26,7 +26,6 @@ import cfeditor.IGUIConstants; import java.io.BufferedReader; -import java.io.BufferedWriter; import java.io.IOException; import net.sf.gridarta.Size2D; import net.sf.gridarta.map.AbstractMapArchObject; @@ -494,104 +493,104 @@ /** * Writing the MapArchObject into the mapfile - * @param stream <code>BufferedWriter</code> to the mapfile + * @param appendable <code>BufferedWriter</code> to the mapfile * @throws java.io.FileNotFoundException the mapfile could not be found * @throws IOException an I/O error occured during writing to the file */ - public void writeMapArch(final BufferedWriter stream) throws IOException { + public void writeMapArch(final Appendable appendable) throws IOException { int i; - stream.append("arch map\n"); + appendable.append("arch map\n"); if (getMapName().length() > 0) { - stream.append("name ").append(getMapName()).append("\n"); + appendable.append("name ").append(getMapName()).append("\n"); } if (getSwapTime() > 0) { - stream.append("swap_time ").append(String.valueOf(getSwapTime())).append("\n"); + appendable.append("swap_time ").append(String.valueOf(getSwapTime())).append("\n"); } if (getResetTimeout() > 0) { - stream.append("reset_timeout ").append(String.valueOf(getResetTimeout())).append("\n"); + appendable.append("reset_timeout ").append(String.valueOf(getResetTimeout())).append("\n"); } if (isFixedReset()) { - stream.append("fixed_resettime 1\n"); + appendable.append("fixed_resettime 1\n"); } if (getDifficulty() > 0) { - stream.append("difficulty ").append(String.valueOf(getDifficulty())).append("\n"); + appendable.append("difficulty ").append(String.valueOf(getDifficulty())).append("\n"); } if (region.length() > 0) { - stream.append("region ").append(region).append("\n"); + appendable.append("region ").append(region).append("\n"); } if (shopitems.length() > 0) { - stream.append("shopitems ").append(shopitems).append("\n"); + appendable.append("shopitems ").append(shopitems).append("\n"); } if (shopgreed != 0) { - stream.append("shopgreed ").append(String.valueOf(shopgreed)).append("\n"); + appendable.append("shopgreed ").append(String.valueOf(shopgreed)).append("\n"); } if (shopmin != 0) { - stream.append("shopmin ").append(String.valueOf(shopmin)).append("\n"); + appendable.append("shopmin ").append(String.valueOf(shopmin)).append("\n"); } if (shopmax != 0) { - stream.append("shopmax ").append(String.valueOf(shopmax)).append("\n"); + appendable.append("shopmax ").append(String.valueOf(shopmax)).append("\n"); } if (shoprace.length() > 0) { - stream.append("shoprace ").append(shoprace).append("\n"); + appendable.append("shoprace ").append(shoprace).append("\n"); } if (getDarkness() > 0) { - stream.append("darkness ").append(String.valueOf(getDarkness())).append("\n"); + appendable.append("darkness ").append(String.valueOf(getDarkness())).append("\n"); } - stream.append("width ").append(String.valueOf(getMapSize().getWidth())).append("\n"); - stream.append("height ").append(String.valueOf(getMapSize().getHeight())).append("\n"); + appendable.append("width ").append(String.valueOf(getMapSize().getWidth())).append("\n"); + appendable.append("height ").append(String.valueOf(getMapSize().getHeight())).append("\n"); if (getEnterX() > 0) { - stream.append("enter_x ").append(String.valueOf(getEnterX())).append("\n"); + appendable.append("enter_x ").append(String.valueOf(getEnterX())).append("\n"); } if (getEnterY() > 0) { - stream.append("enter_y ").append(String.valueOf(getEnterY())).append("\n"); + appendable.append("enter_y ").append(String.valueOf(getEnterY())).append("\n"); } if (msgText.length() > 0 && msgText.toString().trim().length() > 0) { - stream.append(TAG_START_TEXT + "\n"); - stream.append(msgText.toString().trim()).append("\n"); - stream.append(TAG_END_TEXT + "\n"); + appendable.append(TAG_START_TEXT + "\n"); + appendable.append(msgText.toString().trim()).append("\n"); + appendable.append(TAG_END_TEXT + "\n"); } if (loreText.length() > 0 && loreText.toString().trim().length() > 0) { - stream.append(TAG_START_LORE + "\n"); - stream.append(loreText.toString().trim()).append("\n"); - stream.append(TAG_END_LORE + "\n"); + appendable.append(TAG_START_LORE + "\n"); + appendable.append(loreText.toString().trim()).append("\n"); + appendable.append(TAG_END_LORE + "\n"); } if (isUnique()) { - stream.append("unique 1\n"); + appendable.append("unique 1\n"); } if (template) { - stream.append("template 1\n"); + appendable.append("template 1\n"); } if (outdoor) { - stream.append("outdoor 1\n"); + appendable.append("outdoor 1\n"); } if (temp != 0) { - stream.append("temp ").append(String.valueOf(temp)).append("\n"); + appendable.append("temp ").append(String.valueOf(temp)).append("\n"); } if (pressure != 0) { - stream.append("pressure ").append(String.valueOf(pressure)).append("\n"); + appendable.append("pressure ").append(String.valueOf(pressure)).append("\n"); } if (humid != 0) { - stream.append("humid ").append(String.valueOf(humid)).append("\n"); + appendable.append("humid ").append(String.valueOf(humid)).append("\n"); } if (windspeed != 0) { - stream.append("windspeed ").append(String.valueOf(windspeed)).append("\n"); + appendable.append("windspeed ").append(String.valueOf(windspeed)).append("\n"); } if (winddir != 0) { - stream.append("winddir ").append(String.valueOf(winddir)).append("\n"); + appendable.append("winddir ").append(String.valueOf(winddir)).append("\n"); } if (sky != 0) { - stream.append("sky ").append(String.valueOf(sky)).append("\n"); + appendable.append("sky ").append(String.valueOf(sky)).append("\n"); } for (i = 0; i < MAX_TILE; i++) { if (tilePaths[i].length() > 0) { - stream.append("tile_path_").append(String.valueOf(i + 1)).append(" ").append(tilePaths[i]).append("\n"); + appendable.append("tile_path_").append(String.valueOf(i + 1)).append(" ").append(tilePaths[i]).append("\n"); } } if (nosmooth) { - stream.append("nosmooth 1\n"); + appendable.append("nosmooth 1\n"); } - stream.append("end\n"); + appendable.append("end\n"); } } // class MapArchObject Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-11-11 15:46:16 UTC (rev 643) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-11-11 17:24:41 UTC (rev 644) @@ -199,8 +199,6 @@ /** Bit field of edit types to show transparent. */ private int alphaType; - private CMapFileEncode mapFileEncoder; - private ArchetypeParser archetypeParser; /** The Animation Objects. */ @@ -421,9 +419,6 @@ autoPopupDocu = false; } - // attach map encoder and decoder - mapFileEncoder = new CMapFileEncode(); - // our global object parser archetypeParser = new ArchetypeParser(this); animationObjects = new AnimationObjects(ACTION_FACTORY.getString("nameOfAnimationObject")); @@ -1248,7 +1243,12 @@ */ public void encodeMapFile(final File file, final MapModel mapModel) { try { - mapFileEncoder.encodeMapFile(file, mapModel); + final CMapFileEncode mapFileEncoder = new CMapFileEncode(file); + try { + mapFileEncoder.encodeMapFile(mapModel); + } finally { + mapFileEncoder.close(); + } } catch (final FileNotFoundException e) { ACTION_FACTORY.showMessageDialog(mainView, "encodeMapFile", file); } catch (final IOException e) { Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-11-11 15:46:16 UTC (rev 643) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-11-11 17:24:41 UTC (rev 644) @@ -293,16 +293,6 @@ } /** - * Determine if this part is the head part. For single-part objects this is - * always true. - * - * @return <code>true</code> iff this part if a head part - */ - public boolean isHead() { - return getHead() == this; - } - - /** * Determine if this part is a tail part. For single-part objects this is * never true. * Modified: trunk/daimonin/src/daieditor/io/CMapFileEncode.java =================================================================== --- trunk/daimonin/src/daieditor/io/CMapFileEncode.java 2006-11-11 15:46:16 UTC (rev 643) +++ trunk/daimonin/src/daieditor/io/CMapFileEncode.java 2006-11-11 17:24:41 UTC (rev 644) @@ -34,10 +34,7 @@ import java.util.Formatter; import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.io.IOUtils; -import net.sf.gridarta.io.MapFileEncode; -import net.sf.gridarta.map.MapSquare; -import org.apache.log4j.Logger; +import net.sf.gridarta.io.AbstractMapFileEncode; import org.jetbrains.annotations.NotNull; /** @@ -47,70 +44,31 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ @SuppressWarnings({"HardcodedLineSeparator"}) -public final class CMapFileEncode implements MapFileEncode<MapModel> { +public final class CMapFileEncode extends AbstractMapFileEncode<GameObject, MapArchObject, MapModel> { - private static final Logger log = Logger.getLogger(CMapFileEncode.class); - /** * Formatter to use for writing maps. * @note use '\n' for line endings only. The fileformat requires Unix LF only. */ - private Formatter format; + private final Formatter format = new Formatter(this); - /** Create a CMapFileEncode instance. */ - public CMapFileEncode() { + /** + * Create a CMapFileEncode instance. + * @param file File to open. + * @throws FileNotFoundException in case the file couldn't be opened for writing + */ + public CMapFileEncode(@NotNull final File file) throws FileNotFoundException { + super(file); } - /** {@inheritDoc} */ - public void encodeMapFile(@NotNull final File file, @NotNull final MapModel mapModel) throws FileNotFoundException, IOException { - final MapArchObject mapArch = mapModel.getMapArchObject(); - try { - format = new Formatter(file, IOUtils.MAP_ENCODING); - //GameObject multi; - - // write map header: map arch - mapArch.writeMapArch(format.out()); // FIXME: It doesn't look like a good idea to mix Push and Pull - - // first, write all one tile parts - final Size2D mapSize = mapModel.getMapSize(); - final Point pos = new Point(); - for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { - for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { - for (final GameObject node : mapModel.getMapSquare(pos)) { - // only non multi suckers - if (!node.isMulti()) { - writeGameObject(node, pos.x, pos.y); - } - } // node - } // y - } // x - - for (final MapSquare<GameObject> square : mapModel) { - final int x = square.getMapX(); - final int y = square.getMapY(); - for (final GameObject node : square) { - // search only for heads! - if (node.isMulti() && node.isHead()) { - // only the heads get stored in the mapfile - // (that's much more efficient) - writeGameObject(node, x, y); - } // node - } // y - } // x - } finally { - format.close(); - format = null; - } - } - /** - * Here the map gameObject gets written into the file. - * @param gameObject <code>GameObject</code> to be written into the map - * @param x x position of gameObject (0 if <var>gameObject</var> is inside an inventory) - * @param y y position of gameObject (0 if <var>gameObject</var> is inside an inventory) + * Writes a single GameObject. + * @param gameObject <code>GameObject</code> to be written into the map + * @param x X position of gameObject (0 if <var>gameObject</var> is inside an inventory) + * @param y Y position of gameObject (0 if <var>gameObject</var> is inside an inventory) * @throws IOException in case of I/O problems */ - private void writeGameObject(final GameObject gameObject, final int x, final int y) throws IOException { + protected void writeGameObject(final GameObject gameObject, final int x, final int y) throws IOException { final Archetype<GameObject> archetype = gameObject.getArchetype(); // ok, we start with the standard parts... this is valid for all types Modified: trunk/daimonin/src/daieditor/map/MapArchObject.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapArchObject.java 2006-11-11 15:46:16 UTC (rev 643) +++ trunk/daimonin/src/daieditor/map/MapArchObject.java 2006-11-11 17:24:41 UTC (rev 644) @@ -407,13 +407,13 @@ /** * Writing the MapArchObject into the mapfile - * @param stream <code>Appendable</code> to the mapfile + * @param appendable <code>Appendable</code> to the mapfile * @throws IOException an I/O error occured during appending or formatting */ - public void writeMapArch(@NotNull final Appendable stream) throws IOException { + public void writeMapArch(@NotNull final Appendable appendable) throws IOException { - final Formatter format = new Formatter(stream); - stream.append("arch map\n"); + final Formatter format = new Formatter(appendable); + appendable.append("arch map\n"); if (getMapName().length() > 0) { format.format("name %s\n", getMapName()); } @@ -443,41 +443,41 @@ format.format("darkness %d\n", getDarkness()); } if (isFixedReset()) { - stream.append("fixed_resettime 1\n"); + appendable.append("fixed_resettime 1\n"); } if (outdoor) { - stream.append("outdoor 1\n"); + appendable.append("outdoor 1\n"); } if (noSave) { - stream.append("no_save 1\n"); + appendable.append("no_save 1\n"); } if (noMagic) { - stream.append("no_magic 1\n"); + appendable.append("no_magic 1\n"); } if (noPriest) { - stream.append("no_priest 1\n"); + appendable.append("no_priest 1\n"); } if (noSummon) { - stream.append("no_summon 1\n"); + appendable.append("no_summon 1\n"); } if (noHarm) { - stream.append("no_harm 1\n"); + appendable.append("no_harm 1\n"); } if (fixedLogin) { - stream.append("fixed_login 1\n"); + appendable.append("fixed_login 1\n"); } if (permDeath) { - stream.append("perm_death 1\n"); + appendable.append("perm_death 1\n"); } if (ultraDeath) { - stream.append("ultra_death 1\n"); + appendable.append("ultra_death 1\n"); } if (ultimateDeath) { - stream.append("ultimate_death 1\n"); + appendable.append("ultimate_death 1\n"); } if (pvp) { - stream.append("pvp 1\n"); + appendable.append("pvp 1\n"); } // tilePaths @@ -494,7 +494,7 @@ } // end - stream.append("end\n"); + appendable.append("end\n"); } } // class MapArchObject Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-11-11 15:46:16 UTC (rev 643) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-11-11 17:24:41 UTC (rev 644) @@ -667,6 +667,16 @@ */ public abstract G getHead(); + /** + * Determine if this part is the head part. For single-part objects this is + * always true. + * + * @return <code>true</code> iff this part if a head part + */ + public boolean isHead() { + return getHead() == this; + } + /** {@inheritDoc} */ @Nullable public abstract G getMultiNext(); Modified: trunk/src/app/net/sf/gridarta/io/AbstractMapFileDecode.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/AbstractMapFileDecode.java 2006-11-11 15:46:16 UTC (rev 643) +++ trunk/src/app/net/sf/gridarta/io/AbstractMapFileDecode.java 2006-11-11 17:24:41 UTC (rev 644) @@ -118,7 +118,7 @@ /** * Reads a single line. * @return line read - * @throws IOException when an I/O-error occured during file reading + * @throws IOException if an I/O-error occured during reading */ @Nullable protected final String readLine() throws IOException { return myInput.readLine(); Added: trunk/src/app/net/sf/gridarta/io/AbstractMapFileEncode.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/AbstractMapFileEncode.java (rev 0) +++ trunk/src/app/net/sf/gridarta/io/AbstractMapFileEncode.java 2006-11-11 17:24:41 UTC (rev 644) @@ -0,0 +1,127 @@ +package net.sf.gridarta.io; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.awt.Point; +import net.sf.gridarta.map.MapModel; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.Size2D; +import org.jetbrains.annotations.NotNull; + +/** + * Abstract base implementation of {@link MapFileEncode}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class AbstractMapFileEncode<G extends GameObject<G>, A extends MapArchObject, M extends MapModel<G, A>> implements Appendable, MapFileEncode<M> { + + /** The reader to read from. */ + private final PrintWriter myOutput; + + /** The uri to write to. */ + protected final String uri; + + /** + * Open a resource for reading it as a map. + * @param uri URI of resource to open. + * @throws FileNotFoundException in case the resource couldn't be opened for writing + */ + protected AbstractMapFileEncode(final String uri) throws FileNotFoundException { + this.uri = uri; + try { + myOutput = new PrintWriter(new OutputStreamWriter(new FileOutputStream(uri), IOUtils.MAP_ENCODING)); + } catch (final UnsupportedEncodingException e) { + assert false : IOUtils.MAP_ENCODING + " must be a valid encoding."; + throw new Error(IOUtils.MAP_ENCODING + " must be a valid encoding."); + } + } + + /** + * Open a file for reading it as a map. + * @param file File to open. + * @throws FileNotFoundException in case the file couldn't be opened for writing + */ + protected AbstractMapFileEncode(final File file) throws FileNotFoundException { + this.uri = file.toURI().toString(); + try { + myOutput = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), IOUtils.MAP_ENCODING)); + } catch (final UnsupportedEncodingException e) { + assert false : IOUtils.MAP_ENCODING + " must be a valid encoding."; + throw new Error(IOUtils.MAP_ENCODING + " must be a valid encoding."); + } + } + + /** {@inheritDoc} */ + public final void encodeMapFile(@NotNull final M mapModel) throws IOException { + final MapArchObject mapArch = mapModel.getMapArchObject(); + + // write map header: map arch + mapArch.writeMapArch(this); // FIXME: It doesn't look like a good idea to mix Push and Pull + + // first, write all one tile parts + final Size2D mapSize = mapArch.getMapSize(); + final Point pos = new Point(); + for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { + for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { + for (final G gameObject : mapModel.getMapSquare(pos)) { + // only non multi suckers + if (!gameObject.isMulti()) { + writeGameObject(gameObject, pos.x, pos.y); + } + } // node + } // y + } // x + + // second, we drop the multi part suckers out + for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { + for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { + for (final G gameObject : mapModel.getMapSquare(pos)) { + // search only for heads! + if (gameObject.isMulti() && gameObject.isHead()) { + // only the heads get stored in the mapfile + // (that's much more efficient) + writeGameObject(gameObject, pos.x, pos.y); + } + } // node + } // y + } // x + } + + /** + * Writes a single GameObject. + * @param gameObject <code>GameObject</code> to be written into the map + * @param x X position of gameObject (0 if <var>gameObject</var> is inside an inventory) + * @param y Y position of gameObject (0 if <var>gameObject</var> is inside an inventory) + * @throws IOException in case of I/O problems + */ + protected abstract void writeGameObject(final G gameObject, final int x, final int y) throws IOException; + + /** {@inheritDoc} */ + public final void close() throws IOException { + myOutput.close(); + } + + /** {@inheritDoc} */ + public final Appendable append(final CharSequence csq) throws IOException { + myOutput.append(csq); + return this; + } + + /** {@inheritDoc} */ + public final Appendable append(final CharSequence csq, final int start, final int end) throws IOException { + myOutput.append(csq, start, end); + return this; + } + + /** {@inheritDoc} */ + public final Appendable append(final char c) throws IOException { + myOutput.append(c); + return this; + } + +} // class AbstractMapFileEncode Property changes on: trunk/src/app/net/sf/gridarta/io/AbstractMapFileEncode.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/io/MapFileEncode.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/MapFileEncode.java 2006-11-11 15:46:16 UTC (rev 643) +++ trunk/src/app/net/sf/gridarta/io/MapFileEncode.java 2006-11-11 17:24:41 UTC (rev 644) @@ -1,22 +1,21 @@ package net.sf.gridarta.io; -import java.io.File; +import java.io.Closeable; import java.io.FileNotFoundException; import java.io.IOException; -import org.jetbrains.annotations.NotNull; import net.sf.gridarta.map.MapModel; +import org.jetbrains.annotations.NotNull; /** * A MapFileEncode writes a map file to a file. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public interface MapFileEncode<M extends MapModel> { +public interface MapFileEncode<M extends MapModel> extends Closeable { /** * Write the whole map-data into a file. - * @param file mapfile * @param mapModel the MapModel to encode */ - void encodeMapFile(@NotNull File file, @NotNull M mapModel) throws FileNotFoundException, IOException; + void encodeMapFile(@NotNull M mapModel) throws FileNotFoundException, IOException; } // interface MapFileEncode Modified: trunk/src/app/net/sf/gridarta/map/MapArchObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapArchObject.java 2006-11-11 15:46:16 UTC (rev 643) +++ trunk/src/app/net/sf/gridarta/map/MapArchObject.java 2006-11-11 17:24:41 UTC (rev 644) @@ -163,4 +163,12 @@ */ boolean parseMapArch(BufferedReader reader, String fname) throws IOException; + /** + * Append this MapArchObject as text. + * This method can be used for writing a MapArchObject to a file. + * @param appendable <code>Appendable</code> to append to. + * @throws IOException if an I/O error occured during appending + */ + void writeMapArch(final Appendable appendable) throws IOException; + } // interface MapArchObject This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-11 15:47:05
|
Revision: 643 http://svn.sourceforge.net/gridarta/?rev=643&view=rev Author: christianhujer Date: 2006-11-11 07:46:16 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Fixed modifier order, removed modifier redundancies. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFTreasureListTree.java trunk/crossfire/src/cfeditor/filter/SimpleFilterConfig.java trunk/crossfire/src/cfeditor/gui/ArchComboBox.java trunk/daimonin/src/daieditor/CArchPanelPan.java trunk/daimonin/src/daieditor/CAttribDialog.java trunk/daimonin/src/daieditor/CFTreasureListTree.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/ProcessRunner.java trunk/daimonin/src/daieditor/ReplaceDialog.java trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/MapArchObject.java trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObject.java trunk/src/app/net/sf/gridarta/textedit/scripteditor/CFPythonPopup.java trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditMenuBar.java trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditView.java trunk/src/app/net/sf/gridarta/textedit/textarea/InputHandler.java trunk/src/app/net/sf/gridarta/textedit/textarea/JEditTextArea.java trunk/src/app/net/sf/gridarta/textedit/textarea/LuaTokenMarker.java trunk/src/app/net/sf/gridarta/textedit/textarea/SyntaxDocument.java trunk/src/app/net/sf/gridarta/textedit/textarea/SyntaxStyle.java trunk/src/app/net/sf/gridarta/textedit/textarea/TextAreaPainter.java trunk/src/app/net/sf/gridarta/textedit/textarea/Token.java trunk/src/app/net/sf/gridarta/textedit/textarea/TokenMarker.java Modified: trunk/crossfire/src/cfeditor/CFTreasureListTree.java =================================================================== --- trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-11-11 15:46:16 UTC (rev 643) @@ -219,7 +219,7 @@ * @param name Name of a treasurelist * @return True when the treasurelists with the given name exists */ - public static final boolean containsTreasureList(final String name) { + public static boolean containsTreasureList(final String name) { return treasureTable.containsKey(name); } Modified: trunk/crossfire/src/cfeditor/filter/SimpleFilterConfig.java =================================================================== --- trunk/crossfire/src/cfeditor/filter/SimpleFilterConfig.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/crossfire/src/cfeditor/filter/SimpleFilterConfig.java 2006-11-11 15:46:16 UTC (rev 643) @@ -18,7 +18,7 @@ */ public class SimpleFilterConfig extends BasicFilterConfig { - private boolean enabled = true; + private final boolean enabled = true; private Map<String, Object> properties = new HashMap<String, Object>(); Modified: trunk/crossfire/src/cfeditor/gui/ArchComboBox.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2006-11-11 15:46:16 UTC (rev 643) @@ -108,7 +108,7 @@ boolean locked = false; - ArchComboBoxModel archModel; + private final ArchComboBoxModel archModel; public ArchComboBoxEditor() { archModel = new ArchComboBoxModel(); Modified: trunk/daimonin/src/daieditor/CArchPanelPan.java =================================================================== --- trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/daimonin/src/daieditor/CArchPanelPan.java 2006-11-11 15:46:16 UTC (rev 643) @@ -79,7 +79,7 @@ /** The popup menu for the arch lists to bring up the editor. */ // This looks unused, but don't remove it. It will be used in future. - private JPopupMenu menu = createListPopupMenu(); + private final JPopupMenu menu = createListPopupMenu(); private final CArchPanel archPanel; Modified: trunk/daimonin/src/daieditor/CAttribDialog.java =================================================================== --- trunk/daimonin/src/daieditor/CAttribDialog.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/daimonin/src/daieditor/CAttribDialog.java 2006-11-11 15:46:16 UTC (rev 643) @@ -1589,7 +1589,7 @@ } /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { if (strAttr != null) { CFTreasureListTree.getInstance().showDialog(strAttr.input, dialog); } Modified: trunk/daimonin/src/daieditor/CFTreasureListTree.java =================================================================== --- trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/daimonin/src/daieditor/CFTreasureListTree.java 2006-11-11 15:46:16 UTC (rev 643) @@ -212,7 +212,7 @@ * @param name Name of a treasurelist * @return True when the treasurelists with the given name exists */ - public static final boolean containsTreasureList(final String name) { + public static boolean containsTreasureList(final String name) { return treasureTable.containsKey(name); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-11-11 15:46:16 UTC (rev 643) @@ -295,10 +295,10 @@ public MutableOrGameObjectMatcher moaomAlpha = new MutableOrGameObjectMatcher(false); /** The ViewGameObjectMatcherManager for show only. */ - public ViewGameObjectMatcherManager vaommShow = new ViewGameObjectMatcherManager(moaomShow); + public final ViewGameObjectMatcherManager vaommShow = new ViewGameObjectMatcherManager(moaomShow); /** The ViewGameObjectMatcherManager for alpha. */ - public ViewGameObjectMatcherManager vaommAlpha = new ViewGameObjectMatcherManager(moaomAlpha); + public final ViewGameObjectMatcherManager vaommAlpha = new ViewGameObjectMatcherManager(moaomAlpha); private boolean gridVisible; Modified: trunk/daimonin/src/daieditor/ProcessRunner.java =================================================================== --- trunk/daimonin/src/daieditor/ProcessRunner.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/daimonin/src/daieditor/ProcessRunner.java 2006-11-11 15:46:16 UTC (rev 643) @@ -190,7 +190,7 @@ * Set the command to be executed by this ProcessRunner. * @param command command */ - public final void setCommand(final String command) { + public void setCommand(final String command) { this.command = command; } @@ -198,7 +198,7 @@ * Get the command to be executed by this ProcessRunner. * @return command */ - public final String getCommand() { + public String getCommand() { return command; } @@ -206,7 +206,7 @@ * Set the working directory. * @param dir working directory */ - public final void setDir(final File dir) { + public void setDir(final File dir) { this.dir = dir; } @@ -214,7 +214,7 @@ * Get the working directory. * @return working directory */ - public final File getDir() { + public File getDir() { return dir; } @@ -222,7 +222,7 @@ * Action method for starting. * @used */ - public final void controlStart() { + public void controlStart() { synchronized (lock) { if (process != null) { try { @@ -262,7 +262,7 @@ * Action method for stopping. * @used */ - public final void controlStop() { + public void controlStop() { if (process != null) { process.destroy(); } @@ -274,7 +274,7 @@ * Action method for clearing the log. * @used */ - public final void controlClear() { + public void controlClear() { stdtxt.setText(""); } Modified: trunk/daimonin/src/daieditor/ReplaceDialog.java =================================================================== --- trunk/daimonin/src/daieditor/ReplaceDialog.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/daimonin/src/daieditor/ReplaceDialog.java 2006-11-11 15:46:16 UTC (rev 643) @@ -80,8 +80,6 @@ private GameObject replaceArch; // objects will be replaced by this arch - private List<GameObject> replaceSingle = new ArrayList<GameObject>(1); // Used to store only 1 object - private List<GameObject> replaceCopyBuffer; // objects in CopyBuffer private List<GameObject> replacePickmap; // selected objects in pickmap or all if none is selected Modified: trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/daimonin/src/daieditor/gui/map/tools/InsertionTool.java 2006-11-11 15:46:16 UTC (rev 643) @@ -22,7 +22,8 @@ @NotNull private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor.gui.map.tools"); /** The ToggleAction for toggling the insertBelow status. */ - private ToggleAction insertBelowAction = (ToggleAction) ACTION_FACTORY.createToggle(true, "insertBelow", this); + @SuppressWarnings({"UnusedDeclaration"}) + private final ToggleAction insertBelowAction = (ToggleAction) ACTION_FACTORY.createToggle(true, "insertBelow", this); /** The position for insertion. */ private boolean insertBelow; Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-11-11 15:46:16 UTC (rev 643) @@ -58,9 +58,6 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = getFactory("daieditor"); - /** Flag that indicates if the level has been changed since last save. */ - private boolean levelChanged = false; - /** * The CMainControl used for various operations. * @deprecated it's not a good idea to require the MapModel implementation to know such a heavy-weight strongly UI-related glue class like {@link CMainControl}. Modified: trunk/daimonin/src/daieditor/map/MapArchObject.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapArchObject.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/daimonin/src/daieditor/map/MapArchObject.java 2006-11-11 15:46:16 UTC (rev 643) @@ -244,7 +244,7 @@ } /** @return the maptext */ - public @NotNull String getText() { + @NotNull public String getText() { return msgText.toString(); } Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObject.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AnimationObject.java 2006-11-11 15:46:16 UTC (rev 643) @@ -10,13 +10,13 @@ * Get the animName, which is the name of the animation as usable by the "animations" attribute. * @return the name of this animation. */ - public String getAnimName(); + String getAnimName(); /** * Returns the animation list of this animation. * The individual entries are all postfixed with '\n'. * @return the animation list of this animation. */ - public String getAnimList(); + String getAnimList(); } // interface AnimationObject Modified: trunk/src/app/net/sf/gridarta/textedit/scripteditor/CFPythonPopup.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/scripteditor/CFPythonPopup.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/src/app/net/sf/gridarta/textedit/scripteditor/CFPythonPopup.java 2006-11-11 15:46:16 UTC (rev 643) @@ -149,7 +149,7 @@ * @return true when this popup menu has been fully initialized and is * ready for use */ - public final boolean isInitialized() { + public boolean isInitialized() { return isReady; } @@ -157,13 +157,13 @@ * Set the caret position where this menu has been invoked. * @param pos caret position in the document */ - public final void setCaretPosition(final int pos) { + public void setCaretPosition(final int pos) { caretPos = pos; getMenu().requestFocus(); ScriptEditControl.registerActivePopup(this); } - public final CFPythonPopupMenu getMenu() { + public CFPythonPopupMenu getMenu() { return menu; } @@ -183,7 +183,7 @@ ignore = false; } - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { if (!ignore) { // get method name to insert String method = popup.getSelectedItem().toString(); Modified: trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java 2006-11-11 15:46:16 UTC (rev 643) @@ -100,7 +100,7 @@ return instance; } - public static final boolean isStandAlone() { + public static boolean isStandAlone() { return isStandAlone; } @@ -108,7 +108,7 @@ * @return instance of gridarta main control (is null for stand-alone * configuration!) */ - @Nullable final MainControl getMainControl() { + @Nullable MainControl getMainControl() { return mainControl; } @@ -117,14 +117,14 @@ * popup will be closed (if still open). * @param p active popup to register */ - public static final void registerActivePopup(final CFPythonPopup p) { + public static void registerActivePopup(final CFPythonPopup p) { activePopup = p; } /** * Open a new empty script document. */ - public final void openScriptNew() { + public void openScriptNew() { opened.add("<>"); // this script has no filename assigned yet view.addTab("<New Script>", null); } @@ -132,7 +132,7 @@ /** * Open a new empty script document. */ - public final void openScriptFile(final String pathname) { + public void openScriptFile(final String pathname) { final File file = new File(pathname); if (file.exists() && file.isFile()) { @@ -149,7 +149,7 @@ /** * Open a file which is chosen by the user. */ - public final void openUserWanted() { + public void openUserWanted() { final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Open Script File"); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); @@ -178,7 +178,7 @@ /** * Close the active script-tab. */ - public final void closeActiveTab() { + public void closeActiveTab() { if (view.getSelectedIndex() >= 0 && opened.size() > 0) { opened.remove(view.getSelectedIndex()); // dump the filename } @@ -199,7 +199,7 @@ /** * Close all opened script-tabs. */ - public final void closeAllTabs() { + public void closeAllTabs() { // simply keep closing active tabs till none are left while (view.getSelectedIndex() >= 0 || opened.size() > 0) { closeActiveTab(); @@ -210,7 +210,7 @@ * Open a filebrowser and prompt the user for a location/name to store this * file. If everything goes fine, the file is saved. */ - public final void saveAsActiveTab() { + public void saveAsActiveTab() { final String activePath = getActiveFilePath(); // active file path ('null' if undefined) final String text = getActiveTextArea().getText(); // Store text data to ensure that the right text is saved later. // User could switch tabs or type text in the meantime, who knows. @@ -270,7 +270,7 @@ /** * Save the active script-tab to the stored filepath. */ - public final void saveActiveTab() { + public void saveActiveTab() { if (getActiveFilePath() != null) { final File file = new File(getActiveFilePath()); // get active path saveTextToFile(file, getActiveTextArea().getText()); // write text to file @@ -286,7 +286,7 @@ * @param file text gets saved into this file * @param text text to be saved */ - public final void saveTextToFile(final File file, String text) { + public void saveTextToFile(final File file, String text) { if (text == null) { text = ""; } @@ -317,14 +317,14 @@ /** * @return currently active JEditTextArea, or null if none are open */ - final JEditTextArea getActiveTextArea() { + JEditTextArea getActiveTextArea() { return view.getActiveTextArea(); } /** * @return file path of active tab, null if no path is available */ - @Nullable final String getActiveFilePath() { + @Nullable String getActiveFilePath() { if (view != null && opened != null && view.getSelectedIndex() >= 0 && opened.size() > 0) { // get stored path final String path = opened.get(view.getSelectedIndex()); Modified: trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditMenuBar.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditMenuBar.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditMenuBar.java 2006-11-11 15:46:16 UTC (rev 643) @@ -189,7 +189,7 @@ /** * Refreshes the enable/disable state of all menus. */ - public final void refresh() { + public void refresh() { // see if there is a path for direct 'save' miSave.setEnabled(control.getActiveFilePath() != null); } Modified: trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditView.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditView.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditView.java 2006-11-11 15:46:16 UTC (rev 643) @@ -113,7 +113,7 @@ * @param title title of this script (filename) * @param file file where this script is stored, null if new script opened */ - public final void addTab(final String title, final File file) { + public void addTab(final String title, final File file) { final JEditTextArea ta = new JEditTextArea(); // open new TextArea //ta.setFont(new Font("Courier New", Font.PLAIN, 12)); ta.setDocument(new SyntaxDocument()); @@ -172,7 +172,7 @@ /** * Close the active script-tab. */ - public final void closeActiveTab() { + public void closeActiveTab() { if (textAreas.size() > 0) { // remove textArea textAreas.remove(tabPane.getSelectedIndex()); @@ -185,7 +185,7 @@ /** * @return the currently active TextArea (in front) */ - @Nullable public final JEditTextArea getActiveTextArea() { + @Nullable public JEditTextArea getActiveTextArea() { if (getTabCount() > 0) { return textAreas.get(tabPane.getSelectedIndex()); } @@ -196,14 +196,14 @@ /** * @return index of selected tab pane */ - public final int getSelectedIndex() { + public int getSelectedIndex() { return tabPane.getSelectedIndex(); } /** * @return number of open tabs */ - public final int getTabCount() { + public int getTabCount() { return tabPane.getTabCount(); } @@ -212,7 +212,7 @@ * @param index index of the tab to change title * @param title new title string */ - public final void setTitleAt(final int index, final String title) { + public void setTitleAt(final int index, final String title) { tabPane.setTitleAt(index, title); } @@ -224,7 +224,7 @@ * @param message the message to be shown * @return true if the user agrees, false if user disagrees */ - public final boolean askConfirm(final String title, final String message) { + public boolean askConfirm(final String title, final String message) { return JOptionPane.showConfirmDialog(this, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.YES_OPTION; } @@ -235,11 +235,11 @@ * @param messageType type of message (see JOptionPane constants), defines * icon used */ - public final void showMessage(final String title, final String message, final int messageType) { + public void showMessage(final String title, final String message, final int messageType) { JOptionPane.showMessageDialog(this, message, title, messageType); } - public final void showMessage(final String title, final String message) { + public void showMessage(final String title, final String message) { JOptionPane.showMessageDialog(this, message, title, JOptionPane.INFORMATION_MESSAGE); } @@ -257,7 +257,7 @@ index = view.getSelectedIndex(); } - public final void stateChanged(final ChangeEvent e) { + public void stateChanged(final ChangeEvent e) { if (index != view.getSelectedIndex()) { // active selected tab has changed menuBar.refresh(); // refresh state of menus @@ -286,11 +286,11 @@ * Window closebox has been clicked. * @param e WindowEvent */ - @Override public final void windowClosing(final WindowEvent e) { + @Override public void windowClosing(final WindowEvent e) { control.closeAllTabs(); } - @Override public final void windowClosed(final WindowEvent e) { + @Override public void windowClosed(final WindowEvent e) { control.closeAllTabs(); // (just make sure tabs are removed...) } Modified: trunk/src/app/net/sf/gridarta/textedit/textarea/InputHandler.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/InputHandler.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/InputHandler.java 2006-11-11 15:46:16 UTC (rev 643) @@ -448,7 +448,7 @@ public static final class backspace implements ActionListener { /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); if (!textArea.isEditable()) { @@ -477,7 +477,7 @@ public static final class backspace_word implements ActionListener { /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); final int start = textArea.getSelectionStart(); if (start != textArea.getSelectionEnd()) { @@ -512,7 +512,7 @@ public static final class delete implements ActionListener { /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); if (!textArea.isEditable()) { @@ -541,7 +541,7 @@ public static final class delete_word implements ActionListener { /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); final int start = textArea.getSelectionStart(); if (start != textArea.getSelectionEnd()) { @@ -582,7 +582,7 @@ } /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); @@ -628,7 +628,7 @@ } /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); if (select) { textArea.select(textArea.getMarkPosition(), textArea.getDocumentLength()); @@ -647,7 +647,7 @@ } /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); @@ -688,7 +688,7 @@ } /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); if (select) { textArea.select(textArea.getMarkPosition(), 0); @@ -700,7 +700,7 @@ public static final class insert_break implements ActionListener { - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); if (!textArea.isEditable()) { @@ -715,7 +715,7 @@ public static final class insert_tab implements ActionListener { /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); if (!textArea.isEditable()) { @@ -737,7 +737,7 @@ } /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); final int caret = textArea.getCaretPosition(); if (caret == textArea.getDocumentLength()) { @@ -762,7 +762,7 @@ } /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); final int line = textArea.getCaretLine(); @@ -796,7 +796,7 @@ } /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); final int lineCount = textArea.getLineCount(); int firstLine = textArea.getFirstLine(); @@ -829,7 +829,7 @@ } /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); final int line = textArea.getCaretLine(); @@ -860,7 +860,7 @@ public static final class overwrite implements ActionListener { /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); textArea.setOverwriteEnabled( !textArea.isOverwriteEnabled()); @@ -876,7 +876,7 @@ } /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); final int caret = textArea.getCaretPosition(); if (caret == 0) { @@ -901,7 +901,7 @@ } /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); final int line = textArea.getCaretLine(); @@ -935,7 +935,7 @@ } /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); int firstLine = textArea.getFirstLine(); final int visibleLines = textArea.getVisibleLines(); @@ -965,7 +965,7 @@ } /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); int caret = textArea.getCaretPosition(); final int line = textArea.getCaretLine(); @@ -996,7 +996,7 @@ public static final class repeat implements ActionListener, InputHandler.NonRecordable { /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); textArea.getInputHandler().setRepeatEnabled(true); final String actionCommand = e.getActionCommand(); @@ -1009,7 +1009,7 @@ public static final class toggle_rect implements ActionListener { /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); textArea.setSelectionRectangular(!textArea.isSelectionRectangular()); } @@ -1018,7 +1018,7 @@ public static final class insert_char implements ActionListener, InputHandler.NonRepeatable { /** {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textArea = getTextArea(e); final String str = e.getActionCommand(); final int repeatCount = textArea.getInputHandler().getRepeatCount(); @@ -1045,7 +1045,7 @@ * Copy current selection into the system clipboard. * {@inheritDoc} */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { // get the selected string final String text = getTextArea(e).getSelectedText(); if (text != null) { @@ -1067,7 +1067,7 @@ * Copy current selection into the system clipboard, then delete the * selected text. */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { // get the selected string final String text = getTextArea(e).getSelectedText(); if (text != null) { @@ -1090,7 +1090,7 @@ * {@inheritDoc} * Get content of the system clipboard and insert it at caret position. */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textarea = getTextArea(e); final StringBuffer buff = new StringBuffer(""); @@ -1147,7 +1147,7 @@ * {@inheritDoc} * Save the currently active tab */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { ScriptEditControl.getInstance().saveActiveTab(); } } @@ -1163,7 +1163,7 @@ * {@inheritDoc} * Get content of the system clipboard and insert it at caret position. */ - public final void actionPerformed(final ActionEvent e) { + public void actionPerformed(final ActionEvent e) { final JEditTextArea textarea = getTextArea(e); final int caretPos = textarea.getCaretPosition(); // caret position Modified: trunk/src/app/net/sf/gridarta/textedit/textarea/JEditTextArea.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/JEditTextArea.java 2006-11-11 15:18:20 UTC (rev 642) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/JEditTextArea.java 2006-11-11 15:46:16 UTC (rev 643) @@ -212,17 +212,17 @@ * Set the TextArea font * @param f font */ - @Override public final void setFont(final Font f) { + @Override public void setFont(final Font f) { getPainter().setFont(f); } /** Returns the object responsible for painting this text area. */ - public final TextAreaPainter getPainter() { + public TextAreaPainter getPainter() { return painter; } /** Returns the input handler. */ - public final InputHandler getInputHandler() { + public InputHandler getInputHandler() { return inputHandler; } @@ -230,12 +230,12 @@ * Sets the input handler. * @param inputHandler the new input handler */ - public final void setInputHandler(final InputHandler inputHandler) { + public void setInputHandler(final InputHandler inputHandler) { this.inputHandler = inputHandler; } /** Returns true if the caret is blinking, false otherwise. */ - public final boolean isCaretBlinkEnabled() { + public boolean isCaretBlinkEnabled() { return caretBlinks; } @@ -243,7 +243,7 @@ * Toggles caret blinking. * @param caretBlinks true if the caret should blink, false otherwise */ - public final void setCaretBlinkEnabled(final boolean caretBlinks) { + public void setCaretBlinkEnabled(final boolean caretBlinks) { this.caretBlinks = caretBlinks; if (!caretBlinks) { blink = false; @@ -253,7 +253,7 @@ } /** Returns true if the caret is visible, false otherwise. */ - public final boolean isCaretVisible() { + public boolean isCaretVisible() { return (!caretBlinks || blink) && caretVisible; } @@ -261,7 +261,7 @@ * Sets if the caret should be visible. * @param caretVisible true if the caret should be visible, false otherwise */ - public final void setCaretVisible(final boolean caretVisible) { + public void setCaretVisible(final boolean caretVisible) { this.caretVisible = caretVisible; blink = true; @@ -269,7 +269,7 @@ } /** Blinks the caret. */ - public final void blinkCaret() { + public void blinkCaret() { if (caretBlinks) { blink = !blink; painter.invalidateSelectedLines(); @@ -282,7 +282,7 @@ * Returns the number of lines from the top and button of the text area * that are always visible. */ - public final int getElectricScroll() { + public int getElectricScroll() { return electricScroll; } @@ -292,7 +292,7 @@ * @param electricScroll the number of lines always visible from the top or * bottom */ - public final void setElectricScroll(final int electricScroll) { + public void setElectricScroll(final int electricScroll) { this.electricScroll = electricScroll; } @@ -301,7 +301,7 @@ * number of lines in the document changes, or when the size of the text * are changes. */ - public final void updateScrollBars() { + public void updateScrollBars() { if (vertical != null && visibleLines != 0) { vertical.setValues(firstLine, visibleLines, 0, getLineCount()); //vertical.setUnitIncrement(2); @@ -319,7 +319,7 @@ } /** Returns the line displayed at the text area's origin. */ - public final int getFirstLine() { + public int getFirstLine() { return firstLine; } @@ -327,7 +327,7 @@ * Sets the line displayed at the text area's origin without updating the * scroll bars. */ - public final void setFirstLine(final int firstLine) { + public void setFirstLine(final int firstLine) { if (firstLine == this.firstLine) { return; } @@ -340,7 +340,7 @@ } /** Returns the number of lines visible in this text area. */ - public final int getVisibleLines() { + public int getVisibleLines() { return visibleLines; } @@ -348,7 +348,7 @@ * Recalculates the number of visible lines. This should not be called * directly. */ - public final void recalculateVisibleLines() { + public void recalculateVisibleLines() { if (painter == null) { return; } @@ -368,7 +368,7 @@ } /** Returns the horizontal offset of drawn lines. */ - public final int getHorizontalOffset() { + public int getHorizontalOffset() { return horizontalOffset; } @@ -377,7 +377,7 @@ * horizontal scrolling. * @param horizontalOffset offset The new horizontal offset */ - public final void setHorizontalOffset(final int horizontalOffset) { + public void setHorizontalOffset(final int horizontalOffset) { if (horizontalOffset == this.horizontalOffset) { return; } @@ -396,7 +396,7 @@ * @param horizontalOffset the new horizontal offset * @return true if any of the values were changed, false otherwise */ - public final boolean setOrigin(final int firstLine, final int horizontalOffset) { + public boolean setOrigin(final int firstLine, final int horizontalOffset) { boolean changed = false; if (horizontalOffset != this.horizontalOffset) { @@ -423,7 +423,7 @@ * @return true if scrolling was actually performed, false if the caret was * already visible */ - public final boolean scrollToCaret() { + public boolean scrollToCaret() { final int line = getCaretLine(); final int lineStart = getLineStartOffset(line); final int offset = Math.max(0, Math.min(getLineLength(line) - 1, getCaretPosition() - lineStart)); @@ -436,7 +436,7 @@ * registered for keypress-events. The graphics context must be fully * initialized before calling this method. */ - public final void setEditingFocus() { + public void setEditingFocus() { try { requestFocus(); setCaretVisible(true); @@ -455,7 +455,7 @@ * @return true if scrolling was actually performed, false if the line and * offset was already visible */ - public final boolean scrollTo(final int line, final int offset) { + public boolean scrollTo(final int line, final int offset) { // visibleLines == 0 before the component is realized // we can't do any proper scrolling then, so we have // this hack... @@ -495,7 +495,7 @@ * Converts a line index to a y co-ordinate. * @param line the line */ - public final int lineToY(final int line) { + public int lineToY(final int line) { final FontMetrics fm = painter.getFontMetrics(); return (line - firstLine) * fm.getHeight() - (fm.getLeading() + fm.getMaxDescent()); } @@ -504,7 +504,7 @@ * Converts a y co-ordinate to a line index. * @param y the y co-ordinate */ - public final int yToLine(final int y) { + public int yToLine(final int y) { final FontMetrics fm = painter.getFontMetrics(); final int height = fm.getHeight(); return Math.max(0, Math.min(getLineCount() - 1, y / height + firstLine)); @@ -516,7 +516,7 @@ * @param line the line * @param offset the offset, from the start of the line */ - public final int offsetToX(final int line, final int offset) { + public int offsetToX(final int line, final int offset) { // don't use cached tokens painter.setCurrentLineTokens(null); return _offsetToX(line, offset); @@ -529,7 +529,7 @@ * @param line the line * @param offset the offset, from the start of the line */ - public final int _offsetToX(final int line, final int offset) { + public int _offsetToX(final int line, final int offset) { final TokenMarker tokenMarker = getTokenMarker(); /* Use painter's cached info for speed */ @@ -591,7 +591,7 @@ * @param line the line * @param x the x co-ordinate */ - public final int xToOffset(final int line, final int x) { + public int xToOffset(final int line, final int x) { final TokenMarker tokenMarker = getTokenMarker(); /* Use painter's cached info for speed */ @@ -690,14 +690,14 @@ * @param x the x co-ordinate of the point * @param y the y co-ordinate of the point */ - public final int xyToOffset(final int x, final int y) { + public int xyToOffset(final int x, final int y) { final int line = yToLine(y); final int start = getLineStartOffset(line); return start + xToOffset(line, x); } /** Returns the document this text area is editing. */ - public final SyntaxDocument getDocument() { + public SyntaxDocument getDocument() { return document; } @@ -705,7 +705,7 @@ * Sets the document this text area is editing. * @param document the document */ - public final void setDocument(final SyntaxDocument document) { + public void setDocument(final SyntaxDocument document) { if (this.document == document) { return; } @@ -727,7 +727,7 @@ * Returns the document's token marker. Equivalent to calling * <code>getDocument().getTokenMarker()</code>. */ - public final TokenMarker getTokenMarker() { + public TokenMarker getTokenMarker() { return document.getTokenMarker(); } @@ -736,7 +736,7 @@ * <code>getDocument().setTokenMarker()</code>. * @param tokenMarker the token marker */ - public final void setTokenMarker(final TokenMarker tokenMarker) { + public void setTokenMarker(final TokenMarker tokenMarker) { document.setTokenMarker(tokenMarker); } @@ -744,12 +744,12 @@ * Returns the length of the document. Equivalent to calling * <code>getDocument().getLength()</code>. */ - public final int getDocumentLength() { + public int getDocumentLength() { return document.getLength(); } /** Returns the number of lines in the document. */ - public final int getLineCount() { + public int getLineCount() { return document.getDefaultRootElement().getElementCount(); } @@ -757,7 +757,7 @@ * Returns the line containing the specified offset. * @param offset the offset */ - public final int getLineOfOffset(final int offset) { + public int getLineOfOffset(final int offset) { return document.getDefaultRootElement().getElementIndex(offset); } @@ -767,7 +767,7 @@ * @return the start offset of the specified line, or -1 if the line is * invalid */ - public final int getLineStartOffset(final int line) { + public int getLineStartOffset(final int line) { final Element lineElement = document.getDefaultRootElement().getElement(line); if (lineElement == null) { return -1; @@ -782,7 +782,7 @@ * @return the end offset of the specified line, or -1 if the line is * invalid */ - public final int getLineEndOffset(final int line) { + public int getLineEndOffset(final int line) { final Element lineElement = document.getDefaultRootElement().getElement(line); if (lineElement == null) { return -1; @@ -795,7 +795,7 @@ * Returns the length of the specified line. * @param line the line */ - public final int getLineLength(final int line) { + public int getLineLength(final int line) { final Element lineElement = document.getDefaultRootElement().getElement(line); if (lineElement == null) { return -1; @@ -807,7 +807,7 @@ /** * Returns the entire text of this text area. */ - @Nullable public final String getText() { + @Nullable public String getText() { try { return document.getText(0, document.getLength()); } catch (final BadLocationException bl) { @@ -819,7 +819,7 @@ /** * Sets the entire text of this text area. */ - public final void setText(final String text) { + public void setText(final String text) { try { SyntaxDocument.beginCompoundEdit(); document.remove(0, document.getLength()); @@ -837,7 +837,7 @@ * @param len the length of the substring * @return the substring, or null if the offsets are invalid */ - @Nullable public final String getText(final int start, final int len) { + @Nullable public String getText(final int start, final int len) { try { return document.getText(start, len); } catch (final BadLocationException bl) { @@ -853,7 +853,7 @@ * @param len the length of the substring * @param segment the segment */ - public final void getText(final int start, final int len, final Segment segment) { + public void getText(final int start, final int len, final Segment segment) { try { document.getText(start, len, segment); } catch (final BadLocationException bl) { @@ -867,7 +867,7 @@ * @param lineIndex the line * @return the text, or null if the line is invalid */ - public final String getLineText(final int lineIndex) { + public String getLineText(final int lineIndex) { final int start = getLineStartOffset(lineIndex); return getText(start, getLineEndOffset(lineIndex) - start - 1); } @@ -877,20 +877,20 @@ * invalid, the segment will contain a null string. * @param lineIndex the line */ - public final void getLineText(final int lineIndex, final Segment segment) { + public void getLineText(final int lineIndex, final Segment segment) { final int start = getLineStartOffset(lineIndex); getText(start, getLineEndOffset(lineIndex) - start - 1, segment); } /** Returns the selection start offset. */ - public final int getSelectionStart() { + public int getSelectionStart() { return selectionStart; } /** * Returns the offset where the selection starts on the specified line. */ - public final int getSelectionStart(final int line) { + public int getSelectionStart(final int line) { if (line == selectionStartLine) { return selectionStart; } else if (rectSelect) { @@ -907,7 +907,7 @@ } /** Returns the selection start line. */ - public final int getSelectionStartLine() { + public int getSelectionStartLine() { return selectionStartLine; } @@ -917,19 +917,19 @@ * @param selectionStart the selection start * @see #select(int, int) */ - public final void setSelectionStart(final int selectionStart) { + public void setSelectionStart(final int selectionStart) { select(selectionStart, selectionEnd); } /** Returns the selection end offset. */ - public final int getSelectionEnd() { + public int getSelectionEnd() { return selectionEnd; } /** * Returns the offset where the selection ends on the specified line. */ - public final int getSelectionEnd(final int line) { + public int getSelectionEnd(final int line) { if (line == selectionEndLine) { return selectionEnd; } else if (rectSelect) { @@ -946,7 +946,7 @@ } /** Returns the selection end line. */ - public final int getSelectionEndLine() { + public int getSelectionEndLine() { return selectionEndLine; } @@ -956,7 +956,7 @@ * @param selectionEnd the selection end * @see #select(int, int) */ - public final void setSelectionEnd(final int selectionEnd) { + public void setSelectionEnd(final int selectionEnd) { select(selectionStart, selectionEnd); } @@ -965,12 +965,12 @@ * the selection end, depending on which direction the selection was made * in. */ - public final int getCaretPosition() { + public int getCaretPosition() { return biasLeft ? selectionStart : selectionEnd; } /** Returns the caret line. */ - public final int getCaretLine() { + public int getCaretLine() { return biasLeft ? selectionStartLine : selectionEndLine; } @@ -979,12 +979,12 @@ * the caret position. * @see #getCaretPosition() */ - public final int getMarkPosition() { + public int getMarkPosition() { return biasLeft ? selectionEnd : selectionStart; } /** Returns the mark line. */ - public final int getMarkLine() { + public int getMarkLine() { return biasLeft ? selectionEndLine : selectionStartLine; } @@ -994,21 +994,21 @@ * @param caret the caret position * @see #select(int, int) */ - public final void setCaretPosition(final int caret) { + public void setCaretPosition(final int caret) { select(caret, caret); } /** * Selects all text in the document. */ - public final void selectAll() { + public void selectAll() { select(0, getDocumentLength()); } /** * Moves the mark to the caret position. */ - public final void selectNone() { + public void selectNone() { select(getCaretPosition(), getCaretPosition()); } @@ -1019,7 +1019,7 @@ * @param start the start offset * @param end the end offset */ - public final void select(final int start, final int end) { + public void select(final int start, final int end) { final int newStart; final int newEnd; final boolean newBias; @@ -1088,7 +1088,7 @@ /** * Returns the selected text, or null if no selection is active. */ - @Nullable public final String getSelectedText() { + @Nullable public String getSelectedText() { if (selectionStart == selectionEnd) { return null; } @@ -1138,7 +1138,7 @@ * Replaces the selection with the specified text. * @param selectedText the replacement text for the selection */ - public final void setSelectedText(final String selectedText) { + public void setSelectedText(final String selectedText) { if (!editable) { throw new InternalError("Text component read only"); } @@ -1208,7 +1208,7 @@ } /** Returns true if this text area is editable, false otherwise. */ - public final boolean isEditable() { + public boolean isEditable() { return editable; } @@ -1217,12 +1217,12 @@ * @param editable true if this text area should be editable, false * otherwise */ - public final void setEditable(final boolean editable) { + public void setEditable(final boolean editable) { this.editable = editable; } /** Returns the right click popup menu. */ - public final JPopupMenu getRightClickPopup() { + public JPopupMenu getRightClickPopup() { return popup; } @@ -1230,7 +1230,7 @@ * Sets the right click popup menu. * @param popup the popup */ - public final void setRightClickPopup(final JPopupMenu popup) { + public void setRightClickPopup(final JPopupMenu popup) { this.popup = popup; } @@ -1238,7 +1238,7 @@ * Returns the `magic' caret position. This can be used to preserve the * column position when moving up and down lines. */ - public final int getMagicCaretPosition() { + public int getMagicCaretPosition() { return magicCaret; } @@ -1247,7 +1247,7 @@ * position when moving up and down lines. * @param magicCaret the magic caret position */ - public final void setMagicCaretPosition(final int magicCaret) { + public void setMagicCaretPosition(final int magicCaret) { this.magicCaret = magicCaret; } @@ -1258,7 +1258,7 @@ * @see #setSelectedText(String) * @see #isOverwriteEnabled() */ - public final void overwriteSetSelectedText(final String str) { + public void overwriteSetSelectedText(final String str) { // Don't overstrike if there is a selection if (!overwrite || selectionStart != selectionEnd) { setSelectedText(str); @@ -1287,7 +1287,7 @@ } /** Returns true if overwrite mode is enabled, false otherwise. */ - public final boolean isOverwriteEnabled() { + public boolean isOverwriteEnabled() { return overwrite; } @@ -1296,13 +1296,13 @@ * @param overwrite true if overwrite mode should be enabled, false * otherwise */ - public final void setOverwriteEnabled(final boolean overwrite) { + public void setOverwriteEnabled(final boolean overwrite) { this.overwrite = overwrite; painter.invalidateSelectedLines(); } /** Returns true if the selection is rectangular, false otherwise. */ - public final boolean isSelectionRectangular() { + public boolean isSelectionRectangular() { return rectSelect; } @@ -1311,7 +1311,7 @@ * @param rectSelect true if the selection should be rectangular, false * otherwise */ - public final void setSelectionRectangular(final boolean rectSelect) { + public void setSelectionRectangular(final boolean rectSelect) { this.rectSelect = rectSelect; painter.invalidateSelectedLines(); } @@ -1320,7 +1320,7 @@ * Returns the position of the highlighted bracket (the bracket matching * the one before the caret). */ - public final int getBracketPosition() { + public int getBracketPosition() { return bracketPosition; } @@ -1328,7 +1328,7 @@ * Returns the line of the highlighted bracket (the bracket matching the * one before the caret). */ - public final int getBracketLine() { + public int getBracketLine() { return bracketLine; } @@ -1336,7 +1336,7 @@ * Adds a caret change listener to this text area. * @param listener the listener */ - public final void addCaretListener(final CaretListener listener) { + public void addCaretListener(final CaretListener listener) { listenerList.add(CaretListener.class, listener); } @@ -1344,7 +1344,7 @@ * Removes a caret change listener from this text area. * @param listener the listener */ - public final void removeCaretListener(final CaretListener listener) { + public void removeCaretListener(final CaretListener listener) { listenerList.remove(CaretListener.class, listener); } @@ -1352,7 +1352,7 @@ * Deletes the selected text from the text area and places it into the * clipboard. */ - public final void cut() { + public void cut() { if (editable) { copy(); setSelectedText(""); @@ -1360,7 +1360,7 @@ } /** Places the selected text into the clipboard. */ - public final void copy() { + public void copy() { if (selectionStart != selectionEnd) { final Clipboard clipboard = getToolkit().getSystemClipboard(); @@ -1379,7 +1379,7 @@ /** * Inserts the clipboard contents into the text. */ - public final void paste() { + public void paste() { if (editable) { final Clipboard clipboard = getToolkit().getSystemClipboard(); try { @@ -1405,7 +1405,7 @@ * Called by the AWT when this component is removed from it's parent. This * stops clears the currently focused component. */ - @Override public final void removeNotify() { + @Override public void removeNotify() { super.removeNotify(); if (focusedComponent == this) { focusedComponent = null; @@ -1416,7 +1416,7 @@ * Forwards key events directly to the input handler. This is slightly * faster than using a KeyListener because some Swing overhead is avoided. */ - @Override public final void processKeyEvent(final KeyEvent evt) { + @Override public void processKeyEvent(final KeyEvent evt) { if (inputHandler == null) { return; } @@ -1505,7 +1505,7 @@ protected boolean rectSelect; - protected final void fireCaretEvent() { + protected void fireCaretEvent() { final Object[] listeners = listenerList.getListenerList(); for (int i = listeners.length - 2; i >= 0; i--) { if (listeners[i] == CaretListener.class) { @@ -1514,7 +1514,7 @@ } } - protected final void updateBracketHighlight(final int newCaretPosition) { + protected void updateBracketHighlight(final int newCaretPosition) { if (newCaretPosition == 0) { bracketPosition = bracketLine = -1; return; @@ -1534,7 +1534,7 @@ bracketLine = bracketPosition = -1; } - protected final void documentChanged(final DocumentEvent evt) { + protected void documentChanged(final DocumentEvent evt) { final DocumentEvent.ElementChange ch = evt.getChange(document.getDefaultRootElement()); final int count; @@ -1559,7 +1559,7 @@ final class ScrollLayout implements LayoutManager { - public final void addLayoutComponent(final String name, final Component comp) { + public void addLayoutComponent(final String name, final Component comp) { if (name.equals(CENTER)) { center = comp; } else if (name.equals(RIGHT)) { @@ -1571,7 +1571,7 @@ } } - public final void removeLayoutComponent(final Component comp) { + public void removeLayoutComponent(final Component comp) { if (center == comp) { center = null; } @@ -1587,7 +1587,7 @@ } } - public final Dimension preferredLayoutSize(final Container parent) { + public Dimension preferredLayoutSize(final Container parent) { final Dimension dim = new Dimension(); final Insets insets = getInsets(); dim.width = insets.left + insets.right; @@ -1604,7 +1604,7 @@ return dim; } - public final Dimension minimumLayoutSize(final Container parent) { + public Dimension minimumLayoutSize(final Container parent) { final Dimension dim = new Dimension(); final Insets insets = getInsets(); dim.width = insets.left + insets.right; @@ -1621,7 +1621,7 @@ return dim; } - public final void layoutContainer(final Container parent) { + public void layoutContainer(final Container parent) { final Dimension size = parent.getS... [truncated message content] |
From: <chr...@us...> - 2006-11-11 15:18:36
|
Revision: 642 http://svn.sourceforge.net/gridarta/?rev=642&view=rev Author: christianhujer Date: 2006-11-11 07:18:20 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Minor code cleanup: Improved some naming. Removed unneccessary invocation indirection. Moved global rng to common interface. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CArchPanel.java trunk/daimonin/src/daieditor/CArchQuickView.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-11 15:04:21 UTC (rev 641) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-11-11 15:18:20 UTC (rev 642) @@ -74,9 +74,6 @@ /** ActionFactory. */ private static final ActionFactory ACTION_FACTORY = getFactory("cfeditor"); - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - /** Logger. */ private static final Logger log = Logger.getLogger(CMainControl.class); @@ -155,9 +152,6 @@ private String strCurrentDir; - /** Global random number generator. */ - public static final Random rnd = new Random(System.currentTimeMillis() + 19580427); - // resource directories private File mapDir; Modified: trunk/daimonin/src/daieditor/CArchPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CArchPanel.java 2006-11-11 15:04:21 UTC (rev 641) +++ trunk/daimonin/src/daieditor/CArchPanel.java 2006-11-11 15:18:20 UTC (rev 642) @@ -136,8 +136,8 @@ return selectedPanel != null ? selectedPanel.getArchListObject() : null; } - public void showArchPanelQuickObject(final GameObject arch) { - archQuickPanel.showArchPanelQuickObject(arch); + public void showArchPanelQuickObject(final GameObject gameObject) { + archQuickPanel.showArchPanelQuickObject(gameObject); } public int addArchPanelCombo(final String name) { Modified: trunk/daimonin/src/daieditor/CArchQuickView.java =================================================================== --- trunk/daimonin/src/daieditor/CArchQuickView.java 2006-11-11 15:04:21 UTC (rev 641) +++ trunk/daimonin/src/daieditor/CArchQuickView.java 2006-11-11 15:18:20 UTC (rev 642) @@ -91,11 +91,11 @@ /** * Show quick info for an object. * - * @param gameObjectPart the object to show; this may be any part of a multi-part + * @param gameObject the object to show; this may be any part of a multi-part * object */ - void showArchPanelQuickObject(final GameObject gameObjectPart) { - if (gameObjectPart == null) { + void showArchPanelQuickObject(final GameObject gameObject) { + if (gameObject == null) { if (mainControl.getMainView().isPickmapActive()) { archObjNameText.setText(" -random pick- "); archObjNameText.setForeground(Color.BLUE); @@ -106,11 +106,11 @@ archTypeText.setText(null); archTileText.setText(null); } else { - final GameObject gameObject = gameObjectPart.getHead(); - String objName = gameObject.getObjName(); + final GameObject headObject = gameObject.getHead(); + String objName = headObject.getObjName(); if (objName == null || objName.length() == 0) { - final Archetype<GameObject> archetype = gameObject.getArchetype(); - if (archetype == null || archetype == gameObject) { + final Archetype<GameObject> archetype = headObject.getArchetype(); + if (archetype == null || archetype == headObject) { objName = null; } else if ((objName = archetype.getObjName()) != null && objName.length() != 0) { } else if ((objName = archetype.getArchetypeName()) != null && objName.length() != 0) { @@ -126,19 +126,19 @@ } archObjNameText.setText(objName); - archArchNameText.setText(gameObject.getArchetypeName()); + archArchNameText.setText(headObject.getArchetypeName()); - archTypeText.setText(mainControl.getTypeList().getArchTypeName(gameObject.getArchTypNr()) + " (" + gameObject.getArchTypNr() + ')'); + archTypeText.setText(mainControl.getTypeList().getArchTypeName(headObject.getArchTypNr()) + " (" + headObject.getArchTypNr() + ')'); - if (gameObject.isMulti()) { - archTileText.setText("<html><span style=\"color:green;\"> multi</span> (" + gameObject.getMultiRefCount() + " parts) (" + gameObject.getSizeX() + ',' + gameObject.getSizeY() + ")</html>"); + if (headObject.isMulti()) { + archTileText.setText("<html><span style=\"color:green;\"> multi</span> (" + headObject.getMultiRefCount() + " parts) (" + headObject.getSizeX() + ',' + headObject.getSizeY() + ")</html>"); } else { archTileText.setText("single"); } // notify ReplaceDialog if (ReplaceDialog.isBuilt() && ReplaceDialog.getInstance().isShowing()) { - ReplaceDialog.getInstance().updateArchSelection(gameObject, false); + ReplaceDialog.getInstance().updateArchSelection(headObject, false); } } } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-11-11 15:04:21 UTC (rev 641) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-11-11 15:18:20 UTC (rev 642) @@ -80,7 +80,6 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import static java.lang.System.currentTimeMillis; import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; @@ -88,7 +87,6 @@ import java.util.List; import java.util.ListIterator; import java.util.MissingResourceException; -import java.util.Random; import static java.util.ResourceBundle.getBundle; import java.util.logging.Level; import java.util.logging.Logger; @@ -242,9 +240,6 @@ /** The current main directory. */ private File currentDir; - /** Global random number generator. */ - public static final Random rnd = new Random(currentTimeMillis() + 19580427); - // resource directories private File mapDir; @@ -783,8 +778,8 @@ } // setup quick view window - public void showArchPanelQuickObject(final GameObject arch) { - mainView.showArchPanelQuickObject(arch); + public void showArchPanelQuickObject(final GameObject gameObject) { + mainView.showArchPanelQuickObject(gameObject); } boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final int mapx, final int mapy) { Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-11-11 15:04:21 UTC (rev 641) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-11-11 15:18:20 UTC (rev 642) @@ -293,7 +293,7 @@ return arch; } } - mainControl.showArchPanelQuickObject(null); // send it to quick view + showArchPanelQuickObject(null); return null; } @@ -332,8 +332,8 @@ return null; } - public void showArchPanelQuickObject(final GameObject arch) { - archPanel.showArchPanelQuickObject(arch); + public void showArchPanelQuickObject(final GameObject gameObject) { + archPanel.showArchPanelQuickObject(gameObject); } /** @return the panel with all pickmaps */ Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2006-11-11 15:04:21 UTC (rev 641) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2006-11-11 15:18:20 UTC (rev 642) @@ -4,6 +4,7 @@ import net.sf.gridarta.gameobject.ArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeSet; import org.jetbrains.annotations.NotNull; +import java.util.Random; /** * This interface is only for unification. @@ -13,6 +14,11 @@ public interface MainControl { /** + * Global random number generator. + */ + Random rnd = new Random(); + + /** * Refresh menus and toolbars. * @deprecated This method is bullshit for being a severe violation of MVC and therefore MUST be removed some day. Do not use it for other than unification purposes. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-11 15:04:27
|
Revision: 641 http://svn.sourceforge.net/gridarta/?rev=641&view=rev Author: christianhujer Date: 2006-11-11 07:04:21 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Cosmetic code cleanup. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/textedit/textarea/KeywordMap.java Modified: trunk/src/app/net/sf/gridarta/textedit/textarea/KeywordMap.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/KeywordMap.java 2006-11-11 14:26:47 UTC (rev 640) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/KeywordMap.java 2006-11-11 15:04:21 UTC (rev 641) @@ -22,6 +22,13 @@ */ public final class KeywordMap { + // protected members + private final int mapLength; + + private final Keyword[] map; + + private boolean ignoringCase; + /** * Creates a new <code>KeywordMap</code>. * @param ignoreCase True if keys are case insensitive @@ -38,7 +45,7 @@ */ public KeywordMap(final boolean ignoreCase, final int mapLength) { this.mapLength = mapLength; - this.ignoreCase = ignoreCase; + this.ignoringCase = ignoreCase; map = new Keyword[mapLength]; } @@ -48,7 +55,7 @@ * @param offset the offset of the substring within the text segment * @param length the length of the substring */ - public final byte lookup(final Segment text, final int offset, final int length) { + public byte lookup(final Segment text, final int offset, final int length) { if (length == 0) { return Token.NULL; } @@ -59,7 +66,7 @@ k = k.next; continue; } - if (SyntaxUtilities.regionMatches(ignoreCase, text, offset, k.keyword)) { + if (SyntaxUtilities.regionMatches(ignoringCase, text, offset, k.keyword)) { return k.id; } @@ -73,57 +80,51 @@ * @param keyword the key * @param id the value */ - public final void add(final String keyword, final byte id) { + public void add(final String keyword, final byte id) { final int key = getStringMapKey(keyword); map[key] = new Keyword(keyword.toCharArray(), id, map[key]); } /** - * Returns true if the keyword map is set to be case insensitive, false - * otherwise. + * Returns whether the keyword map is set to be case insensitive. + * @return <code>true</code> if the keyword map is case insensitive, otherwise <code>false</code>. */ - public final boolean getIgnoreCase() { - return ignoreCase; + public boolean isIgnoringCase() { + return ignoringCase; } /** * Sets if the keyword map should be case insensitive. - * @param ignoreCase true if the keyword map should be case insensitive, + * @param ignoringCase true if the keyword map should be case insensitive, * false otherwise */ - public final void setIgnoreCase(final boolean ignoreCase) { - this.ignoreCase = ignoreCase; + public void setIgnoringCase(final boolean ignoringCase) { + this.ignoringCase = ignoringCase; } - // protected members - private final int mapLength; - - protected final int getStringMapKey(final String s) { + protected int getStringMapKey(final String s) { return (Character.toUpperCase(s.charAt(0)) + Character.toUpperCase(s.charAt(s.length() - 1))) % mapLength; } - protected final int getSegmentMapKey(final Segment s, final int off, final int len) { + protected int getSegmentMapKey(final Segment s, final int off, final int len) { return (Character.toUpperCase(s.array[off]) + Character.toUpperCase(s.array[off + len - 1])) % mapLength; } // private members static final class Keyword { - public Keyword(final char[] keyword, final byte id, final Keyword next) { - this.keyword = keyword; - this.id = id; - this.next = next; - } - private final char[] keyword; private final byte id; private final Keyword next; - } - private final Keyword[] map; + public Keyword(final char[] keyword, final byte id, final Keyword next) { + this.keyword = keyword; + this.id = id; + this.next = next; + } - private boolean ignoreCase; + } // class Keyword } // class KeywordMap This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-11 14:26:56
|
Revision: 640 http://svn.sourceforge.net/gridarta/?rev=640&view=rev Author: christianhujer Date: 2006-11-11 06:26:47 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Naming improvements. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/MapCursor.java Modified: trunk/src/app/net/sf/gridarta/gui/map/MapCursor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursor.java 2006-11-11 13:32:57 UTC (rev 639) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursor.java 2006-11-11 14:26:47 UTC (rev 640) @@ -53,10 +53,10 @@ private final Dimension dragOffset = new Dimension(); /** Is cursor shown? */ - private boolean isOnMap; + private boolean onMap; /** Gets set to <code>true</code> when in drag mode. */ - private boolean isDragging; + private boolean dragging; /** Grid where cursor is bound to. */ private MapGrid mapGrid; @@ -101,7 +101,7 @@ * @return coordinates of cursor or <code>null</code> if cursor is not active */ @Nullable public Point getLocation() { - return isOnMap ? pos : null; + return onMap ? pos : null; } /** @@ -112,7 +112,7 @@ public boolean setLocation(@Nullable final Point p) { final boolean hasChanged; if (p != null && mapRec.contains(p)) { - if (isOnMap) { + if (onMap) { if (pos.equals(p)) { hasChanged = false; } else { @@ -125,12 +125,12 @@ } else { pos.setLocation(p); mapGrid.setCursor(pos); - isOnMap = true; + onMap = true; fireMapCursorChangedModeEvent(); fireMapCursorChangedPosEvent(); hasChanged = true; } - } else if (isOnMap) { + } else if (onMap) { deactivate(); hasChanged = true; } else { @@ -147,7 +147,7 @@ public boolean setLocationSafe(@Nullable final Point p) { final boolean hasChanged; if (p != null && mapRec.contains(p)) { - if (isOnMap) { + if (onMap) { if (pos.equals(p)) { hasChanged = false; } else { @@ -158,7 +158,7 @@ } } else { pos.setLocation(p); - isOnMap = true; + onMap = true; fireMapCursorChangedModeEvent(); hasChanged = true; } @@ -173,10 +173,10 @@ /** Set cursor to drag mode when it is active. */ public void dragStart() { - if (isOnMap && !isDragging) { + if (onMap && !dragging) { dragStart.setLocation(pos); mapGrid.preSelect(dragStart, pos); - isDragging = true; + dragging = true; dragOffset.setSize(0, 0); fireMapCursorChangedModeEvent(); } @@ -189,7 +189,7 @@ * @return <code>true</code> when dragging position changed successfully */ public boolean dragTo(@Nullable final Point p) { - if (p != null && mapRec.contains(p) && isDragging && !pos.equals(p)) { + if (p != null && mapRec.contains(p) && dragging && !pos.equals(p)) { mapGrid.unPreSelect(dragStart, pos); mapGrid.unSetCursor(pos); pos.setLocation(p); @@ -204,9 +204,9 @@ /** Leave drag mode and undo preselection. */ public void dragRelease() { - if (isDragging) { + if (dragging) { mapGrid.unPreSelect(dragStart, pos); - isDragging = false; + dragging = false; fireMapCursorChangedModeEvent(); } } @@ -217,7 +217,7 @@ * @see MapGrid.SelectionMode */ public void dragSelect(final MapGrid.SelectionMode selectionMode) { - if (isDragging) { + if (dragging) { dragRelease(); mapGrid.select(dragStart, pos, selectionMode); } @@ -225,9 +225,9 @@ /** Cursor gets deactivated. All selections get lost. */ public void deactivate() { - final boolean hasChanged = isOnMap; - isOnMap = false; - isDragging = false; + final boolean hasChanged = onMap; + onMap = false; + dragging = false; mapGrid.unSetCursor(pos); mapGrid.unSelect(); if (hasChanged) { @@ -241,19 +241,15 @@ * @return <code>true</code> if cursor is on the map */ public boolean isActive() { - return isOnMap; + return onMap; } /** * Get offset from start position of dragging. * @return offset or <code>null</code> when not in drag mode */ - @Nullable public final Dimension getDragOffset() { - if (isDragging) { - return dragOffset; - } else { - return null; - } + @Nullable public Dimension getDragOffset() { + return dragging ? dragOffset : null; } /** @@ -272,9 +268,9 @@ */ public boolean go(final int dir) { assert dir >= 0 && dir < 8; - if (isOnMap) { + if (onMap) { tmpPoint.setLocation(pos.x + direction[dir][0], pos.y + direction[dir][1]); - if (isDragging) { + if (dragging) { return dragTo(tmpPoint); } else { return setLocationSafe(tmpPoint); @@ -283,9 +279,12 @@ return false; } - /** Getter of {@link #isDragging}. */ + /** + * Returns whether the cursor is currently being dragged. + * @return <code>true</code> if dragging is active, otherwise <code>false</code>. + */ public boolean isDragging() { - return isDragging; + return dragging; } /** @@ -336,12 +335,12 @@ /** {@inheritDoc} */ public void mapGridResized(@NotNull final MapGridEvent e) { // Test if drag start point is outside map -> move inside - if (isDragging && !mapRec.contains(dragStart)) { + if (dragging && !mapRec.contains(dragStart)) { dragStart.x = min(dragStart.x, mapRec.width - 1); dragStart.y = min(dragStart.y, mapRec.height - 1); } // Test if cursor position is outside map -> move inside - if (isOnMap && !mapRec.contains(pos)) { + if (onMap && !mapRec.contains(pos)) { pos.x = min(pos.x, mapRec.width - 1); pos.y = min(pos.y, mapRec.height - 1); mapGrid.setCursor(pos); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-11 13:33:06
|
Revision: 639 http://svn.sourceforge.net/gridarta/?rev=639&view=rev Author: christianhujer Date: 2006-11-11 05:32:57 -0800 (Sat, 11 Nov 2006) Log Message: ----------- Fixed bug: Grid was not painted correctly for non-square maps. Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-11-10 23:11:30 UTC (rev 638) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2006-11-11 13:32:57 UTC (rev 639) @@ -416,15 +416,15 @@ for (int x = 0; x <= mapSize.getWidth(); x++) { grfx.drawLine(origin.x + x * IGUIConstants.TILE_ISO_XLEN2 - 1, origin.y + x * IGUIConstants.TILE_ISO_YLEN2 - 1, - origin.x - (mapSize.getWidth() - x) * IGUIConstants.TILE_ISO_XLEN2 - 1, - origin.y + (mapSize.getWidth() + x) * IGUIConstants.TILE_ISO_YLEN2 - 1); + origin.x - (mapSize.getHeight() - x) * IGUIConstants.TILE_ISO_XLEN2 - 1, + origin.y + (mapSize.getHeight() + x) * IGUIConstants.TILE_ISO_YLEN2 - 1); } for (int y = 0; y <= mapSize.getHeight(); y++) { grfx.drawLine(origin.x - y * IGUIConstants.TILE_ISO_XLEN2 - 1, origin.y + y * IGUIConstants.TILE_ISO_YLEN2 - 1, - origin.x + (mapSize.getHeight() - y) * IGUIConstants.TILE_ISO_XLEN2 - 1, - origin.y + (mapSize.getHeight() + y) * IGUIConstants.TILE_ISO_YLEN2 - 1); + origin.x + (mapSize.getWidth() - y) * IGUIConstants.TILE_ISO_XLEN2 - 1, + origin.y + (mapSize.getWidth() + y) * IGUIConstants.TILE_ISO_YLEN2 - 1); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-10 23:11:36
|
Revision: 638 http://svn.sourceforge.net/gridarta/?rev=638&view=rev Author: christianhujer Date: 2006-11-10 15:11:30 -0800 (Fri, 10 Nov 2006) Log Message: ----------- Fixed naming in package documentation. Modified Paths: -------------- trunk/daimonin/src/daieditor/gameobject/match/package.html Modified: trunk/daimonin/src/daieditor/gameobject/match/package.html =================================================================== --- trunk/daimonin/src/daieditor/gameobject/match/package.html 2006-11-10 23:09:52 UTC (rev 637) +++ trunk/daimonin/src/daieditor/gameobject/match/package.html 2006-11-10 23:11:30 UTC (rev 638) @@ -7,8 +7,8 @@ </head> <body> <p> - This package contains classes related to matching ArchObjects, socalled ArchObjectMatcher. - An ArchObjectMatcher matches an ArchObject by checking whether it fulfills certain conditions. + This package contains classes related to matching GameObjects, socalled GameObjectMatcher. + A GameObjectMatcher matches a GameObject by checking whether it fulfills certain conditions. </p> <p> One application is used for instance for choosing which objects to render transparent or at all. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-10 23:09:57
|
Revision: 637 http://svn.sourceforge.net/gridarta/?rev=637&view=rev Author: christianhujer Date: 2006-11-10 15:09:52 -0800 (Fri, 10 Nov 2006) Log Message: ----------- Cosmetic: Improved documentation. Modified Paths: -------------- trunk/crossfire/src/cfeditor/io/CMapFileDecode.java Modified: trunk/crossfire/src/cfeditor/io/CMapFileDecode.java =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapFileDecode.java 2006-11-10 23:07:38 UTC (rev 636) +++ trunk/crossfire/src/cfeditor/io/CMapFileDecode.java 2006-11-10 23:09:52 UTC (rev 637) @@ -47,9 +47,19 @@ private static final Logger log = Logger.getLogger(CMapFileDecode.class); - private int maxxlen, maxylen; + /** + * The maximum x position of all data read from the file. + * It's used to automatically expand a map to the size of its contents in case of a map with wrongly set size. + */ + private int maxxlen; /** + * The maximum y position of all data read from the file. + * It's used to automatically expand a map to the size of its contents in case of a map with wrongly set size. + */ + private int maxylen; + + /** * Open a resource for reading it as a map. * @param uri URI of resource to open. * @throws FileNotFoundException in case the resource was not found. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-10 23:07:57
|
Revision: 636 http://svn.sourceforge.net/gridarta/?rev=636&view=rev Author: christianhujer Date: 2006-11-10 15:07:38 -0800 (Fri, 10 Nov 2006) Log Message: ----------- Moved MapView interface from gridarta to crossfire, now unused in daimonin. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/daimonin/src/daieditor/MapViewIFrame.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/MapView.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/MapView.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-11-10 23:02:34 UTC (rev 635) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-11-10 23:07:38 UTC (rev 636) @@ -29,6 +29,7 @@ import cfeditor.gameobject.GameObject; import cfeditor.map.MapControl; import cfeditor.map.MapModel; +import cfeditor.gui.MapView; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; @@ -54,7 +55,6 @@ import javax.swing.JViewport; import net.sf.gridarta.EditOperation; import net.sf.gridarta.Size2D; -import net.sf.gridarta.gui.MapView; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-11-10 23:02:34 UTC (rev 635) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-11-10 23:07:38 UTC (rev 636) @@ -28,13 +28,13 @@ import cfeditor.map.MapControl; import cfeditor.menu.MenuHelper; import cfeditor.menu.MenuManager; +import cfeditor.gui.MapView; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Point; import java.io.IOException; import javax.swing.JInternalFrame; import javax.swing.JViewport; -import net.sf.gridarta.gui.MapView; /** * The <code>MapViewIFrame</code> is mainly a wrapper class which creates a Copied: trunk/crossfire/src/cfeditor/gui/MapView.java (from rev 630, trunk/src/app/net/sf/gridarta/gui/MapView.java) =================================================================== --- trunk/crossfire/src/cfeditor/gui/MapView.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/MapView.java 2006-11-10 23:07:38 UTC (rev 636) @@ -0,0 +1,39 @@ +/* + * Crossfire Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * 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., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package cfeditor.gui; + +/** + * A mapview consists of two classes: The CMapViewBasic instance which contains + * the real mapview, and the wrapper frame class which extends a frame + * displaying the mapview. Now the communication "frame -> basic mapview" is no + * problem, but "basic mapview -> frame" can only be realized with this + * interface. + */ +public interface MapView { + + /** Update the title on the frame. */ + void updateTitle(); + +} // interface MapView Property changes on: trunk/crossfire/src/cfeditor/gui/MapView.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/MapViewIFrame.java =================================================================== --- trunk/daimonin/src/daieditor/MapViewIFrame.java 2006-11-10 23:02:34 UTC (rev 635) +++ trunk/daimonin/src/daieditor/MapViewIFrame.java 2006-11-10 23:07:38 UTC (rev 636) @@ -36,7 +36,6 @@ import javax.swing.ImageIcon; import javax.swing.JInternalFrame; import static javax.swing.KeyStroke.getKeyStroke; -import net.sf.gridarta.gui.MapView; /** * The <code>MapViewIFrame</code> is mainly a wrapper class which creates a @@ -49,7 +48,7 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @fixme these are also created for Pickmaps */ -public final class MapViewIFrame extends JInternalFrame implements MapView { +public final class MapViewIFrame extends JInternalFrame { /** Serial Version UID. */ private static final long serialVersionUID = 1L; @@ -101,20 +100,6 @@ return view; } - /** Update the Map-Window Title (according to name and changeFlag) */ - public void updateTitle() { - - if (view == null || mapControl == null) { - return; - } - - final StringBuilder strTitle = new StringBuilder(); - strTitle.append(mapControl.getMapFileName()).append(" [ ").append(mapControl.getMapArch().getMapDisplayName()).append(" ] ("); - strTitle.append(viewNumber).append(')'); - - setTitle(strTitle.toString()); // display new title - } - // following a bunch of wrapper methods which just pass access // to the basic mapview object 'view': Deleted: trunk/src/app/net/sf/gridarta/gui/MapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MapView.java 2006-11-10 23:02:34 UTC (rev 635) +++ trunk/src/app/net/sf/gridarta/gui/MapView.java 2006-11-10 23:07:38 UTC (rev 636) @@ -1,39 +0,0 @@ -/* - * Crossfire Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * 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., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package net.sf.gridarta.gui; - -/** - * A mapview consists of two classes: The CMapViewBasic instance which contains - * the real mapview, and the wrapper frame class which extends a frame - * displaying the mapview. Now the communication "frame -> basic mapview" is no - * problem, but "basic mapview -> frame" can only be realized with this - * interface. - */ -public interface MapView { - - /** Update the title on the frame. */ - void updateTitle(); - -} // interface MapView This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-11-10 23:02:43
|
Revision: 635 http://svn.sourceforge.net/gridarta/?rev=635&view=rev Author: christianhujer Date: 2006-11-10 15:02:34 -0800 (Fri, 10 Nov 2006) Log Message: ----------- Added crossfire wiki link to documentation. Modified Paths: -------------- trunk/src/doc/start.xhtml Modified: trunk/src/doc/start.xhtml =================================================================== --- trunk/src/doc/start.xhtml 2006-11-10 23:00:18 UTC (rev 634) +++ trunk/src/doc/start.xhtml 2006-11-10 23:02:34 UTC (rev 635) @@ -54,6 +54,7 @@ </ul> <h2>Links</h2> <ul> + <li><a href="http://wiki.metalforge.net/doku.php/gridarta">Gridarta in the Crossfire Wiki</a></li> <li><a href="http://sourceforge.net/projects/gridarta/">Gridarta SourceForge Project Page</a> (Forum, Bug Tracker, Feature Request Tracker, Web access to the SVN repository and more)</li> <li><a href="http://freshmeat.net/projects/gridarta/">Gridarta FreshMeat Project Page</a></li> <li><a href="http://cia.navi.cx/stats/project/gridarta">Gridarta CIA project page</a></li> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |