From: <aki...@us...> - 2006-12-03 16:08:53
|
Revision: 821 http://svn.sourceforge.net/gridarta/?rev=821&view=rev Author: akirschbaum Date: 2006-12-03 08:08:44 -0800 (Sun, 03 Dec 2006) Log Message: ----------- Remove support for Iso-Tiles. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/IGUIConstants.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java Removed Paths: ------------- trunk/crossfire/resource/system/igridtile.png trunk/crossfire/resource/system/inoarch.png trunk/crossfire/resource/system/inoface.png trunk/crossfire/resource/system/iseltile.png trunk/crossfire/resource/system/iunknown.png Deleted: trunk/crossfire/resource/system/igridtile.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/inoarch.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/inoface.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/iseltile.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/iunknown.png =================================================================== (Binary files differ) Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-03 15:56:25 UTC (rev 820) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-03 16:08:44 UTC (rev 821) @@ -123,18 +123,8 @@ private static ImageIcon nofaceTileIcon; - private static ImageIcon mapSelIconX; - - private static ImageIcon mapGridIconX; - - private static ImageIcon unknownTileIconX; - - private static ImageIcon nofaceTileIconX; - private static ImageIcon noarchTileIcon; - private static ImageIcon noarchTileIconX; - private final ArchetypeSet archetypeSet; // the one and only arch list /** All open maps. */ @@ -1631,61 +1621,31 @@ } public static ImageIcon getUnknownTileIcon() { - return unknownTileIconX; + return unknownTileIcon; } - public static ImageIcon getUnknownTileIconX() { - return unknownTileIconX; - } - public static ImageIcon getNoarchTileIcon() { - return noarchTileIconX; - } - - public static ImageIcon getNoarchTileIconF() { return noarchTileIcon; } - public static ImageIcon getNoarchTileIconX() { - return noarchTileIconX; - } - public static ImageIcon getNofaceTileIcon() { - return nofaceTileIconX; - } - - public static ImageIcon getNofaceTileIconF() { return nofaceTileIcon; } - public static ImageIcon getNofaceTileIconX() { - return nofaceTileIconX; - } - - public static ImageIcon getMapSelIconF() { + public static ImageIcon getMapSelIcon() { return mapSelIcon; } - public static ImageIcon getMapSelIconX() { - return mapSelIconX; - } - /** * Load all system tile icons into temporare variables for more convenient * access. */ private static void loadDefTiles() { - mapGridIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_IGRID_TILE); - mapSelIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_ISEL_TILE); - unknownTileIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_IUNKNOWN); - nofaceTileIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_INOFACE); - noarchTileIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_INOARCH); - - mapGridIconX = CGUIUtils.getSysIcon(IGUIConstants.TILE_GRID_TILE); - mapSelIconX = CGUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE); - unknownTileIconX = CGUIUtils.getSysIcon(IGUIConstants.TILE_UNKNOWN); - nofaceTileIconX = CGUIUtils.getSysIcon(IGUIConstants.TILE_NOFACE); - noarchTileIconX = CGUIUtils.getSysIcon(IGUIConstants.TILE_NOARCH); + mapGridIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_GRID_TILE); + mapSelIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE); + unknownTileIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_UNKNOWN); + nofaceTileIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_NOFACE); + noarchTileIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_NOARCH); } public void handleErrors(final GridderException error) { @@ -1732,7 +1692,7 @@ } public static ImageIcon getEmptyTileIcon() { - return nofaceTileIconX; + return nofaceTileIcon; } public MapControl[] getOpenedMaps() { Modified: trunk/crossfire/src/cfeditor/IGUIConstants.java =================================================================== --- trunk/crossfire/src/cfeditor/IGUIConstants.java 2006-12-03 15:56:25 UTC (rev 820) +++ trunk/crossfire/src/cfeditor/IGUIConstants.java 2006-12-03 16:08:44 UTC (rev 821) @@ -233,16 +233,6 @@ String EDIT_PLUGINS_SMALLICON = "EditPluginSmallIcon.gif"; // tile icons from the system dir: - String TILE_IGRID_TILE = "igridtile.png"; - - String TILE_ISEL_TILE = "iseltile.png"; - - String TILE_IUNKNOWN = "iunknown.png"; - - String TILE_INOFACE = "inoface.png"; - - String TILE_INOARCH = "inoarch.png"; - String TILE_GRID_TILE = "gridtile.png"; String TILE_SEL_TILE = "seltile.png"; Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-03 15:56:25 UTC (rev 820) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-03 16:08:44 UTC (rev 821) @@ -221,7 +221,7 @@ if (isPickmap) { grfx.fillRect(x * 32 + borderOffset, y * 32 + borderOffset, 32, 32); } else { - mainControl.getUnknownTileIconX().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + mainControl.getUnknownTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); } } else { for (final GameObject node : mapControl.getMapModel().getMapSquare(new Point(x, y))) { @@ -231,12 +231,12 @@ } if (mainControl.isTileEdit(node.getEditType()) || mainControl.getTileEdit() == 0 || isPickmap) { if (node.getArchetypeName() == null) { - mainControl.getNoarchTileIconX().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + mainControl.getNoarchTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); } else if (node.getFaceFlag()) { - mainControl.getNofaceTileIconX().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + mainControl.getNofaceTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); } else { if (node.getFaceNr() == -1) { - mainControl.getUnknownTileIconX().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + mainControl.getUnknownTileIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); } else { // draw object face final ImageIcon img = archlist.getFace(node.getFaceNr()); @@ -322,7 +322,7 @@ grfx.setColor(IGUIConstants.BG_COLOR); grfx.fillRect(x * 32 + borderOffset, y * 32 + borderOffset, 32, 32); } else { - mainControl.getUnknownTileIconX().paintIcon(this, grfx, x * 32, y * 32); + mainControl.getUnknownTileIcon().paintIcon(this, grfx, x * 32, y * 32); } } else { tmpGrfx.fillRect(0, 0, 32, 32); @@ -334,12 +334,12 @@ } if (mainControl.isTileEdit(node.getEditType()) || mainControl.getTileEdit() == 0) { if (node.getArchetypeName() == null) { - mainControl.getNoarchTileIconX().paintIcon(this, tmpGrfx, 0, 0); + mainControl.getNoarchTileIcon().paintIcon(this, tmpGrfx, 0, 0); } else if (node.getFaceFlag()) { - mainControl.getNofaceTileIconX().paintIcon(this, tmpGrfx, 0, 0); + mainControl.getNofaceTileIcon().paintIcon(this, tmpGrfx, 0, 0); } else { if (node.getFaceNr() == -1) { - mainControl.getUnknownTileIconX().paintIcon(this, tmpGrfx, 0, 0); + mainControl.getUnknownTileIcon().paintIcon(this, tmpGrfx, 0, 0); } else { final ImageIcon img = archlist.getFace(node.getFaceNr()); if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { @@ -410,7 +410,7 @@ // Highlight the selected square if (x >= topx && x <= botx && y >= topy && y <= boty) { - mainControl.getMapSelIconX().paintIcon(this, grfx, x * 32, y * 32); + mainControl.getMapSelIcon().paintIcon(this, grfx, x * 32, y * 32); } } } @@ -447,7 +447,7 @@ // Draw the Icon: // Rectangular view - mainControl.getMapSelIconX().paintIcon(this, grfx, posx * 32 + borderOffset, posy * 32 + borderOffset); + mainControl.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: <aki...@us...> - 2006-12-05 23:26:20
|
Revision: 920 http://svn.sourceforge.net/gridarta/?rev=920&view=rev Author: akirschbaum Date: 2006-12-05 15:26:20 -0800 (Tue, 05 Dec 2006) Log Message: ----------- Do not close treasure list selection dialog if the user selects an invalid treasure list. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CFTreasureListTree.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-05 23:22:37 UTC (rev 919) +++ trunk/crossfire/ChangeLog 2006-12-05 23:26:20 UTC (rev 920) @@ -1,3 +1,8 @@ +2006-12-06 Andreas Kirschbaum + + * Do not close treasure list selection dialog if the user selects + an invalid treasure list. + 2006-12-03 Andreas Kirschbaum * Change layout of map properties dialog. Modified: trunk/crossfire/src/cfeditor/CFTreasureListTree.java =================================================================== --- trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-05 23:22:37 UTC (rev 919) +++ trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-05 23:26:20 UTC (rev 920) @@ -581,8 +581,8 @@ final String result = getSelectedTreasureList(); if (result != null) { input.setText(" " + result); + frame.setVisible(false); } - frame.setVisible(false); } }); rightSide.add(okButton); 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:24
|
Revision: 1014 http://svn.sourceforge.net/gridarta/?rev=1014&view=rev Author: akirschbaum Date: 2006-12-10 07:28:08 -0800 (Sun, 10 Dec 2006) Log Message: ----------- Make WorldMaker script more robust. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/resource/conf/scripts.xml Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-10 15:16:01 UTC (rev 1013) +++ trunk/crossfire/ChangeLog 2006-12-10 15:28:08 UTC (rev 1014) @@ -1,3 +1,9 @@ +2006-12-10 Andreas Kirschbaum + + * Make WorldMaker script more robust: + - create PictureDirectory if it does not exist + - do not require a trailing / for PictureDirectory + 2006-12-07 Andreas Kirschbaum * Make mouse position display work again. Modified: trunk/crossfire/resource/conf/scripts.xml =================================================================== --- trunk/crossfire/resource/conf/scripts.xml 2006-12-10 15:16:01 UTC (rev 1013) +++ trunk/crossfire/resource/conf/scripts.xml 2006-12-10 15:28:08 UTC (rev 1014) @@ -69,6 +69,11 @@ Location = Location + File.separator; } + if (!PictureDirectory.endsWith(File.separator)) { + PictureDirectory = PictureDirectory + File.separator; + } + new File(Location + PictureDirectory).mkdirs(); + HashSet mapList = new HashSet(); boolean firstRun = false; if (fileExists(Location + PictureDirectory + WorldPicture + ".ppm")) { @@ -179,7 +184,7 @@ <name>PictureDirectory</name> <description>The subdirectory where to put pictures</description> <type>java.lang.String</type> - <value>images/</value> + <value>images</value> </parameter> <parameter> <name>WorldPicture</name> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-12 19:33:07
|
Revision: 1057 http://svn.sourceforge.net/gridarta/?rev=1057&view=rev Author: akirschbaum Date: 2006-12-12 11:33:03 -0800 (Tue, 12 Dec 2006) Log Message: ----------- Make View|Reset View work. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainMenu.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-12 19:26:42 UTC (rev 1056) +++ trunk/crossfire/ChangeLog 2006-12-12 19:33:03 UTC (rev 1057) @@ -1,3 +1,7 @@ +2006-12-12 Andreas Kirschbaum + + * Make View|Reset View work. + 2006-12-10 Andreas Kirschbaum * Make WorldMaker script more robust: Modified: trunk/crossfire/src/cfeditor/CMainMenu.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-12 19:26:42 UTC (rev 1056) +++ trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-12 19:33:03 UTC (rev 1057) @@ -605,7 +605,7 @@ new ActionListener() { public void actionPerformed(final ActionEvent event) { // set tileEdit to zero (-> show all) - mainControl.setTileEdit(0); + mainControl.unsetTileEdit(~0); monster.setChecked(false); exit.setChecked(false); background.setChecked(false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-13 19:19:38
|
Revision: 1059 http://svn.sourceforge.net/gridarta/?rev=1059&view=rev Author: akirschbaum Date: 2006-12-13 11:19:24 -0800 (Wed, 13 Dec 2006) Log Message: ----------- Make Analyze menu work. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/filter/BasicFilterConfig.java trunk/crossfire/src/cfeditor/filter/NamedFilterConfig.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-13 18:34:55 UTC (rev 1058) +++ trunk/crossfire/ChangeLog 2006-12-13 19:19:24 UTC (rev 1059) @@ -1,3 +1,7 @@ +2006-12-13 Andreas Kirschbaum + + * Make Analyze menu work. + 2006-12-12 Andreas Kirschbaum * Make View|Reset View work. Modified: trunk/crossfire/src/cfeditor/filter/BasicFilterConfig.java =================================================================== --- trunk/crossfire/src/cfeditor/filter/BasicFilterConfig.java 2006-12-13 18:34:55 UTC (rev 1058) +++ trunk/crossfire/src/cfeditor/filter/BasicFilterConfig.java 2006-12-13 19:19:24 UTC (rev 1059) @@ -24,12 +24,12 @@ private final EventListenerList listenerList = new EventListenerList(); public void setEnabled(final boolean enabled) { - this.enabled = enabled; if (enabled) { if (log.isDebugEnabled()) { log.debug("enabling filter " + this); } - if (!enabled) { + if (!this.enabled) { + this.enabled = true; final ConfigEvent e = new ConfigEvent(ConfigEventType.ENABLE, this); fireEvent(e); } @@ -37,7 +37,8 @@ if (log.isDebugEnabled()) { log.debug("disabling filter " + this); } - if (enabled) { + if (this.enabled) { + this.enabled = false; final ConfigEvent e = new ConfigEvent(ConfigEventType.DISABLE, this); fireEvent(e); } Modified: trunk/crossfire/src/cfeditor/filter/NamedFilterConfig.java =================================================================== --- trunk/crossfire/src/cfeditor/filter/NamedFilterConfig.java 2006-12-13 18:34:55 UTC (rev 1058) +++ trunk/crossfire/src/cfeditor/filter/NamedFilterConfig.java 2006-12-13 19:19:24 UTC (rev 1059) @@ -34,7 +34,11 @@ } public void setInverted(final boolean inverted) { + if (this.inverted == inverted) { + return; + } this.inverted = inverted; + fireEvent(new ConfigEvent(ConfigEventType.CHANGE, this)); } public FilterConfig getConfig(final String name) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-14 21:49:25
|
Revision: 1065 http://svn.sourceforge.net/gridarta/?rev=1065&view=rev Author: akirschbaum Date: 2006-12-14 13:49:25 -0800 (Thu, 14 Dec 2006) Log Message: ----------- Use ActionFactory to create main menu. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFilterControl.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CScriptView.java trunk/crossfire/src/cfeditor/IGUIConstants.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/crossfire/src/cfeditor/action.properties trunk/crossfire/src/cfeditor/filter/AttributeFilter.java trunk/crossfire/src/cfeditor/filter/Filter.java trunk/crossfire/src/cfeditor/filter/NamedFilterList.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties trunk/crossfire/src/cfeditor/parameter/FilterParameterView.java Added Paths: ----------- trunk/crossfire/resource/icons/development/Jar16.gif trunk/crossfire/resource/icons/general/About16.gif trunk/crossfire/resource/icons/general/Copy16.gif trunk/crossfire/resource/icons/general/Cut16.gif trunk/crossfire/resource/icons/general/Delete16.gif trunk/crossfire/resource/icons/general/Help16.gif trunk/crossfire/resource/icons/general/New16.gif trunk/crossfire/resource/icons/general/Paste16.gif trunk/crossfire/resource/icons/general/Preferences16.gif trunk/crossfire/resource/icons/general/Properties16.gif trunk/crossfire/resource/icons/general/Refresh16.gif trunk/crossfire/resource/icons/general/Remove16.gif trunk/crossfire/resource/icons/general/Replace16.gif trunk/crossfire/resource/icons/general/Save16.gif trunk/crossfire/resource/icons/general/SaveAs16.gif Removed Paths: ------------- trunk/crossfire/resource/icons/ImportTilesetSmallIcon.gif trunk/crossfire/resource/icons/NewLevelSmallIcon.gif trunk/crossfire/resource/icons/NextWindowSmallIcon.gif trunk/crossfire/resource/icons/OpenLevelSmallIcon.gif trunk/crossfire/resource/icons/PrevWindowSmallIcon.gif trunk/crossfire/resource/icons/RedoSmallIcon.gif trunk/crossfire/resource/icons/RemoveTilesetSmallIcon.gif trunk/crossfire/resource/icons/UndoSmallIcon.gif trunk/crossfire/src/cfeditor/CMainMenu.java Deleted: trunk/crossfire/resource/icons/ImportTilesetSmallIcon.gif =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/icons/NewLevelSmallIcon.gif =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/icons/NextWindowSmallIcon.gif =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/icons/OpenLevelSmallIcon.gif =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/icons/PrevWindowSmallIcon.gif =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/icons/RedoSmallIcon.gif =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/icons/RemoveTilesetSmallIcon.gif =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/icons/UndoSmallIcon.gif =================================================================== (Binary files differ) Added: trunk/crossfire/resource/icons/development/Jar16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/development/Jar16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/general/About16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/general/About16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/general/Copy16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/general/Copy16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/general/Cut16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/general/Cut16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/general/Delete16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/general/Delete16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/general/Help16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/general/Help16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/general/New16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/general/New16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/general/Paste16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/general/Paste16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/general/Preferences16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/general/Preferences16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/general/Properties16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/general/Properties16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/general/Refresh16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/general/Refresh16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/general/Remove16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/general/Remove16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/general/Replace16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/general/Replace16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/general/Save16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/general/Save16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/general/SaveAs16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/general/SaveAs16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/crossfire/src/cfeditor/CFilterControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CFilterControl.java 2006-12-14 21:36:04 UTC (rev 1064) +++ trunk/crossfire/src/cfeditor/CFilterControl.java 2006-12-14 21:49:25 UTC (rev 1065) @@ -16,10 +16,9 @@ import cfeditor.filter.NamedFilterListener; import cfeditor.gameobject.GameObject; import cfeditor.map.MapControl; -import cfeditor.menu.BasicMenuEntry; -import javax.swing.JComponent; import javax.swing.JMenu; -import org.jetbrains.annotations.Nullable; +import javax.swing.JMenuItem; +import net.sf.japi.swing.ActionFactory; /** * Control for filters. @@ -42,6 +41,9 @@ //TODO allow implementation of own filter public final class CFilterControl implements NamedFilterListener, ConfigListener { + /** Action Factory to create Actions. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); + public static final int MAX_HIGHLIGHT = 3; private final boolean filterOut = false; @@ -83,8 +85,16 @@ return defaultFilter; } - public BasicMenuEntry createMenuEntry() { - return new FilterControlMenuEntry(); + public void createMenuEntries(final JMenu menu) { + final JMenuItem menuItem = filterList.createMenuEntry(filterOutConfig); + menuItem.setText("Filter view"); + menu.add(menuItem); + menu.addSeparator(); + for (int i = 0; i < MAX_HIGHLIGHT; i++) { + final JMenuItem menuItem2 = filterList.createMenuEntry(highLightConfig[i]); + menuItem2.setText("Highlight " + i); + menu.add(menuItem2); + } } /* ---------- use part --------------*/ @@ -140,45 +150,6 @@ } } - private final class FilterControlMenuEntry extends BasicMenuEntry { - - FilterControlMenuEntry() { - super("<<set me>>"); - } - - @Override protected void update() { - // nothing to do - } - - @Override protected void updateItem(final JComponent item) { - // nothing to do - } - - @Override public JComponent getMenuBarComponent() { - final JMenu menu = new JMenu(getName()); - final BasicMenuEntry outEntry = filterList.createMenuEntry(filterOutConfig); - outEntry.setName("Filter view"); - final JComponent out = outEntry.getMenuItemComponent(); - menu.add(out); - menu.addSeparator(); - for (int i = 0; i < MAX_HIGHLIGHT; i++) { - final BasicMenuEntry bme = filterList.createMenuEntry(highLightConfig[i]); - bme.setName("Highlight " + i); - final JComponent hl = bme.getMenuItemComponent(); - menu.add(hl); - } - return menu; - } - - @Override public JComponent getMenuItemComponent() { - return getMenuBarComponent(); - } - - @Override @Nullable public JComponent getToolbarComponent() { - return null; - } - } - public boolean addFilter(final String name, final Filter f) { return filterList.addFilter(name, f); } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-14 21:36:04 UTC (rev 1064) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-14 21:49:25 UTC (rev 1065) @@ -90,7 +90,7 @@ public static final String LOAD_ARCH_COLL = "loadArchFromCollection"; - public static final String PICKMAPS_LOCKED = "pickmapsLocked"; + private static final String PICKMAPS_LOCKED = "pickmapsLocked"; /** Preferences key for language. */ public static final String PREFS_LANGUAGE = "language"; @@ -180,8 +180,8 @@ public CMainControl() { instance = this; archetypeSet = new ArchetypeSet(this); - mainView = new CMainView(this); scriptControl = new CScriptController(this); + mainView = new CMainView(); } /** @@ -215,7 +215,7 @@ if (autoPopupDocu) { // do an automated help popup because the docu version has increased // (people won't notice the docu otherwise - nobody expects a docu in opensource) - openHelpWindow(); + onlineHelp(); autoPopupDocu = false; } @@ -248,8 +248,15 @@ } } + /** Show about dialog. */ + @ActionMethod public void about() { + mainView.about(); + } + /** Collect crossfire archetypes. */ public void collectArches() { + getMainView().update(getMainView().getGraphics()); + if (archetypeSet.getLoadStatus() != ArchetypeSet.LoadStatus.COMPLETE) { // must not collect arches while arch stack not complete ACTION_FACTORY.showMessageDialog(mainView, "collectArchesNotReady"); @@ -267,6 +274,11 @@ collector.start(); } + /** Collect Spells. */ + @ActionMethod public void collectSpells() { + getTypeList().importSpellsWanted(this); + } + /** View Treasure Lists. */ @ActionMethod public void viewTreasurelists() { CFTreasureListTree.getInstance().showDialog(); @@ -324,7 +336,7 @@ * each map where this type has not yet been used. * @param newType new selected edit type (should not be more than one) */ - void selectEditType(final int newType) { + private void selectEditType(final int newType) { // calculate the new type for all opened maps: for (final MapControl level : levels) { level.addEditType(newType); // calculate new type @@ -333,15 +345,88 @@ setTileEdit(newType); // activate the new type for all views } + public boolean isAutoJoin() { + return autoJoin; + } + public void setAutoJoin(final boolean autoJoin) { this.autoJoin = autoJoin; } - public boolean isAutoJoin() { - return autoJoin; + private void setShow(final boolean show, final int editType) { + if (show) { + selectEditType(editType); + } else { + unsetTileEdit(editType); + } + refreshCurrentMap(); } - public void openHelpWindow() { + public boolean isShowMonster() { + return isTileEdit(IGUIConstants.TILE_EDIT_MONSTER); + } + + public void setShowMonster(final boolean showMonster) { + setShow(showMonster, IGUIConstants.TILE_EDIT_MONSTER); + } + + public boolean isShowExit() { + return isTileEdit(IGUIConstants.TILE_EDIT_EXIT); + } + + public void setShowExit(final boolean showExit) { + setShow(showExit, IGUIConstants.TILE_EDIT_EXIT); + } + + public boolean isShowBackground() { + return isTileEdit(IGUIConstants.TILE_EDIT_BACKGROUND); + } + + public void setShowBackground(final boolean showBackground) { + setShow(showBackground, IGUIConstants.TILE_EDIT_BACKGROUND); + } + + public boolean isShowDoor() { + return isTileEdit(IGUIConstants.TILE_EDIT_DOOR); + } + + public void setShowDoor(final boolean showDoor) { + setShow(showDoor, IGUIConstants.TILE_EDIT_DOOR); + } + + public boolean isShowWall() { + return isTileEdit(IGUIConstants.TILE_EDIT_WALL); + } + + public void setShowWall(final boolean showWall) { + setShow(showWall, IGUIConstants.TILE_EDIT_WALL); + } + + public boolean isShowEquipment() { + return isTileEdit(IGUIConstants.TILE_EDIT_EQUIP); + } + + public void setShowEquipment(final boolean showEquipment) { + setShow(showEquipment, IGUIConstants.TILE_EDIT_EQUIP); + } + + public boolean isShowTreasure() { + return isTileEdit(IGUIConstants.TILE_EDIT_TREASURE); + } + + public void setShowTreasure(final boolean showTreasure) { + setShow(showTreasure, IGUIConstants.TILE_EDIT_TREASURE); + } + + public boolean isShowConnected() { + return isTileEdit(IGUIConstants.TILE_EDIT_CONNECTED); + } + + public void setShowConnected(final boolean showConnected) { + setShow(showConnected, IGUIConstants.TILE_EDIT_CONNECTED); + } + + public void onlineHelp() { mainView.openHelpWindow(); } @@ -1110,17 +1195,14 @@ } } - boolean isTileShow() { + public boolean isTileShow() { return currentMap.isTileShow(); } - void setTileShow() { - // TODO: implement this + public void setTileShow(final boolean tileShow) { + currentMap.setTileShow(tileShow); } - void toggleShowTiles() { - } - private PreferencesGroup prefsGroup; public void options() { @@ -1225,6 +1307,36 @@ } } + /** Action method for entering the north map. */ + public void enterNorthMap() { + enterTileWanted(IGUIConstants.NORTH); + } + + /** Action method for entering the east map. */ + public void enterEastMap() { + enterTileWanted(IGUIConstants.EAST); + } + + /** Action method for entering the south map. */ + public void enterSouthMap() { + enterTileWanted(IGUIConstants.SOUTH); + } + + /** Action method for entering the west map. */ + public void enterWestMap() { + enterTileWanted(IGUIConstants.WEST); + } + + /** Action method for entering the upper map. */ + public void enterUpperMap() { + enterTileWanted(IGUIConstants.TOP); + } + + /** Action method for entering the lower map. */ + public void enterLowerMap() { + enterTileWanted(IGUIConstants.BOTTOM); + } + /** * Try to load the map where the specified map-tile path points to. * Usually this method can only be invoked when such a path exists. @@ -1525,7 +1637,7 @@ * @return true if a level is being edited or false if not */ boolean isLevelEdited() { - return currentMap != null; + return currentMap != null && currentMap.isLevelChanged(); } /** Deleted: trunk/crossfire/src/cfeditor/CMainMenu.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-14 21:36:04 UTC (rev 1064) +++ trunk/crossfire/src/cfeditor/CMainMenu.java 2006-12-14 21:49:25 UTC (rev 1065) @@ -1,1354 +0,0 @@ -/* - * Crossfire Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package cfeditor; - -import cfeditor.gameobject.ArchetypeSet; -import cfeditor.menu.AggregateMenuLocation; -import cfeditor.menu.BasicMenuEntry; -import cfeditor.menu.CheckBoxMenuEntry; -import cfeditor.menu.LocationMenuEntry; -import cfeditor.menu.MenuGroup; -import cfeditor.menu.MenuManager; -import cfeditor.menu.SimpleMenuEntry; -import cfeditor.menu.SimpleMenuLocation; -import cfeditor.menu.MenuEntry; -import java.awt.Event; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.util.List; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; -import javax.swing.KeyStroke; -import javax.swing.UIManager; - -/** - * <code>CMainMenu</code implements the main menu of the application. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - */ -public final class CMainMenu extends JMenuBar { - - /** Controller of this menu view. */ - private final CMainControl mainControl; - - private AggregateMenuLocation mainLocation; - - private AggregateMenuLocation currentmapLocation; - - private JMenu windowMenu; - - private SimpleMenuEntry close; - - private SimpleMenuEntry revert; - - private SimpleMenuEntry save; - - private SimpleMenuEntry saveAs; - - private SimpleMenuEntry createImg; - - private SimpleMenuEntry collectArch; - - private SimpleMenuEntry spellC; - - private SimpleMenuEntry viewTreasure; - - private CheckBoxMenuEntry autojoin; - - private CheckBoxMenuEntry gridToggle; - - private SimpleMenuEntry properties; - - private SimpleMenuEntry enterExit; - - private SimpleMenuEntry enterNorth; - - private SimpleMenuEntry enterEast; - - private SimpleMenuEntry enterWest; - - private SimpleMenuEntry enterSouth; - - private SimpleMenuEntry enterUpper; - - private SimpleMenuEntry enterLower; - - private CheckBoxMenuEntry showTiles; - - private CheckBoxMenuEntry lockPickmaps; - - private SimpleMenuEntry newPickmap; - - private SimpleMenuEntry deletePickmap; - - private SimpleMenuEntry loadPickmap; - - private SimpleMenuEntry savePickmap; - - private SimpleMenuEntry revertPickmap; - - private SimpleMenuEntry clear; - - private SimpleMenuEntry cut; - - private SimpleMenuEntry copy; - - private SimpleMenuEntry paste; - - private SimpleMenuEntry replace; - - private SimpleMenuEntry fillAbove; - - private SimpleMenuEntry fillBelow; - - private CheckBoxMenuEntry monster; - - private CheckBoxMenuEntry exit; - - private CheckBoxMenuEntry background; - - private CheckBoxMenuEntry door; - - private CheckBoxMenuEntry wall; - - private CheckBoxMenuEntry equip; - - private CheckBoxMenuEntry treasure; - - private CheckBoxMenuEntry connected; - - private JMenuItem newWindow; - - private JMenuItem closeAll; - - /*private JCheckBoxMenuItem[] m_analyze_show_filters; - private JCheckBoxMenuItem m_analyze_show_activate; - private JCheckBoxMenuItem m_analyze_show_invert; - private JMenu m_analyze_show; - private JCheckBoxMenuItem[][] m_analyze_highLight_filters; - private JCheckBoxMenuItem[] m_analyze_highLight_activate; - private JCheckBoxMenuItem[] m_analyze_highLight_invert; - private JMenu[] m_analyze_highLight;*/ - - private static final long serialVersionUID = 1491480879950551491L; - - /** - * Constructs a main menu. - * @param mainControl The controller of this main menu. - */ - CMainMenu(final CMainControl mainControl) { - this.mainControl = mainControl; // reference to main control - buildAggregates(); - buildFileMenu(); - buildEditMenu(); - buildMapMenu(); - buildPickmapsMenu(); - buildResourceMenu(); - //buildScriptMenu(); - buildAnalyzeMenu(); - buildViewMenu(); - buildBshMenu(); - buildWindowMenu(); - buildHelpMenu(); - buildCurrentMapMenu(); - } - - private void buildAggregates() { - mainLocation = new AggregateMenuLocation("main"); - final AggregateMenuLocation toolbarLocation = new AggregateMenuLocation("toolbar"); - currentmapLocation = new AggregateMenuLocation("currentmap"); - MenuManager.getMenuManager().addMenuLocation(mainLocation); - MenuManager.getMenuManager().addMenuLocation(toolbarLocation); - MenuManager.getMenuManager().addMenuLocation(currentmapLocation); - } - - private void buildCurrentMapMenu() { - currentmapLocation.addMenuEntry(save); - currentmapLocation.addMenuEntry(saveAs); - currentmapLocation.addMenuEntry(createImg); - currentmapLocation.addMenuEntry(revert); - currentmapLocation.addMenuEntry(autojoin); - currentmapLocation.addMenuEntry(properties); - currentmapLocation.addMenuEntry(fillAbove); - currentmapLocation.addMenuEntry(fillBelow); - } - - /** - * Creates the "File"-Menu. - */ - private void buildFileMenu() { - final MenuManager menuManager = MenuManager.getMenuManager(); - final SimpleMenuLocation fileMenu = new SimpleMenuLocation("main.file"); - menuManager.addMenuLocation(fileMenu); - mainLocation.addMenuLocation(fileMenu); - final LocationMenuEntry entry = new LocationMenuEntry("main.file", "File"); - menuManager.addMenuEntry("main", entry); - entry.setMnemonic('F'); - - final SimpleMenuEntry newME = new SimpleMenuEntry("New..."); - newME.setIcon(CGUIUtils.getIcon(IGUIConstants.NEW_LEVEL_SMALLICON)); - newME.setMnemonic('N'); - newME.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK)); - newME.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.createNew(); - } - }); - menuManager.addMenuEntry("main.file", newME); - - final SimpleMenuEntry open = new SimpleMenuEntry("Open..."); - open.setIcon(CGUIUtils.getIcon(IGUIConstants.OPEN_LEVEL_SMALLICON)); - open.setMnemonic('O'); - open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK)); - open.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.open(); - } - }); - menuManager.addMenuEntry("main.file", open); - - close = new SimpleMenuEntry("Close"); - close.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - close.setMnemonic('C'); - close.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, Event.CTRL_MASK)); - close.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.close(); - } - }); - menuManager.addMenuEntry("main.file", close); - - menuManager.addMenuEntry("main.file", MenuEntry.getSeparator()); - - save = new SimpleMenuEntry("Save"); - save.setIcon(CGUIUtils.getIcon(IGUIConstants.SAVE_LEVEL_SMALLICON)); - save.setMnemonic('S'); - save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)); - save.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.save(); - } - }); - menuManager.addMenuEntry("main.file", save); - - saveAs = new SimpleMenuEntry("Save as..."); - saveAs.setIcon(CGUIUtils.getIcon(IGUIConstants.SAVE_LEVEL_AS_SMALLICON)); - saveAs.setMnemonic('A'); - saveAs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)); - saveAs.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.saveAs(); - } - }); - menuManager.addMenuEntry("main.file", saveAs); - - revert = new SimpleMenuEntry("Revert"); - revert.setMnemonic('R'); - revert.setIcon(CGUIUtils.getIcon(IGUIConstants.REVERT_ICON)); - revert.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.revert(); - } - }); - menuManager.addMenuEntry("main.file", revert); - - createImg = new SimpleMenuEntry("Create image"); - createImg.setMnemonic('I'); - createImg.setIcon(CGUIUtils.getIcon(IGUIConstants.CREATE_IMAGE_SMALLICON)); - createImg.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.createImg(); - } - }); - menuManager.addMenuEntry("main.file", createImg); - - menuManager.addMenuEntry("main.file", SimpleMenuEntry.getSeparator()); - - final SimpleMenuEntry options = new SimpleMenuEntry("Options..."); - options.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - options.setMnemonic('P'); - options.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, Event.ALT_MASK)); - options.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.options(); - } - }); - menuManager.addMenuEntry("main.file", options); - - menuManager.addMenuEntry("main.file", SimpleMenuEntry.getSeparator()); - - final SimpleMenuEntry exit = new SimpleMenuEntry("Exit"); - exit.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - exit.setMnemonic('X'); - exit.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.exit(); - } - }); - menuManager.addMenuEntry("main.file", exit); - add(entry.getMenuBarComponent()); - } - - /** - * Creates the "Edit"-Menu. - */ - private void buildEditMenu() { - final MenuManager menuManager = MenuManager.getMenuManager(); - final SimpleMenuLocation editMenu = new SimpleMenuLocation("main.edit"); - mainLocation.addMenuLocation(editMenu); - menuManager.addMenuLocation(editMenu); - final LocationMenuEntry entry = new LocationMenuEntry("main.edit", "Edit"); - menuManager.addMenuEntry("main", entry); - entry.setMnemonic('E'); - - // Clear: - clear = new SimpleMenuEntry("Clear"); - clear.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - clear.addActionListener(new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.clear(); - } - }); - menuManager.addMenuEntry("main.edit", clear); - - // Cut: - cut = new SimpleMenuEntry("Cut"); - cut.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK)); - cut.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.cut(); - } - }); - menuManager.addMenuEntry("main.edit", cut); - - // Copy: - copy = new SimpleMenuEntry("Copy"); - copy.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK)); - copy.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.copy(); - } - }); - menuManager.addMenuEntry("main.edit", copy); - - // Paste: - paste = new SimpleMenuEntry("Paste"); - paste.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK)); - paste.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.paste(); - } - }); - menuManager.addMenuEntry("main.edit", paste); - - menuManager.addMenuEntry("main.edit", MenuEntry.getSeparator()); - - // Replace: - replace = new SimpleMenuEntry("Replace"); - replace.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - replace.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, Event.CTRL_MASK)); - replace.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.replace(); - } - }); - menuManager.addMenuEntry("main.edit", replace); - - // Fill: - fillAbove = new SimpleMenuEntry("Fill Above"); - fillAbove.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - fillAbove.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK)); - fillAbove.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.fillAbove(); - } - }); - menuManager.addMenuEntry("main.edit", fillAbove); - - // Fill: - fillBelow = new SimpleMenuEntry("Fill Below"); - fillBelow.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - fillBelow.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, Event.CTRL_MASK | Event.SHIFT_MASK)); - fillBelow.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.fillBelow(); - } - }); - menuManager.addMenuEntry("main.edit", fillBelow); - - // Random Fill: - final SimpleMenuEntry randFillAbove = new SimpleMenuEntry("Random Fill Above"); - randFillAbove.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - randFillAbove.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK)); - randFillAbove.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.randFillAbove(); - } - }); - menuManager.addMenuEntry("main.edit", randFillAbove); - - // Random Fill: - final SimpleMenuEntry randFillBelow = new SimpleMenuEntry("Random Fill Below"); - randFillBelow.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - randFillBelow.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, Event.CTRL_MASK | Event.SHIFT_MASK)); - randFillBelow.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.randFillBelow(); - } - }); - menuManager.addMenuEntry("main.edit", randFillBelow); - - final SimpleMenuEntry garbageCollection = new SimpleMenuEntry("Run Garbage Collection"); - garbageCollection.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - garbageCollection.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.gc(); - } - }); - menuManager.addMenuEntry("main.edit", garbageCollection); - - add(entry.getMenuBarComponent()); - } - - private void buildViewMenu() { - final MenuManager menuManager = MenuManager.getMenuManager(); - final SimpleMenuLocation viewMenu = new SimpleMenuLocation("main.view"); - mainLocation.addMenuLocation(viewMenu); - menuManager.addMenuLocation(viewMenu); - final LocationMenuEntry entry = new LocationMenuEntry("main.view", "View"); - menuManager.addMenuEntry("main", entry); - entry.setMnemonic('V'); - - final CSettings settings = CSettings.getInstance(IGUIConstants.APP_NAME); - final UIManager.LookAndFeelInfo[] lafInfos = UIManager.getInstalledLookAndFeels(); - final MenuGroup group = new MenuGroup(); - //JCheckBoxMenuItem selectedMenuItem = null; - final String strSelectedLNFName = settings.getProperty(CMainView.SELECTED_LNF_KEY, - UIManager.getCrossPlatformLookAndFeelClassName()); - for (final UIManager.LookAndFeelInfo lafInfo : lafInfos) { - final CheckBoxMenuEntry menuItem = new CheckBoxMenuEntry(lafInfo.getName()); - if (strSelectedLNFName.compareTo(lafInfo.getClassName()) == 0) { - menuItem.setChecked(true); - } - - menuItem.addActionListener(new CLNFActionListener(lafInfo.getClassName())); - menuManager.addMenuEntry("main.view", menuItem); - group.add(menuItem); - } - - menuManager.addMenuEntry("main.view", MenuEntry.getSeparator()); - - menuManager.addMenuEntry("main.view", MenuEntry.getSeparator()); - - monster = new CheckBoxMenuEntry("Show Monsters"); - monster.setChecked(mainControl.isTileEdit(IGUIConstants.TILE_EDIT_MONSTER)); - monster.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - if (monster.isChecked()) { - mainControl.selectEditType(IGUIConstants.TILE_EDIT_MONSTER); - } else { - mainControl.unsetTileEdit(IGUIConstants.TILE_EDIT_MONSTER); - } - mainControl.refreshCurrentMap(); - } - }); - menuManager.addMenuEntry("main.view", monster); - - exit = new CheckBoxMenuEntry("Show Exits"); - exit.setChecked(mainControl.isTileEdit(IGUIConstants.TILE_EDIT_EXIT)); - exit.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - if (exit.isChecked()) { - mainControl.selectEditType(IGUIConstants.TILE_EDIT_EXIT); - } else { - mainControl.unsetTileEdit(IGUIConstants.TILE_EDIT_EXIT); - } - mainControl.refreshCurrentMap(); - } - }); - menuManager.addMenuEntry("main.view", exit); - - background = new CheckBoxMenuEntry("Show Background"); - background.setChecked(mainControl.isTileEdit(IGUIConstants.TILE_EDIT_BACKGROUND)); - background.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - if (background.isChecked()) { - mainControl.selectEditType(IGUIConstants.TILE_EDIT_BACKGROUND); - } else { - mainControl.unsetTileEdit(IGUIConstants.TILE_EDIT_BACKGROUND); - } - mainControl.refreshCurrentMap(); - } - }); - menuManager.addMenuEntry("main.view", background); - - door = new CheckBoxMenuEntry("Show Doors & Keys"); - door.setChecked(mainControl.isTileEdit(IGUIConstants.TILE_EDIT_DOOR)); - door.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - if (door.isChecked()) { - mainControl.selectEditType(IGUIConstants.TILE_EDIT_DOOR); - } else { - mainControl.unsetTileEdit(IGUIConstants.TILE_EDIT_DOOR); - } - mainControl.refreshCurrentMap(); - } - }); - menuManager.addMenuEntry("main.view", door); - wall = new CheckBoxMenuEntry("Show Wall"); - wall.setChecked(mainControl.isTileEdit(IGUIConstants.TILE_EDIT_WALL)); - wall.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - if (wall.isChecked()) { - mainControl.selectEditType(IGUIConstants.TILE_EDIT_WALL); - } else { - mainControl.unsetTileEdit(IGUIConstants.TILE_EDIT_WALL); - } - mainControl.refreshCurrentMap(); - } - }); - menuManager.addMenuEntry("main.view", wall); - equip = new CheckBoxMenuEntry("Show Equipment"); - equip.setChecked(mainControl.isTileEdit(IGUIConstants.TILE_EDIT_EQUIP)); - equip.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - if (equip.isChecked()) { - mainControl.selectEditType(IGUIConstants.TILE_EDIT_EQUIP); - } else { - mainControl.unsetTileEdit(IGUIConstants.TILE_EDIT_EQUIP); - } - mainControl.refreshCurrentMap(); - } - }); - menuManager.addMenuEntry("main.view", equip); - treasure = new CheckBoxMenuEntry("Show Treasure"); - treasure.setChecked(mainControl.isTileEdit(IGUIConstants.TILE_EDIT_TREASURE)); - treasure.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - if (treasure.isChecked()) { - mainControl.selectEditType(IGUIConstants.TILE_EDIT_TREASURE); - } else { - mainControl.unsetTileEdit(IGUIConstants.TILE_EDIT_TREASURE); - } - mainControl.refreshCurrentMap(); - } - }); - menuManager.addMenuEntry("main.view", treasure); - connected = new CheckBoxMenuEntry("Show Connected"); - connected.setChecked(mainControl.isTileEdit(IGUIConstants.TILE_EDIT_CONNECTED)); - connected.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - if (connected.isChecked()) { - mainControl.selectEditType(IGUIConstants.TILE_EDIT_CONNECTED); - } else { - mainControl.unsetTileEdit(IGUIConstants.TILE_EDIT_CONNECTED); - } - mainControl.refreshCurrentMap(); - } - }); - menuManager.addMenuEntry("main.view", connected); - menuManager.addMenuEntry("main.view", MenuEntry.getSeparator()); - final SimpleMenuEntry showAll = new SimpleMenuEntry("Reset View"); - showAll.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - // set tileEdit to zero (-> show all) - mainControl.unsetTileEdit(~0); - monster.setChecked(false); - exit.setChecked(false); - background.setChecked(false); - door.setChecked(false); - wall.setChecked(false); - equip.setChecked(false); - treasure.setChecked(false); - connected.setChecked(false); - mainControl.refreshCurrentMap(); // redraw map - } - }); - menuManager.addMenuEntry("main.view", showAll); - - add(entry.getMenuBarComponent()); - } - - private void buildMapMenu() { - final SimpleMenuLocation mapMenu = new SimpleMenuLocation("main.map"); - final LocationMenuEntry entry = new LocationMenuEntry("main.map", "Map"); - final MenuManager menuManager = MenuManager.getMenuManager(); - menuManager.addMenuLocation(mapMenu); - mainLocation.addMenuLocation(mapMenu); - entry.setMnemonic('M'); - menuManager.addMenuEntry("main", entry); - - autojoin = new CheckBoxMenuEntry("Auto-Joining"); - autojoin.setMnemonic('A'); - autojoin.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, Event.CTRL_MASK)); - autojoin.setChecked(mainControl.isAutoJoin()); - autojoin.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - // toggle autojoining state on/off - mainControl.setAutoJoin(autojoin.isChecked()); - } - }); - menuManager.addMenuEntry("main.map", autojoin); - - menuManager.addMenuEntry("main.map", MenuEntry.getSeparator()); - - gridToggle = new CheckBoxMenuEntry("Show Grid"); - gridToggle.setMnemonic('G'); - gridToggle.setChecked(mainControl.isGridVisible()); - - gridToggle.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.setGridVisible(gridToggle.isChecked()); - } - }); - menuManager.addMenuEntry("main.map", gridToggle); - - enterExit = new SimpleMenuEntry("Enter Exit"); - enterExit.setMnemonic('E'); - enterExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, Event.CTRL_MASK)); - enterExit.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.enterExit(); - } - }); - menuManager.addMenuEntry("main.map", enterExit); - menuManager.addMenuEntry("main.map", MenuEntry.getSeparator()); - - enterNorth = new SimpleMenuEntry("Enter North Map"); - enterNorth.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_UP, Event.CTRL_MASK)); - enterNorth.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.enterTileWanted(IGUIConstants.NORTH); - } - }); - menuManager.addMenuEntry("main.map", enterNorth); - - enterEast = new SimpleMenuEntry("Enter East Map"); - enterEast.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Event.CTRL_MASK)); - enterEast.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.enterTileWanted(IGUIConstants.EAST); - } - }); - menuManager.addMenuEntry("main.map", enterEast); - - enterSouth = new SimpleMenuEntry("Enter South Map"); - enterSouth.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, Event.CTRL_MASK)); - enterSouth.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.enterTileWanted(IGUIConstants.SOUTH); - } - }); - menuManager.addMenuEntry("main.map", enterSouth); - - enterWest = new SimpleMenuEntry("Enter West Map"); - enterWest.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Event.CTRL_MASK)); - enterWest.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.enterTileWanted(IGUIConstants.WEST); - } - }); - menuManager.addMenuEntry("main.map", enterWest); - - enterUpper = new SimpleMenuEntry("Enter Upper Map"); - enterUpper.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, Event.CTRL_MASK)); - enterUpper.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.enterTileWanted(IGUIConstants.TOP); - } - }); - menuManager.addMenuEntry("main.map", enterUpper); - - enterLower = new SimpleMenuEntry("Enter Lower Map"); - enterLower.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, Event.CTRL_MASK)); - enterLower.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.enterTileWanted(IGUIConstants.BOTTOM); - } - }); - menuManager.addMenuEntry("main.map", enterLower); - - menuManager.addMenuEntry("main.map", MenuEntry.getSeparator()); - - showTiles = new CheckBoxMenuEntry("Show Tiles around"); - showTiles.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.toggleShowTiles(); - } - }); - menuManager.addMenuEntry("main.map", showTiles); - - menuManager.addMenuEntry("main.map", MenuEntry.getSeparator()); - properties = new SimpleMenuEntry("Map Properties"); - properties.setMnemonic('P'); - properties.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, Event.CTRL_MASK)); - properties.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.mapProperties(); - } - }); - menuManager.addMenuEntry("main.map", properties); - add(entry.getMenuBarComponent()); - } - - private void buildPickmapsMenu() { - final SimpleMenuLocation pickmapsMenu = new SimpleMenuLocation("main.pickmaps"); - final LocationMenuEntry entry = new LocationMenuEntry("main.pickmaps", "Pickmaps"); - final MenuManager menuManager = MenuManager.getMenuManager(); - mainLocation.addMenuLocation(pickmapsMenu); - menuManager.addMenuLocation(pickmapsMenu); - entry.setMnemonic('P'); - menuManager.addMenuEntry("main", entry); - - lockPickmaps = new CheckBoxMenuEntry("Lock All Pickmaps"); - lockPickmaps.setMnemonic('L'); - lockPickmaps.setChecked(Boolean.valueOf(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty( - CMainControl.PICKMAPS_LOCKED, "false"))); - lockPickmaps.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - // lock pickmaps - mainControl.setLockAllPickmaps(lockPickmaps.isChecked()); - newPickmap.setEnabled(!lockPickmaps.isChecked()); - - final boolean isArchLoadComplete = mainControl.getArchetypeSet().getLoadStatus() == ArchetypeSet.LoadStatus.COMPLETE; - if (isArchLoadComplete) { - deletePickmap.setEnabled(!lockPickmaps.isChecked()); - loadPickmap.setEnabled(!lockPickmaps.isChecked()); - savePickmap.setEnabled(!lockPickmaps.isChecked()); - revertPickmap.setEnabled(!lockPickmaps.isChecked()); - } else { - deletePickmap.setEnabled(false); - loadPickmap.setEnabled(false); - savePickmap.setEnabled(false); - revertPickmap.setEnabled(false); - } - - // store this in the settings - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(CMainControl.PICKMAPS_LOCKED, lockPickmaps.isChecked() ? "true" : "false"); - } - }); - menuManager.addMenuEntry("main.pickmaps", lockPickmaps); - - menuManager.addMenuEntry("main.pickmaps", MenuEntry.getSeparator()); - - newPickmap = new SimpleMenuEntry("Add New Pickmap"); - newPickmap.setMnemonic('N'); - newPickmap.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - newPickmap.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - // create new pickmap - mainControl.addNewPickmap(); - } - }); - menuManager.addMenuEntry("main.pickmaps", newPickmap); - - deletePickmap = new SimpleMenuEntry("Close Active Pickmap"); - deletePickmap.setMnemonic('C'); - deletePickmap.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - deletePickmap.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - // close pickmap - mainControl.closePickmap(); - } - }); - menuManager.addMenuEntry("main.pickmaps", deletePickmap); - menuManager.addMenuEntry("main.pickmaps", MenuEntry.getSeparator()); - - loadPickmap = new SimpleMenuEntry("Open Active Pickmap as Map"); - loadPickmap.setMnemonic('O'); - loadPickmap.setIcon(CGUIUtils.getIcon(IGUIConstants.EMPTY_SMALLICON)); - loadPickmap.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - // load pickmap as normal map - mainControl.openPickmapMap(); - } - }); - menuManager.addMenuEntry("main.pickmaps", loadPickmap); - - savePickmap = new SimpleMenuEntry("Save Active Pickmap"); - savePickmap.setMnemonic('S'); - savePickmap.setIcon(CGUIUtils.getIcon(IGUIConstants.SAVE_LEVEL_SMALLICON)); - savePickmap.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - // save pickmap - mainControl.savePickmap(); - } - }); - menuManager.addMenuEntry("main.pickmaps", savePickmap); - - revertPickmap = new SimpleMenuEntry("Revert Active Pickmap"); - revertPickmap.setMnemonic('R'); - revertPickmap.setIcon(CGUIUtils.getIcon(IGUIConstants.REVERT_ICON)); - revertPickmap.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - // revert pickmap - mainControl.revertPickmap(); - } - }); - menuManager.addMenuEntry("main.pickmaps", revertPickmap); - - add(entry.getMenuBarComponent()); - } - - private void buildResourceMenu() { - final SimpleMenuLocation collectMenu = new SimpleMenuLocation("main.resources"); - final LocationMenuEntry entry = new LocationMenuEntry("main.resources", "Resources"); - final MenuManager menuManager = MenuManager.getMenuManager(); - mainLocation.addMenuLocation(collectMenu); - menuManager.addMenuLocation(collectMenu); - menuManager.addMenuEntry("main", entry); - entry.setMnemonic('R'); - - collectArch = new SimpleMenuEntry("Collect CF Arches"); - collectArch.setMnemonic('A'); - collectArch.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - //TODO fix this - //collectMenu.setPopupMenuVisible(false); - mainControl.getMainView().update(mainControl.getMainView().getGraphics()); - mainControl.collectArches(); - } - }); - menuManager.addMenuEntry("main.resources", collectArch); - - spellC = new SimpleMenuEntry("Collect Spells"); - spellC.setMnemonic('S'); - spellC.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.getTypeList().importSpellsWanted(mainControl); - } - }); - menuManager.addMenuEntry("main.resources", spellC); - menuManager.addMenuEntry("main.resources", MenuEntry.getSeparator()); - - viewTreasure = new SimpleMenuEntry("View Treasurelists"); - viewTreasure.setMnemonic('T'); - viewTreasure.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - // show the treasurelist tree - CFTreasureListTree.getInstance().showDialog(); - } - }); - menuManager.addMenuEntry("main.resources", viewTreasure); - - add(entry.getMenuBarComponent()); - } - - /*private void buildScriptMenu() { - menu_script = new JMenu("Scriptfire"); - menu_script.setMnemonic('S'); - - m_scriptMenu = new JMenuItem("under construction..."); - m_scriptMenu.setMnemonic('N'); - m_scriptMenu.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - } - }); - menu_script.add(m_scriptMenu); - //add(menu_script); - }*/ - - public void buildAnalyzeMenu() { - final MenuManager menuManager = MenuManager.getMenuManager(); - final CFilterControl filter = mainControl.getFilterControl(); - final BasicMenuEntry entry = filter.createMenuEntry(); - entry.setVisible(true); - entry.setMnemonic('y'); - entry.setName("Analyze"); - menuManager.addMenuEntry("main", entry); - add(entry.getMenuBarComponent()); - } - -/* - private void buildAnalyzeMenu() { - menu_analyze = new SimpleMenuLocation("main.analyze"); - final LocationMenuEntry entry = new LocationMenuEntry("main.analyze", "Analyze"); - final MenuManager menuManager = MenuManager.getMenuManager(); - mainLocation.addMenuLocation(menu_analyze); - menuManager.addMenuLocation(menu_analyze); - menuManager.addMenuEntry("main", entry); - entry.setMnemonic('y'); - final CFilterControl filter = mainControl.getFilterControl(); - m_analyze_show = new JMenu("Filter View"); - m_analyze_show.setMnemonic('v'); - m_analyze_show.setEnabled(false); - ActionListener showListener = new ActionListener() { - public void actionPerformed(final ActionEvent event) { - try {... [truncated message content] |
From: <aki...@us...> - 2006-12-15 18:55:17
|
Revision: 1072 http://svn.sourceforge.net/gridarta/?rev=1072&view=rev Author: akirschbaum Date: 2006-12-15 10:55:17 -0800 (Fri, 15 Dec 2006) Log Message: ----------- Fix #1613731 (Arch list tabs sometimes blank). Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CArchPanel.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-14 22:20:20 UTC (rev 1071) +++ trunk/crossfire/ChangeLog 2006-12-15 18:55:17 UTC (rev 1072) @@ -1,3 +1,7 @@ +2006-12-15 Andreas Kirschbaum + + * Fix #1613731 (Arch list tabs sometimes blank). + 2006-12-13 Andreas Kirschbaum * Make Analyze menu work. Modified: trunk/crossfire/src/cfeditor/CArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanel.java 2006-12-14 22:20:20 UTC (rev 1071) +++ trunk/crossfire/src/cfeditor/CArchPanel.java 2006-12-15 18:55:17 UTC (rev 1072) @@ -111,20 +111,6 @@ splitPane.setDividerLocation(divLocation); splitPane.setDividerSize(5); add(splitPane, BorderLayout.CENTER); - - // 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(); - if (selectedPanel != null) { - selectedPanel.showArchList(); - } - } - }); } public static List<PanelNode> getPanelNodeList() { @@ -168,13 +154,12 @@ public void addPanel(final String name) { final PanelNode newnode = new PanelNode(new CArchPanelPan(this, mainControl), name); - panelNodeList.add(newnode); - // 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); // careful: during the build process we are setting 'selectedPanel' @@ -198,6 +183,20 @@ 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(); + if (selectedPanel != null) { + selectedPanel.showArchList(); + } + } + }); } void appExitNotify() { 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:09:11
|
Revision: 1075 http://svn.sourceforge.net/gridarta/?rev=1075&view=rev Author: akirschbaum Date: 2006-12-15 12:09:11 -0800 (Fri, 15 Dec 2006) Log Message: ----------- Invert sorting order of archetype panels. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CArchPanel.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-15 19:59:26 UTC (rev 1074) +++ trunk/crossfire/ChangeLog 2006-12-15 20:09:11 UTC (rev 1075) @@ -1,5 +1,7 @@ 2006-12-15 Andreas Kirschbaum + * Invert sorting order of archetype panels. + * Fix #1613731 (Arch list tabs sometimes blank). 2006-12-13 Andreas Kirschbaum Modified: trunk/crossfire/src/cfeditor/CArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanel.java 2006-12-15 19:59:26 UTC (rev 1074) +++ trunk/crossfire/src/cfeditor/CArchPanel.java 2006-12-15 20:09:11 UTC (rev 1075) @@ -156,7 +156,7 @@ // insert new panels in alphabetical order int i; - for (i = 0; i < tabDesktop.getTabCount() && name.compareToIgnoreCase(tabDesktop.getTitleAt(i)) < 0; i++) { + for (i = 0; i < tabDesktop.getTabCount() && name.compareToIgnoreCase(tabDesktop.getTitleAt(i)) > 0; i++) { ; } panelNodeList.add(i, newnode); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-16 21:30:29
|
Revision: 1115 http://svn.sourceforge.net/gridarta/?rev=1115&view=rev Author: akirschbaum Date: 2006-12-16 13:30:26 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Unify map cursor and non-rectangular selection. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/resource/system/seltile.png trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapTileList.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/crossfire/src/cfeditor/IGUIConstants.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/crossfire/src/cfeditor/ReplaceDialog.java trunk/crossfire/src/cfeditor/action.properties trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.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/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties Added Paths: ----------- trunk/crossfire/resource/system/cursor.png trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/ChangeLog 2006-12-16 21:30:26 UTC (rev 1115) @@ -1,3 +1,13 @@ +2006-12-16 Andreas Kirschbaum + + * Implement non-rectangular selections. For now, it does not take + effect on any operation. + + * Implement map cursor. It affects flood filling, enter exit and + pasting. + + * Allow archetype selection by cursor in archetype panel. + 2006-12-15 Andreas Kirschbaum * Invert sorting order of archetype panels. Added: trunk/crossfire/resource/system/cursor.png =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/system/cursor.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/crossfire/resource/system/seltile.png =================================================================== (Binary files differ) Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -29,6 +29,7 @@ import cfeditor.gameobject.GameObject; import cfeditor.gameobject.anim.AnimationObjects; import cfeditor.gameobject.face.FaceObjects; +import cfeditor.gui.map.MapCursorControl; import cfeditor.gui.map.MapPropertiesDialog; import cfeditor.gui.prefs.GUIPrefs; import cfeditor.gui.prefs.ResPrefs; @@ -113,6 +114,8 @@ private static ImageIcon mapGridIcon; + private static ImageIcon mapCursorIcon; + private static ImageIcon unknownTileIcon; private static ImageIcon nofaceTileIcon; @@ -176,11 +179,14 @@ /** Pickmaps cannot be edited while lockedPickmaps is true. */ private boolean lockAllPickmaps = false; + private final MapCursorControl mapCursorControl; + /** Constructs the main controller and its model and view. */ public CMainControl() { instance = this; archetypeSet = new ArchetypeSet(this); scriptControl = new CScriptController(this); + mapCursorControl = new MapCursorControl(this); mainView = new CMainView(); } @@ -1232,7 +1238,7 @@ public void enterExit() { GameObject exit = getMainView().getMapTileSelection(); if (exit == null || !CFArchTypeList.isExitType(exit)) { - exit = currentMap.getMapModel().getExit(currentMap.getMapViewFrame().getHighlightStart()); + exit = currentMap.getMapModel().getExit(currentMap.getMapViewFrame().getView().getCursorPosition()); } if (exit == null) { // no exit found @@ -1654,6 +1660,10 @@ return mapGridIcon; } + public static ImageIcon getMapCursorIcon() { + return mapCursorIcon; + } + public static ImageIcon getUnknownTileIcon() { return unknownTileIcon; } @@ -1677,6 +1687,7 @@ private static void loadDefTiles() { mapGridIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_GRID_TILE); mapSelIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_SEL_TILE); + mapCursorIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_CURSOR); unknownTileIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_UNKNOWN); nofaceTileIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_NOFACE); noarchTileIcon = CGUIUtils.getSysIcon(IGUIConstants.TILE_NOARCH); @@ -1796,6 +1807,10 @@ return null; } + public MapCursorControl getMapCursorControl() { + return mapCursorControl; + } + /** * Runs the garbage collection. */ Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -32,6 +32,7 @@ import java.awt.Component; import java.awt.Dimension; import java.awt.Rectangle; +import java.awt.Point; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.WindowAdapter; @@ -339,8 +340,9 @@ if (pmap != null && pmap.getMapViewFrame().isHighlight()) { // now try to get the topmost object GameObject arch = null; - if (pmap.isPointValid(pmap.getMapViewFrame().getHighlightStart())) { - arch = pmap.getMapModel().getMapSquare(pmap.getMapViewFrame().getHighlightStart()).getFirst(); + final Point cursor = pmap.getMapViewFrame().getView().getCursorPosition(); + if (pmap.isPointValid(cursor)) { + arch = pmap.getMapModel().getMapSquare(cursor).getFirst(); } if (arch != null) { // so here we return the arch from the pickmap @@ -822,12 +824,19 @@ private final String[] directionsMap = {"enterNorthMap", "enterEastMap", "enterSouthMap", "enterWestMap", "enterUpperMap", "enterLowerMap"}; + private final String[] directionsGo = {"goNorth", "goEast", "goSouth", "goWest", "goNorthEast", "goSouthEast", "goSouthWest", "goNorthWest"}; + private void initActions() { ACTION_FACTORY.createActions(true, mainControl, "createNew", "open", "options", "exit", "gc", "onlineHelp", "about"); ACTION_FACTORY.createActions(true, mainControl.getScriptController().getView(), "editPlugins", "savePlugins", "exportPluginAs", "importPlugin"); ACTION_FACTORY.createActions(true, mainControl, directionsMap); ACTION_FACTORY.createActions(true, this, "resetView"); ACTION_FACTORY.createToggles(true, mainControl, "autoJoin"); + ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), directionsGo); + ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), "selectTile", "startStopDrag", "addToSelection", "subFromSelection", "releaseDrag"); + ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), "insertArch", "deleteArch"); + ACTION_FACTORY.createActions(true, mainControl.getMapCursorControl(), "selectArchAbove", "selectArchBelow"); + ACTION_FACTORY.createAction(true, "archAttributes", mainControl.getMapCursorControl()); ACTION_FACTORY.createToggles(true, this, "lockAllPickmaps"); aTileShow.setEnabled(false); // not yet implemented @@ -932,10 +941,13 @@ //aTileShow.setEnabled(mapState); aMapProperties.setEnabled(mapState); aReplace.setEnabled(mapState); - for (int direction = 0; direction < IGUIConstants.DIRECTIONS; direction++) { + for (int direction = 0; direction < directionsMap.length; direction++) { final String mtp = mapState ? mainControl.getCurrentMap().getMapArch().getTilePath(direction) : null; ACTION_FACTORY.getAction(directionsMap[direction]).setEnabled(mtp != null && mtp.length() > 0); } + for (int direction = 0; direction < directionsGo.length; direction++) { + ACTION_FACTORY.getAction(directionsGo[direction]).setEnabled(selState); + } aClear.setEnabled(selState); aCut.setEnabled(selState); aCopy.setEnabled(selState); @@ -969,6 +981,10 @@ MenuManager.getMenuManager().addMenuLocation(currentmapLocation); } + public CMapTileList getMapTileList() { + return mapTileList; + } + private final class LookAndFeelAction extends AbstractAction { private final String className; Modified: trunk/crossfire/src/cfeditor/CMapTileList.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/CMapTileList.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -53,6 +53,10 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import net.sf.gridarta.gameobject.GameObjectContainer; +import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapCursorEvent; +import net.sf.gridarta.gui.map.MapCursorListener; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -61,7 +65,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class CMapTileList extends JPanel { +public final class CMapTileList extends JPanel implements MapCursorListener { /** Serial Version UID. */ private static final long serialVersionUID = 1L; @@ -213,6 +217,17 @@ }); } + public void selectArchBelow() { + list.setSelectedIndex(list.getSelectedIndex() + 1); + } + + public void selectArchAbove() { + final int index = list.getSelectedIndex(); + if (index > 0) { + list.setSelectedIndex(index - 1); + } + } + /** * Determine the list index for a given mouse event. This function differs * from <code>list.locationTopIndex(e.getPoint())</code> in that it always @@ -309,7 +324,7 @@ } listCounter = 0; - currentSquare = mapControl.getMapModel().getMouseRightPos(); + currentSquare = mapControl.getMapCursor().getLocation(); int postSelect = -1; boolean foundSIndex = false; int sIndex = 0; @@ -375,6 +390,22 @@ return selListCounter; } + /** {@inheritDoc} */ + public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { + if (e.getSource().isActive()) { + // Position changed + setMapTileList(mainControl.getCurrentMap(), null); + } else { + // Cursor was disabled + setMapTileList(null, null); + } + } + + /** {@inheritDoc} */ + public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { + // A mode change can be ignored + } + /** CellRenderer for rendering ArchObjects on a certain map tile in a list. */ private final class MyCellRenderer extends DefaultListCellRenderer { Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -45,8 +45,14 @@ import javax.swing.ScrollPaneConstants; import net.sf.gridarta.EditOperation; import net.sf.gridarta.Size2D; +import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapCursorEvent; +import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGrid; +import net.sf.gridarta.map.MapModelEvent; +import net.sf.gridarta.map.MapModelListener; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -69,7 +75,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class CMapViewBasic extends JScrollPane { +public final class CMapViewBasic extends JScrollPane implements MapModelListener, MapCursorListener { private static final Logger log = Logger.getLogger(CMapViewBasic.class); @@ -92,15 +98,10 @@ private boolean gridVisible = false; - // this is needed to check the diamond tile areas and convert rectangles to diamond - private final Point mapMousePos = new Point(); + private MapCursor mapCursor; private final Point mapMouseRightPos = new Point(); // coordinates of selected tile on the map - private final Point mapMouseRightOff = new Point(); // offset from the selected tile while left-click draging - - private boolean highlightOn; // Is map-tile selection highlighted? true/false - private final boolean[] needMpanelUpdate; // indicates that the mapArchPanel needs private MapGrid mapGrid; @@ -120,21 +121,23 @@ //super("Map ["+control.getMapFileName()+"]", true, true, true, true); super(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); this.mapControl = mapControl; + final MapModel mapModel = mapControl.getMapModel(); + mapGrid = new MapGrid(mapModel.getMapSize()); + mapCursor = new MapCursor(mapGrid); + mapCursor.addMapCursorListener(this); + if (!mapControl.isPickmap()) { + mapCursor.addMapCursorListener(mainControl.getMainView().getMapTileList()); + mapCursor.addMapCursorListener(mainControl.getMainView().getStatusBar()); + } this.mainControl = mainControl; - mapGrid = new MapGrid(mapControl.getMapModel().getMapSize()); frame = fi; - highlightOn = false; needMpanelUpdate = new boolean[3]; needMpanelUpdate[0] = false; needMpanelUpdate[1] = false; needMpanelUpdate[2] = false; - mapMousePos.x = -1; - mapMousePos.y = -1; mapMouseRightPos.x = -1; mapMouseRightPos.y = -1; - mapMouseRightOff.x = 0; - mapMouseRightOff.y = 0; if (isPickmap()) { setBackground(IGUIConstants.BG_COLOR); @@ -143,6 +146,7 @@ setViewportView(renderer); getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); + mapModel.addMapModelListener(this); refreshDataFromModel(); // set the pixel increment scrolling for clicking once on a scrollbar arrow @@ -161,6 +165,8 @@ } renderer.updateLookAndFeel(); mapGrid.addMapGridListener(renderer); + renderer.setFocusable(true); + setFocusable(true); } public boolean isChanged() { @@ -171,10 +177,26 @@ changed = state; } - public Point getMapMouseRightPos() { - return mapMouseRightPos; + /** + * Get MapGrid of this view. + * @return MapGrid of this view. + */ + public MapGrid getMapGrid() { + return mapGrid; } + /** + * Get MapCursor of this view. + * @return MapCursor of this view. + */ + public MapCursor getMapCursor() { + return mapCursor; + } + + @Nullable public Point getCursorPosition() { + return mapCursor.getLocation(); + } + public boolean isPickmap() { return mapControl.isPickmap(); } @@ -193,17 +215,17 @@ } /** - * Returns whether there is a highlighted area in this MapView. + * Returns whether there is a highlighted area in this mapview. * @return <code>true</code> if there is a highlighted area, otherwise <code>false</code>. */ public boolean isHighlight() { - return highlightOn; + return mapCursor.isActive(); } /** Turn the highlight off. */ public void unHighlight() { - if (highlightOn) { - highlightOn = false; + if (mapCursor.isActive()) { + mapCursor.deactivate(); mainControl.getMainView().refreshMenus(); } @@ -240,23 +262,16 @@ } /** - * Returns the starting coordinates of the highlighted tile-selection. - * @return The starting coordinates of the highlighted tile-selection. + * This method returns the bounding rectangle of the selection + * There may be non-selected tiles in that rectangle + * This method is mainly useful for creating a submap for copy/paste operations. + * @return selected Rectangle */ - public Point getHighlightStart() { - return mapMouseRightPos; + public Rectangle getSelectionRec() { + return mapGrid.getSelectedRec(); } /** - * Returns the ending coordinates of the highlighted tile-selection. - * @return The ending coordinates of the highlighted tile-selection. - * @todo fix naming or comment: The method name suggests ending is relative to start, while the original description suggests its absolute. - */ - public Point getHighlightOffset() { - return mapMouseRightOff; - } - - /** * Highlight the tile at given coordinates (just as * if it had been selected with leftclick). Besides, the mapview is * always centered on the coordinates as far as possible. @@ -266,8 +281,6 @@ // set the highlighted spot: mapMouseRightPos.x = point.x; mapMouseRightPos.y = point.y; - mapMouseRightOff.x = 0; - mapMouseRightOff.y = 0; // set scroll position accordingly to center on target final Rectangle scrollto = new Rectangle((point.x + 1) * 32 + 16 - getViewport().getViewRect().width / 2, @@ -289,16 +302,15 @@ getViewport().setViewPosition(scrollto.getLocation()); //getViewport().scrollRectToVisible(scrollto); - if (!highlightOn) { - highlightOn = true; - mainControl.getMainView().refreshMenus(); - } - // repaint map to display selection mapControl.repaint(); mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), null); } + public void setCursorPosition(final Point cursorPosition) { + mapCursor.setLocation(cursorPosition); + } + /** * Convert the map into a png file. * @param file the file to write to @@ -426,15 +438,6 @@ return mapSize; } - public Point getMapMousePos() { - return mapMousePos; - } - - public void setMapMousePos(final Point point) { - mapMousePos.x = point.x; - mapMousePos.y = point.y; - } - /** The mouse listener for the view. */ public final class CListener extends MouseAdapter implements MouseMotionListener { @@ -444,16 +447,12 @@ private Rectangle previewRect = null; - private Point[] needRedraw = null; // array of tile coords which need to be redrawn - /** {@inheritDoc} */ @Override public void mousePressed(final MouseEvent e) { + requestFocus(); changedFlagNotify(); // set flag: map has changed final Point clickPoint = e.getPoint(); final Point mapLoc = renderer.getTileLocationAt(clickPoint, null); - needRedraw = null; - Point[] preRedraw = null; // array of tile coords which need to be redrawn - boolean needFullRepaint = false; // true if full repaint of map needed previewRect = null; if (mapLoc != null) { @@ -462,58 +461,60 @@ return; } - if (highlightOn) { - // if we had a selected rect, we must remove it: - if (Math.abs(mapMouseRightOff.x + 1) * Math.abs(mapMouseRightOff.y + 1) <= 16) { - // the rect is relatively small, so we remove it per-tile - preRedraw = calcRectRedraw(mapMouseRightPos.x, mapMouseRightPos.y, - mapMouseRightPos.x + mapMouseRightOff.x, - mapMouseRightPos.y + mapMouseRightOff.y); - paintTileArray(preRedraw); - needRedraw = null; - } else { - // the rect is big, we redraw the whole map later - needFullRepaint = true; - } - } - // right mouse button: insert arch if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { + mapCursor.setLocation(mapLoc); insertObject(mapLoc); } else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { - if (e.isShiftDown()) { - insertObject(mapLoc); - } else if (e.isControlDown()) { - deleteObject(mapLoc); - } else { + final boolean selChange = mapCursor.isActive(); + // Throw away old selection if CTRL is not pressed + if (!e.isControlDown()) { + mapCursor.deactivate(); + } + mapCursor.setLocation(mapLoc); + mapCursor.dragStart(); + if (mapCursor.isActive() && mapControl.isPickmap()) { + // an arch of a pickmap was selected + CMainControl.getInstance().showArchPanelQuickObject(mapControl.getMapModel().getMapSquare(mapLoc).getFirst()); + } + // Change edit menu if there was a selection before and has gone or the other way around + if (!(selChange == mapCursor.isActive())) { + CMainControl.getInstance().getMainView().refreshMenus(); + } + + if (!e.isShiftDown() && !e.isControlDown()) { selectTile(mapLoc); } } else { // middle mouse button: delete arch // (I intenionally used "else" here. BUTTON2_MASK seems not to work for some systems) + mapCursor.setLocation(mapLoc); deleteObject(mapLoc); } } else { + mapCursor.setLocation(mapLoc); mainControl.getMainView().setMapTileList(null, null); // for secure... } /* UndoAndRedo.getInstance(mapControl).add(new CPaintOp(previewRect, aOrigData, (short)mapControl.getSelectedTile())); */ endFill(); - - // finally redraw the map: - if (!needFullRepaint) { - // redraw only tiles that need an update - paintTileArray(preRedraw); - paintTileArray(needRedraw); - } else { - //repaint(); // redraw full map - renderer.modelChanged(); - } } /** {@inheritDoc} */ @Override public void mouseReleased(final MouseEvent event) { + final Point clickPoint = event.getPoint(); + final Point mapLoc = renderer.getTileLocationAt(clickPoint, null); + if (!mapCursor.isOnGrid(mapLoc)) { + mapCursor.dragRelease(); + } else if (event.isShiftDown()) { + mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); + } else if (event.isControlDown()) { + mapCursor.dragSelect(MapGrid.SelectionMode.SUB); + } else { + mapCursor.dragSelect(MapGrid.SelectionMode.ADD); + } + final int buttonNr; // Number of released mouse button if (event.getModifiers() == InputEvent.BUTTON1_MASK) { @@ -546,7 +547,6 @@ /** {@inheritDoc} */ public void mouseDragged(final MouseEvent event) { changedFlagNotify(); - Point[] needRedraw = null; // array of tile coords which need to be redrawn final Point dragPoint = event.getPoint(); // Mouse pointer Point temp = renderer.getTileLocationAt(dragPoint, null); // tile under Mouse pointer @@ -554,65 +554,45 @@ temp = new Point(-1, -1); } - if (event.getModifiers() == InputEvent.BUTTON1_MASK) { + if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { // Left Mouse Button: Selected area gets highlighted - // Update offset (from starting-dragpoint) only when mouse moved - // over new tile and mouse is still on the map - if (temp.x != -1 && temp.y != -1 && (mapMouseRightOff.x != temp.x - mapMouseRightPos.x || mapMouseRightOff.y != temp.y - mapMouseRightPos.y)) { - // update offset and redraw mapview - mapMouseRightOff.x = temp.x - mapMouseRightPos.x; - mapMouseRightOff.y = temp.y - mapMouseRightPos.y; + mapCursor.dragTo(temp); + } else if ((event.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { + mapCursor.setLocation(temp); - renderer.modelChanged(); - } - } else if (event.getModifiers() == InputEvent.BUTTON3_MASK) { // Right Mouse Button: Arches get inserted all the way - if (temp.x != mapMouseRightPos.x || mapMouseRightPos.y != temp.y) { - mapMouseRightPos.x = temp.x; - mapMouseRightPos.y = temp.y; - - if (temp.x == -1 || temp.y == -1) { - mainControl.getMainView().setMapTileList(null, null); - } else { - needRedraw = mapControl.insertSelArchToMap(temp, false); - needMpanelUpdate[2] = true; // when dragging is done, update map panel - } + if (temp.x == -1 || temp.y == -1) { + mainControl.getMainView().setMapTileList(null, null); + } else { + mapControl.insertSelArchToMap(temp, false); } } else { + mapCursor.setLocation(temp); + // Middle Mouse Button: Arches get deleted all the way - if (temp.x != mapMouseRightPos.x || mapMouseRightPos.y != temp.y) { - mapMouseRightPos.x = temp.x; - mapMouseRightPos.y = temp.y; + if (temp.x == -1 || temp.y == -1) { + mainControl.getMainView().setMapTileList(null, null); + } else { + // delete the topmost arch (matching the view settings) + // on that square and redraw the map + GameObject tmpArch = null; + final Iterator<GameObject> it = mapControl.getMapModel().getMapSquare(temp).reverse().iterator(); + for (final GameObject gameObject : mapControl.getMapModel().getMapSquare(temp).reverse()) { + tmpArch = gameObject; - if (temp.x == -1 || temp.y == -1) { - mainControl.getMainView().setMapTileList(null, null); - } else { - // delete the topmost arch (matching the view settings) - // on that square and redraw the map - GameObject tmpArch = null; - final Iterator<GameObject> it = mapControl.getMapModel().getMapSquare(temp).reverse().iterator(); - for (final GameObject gameObject : mapControl.getMapModel().getMapSquare(temp).reverse()) { - tmpArch = gameObject; - - // now search backwards for matching view settings - if (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(tmpArch.getEditType())) { - break; - } + // now search backwards for matching view settings + if (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(tmpArch.getEditType())) { + break; } - if (tmpArch != null) { - needRedraw = mapControl.calcArchRedraw(tmpArch); // get redraw info - mapControl.deleteMapArch(tmpArch, temp, false, MapModel.JOIN_ENABLE); - } - - needMpanelUpdate[1] = true; // when dragging is done, update map panel } + if (tmpArch != null) { + mapControl.calcArchRedraw(tmpArch); // get redraw info + mapControl.deleteMapArch(tmpArch, temp, false, MapModel.JOIN_ENABLE); + } } } - - // finally redraw all map-squares that need an update - paintTileArray(needRedraw); } private void insertObject(final Point mapLoc) { @@ -623,22 +603,14 @@ previewRect.height = 1; startMapLoc = mapLoc; - if (highlightOn && !mapControl.isPickmap()) { - highlightOn = false; // no longer highlighting tiles - mainControl.getMainView().refreshMenus(); - } - if (mapLoc.x != -1 && mapLoc.y != -1) { if (mapControl.isPickmap()) { // insert on pickmap - needRedraw = insertMapArchToPickmap(mapLoc); + insertMapArchToPickmap(mapLoc); } else { // insert on normal map - mapMouseRightPos.x = mapLoc.x; - mapMouseRightPos.y = mapLoc.y; + mapControl.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(); final String insertArchName; @@ -662,56 +634,22 @@ } private void selectTile(final Point mapLoc) { - // left mouse button: select tiles - mapMouseRightPos.x = mapLoc.x; // position of selected tile - mapMouseRightPos.y = mapLoc.y; - mapMouseRightOff.x = 0; // dragging offset - mapMouseRightOff.y = 0; - if (mapLoc.x == -1 || mapLoc.y == -1) { if (!mapControl.isPickmap()) { mainControl.getMainView().setMapTileList(null, null); - - if (highlightOn) { - highlightOn = false; - mainControl.getMainView().refreshMenus(); - } } } else { if (!mapControl.isPickmap()) { mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), null); } - if (!highlightOn) { - highlightOn = true; // highlight the selected area - mainControl.getMainView().refreshMenus(); - } - // paint the highlight-icon renderer.setHighlightTile(/*((JComponent)renderer).getGraphics(), */mapLoc); - - if (mapControl.isPickmap()) { - final GameObject arch = mapControl.getBottomArchObject(mapLoc); - if (arch != null) { - // an arch of a pickmap was selected - mainControl.showArchPanelQuickObject(arch); - } - } } } private void deleteObject(final Point mapLoc) { - if (highlightOn && !mapControl.isPickmap()) { - highlightOn = false; // no longer highlighting tiles - mainControl.getMainView().refreshMenus(); - } - if (mapLoc.x != -1 && mapLoc.y != -1) { - if (!mapControl.isPickmap()) { - mapMouseRightPos.x = mapLoc.x; - mapMouseRightPos.y = mapLoc.y; - } - // delete the topmost arch (matching the view settings) on that square // and redraw the map GameObject tmpArch = null; @@ -723,7 +661,7 @@ } } if (tmpArch != null) { - needRedraw = mapControl.calcArchRedraw(tmpArch); // get redraw info + mapControl.calcArchRedraw(tmpArch); // get redraw info mapControl.deleteMapArch(tmpArch, mapLoc, false, MapModel.JOIN_ENABLE); // update mapArch panel @@ -735,14 +673,10 @@ /** * 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 - * here. * @param pos tile-coordinates in pickmap * @return array of coordinates for tiles that need to be redrawn */ - private Point[] insertMapArchToPickmap(final Point pos) { - Point[] needRedraw = null; // returned array of points which need redraw - + private void insertMapArchToPickmap(final Point pos) { final MapControl currentMap = mainControl.getCurrentMap(); // insertion is only allowed for valid *empty* squares if (currentMap != null && mapControl.isPickmap() && mapControl.isPointValid(pos) && !mapControl.containsArchObject(pos)) { @@ -753,7 +687,7 @@ // insert single tile from pickmap newarch = newarch.createClone(pos.x, pos.y); mapControl.addArchObjectToMap(newarch); - needRedraw = mapControl.calcArchRedraw(newarch); + mapControl.calcArchRedraw(newarch); } else { // insert multi tile from pickmap: newarch = newarch.getHead(); @@ -782,14 +716,12 @@ newdef.resetMsgText(); newdef.addMsgText(newarch.getMsgText()); - needRedraw = mapControl.calcArchRedraw(newdef); + mapControl.calcArchRedraw(newdef); } } } } } - - return needRedraw; } void endFill() { @@ -803,6 +735,24 @@ } } + /** {@inheritDoc} */ + public void mapSizeChanged(final MapModelEvent e) { + mapGrid.resize(e.getMapModel().getMapSize()); + refreshDataFromModel(); + } + + /** {@inheritDoc} */ + public void mapSquaresChanged(final MapModelEvent e) { + modelChanged(); + // TODO: only repaint a specific region + } + + /** {@inheritDoc} */ + public void mapObjectsChanged(final MapModelEvent e) { + modelChanged(); + // TODO: only repaint a specific region + } + public final class CPaintOp implements EditOperation { final Rectangle fillRect; @@ -853,4 +803,18 @@ } } + /** {@inheritDoc} */ + public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { + final MapCursor mapCursor = e.getSource(); + if (mapCursor.isActive()) { + final Rectangle rec = renderer.getTileBounds(mapCursor.getLocation()); + renderer.scrollRectToVisible(rec); + } + } + + /** {@inheritDoc} */ + public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { + // Ignore mode change events + } + } // class CMapViewBasic Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -139,26 +139,11 @@ * @param mode defines if we have a cut, copy or paste action */ private void copyNCut(final MapControl mapControl, final Mode mode) { - final Point startp = mapControl.getMapViewFrame().getHighlightStart(); // start of highlighted rect - final Point offset = mapControl.getMapViewFrame().getHighlightOffset(); // offset of rect from startp - - if (!mapControl.getMapViewFrame().isHighlight()) { - return; // should actually never happen + final Rectangle selRec = mapControl.getMapGrid().getSelectedRec(); + if (selRec == null) { + return; } - // convert negative 'offset' into positive by flipping 'startp' - if (offset.x < 0) { - startp.x += offset.x; - offset.x = Math.abs(offset.x); - } - if (offset.y < 0) { - startp.y += offset.y; - offset.y = Math.abs(offset.y); - } - - final Rectangle selRec = new Rectangle(startp.x, startp.y, offset.x, offset.y); - assert selRec != null; - // Prepare the buffer (if it's a cut or copy) if (mode == Mode.DO_CUT || mode == Mode.DO_COPY) { if (empty) { @@ -167,8 +152,8 @@ } // recycle and resize buffer - bufWidth = Math.abs(offset.x) + 1; // new width - bufHeight = Math.abs(offset.y) + 1; // new height + bufWidth = Math.abs(selRec.width) + 1; // new width + bufHeight = Math.abs(selRec.height) + 1; // new height mapArch.setMapSize(new Size2D(bufWidth, bufHeight)); copyMap = null; // free objects (at least that is the plan and theory) copyMapCtrl = null; @@ -180,8 +165,8 @@ final Point pos = new Point(); mapControl.getMapModel().beginTransaction("Cut / Clear"); // TODO: I18N/L10N final HashSet<GameObject> gameObjectsToDelete = new HashSet<GameObject>(); - for (pos.x = startp.x; pos.x - startp.x <= offset.x; pos.x++) { - for (pos.y = startp.y; pos.y - startp.y <= offset.y; pos.y++) { + for (pos.x = selRec.x; pos.x - selRec.x <= selRec.width; pos.x++) { + for (pos.y = selRec.y; pos.y - selRec.y <= selRec.height; pos.y++) { // do the copying for one tile position: for (final GameObject gameObject : mapControl.getMapModel().getMapSquare(pos)) { // store a clone of the gameObject in the CopyBuffer @@ -189,7 +174,7 @@ // arches that don't match the view settings are ignored! if ((mode == Mode.DO_CUT || mode == Mode.DO_COPY) && gameObject.isHead() && !gameObject.isInContainer() && (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(gameObject.getEditType()))) { // copy this gameObject - final GameObject clone = gameObject.createClone(pos.x - startp.x, pos.y - startp.y); + final GameObject clone = gameObject.createClone(pos.x - selRec.x, pos.y - selRec.y); assert copyMapCtrl != null; copyMapCtrl.addArchObjectToMap(clone); } @@ -223,14 +208,12 @@ /** * Excecuting the Paste command. * @param mapControl MapControl of the active map we paste on + * @todo paste only subregions when a region is selected */ public void paste(final MapControl mapControl) { - final Point startp = mapControl.getMapViewFrame().getHighlightStart(); // start of highlighted rect + final Point startp = mapControl.getMapCursor().getLocation(); + assert startp != null; - if (!mapControl.getMapViewFrame().isHighlight()) { - return; // should actually never happen - } - // cycle through all tile coordinates which are highlighted: mapControl.getMapModel().beginTransaction("Paste"); // TODO: I18N/L10N final Point pos = new Point(); @@ -283,8 +266,8 @@ * @todo the fill density is ignored for floodfill */ public void fill(final MapControl mapControl, final boolean fillBelow, final int density) { - final Point startp = mapControl.getMapViewFrame().getHighlightStart(); // start of highlighted rect - final Point offset = mapControl.getMapViewFrame().getHighlightOffset(); // offset of rect from startp + final Rectangle selRec = mapControl.getMapGrid().getSelectedRec();; + final Point cursor = mapControl.getMapViewFrame().getView().getCursorPosition(); final Point pos = new Point(); if (!mapControl.getMapViewFrame().isHighlight()) { @@ -295,31 +278,20 @@ return; } - // If offset is zero and map-spot empty, a floodfill is done + // If selection is empty and map-spot empty, a floodfill is done final GameObject arch; - if (offset.x == 0 && offset.y == 0 && !mapControl.containsArchObject(startp)) { + if ((selRec == null || (selRec.x == 0 && selRec.height == 0)) && !mapControl.containsArchObject(cursor)) { arch = mainControl.getArchPanelHighlight(); if (arch != null) { - floodfill(mapControl, startp.x, startp.y, arch); + floodfill(mapControl, cursor.x, cursor.y, arch); } } else { - // Rectangular fill: - // convert negative 'offset' into positive by flipping 'startp' - if (offset.x < 0) { - startp.x += offset.x; - offset.x = Math.abs(offset.x); - } - if (offset.y < 0) { - startp.y += offset.y; - offset.y = Math.abs(offset.y); - } - // get the arch to fill with arch = mainControl.getArchPanelHighlight(); // cycle through all tile coordinates which are highlighted: - for (pos.x = startp.x; pos.x - startp.x <= offset.x; pos.x++) { - for (pos.y = startp.y; pos.y - startp.y <= offset.y; pos.y++) { + for (pos.x = selRec.x; pos.x - selRec.x <= selRec.width; pos.x++) { + for (pos.y = selRec.y; pos.y - selRec.y <= selRec.height; pos.y++) { if (density != -1 && density != 100 && density < MainControl.rnd.nextInt(100) + 1) { continue; } Modified: trunk/crossfire/src/cfeditor/IGUIConstants.java =================================================================== --- trunk/crossfire/src/cfeditor/IGUIConstants.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/IGUIConstants.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -214,6 +214,8 @@ String TILE_SEL_TILE = "seltile.png"; + String TILE_CURSOR = "cursor.png"; + String TILE_UNKNOWN = "unknown.png"; String TILE_NOFACE = "noface.png"; @@ -243,6 +245,14 @@ int BOTTOM = 5; + int NORTH_EAST = 4; + + int SOUTH_EAST = 5; + + int SOUTH_WEST = 6; + + int NORTH_WEST = 7; + int DIRECTIONS = 6; } // interface IGUIConstants Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -111,10 +111,6 @@ // following a bunch of wrapper methods which just pass access // to the basic mapview object 'view': - public Point getMapMouseRightPos() { - return view.getMapMouseRightPos(); - } - public JViewport getViewPort() { return view.getViewport(); } @@ -159,14 +155,6 @@ view.closeNotify(); } - public Point getHighlightStart() { - return view.getHighlightStart(); - } - - public Point getHighlightOffset() { - return view.getHighlightOffset(); - } - public void setHotspot(final Point point) { view.setHotspot(point); } @@ -226,6 +214,10 @@ view.freeMap(); } + public CMapViewBasic getView() { + return view; + } + /** Action class for selecting this window. */ public final class WindowAction extends AbstractAction { Modified: trunk/crossfire/src/cfeditor/ReplaceDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -28,6 +28,7 @@ import cfeditor.map.MapControl; import java.awt.FlowLayout; import java.awt.Point; +import java.awt.Rectangle; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; @@ -294,20 +295,11 @@ final Size2D mapSize = mapControl.getMapSize(); offset = new Point(mapSize.getWidth() - 1, mapSize.getHeight() - 1); } else { - startp = mapControl.getMapViewFrame().getHighlightStart(); // start of highlighted rect - offset = mapControl.getMapViewFrame().getHighlightOffset(); // offset of rect from startp + final Rectangle selRec = mapControl.getMapGrid().getSelectedRec(); + startp = new Point(selRec.x, selRec.y); + offset = new Point(selRec.width, selRec.height); } - // convert negative 'offset' into positive by flipping 'startp' - if (offset.x < 0) { - startp.x += offset.x; - offset.x = Math.abs(offset.x); - } - if (offset.y < 0) { - startp.y += offset.y; - offset.y = Math.abs(offset.y); - } - // cycle through all tile coordinates between startpoint and offset: final Point pos = new Point(); int replaceCount = 0; Modified: trunk/crossfire/src/cfeditor/action.properties =================================================================== --- trunk/crossfire/src/cfeditor/action.properties 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/action.properties 2006-12-16 21:30:26 UTC (rev 1115) @@ -7,11 +7,12 @@ ######## # Menus -main.menubar=file edit map pickmaps resources tools analyze view plugins window help +main.menubar=file edit map cursor pickmaps resources tools analyze view plugins window help file.menu=createNew open close - save saveAs revert createImg - options - exit edit.menu=clear cut copy paste - replace fillAbove fillBelow randFillAbove randFillBelow map.menu=autoJoin - gridVisible enterExit enterNorthMap enterEastMap enterSouthMap enterWestMap enterUpperMap enterLowerMap tileShow - mapProperties +cursor.menu=moveCursor - selectTile startStopDrag addToSelection subFromSelection releaseDrag - insertArch deleteArch - selectArchAbove selectArchBelow - archAttributes pickmaps.menu=lockAllPickmaps - addNewPickmap closePickmap - openPickmapMap - savePickmap revertPickmap resources.menu=collectArches collectSpells - viewTreasurelists tools.menu=gc @@ -21,11 +22,12 @@ window.menu=closeAll help.menu=onlineHelp about -mapwindow.menubar=mapwindowFile mapwindowEdit mapwindowMap mapwindowView +mapwindow.menubar=mapwindowFile mapwindowEdit mapwindowMap mapwindowCursor mapwindowView mapwindowFile.menu=save saveAs createImg - revert - close mapwindowEdit.menu=clear cut copy paste - replace fillAbove fillBelow randFillAbove randFillBelow mapwindowMap.menu=autoJoin - gridVisible enterExit enterNorthMap enterEastMap enterSouthMap enterWestMap enterUpperMap enterLowerMap tileShow - mapProperties +mapwindowCursor.menu=moveCursor - selectTile startStopDrag addToSelection subFromSelection releaseDrag - insertArch deleteArch - selectArchAbove selectArchBelow - archAttributes mapwindowView.menu=showMonster showExit showBackground showDoor showWall showEquipment showTreasure showConnected resetView ####### @@ -72,6 +74,10 @@ mapProperties.icon=general/Properties16 + +moveCursor.menu=goNorth goEast goSouth goWest goNorthEast goSouthEast goSouthWest goNorthWest + + addNewPickmap.icon=general/New16 closePickmap.icon=EmptySmallIcon Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-16 21:22:20 UTC (rev 1114) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -59,7 +59,7 @@ /** * The component that does the actual rendering of tiles in the palette. * Flat version. - * @author unknown (probably Ragnor) +b * @author unknown (probably Ragnor) */ public final class DefaultLevelRenderer extends LevelRenderer implements MapGridListener { @@ -132,6 +132,8 @@ } tmpIcon = new ImageIcon(); + setFocusable(true); + borderOffset = !pickmap ? 32 : 0; renderTransform = new AffineTransform(1.0f, 0.0f, 0.0f, 1.0f, (float) borderOffset, (float) borderOffset); highLightMask = new Color[]{ @@ -209,7 +211,22 @@ } } + private final Rectangle tmpRec = new Rectangle(); + /** + * Get coordinates, length and width of map tile. + * @param p Map coordinates + * @return Boundary rectangle of tile + */ + public Rectangle getTileBounds(final Point p) { + tmpRec.x = borderOffset + p.x * 32; + tmpRec.y = borderOffset + p.y * 32; + tmpRec.width = 32; + tmpRec.height = 32; + return tmpRec; + } + + /** * Paints this component. * @param grfx The graphics context to paint to. * @param isSnapshot true when this drawing is for a @@ -394,63 +411,16 @@ * @param grfx graphics context to draw in */ public void paintHighlightTile(final Graphics grfx, final Point point) { - // if tile is highlighted, draw the highlight icon: - if (mapViewBasic.isHighlight() && mapViewBasic.getMapMouseRightPos().y != -1 && mapViewBasic.getMapMouseRightPos().x != -1) { - // get rect. coords of highlighted area: top(left) and bot(tomright) corner - final int topx = Math.min(mapViewBasic.getMapMouseRightPos().x, mapViewBasic.getMapMouseRightPos().x + mapViewBasic.getHighlightOffset().x); - final int topy = Math.min(mapViewBasic.getMapMouseRightPos().y, mapViewBasic.getMapMouseRightPos().y + mapViewBasic.getHighlightOffset().y); - final int botx = Math.max(mapViewBasic.getMapMouseRightPos().x, mapViewBasic.getMapMouseRightPos().x + mapViewBasic.getHighlightOffset().x); - final int boty = Math.max(mapViewBasic.getMapMouseRightPos().y, mapViewBasic.getMapMouseRightPos().y + mapViewBasic.getHighlightOffset().y); - - // Highlight the selected square - if (point.x >= topx && point.x <= botx && point.y >= topy && point.y <= boty) { - CMainControl.getMapSelIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); - } + final int gridFlags = mapGrid.getFlags(point.x, point.y); + if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { + CMainControl.getMapSelIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); } - } - - /** - * Paints the highlighted (selected) area on the map. - * - * @param grfx graphics context of mapview - */ - public void paintHighlightArea(final Graphics grfx) { - final int signX, signY; // sign = "direction" of the dragging offset - - if (mapViewBasic.getHighlightOffset().x > 0) { - signX = 1; - } else if (mapViewBasic.getHighlightOffset().x < 0) { - signX = -1; - } else { - signX = 0; + if ((gridFlags & MapGrid.GRID_FLAG_SELECTION) != 0) { + CMainControl.getMapSelIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); } - - if (mapViewBasic.getHighlightOffset().y > 0) { - signY = 1; - } else if (mapViewBasic.getHighlightOffset().y < 0) { - signY = -1; - } else { - signY = 0; + if ((gridFlags & MapGrid.GRID_FLAG_CURSOR) != 0) { + CMainControl.getMapCursorIcon().paintIcon(this, grfx, point.x * 32, point.y * 32); } - - // Highlight all tiles that are in the rectangle between drag-start and mouse - for (int posx = mapViewBasic.getMapMouseRightPos().x; Math.abs(posx - mapViewBasic.getMapMouseRightPos().x) - <= Math.abs(mapViewBasic.getHighlightOffset().x); posx += signX) { - for (int posy = mapViewBasic.getMapMouseRightPos().y; Math.abs(posy - mapViewBasic.getMapMouseRightPos().y) - <= Math.abs(mapViewBasic.getHighlightOffset().y); posy += signY) { - // Draw the Icon: - - // Rectangular view - CMainControl.getMapSelIcon().paintIcon(this, grfx, posx * 32 + borderOffset, posy * 32 + borderOffset); - - if (signY == 0) { - break; - } - } - if (signX == 0) { - break; - } - } } /** @@ -459,9 +429,21 @@ * @param grfx Graphics for painting */ private void paintSelection(final Graphics2D grfx) { - if (mapViewBasic.isHighlight() && mapViewBasic.getMapMouseRightPos().y != -1 && mapViewBasic.getMapMouseRightPos().x != -1) { - // Highlight the selected area - paintHighlightArea(grfx); + for (int y = 0; y < mapSize.getHeight(); y++) { + for (int x = 0; x < mapSize.getWidth(); x++) { + if (grfx.hitClip(x * 32 + borderOffset, y * 32 + borderOffset, 32, 32)) { + final int gridFlags = mapGrid.getFlags(x, y); + if ((gridFlags & MapGrid.GRID_FLAG_SELECTION) != 0) { + CMainControl.getMapSelIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + } + if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { + CMainControl.getMapSelIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + } + if ((gridFlags & MapGrid.GRID_FLAG_CURSOR) != 0) { + CMainControl.getMapCursorIcon().paintIcon(this, grfx, x * 32 + borderOffset, y * 32 + borderOffset); + } + } + } } } @@ -497,16 +479,17 @@ renderTransform.inverseTransform(point, point); } catch (final NoninvertibleTransformException e) { } - mapViewBasic.setMapMousePos(new Point(-1, -1)); final Size2D mapSize = mapViewBasic.getMapControl().getMapSize(); + final int xm, ym; if (point.x >= 0 && point.x < mapSize.getWidth() * 32 && point.y >= 0 && point.y < mapSize.getHeight() * 32) { - mapViewBasic.setMapMousePos(new Point(point.x / 32, point.y / 32)); + xm = point.x / 32; + ym = point.y / 32; + } else { + xm = -1; + ym = -1; } - final int xm = mapViewBasic.getMapMousePos().x; - final int ym = mapViewBasic.getMapMousePos().y; - if (xm < 0 || xm >= mapSize.getWidth() || ym < 0 || ym >= mapSize.getHeight()) { return null; } @@ -520,13 +503,13 @@ /** {@inheritDoc} */ public void mapGridChanged(@NotNull final MapGridEvent e) { - repaint(); + modelChanged(); } /** {@inheritDoc} */ public void mapGridResized(@NotNull final MapGridEvent e) { mapSize = e.getSource().getSize(); - repaint(); + modelChanged(); } @Override public boolean resizeBackBuffer() { Added: trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/map/MapCursorControl.java 2006-12-16 21:30:26 UTC (rev 1115) @@ -0,0 +1,213 @@ +/* + * Daimonin Java Editor. + * Copyright (C) 2006 Daniel Viegas + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package cfeditor.gui.map; + +import cfeditor.CMainControl; +import cfeditor.CMainView; +import cfeditor.CMapTileList; +import cfeditor.IGUIConstants; +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapControl; +import java.awt.Point; +import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapGrid; + +/** + * This class processes events from the cursor menu. + * Moving the cursor, selecting map tiles/arches, inserting/deleting arches and open arch property dialog is supported. + * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> + */ +public class MapCursorControl { + + /** The MainControl. */ + private final CMainControl mainControl; + + /** + * Create a MapCursorControl. + * @param mainControl MainControl to use (used for getting the current map etc.) + */ + public MapCursorControl(final CMainControl mainControl) { + this.mainControl = mainControl; + } + + /** + * Move cursor to specified direction. + * @param dir Constants in #IGUIConstants + */ + public void goTo(final int dir) { + final MapCursor mapCursor = getMapCursor(); + if (mapCursor.isActive()) { + mapCursor.goTo(dir); + } else { + mapCursor.setLocation(new Point(0, 0)); + } + } + + public void goNorth() { + goTo(IGUIConstants.NORTH); + } + + public void goSouth() { + goTo(IGUIConstants.SOUTH); + } + + public void goEast() { + goTo(IGUIConstants.EAST); + } + + public void goWest() { + goTo(IGUIConstants.WEST); + } + + public void goNorthEast() { + goTo(IGUIConstants.NORTH_EAST); + } + + public void goNorthWest() { + goTo(IGUIConstants.NORTH_WEST); + } + + public void goSouthEast() { + goTo(IGUIConstants.SOUTH_EAST); + } + + public void goSouthWest() { + goTo(IGUIConstants.SOUTH_WEST); + } + + public void selectTile() { + selectTile(MapGrid.SelectionMode.FLIP); + } + + public void addToSelection() { + selectTile(MapGrid.SelectionMode.ADD); + } + + public void subFromSelection() { + selectTile(MapGrid.SelectionMode.SUB); + } + + public void insertArch() { + final MapControl mapControl = mainControl.getCurrentMap(); + assert mapControl != null; + final MapCursor mapCursor = mapControl.getMapCursor(); + assert mapCursor != null; + if (mapCursor.isActive()) { + mapControl.insertSelArchToMap(mapCursor.getLocation(), true); + mainControl.getMain... [truncated message content] |
From: <aki...@us...> - 2006-12-17 00:53:47
|
Revision: 1123 http://svn.sourceforge.net/gridarta/?rev=1123&view=rev Author: akirschbaum Date: 2006-12-16 16:53:47 -0800 (Sat, 16 Dec 2006) Log Message: ----------- Add copy/cut/paste for non-rectangular selections. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CopyBuffer.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-17 00:38:22 UTC (rev 1122) +++ trunk/crossfire/ChangeLog 2006-12-17 00:53:47 UTC (rev 1123) @@ -1,5 +1,7 @@ 2006-12-17 Andreas Kirschbaum + * Add copy/cut/paste for non-rectangular selections. + * Properly enable/disable cursor menu entries. 2006-12-16 Andreas Kirschbaum Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 00:38:22 UTC (rev 1122) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 00:53:47 UTC (rev 1123) @@ -38,7 +38,9 @@ import java.awt.event.InputEvent; import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import javax.imageio.ImageIO; import javax.swing.JScrollPane; import javax.swing.JViewport; @@ -51,6 +53,7 @@ import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; +import net.sf.gridarta.map.MapSquare; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -85,6 +88,9 @@ /** The controller of this view. */ private final MapControl mapControl; + /** The MapModel. */ + private final MapModel mapModel; + /** The CMainControl. */ private final CMainControl mainControl; @@ -121,7 +127,7 @@ //super("Map ["+control.getMapFileName()+"]", true, true, true, true); super(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); this.mapControl = mapControl; - final MapModel mapModel = mapControl.getMapModel(); + mapModel = mapControl.getMapModel(); mapGrid = new MapGrid(mapModel.getMapSize()); mapCursor = new MapCursor(mapGrid); mapCursor.addMapCursorListener(this); @@ -423,6 +429,20 @@ } } + public List<MapSquare<GameObject>> getSelectedSquares() { + final List<MapSquare<GameObject>> selection = new ArrayList<MapSquare<GameObject>>(); + final Size2D mapSize = mapModel.getMapSize(); + final Point pos = new Point(); + for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { + for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { + if ((mapGrid.getFlags(pos) & MapGrid.GRID_FLAG_SELECTION) > 0) { + selection.add(mapModel.getMapSquare(pos)); + } + } + } + return selection; + } + /** * Return the current view position. * @return the current view position Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 00:38:22 UTC (rev 1122) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 00:53:47 UTC (rev 1123) @@ -148,35 +148,32 @@ } } - // cycle through all tile coordinates which are highlighted: - final Point pos = new Point(); + final Point offset = selRec.getLocation(); mapControl.getMapModel().beginTransaction("Cut / Clear"); // TODO: I18N/L10N final HashSet<GameObject> gameObjectsToDelete = new HashSet<GameObject>(); - for (pos.x = selRec.x; pos.x - selRec.x <= selRec.width; pos.x++) { - for (pos.y = selRec.y; pos.y - selRec.y <= selRec.height; pos.y++) { - // do the copying for one tile position: - for (final GameObject gameObject : mapControl.getMapModel().getMapSquare(pos)) { - // store a clone of the gameObject in the CopyBuffer - // (for multiparts, only the heads get copied into the buffer) - // arches that don't match the view settings are ignored! - if ((mode == Mode.DO_CUT || mode == Mode.DO_COPY) && gameObject.isHead() && !gameObject.isInContainer() && (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(gameObject.getEditType()))) { - // copy this gameObject - final GameObject clone = gameObject.createClone(pos.x - selRec.x, pos.y - selRec.y); - assert copyMapCtrl != null; - copyMapCtrl.addArchObjectToMap(clone); - } + for (final MapSquare<GameObject> square : mapControl.getMapViewFrame().getView().getSelectedSquares()) { + final int posx = square.getMapX(); + final int posy = square.getMapY(); + for (final GameObject gameObject : square) { + // store a clone of the gameObject in the CopyBuffer + // (for multiparts, only the heads get copied into the buffer) + // arches that don't match the view settings are ignored! + if ((mode == Mode.DO_CUT || mode == Mode.DO_COPY) && gameObject.isHead() && !gameObject.isInContainer() && (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(gameObject.getEditType()))) { + // copy this gameObject + final GameObject clone = gameObject.createClone(posx - selRec.x, posy - selRec.y); + assert copyMapCtrl != null; + copyMapCtrl.addArchObjectToMap(clone); + } + // delete the gameObject if we have a "cut" or "clear" command + // again, arches that don't match the view settings are ignored + if ((mode == Mode.DO_CLEAR || mode == Mode.DO_CUT) && (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(gameObject.getEditType()))) { + // store next arch in tmp - // delete the gameObject if we have a "cut" or "clear" command - // again, arches that don't match the view settings are ignored - if ((mode == Mode.DO_CLEAR || mode == Mode.DO_CUT) && (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(gameObject.getEditType()))) { - // store next arch in tmp - - // delete gameObject (without redrawing the map) - // For CUT we don't delete multi tails of multis which are left or - // above the head (we would miss to copy them otherwise). - if (mode == Mode.DO_CLEAR || (gameObject.getMultiX() >= 0 && gameObject.getMultiY() >= 0)) { - gameObjectsToDelete.add(gameObject.getHead()); - } + // delete gameObject (without redrawing the map) + // For CUT we don't delete multi tails of multis which are left or + // above the head (we would miss to copy them otherwise). + if (mode == Mode.DO_CLEAR || (gameObject.getMultiX() >= 0 && gameObject.getMultiY() >= 0)) { + gameObjectsToDelete.add(gameObject.getHead()); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 12:53:54
|
Revision: 1134 http://svn.sourceforge.net/gridarta/?rev=1134&view=rev Author: akirschbaum Date: 2006-12-17 04:53:55 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Add filling of non-rectangular selections. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CopyBuffer.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-17 12:44:17 UTC (rev 1133) +++ trunk/crossfire/ChangeLog 2006-12-17 12:53:55 UTC (rev 1134) @@ -1,5 +1,7 @@ 2006-12-17 Andreas Kirschbaum + * Add filling of non-rectangular selections. + * Add copy/cut/paste for non-rectangular selections. * Properly enable/disable cursor menu entries. Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 12:44:17 UTC (rev 1133) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 12:53:55 UTC (rev 1134) @@ -429,6 +429,20 @@ } } + public Point[] getSelection() { + final List<Point> selection = new ArrayList<Point>(); + final Size2D mapSize = mapModel.getMapSize(); + final Point pos = new Point(); + for (pos.x = 0; pos.x < mapSize.getWidth(); pos.x++) { + for (pos.y = 0; pos.y < mapSize.getHeight(); pos.y++) { + if ((mapGrid.getFlags(pos) & MapGrid.GRID_FLAG_SELECTION) > 0) { + selection.add((Point) pos.clone()); + } + } + } + return selection.toArray(new Point[selection.size()]); + } + /** * Get the selected squares. * @return selected squares Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 12:44:17 UTC (rev 1133) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 12:53:55 UTC (rev 1134) @@ -245,7 +245,6 @@ final Rectangle selRec = mapControl.getMapGrid().getSelectedRec();; final Point cursor = mapControl.getMapViewFrame().getView().getCursorPosition(); - final Point pos = new Point(); if (mainControl.getArchPanelHighlight() == null) { // no selected arch to fill with return; @@ -259,19 +258,15 @@ floodfill(mapControl, cursor.x, cursor.y, arch); } } else { - // get the arch to fill with - arch = mainControl.getArchPanelHighlight(); - - // cycle through all tile coordinates which are highlighted: - for (pos.x = selRec.x; pos.x - selRec.x <= selRec.width; pos.x++) { - for (pos.y = selRec.y; pos.y - selRec.y <= selRec.height; pos.y++) { - if (density != -1 && density != 100 && density < MainControl.rnd.nextInt(100) + 1) { - continue; - } - // Insert the new arch into the map - addArchToMap(mapControl, arch, pos, false, fillBelow); + mapControl.getMapModel().beginTransaction("Fill"); // TODO; I18N/L10N + for (final Point p : mapControl.getMapViewFrame().getView().getSelection()) { + if (density != -1 && density != 100 && density < MainControl.rnd.nextInt(100) + 1) { + continue; } + final GameObject gameObject = mainControl.getArchPanelHighlight(); + addArchToMap(mapControl, gameObject, p, false, fillBelow); } + mapControl.getMapModel().endTransaction(); } // now the map and toolbars must be redrawn This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 13:22:21
|
Revision: 1136 http://svn.sourceforge.net/gridarta/?rev=1136&view=rev Author: akirschbaum Date: 2006-12-17 05:22:22 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Add replace of non-rectangular selections; make replacement of large areas much faster. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/ReplaceDialog.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-17 12:55:31 UTC (rev 1135) +++ trunk/crossfire/ChangeLog 2006-12-17 13:22:22 UTC (rev 1136) @@ -1,5 +1,8 @@ 2006-12-17 Andreas Kirschbaum + * Add replace of non-rectangular selections; make replacement of + large areas much faster. + * Add filling of non-rectangular selections. * Add copy/cut/paste for non-rectangular selections. Modified: trunk/crossfire/src/cfeditor/ReplaceDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-12-17 12:55:31 UTC (rev 1135) +++ trunk/crossfire/src/cfeditor/ReplaceDialog.java 2006-12-17 13:22:22 UTC (rev 1136) @@ -46,6 +46,7 @@ import javax.swing.JTextField; import javax.swing.WindowConstants; import net.sf.gridarta.Size2D; +import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; /** @@ -282,75 +283,62 @@ * @return number of arches that have been replaced */ private int doReplace(final int matchCriteria, final String matchString, final boolean entireMap, final boolean deleteOnly) { - if (mapControl == null) { return 0; } - // define area of effect - final Point startp; - final Point offset; - if (entireMap) { - startp = new Point(0, 0); - final Size2D mapSize = mapControl.getMapSize(); - offset = new Point(mapSize.getWidth() - 1, mapSize.getHeight() - 1); - } else { - final Rectangle selRec = mapControl.getMapGrid().getSelectedRec(); - startp = new Point(selRec.x, selRec.y); - offset = new Point(selRec.width, selRec.height); - } + mapControl.getMapModel().beginTransaction("Replace"); // TODO: I18N/L10N - // cycle through all tile coordinates between startpoint and offset: - final Point pos = new Point(); + final MapViewIFrame mapViewIFrame = mapControl.getMapViewFrame(); + assert mapViewIFrame != null; int replaceCount = 0; final ArrayList<GameObject> objectsToReplace = new ArrayList<GameObject>(); - for (pos.x = startp.x; pos.x - startp.x <= offset.x; pos.x++) { - for (pos.y = startp.y; pos.y - startp.y <= offset.y; pos.y++) { - - // find objects to replace - objectsToReplace.clear(); - for (final GameObject node : mapControl.getMapModel().getMapSquare(pos)) { - if (node.isHead() && ((matchCriteria == MATCH_ARCH_NAME && node.getArchetypeName() != null && node.getArchetypeName().equalsIgnoreCase(matchString)) || (matchCriteria == MATCH_OBJ_NAME && node.getBestName().equalsIgnoreCase(matchString)))) { - objectsToReplace.add(node); - } + for (final MapSquare<GameObject> square : entireMap ? mapControl.getMapModel() : mapViewIFrame.getView().getSelectedSquares()) { + // find objects to replace + objectsToReplace.clear(); + for (final GameObject node : square) { + if (node.isHead() && ((matchCriteria == MATCH_ARCH_NAME && node.getArchetypeName() != null && node.getArchetypeName().equalsIgnoreCase(matchString)) || (matchCriteria == MATCH_OBJ_NAME && node.getBestName().equalsIgnoreCase(matchString)))) { + objectsToReplace.add(node); } + } - // actually replace the objects - for (final GameObject objectToDelete : objectsToReplace) { - final Iterator<GameObject> it = mapControl.getMapModel().getMapSquare(pos).iterator(); - GameObject prevArch = null; - GameObject node = null; - while (it.hasNext()) { - node = it.next(); + // actually replace the objects + for (final GameObject objectToDelete : objectsToReplace) { + final Iterator<GameObject> it = square.iterator(); + GameObject prevArch = null; + GameObject node = null; + while (it.hasNext()) { + node = it.next(); - if (node == objectToDelete) { - break; - } - - prevArch = node; + if (node == objectToDelete) { + break; } - assert node != null; - // first, delete the old arch - node.remove(); + prevArch = node; + } + assert node != null; - if (replaceArch != null && !deleteOnly) { - // insert replacement object - if (replaceArch.isMulti()) { - // multi's cannot be inserted properly, so we just put them ontop - replaceArch = replaceArch.getHead(); - mapControl.addArchToMap(replaceArch.getArchetypeName(), pos, false, false); + // first, delete the old arch + node.remove(); - // TODO: if from pickmap it could have special attributes -> copy them - } else { - mapControl.insertArchToMap(replaceArch, null, prevArch, pos, false); - } + if (replaceArch != null && !deleteOnly) { + // insert replacement object + if (replaceArch.isMulti()) { + // multi's cannot be inserted properly, so we just put them ontop + replaceArch = replaceArch.getHead(); + mapControl.addArchToMap(replaceArch.getArchetypeName(), new Point(square.getMapX(), square.getMapY()), false, false); + + // TODO: if from pickmap it could have special attributes -> copy them + } else { + mapControl.insertArchToMap(replaceArch, null, prevArch, new Point(square.getMapX(), square.getMapY()), false); } - replaceCount++; } + replaceCount++; } } + mapControl.getMapModel().endTransaction(); + // now the map and toolbars must be redrawn mapControl.repaint(); mainControl.getMainView().refreshMapTileList(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 23:33:59
|
Revision: 1182 http://svn.sourceforge.net/gridarta/?rev=1182&view=rev Author: akirschbaum Date: 2006-12-17 15:33:58 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Accelerate map drawing speed. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-17 23:28:03 UTC (rev 1181) +++ trunk/crossfire/ChangeLog 2006-12-17 23:33:58 UTC (rev 1182) @@ -1,3 +1,7 @@ +2006-12-18 Andreas Kirschbaum + + * Accelerate map drawing speed. + 2006-12-17 Andreas Kirschbaum * Split fill and floodfill into separate functions in user Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 23:28:03 UTC (rev 1181) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 23:33:58 UTC (rev 1182) @@ -549,9 +549,6 @@ if (!mapControl.isPickmap()) { mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), null); } - - // paint the highlight-icon - renderer.setHighlightTile(/*((JComponent)renderer).getGraphics(), */mapLoc); } } Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-17 23:28:03 UTC (rev 1181) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-17 23:33:58 UTC (rev 1182) @@ -46,6 +46,7 @@ import net.sf.gridarta.gui.map.MapGridListener; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; +import net.sf.gridarta.map.MapSquare; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -54,6 +55,7 @@ * The component that does the actual rendering of tiles in the palette. * Flat version. * @author unknown + * @author Andreas Kirschbaum */ public final class DefaultLevelRenderer extends LevelRenderer implements MapGridListener, MapModelListener { @@ -168,10 +170,7 @@ bufGrfx.fillRect(0, 0, viewWidth, viewHeight); // paint the mapview into the image - final Point storeOffset = new Point(borderOffset); - borderOffset.setLocation(0, 0); paintComponent(bufGrfx, true); - borderOffset.setLocation(storeOffset); return bufImage; } @@ -179,16 +178,21 @@ if (isPickmap) { paintComponent(grfx, false); } else { - grfx.drawImage(backBuffer, borderOffset.x, borderOffset.y, null); + paintFromBackbuffer(grfx, 0, 0, bufferedSize.width, bufferedSize.height); } } + private void paintFromBackbuffer(final Graphics grfx, final int x, final int y, final int width, final int height) { + if (grfx == null) { + return; + } + + grfx.drawImage(backBuffer, x + borderOffset.x, y + borderOffset.y, x + borderOffset.x + width, y + borderOffset.y + height, x, y, x + width, y + height, null); + } + @Override public void modelChanged() { if (!isPickmap) { - final Point storeOffset = new Point(borderOffset); - borderOffset.setLocation(0, 0); paintComponent(backBuffer.getGraphics(), false); - borderOffset.setLocation(storeOffset); } repaint(); } @@ -244,7 +248,7 @@ * more difficult. :( * @param point Map coordinates for the tile to draw */ - @Override public void paintTile(final Point point) { + private void paintTile(final Point point) { final Graphics grfx; if (isPickmap) { grfx = getGraphics(); // graphics context for drawing in the mapview @@ -309,16 +313,16 @@ private void paintSelection(final Graphics grfx) { for (int y = 0; y < mapSize.getHeight(); y++) { for (int x = 0; x < mapSize.getWidth(); x++) { - if (grfx.hitClip(x * 32 + borderOffset.x, y * 32 + borderOffset.y, 32, 32)) { + if (grfx.hitClip(x * 32, y * 32, 32, 32)) { final int gridFlags = mapGrid.getFlags(x, y); if ((gridFlags & MapGrid.GRID_FLAG_SELECTION) != 0) { - CMainControl.getMapSelIcon().paintIcon(this, grfx, x * 32 + borderOffset.x, y * 32 + borderOffset.y); + CMainControl.getMapSelIcon().paintIcon(this, grfx, x * 32, y * 32); } if ((gridFlags & MapGrid.GRID_FLAG_SELECTING) != 0) { - CMainControl.getMapSelIcon().paintIcon(this, grfx, x * 32 + borderOffset.x, y * 32 + borderOffset.y); + CMainControl.getMapSelIcon().paintIcon(this, grfx, x * 32, y * 32); } if ((gridFlags & MapGrid.GRID_FLAG_CURSOR) != 0) { - CMainControl.getMapCursorIcon().paintIcon(this, grfx, x * 32 + borderOffset.x, y * 32 + borderOffset.y); + CMainControl.getMapCursorIcon().paintIcon(this, grfx, x * 32, y * 32); } } } @@ -335,18 +339,10 @@ // grid lines if (mapViewBasic.isGridVisible()) { for (int x = 0; x <= mapGrid.getSize().getWidth(); x++) { - grfx.drawLine( - x * 32 + borderOffset.x, - borderOffset.x, - x * 32 + borderOffset.y, - mapGrid.getSize().getHeight() * 32 + borderOffset.y); + grfx.drawLine(x * 32, 0, x * 32, mapGrid.getSize().getHeight() * 32); } for (int y = 0; y <= mapGrid.getSize().getHeight(); y++) { - grfx.drawLine( - borderOffset.x, - y * 32 + borderOffset.y, - mapGrid.getSize().getWidth() * 32 + borderOffset.x, - y * 32 + borderOffset.y); + grfx.drawLine(0, y * 32, mapGrid.getSize().getWidth() * 32, y * 32); } } } @@ -375,13 +371,21 @@ /** {@inheritDoc} */ public void mapGridChanged(@NotNull final MapGridEvent e) { - resizeMapGrid(); + final Rectangle recChange = mapGrid.getRecChange(); + for (int x = recChange.x; x < recChange.x + recChange.width; x++) { + for (int y = recChange.y; y < recChange.y + recChange.height; y++) { + paintTile(new Point(x, y)); + } + } + + if (!isPickmap) { + paintFromBackbuffer(getGraphics(), recChange.x * 32, recChange.y * 32, recChange.width * 32, recChange.height * 32); + } } /** {@inheritDoc} */ public void mapGridResized(@NotNull final MapGridEvent e) { - mapSize = e.getSource().getSize(); - modelChanged(); + resizeMapGrid(); } /** {@inheritDoc} */ @@ -391,7 +395,35 @@ /** {@inheritDoc} */ public void mapSquaresChanged(final MapModelEvent e) { - modelChanged(); + final MapSquare<GameObject>[] squares = e.getSquares(); + int minX = bufferedSize.width; + int minY = bufferedSize.height; + int maxX = 0; + int maxY = 0; + if (squares != null) { + for (final MapSquare square : squares) { + final int x = square.getMapX(); + final int y = square.getMapY(); + paintTile(new Point(x, y)); + + if (minX > x) { + minX = x; + } + if (minY > y) { + minY = y; + } + if (maxX < x) { + maxX = x; + } + if (maxY < y) { + maxY = y; + } + } + } + + if (!isPickmap && minX <= maxX && minY <= maxY) { + paintFromBackbuffer(getGraphics(), minX * 32, minY * 32, (maxX + 1 - minX) * 32, (maxY + 1 - minY) * 32); + } } /** {@inheritDoc} */ @@ -443,12 +475,12 @@ if (!mapModel.containsArchObject(point)) { if (isPickmap) { grfx.setColor(IGUIConstants.BG_COLOR); - grfx.fillRect(point.x * 32 + borderOffset.x, point.y * 32 + borderOffset.y, 32, 32); + grfx.fillRect(point.x * 32, point.y * 32, 32, 32); } else { - CMainControl.getUnknownTileIcon().paintIcon(DefaultLevelRenderer.this, grfx, point.x * 32 + borderOffset.x, point.y * 32 + borderOffset.y); + CMainControl.getUnknownTileIcon().paintIcon(DefaultLevelRenderer.this, grfx, point.x * 32, point.y * 32); } } else { - grfx.fillRect(point.x * 32 + borderOffset.x, point.y * 32 + borderOffset.y, 32, 32); + grfx.fillRect(point.x * 32, point.y * 32, 32, 32); for (final GameObject node : mapModel.getMapSquare(point)) { filter.objectInSquare(node); if (!filter.canShow(node)) { @@ -480,7 +512,7 @@ offset.y = -32 * node.getMultiY(); } } - img.paintIcon(DefaultLevelRenderer.this, grfx, point.x * 32 + borderOffset.x + offset.x, point.y * 32 + borderOffset.y + offset.y); + img.paintIcon(DefaultLevelRenderer.this, grfx, point.x * 32 + offset.x, point.y * 32 + offset.y); } } } @@ -491,7 +523,7 @@ final Color alpha = highLightMask[i]; final Color c = grfx.getColor(); grfx.setColor(alpha); - grfx.fillRect(point.x * 32 + borderOffset.x, point.y * 32 + borderOffset.y, 32, 32); + grfx.fillRect(point.x * 32, point.y * 32, 32, 32); grfx.setColor(c); } } Modified: trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java 2006-12-17 23:28:03 UTC (rev 1181) +++ trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java 2006-12-17 23:33:58 UTC (rev 1182) @@ -41,8 +41,6 @@ */ public abstract BufferedImage getFullImage(); - public abstract void paintTile(final Point point); - /** * Returns the map location at the given point or null if no map location * is at the point. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-22 16:45:06
|
Revision: 1201 http://svn.sourceforge.net/gridarta/?rev=1201&view=rev Author: akirschbaum Date: 2006-12-22 08:45:06 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Unify xml parsing. Modified Paths: -------------- trunk/crossfire/resource/conf/spells.xml trunk/crossfire/src/cfeditor/CAttribBitmask.java trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/CFArchAttrib.java trunk/crossfire/src/cfeditor/CFArchType.java trunk/crossfire/src/cfeditor/CFArchTypeList.java trunk/crossfire/src/cfeditor/Spells.java Added Paths: ----------- trunk/crossfire/resource/conf/spells.dtd Added: trunk/crossfire/resource/conf/spells.dtd =================================================================== --- trunk/crossfire/resource/conf/spells.dtd (rev 0) +++ trunk/crossfire/resource/conf/spells.dtd 2006-12-22 16:45:06 UTC (rev 1201) @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Document Type Definition External Subset for Daimonin spells file. +- Author: <a href="mailto:ch...@it...">Christian Hujer</a> +--> + +<!-- spells +- Containts: spell elements (any number) +--> +<!ELEMENT spells (spell*)> + +<!-- spell defines a single spell with its number. +- @id must be a unique number, starting with 0. +- @name must be a string +--> +<!ELEMENT spell EMPTY> +<!ATTLIST spell +id CDATA #REQUIRED +name CDATA #REQUIRED +> Property changes on: trunk/crossfire/resource/conf/spells.dtd ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/crossfire/resource/conf/spells.xml =================================================================== --- trunk/crossfire/resource/conf/spells.xml 2006-12-21 23:31:46 UTC (rev 1200) +++ trunk/crossfire/resource/conf/spells.xml 2006-12-22 16:45:06 UTC (rev 1201) @@ -1,4 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE spells SYSTEM "spells.dtd"> <spells> <!-- ########################################################## Modified: trunk/crossfire/src/cfeditor/CAttribBitmask.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribBitmask.java 2006-12-21 23:31:46 UTC (rev 1200) +++ trunk/crossfire/src/cfeditor/CAttribBitmask.java 2006-12-22 16:45:06 UTC (rev 1201) @@ -26,15 +26,15 @@ import java.awt.Component; import java.awt.GridLayout; -import java.util.List; import javax.swing.JCheckBox; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathExpressionException; +import net.sf.japi.xml.NodeListIterator; import org.apache.log4j.Logger; -import org.jdom.Attribute; -import org.jdom.DataConversionException; -import org.jdom.Element; import org.jetbrains.annotations.Nullable; +import org.w3c.dom.Element; /** * This class manages bitmask values which appear in Crossfire arch attributes. @@ -64,70 +64,18 @@ /** * Constructor of a bitmask from XML element. + * @param xpath XPath for XPath evaluation * @param bitmasksElement xml bitmask element + * @throws XPathExpressionException in case of XPath evaluation errors */ - public CAttribBitmask(final Element bitmasksElement) { - - List entries = bitmasksElement.getChildren("entry"); - if (entries != null && entries.size() > 0) { - Element elem; - - // find highest bit number - int maxBit = 0; - for (final Object entry : entries) { - elem = (Element) entry; - final Attribute a; - if ((a = elem.getAttribute("bit")) == null || elem.getAttribute("name") == null) { - log.warn("Parse error: Found bitmask entry without 'bit' or 'name'."); - elem.detach(); // remove element from DOM tree - } else { - try { - final int bit = a.getIntValue(); - if (bit > maxBit) { - maxBit = bit; // this is the highest bit so far - } - } catch (final DataConversionException e) { - log.warn("Parse error: Bitmask bit '" + a.getValue() + "' (" + elem.getAttribute("name").getValue() + ") is not an integer."); - elem.detach(); // remove element from DOM tree - } - } - } - entries = bitmasksElement.getChildren("entry"); // retake list, in case we detached some elements - - // initialize array - bitName = new String[maxBit + 2]; - - // initialize names array - the zero-bit always stays <none> - for (int i = 0; i < maxBit + 2; i++) { - bitName[i] = "<none>"; - } - - for (int i = 0; entries != null && i < entries.size(); i++) { - elem = (Element) entries.get(i); - // fill array and assign 2^i values - try { - bitName[elem.getAttribute("bit").getIntValue() + 1] = elem.getAttribute("name").getValue(); - } catch (final DataConversionException e) { - } - } - - if (log.isDebugEnabled()) { - String s = "bitmask '" + bitmasksElement.getAttribute("name") + "':"; - for (int i = 0; i < bitName.length; i++) { - s = s + " " + i + " = " + bitName[i]; - } - log.debug(s); - } - - number = bitName.length - 1; - maxvalue = (1 << (bitName.length + 1)) - 1; - } else { - // Error: this is an "empty" bitmask - log.warn("Error in \"" + IGUIConstants.TYPEDEF_FILE + "\": Found a bitmask without content!"); - bitName = new String[1]; - bitName[0] = "<none>"; - number = 0; - maxvalue = 0; + public CAttribBitmask(final XPath xpath, final Element bitmasksElement) throws XPathExpressionException { + final NodeListIterator<Element> entries = new NodeListIterator<Element>(xpath, bitmasksElement, "bmentry|entry"); + number = entries.size(); + bitName = new String[number + 1]; + maxvalue = (1 << (bitName.length + 1)) - 1; + bitName[0] = "<none>"; + for (final Element elem : entries) { + bitName[Integer.parseInt(elem.getAttribute("bit")) + 1] = elem.getAttribute("name"); } } Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-21 23:31:46 UTC (rev 1200) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-22 16:45:06 UTC (rev 1201) @@ -797,7 +797,7 @@ newAttr = new BitmaskAttrib(attrib); if (attrib.getMisc() != null && archTypeList.getBitmaskTable().containsKey(attrib.getMisc()[0])) { // fetch the bitmask data, then build the attribute panel - final CAttribBitmask bitmask = archTypeList.getBitmaskTable().get((String) (attrib.getMisc()[0])); + final CAttribBitmask bitmask = archTypeList.getBitmaskTable().get(attrib.getMisc()[0]); ((BitmaskAttrib) (DialogAttrib<JTextComponent>) newAttr).bitmask = bitmask; cLabel = new JButton(new MaskChangeAL(attrib.getNameNew() + ":", (BitmaskAttrib) (DialogAttrib<JTextComponent>) newAttr)); final JTextArea input = new JTextArea(); Modified: trunk/crossfire/src/cfeditor/CFArchAttrib.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchAttrib.java 2006-12-21 23:31:46 UTC (rev 1200) +++ trunk/crossfire/src/cfeditor/CFArchAttrib.java 2006-12-22 16:45:06 UTC (rev 1201) @@ -24,15 +24,10 @@ package cfeditor; -import java.io.BufferedReader; -import java.io.EOFException; -import java.io.IOException; -import java.io.StringReader; import net.sf.gridarta.gameobject.ArchAttribType; import org.apache.log4j.Logger; -import org.jdom.Attribute; -import org.jdom.DataConversionException; -import org.jdom.Element; +import org.w3c.dom.Attr; +import org.w3c.dom.Element; /** * This Class contains the data of one arch attribute. @@ -103,19 +98,19 @@ parseText(root); // arch syntax key - Attribute a1; - if ((a1 = root.getAttribute(XML_KEY_ARCH)) != null) { + Attr a1; + if ((a1 = root.getAttributeNode(XML_KEY_ARCH)) != null) { nameOld = a1.getValue().trim(); } // editor syntax key - if ((a1 = root.getAttribute(XML_KEY_EDITOR)) != null) { + if ((a1 = root.getAttributeNode(XML_KEY_EDITOR)) != null) { nameNew = a1.getValue().trim(); } // type name final String atype; - if ((a1 = root.getAttribute(XML_ATTR_TYPE)) != null) { + if ((a1 = root.getAttributeNode(XML_ATTR_TYPE)) != null) { atype = a1.getValue().trim(); } else { // error: no type @@ -124,10 +119,10 @@ } // input length (optional) - if ((a1 = root.getAttribute(XML_INPUT_LENGTH)) != null) { + if ((a1 = root.getAttributeNode(XML_INPUT_LENGTH)) != null) { try { - inputLength = a1.getIntValue(); - } catch (final DataConversionException de) { + inputLength = Integer.parseInt(a1.getValue()); + } catch (final NumberFormatException de) { log.error("In '" + IGUIConstants.TYPEDEF_FILE + "': Type " + typeName + " has attribute with invalid length '" + a1.getValue() + "' (must be a number)."); } } @@ -140,8 +135,8 @@ dataType = ArchAttribType.BOOL_SPEC; // parse true and false values: - a1 = root.getAttribute("true"); - final Attribute a2 = root.getAttribute("false"); + a1 = root.getAttributeNode("true"); + final Attr a2 = root.getAttributeNode("false"); if (a1 == null || a2 == null) { log.error("In '" + IGUIConstants.TYPEDEF_FILE + "': Type " + typeName + " has bool_special attribute missing 'true' or 'false' value."); return false; @@ -165,11 +160,11 @@ } 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) { + if ((a1 = root.getAttributeNode(XML_KEY_ARCH_BEGIN)) != null) { nameOld = a1.getValue().trim(); } - if ((a1 = root.getAttribute(XML_KEY_ARCH_END)) != null) { + if ((a1 = root.getAttributeNode(XML_KEY_ARCH_END)) != null) { endingOld = a1.getValue().trim(); } @@ -180,7 +175,7 @@ } else if ("fixed".equalsIgnoreCase(atype)) { // fixed attribute dataType = ArchAttribType.FIXED; - if ((a1 = root.getAttribute("value")) != null) { + if ((a1 = root.getAttributeNode("value")) != null) { nameNew = a1.getValue().trim(); } else { log.warn("In '" + IGUIConstants.TYPEDEF_FILE + "': Type " + typeName + " has fixed attribute missing 'value'."); @@ -222,6 +217,10 @@ misc[0] = listName; // store list name in misc[0] } else { log.warn("In '" + IGUIConstants.TYPEDEF_FILE + "', type " + typeName + ": List \"" + listName + "\" is undefined."); + log.error("Size of tlist: " + tlist.getListTable().size()); + for (final String key : tlist.getListTable().keySet()) { + log.error(key); + } } } else if ("doublelist".startsWith(atype)) { // got a doublelist attribute @@ -264,40 +263,7 @@ * @param root xml attribute element */ private void parseText(final Element root) { - // parse the text - if (root.getText() == null) { - text = ""; - } else { - final StringBuffer buff = new StringBuffer(""); - StringReader stream = null; - BufferedReader bfread = null; - try { - // we read the text from a stringstream line by line - stream = new StringReader(root.getText().trim()); - bfread = new BufferedReader(stream); - String line; - boolean isFirst = true; - while ((line = bfread.readLine()) != null) { - // delete extra spaces for every line seperately - buff.append(isFirst ? "" : "\n").append(line.trim()); - isFirst = false; - } - text = buff.toString(); - - bfread.close(); - stream.close(); - } catch (final EOFException e) { - // this is actually not expected to happen - text = buff.toString(); - try { - bfread.close(); - stream.close(); - } catch (final IOException ioe) { - } - } catch (final IOException e) { - log.error("In CFArchAttrib.parseText(): Cannot read from text stream."); - } - } + text = root.getTextContent().trim().replaceAll("\\s*\n\\s*", "\n"); } /** @@ -352,10 +318,6 @@ return nameOld; } - public String getEndingOld() { - return endingOld; - } - public String getNameNew() { return nameNew; } @@ -376,10 +338,6 @@ return inputLength; } - public CFArchAttrib getNext() { - return next; - } - public void setNext(final CFArchAttrib cfAttr) { next = cfAttr; } Modified: trunk/crossfire/src/cfeditor/CFArchType.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchType.java 2006-12-21 23:31:46 UTC (rev 1200) +++ trunk/crossfire/src/cfeditor/CFArchType.java 2006-12-22 16:45:06 UTC (rev 1201) @@ -30,15 +30,19 @@ import java.util.Map; import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.japi.swing.ActionFactory; +import net.sf.japi.xml.NodeListIterator; +import static net.sf.japi.xml.NodeListIterator.getFirstChild; import org.apache.log4j.Logger; -import org.jdom.Attribute; -import org.jdom.Element; +import org.w3c.dom.Attr; +import org.w3c.dom.Element; +import static org.w3c.dom.Node.ELEMENT_NODE; /** * Contains the data of one Crossfire Object-Type. * The data is read from a definitions file called 'types.txt'. * It is mainly used as info-base for the arch-attribute GUI. * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public final class CFArchType { @@ -47,8 +51,6 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - public static final String XML_TYPE = "type"; - /** Attribute Element Name. */ public static final String XML_ATTRIBUTE = "attribute"; @@ -112,6 +114,7 @@ * @param root the xml 'type' element which is going to be parsed * @param tlist archtype list * @return true if the object was parsed correctly and can be used + * @todo I'm sucking slow, improve me */ public boolean load(final Element root, final CFArchTypeList tlist) { // this vector is used to store a temporare linked list of attributes @@ -121,11 +124,7 @@ final List<String> secNames = new ArrayList<String>(); // list of section names final Map<String, String> ignoreTable = new HashMap<String, String>(); // ignore list - List<Element> children; // list of children elements - Element elem; // xml element - Attribute a1; - - if (root.getName().equalsIgnoreCase("default_type")) { + if (root.getNodeName().equalsIgnoreCase("default_type")) { // special case: default type (this one contains the default attribs) typenr = -1; typeName = "default"; @@ -136,24 +135,22 @@ } else { try { // parse the type name - typeName = root.getAttribute("name").getValue().trim(); + typeName = root.getAttribute("name").trim(); // parse the type number - typenr = Integer.parseInt(root.getAttribute("number").getValue().trim()); + typenr = Integer.parseInt(root.getAttribute("number").trim()); if (log.isDebugEnabled()) { log.debug("reading type: " + typeName + ", " + typenr); } // parse 'required' attributes - final Element required = root.getChild(XML_REQUIRED); + final Element required = getFirstChild(root, XML_REQUIRED); if (required != null) { - children = required.getChildren(XML_ATTRIBUTE); final List<String> tmp = new ArrayList<String>(); - for (int i = 0; children != null && i < children.size(); i++) { - elem = children.get(i); - a1 = elem.getAttribute(CFArchAttrib.XML_KEY_ARCH); - final Attribute a2 = elem.getAttribute(XML_VALUE); + for (final Element elem : new NodeListIterator<Element>(required, XML_ATTRIBUTE)) { + final Attr a1 = elem.getAttributeNode(CFArchAttrib.XML_KEY_ARCH); + final Attr a2 = elem.getAttributeNode(XML_VALUE); if (a1 == null || a2 == null) { log.error("In '" + XML_REQUIRED + "' element of type " + typeName + ": " + XML_ATTRIBUTE + " missing '" + CFArchAttrib.XML_KEY_ARCH + "' or '" + XML_VALUE + "'."); } else { @@ -169,18 +166,16 @@ } } catch (final NumberFormatException e) { // parsing type number failed: - log.error("In " + IGUIConstants.TYPEDEF_FILE + ": Type " + typeName + " has invalid type number '" + root.getAttribute("number").getValue() + "'."); + log.error("In " + IGUIConstants.TYPEDEF_FILE + ": Type " + typeName + " has invalid type number '" + root.getAttribute("number") + "'."); return false; } // parse 'ignore' elements - final Element signore = root.getChild(XML_IGNORE); + final Element signore = getFirstChild(root, XML_IGNORE); if (signore != null) { // load all attributes in the ignore section - children = signore.getChildren(XML_ATTRIBUTE); - for (int i = 0; children != null && i < children.size(); i++) { - elem = children.get(i); - a1 = elem.getAttribute(CFArchAttrib.XML_KEY_ARCH); + for (final Element elem : new NodeListIterator<Element>(signore, XML_ATTRIBUTE)) { + final Attr a1 = elem.getAttributeNode(CFArchAttrib.XML_KEY_ARCH); if (a1 == null) { log.error("In '" + XML_IGNORE + "' section of type " + typeName + ": " + XML_ATTRIBUTE + " missing '" + CFArchAttrib.XML_KEY_ARCH + "'."); } else { @@ -189,10 +184,8 @@ } // load attributes from ignore lists - children = signore.getChildren("ignore_list"); - for (int i = 0; children != null && i < children.size(); i++) { - elem = children.get(i); - a1 = elem.getAttribute("name"); + for (final Element elem : new NodeListIterator<Element>(signore, "ignore_list")) { + final Attr a1 = elem.getAttributeNode("name"); if (a1 == null) { log.error("In '" + XML_IGNORE + "' section of type " + typeName + ": ignore_list missing 'name'."); } else if (tlist.getIgnoreListTable().containsKey(a1.getValue().trim())) { @@ -208,43 +201,45 @@ } } - // load description - if ((elem = root.getChild(XML_DESC)) != null) { - desc = elem.getText().trim(); - } + String importName = null; + { + // load description + Element elem; + if ((elem = getFirstChild(root, XML_DESC)) != null) { + desc = elem.getTextContent().trim(); + } - // load use - if ((elem = root.getChild(XML_USE)) != null) { - use = elem.getText().trim(); - } + // load use + if ((elem = getFirstChild(root, XML_USE)) != null) { + use = elem.getTextContent().trim(); + } - // load import_type - String importName = null; - if ((elem = root.getChild(XML_IMPORT_TYPE)) != null) { - a1 = elem.getAttribute("name"); - if (a1 == null) { - log.error("In file '" + IGUIConstants.TYPEDEF_FILE + "': Type " + typeName + " has " + XML_IMPORT_TYPE + " element without 'name'."); - } else { - importName = a1.getValue().trim(); + // load import_type + if ((elem = getFirstChild(root, XML_IMPORT_TYPE)) != null) { + final Attr a1 = elem.getAttributeNode("name"); + if (a1 == null) { + throw new RuntimeException("In file '" + IGUIConstants.TYPEDEF_FILE + "': Type " + typeName + " has " + XML_IMPORT_TYPE + " element without 'name'."); + } else { + importName = a1.getValue().trim(); + } } } // now get all children and process them in order: - children = root.getChildren(); boolean inSection; - String section = "?"; - for (int i = 0; children != null && i < children.size(); i++) { - elem = children.get(i); + for (final Element elem : new NodeListIterator<Element>(root, ELEMENT_NODE)) { // attribute directly in type element - if (elem.getName().equalsIgnoreCase(XML_ATTRIBUTE)) { + if (elem.getNodeName().equalsIgnoreCase(XML_ATTRIBUTE)) { parseAttribute(elem, secNames, false, null, attrList, tlist); } // attributes in a section - if (elem.getName().equalsIgnoreCase(XML_SECTION) && !elem.getChildren().isEmpty()) { - a1 = elem.getAttribute("name"); + if (elem.getNodeName().equalsIgnoreCase(XML_SECTION) && elem.hasChildNodes()) { + final Attr a1 = elem.getAttributeNode("name"); + final String section; if (a1 == null) { log.warn("In " + IGUIConstants.TYPEDEF_FILE + ": Type " + typeName + " contains a " + XML_SECTION + " missing 'name'."); + section = "?"; inSection = false; // we'll treat the attributes as "sectionless" } else { // get section name @@ -255,13 +250,9 @@ } // parse all attributes in the section - final List<Element> schildren = elem.getChildren(); - for (int k = 0; schildren != null && k < schildren.size(); k++) { - elem = schildren.get(k); - if (elem.getName().equalsIgnoreCase(XML_ATTRIBUTE)) { - // got an attribute element possibly in a section - parseAttribute(elem, secNames, inSection, section, attrList, tlist); - } + for (final Element elem2 : new NodeListIterator<Element>(elem, XML_ATTRIBUTE)) { + // got an attribute element possibly in a section + parseAttribute(elem2, secNames, inSection, section, attrList, tlist); } } } @@ -403,7 +394,7 @@ } if (log.isDebugEnabled()) { - final Attribute a = elem.getAttribute("arch"); + final Attr a = elem.getAttributeNode("arch"); log.debug("attribute " + (a == null ? "null" : a.getValue()) + ", section " + attrib.getSecId() + " = '" + attrib.getSecName() + "'"); } } Modified: trunk/crossfire/src/cfeditor/CFArchTypeList.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-21 23:31:46 UTC (rev 1200) +++ trunk/crossfire/src/cfeditor/CFArchTypeList.java 2006-12-22 16:45:06 UTC (rev 1201) @@ -25,7 +25,7 @@ package cfeditor; import cfeditor.gameobject.GameObject; -import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -33,28 +33,39 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import net.sf.gridarta.io.IOUtils; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathExpressionException; +import javax.xml.xpath.XPathFactory; +import net.sf.japi.swing.JSAXErrorHandler; +import net.sf.japi.xml.NodeListIterator; +import static net.sf.japi.xml.NodeListIterator.getFirstChild; import org.apache.log4j.Logger; -import org.jdom.Attribute; -import org.jdom.DataConversionException; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.JDOMException; -import org.jdom.input.SAXBuilder; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; /** * This class handles all the CFArchTypes and makes them conveniently * accessible. * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public final class CFArchTypeList implements Iterable<CFArchType> { private static final Logger log = Logger.getLogger(CFArchTypeList.class); - private final CFArchType head = new CFArchType(null); // head of CFArchType list (head contains default type) - private static final Spells spells = new Spells(); + /** DocumentBuilder. */ + private DocumentBuilder documentBuilder; + + /** The XPath for using XPath. */ + private XPath xpath; + /** * Table with type numbers as keys (Integer), and type names as values (String). */ @@ -113,171 +124,145 @@ * 'types.xml'. */ CFArchTypeList() { - CFArchType cfType = head; // index of CFArchType list // initialize the arrays of "special-data" bitmaskTable = new HashMap<String, CAttribBitmask>(); listTable = new HashMap<String, List<?>>(); ignoreListTable = new HashMap<String, List<String>>(); + try { + initXML(); + spells.loadSpellsFromXML(documentBuilder); + // open ascii filestream to the xml data + loadTypesFromXML(); + } catch (final ParserConfigurationException e) { + log.error("Cannot create XML parser: " + e.getMessage()); + } + ignoreListTable = null; // this was only needed during load phase + } - spells.loadSpellsFromXML(); // load spells from file + /** + * Initialize the XML engine. + * @throws ParserConfigurationException in case the xml parser couldn't be set up + */ + private void initXML() throws ParserConfigurationException { + // TODO: Change hard coded document builder factory to user configurable settings + final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setCoalescing(true); + // dbf.setExpandEntityReferences(true); // true is default on this + dbf.setIgnoringComments(true); + dbf.setIgnoringElementContentWhitespace(true); + dbf.setNamespaceAware(true); + dbf.setValidating(true); + dbf.setXIncludeAware(true); + documentBuilder = dbf.newDocumentBuilder(); + documentBuilder.setErrorHandler(new JSAXErrorHandler(CMainControl.getInstance().getMainView())); + xpath = XPathFactory.newInstance().newXPath(); + } + private void loadTypesFromXML() { try { - // open ascii filestream to the xml data final String baseDir = IGUIConstants.CONFIG_DIR; - final BufferedReader fread = IOUtils.createReader(baseDir, IGUIConstants.TYPEDEF_FILE); - try { - // parse xml document - final SAXBuilder builder = new SAXBuilder(); - builder.setValidation(true); - final Document doc = builder.build(fread); + // parse xml document + final Document doc = documentBuilder.parse(new File(baseDir, IGUIConstants.TYPEDEF_FILE)); - // start parsing the xml - final Element root = doc.getRootElement(); - parseTypes(root); - Element elem; - Attribute a; - if (root == null || !root.getName().equalsIgnoreCase("types")) { - log.warn("File '" + IGUIConstants.TYPEDEF_FILE + "' lacks root element 'types'."); - } else { - List<Element> children; - // parse all bitmask elements - children = root.getChildren("bitmask"); - for (int i = 0; children != null && i < children.size(); i++) { - elem = children.get(i); - if (elem.getAttribute("name") == null) { - log.warn("In file '" + IGUIConstants.TYPEDEF_FILE + "': cannot load bitmask element without 'name'."); - } else { - bitmaskTable.put(elem.getAttribute("name").getValue(), new CAttribBitmask(elem)); - } - } + // start parsing the xml + final Element root = doc.getDocumentElement(); + parseBitmasks(root); + parseLists(root); + parseIgnoreLists(root); + parseDefaultType(root); + parseTypes(root); - // parse all list elements - children = root.getChildren("list"); - for (int i = 0; children != null && i < children.size(); i++) { - elem = children.get(i); - if (elem.getAttribute("name") == null) { - log.warn("In file '" + IGUIConstants.TYPEDEF_FILE + "': cannot load list element without 'name'."); - } else { - final List<?> list = parseListFromElement(elem); - if (list != null && list.size() > 0) { - listTable.put(elem.getAttribute("name").getValue(), list); - } - } - } + if (log.isInfoEnabled()) { + log.info("Loaded " + archTypeList.size() + " types from '" + IGUIConstants.TYPEDEF_FILE + "\'"); + } + } catch (final SAXException e) { + log.error("Parsing error in '" + IGUIConstants.TYPEDEF_FILE + "':\n" + e.getMessage()); + } catch (final IOException e) { + log.error("Cannot read file '" + IGUIConstants.TYPEDEF_FILE + "'!"); + } catch (final XPathExpressionException e) { + log.error("XPath error: " + e.getMessage()); + } + } - // parse default type - elem = root.getChild("default_type"); - if (elem == null) { - log.warn("In file '" + IGUIConstants.TYPEDEF_FILE + "': default_type element is missing!"); - } else { - // create a new CFArchType element - new CFArchType(head); + private void parseBitmasks(final Element root) throws XPathExpressionException { + for (final Element elem : new NodeListIterator<Element>(xpath, root, "bitmask|bitmasks/bitmask")) { + bitmaskTable.put(elem.getAttribute("name"), new CAttribBitmask(xpath, elem)); + } + } - // attach the new CFArchType element to the list - // if we manage to parse it properly from the file - if (head.load(elem, this)) { - cfType = head; - } - } - - // parse ignore lists - children = root.getChildren("ignore_list"); - for (int i = 0; children != null && i < children.size(); i++) { - elem = children.get(i); - if (elem.getAttribute("name") == null) { - log.warn("In file '" + IGUIConstants.TYPEDEF_FILE + "': cannot load ignore_list element without 'name'."); - } else { - final String lname = elem.getAttribute("name").getValue().trim(); - final List<Element> children2 = elem.getChildren(CFArchType.XML_ATTRIBUTE); - if (children2 != null && children2.size() > 0) { - // load all attribute entries - final List<String> content = new ArrayList<String>(); - for (Element aChildren2 : children2) { - elem = aChildren2; - if ((a = elem.getAttribute(CFArchAttrib.XML_KEY_ARCH)) != null) { - content.add(a.getValue().trim()); - } else { - log.warn("In file '" + IGUIConstants.TYPEDEF_FILE + "': ignore_list '" + lname + "' has " + CFArchType.XML_ATTRIBUTE + " missing '" + CFArchAttrib.XML_KEY_ARCH + "'."); - } - } - // now add the list vector to the ignoreListTable: - ignoreListTable.put(lname, content); - } - } - } - - // parse all type elements - children = root.getChildren("type"); - for (int i = 0; children != null && i < children.size(); i++) { - elem = children.get(i); - if (elem.getAttribute("name") == null || elem.getAttribute("number") == null) { - log.warn("In file '" + IGUIConstants.TYPEDEF_FILE + "': found type element without 'name' or 'number'."); - } else { - // create a new CFArchType element - final CFArchType newType = new CFArchType(head); - - // attach the new CFArchType element to the list - // if we manage to parse it properly from the file - if (newType.load(elem, this)) { - archTypeList.add(newType); - cfType = newType; - } - } - } - - if (log.isInfoEnabled()) { - log.info("Loaded " + archTypeList.size() + " types from '" + IGUIConstants.TYPEDEF_FILE + "'"); - } + private void parseLists(final Element root) throws XPathExpressionException { + for (final Element elem : new NodeListIterator<Element>(xpath, root, "list|lists/list")) { + if (elem.getAttribute("name") == null) { + throw new RuntimeException("In file '" + IGUIConstants.TYPEDEF_FILE + "': cannot load list element without 'name'."); + } else { + final List<?> list = parseListFromElement(elem); + if (list != null && list.size() > 0) { + listTable.put(elem.getAttribute("name"), list); } - } finally { - fread.close(); } - } catch (final JDOMException e) { - log.error("Parsing error in '" + IGUIConstants.TYPEDEF_FILE, e); - } catch (final IOException e) { - log.error("Cannot read file '" + IGUIConstants.TYPEDEF_FILE + "'!", e); } - - ignoreListTable = null; // this was only needed during load phase } /** * Parse a list vector from an xml list element. * @param root element to parse * @return List with data parsed from <var>root</var> + * @todo improve this comment + * @throws XPathExpressionException In case of XPath issues (should never happen). */ - private List<?> parseListFromElement(final Element root) { + private List<?> parseListFromElement(final Element root) throws XPathExpressionException { + // XXX The list created here contains altering types: Integer for even, String for odd indices. final List<Object> list = new ArrayList<Object>(); - int num; // number for list element + for (final Element elem : new NodeListIterator<Element>(xpath, root, "entry|listentry")) { + // every list entry adds value (Integer) and name (String) to the vector + try { + list.add(Integer.valueOf(elem.getAttribute("value"))); + list.add(" " + elem.getAttribute("name").trim()); + } catch (final NumberFormatException ignore) { + throw new RuntimeException("In '" + IGUIConstants.TYPEDEF_FILE + "', list " + root.getAttribute("name") + ": value '" + elem.getAttribute("value") + "' is not an integer."); + } + } + return list; + } - Element elem; - final List entries = root.getChildren("entry"); - for (int i = 0; entries != null && i < entries.size(); i++) { - elem = (Element) entries.get(i); - if (elem.getAttribute("value") == null || elem.getAttribute("name") == null) { - log.warn("In '" + IGUIConstants.TYPEDEF_FILE + "', list " + root.getAttribute("name").getValue() + ": found entry missing 'value' or 'name'."); + private void parseIgnoreLists(final Element root) throws XPathExpressionException { + for (final Element elem : new NodeListIterator<Element>(xpath, root, "ignore_list|ignorelists/ignore_list")) { + if (elem.getAttribute("name") == null) { + throw new RuntimeException("In file '" + IGUIConstants.TYPEDEF_FILE + "': cannot load ignore_list element without 'name'."); } else { - // every list entry adds value (Integer) and name (String) to the vector - try { - num = elem.getAttribute("value").getIntValue(); - 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."); + final String lname = elem.getAttribute("name").trim(); + final List<String> content = new ArrayList<String>(); + for (final Element el2 : new NodeListIterator<Element>(elem, CFArchType.XML_ATTRIBUTE)) { + final Attr a = el2.getAttributeNode(CFArchAttrib.XML_KEY_ARCH); + if (a != null) { + content.add(a.getValue().trim()); + } else { + throw new RuntimeException("In file '" + IGUIConstants.TYPEDEF_FILE + "': ignore_list '" + lname + "' has " + CFArchType.XML_ATTRIBUTE + " missing '" + CFArchAttrib.XML_KEY_ARCH + "'."); + } } + // now add the list vector to the ignoreListTable: + if (content.size() > 0) { + ignoreListTable.put(lname, content); + } } } - return list; } + private void parseDefaultType(final Element root) { + // parse default type + final Element el = getFirstChild(root, "default_type"); + if (el == null) { + throw new RuntimeException("In file '" + IGUIConstants.TYPEDEF_FILE + "': default_type element is missing!"); + } else { + defaultArchType.load(el, this); + } + } + private void parseTypes(final Element root) { // parse all type elements - final List entries = root.getChildren("type"); - for (int i = 0; entries != null && i < entries.size(); i++) { - final Element elem = (Element) entries.get(i); - final Attribute attr = elem.getAttribute("available"); - if (attr != null && !attr.getValue().equals("no")) { + for (final Element elem : new NodeListIterator<Element>(root, "type")) { + if (!"no".equals(elem.getAttribute("available"))) { // create a new CFArchType element final CFArchType newType = new CFArchType(defaultArchType); @@ -288,11 +273,7 @@ archTypeNames.put(newType.getTypeName(), newType); } } - try { - archTypeNumbers.put(elem.getAttribute("number").getIntValue(), elem.getAttribute("name").getValue()); - } catch (final DataConversionException ex) { - // ignore - } + archTypeNumbers.put(Integer.parseInt(elem.getAttribute("number")), elem.getAttribute("name")); } } Modified: trunk/crossfire/src/cfeditor/Spells.java =================================================================== --- trunk/crossfire/src/cfeditor/Spells.java 2006-12-21 23:31:46 UTC (rev 1200) +++ trunk/crossfire/src/cfeditor/Spells.java 2006-12-22 16:45:06 UTC (rev 1201) @@ -34,15 +34,15 @@ import java.util.List; import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; +import javax.xml.parsers.DocumentBuilder; import net.sf.gridarta.io.IOUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.util.filter.file.FilenameFileFilter; +import net.sf.japi.xml.NodeListIterator; 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; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; /** * This class manages the spells and spell lists. @@ -220,75 +220,61 @@ /** * Read the spells from "spells.xml" into the arrays 'spellNames' * and 'spellNumbers'. This method is called at startup. + * @param documentBuilder Document Builder to use for parsing */ - public void loadSpellsFromXML() { + public void loadSpellsFromXML(final DocumentBuilder documentBuilder) { 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]; + // parse xml document + final Document doc = documentBuilder.parse(new File(baseDir, IGUIConstants.SPELL_FILE)); - // first element is <none> - spellNames[0] = " <none>"; - spellNumbers[0] = -1; + // retrieve the spell data from the xml + final Element root = doc.getDocumentElement(); + if (root == null || !"spells".equalsIgnoreCase(root.getNodeName())) { + log.warn("File '" + IGUIConstants.SPELL_FILE + "' lacks root element 'spells'."); + } else { + final List<String> tmpSpellNames = new ArrayList<String>(); + final List<Integer> tmpSpellNumbers = new ArrayList<Integer>(); + // initialize array with appropriate size + for (final Element spellElem : new NodeListIterator<Element>(root, "spell")) { - 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."); - } - } + 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 + tmpSpellNumbers.add(Integer.parseInt(spellElem.getAttribute("id"))); + tmpSpellNames.add(spellElem.getAttribute("name").trim()); + } catch (final NumberFormatException de) { + log.warn("Parsing error in '" + IGUIConstants.SPELL_FILE + "':\n spell id '" + spellElem.getAttribute("id") + "' 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 + "'"); - } - } + // loading successful + log.info("Loaded " + tmpSpellNames.size() + " defined spells from '" + IGUIConstants.SPELL_FILE + "'"); + if (tmpSpellNames.size() == 0) { + log.warn("File '" + IGUIConstants.SPELL_FILE + "' has no content."); + } else { + tmpSpellNames.add(0, "<none>"); + tmpSpellNumbers.add(0, -1); + spellNames = tmpSpellNames.toArray(new String[tmpSpellNames.size()]); + spellNumbers = new int[tmpSpellNumbers.size()]; + // No good conversion in case of generics + for (int i = 0; i < tmpSpellNumbers.size(); i++) { + spellNumbers[i] = tmpSpellNumbers.get(i); } } - } finally { - reader.close(); } - } catch (final JDOMException e) { - log.error("Parsing error in '" + IGUIConstants.SPELL_FILE + "'", e); + } catch (final SAXException e) { + log.error("Parsing error in '" + IGUIConstants.SPELL_FILE + "':\n" + e.getMessage() + '\n'); } catch (final IOException e) { log.error("Cannot read file '" + IGUIConstants.SPELL_FILE + "'!"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-22 19:26:13
|
Revision: 1202 http://svn.sourceforge.net/gridarta/?rev=1202&view=rev Author: akirschbaum Date: 2006-12-22 11:26:11 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Remove support for loading maps with invalid width/height specifications. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/io/CMapReader.java trunk/crossfire/src/cfeditor/map/MapArchObject.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-22 16:45:06 UTC (rev 1201) +++ trunk/crossfire/ChangeLog 2006-12-22 19:26:11 UTC (rev 1202) @@ -1,3 +1,8 @@ +2006-12-22 Andreas Kirschbaum + + * Remove support for loading maps with invalid width/height + specifications. + 2006-12-21 Andreas Kirschbaum * Properly update connection view when the map changes. Modified: trunk/crossfire/src/cfeditor/io/CMapReader.java =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapReader.java 2006-12-22 16:45:06 UTC (rev 1201) +++ trunk/crossfire/src/cfeditor/io/CMapReader.java 2006-12-22 19:26:11 UTC (rev 1202) @@ -50,18 +50,6 @@ private static final Logger log = Logger.getLogger(CMapReader.class); /** - * The maximum x position of all data read from the file. - * It's used to automatically expand a map to the size of its contents in case of a map with wrongly set size. - */ - private int maxxlen; - - /** - * The maximum y position of all data read from the file. - * It's used to automatically expand a map to the size of its contents in case of a map with wrongly set size. - */ - private int maxylen; - - /** * Open a resource for reading it as a map. * @param uri URI of resource to open. * @throws FileNotFoundException in case the resource was not found. @@ -94,11 +82,6 @@ */ @Override @NotNull public List<GameObject> decodeMapFile() throws IOException { final List<GameObject> objects = super.decodeMapFile(); - // finally... here we go - // last action: if the map is bigger than the specified size in - // the maparch, we set the true size: the maxxlen/maxylen counters. - maparch.ensureMapSize(maxxlen + 1, maxylen + 1); - return objects; // return first arch of the list } @@ -195,17 +178,9 @@ gameObject.addObjectText(thisLine); // keep line, it might have a meaning after all } } else if (thisLine.startsWith("x ")) { - final int temp = Integer.parseInt(thisLine.substring(2)); - if (temp > maxxlen) { - maxxlen = temp; - } - gameObject.setMapX(temp); + gameObject.setMapX(Integer.parseInt(thisLine.substring(2))); } else if (thisLine.startsWith("y ")) { - final int temp = Integer.parseInt(thisLine.substring(2)); - if (temp > maxylen) { - maxylen = temp; - } - gameObject.setMapY(temp); + gameObject.setMapY(Integer.parseInt(thisLine.substring(2))); } else if (thisLine.startsWith("type ")) { // Arches in maps can override their default arch's type gameObject.setArchTypNr(Integer.parseInt(thisLine.substring(5))); Modified: trunk/crossfire/src/cfeditor/map/MapArchObject.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapArchObject.java 2006-12-22 16:45:06 UTC (rev 1201) +++ trunk/crossfire/src/cfeditor/map/MapArchObject.java 2006-12-22 19:26:11 UTC (rev 1202) @@ -129,17 +129,6 @@ } /** - * Ensure that the map size is at least the given size. - * @param width the new minimum map width - * @param height the new minimum map height - */ - public void ensureMapSize(final int width, final int height) { - Size2D mapSize = getMapSize(); - mapSize = new Size2D(Math.max(mapSize.getWidth(), width), Math.max(mapSize.getHeight(), height)); - setMapSize(mapSize); - } - - /** * Get whether this map is unique. * @return whether this map is unique */ @@ -345,8 +334,8 @@ String line2; // input line, includes leading and trailing white space boolean loreflag = false; // flag for lore-text boolean archflag = false; // flag for arch<->end - int width = 0; - int height = 0; + int width = 16; + int height = 16; boolean msgflag = false; // flag for map-message // read lines boolean endReached = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-22 20:37:51
|
Revision: 1205 http://svn.sourceforge.net/gridarta/?rev=1205&view=rev Author: akirschbaum Date: 2006-12-22 12:37:51 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Try harder to prevent losing unsaved maps when exiting the application or closing a map window. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-22 19:53:34 UTC (rev 1204) +++ trunk/crossfire/ChangeLog 2006-12-22 20:37:51 UTC (rev 1205) @@ -1,5 +1,8 @@ 2006-12-22 Andreas Kirschbaum + * Try harder to prevent losing unsaved maps when exiting the + application or closing a map window. + * Properly update connection view when the current map changes. * Remove support for loading maps with invalid width/height Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-22 19:53:34 UTC (rev 1204) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-22 20:37:51 UTC (rev 1205) @@ -741,22 +741,43 @@ /** Invoked when the user wants to close the current level. */ public void close() { - if (currentMap != null) { - closeLevel(currentMap, false); - if (currentMap != null) { + if (currentMap != null && closeLevel(currentMap) && currentMap != null) { + if (currentMap.getMapViewFrame() != null) { mainView.setCurrentLevelView(currentMap.getMapViewFrame()); } } } - /** Invoked when the user wants to close all levels. */ - public void closeAll() { - for (; levels.size() > 0;) { - closeLevel(currentMap, false); - if (currentMap != null) { - mainView.setCurrentLevelView(currentMap.getMapViewFrame()); + /** + * Invoked when the user wants to close the current view. + * If there is only 1 view left the level will be closed. + * @param mapViewIFrame View to close + */ + public void closeView(final MapViewIFrame mapViewIFrame) { + final MapControl mapControl = mapViewIFrame.getMapControl(); + closeLevel(mapControl); + } + + /** + * Invoked when the user wants to close all levels. + * @return <code>true</code> if all levels closed, <code>false</code> if user cancelled + */ + public boolean closeAll() { + while (levels.size() > 0) { + final MapControl mapToClose; + if (currentMap == null) { + mapToClose = levels.get(levels.size() - 1); + } else { + mapToClose = currentMap; } + if (!closeLevel(mapToClose)) { + return false; + } } + if (currentMap != null) { + mainView.setCurrentLevelView(currentMap.getMapViewFrame()); + } + return true; } /** Invoked when the user wants to close the active pickmap. */ @@ -788,6 +809,15 @@ } /** + * Closes the given level, asking the user whether to save changes. + * @param level throws level to close + * @return <code>true</code> if the level was successfully closed, otherwise <code>false</code> + */ + public boolean closeLevel(final MapControl level) { + return closeLevel(level, false); + } + + /** * Closes the given level, eventually asking the user whether to save changes. * @param level the level to close * @param forced when true, user does not get asked and changes do not get saved @@ -800,14 +830,18 @@ return false; } - if (level != null && !forced && level.isLevelChanged()) { + if (!forced && level.isLevelChanged()) { final int result = ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, "confirmSaveChanges", level.getMapArch().getMapDisplayName()); if (result == JOptionPane.YES_OPTION) { if (level.isPlainSaveEnabled()) { level.save(); } else { - saveLevelAsWanted(level); + if (!saveLevelAsWanted(level)) { + return false; + } } + } else if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) { + return false; } } @@ -1090,11 +1124,12 @@ /** * Invoked when user wants to save a level to certain file. * @param level map control of the map to be saved + * @return <code>true</code> if the user confirmed saving the map and the map was saved successfully, otherwise <code>false</code> */ - public void saveLevelAsWanted(final MapControl level) { + public boolean saveLevelAsWanted(final MapControl level) { if (level == null) { log.warn(ACTION_FACTORY.getString("saveLevelAsWithNull")); - return; + return false; } final JFileChooser fileChooser = new JFileChooser(); @@ -1120,14 +1155,18 @@ if (returnVal == JFileChooser.APPROVE_OPTION) { hasChangedDir = true; // user has chosen an active dir final File file = fileChooser.getSelectedFile(); - assert file != null; - level.saveAs(file); - level.setMapFileName(file.getName()); // window title and file name - //level.setMapName(file.getName()); // map name (internal) - level.setMapFile(file); + if (!file.exists() || ACTION_FACTORY.showConfirmDialog(mainView, JOptionPane.WARNING_MESSAGE, JOptionPane.OK_CANCEL_OPTION, "overwriteOtherFile", file.getName()) == JOptionPane.OK_OPTION) { + level.saveAs(file); + level.setMapFileName(file.getName()); // window title and file name + //level.setMapName(file.getName()); // map name (internal) + level.setMapFile(file); - currentDir = fileChooser.getCurrentDirectory(); - refreshMenusAndToolbars(); + currentDir = fileChooser.getCurrentDirectory(); + refreshMenusAndToolbars(); + } + return true; + } else { + return false; } } @@ -1262,9 +1301,13 @@ /** Invoked when user wants to exit from the program. */ public void exit() { - while (levels.size() > 0) { - closeLevel(levels.get(0), false); + if (closeAll()) { + doExit(); } + } + + /** Exits from the program. */ + void doExit() { appExitNotify(); System.exit(0); } Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-22 19:53:34 UTC (rev 1204) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-22 20:37:51 UTC (rev 1205) @@ -542,7 +542,6 @@ } mapViews.remove(mapView); - mapView.closeNotify(); mapDesktop.remove(mapView); // This is important: Removing a JInternalFrame from a JDesktopPane doesn't deselect it. // Thus it will still be referenced. To prevent a closed map from being referenced by Swing, @@ -709,7 +708,7 @@ /** {@inheritDoc} */ public void internalFrameClosing(final InternalFrameEvent event) { - removeLevelView((MapViewIFrame) event.getSource()); + mainControl.closeView((MapViewIFrame) event.getInternalFrame()); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-22 19:53:34 UTC (rev 1204) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-22 20:37:51 UTC (rev 1205) @@ -240,11 +240,6 @@ modelChanged(); } - /** Notifies that this level view is about to be closed. */ - void closeNotify() { - mapControl.viewCloseNotify(this); - } - /** * Returns the controller of this view. * @return The controller of this view. Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-22 19:53:34 UTC (rev 1204) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-22 20:37:51 UTC (rev 1205) @@ -148,10 +148,6 @@ view.setGridVisible(gridVisible); } - public void closeNotify() { - view.closeNotify(); - } - public void setCursorPosition(final Point cursorPosition) { view.setCursorPosition(cursorPosition); } Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-22 19:53:34 UTC (rev 1204) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-22 20:37:51 UTC (rev 1205) @@ -174,16 +174,6 @@ } } - /** - * Notifies that a view has been closed. - * @param view the view that was closed - */ - public void viewCloseNotify(final CMapViewBasic view) { - if (!levelClosing) { - mainControl.closeLevel(this, false); - } - } - public void levelCloseNotify() { levelClosing = true; } Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2006-12-22 19:53:34 UTC (rev 1204) +++ trunk/crossfire/src/cfeditor/messages.properties 2006-12-22 20:37:51 UTC (rev 1205) @@ -7,6 +7,8 @@ ########## # Dialogs +overwriteOtherFile.title=Overwrite file? +overwriteOtherFile.message=A file named "{0}" already exists.\n\nReally overwrite it? collectArchesNotReady.title=Arches still loading collectArchesNotReady.message=You have to wait for all arches to be loaded\nbefore you can collect them. Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2006-12-22 19:53:34 UTC (rev 1204) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2006-12-22 20:37:51 UTC (rev 1205) @@ -2,6 +2,8 @@ # See http://java.sun.com/j2se/1.5.0/docs/api/java/util/Properties.html#encoding # Dialogs +overwriteOtherFile.title=Datei \xFCberschreiben? +overwriteOtherFile.message=Eine Datei mit Namen "{0}" existiert bereits.\n\nWirklich \xFCberschreiben? collectArchesNotReady.title=Archetypen noch nicht geladen collectArchesNotReady.message=Sie m\xFCssen warten bis die Archetypen geladen\nsind, bevor Sie sie neu sammeln k\xF6nnen. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-22 21:07:14
|
Revision: 1209 http://svn.sourceforge.net/gridarta/?rev=1209&view=rev Author: akirschbaum Date: 2006-12-22 13:07:13 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Use bold font for top-level entries in treasure list viewer. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CFTreasureListTree.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-22 21:03:10 UTC (rev 1208) +++ trunk/crossfire/ChangeLog 2006-12-22 21:07:13 UTC (rev 1209) @@ -1,5 +1,7 @@ 2006-12-22 Andreas Kirschbaum + * Use bold font for top-level entries in treasure list viewer. + * Try harder to prevent losing unsaved maps when exiting the application or closing a map window. Modified: trunk/crossfire/src/cfeditor/CFTreasureListTree.java =================================================================== --- trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-22 21:03:10 UTC (rev 1208) +++ trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2006-12-22 21:07:13 UTC (rev 1209) @@ -930,6 +930,18 @@ setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0)); } + // set bold/plain font style + if (node.getParent() == root) { + if (content.getType() != TreasureObj.FOLDER) { + setFont(getFont().deriveFont(Font.BOLD)); + } + } else { + // parent is not root + final TreasureTreeNode parent = (TreasureTreeNode) node.getParent(); + if (parent.getTreasureObj().getType() == TreasureObj.FOLDER) { + setFont(getFont().deriveFont(Font.BOLD)); + } + } } return this; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-22 21:25:53
|
Revision: 1214 http://svn.sourceforge.net/gridarta/?rev=1214&view=rev Author: akirschbaum Date: 2006-12-22 13:25:53 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/IGUIConstants.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java Removed Paths: ------------- trunk/crossfire/resource/conf/typenumbers.xml Deleted: trunk/crossfire/resource/conf/typenumbers.xml =================================================================== --- trunk/crossfire/resource/conf/typenumbers.xml 2006-12-22 21:25:11 UTC (rev 1213) +++ trunk/crossfire/resource/conf/typenumbers.xml 2006-12-22 21:25:53 UTC (rev 1214) @@ -1,162 +0,0 @@ -<?xml version="1.0" standalone="yes" ?> -<!-- - ################################################################# - # This file contains the typenumbers with their associated # - # names, from the file "define.h" in the crossfire package. # - # This file should be updated when new types have been defined. # - ################################################################# ---> -<!DOCTYPE typenumbers [ - <!ELEMENT typenumbers (type*)> - - <!ELEMENT type EMPTY> - <!ATTLIST type number CDATA #REQUIRED - name CDATA #REQUIRED> -]> - -<typenumbers> - <type number="0" name="*NONE*" /> - <type number="1" name="PLAYER" /> - <type number="2" name="TRANSPORT" /> - <type number="3" name="ROD" /> - <type number="4" name="TREASURE" /> - <type number="5" name="POTION" /> - <type number="6" name="FOOD" /> - <type number="7" name="POISON" /> - <type number="8" name="BOOK" /> - <type number="9" name="CLOCK" /> - <!--<type number="10" name="FBULLET" />--> - <!--<type number="11" name="FBALL" />--> - <type number="12" name="LIGHTNING" /> - <type number="13" name="ARROW" /> - <type number="14" name="BOW" /> - <type number="15" name="WEAPON" /> - <type number="16" name="ARMOUR" /> - <type number="17" name="PEDESTAL" /> - <type number="18" name="ALTAR" /> - <!--<type number="19" name="CONFUSION" />--> - <type number="20" name="LOCKED_DOOR" /> - <type number="21" name="SPECIAL_KEY" /> - <type number="22" name="MAP" /> - <type number="23" name="DOOR" /> - <type number="24" name="KEY" /> - <!--<type number="25" name="MMISSILE" />--> - <type number="26" name="TIMED_GATE" /> - <type number="27" name="TRIGGER" /> - <type number="28" name="GRIMREAPER" /> - <type number="29" name="MAGIC_EAR" /> - <type number="30" name="TRIGGER_BUTTON" /> - <type number="31" name="TRIGGER_ALTAR" /> - <type number="32" name="TRIGGER_PEDESTAL" /> - <type number="33" name="SHIELD" /> - <type number="34" name="HELMET" /> - <type number="35" name="HORN" /> - <type number="36" name="MONEY" /> - <type number="37" name="CLASS" /> - <type number="38" name="GRAVESTONE" /> - <type number="39" name="AMULET" /> - <type number="40" name="PLAYERMOVER" /> - <type number="41" name="TELEPORTER" /> - <type number="42" name="CREATOR" /> - <type number="43" name="SKILL" /> - <type number="44" name="EXPERIENCE" /> - <type number="45" name="EARTHWALL" /> - <type number="46" name="GOLEM" /> - <!--<type number="47" name="BOMB" />--> - <type number="48" name="THROWN_OBJ" /> - <type number="49" name="BLINDNESS" /> - <type number="50" name="GOD" /> - <type number="51" name="DETECTOR" /> - <type number="52" name="TRIGGER_MARKER" /> - <type number="53" name="DEAD_OBJECT" /> - <type number="54" name="DRINK" /> - <type number="55" name="MARKER" /> - <type number="56" name="HOLY_ALTAR" /> - <type number="57" name="PLAYER_CHANGER" /> - <type number="58" name="BATTLEGROUND" /> - <type number="59" name="PEACEMAKER" /> - <type number="60" name="GEM" /> - <!--<type number="61" name="FIRECHEST" />--> - <type number="62" name="FIREWALL" /> - <type number="63" name="ANVIL" /> - <type number="64" name="CHECK_INV" /> - <type number="65" name="MOOD_FLOOR" /> - <type number="66" name="EXIT" /> - <type number="67" name="ENCOUNTER" /> - <type number="68" name="SHOP_FLOOR" /> - <type number="69" name="SHOP_MAT" /> - <type number="70" name="RING" /> - <type number="71" name="FLOOR" /> - <type number="72" name="FLESH" /> - <type number="73" name="INORGANIC" /> - <type number="74" name="SKILL_TOOL" /> - <type number="75" name="LIGHTER" /> - <type number="76" name="TRAP_PART" /> - <type number="77" name="WALL" /> - <type number="78" name="LIGHT_SOURCE" /> - <type number="79" name="MISC_OBJECT" /> - <type number="80" name="MONSTER" /> - <type number="81" name="SPAWN_GENERATOR" /> - <type number="82" name="LAMP" /> - <type number="83" name="DUPLICATOR" /> - <type number="84" name="TOOL" /> - <type number="85" name="SPELLBOOK" /> - <type number="86" name="BUILDFAC" /> - <type number="87" name="CLOAK" /> - <!--<type number="88" name="CONE" />--> - <!--<type number="89" name="AURA" />--> - <type number="90" name="SPINNER" /> - <type number="91" name="GATE" /> - <type number="92" name="BUTTON" /> - <type number="93" name="CF_HANDLE" /> - <type number="94" name="HOLE" /> - <type number="95" name="TRAPDOOR" /> - <!--<type number="96" name="WORD_OF_RECALL" />--> - <!--<type number="97" name="PARAIMAGE" />--> - <type number="98" name="SIGN" /> - <type number="99" name="BOOTS" /> - <type number="100" name="GLOVES" /> - <type number="101" name="SPELL" /> - <type number="102" name="SPELL_EFFECT" /> - <type number="103" name="CONVERTER" /> - <type number="104" name="BRACERS" /> - <type number="105" name="POISONING" /> - <type number="106" name="SAVEBED" /> - <type number="107" name="POISONCLOUD" /> - <type number="108" name="FIREHOLES" /> - <type number="109" name="WAND" /> - <!--<type number="110" name="ABILITY" />--> - <type number="111" name="SCROLL" /> - <type number="112" name="DIRECTOR" /> - <type number="113" name="GIRDLE" /> - <type number="114" name="FORCE" /> - <type number="115" name="POTION_EFFECT" /> - - <type number="121" name="CLOSE_CON" /> - <type number="122" name="CONTAINER" /> - <type number="123" name="ARMOUR_IMPROVER" /> - <type number="124" name="WEAPON_IMPROVER" /> - - <type number="130" name="SKILLSCROLL" /> - - <type number="138" name="DEEP_SWAMP" /> - <type number="139" name="IDENTIFY_ALTAR" /> - - <!--<type number="141" name="CANCELLATION" />--> - - <type number="150" name="MENU" /> - <!--<type number="151" name="BALL_LIGHTNING" />--> - - <!--<type number="153" name="SWARM_SPELL" />--> - <type number="154" name="RUNE" /> - <type number="155" name="TRAP" /> - <type number="156" name="POWER_CRYSTAL" /> - <type number="157" name="CORPSE" /> - <type number="158" name="DISEASE" /> - <type number="159" name="SYMPTOM" /> - <type number="160" name="BUILDER" /> - <type number="161" name="MATERIAL" /> - <type number="162" name="GPS" /> - <type number="163" name="ITEM_TRANSFORMER" /> - <type number="164" name="QUEST" /> -</typenumbers> Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-22 21:25:11 UTC (rev 1213) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-22 21:25:53 UTC (rev 1214) @@ -253,10 +253,6 @@ animationObjects = new AnimationObjects(); faceObjects = new FaceObjects(); - // read in the type & type field definitions - archetypeParser.loadTypeNumbers(); - //loadTypeDef(); - // load the list with archtype-data from "types.txt" typeList = new CFArchTypeList(); Modified: trunk/crossfire/src/cfeditor/IGUIConstants.java =================================================================== --- trunk/crossfire/src/cfeditor/IGUIConstants.java 2006-12-22 21:25:11 UTC (rev 1213) +++ trunk/crossfire/src/cfeditor/IGUIConstants.java 2006-12-22 21:25:53 UTC (rev 1214) @@ -141,8 +141,6 @@ // name of the configuration files: String SPELL_FILE = "spells.xml"; // spell-numbers - String TYPENR_FILE = "typenumbers.xml"; // type-numbers - String TYPEDEF_FILE = "types.xml"; // type-definitions String ARCH_FILE = "archetypes"; // file with all arches Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-12-22 21:25:11 UTC (rev 1213) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-12-22 21:25:53 UTC (rev 1214) @@ -37,11 +37,6 @@ import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; import net.sf.gridarta.io.IOUtils; 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; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -59,9 +54,6 @@ /** Logger. */ private static final Logger log = Logger.getLogger(ArchetypeParser.class); - // table with type numbers as keys (Integer), and type names as values (String) - private Map<Integer,String> archTypeNumbers; - private final CMainControl mainControl; /** @@ -70,86 +62,8 @@ */ public ArchetypeParser(final CMainControl mainControl) { this.mainControl = mainControl; - archTypeNumbers = null; } - /** - * Parse the typenumbers file (associate names with type numbers) - * Type numbers and names are stored as key-value pairs in the - * Hashtable 'archTypeNumbers'. - */ - public void loadTypeNumbers() { - archTypeNumbers = new HashMap<Integer,String>(); - - try { - // open reading stream to the spells xml file - final String baseDir = IGUIConstants.CONFIG_DIR; - final BufferedReader reader = IOUtils.createReader(baseDir, IGUIConstants.TYPENR_FILE); - try { - - // parse xml document - final SAXBuilder builder = new SAXBuilder(); - builder.setValidation(true); - final Document doc = builder.build(reader); - - // retrieve the spell data from the xml - final Element root = doc.getRootElement(); - if (root == null || !"typenumbers".equalsIgnoreCase(root.getName())) { - log.warn("File '" + IGUIConstants.TYPENR_FILE + "' lacks root element 'typenumbers'."); - } else { - final List types = root.getChildren("type"); - if (types == null || types.size() == 0) { - log.warn("File '" + IGUIConstants.TYPENR_FILE + "' has no content."); - } else { - // process all 'type' elements from the xml file - int i; - for (i = 0; i < types.size(); i++) { - final Element typeElem = (Element) types.get(i); - - if (typeElem.getAttribute("number") == null) { - log.warn("In File '" + IGUIConstants.TYPENR_FILE + "': Found 'type' element without 'number'"); - } else if (typeElem.getAttribute("name") == null) { - log.warn("In File '" + IGUIConstants.TYPENR_FILE + "': Found 'type' element without 'name'"); - } else { - try { - // parse type number and -name, then add it to the table 'archTypeNumbers' - archTypeNumbers.put(typeElem.getAttribute("number").getIntValue(), typeElem.getAttribute("name").getValue()); - } catch (final DataConversionException de) { - log.error("In '" + IGUIConstants.TYPENR_FILE + "':\n type number '" + typeElem.getAttribute("number").getValue() + "' is not an integer."); - } - } - } - - // loading successful - if (log.isInfoEnabled()) { - log.info("" + i + " typenumbers loaded."); - } - } - } - } finally { - reader.close(); - } - } catch (final JDOMException e) { - log.error("Parsing error in '" + IGUIConstants.TYPENR_FILE + "'", e); - } catch (final FileNotFoundException e) { - log.error("Cannot read file '" + IGUIConstants.TYPENR_FILE + "'!", e); - } catch (final IOException e) { - log.error("Error while reading file '" + IGUIConstants.TYPENR_FILE + "'!", e); - } - } - - /** - * Lookup the name of an archtype. - * @param index type number - * @return name of this type, as defined in "typenumbers.xml" - */ - public String getArchTypeName(final int index) { - if (archTypeNumbers != null && archTypeNumbers.containsKey(index)) { - return archTypeNumbers.get(index); - } - return "*UNKNOWN" + index + "*"; // this type is unknown - } - /** {@inheritDoc} */ public void parseArchetype(final String fname, @NotNull final String panelName, @NotNull final String folderName) { //Open the file for reading This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-22 22:00:31
|
Revision: 1216 http://svn.sourceforge.net/gridarta/?rev=1216&view=rev Author: akirschbaum Date: 2006-12-22 14:00:27 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Use ActionFactor to create toolbar. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/action.properties trunk/crossfire/src/cfeditor/messages.properties trunk/crossfire/src/cfeditor/messages_de.properties Added Paths: ----------- trunk/crossfire/resource/icons/navigation/ trunk/crossfire/resource/icons/navigation/Back16.gif trunk/crossfire/resource/icons/navigation/Forward16.gif Removed Paths: ------------- trunk/crossfire/src/cfeditor/CMainToolbar.java Added: trunk/crossfire/resource/icons/navigation/Back16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/navigation/Back16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/crossfire/resource/icons/navigation/Forward16.gif =================================================================== (Binary files differ) Property changes on: trunk/crossfire/resource/icons/navigation/Forward16.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Deleted: trunk/crossfire/src/cfeditor/CMainToolbar.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainToolbar.java 2006-12-22 21:32:21 UTC (rev 1215) +++ trunk/crossfire/src/cfeditor/CMainToolbar.java 2006-12-22 22:00:27 UTC (rev 1216) @@ -1,341 +0,0 @@ -/* - * Crossfire Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package cfeditor; - -import java.awt.Dimension; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.InputEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.Enumeration; -import java.util.Vector; -import javax.swing.ButtonGroup; -import javax.swing.JButton; -import javax.swing.JPopupMenu; -import javax.swing.JRadioButtonMenuItem; -import javax.swing.JToolBar; -import javax.swing.SwingConstants; -import org.jetbrains.annotations.Nullable; - -/** - * <code>CMainTolbar</code> implements the main toolbar of the application. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - */ -public final class CMainToolbar extends JToolBar { - - /** The key used to store the icons/labels setting to the INI file. */ - public static final String SHOW_ICONS_AND_LABELS_KEY = "MainToolbar.iconsAndLabels"; - - /** Enumerated icons/labels mode. Shows both icons and labels. */ - public static final int SHOW_ICONS_AND_LABELS = 0; - - /** Enumerated icons/labels mode. Shows only icons. */ - public static final int SHOW_ICONS_ONLY = 1; - - /** Enumerated icons/labels mode. Shows only labels. */ - public static final int SHOW_LABELS_ONLY = 2; - - /** The controller of this toolbar view. */ - private final CMainControl mainControl; - - /** The current icon/labels mode. */ - private int eIconAndLabelVisibility = SHOW_ICONS_ONLY; - - /** The popup menu. */ - private final CPopupMenu popupMenu; - - private JButton save; - - private JButton saveAs; - - private static final long serialVersionUID = 1L; - - /** - * Constructs a new toolbar. - * @param mainControl The controller of this toolbar. - */ - CMainToolbar(final CMainControl mainControl) { - super(SwingConstants.VERTICAL); // construct with vertical alignment - this.mainControl = mainControl; - - eIconAndLabelVisibility = Integer.parseInt(CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(SHOW_ICONS_AND_LABELS_KEY, "" + SHOW_ICONS_ONLY)); - popupMenu = new CPopupMenu(); - addMouseListener( - new MouseAdapter() { - @Override public void mousePressed(final MouseEvent event) { - if ((event.getModifiers() & InputEvent.META_MASK) != 0) { - popupMenu.show(CMainToolbar.this, event.getX(), event.getY()); - } - } - }); - - rebuild(); - } - - /** - * Returns the text if it should be visible, otherwise <code>null</code>. - * @param label The label text. - * @return The label text or null if labels should not be visible. - */ - @Nullable private String filterLabel(final String label) { - return eIconAndLabelVisibility == SHOW_ICONS_ONLY ? null : label; - } - - /** - * Returns the icon name if it should be visible, otherwise <code>null</code>. - * @param iconName The icon name. - * @return The icon name or null if icons should not be visible. - */ - @Nullable private String filterIconName(final String iconName) { - return eIconAndLabelVisibility == SHOW_LABELS_ONLY ? null : iconName; - } - - /** - * Rebuilds the toolbar by first removing the buttons and - * then adding them again. - */ - private void rebuild() { - removeAll(); - - setMargin(new Insets(IGUIConstants.DIALOG_INSETS, 0, IGUIConstants.DIALOG_INSETS, IGUIConstants.DIALOG_INSETS)); - - final Vector<JButton> buttons = new Vector<JButton>(10, 2); - final JButton newButton = new CFancyButton( - filterLabel("New"), - "New Map", - filterIconName(IGUIConstants.NEW_LEVEL_ICON), - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.createNew(); - } - }); - newButton.setVerticalTextPosition(SwingConstants.BOTTOM); - newButton.setHorizontalTextPosition(SwingConstants.CENTER); - buttons.addElement(newButton); - add(newButton); - - final JButton open = new CFancyButton( - filterLabel("Open"), - "Open Map File", - filterIconName(IGUIConstants.OPEN_LEVEL_ICON), - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.open(); - } - }); - open.setVerticalTextPosition(SwingConstants.BOTTOM); - open.setHorizontalTextPosition(SwingConstants.CENTER); - buttons.addElement(open); - add(open); - - save = new CFancyButton( - filterLabel("Save"), - "Save Map File", - filterIconName(IGUIConstants.SAVE_LEVEL_ICON), - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.save(); - } - }); - save.setVerticalTextPosition(SwingConstants.BOTTOM); - save.setHorizontalTextPosition(SwingConstants.CENTER); - buttons.addElement(save); - add(save); - - saveAs = new CFancyButton( - filterLabel("Save As"), - "Save Map File As", - filterIconName(IGUIConstants.SAVE_LEVEL_AS_ICON), - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.saveAs(); - } - }); - saveAs.setVerticalTextPosition(SwingConstants.BOTTOM); - saveAs.setHorizontalTextPosition(SwingConstants.CENTER); - buttons.addElement(saveAs); - add(saveAs); - - addSeparator(); - - final JButton prevWindow = new CFancyButton( - filterLabel("Prev"), - "Show Previous Window", - filterIconName(IGUIConstants.PREVIOUS_WINDOW_ICON), - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.prevWindow(); - } - }); - prevWindow.setVerticalTextPosition(SwingConstants.BOTTOM); - prevWindow.setHorizontalTextPosition(SwingConstants.CENTER); - buttons.addElement(prevWindow); - add(prevWindow); - - final JButton nextWindow = new CFancyButton( - filterLabel("Next"), - "Show Next Window", - filterIconName(IGUIConstants.NEXT_WINDOW_ICON), - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - mainControl.nextWindow(); - } - }); - nextWindow.setVerticalTextPosition(SwingConstants.BOTTOM); - nextWindow.setHorizontalTextPosition(SwingConstants.CENTER); - buttons.addElement(nextWindow); - add(nextWindow); - - doLayout(); - - // If icons and labels are visible make buttons square shaped - if (eIconAndLabelVisibility == SHOW_ICONS_AND_LABELS) { - int maxWidth = 16; - for (Enumeration<JButton> enu = buttons.elements(); - enu.hasMoreElements();) { - final JButton button = enu.nextElement(); - maxWidth = Math.max(maxWidth, button.getWidth()); - } - - for (final Enumeration<JButton> enu = buttons.elements(); enu.hasMoreElements();) { - final JButton button = enu.nextElement(); - final Dimension size = new Dimension(maxWidth, maxWidth); - button.setSize(size); - button.setMinimumSize(size); - button.setMaximumSize(size); - button.setPreferredSize(size); - } - } - - refresh(); - doLayout(); - repaint(); - mainControl.refreshMainView(); - } - - /** - * Sets the icon and label visibility. - * @param eVisibility One of the enumerated SHOW_xxx values. - */ - void setIconAndLabelVisibility(final int eVisibility) { - switch (eVisibility) { - case SHOW_ICONS_AND_LABELS: - case SHOW_ICONS_ONLY: - case SHOW_LABELS_ONLY: - eIconAndLabelVisibility = eVisibility; - CSettings.getInstance(IGUIConstants.APP_NAME).setProperty(SHOW_ICONS_AND_LABELS_KEY, "" + eVisibility); - break; - - default: - return; - } - - rebuild(); - } - - /** Refreshes the state of items in this toolbar. */ - void refresh() { - final boolean fLevelEdited = mainControl.isLevelEdited(); - save.setEnabled(mainControl.isPlainSaveEnabled()); - saveAs.setEnabled(fLevelEdited); - } - - /** - * The popup menu that is shown on right click - * upon this toolbar. - */ - public final class CPopupMenu extends JPopupMenu { - - final JRadioButtonMenuItem iconsAndLabels; - - final JRadioButtonMenuItem iconsOnly; - - final JRadioButtonMenuItem labelsOnly; - - final ButtonGroup group; - - private static final long serialVersionUID = 1L; - - /** Constructs the popup menu with the appropriate menuitems. */ - public CPopupMenu() { - group = new ButtonGroup(); - iconsAndLabels = new JRadioButtonMenuItem("Icons&Labels"); - iconsAndLabels.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - setIconAndLabelVisibility(SHOW_ICONS_AND_LABELS); - } - }); - group.add(iconsAndLabels); - add(iconsAndLabels); - iconsOnly = new JRadioButtonMenuItem("Icons"); - iconsOnly.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - setIconAndLabelVisibility(SHOW_ICONS_ONLY); - } - }); - group.add(iconsOnly); - add(iconsOnly); - labelsOnly = new JRadioButtonMenuItem("Labels"); - labelsOnly.addActionListener( - new ActionListener() { - public void actionPerformed(final ActionEvent event) { - setIconAndLabelVisibility(SHOW_LABELS_ONLY); - } - }); - group.add(labelsOnly); - add(labelsOnly); - - refresh(); - } - - /** Refreshes the states of the menuitems. */ - void refresh() { - switch (eIconAndLabelVisibility) { - case SHOW_ICONS_AND_LABELS: - group.setSelected(iconsAndLabels.getModel(), true); - group.setSelected(iconsOnly.getModel(), false); - group.setSelected(labelsOnly.getModel(), false); - break; - - case SHOW_ICONS_ONLY: - group.setSelected(iconsAndLabels.getModel(), false); - group.setSelected(iconsOnly.getModel(), true); - group.setSelected(labelsOnly.getModel(), false); - break; - - case SHOW_LABELS_ONLY: - group.setSelected(iconsAndLabels.getModel(), false); - group.setSelected(iconsOnly.getModel(), false); - group.setSelected(labelsOnly.getModel(), true); - break; - } - } - } -} Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-22 21:32:21 UTC (rev 1215) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-22 22:00:27 UTC (rev 1216) @@ -117,9 +117,6 @@ /** The controller of this view. */ private static final CMainControl mainControl = CMainControl.getInstance(); - /** The main toolbar. */ - private CMainToolbar toolBar; - /** The main statusbar. */ private CMainStatusbar statusBar; @@ -276,9 +273,7 @@ mainControl.getFilterControl().createMenuEntries(menuAnalyze); } - toolBar = new CMainToolbar(mainControl); - //getContentPane().add(toolBar, BorderLayout.NORTH); - getContentPane().add(toolBar, BorderLayout.WEST); // put it left + add(ACTION_FACTORY.createToolBar("main"), BorderLayout.NORTH); // set bounds (location and size) of the main frame setBounds(x, y, width, height); @@ -473,7 +468,6 @@ archPanel.refresh(); mapTileList.refresh(); mapArchPanel.refresh(); - toolBar.refresh(); statusBar.refresh(); refresh3(); @@ -828,7 +822,7 @@ private final String[] directionsMap = {"enterNorthMap", "enterEastMap", "enterSouthMap", "enterWestMap", "enterUpperMap", "enterLowerMap"}; private void initActions() { - ACTION_FACTORY.createActions(true, mainControl, "createNew", "open", "options", "exit", "gc", "onlineHelp", "about"); + ACTION_FACTORY.createActions(true, mainControl, "createNew", "open", "options", "exit", "gc", "prevWindow", "nextWindow", "onlineHelp", "about"); ACTION_FACTORY.createActions(true, mainControl.getScriptController().getView(), "editPlugins", "savePlugins", "exportPluginAs", "importPlugin"); ACTION_FACTORY.createActions(true, mainControl, directionsMap); ACTION_FACTORY.createActions(true, this, "resetView"); Modified: trunk/crossfire/src/cfeditor/action.properties =================================================================== --- trunk/crossfire/src/cfeditor/action.properties 2006-12-22 21:32:21 UTC (rev 1215) +++ trunk/crossfire/src/cfeditor/action.properties 2006-12-22 22:00:27 UTC (rev 1216) @@ -30,6 +30,10 @@ mapwindowCursor.menu=moveCursor - selectTile startStopDrag addToSelection subFromSelection releaseDrag - insertArch deleteArch - selectArchAbove selectArchBelow - archAttributes mapwindowView.menu=showMonster showExit showBackground showDoor showWall showEquipment showTreasure showConnected resetView +########## +# ToolBars +main.toolbar=createNew open save saveAs - prevWindow nextWindow + ####### # File @@ -108,6 +112,11 @@ importPlugin.icon=ImportPluginSmallIcon +nextWindow.icon=navigation/Forward16 + +prevWindow.icon=navigation/Back16 + + onlineHelp.icon=general/Help16 about.icon=general/About16 Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2006-12-22 21:32:21 UTC (rev 1215) +++ trunk/crossfire/src/cfeditor/messages.properties 2006-12-22 22:00:27 UTC (rev 1216) @@ -406,6 +406,14 @@ window.text=Window window.mnemonic=W +nextWindow.text=Next Window +nextWindow.shortdescription=Display next window +nextWindow.accel=shift pressed PAGE_UP + +prevWindow.text=Previous Window +prevWindow.shortdescription=Display previous window +prevWindow.accel=shift pressed PAGE_DOWN + closeAll.text=Close All closeAll.shortdescription=Close all maps closeAll.longdescription=Closes all opened maps Modified: trunk/crossfire/src/cfeditor/messages_de.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages_de.properties 2006-12-22 21:32:21 UTC (rev 1215) +++ trunk/crossfire/src/cfeditor/messages_de.properties 2006-12-22 22:00:27 UTC (rev 1216) @@ -630,6 +630,14 @@ window.text=Fenster window.mnemonic=F +nextWindow.text=N\xE4chstes Fenster +nextWindow.shortdescription=Zeige das n\xE4chste Fenster +nextWindow.accel=shift pressed PAGE_UP + +prevWindow.text=Vorheriges Fenster +prevWindow.shortdescription=Zeige das vorherige Fenster +prevWindow.accel=shift pressed PAGE_DOWN + closeAll.text=Alle schlie\xDFen closeAll.shortdescription=Alle Karten schlie\xDFen closeAll.longdescription=Schlie\xDFt alle ge\xF6ffneten Karten. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 21:39:05
|
Revision: 1235 http://svn.sourceforge.net/gridarta/?rev=1235&view=rev Author: akirschbaum Date: 2006-12-23 13:39:03 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Repaint pickmaps with correct background color. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-23 21:16:52 UTC (rev 1234) +++ trunk/crossfire/ChangeLog 2006-12-23 21:39:03 UTC (rev 1235) @@ -1,5 +1,7 @@ 2006-12-23 Andreas Kirschbaum + * Repaint pickmaps with correct background color. + * Properly update map tile panel after changes. 2006-12-22 Andreas Kirschbaum Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-23 21:16:52 UTC (rev 1234) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-23 21:39:03 UTC (rev 1235) @@ -125,11 +125,7 @@ // initialize the tmp. graphic buffer tmpImage = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB); tmpGrfx = tmpImage.getGraphics(); - if (isPickmap) { - tmpGrfx.setColor(IGUIConstants.BG_COLOR); - } else { - tmpGrfx.setColor(mainControl.getMainView().getBackground()); // background color of window - } + setColor(tmpGrfx); tmpIcon = new ImageIcon(); setFocusable(true); @@ -219,12 +215,7 @@ * "screenshot"-image, false for normal drawing */ public void paintComponent(final Graphics grfx, final boolean isSnapshot) { - if (isPickmap) { - // draw greenisch background for pickmaps - grfx.setColor(IGUIConstants.BG_COLOR); - } else { - grfx.setColor(mainControl.getMainView().getBackground()); // background color of window - } + setColor(grfx); grfx.fillRect(0, 0, getWidth(), getHeight()); final Point point = new Point(); for (point.y = 0; point.y < mapGrid.getSize().getHeight(); point.y++) { @@ -463,9 +454,9 @@ public void paintTile(final Graphics grfx, final Point point) { // ---------- draw tile for rectangular view (non-iso) -------------- filter.newSquare(); + setColor(grfx); if (!mapModel.containsArchObject(point)) { if (isPickmap) { - grfx.setColor(IGUIConstants.BG_COLOR); grfx.fillRect(point.x * 32, point.y * 32, 32, 32); } else { CMainControl.getUnknownTileIcon().paintIcon(DefaultLevelRenderer.this, grfx, point.x * 32, point.y * 32); @@ -537,4 +528,18 @@ modelChanged(); } + /** + * Set the background color appropriate for pickmap/map window. + * + * @param grfx the Graphics to change + */ + private void setColor(final Graphics grfx) { + if (isPickmap) { + // draw greenisch background for pickmaps + grfx.setColor(IGUIConstants.BG_COLOR); + } else { + grfx.setColor(mainControl.getMainView().getBackground()); + } + } + } // class DefaultLevelRenderer This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 21:46:21
|
Revision: 1236 http://svn.sourceforge.net/gridarta/?rev=1236&view=rev Author: akirschbaum Date: 2006-12-23 13:46:21 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Make sure inventory items in map tile panel ore indented. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-23 21:39:03 UTC (rev 1235) +++ trunk/crossfire/ChangeLog 2006-12-23 21:46:21 UTC (rev 1236) @@ -1,5 +1,7 @@ 2006-12-23 Andreas Kirschbaum + * Make sure inventory items in map tile panel ore indented. + * Repaint pickmaps with correct background color. * Properly update map tile panel after changes. Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java 2006-12-23 21:39:03 UTC (rev 1235) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/CellRenderer.java 2006-12-23 21:46:21 UTC (rev 1236) @@ -101,8 +101,8 @@ arch = (GameObject) env; indent++; } - if (indent > 1) { - setBorder(BorderFactory.createEmptyBorder(0, (indent - 1) * 16, 0, 0)); // indentation + if (indent > 0) { + setBorder(BorderFactory.createEmptyBorder(0, indent * 16, 0, 0)); // indentation } return this; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 22:08:50
|
Revision: 1238 http://svn.sourceforge.net/gridarta/?rev=1238&view=rev Author: akirschbaum Date: 2006-12-23 14:08:51 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Do not delete more than one object per tile when dragging the mouse. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMapViewBasic.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-23 21:56:49 UTC (rev 1237) +++ trunk/crossfire/ChangeLog 2006-12-23 22:08:51 UTC (rev 1238) @@ -1,5 +1,8 @@ 2006-12-23 Andreas Kirschbaum + * Do not delete more than one object per tile when dragging the + mouse. + * Make sure inventory items in map tile panel ore indented. * Repaint pickmaps with correct background color. Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 21:56:49 UTC (rev 1237) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 22:08:51 UTC (rev 1238) @@ -112,6 +112,12 @@ private final MapView frame; /** + * Last processed point when deleting objects by dragging. Used to prevent + * deleting multiple objects from one tile while dragging over the tile. + */ + @NotNull private final Point lastMapLoc = new Point(); + + /** * Constructs a level view. * @param mainControl the main controller * @param mapControl the controller of this view @@ -389,6 +395,7 @@ // middle mouse button: delete arch // (I intenionally used "else" here. BUTTON2_MASK seems not to work for some systems) mapCursor.setLocation(mapLoc); + lastMapLoc.setLocation(mapLoc); deleteObject(mapLoc); } } else { @@ -459,7 +466,9 @@ // Middle Mouse Button: Arches get deleted all the way - if (temp != null) { + if (temp != null && !lastMapLoc.equals(temp)) { + lastMapLoc.setLocation(temp); + // delete the topmost arch (matching the view settings) // on that square and redraw the map GameObject tmpArch = null; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 22:15:32
|
Revision: 1240 http://svn.sourceforge.net/gridarta/?rev=1240&view=rev Author: akirschbaum Date: 2006-12-23 14:15:32 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Remove support for deleting/inserting with button 1 and shift/control. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-23 22:10:54 UTC (rev 1239) +++ trunk/crossfire/ChangeLog 2006-12-23 22:15:32 UTC (rev 1240) @@ -1,5 +1,8 @@ 2006-12-23 Andreas Kirschbaum + * Remove support for deleting/inserting with button 1 and + shift/control. + * Do not delete more than one object per tile when dragging the mouse. Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 22:10:54 UTC (rev 1239) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 22:15:32 UTC (rev 1240) @@ -367,7 +367,7 @@ if (mapLoc != null) { // in "locked pickmaps" mode, pickmaps react only to leftclicks - if (mapControl.isPickmap() && mainControl.isLockAllPickmaps() && !(e.getModifiers() == InputEvent.BUTTON1_MASK && !e.isShiftDown() && !e.isControlDown())) { + if (mapControl.isPickmap() && mainControl.isLockAllPickmaps() && (e.getModifiers() & InputEvent.BUTTON1_MASK) == 0) { return; } Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 22:10:54 UTC (rev 1239) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListControl.java 2006-12-23 22:15:32 UTC (rev 1240) @@ -112,7 +112,7 @@ MouseListener getMouseListener() { return new MouseAdapter() { @Override public void mousePressed(final MouseEvent e) { - if (e.getModifiers() == InputEvent.BUTTON1_MASK && !e.isShiftDown() && !e.isControlDown()) { + if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { // --- left mouse button: select arch --- // first, check if this is a doubleclick final long thisClick = (new Date()).getTime(); @@ -127,7 +127,7 @@ // save values for next click lastClick = thisClick; lastClickGameObject = getMapTileSelection(); - } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0 || ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && e.isShiftDown())) { + } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { // --- right mouse button: insert arch --- insertGameObjectFromArchPanel(view.getListIndex(e)); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 22:25:52
|
Revision: 1242 http://svn.sourceforge.net/gridarta/?rev=1242&view=rev Author: akirschbaum Date: 2006-12-23 14:25:53 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Make selection in pickmaps work. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMapViewBasic.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-23 22:20:36 UTC (rev 1241) +++ trunk/crossfire/ChangeLog 2006-12-23 22:25:53 UTC (rev 1242) @@ -1,5 +1,7 @@ 2006-12-23 Andreas Kirschbaum + * Make selection in pickmaps work. (Not yet used anywhere.) + * Make map tile panel a "single selection" list. * Remove support for deleting/inserting with button 1 and Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 22:20:36 UTC (rev 1241) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-23 22:25:53 UTC (rev 1242) @@ -162,8 +162,8 @@ final CListener listener = new CListener(); renderer.addMouseListener(listener); + renderer.addMouseMotionListener(listener); if (!isPickmap()) { - renderer.addMouseMotionListener(listener); renderer.addMouseMotionListener(mainControl.getMainView().getStatusBar()); } renderer.updateLookAndFeel(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-23 22:46:35
|
Revision: 1249 http://svn.sourceforge.net/gridarta/?rev=1249&view=rev Author: akirschbaum Date: 2006-12-23 14:46:34 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Reorder inventory items in map tile panel to make "move up/down" work correctly. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-23 22:41:50 UTC (rev 1248) +++ trunk/crossfire/ChangeLog 2006-12-23 22:46:34 UTC (rev 1249) @@ -1,5 +1,8 @@ 2006-12-23 Andreas Kirschbaum + * Reorder inventory items in map tile panel to make "move up/down" + work correctly. + * Make selection in pickmaps work. (Not yet used anywhere.) * Make map tile panel a "single selection" list. Modified: trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 22:41:50 UTC (rev 1248) +++ trunk/crossfire/src/cfeditor/gui/maptilelist/MapTileListView.java 2006-12-23 22:46:34 UTC (rev 1249) @@ -300,7 +300,7 @@ */ private int addInvObjects(final GameObject node, final GameObject gameObject) { int selListCounter = -1; - for (final GameObject invObject : node.getHead()) { + for (final GameObject invObject : node.getHead().reverse()) { if (invObject == gameObject) { selListCounter = listCounter; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |