From: <aki...@us...> - 2006-12-07 23:32:41
|
Revision: 958 http://svn.sourceforge.net/gridarta/?rev=958&view=rev Author: akirschbaum Date: 2006-12-07 15:32:40 -0800 (Thu, 07 Dec 2006) Log Message: ----------- Remove LevelRenderer.isPickmap(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-07 23:29:54 UTC (rev 957) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-07 23:32:40 UTC (rev 958) @@ -736,7 +736,7 @@ mapMouseRightOff.y = 0; if (mapLoc.x == -1 || mapLoc.y == -1) { - if (!renderer.isPickmap()) { + if (!mapControl.isPickmap()) { mainControl.getMainView().setMapTileList(null, null); if (highlightOn) { @@ -757,7 +757,7 @@ // paint the highlight-icon renderer.setHighlightTile(/*((JComponent)renderer).getGraphics(), */mapLoc); - if (renderer.isPickmap()) { + if (mapControl.isPickmap()) { final GameObject arch = mapControl.getBottomArchObject(mapLoc); if (arch != null) { // an arch of a pickmap was selected Modified: trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java 2006-12-07 23:29:54 UTC (rev 957) +++ trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java 2006-12-07 23:32:40 UTC (rev 958) @@ -49,8 +49,6 @@ */ @Nullable public abstract Point getTileLocationAt(@NotNull final Point point, @Nullable final Point retPoint); - public abstract boolean isPickmap(); - public abstract void modelChanged(); public abstract void setHighlightTile(final Point point); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-09 14:25:07
|
Revision: 964 http://svn.sourceforge.net/gridarta/?rev=964&view=rev Author: christianhujer Date: 2006-12-09 06:25:07 -0800 (Sat, 09 Dec 2006) Log Message: ----------- Simplified some expressions. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CScriptController.java trunk/crossfire/src/cfeditor/CScriptModel.java trunk/crossfire/src/cfeditor/PluginParameterFactory.java trunk/crossfire/src/cfeditor/gui/CloseableTabbedPane.java trunk/crossfire/src/cfeditor/gui/ScriptEditor.java trunk/crossfire/src/cfeditor/menu/BasicMenuEntry.java Modified: trunk/crossfire/src/cfeditor/CScriptController.java =================================================================== --- trunk/crossfire/src/cfeditor/CScriptController.java 2006-12-09 14:14:29 UTC (rev 963) +++ trunk/crossfire/src/cfeditor/CScriptController.java 2006-12-09 14:25:07 UTC (rev 964) @@ -218,8 +218,7 @@ final Interpreter runner = new Interpreter(); try { setInterpreterValues(runner, "filter"); - final Filter cfc = (Filter) runner.eval(script.getCode()); - return cfc; + return (Filter) runner.eval(script.getCode()); } catch (final EvalError e) { log.warn("Evaluation error on (filter)" + script.getName(), e); } catch (final ClassCastException e) { Modified: trunk/crossfire/src/cfeditor/CScriptModel.java =================================================================== --- trunk/crossfire/src/cfeditor/CScriptModel.java 2006-12-09 14:14:29 UTC (rev 963) +++ trunk/crossfire/src/cfeditor/CScriptModel.java 2006-12-09 14:25:07 UTC (rev 964) @@ -211,8 +211,7 @@ */ @Nullable public Object getParamValue(final int index) { try { - final Object o = ((PluginParameter) params.get(index)).getValue(); - return o; + return ((PluginParameter) params.get(index)).getValue(); } catch (final Exception e) { e.printStackTrace(); return null; Modified: trunk/crossfire/src/cfeditor/PluginParameterFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/PluginParameterFactory.java 2006-12-09 14:14:29 UTC (rev 963) +++ trunk/crossfire/src/cfeditor/PluginParameterFactory.java 2006-12-09 14:25:07 UTC (rev 964) @@ -63,8 +63,7 @@ log.debug("trying to instance a class of type " + c.getName()); } - final PluginParameter p = c.newInstance(); - return p; + return c.newInstance(); } catch (final Exception e) { e.printStackTrace(); return null; Modified: trunk/crossfire/src/cfeditor/gui/CloseableTabbedPane.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/CloseableTabbedPane.java 2006-12-09 14:14:29 UTC (rev 963) +++ trunk/crossfire/src/cfeditor/gui/CloseableTabbedPane.java 2006-12-09 14:25:07 UTC (rev 964) @@ -183,14 +183,8 @@ /** Verifies if x and y are within the icon's borders. */ public boolean contains(final int xEvent, final int yEvent) { - if (!(xEvent >= x) || !(xEvent <= x + width)) { - return false; - } - if (!(yEvent >= y) || !(yEvent <= y + height)) { - return false; - } - - return true; + return !(!(xEvent >= x) || !(xEvent <= x + width)) && !(!(yEvent >= y) || !(yEvent <= y + height)); } + } } Modified: trunk/crossfire/src/cfeditor/gui/ScriptEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ScriptEditor.java 2006-12-09 14:14:29 UTC (rev 963) +++ trunk/crossfire/src/cfeditor/gui/ScriptEditor.java 2006-12-09 14:25:07 UTC (rev 964) @@ -228,8 +228,6 @@ "Delete?", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { getScript().removeParameter(selectedRow); } - - return; } }); paramButtons.add(addParameter); Modified: trunk/crossfire/src/cfeditor/menu/BasicMenuEntry.java =================================================================== --- trunk/crossfire/src/cfeditor/menu/BasicMenuEntry.java 2006-12-09 14:14:29 UTC (rev 963) +++ trunk/crossfire/src/cfeditor/menu/BasicMenuEntry.java 2006-12-09 14:25:07 UTC (rev 964) @@ -80,8 +80,7 @@ if (action == null) { synchronized (this) { if (action == null) { - final BasicAction bas = new BasicAction(this, getName()); - action = bas; + action = new BasicAction(this, getName()); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-09 15:23:33
|
Revision: 969 http://svn.sourceforge.net/gridarta/?rev=969&view=rev Author: christianhujer Date: 2006-12-09 07:23:32 -0800 (Sat, 09 Dec 2006) Log Message: ----------- Removed redundant Boolean constructor calls. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainMenu.java trunk/crossfire/src/cfeditor/parameter/BooleanParameter.java trunk/crossfire/src/cfeditor/parameter/BooleanParameterView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-09 15:21:56 UTC (rev 968) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-09 15:23:32 UTC (rev 969) @@ -381,11 +381,11 @@ imageSet = null; } - loadFromArchive = new Boolean(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(LOAD_ARCH_COLL, "true")).booleanValue(); + loadFromArchive = Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(LOAD_ARCH_COLL, "true")).booleanValue(); - getMainView().setMapTileListBottom(new Boolean(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(CMainView.MAPTILE_BOTTOM_KEY, "false")).booleanValue()); + getMainView().setMapTileListBottom(Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(CMainView.MAPTILE_BOTTOM_KEY, "false")).booleanValue()); - setLockAllPickmaps(new Boolean(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(PICKMAPS_LOCKED, "false")).booleanValue()); + setLockAllPickmaps(Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(PICKMAPS_LOCKED, "false")).booleanValue()); // docu version if (IGUIConstants.DOCU_VERSION > (new Integer(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(DOCU_VERSION_KEY, "0"))).intValue()) { Modified: trunk/crossfire/src/cfeditor/CMainMenu.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-09 15:21:56 UTC (rev 968) +++ trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-09 15:23:32 UTC (rev 969) @@ -760,7 +760,7 @@ m_lockPickmaps = new CheckBoxMenuEntry("Lock All Pickmaps"); m_lockPickmaps.setMnemonic('L'); - m_lockPickmaps.setChecked(new Boolean(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty( + m_lockPickmaps.setChecked(Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty( CMainControl.PICKMAPS_LOCKED, "false")).booleanValue()); m_lockPickmaps.addActionListener( new ActionListener() { Modified: trunk/crossfire/src/cfeditor/parameter/BooleanParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/BooleanParameter.java 2006-12-09 15:21:56 UTC (rev 968) +++ trunk/crossfire/src/cfeditor/parameter/BooleanParameter.java 2006-12-09 15:23:32 UTC (rev 969) @@ -63,7 +63,7 @@ final Boolean iVal = Boolean.valueOf(val); setValue(iVal); } catch (final Exception ex) { - setValue(new Boolean(false)); + setValue(Boolean.FALSE); } ; final BooleanConfig cfg = new BooleanConfig(); Modified: trunk/crossfire/src/cfeditor/parameter/BooleanParameterView.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/BooleanParameterView.java 2006-12-09 15:21:56 UTC (rev 968) +++ trunk/crossfire/src/cfeditor/parameter/BooleanParameterView.java 2006-12-09 15:23:32 UTC (rev 969) @@ -59,10 +59,10 @@ public void actionPerformed(final ActionEvent e) { if (e.getActionCommand().equals("toggle")) { if (value.isSelected()) { - parameter.setValue(new Boolean(true)); + parameter.setValue(Boolean.TRUE); value.setText(parameter.getTrueText()); } else { - parameter.setValue(new Boolean(false)); + parameter.setValue(Boolean.FALSE); value.setText(parameter.getFalseText()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-09 15:24:25
|
Revision: 970 http://svn.sourceforge.net/gridarta/?rev=970&view=rev Author: christianhujer Date: 2006-12-09 07:24:26 -0800 (Sat, 09 Dec 2006) Log Message: ----------- Removed redundant String constructor invocations. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/face/FaceObject.java trunk/crossfire/src/cfeditor/gui/ArchComboBox.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-09 15:23:32 UTC (rev 969) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-09 15:24:26 UTC (rev 970) @@ -376,7 +376,7 @@ mapDir = new File(currentDir.getAbsolutePath(), mapDir.getPath()); } - imageSet = new String(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(USE_IMAGESET, "base")); + imageSet = CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(USE_IMAGESET, "base"); if (imageSet.equalsIgnoreCase("none")) { imageSet = null; } Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObject.java 2006-12-09 15:23:32 UTC (rev 969) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObject.java 2006-12-09 15:24:26 UTC (rev 970) @@ -46,7 +46,7 @@ //private ImageIcon face; private Object face; - private String name = new String(""); // name of face + private String name = ""; // name of face private String path; Modified: trunk/crossfire/src/cfeditor/gui/ArchComboBox.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2006-12-09 15:23:32 UTC (rev 969) +++ trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2006-12-09 15:24:26 UTC (rev 970) @@ -392,7 +392,7 @@ class MyCellRenderer extends DefaultListCellRenderer { - public final String sizeTester = new String("**Sizetester**"); + public final String sizeTester = "**Sizetester**"; private static final long serialVersionUID = 1L; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-09 15:27:44
|
Revision: 971 http://svn.sourceforge.net/gridarta/?rev=971&view=rev Author: christianhujer Date: 2006-12-09 07:27:44 -0800 (Sat, 09 Dec 2006) Log Message: ----------- Removed unneccessary unboxing. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainMenu.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-09 15:24:26 UTC (rev 970) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-09 15:27:44 UTC (rev 971) @@ -29,9 +29,9 @@ import cfeditor.gameobject.GameObject; import cfeditor.gameobject.anim.AnimationObjects; import cfeditor.gameobject.face.FaceObjects; +import cfeditor.gui.map.MapPropertiesDialog; import cfeditor.io.CMapReader; import cfeditor.io.CMapWriter; -import cfeditor.gui.map.MapPropertiesDialog; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import cfeditor.map.MapModel; @@ -41,7 +41,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import javax.swing.ImageIcon; import javax.swing.JFileChooser; @@ -52,7 +51,6 @@ import javax.swing.UnsupportedLookAndFeelException; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.MainControl; -import net.sf.gridarta.Size2D; import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; import net.sf.gridarta.gui.HideFileFilterProxy; @@ -381,14 +379,14 @@ imageSet = null; } - loadFromArchive = Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(LOAD_ARCH_COLL, "true")).booleanValue(); + loadFromArchive = Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(LOAD_ARCH_COLL, "true")); - getMainView().setMapTileListBottom(Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(CMainView.MAPTILE_BOTTOM_KEY, "false")).booleanValue()); + getMainView().setMapTileListBottom(Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(CMainView.MAPTILE_BOTTOM_KEY, "false"))); - setLockAllPickmaps(Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(PICKMAPS_LOCKED, "false")).booleanValue()); + setLockAllPickmaps(Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(PICKMAPS_LOCKED, "false"))); // docu version - if (IGUIConstants.DOCU_VERSION > (new Integer(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(DOCU_VERSION_KEY, "0"))).intValue()) { + if (IGUIConstants.DOCU_VERSION > new Integer(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(DOCU_VERSION_KEY, "0"))) { // remember to open docu autoPopupDocu = true; // update docu version right now, because we want the help popup only one time Modified: trunk/crossfire/src/cfeditor/CMainMenu.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-09 15:24:26 UTC (rev 970) +++ trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-09 15:27:44 UTC (rev 971) @@ -761,7 +761,7 @@ m_lockPickmaps = new CheckBoxMenuEntry("Lock All Pickmaps"); m_lockPickmaps.setMnemonic('L'); m_lockPickmaps.setChecked(Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty( - CMainControl.PICKMAPS_LOCKED, "false")).booleanValue()); + CMainControl.PICKMAPS_LOCKED, "false"))); m_lockPickmaps.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-09 15:28:24
|
Revision: 972 http://svn.sourceforge.net/gridarta/?rev=972&view=rev Author: christianhujer Date: 2006-12-09 07:28:21 -0800 (Sat, 09 Dec 2006) Log Message: ----------- Replaced string concatenations inside append with append. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CResourceLoader.java trunk/crossfire/src/cfeditor/JarResources.java Modified: trunk/crossfire/src/cfeditor/CResourceLoader.java =================================================================== --- trunk/crossfire/src/cfeditor/CResourceLoader.java 2006-12-09 15:27:44 UTC (rev 971) +++ trunk/crossfire/src/cfeditor/CResourceLoader.java 2006-12-09 15:28:21 UTC (rev 972) @@ -180,7 +180,7 @@ final StringBuffer buf = new StringBuffer(128); final String home = System.getProperty("user.home"); buf.append(home); - buf.append(File.separator + IGUIConstants.APP_SETTINGS_DIR); + buf.append(File.separator).append(IGUIConstants.APP_SETTINGS_DIR); final File rc = new File(buf.toString()); if (!rc.isDirectory()) { rc.mkdir(); Modified: trunk/crossfire/src/cfeditor/JarResources.java =================================================================== --- trunk/crossfire/src/cfeditor/JarResources.java 2006-12-09 15:27:44 UTC (rev 971) +++ trunk/crossfire/src/cfeditor/JarResources.java 2006-12-09 15:28:21 UTC (rev 972) @@ -180,9 +180,9 @@ } sb.append(ze.getName()); sb.append("\t"); - sb.append("" + ze.getSize()); + sb.append("").append(ze.getSize()); if (ze.getMethod() == ZipEntry.DEFLATED) { - sb.append("/" + ze.getCompressedSize()); + sb.append("/").append(ze.getCompressedSize()); } return sb.toString(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-09 16:34:01
|
Revision: 975 http://svn.sourceforge.net/gridarta/?rev=975&view=rev Author: christianhujer Date: 2006-12-09 08:33:59 -0800 (Sat, 09 Dec 2006) Log Message: ----------- Removed unneccessary boxing and unboxing. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/CFArchTypeList.java trunk/crossfire/src/cfeditor/CScriptModel.java trunk/crossfire/src/cfeditor/CScriptView.java trunk/crossfire/src/cfeditor/JarResources.java trunk/crossfire/src/cfeditor/io/CMapWriter.java trunk/crossfire/src/cfeditor/map/MapArchObject.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/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-09 15:33:24 UTC (rev 974) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-09 16:33:59 UTC (rev 975) @@ -372,7 +372,7 @@ for (int i = 0; i < array.length; i++) { array[i] = (String) listData.get(i * 2 + 1); // put string to array - if (!hasSelection && ((Integer) listData.get(i * 2)).intValue() == active) { + if (!hasSelection && (Integer) listData.get(i * 2) == active) { hasSelection = true; // the selection is valid active = i; // set selection to this index in the array } Modified: trunk/crossfire/src/cfeditor/CFArchTypeList.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-09 15:33:24 UTC (rev 974) +++ trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-09 16:33:59 UTC (rev 975) @@ -271,7 +271,7 @@ // every list entry adds value (Integer) and name (String) to the vector try { num = elem.getAttribute("value").getIntValue(); - list.add(new Integer(num)); + list.add(num); list.add(" " + elem.getAttribute("name").getValue().trim()); } catch (final DataConversionException e) { log.warn("In '" + IGUIConstants.TYPEDEF_FILE + "', list " + root.getAttribute("name").getValue() + ": value '" + elem.getAttribute("value").getValue() + "' is not an integer."); Modified: trunk/crossfire/src/cfeditor/CScriptModel.java =================================================================== --- trunk/crossfire/src/cfeditor/CScriptModel.java 2006-12-09 15:33:24 UTC (rev 974) +++ trunk/crossfire/src/cfeditor/CScriptModel.java 2006-12-09 16:33:59 UTC (rev 975) @@ -34,11 +34,11 @@ public static final int PLUGIN_SCRIPT = 4; - public static final Integer RUN_AUTOBOOT = new Integer(1); + public static final Integer RUN_AUTOBOOT = 1; - public static final Integer RUN_FILTER = new Integer(2); + public static final Integer RUN_FILTER = 2; - public static final Integer RUN_SCRIPT = new Integer(4); + public static final Integer RUN_SCRIPT = 4; private String code = ""; @@ -409,7 +409,7 @@ } else { final List<Element> modes = mode.getChildren(); for (final Element m : modes) { - final boolean b = Boolean.valueOf(m.getTextTrim()).booleanValue(); + final boolean b = Boolean.valueOf(m.getTextTrim()); final String name = m.getName(); if ("autoboot".equalsIgnoreCase(name) && b) { scriptType |= PLUGIN_AUTOBOOT; Modified: trunk/crossfire/src/cfeditor/CScriptView.java =================================================================== --- trunk/crossfire/src/cfeditor/CScriptView.java 2006-12-09 15:33:24 UTC (rev 974) +++ trunk/crossfire/src/cfeditor/CScriptView.java 2006-12-09 16:33:59 UTC (rev 975) @@ -268,7 +268,7 @@ dialog.setVisible(true); final Object result = p.getValue(); if (result instanceof Integer) { - if (((Integer) result).intValue() == JOptionPane.YES_OPTION) { + if ((Integer) result == JOptionPane.YES_OPTION) { return true; } } Modified: trunk/crossfire/src/cfeditor/JarResources.java =================================================================== --- trunk/crossfire/src/cfeditor/JarResources.java 2006-12-09 15:33:24 UTC (rev 974) +++ trunk/crossfire/src/cfeditor/JarResources.java 2006-12-09 16:33:59 UTC (rev 975) @@ -111,7 +111,7 @@ if (log.isDebugEnabled()) { log.debug(dumpZipEntry(ze)); } - htSizes.put(ze.getName(), new Integer((int) ze.getSize())); + htSizes.put(ze.getName(), (int) ze.getSize()); } zf.close(); @@ -131,7 +131,7 @@ int size = (int) ze.getSize(); // -1 means unknown size. if (size == -1) { - size = htSizes.get(ze.getName()).intValue(); + size = htSizes.get(ze.getName()); } final byte[] b = new byte[size]; int rb = 0; Modified: trunk/crossfire/src/cfeditor/io/CMapWriter.java =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapWriter.java 2006-12-09 15:33:24 UTC (rev 974) +++ trunk/crossfire/src/cfeditor/io/CMapWriter.java 2006-12-09 16:33:59 UTC (rev 975) @@ -206,8 +206,8 @@ 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(); + final int v1 = i1 == null ? Integer.MAX_VALUE : i1; + final int v2 = i2 == null ? Integer.MAX_VALUE : i2; if (v1 < v2) { return -1; } Modified: trunk/crossfire/src/cfeditor/map/MapArchObject.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapArchObject.java 2006-12-09 15:33:24 UTC (rev 974) +++ trunk/crossfire/src/cfeditor/map/MapArchObject.java 2006-12-09 16:33:59 UTC (rev 975) @@ -485,7 +485,7 @@ private double getLineValueAsDouble(final String s) { try { if (s.lastIndexOf(" ") > 0) { - return Double.valueOf(s.substring(s.lastIndexOf(" ") + 1)).doubleValue(); + return Double.valueOf(s.substring(s.lastIndexOf(" ") + 1)); } } catch (final NumberFormatException e) { } Modified: trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java 2006-12-09 15:33:24 UTC (rev 974) +++ trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java 2006-12-09 16:33:59 UTC (rev 975) @@ -60,10 +60,10 @@ super.fromXML(e); final String val = e.getChildText("value"); try { - final Double iVal = new Double(Double.parseDouble(val)); + final Double iVal = Double.parseDouble(val); setValue(iVal); } catch (final Exception ex) { - setValue(new Double(0)); + setValue((double) 0); } ; final DoubleConfig o = new DoubleConfig(); @@ -106,8 +106,8 @@ public void setMax(final double max) { ((DoubleConfig) getConfig()).setMax(max); - if (((Double) getValue()).doubleValue() > ((DoubleConfig) getConfig()).getMax()) { - setValue(new Double(((DoubleConfig) getConfig()).getMax())); + if ((Double) getValue() > ((DoubleConfig) getConfig()).getMax()) { + setValue(((DoubleConfig) getConfig()).getMax()); } } @@ -117,8 +117,8 @@ public void setMin(final double min) { ((DoubleConfig) getConfig()).setMin(min); - if (((Double) getValue()).doubleValue() < ((DoubleConfig) getConfig()).getMin()) { - setValue(new Double(((DoubleConfig) getConfig()).getMin())); + if ((Double) getValue() < ((DoubleConfig) getConfig()).getMin()) { + setValue(((DoubleConfig) getConfig()).getMin()); } } } Modified: trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java 2006-12-09 15:33:24 UTC (rev 974) +++ trunk/crossfire/src/cfeditor/parameter/DoubleParameterView.java 2006-12-09 16:33:59 UTC (rev 975) @@ -128,8 +128,8 @@ } if (e.getActionCommand().equals("Config")) { - final String min = JOptionPane.showInputDialog("Minimum value:", new Double(parameter.getMin())); - final String max = JOptionPane.showInputDialog("Maximum value:", new Double(parameter.getMax())); + final String min = JOptionPane.showInputDialog("Minimum value:", parameter.getMin()); + final String max = JOptionPane.showInputDialog("Maximum value:", parameter.getMax()); try { final double iMin; final double iMax; @@ -137,8 +137,8 @@ iMax = Double.parseDouble(max); parameter.setMax(iMax); parameter.setMin(iMin); - ((SpinnerNumberModel) value.getModel()).setMinimum(new Double(parameter.getMin())); - ((SpinnerNumberModel) value.getModel()).setMaximum(new Double(parameter.getMax())); + ((SpinnerNumberModel) value.getModel()).setMinimum(parameter.getMin()); + ((SpinnerNumberModel) value.getModel()).setMaximum(parameter.getMax()); updateTooltip(); } 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-12-09 15:33:24 UTC (rev 974) +++ trunk/crossfire/src/cfeditor/parameter/IntegerParameter.java 2006-12-09 16:33:59 UTC (rev 975) @@ -58,10 +58,10 @@ super.fromXML(e); final String val = e.getChildText("value"); try { - final Integer iVal = new Integer(Integer.parseInt(val)); + final Integer iVal = Integer.parseInt(val); setValue(iVal); } catch (final Exception ex) { - setValue(new Integer(0)); + setValue(0); } final IntegerConfig o = new IntegerConfig(); try { @@ -103,8 +103,8 @@ public void setMax(final int max) { ((IntegerConfig) getConfig()).setMax(max); - if (((Integer) getValue()).intValue() > ((IntegerConfig) getConfig()).getMax()) { - setValue(new Integer(((IntegerConfig) getConfig()).getMax())); + if ((Integer) getValue() > ((IntegerConfig) getConfig()).getMax()) { + setValue(((IntegerConfig) getConfig()).getMax()); } } @@ -114,8 +114,8 @@ public void setMin(final int min) { ((IntegerConfig) getConfig()).setMin(min); - if (((Integer) getValue()).intValue() < ((IntegerConfig) getConfig()).getMin()) { - setValue(new Integer(((IntegerConfig) getConfig()).getMin())); + if ((Integer) getValue() < ((IntegerConfig) getConfig()).getMin()) { + setValue(((IntegerConfig) getConfig()).getMin()); } } } Modified: trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java 2006-12-09 15:33:24 UTC (rev 974) +++ trunk/crossfire/src/cfeditor/parameter/IntegerParameterView.java 2006-12-09 16:33:59 UTC (rev 975) @@ -124,8 +124,8 @@ log.debug("command: " + e.getActionCommand()); } if (e.getActionCommand().equals("Config")) { - final String min = JOptionPane.showInputDialog("Minimum value:", new Integer(parameter.getMin())); - final String max = JOptionPane.showInputDialog("Maximum value:", new Integer(parameter.getMax())); + final String min = JOptionPane.showInputDialog("Minimum value:", parameter.getMin()); + final String max = JOptionPane.showInputDialog("Maximum value:", parameter.getMax()); try { final int iMin; final int iMax; @@ -133,8 +133,8 @@ iMax = Integer.parseInt(max); parameter.setMax(iMax); parameter.setMin(iMin); - ((SpinnerNumberModel) value.getModel()).setMinimum(new Integer(parameter.getMin())); - ((SpinnerNumberModel) value.getModel()).setMaximum(new Integer(parameter.getMax())); + ((SpinnerNumberModel) value.getModel()).setMinimum(parameter.getMin()); + ((SpinnerNumberModel) value.getModel()).setMaximum(parameter.getMax()); updateTooltip(); } 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-12-09 17:02:20
|
Revision: 976 http://svn.sourceforge.net/gridarta/?rev=976&view=rev Author: christianhujer Date: 2006-12-09 09:02:17 -0800 (Sat, 09 Dec 2006) Log Message: ----------- Rationalized static member access. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CArchPanelPan.java trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/gui/ArchComboBox.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java Modified: trunk/crossfire/src/cfeditor/CArchPanelPan.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-12-09 16:33:59 UTC (rev 975) +++ trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-12-09 17:02:17 UTC (rev 976) @@ -277,9 +277,9 @@ setText(archetypeName); if (archetype.getFaceFlag()) { - setIcon(mainControl.getNofaceTileIcon()); + setIcon(CMainControl.getNofaceTileIcon()); } else if (archetype.getFaceNr() == -1) { - setIcon(mainControl.getUnknownTileIcon()); + setIcon(CMainControl.getUnknownTileIcon()); } else { setIcon(mainControl.getFace(archetype.getFaceNr())); } Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-09 16:33:59 UTC (rev 975) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-09 17:02:17 UTC (rev 976) @@ -1163,7 +1163,7 @@ if (inline != null) { final boolean isNone = inline.equals(CFTreasureListTree.NONE_SYM) || inline.length() == 0; - if (!isNone && !CFTreasureListTree.getInstance().containsTreasureList(inline) && !inline.equalsIgnoreCase(archetype.getAttributeString(attr.ref.getNameOld()))) { + if (!isNone && !CFTreasureListTree.containsTreasureList(inline) && !inline.equalsIgnoreCase(archetype.getAttributeString(attr.ref.getNameOld()))) { // The user has specified a WRONG treasurelist name, and it does not come // from the default gameObject. -> Error and out. JOptionPane.showMessageDialog(this, "In attribute '" + attr.ref.getNameNew() + "':\n" + "'" + inline + "' is not a known treasurelist name!", "Input Error", JOptionPane.ERROR_MESSAGE); Modified: trunk/crossfire/src/cfeditor/gui/ArchComboBox.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2006-12-09 16:33:59 UTC (rev 975) +++ trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2006-12-09 17:02:17 UTC (rev 976) @@ -263,9 +263,9 @@ icon.setIcon(null); icon.setText("No item selected"); } else if (arch.getFaceFlag()) { - icon.setIcon(mainControl.getEmptyTileIcon()); + icon.setIcon(CMainControl.getEmptyTileIcon()); } else if (arch.getFaceNr() == -1) { - icon.setIcon(mainControl.getUnknownTileIcon()); + icon.setIcon(CMainControl.getUnknownTileIcon()); } else { icon.setIcon(mainControl.getFace(arch.getFaceNr())); } @@ -425,9 +425,9 @@ setText(arch.getArchetypeName()); if (arch.getFaceFlag()) { - setIcon(mainControl.getEmptyTileIcon()); + setIcon(CMainControl.getEmptyTileIcon()); } else if (arch.getFaceNr() == -1) { - setIcon(mainControl.getUnknownTileIcon()); + setIcon(CMainControl.getUnknownTileIcon()); } else { setIcon(mainControl.getFace(arch.getFaceNr())); } Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-09 16:33:59 UTC (rev 975) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-09 17:02:17 UTC (rev 976) @@ -219,7 +219,7 @@ if (isPickmap) { grfx.fillRect(x * 32 + borderOffset, y * 32 + borderOffset, 32, 32); } else { - mainControl.getUnknownTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + CMainControl.getUnknownTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); } } else { for (final GameObject node : mapControl.getMapModel().getMapSquare(new Point(x, y))) { @@ -229,12 +229,12 @@ } if (mainControl.isTileEdit(node.getEditType()) || mainControl.getTileEdit() == 0 || isPickmap) { if (node.getArchetypeName() == null) { - mainControl.getNoarchTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + CMainControl.getNoarchTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); } else if (node.getFaceFlag()) { - mainControl.getNofaceTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + CMainControl.getNofaceTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); } else { if (node.getFaceNr() == -1) { - mainControl.getUnknownTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + CMainControl.getUnknownTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); } else { // draw object face final ImageIcon img = archlist.getFace(node.getFaceNr()); @@ -320,7 +320,7 @@ grfx.setColor(IGUIConstants.BG_COLOR); grfx.fillRect(point.x * 32 + borderOffset, point.y * 32 + borderOffset, 32, 32); } else { - mainControl.getUnknownTileIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); + CMainControl.getUnknownTileIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); } } else { tmpGrfx.fillRect(0, 0, 32, 32); @@ -332,12 +332,12 @@ } if (mainControl.isTileEdit(node.getEditType()) || mainControl.getTileEdit() == 0) { if (node.getArchetypeName() == null) { - mainControl.getNoarchTileIcon().paintIcon(this, tmpGrfx, 0, 0); + CMainControl.getNoarchTileIcon().paintIcon(this, tmpGrfx, 0, 0); } else if (node.getFaceFlag()) { - mainControl.getNofaceTileIcon().paintIcon(this, tmpGrfx, 0, 0); + CMainControl.getNofaceTileIcon().paintIcon(this, tmpGrfx, 0, 0); } else { if (node.getFaceNr() == -1) { - mainControl.getUnknownTileIcon().paintIcon(this, tmpGrfx, 0, 0); + CMainControl.getUnknownTileIcon().paintIcon(this, tmpGrfx, 0, 0); } else { final ImageIcon img = archlist.getFace(node.getFaceNr()); if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { @@ -408,7 +408,7 @@ // Highlight the selected square if (point.x >= topx && point.x <= botx && point.y >= topy && point.y <= boty) { - mainControl.getMapSelIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); + CMainControl.getMapSelIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); } } } @@ -445,7 +445,7 @@ // Draw the Icon: // Rectangular view - mainControl.getMapSelIcon().paintIcon(this, grfx, posx * 32 + borderOffset, posy * 32 + borderOffset); + CMainControl.getMapSelIcon().paintIcon(this, grfx, posx * 32 + borderOffset, posy * 32 + borderOffset); if (signY == 0) { break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-09 17:08:39
|
Revision: 977 http://svn.sourceforge.net/gridarta/?rev=977&view=rev Author: christianhujer Date: 2006-12-09 09:08:39 -0800 (Sat, 09 Dec 2006) Log Message: ----------- Removed some unneccessary semicolons. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CScriptController.java trunk/crossfire/src/cfeditor/CScriptModel.java trunk/crossfire/src/cfeditor/PluginParameter.java trunk/crossfire/src/cfeditor/parameter/BooleanParameter.java trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java Modified: trunk/crossfire/src/cfeditor/CScriptController.java =================================================================== --- trunk/crossfire/src/cfeditor/CScriptController.java 2006-12-09 17:02:17 UTC (rev 976) +++ trunk/crossfire/src/cfeditor/CScriptController.java 2006-12-09 17:08:39 UTC (rev 977) @@ -309,8 +309,8 @@ private void notifyListeners() { final ChangeEvent e = new ChangeEvent(this); - for (Iterator<ChangeListener> i = listeners.iterator(); i.hasNext(); i.next().stateChanged(e)) { - ; + for (final ChangeListener listener : listeners) { + listener.stateChanged(e); } } Modified: trunk/crossfire/src/cfeditor/CScriptModel.java =================================================================== --- trunk/crossfire/src/cfeditor/CScriptModel.java 2006-12-09 17:02:17 UTC (rev 976) +++ trunk/crossfire/src/cfeditor/CScriptModel.java 2006-12-09 17:08:39 UTC (rev 977) @@ -9,7 +9,6 @@ import java.util.ArrayList; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -300,8 +299,8 @@ /** Tell all listeners plugged on this CScriptModel its content has changed. */ private void notifyListeners() { final ChangeEvent e = new ChangeEvent(this); - for (Iterator<ChangeListener> i = listeners.iterator(); i.hasNext(); i.next().stateChanged(e)) { - ; + for (final ChangeListener listener : listeners) { + listener.stateChanged(e); } } @@ -457,8 +456,8 @@ } root.addContent(modes); - for (Iterator<PluginParameter> i = params.iterator(); i.hasNext(); root.addContent(i.next().toXML())) { - ; + for (final PluginParameter param : (Iterable<PluginParameter>) params) { + root.addContent(param.toXML()); } return root; } Modified: trunk/crossfire/src/cfeditor/PluginParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/PluginParameter.java 2006-12-09 17:02:17 UTC (rev 976) +++ trunk/crossfire/src/cfeditor/PluginParameter.java 2006-12-09 17:08:39 UTC (rev 977) @@ -8,7 +8,6 @@ package cfeditor; import java.util.HashSet; -import java.util.Iterator; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.jdom.Element; @@ -102,8 +101,8 @@ protected void fireDataChanged() { final ChangeEvent e = new ChangeEvent(this); - for (Iterator<ChangeListener> i = listeners.iterator(); i.hasNext(); i.next().stateChanged(e)) { - ; + for (final ChangeListener listener : listeners) { + listener.stateChanged(e); } } Modified: trunk/crossfire/src/cfeditor/parameter/BooleanParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/BooleanParameter.java 2006-12-09 17:02:17 UTC (rev 976) +++ trunk/crossfire/src/cfeditor/parameter/BooleanParameter.java 2006-12-09 17:08:39 UTC (rev 977) @@ -65,7 +65,6 @@ } catch (final Exception ex) { setValue(Boolean.FALSE); } - ; final BooleanConfig cfg = new BooleanConfig(); cfg.setTrueText(e.getChildText("trueText")); cfg.setFalseText(e.getChildText("falseText")); Modified: trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java 2006-12-09 17:02:17 UTC (rev 976) +++ trunk/crossfire/src/cfeditor/parameter/DoubleParameter.java 2006-12-09 17:08:39 UTC (rev 977) @@ -65,7 +65,6 @@ } catch (final Exception ex) { setValue((double) 0); } - ; final DoubleConfig o = new DoubleConfig(); try { o.setMin(Double.parseDouble(e.getChildTextTrim("minimum"))); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-12-10 17:41:11
|
Revision: 1024 http://svn.sourceforge.net/gridarta/?rev=1024&view=rev Author: christianhujer Date: 2006-12-10 09:41:09 -0800 (Sun, 10 Dec 2006) Log Message: ----------- Added garbage collection menu entry. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainMenu.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-10 17:38:31 UTC (rev 1023) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-10 17:41:09 UTC (rev 1024) @@ -1689,4 +1689,12 @@ return null; } + /** + * Runs the garbage collection. + */ + public void gc() { + System.gc(); + refreshMenusAndToolbars(); + } + } // class CMainControl Modified: trunk/crossfire/src/cfeditor/CMainMenu.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-10 17:38:31 UTC (rev 1023) +++ trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-10 17:41:09 UTC (rev 1024) @@ -441,6 +441,15 @@ }); menuManager.addMenuEntry("main.edit", randFillBelow); + final SimpleMenuEntry garbageCollection = new SimpleMenuEntry("Run Garbage Collection"); + garbageCollection.addActionListener( + new ActionListener() { + public void actionPerformed(final ActionEvent event) { + mainControl.gc(); + } + }); + menuManager.addMenuEntry("main.edit", garbageCollection); + add(entry.getMenuBarComponent()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-12 03:37:16
|
Revision: 1055 http://svn.sourceforge.net/gridarta/?rev=1055&view=rev Author: akirschbaum Date: 2006-12-11 13:21:07 -0800 (Mon, 11 Dec 2006) Log Message: ----------- Rename variable and method names. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainMenu.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-11 20:54:53 UTC (rev 1054) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-11 21:21:07 UTC (rev 1055) @@ -151,7 +151,7 @@ private boolean hasChangedDir = false; /** Indicates whether autojoining is on/off. */ - private boolean autojoin = false; + private boolean autoJoin = false; /** Name of used Image Set (null = none). */ private String imageSet; @@ -333,12 +333,12 @@ setTileEdit(newType); // activate the new type for all views } - public void setAutojoin(final boolean state) { - autojoin = state; + public void setAutoJoin(final boolean autoJoin) { + this.autoJoin = autoJoin; } - public boolean getAutojoin() { - return autojoin; + public boolean isAutoJoin() { + return autoJoin; } public void openHelpWindow() { Modified: trunk/crossfire/src/cfeditor/CMainMenu.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-11 20:54:53 UTC (rev 1054) +++ trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-11 21:21:07 UTC (rev 1055) @@ -634,12 +634,12 @@ autojoin = new CheckBoxMenuEntry("Auto-Joining"); autojoin.setMnemonic('A'); autojoin.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, Event.CTRL_MASK)); - autojoin.setChecked(mainControl.getAutojoin()); + autojoin.setChecked(mainControl.isAutoJoin()); autojoin.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent event) { // toggle autojoining state on/off - mainControl.setAutojoin(autojoin.isChecked()); + mainControl.setAutoJoin(autojoin.isChecked()); } }); menuManager.addMenuEntry("main.map", autojoin); Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-11 20:54:53 UTC (rev 1054) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-11 21:21:07 UTC (rev 1055) @@ -357,7 +357,7 @@ final Point[] redraw; // return value (coords needing redraw) - if (mainControl.getAutojoin() && gameObject.getArchetype().getJoinList() != null) { + if (mainControl.isAutoJoin() && gameObject.getArchetype().getJoinList() != null) { // this gameObject does autojoining: // first look how many we need Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-11 20:54:53 UTC (rev 1054) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-11 21:21:07 UTC (rev 1055) @@ -204,7 +204,7 @@ return false; } - if (mainControl.getAutojoin() && join == JOIN_ENABLE && mainControl.getJoinlist() != null && archetype.getJoinList() != null && !archetype.isMulti()) { + if (mainControl.isAutoJoin() && join == JOIN_ENABLE && mainControl.getJoinlist() != null && archetype.getJoinList() != null && !archetype.isMulti()) { // do autojoining if enabled archName = archetype.getJoinList().joinInsert(this, pos); if (archName == null) { @@ -404,7 +404,7 @@ // do autojoining final GameObject temp = getArchetype(node.getArchetypeName()); // get defarch - if (mainControl.getAutojoin() && join == JOIN_ENABLE && mainControl.getJoinlist() != null && temp.getJoinList() != null && !temp.isMulti()) { + if (mainControl.isAutoJoin() && join == JOIN_ENABLE && mainControl.getJoinlist() != null && temp.getJoinList() != null && !temp.isMulti()) { // remove connections to the deleted arch temp.getJoinList().joinDelete(this, pos); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-12 03:37:16
|
Revision: 1035 http://svn.sourceforge.net/gridarta/?rev=1035&view=rev Author: akirschbaum Date: 2006-12-10 11:54:24 -0800 (Sun, 10 Dec 2006) Log Message: ----------- Unify comments. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-10 19:47:45 UTC (rev 1034) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-10 19:54:24 UTC (rev 1035) @@ -685,58 +685,37 @@ //statusBar.setLevelInfo(level); } - /** - * Invoked when the internal frame view is opened. - * @param event the occurred <code>InternalFrameEvent</code> - */ + /** {@inheritDoc} */ public void internalFrameOpened(final InternalFrameEvent event) { } - /** - * Invoked when the internal frame view is closing. - * @param event the occurred <code>InternalFrameEvent</code> - */ + /** {@inheritDoc} */ public void internalFrameClosing(final InternalFrameEvent event) { final MapViewIFrame view = (MapViewIFrame) event.getSource(); removeLevelView(view); } - /** - * Invoked when the internal frame view is closed. - * @param event the occurred <code>InternalFrameEvent</code> - */ + /** {@inheritDoc} */ public void internalFrameClosed(final InternalFrameEvent event) { } - /** - * Invoked when the internal frame view is iconified. - * @param event the occurred <code>InternalFrameEvent</code> - */ + /** {@inheritDoc} */ public void internalFrameIconified(final InternalFrameEvent event) { final MapViewIFrame view = (MapViewIFrame) event.getSource(); levelViewFocusLostNotify(view); } - /** - * Invoked when the internal frame view is deiconified. - * @param event the occurred <code>InternalFrameEvent</code> - */ + /** {@inheritDoc} */ public void internalFrameDeiconified(final InternalFrameEvent event) { } - /** - * Invoked when the internal frame view is activated. - * @param event the occurred <code>InternalFrameEvent</code> - */ + /** {@inheritDoc} */ public void internalFrameActivated(final InternalFrameEvent event) { final MapViewIFrame view = (MapViewIFrame) event.getSource(); levelViewFocusGainedNotify(view); } - /** - * Invoked when the internal frame view is deactivated. - * @param event the occurred <code>InternalFrameEvent</code> - */ + /** {@inheritDoc} */ public void internalFrameDeactivated(final InternalFrameEvent event) { } Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-12-10 19:47:45 UTC (rev 1034) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-12-10 19:54:24 UTC (rev 1035) @@ -120,7 +120,7 @@ log.warn("addArchToList: duplicate archetype '" + archetype.getArchetypeName() + "'"); } - /** Loads the Archetypes. */ + /** {@inheritDoc} */ public void loadArchetypes() { final long timeStart = System.currentTimeMillis(); setLoadStatus(LoadStatus.LOADING); // status: loading Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-10 19:47:45 UTC (rev 1034) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-10 19:54:24 UTC (rev 1035) @@ -246,7 +246,9 @@ return true; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ public boolean insertArchToMap(GameObject newObject, String archName, final GameObject next, final Point pos, final boolean join) { // map coords must be valid if (!isPointValid(pos)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-12 03:37:38
|
Revision: 1027 http://svn.sourceforge.net/gridarta/?rev=1027&view=rev Author: akirschbaum Date: 2006-12-10 10:10:58 -0800 (Sun, 10 Dec 2006) Log Message: ----------- Add attribute types DBLLIST, FACENAME and ANIMNAME to cfeditor. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/CFArchAttrib.java trunk/crossfire/src/cfeditor/gameobject/ArchAttribType.java Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-10 18:05:24 UTC (rev 1026) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-10 18:10:58 UTC (rev 1027) @@ -27,6 +27,7 @@ import cfeditor.gameobject.ArchAttribType; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; +import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; import java.awt.Component; @@ -85,6 +86,8 @@ import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.NamedObject; +import net.sf.gridarta.gameobject.NamedObjects; import net.sf.gridarta.help.Help; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; @@ -670,7 +673,9 @@ ((DialogAttrib<JFormattedTextField>) newAttr).input = input; } break; - case STRING: { + case STRING: + case FACENAME: + case ANIMNAME: { final String dtxt; if (type.getAttr()[i].getNameOld().equalsIgnoreCase("name")) { if (gameObject.getObjName() != null && gameObject.getObjName().length() > 0) { @@ -695,6 +700,22 @@ cLabel = new JLabel(type.getAttr()[i].getNameNew() + ": "); newAttr = new DialogAttrib<JTextField>(type.getAttr()[i]); break; + case FACENAME: + case ANIMNAME: + newAttr = new DialogAttrib<JTextField>(attrib); + switch (dType) { + case FACENAME: + cLabel = new JButton(new TreeChooseAction(attrib.getNameNew() + ": ", input, mainControl.getFaceObjects())); + break; + case ANIMNAME: + cLabel = new JButton(new TreeChooseAction(attrib.getNameNew() + ": ", input, mainControl.getAnimationObjects())); + break; + default: + assert false; + cLabel = null; + break; + } + break; default: assert false; newAttr = null; @@ -738,6 +759,38 @@ ((DialogAttrib<JComboBox>) newAttr).input = input; } break; + case DBLLIST: { + final JPanel compo = new JPanel(new BorderLayout()); + cLabel = new JLabel(attrib.getNameNew() + ": "); + cLabel.setForeground(IGUIConstants.INT_COLOR); + newAttr = new DialogAttrib<JComboBox[]>(attrib); + // create ComboBox with parsed selection + final JComboBox[] inputs = new JComboBox[2]; + if (attrib.getMisc() != null && typelist.getListTable().containsKey(attrib.getMisc()[0]) && typelist.getListTable().containsKey(attrib.getMisc()[1])) { + // Hack to set preselected if available + final int active = gameObject.getAttributeInt(nameOld); + final int[] activepart = {active & 0x0F, active & 0xF0}; + // build the lists from vector data + for (int j = 0; j < 2; j++) { + final List<?> listData = typelist.getListTable().get(attrib.getMisc()[j]); + inputs[j] = buildArrayBox(attrib, listData); + for (int k = 0; (double) k < listData.size() / 2.0; k++) { + if ((Integer) listData.get(k << 1) == activepart[j]) { + inputs[j].setSelectedIndex(k); // set active selection + break; + } + } + } + compo.add(inputs[0], BorderLayout.NORTH); + compo.add(inputs[1], BorderLayout.SOUTH); + cComp = compo; + } else { + // error: list data is missing or corrupt + cComp = new JLabel("Error: Undefined List"); + } + ((DialogAttrib<JComboBox[]>) newAttr).input = inputs; + } + break; case BITMASK: { newAttr = new BitmaskAttrib(type.getAttr()[i]); if (type.getAttr()[i].getMisc() != null && typelist.getBitmaskTable().containsKey(type.getAttr()[i].getMisc()[0])) { @@ -920,7 +973,9 @@ } } break; - case STRING: { + case STRING: + case FACENAME: + case ANIMNAME: { final String value = ((DialogAttrib<JTextField>) attr).input.getText(); // the attrib value if (value != null && value.length() > 0) { doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + '\n', docStyle); @@ -936,10 +991,29 @@ } } break; + case DBLLIST: { + final String value1 = ((DialogAttrib<JComboBox[]>) attr).input[0].getSelectedItem().toString().trim(); + final String value2 = ((DialogAttrib<JComboBox[]>) attr).input[1].getSelectedItem().toString().trim(); + String out = null; + if (value1 != null && value1.length() > 0 && !value1.startsWith("<")) { + out = value1; + } + if (value2 != null && value2.length() > 0 && !value2.startsWith("<")) { + if (out == null) { + out = value2; + } else { + out += " / " + value2; + } + } + if (out != null) { + doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + out + "\n", docStyle); + } + } + break; case BITMASK: { final String value = ((BitmaskAttrib) attr).input.getText().trim(); if (value != null && value.length() > 0 && !value.startsWith("<")) { - doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + '\n', docStyle); + doc.insertString(doc.getLength(), attr.ref.getNameNew() + " = " + value + "\n", docStyle); } } break; @@ -1075,7 +1149,9 @@ } } break; - case STRING: { + case STRING: + case FACENAME: + case ANIMNAME: { // a String attribute final String inline = ((DialogAttrib<JTextField>) attr).input.getText().trim(); @@ -1148,6 +1224,16 @@ } } break; + case DBLLIST: { + final int val1 = (Integer) typelist.getListTable().get(attr.ref.getMisc()[0]).get(2 * ((JComboBox[]) attr.input)[0].getSelectedIndex()); + final int val2 = (Integer) typelist.getListTable().get(attr.ref.getMisc()[1]).get(2 * ((JComboBox[]) attr.input)[1].getSelectedIndex()); + final int combinedVal = val1 + val2; + + if (archetype.getAttributeInt(attr.ref.getNameOld()) != combinedVal) { + newArchText = newArchText + attr.ref.getNameOld() + " " + combinedVal + "\n"; + } + } + break; case BITMASK: { // a bitmask attribute (similar to integer, but easier because no parsing needed) final int value = ((BitmaskAttrib) attr).getValue(); // get bitmask value @@ -1689,4 +1775,45 @@ } // class StringKeyManager + /** Action for choosing a face or animation. */ + private static final class TreeChooseAction extends AbstractAction { + + /** JTextField to update upon tree selection. */ + private JTextField textField; + + /** Objects providing the tree. */ + private NamedObjects<? extends NamedObject> objects; + + /** + * Create a TreeChooseAction. + * @param text text for label / button + * @param textField JTextField to update upon tree selection + * @param objects NamedObjects that provide the tree + */ + private TreeChooseAction(final String text, final JTextField textField, final NamedObjects<? extends NamedObject> objects) { + super(text); + this.textField = textField; + this.objects = objects; + } + + /** {@inheritDoc} */ + public void actionPerformed(final ActionEvent e) { + String initial = textField.getText(); + final NamedObject selected = objects.get(initial); + if (selected != null) { + initial = selected.getPath(); + } + final String newValue = objects.showNodeChooserDialog(textField, initial); + if (newValue != null) { + textField.setText(newValue); + } + } + + /** {@inheritDoc} */ + @Override protected Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + } // class TreeChooseAction + } // class CAttribDialog Modified: trunk/crossfire/src/cfeditor/CFArchAttrib.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchAttrib.java 2006-12-10 18:05:24 UTC (rev 1026) +++ trunk/crossfire/src/cfeditor/CFArchAttrib.java 2006-12-10 18:10:58 UTC (rev 1027) @@ -159,6 +159,10 @@ } else if (atype.equalsIgnoreCase("string")) { dataType = ArchAttribType.STRING; } else if (atype.equalsIgnoreCase("text")) { + dataType = ArchAttribType.FACENAME; + } else if (atype.equalsIgnoreCase("animname")) { + dataType = ArchAttribType.ANIMNAME; + } else if (atype.equalsIgnoreCase("text")) { dataType = ArchAttribType.TEXT; // for text data, the terminating string has to be read too if ((a1 = root.getAttribute(XML_KEY_ARCH_BEGIN)) != null) { @@ -219,6 +223,29 @@ } else { log.warn("In '" + IGUIConstants.TYPEDEF_FILE + "', type " + typeName + ": List \"" + listName + "\" is undefined."); } + } else if ("doublelist".startsWith(atype)) { + // got a doublelist attribute + final String listNames = atype.substring(11).trim(); + final int seppos = listNames.indexOf(','); + + if (seppos == -1 || seppos == listNames.length() - 1) { + log.error("In '" + IGUIConstants.TYPEDEF_FILE + "': Type " + typeName + ", double list: '" + atype + "' does not contain two comma-separated lists."); + return false; + } + + + final String listName1 = listNames.substring(0, seppos); + final String listName2 = listNames.substring(seppos + 1); + + if (tlist.getListTable().containsKey(listName1) && tlist.getListTable().containsKey(listName2)) { + // the lists are well defined + dataType = ArchAttribType.DBLLIST; + misc = new String[2]; + misc[0] = listName1; // store list name in misc[0] + misc[1] = listName2; // store list name in misc[1] + } else { + log.error("In '" + IGUIConstants.TYPEDEF_FILE + "', type " + typeName + ": List \"" + listName1 + "\" or \"" + listName2 + "\" is undefined."); + } } else if ("treasurelist".equalsIgnoreCase(atype)) { dataType = ArchAttribType.TREASURE; } else { Modified: trunk/crossfire/src/cfeditor/gameobject/ArchAttribType.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchAttribType.java 2006-12-10 18:05:24 UTC (rev 1026) +++ trunk/crossfire/src/cfeditor/gameobject/ArchAttribType.java 2006-12-10 18:10:58 UTC (rev 1027) @@ -66,4 +66,13 @@ /** Treasure -> treasurelist (Textfield and Tree). */ TREASURE, + /** Double List -> 2 × Combobox. */ + DBLLIST, + + /** Face name -> Textfield and Tree. */ + FACENAME, + + /** Animation name -> Textfield and Tree. */ + ANIMNAME + } // enum ArchAttribType This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-12 03:39:23
|
Revision: 1010 http://svn.sourceforge.net/gridarta/?rev=1010&view=rev Author: akirschbaum Date: 2006-12-10 06:16:46 -0800 (Sun, 10 Dec 2006) Log Message: ----------- Remove IdGenerator class. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/ScriptEditor.java trunk/crossfire/src/cfeditor/gui/ScriptManager.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/IdGenerator.java Deleted: trunk/crossfire/src/cfeditor/IdGenerator.java =================================================================== --- trunk/crossfire/src/cfeditor/IdGenerator.java 2006-12-10 14:13:43 UTC (rev 1009) +++ trunk/crossfire/src/cfeditor/IdGenerator.java 2006-12-10 14:16:46 UTC (rev 1010) @@ -1,47 +0,0 @@ -/* - * Created on 03-nov.-2004 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ - -package cfeditor; - -import java.util.HashSet; -import java.util.Random; -import java.util.Set; - -/** - * Generator for ids. - * @author tchize - */ -public final class IdGenerator { - - private final Set<String> unsecureUid; - - private final Random unSecureRandom; - - private static final IdGenerator INSTANCE = new IdGenerator(); - - IdGenerator() { - unsecureUid = new HashSet<String>(); - //noinspection UnsecureRandomNumberGeneration - unSecureRandom = new Random(); - } - - public static IdGenerator getInstance() { - return INSTANCE; - } - - public String getUnsecureId() { - String id; - synchronized (unsecureUid) { - do { - id = Long.toHexString(unSecureRandom.nextLong()); - } while (unsecureUid.contains(id)); - unsecureUid.add(id); - } - return id; - } - -} // class IdGenerator Modified: trunk/crossfire/src/cfeditor/gui/ScriptEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ScriptEditor.java 2006-12-10 14:13:43 UTC (rev 1009) +++ trunk/crossfire/src/cfeditor/gui/ScriptEditor.java 2006-12-10 14:16:46 UTC (rev 1010) @@ -10,7 +10,6 @@ import cfeditor.CGUIUtils; import cfeditor.CScriptModel; import cfeditor.IGUIConstants; -import cfeditor.IdGenerator; import cfeditor.PluginParameter; import cfeditor.PluginParameterView; import cfeditor.parameter.ParameterDescriptionEditor; @@ -373,20 +372,6 @@ paramTable.add(getParameterView(param).getValueComponent(param.getValue(), param), gbc); } - public String getUid() { - if (uuid == null) { - generateUid(); - } - - return uuid; - } - - private synchronized void generateUid() { - if (uuid == null) { - uuid = IdGenerator.getInstance().getUnsecureId(); - } - } - private CScriptModel getScript() { return script; } Modified: trunk/crossfire/src/cfeditor/gui/ScriptManager.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ScriptManager.java 2006-12-10 14:13:43 UTC (rev 1009) +++ trunk/crossfire/src/cfeditor/gui/ScriptManager.java 2006-12-10 14:16:46 UTC (rev 1010) @@ -159,9 +159,9 @@ if (c == null) { c = new ScriptEditor(model); components.put(model, c); - scriptPanel.add(c, c.getUid()); + scriptPanel.add(c, Integer.toString(c.hashCode())); } - scriptLayout.show(scriptPanel, c.getUid()); + scriptLayout.show(scriptPanel, Integer.toString(c.hashCode())); } private void removeScript(final CScriptModel model) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-12 03:39:30
|
Revision: 1031 http://svn.sourceforge.net/gridarta/?rev=1031&view=rev Author: akirschbaum Date: 2006-12-10 11:10:17 -0800 (Sun, 10 Dec 2006) Log Message: ----------- Unify (remove) functions in MapModel. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/crossfire/src/cfeditor/map/MapModel.java trunk/crossfire/src/cfeditor/parameter/MapParameter.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-10 19:07:55 UTC (rev 1030) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-10 19:10:17 UTC (rev 1031) @@ -542,7 +542,7 @@ for (final MapControl level : levels) { level.getMapViewFrame().updateLookAndFeel(); if (log.isDebugEnabled()) { - log.debug("map " + level.getMapName()); + log.debug("map " + level.getMapArch().getMapName()); } } } Modified: trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2006-12-10 19:07:55 UTC (rev 1030) +++ trunk/crossfire/src/cfeditor/gui/map/MapPropertiesDialog.java 2006-12-10 19:10:17 UTC (rev 1031) @@ -189,7 +189,7 @@ private JPanel createMapPanel(final MapArchObject map) { final JPanel panel = new JPanel(new GridLayout(0, 1)); - panel.add(createPanelLine(mapName, 16, mapControl.getMapName(), "mapName")); + panel.add(createPanelLine(mapName, 16, map.getMapName(), "mapName")); panel.add(createPanelLine(mapRegion, 16, map.getMapRegion(), "mapRegion")); final Size2D mapSize = mapControl.getMapSize(); panel.add(createPanelLine(levelWidthField, 10, String.valueOf(mapSize.getWidth()), "mapWidth")); @@ -570,7 +570,7 @@ mapDescription.setText(map.getText()); mapLore.setText(map.getLore()); - mapName.setText(mapControl.getMapName()); + mapName.setText(map.getMapName()); mapRegion.setText("" + map.getMapRegion()); final Size2D mapSize = map.getMapSize(); levelWidthField.setText(String.valueOf(mapSize.getWidth())); Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-10 19:07:55 UTC (rev 1030) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-10 19:10:17 UTC (rev 1031) @@ -444,26 +444,6 @@ } /** {@inheritDoc} */ - public void setFileName(final String strFileName) { - getMapArchObject().setFileName(strFileName); - } - - /** {@inheritDoc} */ - public String getFileName() { - return getMapArchObject().getFileName(); - } - - /** {@inheritDoc} */ - public void setMapName(final String name) { - getMapArchObject().setMapName(name); - } - - /** {@inheritDoc} */ - public String getMapName() { - return getMapArchObject().getMapDisplayName(); - } - - /** {@inheritDoc} */ @Nullable public GameObject getExit(@Nullable final Point hspot) { if (hspot == null || !isPointValid(hspot)) { return null; // out of map Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-10 19:07:55 UTC (rev 1030) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-10 19:10:17 UTC (rev 1031) @@ -47,6 +47,8 @@ */ private final CMainControl mainControl; + private final MapArchObject mapArch; + /** * model (= map data of this level). */ @@ -101,6 +103,7 @@ */ public MapControl(final CMainControl mainControl, final List<GameObject> objects, final MapArchObject maparch, final boolean isPickmap, final Point initial) { this.mainControl = mainControl; + mapArch = maparch; activeEditType = 0; // start with no edit types (saves time) this.isPickmap = isPickmap; // is this a pickmap? // we create model (= data) @@ -230,6 +233,19 @@ return mapModel.getMapArchObject().getTilePath(direction); } + public String getMapFileName() { + return mapArch.getFileName(); + } + + public void setMapFileName(final String fname) { + if (mapViewFrame != null) { + final String title = fname + " [ " + mapArch.getMapName() + " ]"; + assert mapViewFrame != null; + mapViewFrame.setTitle(title); + } + mapArch.setFileName(fname); + } + public boolean containsArchObject(final Point pos) { return mapModel.containsArchObject(pos); } @@ -360,31 +376,6 @@ mapModel.resizeMap(size); } - /** - * Returns the name of this map. - * @return The name of this map. - */ - public String getMapName() { - return mapModel.getMapName(); - } - - /** - * Set the level name. - * @param strName the level name - */ - public void setMapName(final String strName) { - mapModel.setMapName(strName); - } - - public String getMapFileName() { - return mapModel.getFileName(); - } - - public void setMapFileName(final String fname) { - mapViewFrame.setTitle("Map [" + fname + "]"); - mapModel.setFileName(fname); - } - public void setLevelChangedFlag() { mapModel.setLevelChangedFlag(); } Modified: trunk/crossfire/src/cfeditor/map/MapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapModel.java 2006-12-10 19:07:55 UTC (rev 1030) +++ trunk/crossfire/src/cfeditor/map/MapModel.java 2006-12-10 19:10:17 UTC (rev 1031) @@ -119,30 +119,6 @@ boolean containsArchObject(Point pos); /** - * Get the map name as seen by the player. - * @return the map name - */ - String getMapName(); - - /** - * Update the map name as seen by the player. - * @param name the new map name - */ - void setMapName(String name); - - /** - * Get the map filename. - * @return the map filename - */ - String getFileName(); - - /** - * Update the map filename. - * @param strFileName the new map filename - */ - void setFileName(String strFileName); - - /** * Reset the level changed flag to false. * @todo this probably belongs to CMapControl instead */ Modified: trunk/crossfire/src/cfeditor/parameter/MapParameter.java =================================================================== --- trunk/crossfire/src/cfeditor/parameter/MapParameter.java 2006-12-10 19:07:55 UTC (rev 1030) +++ trunk/crossfire/src/cfeditor/parameter/MapParameter.java 2006-12-10 19:10:17 UTC (rev 1031) @@ -65,7 +65,7 @@ super.setValue(null); } else { final MapControl map = (MapControl) value; - super.setValue(map.getMapName()); + super.setValue(map.getMapArch().getMapName()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-12 03:39:31
|
Revision: 1036 http://svn.sourceforge.net/gridarta/?rev=1036&view=rev Author: akirschbaum Date: 2006-12-10 11:58:30 -0800 (Sun, 10 Dec 2006) Log Message: ----------- Remove duplicate function. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/MapViewIFrame.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-10 19:54:24 UTC (rev 1035) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-10 19:58:30 UTC (rev 1036) @@ -680,7 +680,7 @@ public void levelViewFocusGainedNotify(final MapViewIFrame view) { mapViews.remove(view); mapViews.add(0, view); - final MapControl level = view.getLevel(); + final MapControl level = view.getMapControl(); mainControl.setCurrentLevel(level); //statusBar.setLevelInfo(level); } Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-10 19:54:24 UTC (rev 1035) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-10 19:58:30 UTC (rev 1036) @@ -105,14 +105,6 @@ setTitle(strTitle); // display new title } - /** - * Returns the controller of this view. - * @return The controller of this view. - */ - public MapControl getLevel() { - return mapControl; - } - // following a bunch of wrapper methods which just pass access // to the basic mapview object 'view': public Point getMapMouseRightPos() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-15 19:50:04
|
Revision: 1073 http://svn.sourceforge.net/gridarta/?rev=1073&view=rev Author: akirschbaum Date: 2006-12-15 11:50:03 -0800 (Fri, 15 Dec 2006) Log Message: ----------- Rename variable names. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CArchPanel.java trunk/crossfire/src/cfeditor/CArchPanelPan.java Modified: trunk/crossfire/src/cfeditor/CArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanel.java 2006-12-15 18:55:17 UTC (rev 1072) +++ trunk/crossfire/src/cfeditor/CArchPanel.java 2006-12-15 19:50:03 UTC (rev 1073) @@ -136,8 +136,8 @@ return selectedPanel.addArchPanelCombo(name); } - public void addArchPanelArch(final String archname, final int index) { - selectedPanel.addArchPanelArch(archname, index); + public void addArchPanelArch(final String archetypeName, final int index) { + selectedPanel.addArchPanelArch(archetypeName, index); } /** Modified: trunk/crossfire/src/cfeditor/CArchPanelPan.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-12-15 18:55:17 UTC (rev 1072) +++ trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-12-15 19:50:03 UTC (rev 1073) @@ -56,7 +56,7 @@ /** Controller of this subview. */ private final CMainControl mainControl; - /** List of index-archname pairs. */ + /** List of index-archetype name pairs. */ private List<PanelEntry> archList = new ArrayList<PanelEntry>(); private final JList theList; @@ -65,7 +65,7 @@ private final JPanel panelDesktop; - private final JComboBox jbox; + private final JComboBox comboBox; private int comboCounter; @@ -81,7 +81,7 @@ panelDesktop = new JPanel(); panelDesktop.setLayout(new BorderLayout()); - jbox = new JComboBox(); + comboBox = new JComboBox(); model = new DefaultListModel(); theList = new JList(model); @@ -89,13 +89,13 @@ theList.setBackground(IGUIConstants.BG_COLOR); final JScrollPane scrollPane = new JScrollPane(theList); panelDesktop.add(scrollPane, BorderLayout.CENTER); - panelDesktop.add(jbox, BorderLayout.NORTH); + panelDesktop.add(comboBox, BorderLayout.NORTH); scrollPane.setAutoscrolls(true); scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - jbox.setAutoscrolls(true); + comboBox.setAutoscrolls(true); - jbox.addActionListener(new ActionListener() { + comboBox.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { showArchList(); } @@ -145,8 +145,8 @@ if (index != -1) { try { - final String archname = theList.getSelectedValue().toString(); - archetype = mainControl.getArchetypeSet().getArchetype(archname); + final String archetypeName = theList.getSelectedValue().toString(); + archetype = mainControl.getArchetypeSet().getArchetype(archetypeName); } catch (final NullPointerException e) { /* log.info("NullPointerException in showArchListObject()!", e); @@ -161,16 +161,16 @@ /** * Add this arch to list of (this) Jlist list. - * @param archname name of the arch to add + * @param archetypeName name of the archetype to add * @param index index of subdir where to add */ - public void addArchPanelArch(final String archname, final int index) { - archList.add(new PanelEntry(index, archname)); + public void addArchPanelArch(final String archetypeName, final int index) { + archList.add(new PanelEntry(index, archetypeName)); } int addArchPanelCombo(final String name) { setEnabled(false); - jbox.addItem(name); + comboBox.addItem(name); setEnabled(true); return comboCounter++; } @@ -196,7 +196,7 @@ for (final PanelEntry p : archList) { try { final int index = p.getIndex(); - catList[i++] = jbox.getItemAt(index).toString().trim(); + catList[i++] = comboBox.getItemAt(index).toString().trim(); } catch (final NullPointerException e) { log.warn("Nullpointer in getListCategoryArray()!", e); } @@ -206,7 +206,7 @@ } void showArchList() { - final int index = jbox.getSelectedIndex(); + final int index = comboBox.getSelectedIndex(); model.removeAllElements(); for (PanelEntry p : archList) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-15 20:36:29
|
Revision: 1077 http://svn.sourceforge.net/gridarta/?rev=1077&view=rev Author: akirschbaum Date: 2006-12-15 12:36:27 -0800 (Fri, 15 Dec 2006) Log Message: ----------- Simplify CArchPanel/CArchPanelPan implementation. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CArchPanel.java trunk/crossfire/src/cfeditor/CArchPanelPan.java Modified: trunk/crossfire/src/cfeditor/CArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanel.java 2006-12-15 20:11:50 UTC (rev 1076) +++ trunk/crossfire/src/cfeditor/CArchPanel.java 2006-12-15 20:36:27 UTC (rev 1077) @@ -57,7 +57,7 @@ private final transient CMainControl mainControl; /** - * Name of the selected arch. + * Name of the selected archetype. * @serial include */ private String selectedArch; @@ -74,9 +74,6 @@ /** The data/view of selected objects in tab panel. */ private final CArchQuickView archQuickPanel; - /** List of arch panels. */ - private static List<PanelNode> panelNodeList = new ArrayList<PanelNode>(); - /** The active panel. */ private CArchPanelPan selectedPanel; @@ -95,21 +92,19 @@ // archAndPickPane is the panel containing both archpanel and pickmaps archAndPickPane = new JTabbedPane(SwingConstants.TOP); - archAndPickPane.addTab(" Arch List ", tabDesktop); - archAndPickPane.addTab(" Pickmaps ", mainControl.getMainView().getPickmapPanel()); + archAndPickPane.addTab("Arch List", tabDesktop); + archAndPickPane.addTab("Pickmaps", mainControl.getMainView().getPickmapPanel()); // this listener informs the mainview which panel is active: archlist or pickmaps? CPickmapPanel.getInstance().addArchNPickChangeListener(archAndPickPane); - splitPane = new GSplitPane(JSplitPane.VERTICAL_SPLIT, archAndPickPane, archQuickPanel); - // calculate default value in case there is no settings file final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); final int divLocation = Integer.parseInt(settings.getProperty(ARCHPANEL_LOCATION_KEY, String.valueOf((int) (0.77 * 0.9 * screen.getHeight())))); + splitPane = new GSplitPane(JSplitPane.VERTICAL_SPLIT, archAndPickPane, archQuickPanel); splitPane.setDividerLocation(divLocation); - splitPane.setDividerSize(5); add(splitPane, BorderLayout.CENTER); } @@ -148,19 +143,18 @@ } public void addPanel(final String name) { - final PanelNode newnode = new PanelNode(new CArchPanelPan(this, mainControl), name); + final CArchPanelPan newnode = new CArchPanelPan(this, mainControl); // insert new panels in alphabetical order int i; for (i = 0; i < tabDesktop.getTabCount() && name.compareToIgnoreCase(tabDesktop.getTitleAt(i)) > 0; i++) { ; } - panelNodeList.add(i, newnode); - tabDesktop.insertTab(name, null, newnode.data.getPanel(), null, i); + tabDesktop.insertTab(name, null, newnode, null, i); // careful: during the build process we are setting 'selectedPanel' // in spite of the fact that this panel might *not* actually be selected - selectedPanel = newnode.data; + selectedPanel = newnode; } /** @@ -169,25 +163,28 @@ * setting and make sure the arch list is properly drawn. */ public void finishBuildProcess() { - final Component sel = tabDesktop.getSelectedComponent(); - for (final PanelNode node : panelNodeList) { - if (node.data.getPanel() == sel) { - if (node.data != null) { - selectedPanel = node.data; + selectedPanel = (CArchPanelPan) tabDesktop.getSelectedComponent(); + if (selectedPanel != null) { + selectedPanel.showArchList(); + } + + // we must set the list of the selected list depend on combo selection + tabDesktop.addChangeListener(new ChangeListener() { + public void stateChanged(final ChangeEvent e) { + final JTabbedPane tabbedPane = (JTabbedPane) e.getSource(); + selectedPanel = (CArchPanelPan) tabDesktop.getComponentAt(tabbedPane.getSelectedIndex()); + if (selectedPanel != null) { selectedPanel.showArchList(); } - break; } - } + }); // we must set the list of the selected list depend on combo selection tabDesktop.addChangeListener(new ChangeListener() { public void stateChanged(final ChangeEvent e) { final JTabbedPane tabbedPane = (JTabbedPane) e.getSource(); - setSelectedArch(null); - final PanelNode node = panelNodeList.get(tabbedPane.getSelectedIndex()); - selectedPanel = node.getData(); + selectedPanel = (CArchPanelPan) tabDesktop.getComponentAt(tabbedPane.getSelectedIndex()); if (selectedPanel != null) { selectedPanel.showArchList(); } @@ -195,7 +192,7 @@ }); } - void appExitNotify() { + public void appExitNotify() { final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); settings.setProperty(ARCHPANEL_LOCATION_KEY, String.valueOf(splitPane.getDividerLocation())); } @@ -216,33 +213,9 @@ this.selectedArch = selectedArch; } - void refresh() { + public void refresh() { archQuickPanel.refresh(); repaint(); } - public static final class PanelNode { - - private final CArchPanelPan data; - - /** - * Title of this node. - */ - private final String title; - - public PanelNode(final CArchPanelPan data, final String title) { - this.data = data; - this.title = title; - } - - public String getTitle() { - return title; - } - - public CArchPanelPan getData() { - return data; - } - - } // class PanelNode - } // class CArchPanel Modified: trunk/crossfire/src/cfeditor/CArchPanelPan.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-12-15 20:11:50 UTC (rev 1076) +++ trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-12-15 20:36:27 UTC (rev 1077) @@ -33,7 +33,9 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.swing.DefaultListCellRenderer; import javax.swing.DefaultListModel; import javax.swing.JComboBox; @@ -41,6 +43,8 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JViewport; +import javax.swing.ListModel; +import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import org.apache.log4j.Logger; @@ -56,40 +60,33 @@ /** Controller of this subview. */ private final CMainControl mainControl; - /** List of index-archetype name pairs. */ - private List<PanelEntry> archList = new ArrayList<PanelEntry>(); + /** Maps index to list of archetype names. */ + private Map<Integer, ArrayList<String>> archLists = new HashMap<Integer, ArrayList<String>>(); private final JList theList; private final DefaultListModel model; - private final JPanel panelDesktop; - private final JComboBox comboBox; - private int comboCounter; - private final CArchPanel archPanel; /* Build Panel */ CArchPanelPan(final CArchPanel controlPanel, final CMainControl mainControl) { + super(new BorderLayout()); this.mainControl = mainControl; archPanel = controlPanel; - comboCounter = 0; - setLayout(new BorderLayout()); - panelDesktop = new JPanel(); - panelDesktop.setLayout(new BorderLayout()); - comboBox = new JComboBox(); model = new DefaultListModel(); theList = new JList(model); theList.setCellRenderer(new MyCellRenderer()); theList.setBackground(IGUIConstants.BG_COLOR); + theList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); final JScrollPane scrollPane = new JScrollPane(theList); - panelDesktop.add(scrollPane, BorderLayout.CENTER); - panelDesktop.add(comboBox, BorderLayout.NORTH); + add(scrollPane, BorderLayout.CENTER); + add(comboBox, BorderLayout.NORTH); scrollPane.setAutoscrolls(true); scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); @@ -106,17 +103,6 @@ showArchListObject(e.getFirstIndex()); } }); - - // listening for mouse-click events in the ArchPanel list - theList.addMouseListener(new MouseAdapter() { - @Override public void mousePressed(final MouseEvent e) { - // In JDK 1.4 it is required to transfer focus back to mapview after - // every click in the panel, otherwise the menu-shortcuts stop working - if (mainControl.getCurrentMap() != null && mainControl.getCurrentMap().getMapViewFrame() != null) { - mainControl.getCurrentMap().getMapViewFrame().requestFocus(); // focus to mapview - } - } - }); } /** @@ -140,22 +126,17 @@ return archetype; } - public void showArchListObject(int index) { + private void showArchListObject(int index) { GameObject archetype = null; - - if (index != -1) { - try { - final String archetypeName = theList.getSelectedValue().toString(); + String archetypeName = null; + if (0 <= index && index < model.getSize()) { + archetypeName = (String) theList.getSelectedValue(); + if (archetypeName != null) { archetype = mainControl.getArchetypeSet().getArchetype(archetypeName); - } catch (final NullPointerException e) { - /* - log.info("NullPointerException in showArchListObject()!", e); - This happens in JDK 1.4 when you select an arch in panel A, - then select Panel B, then Panel A again. (why??) - */ - } catch (final NumberFormatException e) { + archPanel.setSelectedArch(archetypeName); } } + mainControl.setStatusText(archetypeName == null ? "" : archetypeName); mainControl.showArchPanelQuickObject(archetype); // send it to quick view } @@ -165,59 +146,49 @@ * @param index index of subdir where to add */ public void addArchPanelArch(final String archetypeName, final int index) { - archList.add(new PanelEntry(index, archetypeName)); + final ArrayList<String> tmp = archLists.get(index); + final ArrayList<String> archList; + if (tmp == null) { + archList = new ArrayList<String>(); + archLists.put(index, archList); + } else { + archList = tmp; + } + + archList.add(archetypeName); } - int addArchPanelCombo(final String name) { - setEnabled(false); + /** + * Add a new category to the combo box. + * + * @param name the name of the combo box to create + * + * @return the combo box index + */ + public int addArchPanelCombo(final String name) { comboBox.addItem(name); - setEnabled(true); - return comboCounter++; + return comboBox.getItemCount() - 1; } - JPanel getPanel() { - return panelDesktop; - } - - public List<PanelEntry> getPanelEntries() { - return archList; - } - - void showArchList() { + public void showArchList() { final int index = comboBox.getSelectedIndex(); model.removeAllElements(); - for (PanelEntry p : archList) { - if (index >= 0) { - if (index == 0) { - model.addElement(p.getName()); - } else { - if (index == p.getIndex()) { - model.addElement(p.getName()); - } + if (index == 0) { + for (final List<String> archList : archLists.values()) { + for (final String archName : archList) { + model.addElement(archName); } } } - } - - public static final class PanelEntry { - - private int index; - - private String archName; - - public PanelEntry(final int i, final String name) { - index = i; - archName = name; + else if (index > 0) { + final List<String> archList = archLists.get(index); + if (archList != null) { + for (final String archName : archList) { + model.addElement(archName); + } + } } - - public int getIndex() { - return index; - } - - public String getName() { - return archName; - } } /** Cell Renderer for rendering cells in the ArchPanelPan. */ @@ -234,10 +205,6 @@ final ArchetypeSet archetypeSet = mainControl.getArchetypeSet(); final String archetypeName = (String) value; final GameObject archetype = archetypeSet.getArchetype(archetypeName); - if (isSelected) { // XXX it is not a good idea to query the selection information at this place. - archPanel.setSelectedArch(archetypeName); - mainControl.setStatusText(archetypeName); - } assert archetype != null : "Archetype not found: " + archetypeName; setText(archetypeName); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-15 22:45:47
|
Revision: 1090 http://svn.sourceforge.net/gridarta/?rev=1090&view=rev Author: akirschbaum Date: 2006-12-15 14:45:48 -0800 (Fri, 15 Dec 2006) Log Message: ----------- Whitespace changes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CGUIUtils.java trunk/crossfire/src/cfeditor/CNewMapDialog.java Modified: trunk/crossfire/src/cfeditor/CGUIUtils.java =================================================================== --- trunk/crossfire/src/cfeditor/CGUIUtils.java 2006-12-15 22:44:47 UTC (rev 1089) +++ trunk/crossfire/src/cfeditor/CGUIUtils.java 2006-12-15 22:45:48 UTC (rev 1090) @@ -101,8 +101,7 @@ } else if (dirName.contains(File.separator)) { // let's try it again without first directory (okay, this may look // a bit weird, but usually this is the correct icon path in the jar) - imageResource = ClassLoader.getSystemResource(dirName.substring(dirName.indexOf(File.separator) + 1) - + '/' + strIconName); + imageResource = ClassLoader.getSystemResource(dirName.substring(dirName.indexOf(File.separator) + 1) + '/' + strIconName); if (imageResource != null) { icon = new ImageIcon(imageResource); } else { Modified: trunk/crossfire/src/cfeditor/CNewMapDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CNewMapDialog.java 2006-12-15 22:44:47 UTC (rev 1089) +++ trunk/crossfire/src/cfeditor/CNewMapDialog.java 2006-12-15 22:45:48 UTC (rev 1090) @@ -251,8 +251,7 @@ // default map text: final Calendar today = Calendar.getInstance(); // get current date maparch.addText("Creator: CF Java Map Editor\n"); - maparch.addText("Date: " + (today.get(Calendar.MONTH) + 1) + "/" + - today.get(Calendar.DAY_OF_MONTH) + "/" + today.get(Calendar.YEAR)); + maparch.addText("Date: " + (today.get(Calendar.MONTH) + 1) + "/" + today.get(Calendar.DAY_OF_MONTH) + "/" + today.get(Calendar.YEAR)); if (mapType == MapType.GAMEMAP) { mainControl.newLevel(null, maparch, true, null); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-15 23:54:10
|
Revision: 1093 http://svn.sourceforge.net/gridarta/?rev=1093&view=rev Author: akirschbaum Date: 2006-12-15 15:54:10 -0800 (Fri, 15 Dec 2006) Log Message: ----------- Move spell related code into separate class. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/CFArchAttrib.java trunk/crossfire/src/cfeditor/CFArchTypeList.java trunk/crossfire/src/cfeditor/CMainControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/Spells.java Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-15 23:24:28 UTC (rev 1092) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-15 23:54:10 UTC (rev 1093) @@ -339,7 +339,7 @@ // first parse the spell-number value from gameObject int spnum = gameObject.getAttributeInt(attr.getNameOld()); // spell number - if (spnum < 0 || spnum >= archTypeList.getSpellNum().length - 1) { + if (spnum < 0 || spnum >= CFArchTypeList.getSpells().getSpellNumbers().length - 1) { spnum = 0; // undefined spellnumbers be zero } @@ -350,15 +350,15 @@ } else { // now look up the spell-number in the array of spells active = 0; - for (int i = 0; i < archTypeList.getSpellNum().length; i++) { - if (archTypeList.getSpellNum()[i] == spnum) { + for (int i = 0; i < CFArchTypeList.getSpells().getSpellNumbers().length; i++) { + if (CFArchTypeList.getSpells().getSpellNumbers()[i] == spnum) { active = i; // set selection - i = archTypeList.getSpellNum().length + 10; // end loop + i = CFArchTypeList.getSpells().getSpellNumbers().length + 10; // end loop } } } - final JComboBox spellsel = new JComboBox(archTypeList.getSpellName()); // set "content" + final JComboBox spellsel = new JComboBox(CFArchTypeList.getSpells().getSpellNames()); // set "content" spellsel.setSelectedIndex(active); // set active selection spellsel.setMaximumRowCount(10); spellsel.setKeySelectionManager(new StringKeyManager(spellsel)); @@ -1200,7 +1200,7 @@ switch (dType) { case SPELL: case ZSPELL: - attrVal = archTypeList.getSpellNum()[((DialogAttrib<JComboBox>) attr).input.getSelectedIndex()]; + attrVal = CFArchTypeList.getSpells().getSpellNumbers()[((DialogAttrib<JComboBox>) attr).input.getSelectedIndex()]; break; case LIST: // get selected index of ComboBox Modified: trunk/crossfire/src/cfeditor/CFArchAttrib.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchAttrib.java 2006-12-15 23:24:28 UTC (rev 1092) +++ trunk/crossfire/src/cfeditor/CFArchAttrib.java 2006-12-15 23:54:10 UTC (rev 1093) @@ -188,14 +188,14 @@ } } else if ("spell".equalsIgnoreCase(atype)) { // spell attribute - if (tlist.getSpellNum() == null) { + if (CFArchTypeList.getSpells().getSpellNumbers() == null) { dataType = ArchAttribType.INT; // if we have no spells, use an INT field instead } else { dataType = ArchAttribType.SPELL; } } else if ("nz_spell".equalsIgnoreCase(atype)) { // spell attribute - if (tlist.getSpellNum() == null) { + if (CFArchTypeList.getSpells().getSpellNumbers() == null) { dataType = ArchAttribType.INT; // if we have no spells, use an INT field instead } else { dataType = ArchAttribType.ZSPELL; Modified: trunk/crossfire/src/cfeditor/CFArchTypeList.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-15 23:24:28 UTC (rev 1092) +++ trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-15 23:54:10 UTC (rev 1093) @@ -26,12 +26,6 @@ import cfeditor.gameobject.GameObject; import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.EOFException; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -39,8 +33,6 @@ import java.util.List; import java.util.Map; import java.util.Iterator; -import javax.swing.JFileChooser; -import javax.swing.filechooser.FileFilter; import net.sf.gridarta.io.IOUtils; import org.apache.log4j.Logger; import org.jdom.Attribute; @@ -61,11 +53,8 @@ private final CFArchType head = new CFArchType(null); // head of CFArchType list (head contains default type) - // spell info: - private String[] spellName; // array of spell names (these all begin with a ' ' space!) + private static final Spells spells = new Spells(); - private int[] spellNum; // array of spell numbers - /** * Table with type numbers as keys (Integer), and type names as values (String). */ @@ -117,6 +106,10 @@ return arch != null && EXIT_TYPES.contains(arch.getHead().getArchTypNr()); } + public static Spells getSpells() { + return spells; + } + /** * Constructor - Parsing all the data from the xml definitions file * 'types.xml'. @@ -128,7 +121,7 @@ listTable = new HashMap<String, List<?>>(); ignoreListTable = new HashMap<String, List<String>>(); - loadSpellsFromXML(); // load spells from file + spells.loadSpellsFromXML(); // load spells from file try { // open ascii filestream to the xml data @@ -319,14 +312,6 @@ } } - public String[] getSpellName() { - return spellName; - } - - public int[] getSpellNum() { - return spellNum; - } - /** * Return the bitmask table which contains all definitions of bitmask types for arch attributes. * @return bitmask table @@ -357,116 +342,6 @@ } /** - * Read the spells from "spells.xml" into the arrays 'spellName' - * and 'spellNum'. This method is called at startup - */ - public void loadSpellsFromXML() { - spellName = null; - spellNum = null; - - try { - // open reading stream to the spells xml file - final String baseDir = IGUIConstants.CONFIG_DIR; - final BufferedReader reader = IOUtils.createReader(baseDir, IGUIConstants.SPELL_FILE); - try { - // parse xml document - final SAXBuilder builder = new SAXBuilder(); - final Document doc = builder.build(reader); - - // retrieve the spell data from the xml - final Element root = doc.getRootElement(); - Element spellElem; - if (root == null || !root.getName().equalsIgnoreCase("spells")) { - log.warn("File '" + IGUIConstants.SPELL_FILE + "' lacks root element 'spells'."); - } else { - final List spells = root.getChildren("spell"); - if (spells == null || spells.size() == 0) { - log.warn("File '" + IGUIConstants.SPELL_FILE + "' has no content."); - } else { - // initialize array with appropriate size - spellName = new String[spells.size() + 1]; - spellNum = new int[spells.size() + 1]; - - // first element is <none> - spellName[0] = " <none>"; - spellNum[0] = -1; - - int i; - int j; - for (j = 0, i = 1; j < spells.size(); j++) { - spellElem = (Element) spells.get(j); - - if (spellElem.getAttribute("id") == null) { - log.warn("In File '" + IGUIConstants.SPELL_FILE + "': Found 'spell' element without 'id'"); - } else if (spellElem.getAttribute("name") == null) { - log.warn("In File '" + IGUIConstants.SPELL_FILE + "': Found 'spell' element without 'name'"); - } else { - try { - // parse spell number and -name - spellNum[i] = spellElem.getAttribute("id").getIntValue(); - spellName[i] = spellElem.getAttribute("name").getValue().trim(); - i++; - } catch (final DataConversionException de) { - log.error("in '" + IGUIConstants.SPELL_FILE + "': spell id '" + spellElem.getAttribute("id").getValue() + "' is not an integer."); - } - } - } - - // loading successful - i--; - if (log.isInfoEnabled()) { - if (i == spells.size()) { - log.info("Loaded " + i + " spells from '" + IGUIConstants.SPELL_FILE + "'"); - } else { - log.info("Loaded " + i + " of " + spells.size() + " defined spells from '" + IGUIConstants.SPELL_FILE + "'"); - } - } - } - } - } finally { - reader.close(); - } - } catch (final JDOMException e) { - log.error("Parsing error in '" + IGUIConstants.SPELL_FILE + "'", e); - } catch (final IOException e) { - log.error("Cannot read file '" + IGUIConstants.SPELL_FILE + "'!"); - } - } - - /** - * Opens a file chooser to select the spellist file, - * then import spells. - * @param mainControl main control - */ - public void importSpellsWanted(final CMainControl mainControl) { - // open a file chooser window - final JFileChooser fileChooser = new JFileChooser(); - fileChooser.setDialogTitle("Open CF Spellist File"); - fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); - fileChooser.setMultiSelectionEnabled(false); - fileChooser.setFileFilter(new SpellFileFilter()); // apply file filter - fileChooser.setCurrentDirectory(new File(System.getProperty("user.dir"))); - - final int returnVal = fileChooser.showOpenDialog(mainControl.getMainView()); - - if (returnVal == JFileChooser.APPROVE_OPTION) { - // now import spells from selected file - final File spellfile = fileChooser.getSelectedFile(); - final int spnum = importSpells(spellfile); - if (spnum > 0) { - // yeah it worked - mainControl.showMessage("Collect Spells", - "Successfully collected " + spnum + " spells."); - } else { - // spell collect failed - mainControl.showMessage("Collect Spells", - "Collecting spells failed!\n" + - "Maybe the specified file is of wrong format."); - } - } - } - - /** * Lookup the name of an archtype. * @param typeNr type number * @return name of this type, as defined in "typenumbers.xml" @@ -476,133 +351,6 @@ } /** - * Read all spells from a CF spellist file and write an - * alphabetical list into "spells.def" - * @param spellfile spellfile to read - * @return number of successfully collected spells - */ - private int importSpells(final File spellfile) { - List<String> list = null; // growable array of spellnames+numbers - String tmp; // tmp String for spell names - - final FileWriter fileWriter; // file writer for "spells.def" - final BufferedWriter bufferedWriter; // buffered writer - - if (spellfile.getName().equalsIgnoreCase("spellist.h")) { - list = new ArrayList<String>(); - FileReader fileReader = null; - BufferedReader bufferedReader = null; - - try { - fileReader = new FileReader(spellfile.getAbsolutePath()); - bufferedReader = new BufferedReader(fileReader); - - IOUtils.readUntil(bufferedReader, "spell spells", null); - IOUtils.readUntil(bufferedReader, "{", null); - - // reading spellnames one after the other, - // this loop is terminated by an EOFException - int i; // index for insertion in the vector - for (int counter = 0; true; counter++) { - IOUtils.readUntil(bufferedReader, "{", "}"); - IOUtils.readUntil(bufferedReader, "\"", null); - String name = IOUtils.readUntil(bufferedReader, "\""); - IOUtils.readUntil(bufferedReader, "}", null); - - name = name.trim(); - // now insert this string lexographically into the vector - for (i = 0; i < list.size(); i++) { - tmp = list.get(i); - tmp = tmp.substring(tmp.indexOf(" ") + 1); - - if (name.compareTo(tmp) < 0) { - // everything okay, now insert - list.add(i, counter + " " + name); - i = list.size() + 10; // end for - } else if (name.compareTo(tmp) == 0) { - // this spell already exist in the list - i = list.size() + 10; // end for - counter--; // next loop with same counter value - } - } - - // if no insertion spot found, add to end of list - if (i < list.size() + 10) { - list.add(counter + " " + name); - } - } - } catch (final FileNotFoundException e) { - log.error("File '" + spellfile.getAbsolutePath() + "' not found!"); - } catch (final EOFException e) { - // end of file/spell struct reached - try { - fileReader.close(); - bufferedReader.close(); - } catch (final IOException ioe) { - } - } catch (final IOException e) { - log.error("Cannot read file '" + spellfile.getAbsolutePath() + "'!"); - } - } - - // --------- now write the "spells.def" file --------- - if (list != null && list.size() > 0) { - File dfile = null; - try { - // create new file for writing (replaces old one if existent) - if (IGUIConstants.CONFIG_DIR != null && IGUIConstants.CONFIG_DIR.length() > 0) { - final File dir = new File(IGUIConstants.CONFIG_DIR); - if (!dir.exists() || !dir.isDirectory()) { - // create the config dir - new File("resource").mkdir(); - new File(IGUIConstants.CONFIG_DIR).mkdir(); - } - - dfile = new File(IGUIConstants.CONFIG_DIR + File.separator + IGUIConstants.SPELL_FILE); - } else { - dfile = new File(IGUIConstants.SPELL_FILE); - } - - fileWriter = new FileWriter(dfile); - bufferedWriter = new BufferedWriter(fileWriter); - - // header: - bufferedWriter.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); - bufferedWriter.write("<spells>\n<!--\n"); - bufferedWriter.write(" ##########################################################\n"); - bufferedWriter.write(" # You may add new spells to this file, but there's no #\n"); - bufferedWriter.write(" # need to do it because the file can be autogenerated. #\n"); - bufferedWriter.write(" # In the editor, select menu \"Resources->Collect Spells\" #\n"); - bufferedWriter.write(" # to generate a new version of this file. #\n"); - bufferedWriter.write(" ##########################################################\n-->\n"); - - // write spell-entries: - for (final String entry : list) { - tmp = String.valueOf(entry); - final String id = tmp.substring(0, tmp.indexOf(" ")).trim(); - final String name = tmp.substring(tmp.indexOf(" ") + 1).trim(); - String space = ""; - if (id.length() == 1) { - space = " "; - } else if (id.length() == 2) { - space = " "; - } - bufferedWriter.write(" <spell id=\"" + id + "\"" + space + " name=\"" + name + "\" />\n"); - } - bufferedWriter.write("</spells>"); - - bufferedWriter.close(); - fileWriter.close(); - return list.size(); - } catch (final IOException e) { - log.error("Cannot write file '" + dfile.getAbsolutePath() + "'!"); - } - } - - return 0; - } - - /** * Find and return the type-structure (<code>CFArchType</code>) that * matches for the given arch. This is not only a comparison between * type numbers - special type-attributes must also be dealt with. @@ -691,25 +439,4 @@ return type; } - /** FileFilter to accept only known CF spellist files. */ - static class SpellFileFilter extends FileFilter { - - SpellFileFilter() { - } - - /** - * The description of this filter. For example: "JPG and GIF Images" - * @return filter description - */ - @Override public String getDescription() { - return "spellist.h"; - } - - /** {@inheritDoc} */ - @Override public boolean accept(final File f) { - return f.isDirectory() || f.getName().equalsIgnoreCase("spellist.h"); - } - - } // class SpellFileFilter - } // class CFArchTypeList Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-15 23:24:28 UTC (rev 1092) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-15 23:54:10 UTC (rev 1093) @@ -284,7 +284,7 @@ /** Collect Spells. */ @ActionMethod public void collectSpells() { - getTypeList().importSpellsWanted(this); + Spells.importSpellsWanted(this); } /** View Treasure Lists. */ Added: trunk/crossfire/src/cfeditor/Spells.java =================================================================== --- trunk/crossfire/src/cfeditor/Spells.java (rev 0) +++ trunk/crossfire/src/cfeditor/Spells.java 2006-12-15 23:54:10 UTC (rev 1093) @@ -0,0 +1,327 @@ +/* + * Daimonin Java Editor. + * Copyright (C) 2006 Christian Hujer + * + * 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; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.EOFException; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import javax.swing.JFileChooser; +import javax.swing.filechooser.FileFilter; +import net.sf.gridarta.io.IOUtils; +import net.sf.japi.swing.ActionFactory; +import org.apache.log4j.Logger; +import org.jdom.DataConversionException; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; + +/** + * This class manages the spells and spell lists. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @todo move spell related stuff from CFArchTypeList to this class. + */ +public final class Spells { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + + private static final Logger log = Logger.getLogger(CFArchTypeList.class); + + private String[] spellNames; // array of spell names (these all begin with a ' ' space!) + + private int[] spellNumbers; // array of spell numbers + + /** + * Opens a file chooser to select the spellist file, + * then import spells. + * @param mainControl main control + */ + public static void importSpellsWanted(final CMainControl mainControl) { + // open a file chooser window + final JFileChooser fileChooser = new JFileChooser(); + fileChooser.setDialogTitle("Open CF Spellist File"); + fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + fileChooser.setMultiSelectionEnabled(false); + fileChooser.setFileFilter(new SpellFileFilter()); // apply file filter + fileChooser.setCurrentDirectory(new File(System.getProperty("user.dir"))); + + final int returnVal = fileChooser.showOpenDialog(mainControl.getMainView()); + + if (returnVal == JFileChooser.APPROVE_OPTION) { + // now import spells from selected file + final File spellfile = fileChooser.getSelectedFile(); + final int spnum = importSpells(spellfile); + if (spnum > 0) { + // yeah it worked + mainControl.showMessage("Collect Spells", + "Successfully collected " + spnum + " spells."); + } else { + // spell collect failed + mainControl.showMessage("Collect Spells", + "Collecting spells failed!\n" + + "Maybe the specified file is of wrong format."); + } + } + } + + /** + * Read all spells from a CF spellist file and write an + * alphabetical list into "spells.def" + * @param spellfile spellfile to read + * @return number of successfully collected spells + */ + private static int importSpells(final File spellfile) { + List<String> list = null; // growable array of spellnames+numbers + String tmp; // tmp String for spell names + + final FileWriter fileWriter; // file writer for "spells.def" + final BufferedWriter bufferedWriter; // buffered writer + + if (spellfile.getName().equalsIgnoreCase("spellist.h")) { + list = new ArrayList<String>(); + FileReader fileReader = null; + BufferedReader bufferedReader = null; + + try { + fileReader = new FileReader(spellfile.getAbsolutePath()); + bufferedReader = new BufferedReader(fileReader); + + IOUtils.readUntil(bufferedReader, "spell spells", null); + IOUtils.readUntil(bufferedReader, "{", null); + + // reading spellnames one after the other, + // this loop is terminated by an EOFException + int i; // index for insertion in the vector + for (int counter = 0; true; counter++) { + IOUtils.readUntil(bufferedReader, "{", "}"); + IOUtils.readUntil(bufferedReader, "\"", null); + String name = IOUtils.readUntil(bufferedReader, "\""); + IOUtils.readUntil(bufferedReader, "}", null); + + name = name.trim(); + // now insert this string lexographically into the vector + for (i = 0; i < list.size(); i++) { + tmp = list.get(i); + tmp = tmp.substring(tmp.indexOf(" ") + 1); + + if (name.compareTo(tmp) < 0) { + // everything okay, now insert + list.add(i, counter + " " + name); + i = list.size() + 10; // end for + } else if (name.compareTo(tmp) == 0) { + // this spell already exist in the list + i = list.size() + 10; // end for + counter--; // next loop with same counter value + } + } + + // if no insertion spot found, add to end of list + if (i < list.size() + 10) { + list.add(counter + " " + name); + } + } + } catch (final FileNotFoundException e) { + log.error("File '" + spellfile.getAbsolutePath() + "' not found!"); + } catch (final EOFException e) { + // end of file/spell struct reached + try { + fileReader.close(); + bufferedReader.close(); + } catch (final IOException ioe) { + } + } catch (final IOException e) { + log.error("Cannot read file '" + spellfile.getAbsolutePath() + "'!"); + } + } + + // --------- now write the "spells.def" file --------- + if (list != null && list.size() > 0) { + File dfile = null; + try { + // create new file for writing (replaces old one if existent) + if (IGUIConstants.CONFIG_DIR != null && IGUIConstants.CONFIG_DIR.length() > 0) { + final File dir = new File(IGUIConstants.CONFIG_DIR); + if (!dir.exists() || !dir.isDirectory()) { + // create the config dir + new File("resource").mkdir(); + new File(IGUIConstants.CONFIG_DIR).mkdir(); + } + + dfile = new File(IGUIConstants.CONFIG_DIR + File.separator + IGUIConstants.SPELL_FILE); + } else { + dfile = new File(IGUIConstants.SPELL_FILE); + } + + fileWriter = new FileWriter(dfile); + bufferedWriter = new BufferedWriter(fileWriter); + + // header: + bufferedWriter.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"); + bufferedWriter.write("<spells>\n<!--\n"); + bufferedWriter.write(" ##########################################################\n"); + bufferedWriter.write(" # You may add new spells to this file, but there's no #\n"); + bufferedWriter.write(" # need to do it because the file can be autogenerated. #\n"); + bufferedWriter.write(" # In the editor, select menu \"Resources->Collect Spells\" #\n"); + bufferedWriter.write(" # to generate a new version of this file. #\n"); + bufferedWriter.write(" ##########################################################\n-->\n"); + + // write spell-entries: + for (final String entry : list) { + tmp = String.valueOf(entry); + final String id = tmp.substring(0, tmp.indexOf(" ")).trim(); + final String name = tmp.substring(tmp.indexOf(" ") + 1).trim(); + String space = ""; + if (id.length() == 1) { + space = " "; + } else if (id.length() == 2) { + space = " "; + } + bufferedWriter.write(" <spell id=\"" + id + "\"" + space + " name=\"" + name + "\" />\n"); + } + bufferedWriter.write("</spells>"); + + bufferedWriter.close(); + fileWriter.close(); + return list.size(); + } catch (final IOException e) { + log.error("Cannot write file '" + dfile.getAbsolutePath() + "'!"); + } + } + + return 0; + } + + /** + * Read the spells from "spells.xml" into the arrays 'spellNames' + * and 'spellNumbers'. This method is called at startup + */ + public void loadSpellsFromXML() { + spellNames = null; + spellNumbers = null; + + try { + // open reading stream to the spells xml file + final String baseDir = IGUIConstants.CONFIG_DIR; + final BufferedReader reader = IOUtils.createReader(baseDir, IGUIConstants.SPELL_FILE); + try { + // parse xml document + final SAXBuilder builder = new SAXBuilder(); + final Document doc = builder.build(reader); + + // retrieve the spell data from the xml + final Element root = doc.getRootElement(); + Element spellElem; + if (root == null || !root.getName().equalsIgnoreCase("spells")) { + log.warn("File '" + IGUIConstants.SPELL_FILE + "' lacks root element 'spells'."); + } else { + final List spells = root.getChildren("spell"); + if (spells == null || spells.size() == 0) { + log.warn("File '" + IGUIConstants.SPELL_FILE + "' has no content."); + } else { + // initialize array with appropriate size + spellNames = new String[spells.size() + 1]; + spellNumbers = new int[spells.size() + 1]; + + // first element is <none> + spellNames[0] = " <none>"; + spellNumbers[0] = -1; + + int i; + int j; + for (j = 0, i = 1; j < spells.size(); j++) { + spellElem = (Element) spells.get(j); + + if (spellElem.getAttribute("id") == null) { + log.warn("In File '" + IGUIConstants.SPELL_FILE + "': Found 'spell' element without 'id'"); + } else if (spellElem.getAttribute("name") == null) { + log.warn("In File '" + IGUIConstants.SPELL_FILE + "': Found 'spell' element without 'name'"); + } else { + try { + // parse spell number and -name + spellNumbers[i] = spellElem.getAttribute("id").getIntValue(); + spellNames[i] = spellElem.getAttribute("name").getValue().trim(); + i++; + } catch (final DataConversionException de) { + log.error("in '" + IGUIConstants.SPELL_FILE + "': spell id '" + spellElem.getAttribute("id").getValue() + "' is not an integer."); + } + } + } + + // loading successful + i--; + if (log.isInfoEnabled()) { + if (i == spells.size()) { + log.info("Loaded " + i + " spells from '" + IGUIConstants.SPELL_FILE + "'"); + } else { + log.info("Loaded " + i + " of " + spells.size() + " defined spells from '" + IGUIConstants.SPELL_FILE + "'"); + } + } + } + } + } finally { + reader.close(); + } + } catch (final JDOMException e) { + log.error("Parsing error in '" + IGUIConstants.SPELL_FILE + "'", e); + } catch (final IOException e) { + log.error("Cannot read file '" + IGUIConstants.SPELL_FILE + "'!"); + } + } + + public String[] getSpellNames() { + return spellNames; + } + + public int[] getSpellNumbers() { + return spellNumbers; + } + + /** FileFilter to accept only known CF spellist files. */ + static class SpellFileFilter extends FileFilter { + + SpellFileFilter() { + } + + /** + * The description of this filter. For example: "JPG and GIF Images" + * @return filter description + */ + @Override public String getDescription() { + return "spellist.h"; + } + + /** {@inheritDoc} */ + @Override public boolean accept(final File f) { + return f.isDirectory() || f.getName().equalsIgnoreCase("spellist.h"); + } + + } // class SpellFileFilter + +} // class Spells Property changes on: trunk/crossfire/src/cfeditor/Spells.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-16 00:05:21
|
Revision: 1095 http://svn.sourceforge.net/gridarta/?rev=1095&view=rev Author: akirschbaum Date: 2006-12-15 16:05:22 -0800 (Fri, 15 Dec 2006) Log Message: ----------- Use ActionFactory for text messages. Modified Paths: -------------- trunk/crossfire/src/cfeditor/Spells.java trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties Modified: trunk/crossfire/src/cfeditor/Spells.java =================================================================== --- trunk/crossfire/src/cfeditor/Spells.java 2006-12-15 23:59:59 UTC (rev 1094) +++ trunk/crossfire/src/cfeditor/Spells.java 2006-12-16 00:05:22 UTC (rev 1095) @@ -84,13 +84,10 @@ final int spnum = importSpells(spellfile); if (spnum > 0) { // yeah it worked - mainControl.showMessage("Collect Spells", - "Successfully collected " + spnum + " spells."); + ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "importSpellsSuccess", spnum); } else { // spell collect failed - mainControl.showMessage("Collect Spells", - "Collecting spells failed!\n" + - "Maybe the specified file is of wrong format."); + ACTION_FACTORY.showMessageDialog(mainControl.getMainView(), "importSpellsFailed"); } } } Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2006-12-15 23:59:59 UTC (rev 1094) +++ trunk/crossfire/src/cfeditor/messages.properties 2006-12-16 00:05:22 UTC (rev 1095) @@ -28,6 +28,11 @@ enterExitNotSaved.title=Map not saved enterExitNotSaved.message=You must save the map first to follow a relative path. +importSpellsSuccess.title=Collect spells +importSpellsSuccess.message=Successfully collected {0} spells. +importSpellsFailed.title=Collect spells +importSpellsFailed.message=Collecting spells failed!\nMaybe the specified file is of wrong format. + openScriptNotFound.title=Script file not found openScriptNotFound.message=The file ''{0}'' does not exist.\nPlease correct the path. Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2006-12-15 23:59:59 UTC (rev 1094) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2006-12-16 00:05:22 UTC (rev 1095) @@ -66,6 +66,11 @@ enterExitNotSaved.title=Karte nicht gesichert enterExitNotSaved.message=Der Ausgang verwendet einen relativen Dateinamen. Um ihm zu folgen m\xFCssen Sie die Karte vorher sichern. +importSpellsSuccess.title=Zauberspr\xFCche sammeln +importSpellsSuccess.message={0} Zauberspr\xFCche geladen. +importSpellsFailed.title=Zauberspr\xFCche sammeln +importSpellsFailed.message=Das Sammeln der Zauberspr\xFCche ist fehlgeschlagen.\nEvtl. ist das Dateiformat falsch? + openScriptNotFound.title=Script-Datei nicht gefunden openScriptNotFound.message=Die Datei ''{0}'' existiert nicht.\nBitte geben sie einen g\xFCltigen Dateinamen an. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-16 01:06:08
|
Revision: 1104 http://svn.sourceforge.net/gridarta/?rev=1104&view=rev Author: akirschbaum Date: 2006-12-15 17:06:08 -0800 (Fri, 15 Dec 2006) Log Message: ----------- Correct message files. Modified Paths: -------------- trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2006-12-16 00:59:42 UTC (rev 1103) +++ trunk/crossfire/src/cfeditor/messages.properties 2006-12-16 01:06:08 UTC (rev 1104) @@ -67,7 +67,6 @@ # Options optionsImageSet=Image Set -optionsImageSet.shortdescription=The image set to use ####### # File Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2006-12-16 00:59:42 UTC (rev 1103) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2006-12-16 01:06:08 UTC (rev 1104) @@ -132,7 +132,7 @@ mapDarkness=Dunkelheit mapSwapTime=Swap-Zeit mapNosmooth=Ohne Bild\xFCberg\xE4ng -#mapUnique=??? +mapUnique=Permanente Karte mapResetTimeout=Reset-Zeit mapNorth=Norden mapEast=Osten @@ -162,7 +162,7 @@ mapHumidity=Luftfeuchte mapPressure=Luftdruck -#mapSkySetting=??? +mapSkySetting=Wetterbedingung mapTemperature=Temperatur mapWindDirection=Windrichtung mapWindSpeed=Windgeschwindigkeit @@ -236,6 +236,19 @@ statusNormal=Cursor x:{0,number,integer} y:{1,number,integer} statusCursorOff=Maus nicht auf Karte +# Edit +undo.text=R\xFCckg\xE4ngig +undo.shortdescription=Letze Aktion zur\xFCcknehmen +undo.longdescription=Nimmt die letzte durchgef\xFChrte Aktion zur\xFCck. +undo.mnemonic=R +undo.accel=ctrl pressed Z + +redo.text=Wiederholen +redo.shortdescription=Letze Aktion wiederholen +redo.longdescription=Wiederholt die letzte durchgef\xFChrte Aktion. +redo.mnemonic=W +redo.accel=ctrl pressed Y + ################# # Map Arch Panel @@ -277,7 +290,6 @@ optionsResScripts=Skripte optionsResScripts.shortdescription=Verzeichnis f\xFCr Scripte optionsImageSet=Image Set -optionsImageSet.shortdescription=Verwendetes Image Set zur Darstellung von Karten optionsRestart.title=Warnung optionsRestart.message=Viele Optionen erfordern einen Programmneustart, um effektiv zu werden. @@ -562,7 +574,7 @@ onlineHelp.accel=F1 about.text=\xDCber... -#about.mnemonic=\xDC +about.mnemonic=B ############ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-16 11:16:17
|
Revision: 1107 http://svn.sourceforge.net/gridarta/?rev=1107&view=rev Author: akirschbaum Date: 2006-12-16 03:16:16 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Use MapGrid for DefaultLevelRenderer. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-16 10:43:28 UTC (rev 1106) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-16 11:16:16 UTC (rev 1107) @@ -27,7 +27,6 @@ import cfeditor.gameobject.GameObject; import cfeditor.gui.MapView; import cfeditor.gui.map.DefaultLevelRenderer; -import cfeditor.gui.map.LevelRenderer; import cfeditor.map.MapControl; import cfeditor.map.MapModel; import java.awt.Dimension; @@ -46,6 +45,7 @@ import javax.swing.ScrollPaneConstants; import net.sf.gridarta.EditOperation; import net.sf.gridarta.Size2D; +import net.sf.gridarta.gui.map.MapGrid; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; @@ -86,7 +86,7 @@ private Size2D mapSize = new Size2D(1, 1); /** The tile palette renderer. */ - private final LevelRenderer renderer; + private final DefaultLevelRenderer renderer; private boolean changed = false; @@ -103,6 +103,8 @@ private final boolean[] needMpanelUpdate; // indicates that the mapArchPanel needs + private MapGrid mapGrid; + // interface for the mapview frame private final MapView frame; @@ -119,6 +121,7 @@ super(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); this.mapControl = mapControl; this.mainControl = mainControl; + mapGrid = new MapGrid(mapControl.getMapModel().getMapSize()); frame = fi; highlightOn = false; @@ -136,7 +139,7 @@ if (isPickmap()) { setBackground(IGUIConstants.BG_COLOR); } - renderer = new DefaultLevelRenderer(this, mainControl, mapControl, isPickmap()); + renderer = new DefaultLevelRenderer(this, mainControl, mapControl, isPickmap(), mapGrid); setViewportView(renderer); getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); @@ -157,6 +160,7 @@ renderer.addMouseMotionListener(mainControl.getMainView().getStatusBar()); } renderer.updateLookAndFeel(); + mapGrid.addMapGridListener(renderer); } public boolean isChanged() { Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-16 10:43:28 UTC (rev 1106) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-16 11:16:16 UTC (rev 1107) @@ -49,6 +49,9 @@ import javax.swing.ImageIcon; import javax.swing.JComponent; import net.sf.gridarta.Size2D; +import net.sf.gridarta.gui.map.MapGrid; +import net.sf.gridarta.gui.map.MapGridEvent; +import net.sf.gridarta.gui.map.MapGridListener; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -58,7 +61,7 @@ * Flat version. * @author unknown (probably Ragnor) */ -public final class DefaultLevelRenderer extends LevelRenderer { +public final class DefaultLevelRenderer extends LevelRenderer implements MapGridListener { private static final Logger log = Logger.getLogger(DefaultLevelRenderer.class); @@ -97,17 +100,24 @@ private final AffineTransform renderTransform; + private Size2D mapSize = new Size2D(1, 1); + + private final MapGrid mapGrid; + /** * Creates a DefaultLevelRenderer. * @param mapViewBasic MapView to render. * @param mainControl MainControl, used for getting icons and similar. * @param mapControl MapControl of the map to render. * @param pickmap <code>true</code> if the rendered map is a pickmap, otherwise <code>false</code> + * @param mapGrid Grid to render. */ - public DefaultLevelRenderer(final CMapViewBasic mapViewBasic, final CMainControl mainControl, final MapControl mapControl, final boolean pickmap) { + public DefaultLevelRenderer(final CMapViewBasic mapViewBasic, final CMainControl mainControl, final MapControl mapControl, final boolean pickmap, final MapGrid mapGrid) { this.mapViewBasic = mapViewBasic; this.mainControl = mainControl; this.mapControl = mapControl; + mapSize = mapControl.getMapModel().getMapSize(); + this.mapGrid = mapGrid; final AttributeFilter af = new AttributeFilter(); af.addAttribute("no_pass", "1"); @@ -219,8 +229,8 @@ // this vector contains all heads of multi-tiles with oversized images final Vector<GameObject> oversizedMultiHeads = new Vector<GameObject>(); final CFilterControl filter = mainControl.getFilterControl(); - for (int y = 0; y < mapViewBasic.getMapSize().getHeight(); y++) { - for (int x = 0; x < mapViewBasic.getMapSize().getWidth(); x++) { + for (int y = 0; y < mapGrid.getSize().getHeight(); y++) { + for (int x = 0; x < mapGrid.getSize().getWidth(); x++) { filter.newSquare(); if (!mapControl.getMapModel().containsArchObject(new Point(x, y))) { // empty square @@ -276,18 +286,18 @@ // grid lines if (mapViewBasic.isGridVisible() && !isSnapshot) { - for (int x = 0; x <= mapViewBasic.getMapSize().getWidth(); x++) { + for (int x = 0; x <= mapGrid.getSize().getWidth(); x++) { grfx.drawLine( x * 32 + borderOffset, borderOffset, x * 32 + borderOffset, - mapViewBasic.getMapSize().getHeight() * 32 + borderOffset); + mapGrid.getSize().getHeight() * 32 + borderOffset); } - for (int y = 0; y <= mapViewBasic.getMapSize().getHeight(); y++) { + for (int y = 0; y <= mapGrid.getSize().getHeight(); y++) { grfx.drawLine( borderOffset, y * 32 + borderOffset, - mapViewBasic.getMapSize().getWidth() * 32 + borderOffset, + mapGrid.getSize().getWidth() * 32 + borderOffset, y * 32 + borderOffset); } } @@ -487,6 +497,17 @@ return new Point(xm, ym); } + /** {@inheritDoc} */ + public void mapGridChanged(@NotNull final MapGridEvent e) { + repaint(); + } + + /** {@inheritDoc} */ + public void mapGridResized(@NotNull final MapGridEvent e) { + mapSize = e.getSource().getSize(); + repaint(); + } + @Override public boolean resizeBackBuffer() { if (isPickmap) { return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-16 11:46:08
|
Revision: 1108 http://svn.sourceforge.net/gridarta/?rev=1108&view=rev Author: akirschbaum Date: 2006-12-16 03:46:07 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Move functions to MapControl. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/crossfire/src/cfeditor/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-16 11:16:16 UTC (rev 1107) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-16 11:46:07 UTC (rev 1108) @@ -348,73 +348,6 @@ } /** - * Determine which map-squares need to be redrawn after inserting/deleting - * the given GameObject. - * @param gameObject the gameObject that is inserted or deleted - * @return a <code>Point</code> array containing the coords of the tiles - * which need to be redrawn - */ - @Nullable Point[] calcArchRedraw(GameObject gameObject) { - if (gameObject == null) { // safety check - return null; - } - - final Point[] redraw; // return value (coords needing redraw) - - if (mainControl.isAutoJoin() && gameObject.getArchetype().getJoinList() != null) { - // this gameObject does autojoining: - - // first look how many we need - int num = 1; - if (mapControl.isPointValid(new Point(gameObject.getMapX() + 1, gameObject.getMapY()))) { - num++; - } - if (mapControl.isPointValid(new Point(gameObject.getMapX(), gameObject.getMapY() + 1))) { - num++; - } - if (mapControl.isPointValid(new Point(gameObject.getMapX() - 1, gameObject.getMapY()))) { - num++; - } - if (mapControl.isPointValid(new Point(gameObject.getMapX(), gameObject.getMapY() - 1))) { - num++; - } - - // now get the coordinates - redraw = new Point[num]; // create instance of needed size - redraw[--num] = new Point(gameObject.getMapX(), gameObject.getMapY()); // center square - if (mapControl.isPointValid(new Point(gameObject.getMapX() + 1, gameObject.getMapY()))) { - redraw[--num] = new Point(gameObject.getMapX() + 1, gameObject.getMapY()); - } - if (mapControl.isPointValid(new Point(gameObject.getMapX(), gameObject.getMapY() + 1))) { - redraw[--num] = new Point(gameObject.getMapX(), gameObject.getMapY() + 1); - } - if (mapControl.isPointValid(new Point(gameObject.getMapX() - 1, gameObject.getMapY()))) { - redraw[--num] = new Point(gameObject.getMapX() - 1, gameObject.getMapY()); - } - if (mapControl.isPointValid(new Point(gameObject.getMapX(), gameObject.getMapY() - 1))) { - redraw[--num] = new Point(gameObject.getMapX(), gameObject.getMapY() - 1); - } - assert num == 0; - } else if (gameObject.isMulti()) { - gameObject = gameObject.getHead(); // make sure we got the head - - int num = gameObject.getMultiRefCount(); // get number of parts - redraw = new Point[num]; // create instance of needed size - for (GameObject tmp = gameObject; num > 0 && tmp != null; - num--, tmp = tmp.getMultiNext()) { - redraw[num - 1] = new Point(tmp.getMapX(), tmp.getMapY()); - } - assert num == 0; - } else { - // just an ordinary single-square gameObject - redraw = new Point[1]; - redraw[0] = new Point(gameObject.getMapX(), gameObject.getMapY()); - } - - return redraw; - } - - /** * Determine which map-squares need to be painted if the given rectangle is * to be redrawn. * @param ax map x-coords. of first corner of the rect @@ -642,7 +575,7 @@ if (temp.x == -1 || temp.y == -1) { mainControl.getMainView().setMapTileList(null, null); } else { - needRedraw = insertSelArchToMap(temp, false); + needRedraw = mapControl.insertSelArchToMap(temp, false); needMpanelUpdate[2] = true; // when dragging is done, update map panel } } @@ -669,7 +602,7 @@ } } if (tmpArch != null) { - needRedraw = calcArchRedraw(tmpArch); // get redraw info + needRedraw = mapControl.calcArchRedraw(tmpArch); // get redraw info mapControl.deleteMapArch(tmpArch, temp, false, MapModel.JOIN_ENABLE); } @@ -704,7 +637,7 @@ mapMouseRightPos.x = mapLoc.x; mapMouseRightPos.y = mapLoc.y; - needRedraw = insertSelArchToMap(mapLoc, true); + needRedraw = mapControl.insertSelArchToMap(mapLoc, true); // get name of inserted arch (this is display in status bar while dragging) @Nullable final GameObject insArch = mainControl.getArchPanelHighlight(); @@ -790,7 +723,7 @@ } } if (tmpArch != null) { - needRedraw = calcArchRedraw(tmpArch); // get redraw info + needRedraw = mapControl.calcArchRedraw(tmpArch); // get redraw info mapControl.deleteMapArch(tmpArch, mapLoc, false, MapModel.JOIN_ENABLE); // update mapArch panel @@ -800,81 +733,6 @@ } /** - * Take the currently selected arch (from archlist or pickmap) and - * insert it to the defined spot on the currently active map. Redraw - * info is stored to 'needRedraw', no views get redrawn/updated here. - * @param pos tile-coordinates in map - * @param allowMany when true, it is possible to insert same arches - * many times. when false, only one arch of a kind can be inserted - * @return array of coordinates for tiles that need to be redrawn - */ - private Point[] insertSelArchToMap(final Point pos, final boolean allowMany) { - Point[] needRedraw = null; // returned array of points which need redraw - - // this is the arch that would get inserted from pickmap, but it also could - // be a default arch (when pickmap has no selection) - GameObject newarch = mainControl.getArchPanelHighlight(); - - if (!mainControl.getMainView().isPickmapActive() || mapControl.isPickmap() || (newarch != null && newarch.isArchetype())) { - // insert default arch from archlist: - if (!mapControl.addArchToMap(mainControl.getPanelArchName(), pos, allowMany, MapModel.JOIN_ENABLE)) { - // mainControl.getMainView().mapPanel.setMapArchList(null); - // Toolkit.getDefaultToolkit().beep(); - } else { - // insertion successful, now get redraw info - newarch = mapControl.getTopArchObject(pos); - if (newarch != null) { - // now we've got the inserted arch - needRedraw = calcArchRedraw(newarch); - } - } - } else { - // insert custom arch from the pickmap: - if (newarch != null) { - boolean insertAllowed = true; // are we allowed to insert this? - if (!allowMany) { - // check if there is already an arch of that kind - for (final GameObject t : mapControl.getMapModel().getMapSquare(pos)) { - if (t.getArchetypeName().equals(newarch.getArchetypeName()) && t.getArchTypNr() == newarch.getArchTypNr()) { - insertAllowed = false; // there's a match - don't insert a second one - } - } - } - - if (insertAllowed) { - if (!newarch.isMulti()) { - // insert single tile from pickmap - newarch = newarch.createClone(pos.x, pos.y); - mapControl.addArchObjectToMap(newarch); - needRedraw = calcArchRedraw(newarch); - } else { - // insert multi tile from pickmap: - newarch = newarch.getHead(); - // first insert default arch from archlist - if (!mapControl.addArchToMap(newarch.getArchetypeName(), pos, allowMany, MapModel.JOIN_DISABLE)) { - // do nothing - } else { - // insertion successful, now get redraw info - final GameObject newdef = mapControl.getTopArchObject(pos); // new inserted default arch - if (newdef != null) { - // now we've got the inserted arch, copy the custom stuff from pickmap - newdef.setObjectText(newarch.getObjectText()); - newdef.setObjName(newarch.getObjName()); - newdef.resetMsgText(); - newdef.addMsgText(newarch.getMsgText()); - - needRedraw = calcArchRedraw(newdef); - } - } - } - } - } - } - - return needRedraw; - } - - /** * This method is only called for pickmaps. Take the currently * highlighted arch on the map (if any) and insert it on this pickmap. * Redraw info is stored to 'needRedraw', no views get redrawn/updated @@ -895,7 +753,7 @@ // insert single tile from pickmap newarch = newarch.createClone(pos.x, pos.y); mapControl.addArchObjectToMap(newarch); - needRedraw = calcArchRedraw(newarch); + needRedraw = mapControl.calcArchRedraw(newarch); } else { // insert multi tile from pickmap: newarch = newarch.getHead(); @@ -924,7 +782,7 @@ newdef.resetMsgText(); newdef.addMsgText(newarch.getMsgText()); - needRedraw = calcArchRedraw(newdef); + needRedraw = mapControl.calcArchRedraw(newdef); } } } Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-16 11:16:16 UTC (rev 1107) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-16 11:46:07 UTC (rev 1108) @@ -194,10 +194,6 @@ view.setMapAndArchPosition(gameObject, pos); } - Point[] calcArchRedraw(final GameObject arch) { - return view.calcArchRedraw(arch); - } - Point[] calcRectRedraw(final int ax, final int ay, final int bx, final int by) { return view.calcRectRedraw(ax, ay, bx, by); } Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-16 11:16:16 UTC (rev 1107) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-16 11:46:07 UTC (rev 1108) @@ -34,6 +34,7 @@ import java.util.List; import net.sf.gridarta.Size2D; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The <code>MapControl</code>. @@ -277,6 +278,148 @@ } /** + * Take the currently selected arch (from archlist or pickmap) and + * insert it to the defined spot on the currently active map. Redraw + * info is stored to 'needRedraw', no views get redrawn/updated here. + * @param pos tile-coordinates in map + * @param allowMany when true, it is possible to insert same arches + * many times. when false, only one arch of a kind can be inserted + * @return array of coordinates for tiles that need to be redrawn + */ + public Point[] insertSelArchToMap(final Point pos, final boolean allowMany) { + Point[] needRedraw = null; // returned array of points which need redraw + + // this is the arch that would get inserted from pickmap, but it also could + // be a default arch (when pickmap has no selection) + GameObject newarch = mainControl.getArchPanelHighlight(); + + if (!mainControl.getMainView().isPickmapActive() || isPickmap() || (newarch != null && newarch.isArchetype())) { + // insert default arch from archlist: + if (!addArchToMap(mainControl.getPanelArchName(), pos, allowMany, MapModel.JOIN_ENABLE)) { + // mainControl.getMainView().mapPanel.setMapArchList(null); + // Toolkit.getDefaultToolkit().beep(); + } else { + // insertion successful, now get redraw info + newarch = getTopArchObject(pos); + if (newarch != null) { + // now we've got the inserted arch + needRedraw = calcArchRedraw(newarch); + } + } + } else { + // insert custom arch from the pickmap: + if (newarch != null) { + boolean insertAllowed = true; // are we allowed to insert this? + if (!allowMany) { + // check if there is already an arch of that kind + for (final GameObject t : getMapModel().getMapSquare(pos)) { + if (t.getArchetypeName().equals(newarch.getArchetypeName()) && t.getArchTypNr() == newarch.getArchTypNr()) { + insertAllowed = false; // there's a match - don't insert a second one + } + } + } + + if (insertAllowed) { + if (!newarch.isMulti()) { + // insert single tile from pickmap + newarch = newarch.createClone(pos.x, pos.y); + addArchObjectToMap(newarch); + needRedraw = calcArchRedraw(newarch); + } else { + // insert multi tile from pickmap: + newarch = newarch.getHead(); + // first insert default arch from archlist + if (!addArchToMap(newarch.getArchetypeName(), pos, allowMany, MapModel.JOIN_DISABLE)) { + // do nothing + } else { + // insertion successful, now get redraw info + final GameObject newdef = getTopArchObject(pos); // new inserted default arch + if (newdef != null) { + // now we've got the inserted arch, copy the custom stuff from pickmap + newdef.setObjectText(newarch.getObjectText()); + newdef.setObjName(newarch.getObjName()); + newdef.resetMsgText(); + newdef.addMsgText(newarch.getMsgText()); + + needRedraw = calcArchRedraw(newdef); + } + } + } + } + } + } + + return needRedraw; + } + + /** + * Determine which map-squares need to be redrawn after inserting/deleting + * the given GameObject. + * @param gameObject the gameObject that is inserted or deleted + * @return a <code>Point</code> array containing the coords of the tiles + * which need to be redrawn + */ + @Nullable public Point[] calcArchRedraw(GameObject gameObject) { + if (gameObject == null) { // safety check + return null; + } + + final Point[] redraw; // return value (coords needing redraw) + + if (mainControl.isAutoJoin() && gameObject.getArchetype().getJoinList() != null) { + // this gameObject does autojoining: + + // first look how many we need + int num = 1; + if (isPointValid(new Point(gameObject.getMapX() + 1, gameObject.getMapY()))) { + num++; + } + if (isPointValid(new Point(gameObject.getMapX(), gameObject.getMapY() + 1))) { + num++; + } + if (isPointValid(new Point(gameObject.getMapX() - 1, gameObject.getMapY()))) { + num++; + } + if (isPointValid(new Point(gameObject.getMapX(), gameObject.getMapY() - 1))) { + num++; + } + + // now get the coordinates + redraw = new Point[num]; // create instance of needed size + redraw[--num] = new Point(gameObject.getMapX(), gameObject.getMapY()); // center square + if (isPointValid(new Point(gameObject.getMapX() + 1, gameObject.getMapY()))) { + redraw[--num] = new Point(gameObject.getMapX() + 1, gameObject.getMapY()); + } + if (isPointValid(new Point(gameObject.getMapX(), gameObject.getMapY() + 1))) { + redraw[--num] = new Point(gameObject.getMapX(), gameObject.getMapY() + 1); + } + if (isPointValid(new Point(gameObject.getMapX() - 1, gameObject.getMapY()))) { + redraw[--num] = new Point(gameObject.getMapX() - 1, gameObject.getMapY()); + } + if (isPointValid(new Point(gameObject.getMapX(), gameObject.getMapY() - 1))) { + redraw[--num] = new Point(gameObject.getMapX(), gameObject.getMapY() - 1); + } + assert num == 0; + } else if (gameObject.isMulti()) { + gameObject = gameObject.getHead(); // make sure we got the head + + int num = gameObject.getMultiRefCount(); // get number of parts + redraw = new Point[num]; // create instance of needed size + for (GameObject tmp = gameObject; num > 0 && tmp != null; + num--, tmp = tmp.getMultiNext()) { + redraw[num - 1] = new Point(tmp.getMapX(), tmp.getMapY()); + } + assert num == 0; + } else { + // just an ordinary single-square gameObject + redraw = new Point[1]; + redraw[0] = new Point(gameObject.getMapX(), gameObject.getMapY()); + } + + return redraw; + } + + /** * Repaints the view. */ public void repaint() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 15:05:06
|
Revision: 1141 http://svn.sourceforge.net/gridarta/?rev=1141&view=rev Author: akirschbaum Date: 2006-12-17 07:05:02 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Remove explicit map redraw. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapTileList.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/crossfire/src/cfeditor/map/MapModel.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-17 14:58:15 UTC (rev 1140) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-17 15:05:02 UTC (rev 1141) @@ -563,8 +563,8 @@ return currentMap.insertArchToMap(newarch, archname, next, pos, join); } - public void deleteMapArch(final GameObject gameObject, final Point pos, final boolean refreshMap, final boolean join) { - currentMap.deleteMapArch(gameObject, pos, refreshMap, join); + public void deleteMapArch(final GameObject gameObject, final Point pos, final boolean join) { + currentMap.deleteMapArch(gameObject, pos, join); } public GameObject getMapArch(final GameObject gameObject, final Point pos) { Modified: trunk/crossfire/src/cfeditor/CMapTileList.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-17 14:58:15 UTC (rev 1140) +++ trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-17 15:05:02 UTC (rev 1141) @@ -211,7 +211,9 @@ // --- middle mouse button: delete arch --- final int listIndex = getListIndex(e); if (listIndex < list.getModel().getSize()) { + mainControl.getCurrentMap().getMapModel().beginTransaction("Delete"); // TODO; I18N/L10N deleteIndexFromList(listIndex); + mainControl.getCurrentMap().getMapModel().endTransaction(); } } } @@ -275,7 +277,7 @@ final GameObject temp = getMapTileSelection(); final GameObject entry = (GameObject) model.getElementAt(index); if (entry != null) { - mainControl.deleteMapArch(entry, currentSquare, true, MapModel.JOIN_ENABLE); + mainControl.deleteMapArch(entry, currentSquare, MapModel.JOIN_ENABLE); setMapTileList(mainControl.getCurrentMap(), temp); } } Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 14:58:15 UTC (rev 1140) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 15:05:02 UTC (rev 1141) @@ -628,7 +628,7 @@ } if (tmpArch != null) { mapControl.calcArchRedraw(tmpArch); // get redraw info - mapControl.deleteMapArch(tmpArch, temp, false, MapModel.JOIN_ENABLE); + mapControl.deleteMapArch(tmpArch, temp, MapModel.JOIN_ENABLE); } } } @@ -701,7 +701,7 @@ } if (tmpArch != null) { mapControl.calcArchRedraw(tmpArch); // get redraw info - mapControl.deleteMapArch(tmpArch, mapLoc, false, MapModel.JOIN_ENABLE); + mapControl.deleteMapArch(tmpArch, mapLoc, MapModel.JOIN_ENABLE); // update mapArch panel mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), null); Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-17 14:58:15 UTC (rev 1140) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-17 15:05:02 UTC (rev 1141) @@ -381,7 +381,7 @@ } /** {@inheritDoc} */ - public void deleteMapArch(final GameObject gameObject, final Point pos, final boolean refreshMap, final boolean join) { + public void deleteMapArch(final GameObject gameObject, final Point pos, final boolean join) { // first, try to find the tile we had selected for (final GameObject node : getMapSquare(pos)) { if (node == gameObject) { @@ -405,10 +405,6 @@ } } setLevelChangedFlag(); // the map has been modified - - if (refreshMap) { - mainControl.getMainView().refreshMapTileList(); - } } /** Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-17 14:58:15 UTC (rev 1140) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-17 15:05:02 UTC (rev 1141) @@ -223,8 +223,8 @@ mapModel.addGameObjectToMap(arch, false); } - public void deleteMapArch(final GameObject gameObject, final Point pos, final boolean refreshMap, final boolean join) { - mapModel.deleteMapArch(gameObject, pos, refreshMap, join); + public void deleteMapArch(final GameObject gameObject, final Point pos, final boolean join) { + mapModel.deleteMapArch(gameObject, pos, join); } public GameObject getMapArch(final GameObject gameObject, final Point pos) { Modified: trunk/crossfire/src/cfeditor/map/MapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapModel.java 2006-12-17 14:58:15 UTC (rev 1140) +++ trunk/crossfire/src/cfeditor/map/MapModel.java 2006-12-17 15:05:02 UTC (rev 1141) @@ -71,11 +71,9 @@ * inventory.) * @param gameObject the game object to remove * @param pos location of the arch to be removed - * @param refreshMap If true, mapview is redrawn after deletion. Keep in - * mind: drawing consumes time! * @param join if set to JOIN_ENABLE auto-joining is supported */ - void deleteMapArch(GameObject gameObject, Point pos, boolean refreshMap, boolean join); + void deleteMapArch(GameObject gameObject, Point pos, boolean join); /** * Get the arch from the map with the specified 'id', at location pos. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |