From: <aki...@us...> - 2006-12-17 15:16:42
|
Revision: 1142 http://svn.sourceforge.net/gridarta/?rev=1142&view=rev Author: akirschbaum Date: 2006-12-17 07:16:42 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Remove refreshCurrentMap() function. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-17 15:05:02 UTC (rev 1141) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-17 15:16:42 UTC (rev 1142) @@ -304,7 +304,15 @@ * @param v tileedit bitmask of types to show */ public void setTileEdit(final int v) { + if ((tileEdit & v) == v) { + return; + } + tileEdit |= v; + + if (currentMap != null) { + currentMap.repaint(); + } } /** @@ -313,7 +321,15 @@ * @param v tileedit bitmask of types to hide */ public void unsetTileEdit(final int v) { + if ((tileEdit & v) == 0) { + return; + } + tileEdit &= ~v; + + if (currentMap != null) { + currentMap.repaint(); + } } /** @@ -365,7 +381,6 @@ } else { unsetTileEdit(editType); } - refreshCurrentMap(); } public boolean isShowMonster() { @@ -541,14 +556,6 @@ return lockAllPickmaps; } - /** Refresh the active map view, if there is one. */ - public void refreshCurrentMap() { - mainView.refreshMapTileList(); // update tile window - if (currentMap != null) { - currentMap.repaint(); // update map view (if there is one) - } - } - // ask arch panel which arch is highlighted public GameObject getArchPanelHighlight() { return mainView.getArchPanelHighlight(); Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-17 15:05:02 UTC (rev 1141) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-17 15:16:42 UTC (rev 1142) @@ -819,7 +819,6 @@ ((ToggleAction) aShowEquipment).setSelected(false); ((ToggleAction) aShowTreasure).setSelected(false); ((ToggleAction) aShowConnected).setSelected(false); - mainControl.refreshCurrentMap(); // redraw map } private final String[] directionsMap = {"enterNorthMap", "enterEastMap", "enterSouthMap", "enterWestMap", "enterUpperMap", "enterLowerMap"}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 15:25:32
|
Revision: 1144 http://svn.sourceforge.net/gridarta/?rev=1144&view=rev Author: akirschbaum Date: 2006-12-17 07:25:30 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Move similar code into function. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-17 15:22:49 UTC (rev 1143) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-17 15:25:30 UTC (rev 1144) @@ -344,6 +344,16 @@ } /** + * Get information whether the gameObject is edited. + * Are tiles of type 'v' displayed? + * @param gameObject are tiles of this type displayed? + * @return true if these tiles are currently displayed + */ + public boolean isTileEdit(final GameObject gameObject) { + return tileEdit == 0 || isTileEdit(gameObject.getEditType()); + } + + /** * Returns whether a tileEdit value is set. * In case a tileEdit value is set, not all tiles should be displayed. * @return <code>true</code> if a tileEdit value is set, otherwise <code>false</code>. Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 15:22:49 UTC (rev 1143) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 15:25:30 UTC (rev 1144) @@ -622,7 +622,7 @@ tmpArch = gameObject; // now search backwards for matching view settings - if (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(tmpArch.getEditType())) { + if (mainControl.isTileEdit(tmpArch)) { break; } } @@ -695,7 +695,7 @@ final Iterator<GameObject> it = mapControl.getMapModel().getMapSquare(mapLoc).reverse().iterator(); for (final GameObject gameObject : mapControl.getMapModel().getMapSquare(mapLoc).reverse()) { tmpArch = gameObject; - if (mainControl.getTileEdit() == 0 || mainControl.isTileEdit(tmpArch.getEditType())) { + if (mainControl.isTileEdit(tmpArch)) { break; } } Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 15:22:49 UTC (rev 1143) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-12-17 15:25:30 UTC (rev 1144) @@ -160,7 +160,7 @@ // 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()))) { + if ((mode == Mode.DO_CUT || mode == Mode.DO_COPY) && gameObject.isHead() && !gameObject.isInContainer() && mainControl.isTileEdit(gameObject)) { // copy this gameObject final GameObject clone = gameObject.createClone(posx - selRec.x, posy - selRec.y); assert copyMapCtrl != null; @@ -168,7 +168,7 @@ } // 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()))) { + if ((mode == Mode.DO_CLEAR || mode == Mode.DO_CUT) && mainControl.isTileEdit(gameObject)) { // store next arch in tmp // delete gameObject (without redrawing the map) Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-17 15:22:49 UTC (rev 1143) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-17 15:25:30 UTC (rev 1144) @@ -263,7 +263,7 @@ if (!filter.canShow(node)) { continue; } - if (mainControl.isTileEdit(node.getEditType()) || mainControl.getTileEdit() == 0 || isPickmap) { + if (mainControl.isTileEdit(node) || isPickmap) { if (node.getArchetypeName() == null) { CMainControl.getNoarchTileIcon().paintIcon(this, grfx, point.x * 32 + borderOffset, point.y * 32 + borderOffset); } else if (node.getFaceFlag()) { @@ -346,7 +346,7 @@ if (!filter.canShow(node)) { continue; } - if (mainControl.isTileEdit(node.getEditType()) || mainControl.getTileEdit() == 0) { + if (mainControl.isTileEdit(node)) { if (node.getArchetypeName() == null) { CMainControl.getNoarchTileIcon().paintIcon(this, tmpGrfx, 0, 0); } else if (node.getFaceFlag()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 16:39:06
|
Revision: 1156 http://svn.sourceforge.net/gridarta/?rev=1156&view=rev Author: akirschbaum Date: 2006-12-17 08:39:06 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 16:35:50 UTC (rev 1155) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 16:39:06 UTC (rev 1156) @@ -229,18 +229,6 @@ return mapCursor.isActive(); } - /** Turn the highlight off. */ - public void unHighlight() { - if (mapCursor.isActive()) { - mapCursor.deactivate(); - mainControl.getMainView().refreshMenus(); - } - - // repaint map to display selection no more - mapControl.repaint(); - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), null); - } - public int getActiveEditType() { return mapControl.getActiveEditType(); } Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-17 16:35:50 UTC (rev 1155) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-17 16:39:06 UTC (rev 1156) @@ -131,10 +131,6 @@ return view.isHighlight(); } - public void unHighlight() { - view.unHighlight(); - } - public int getActiveEditType() { return view.getActiveEditType(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 17:12:58
|
Revision: 1158 http://svn.sourceforge.net/gridarta/?rev=1158&view=rev Author: akirschbaum Date: 2006-12-17 09:12:54 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Remove explicit map redraw. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-17 16:54:48 UTC (rev 1157) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-17 17:12:54 UTC (rev 1158) @@ -1274,10 +1274,12 @@ // path points to the same map if (exitPos.x == 0 && exitPos.y == 0) { ACTION_FACTORY.showMessageDialog(mainView, "enterExitNowhere"); - } else if (currentMap.isPointValid(exitPos)) { - currentMap.getMapViewFrame().setHotspot(exitPos); + } else if (!currentMap.isPointValid(exitPos)) { + ACTION_FACTORY.showMessageDialog(mainView, "enterExitOutside"); } else { - ACTION_FACTORY.showMessageDialog(mainView, "enterExitOutside"); + currentMap.getMapModel().beginTransaction("Enter Exit"); + currentMap.getMapViewFrame().setCursorPosition(exitPos); + currentMap.getMapModel().endTransaction(); } } else { // path points to a different map @@ -1316,7 +1318,9 @@ exitPos.x = currentMap.getMapModel().getMapArchObject().getEnterX(); exitPos.y = currentMap.getMapModel().getMapArchObject().getEnterY(); } - currentMap.getMapViewFrame().setHotspot(exitPos); // set hotspot + currentMap.getMapModel().beginTransaction("Enter Exit"); + currentMap.getMapViewFrame().setCursorPosition(exitPos); + currentMap.getMapModel().endTransaction(); // Update the main view so the new map instantly pops up. mainView.update(mainView.getGraphics()); Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 16:54:48 UTC (rev 1157) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 17:12:54 UTC (rev 1158) @@ -263,39 +263,10 @@ } /** - * 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. - * @param point Coordinates to set hotsopt to. + * Set the cursor position. + * @param cursorPosition cursor position + * @see #getCursorPosition() */ - public void setHotspot(final Point point) { - // set the highlighted spot: - - // set scroll position accordingly to center on target - final Rectangle scrollto = new Rectangle((point.x + 1) * 32 + 16 - getViewport().getViewRect().width / 2, - (point.y + 1) * 32 + 16 - getViewport().getViewRect().height / 2, - getViewport().getViewRect().width, - getViewport().getViewRect().height); - if (scrollto.x + scrollto.width > getViewport().getViewSize().width) { - scrollto.x = getViewport().getViewSize().width - scrollto.width; - } - if (scrollto.x < 0) { - scrollto.x = 0; - } - if (scrollto.y + scrollto.height > getViewport().getViewSize().height) { - scrollto.y = getViewport().getViewSize().height - scrollto.height; - } - if (scrollto.y < 0) { - scrollto.y = 0; - } - getViewport().setViewPosition(scrollto.getLocation()); - //getViewport().scrollRectToVisible(scrollto); - - // repaint map to display selection - mapControl.repaint(); - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), null); - } - public void setCursorPosition(final Point cursorPosition) { mapCursor.setLocation(cursorPosition); } Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-17 16:54:48 UTC (rev 1157) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-17 17:12:54 UTC (rev 1158) @@ -151,8 +151,8 @@ view.closeNotify(); } - public void setHotspot(final Point point) { - view.setHotspot(point); + public void setCursorPosition(final Point cursorPosition) { + view.setCursorPosition(cursorPosition); } public void printFullImage(final File file) throws IOException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 20:07:37
|
Revision: 1168 http://svn.sourceforge.net/gridarta/?rev=1168&view=rev Author: akirschbaum Date: 2006-12-17 12:07:37 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 20:05:15 UTC (rev 1167) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 20:07:37 UTC (rev 1168) @@ -352,35 +352,6 @@ return redraw; } - /** - * Paint a given array of map-squares. This is much more efficient than - * repainting the whole map and should be used wherever possible. - * @param tile a <code>Point</code> array containing map coords of all - * tiles to draw - */ - public void paintTileArray(final Point[] tile) { - if (tile != null) { - // for rectangular maps we paint only the needed tiles - log.debug("-> redraw map:"); - if (tile.length <= 25) { - for (int i = tile.length - 1; i >= 0; i--) { - // paint the tiles - if (mapControl.getMapModel().isPointValid(tile[i])) { - renderer.paintTile(tile[i]); - } - if (log.isDebugEnabled()) { - log.debug("redraw: (" + tile[i].x + ", " + tile[i].y + ")"); - } - } - if (!isPickmap()) { - repaint(); - } - } else { - modelChanged(); // at some point it's more efficient to draw the whole thing - } - } - } - public Point[] getSelection() { final List<Point> selection = new ArrayList<Point>(); final Size2D mapSize = mapModel.getMapSize(); Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-17 20:05:15 UTC (rev 1167) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-17 20:07:37 UTC (rev 1168) @@ -182,10 +182,6 @@ return view.calcRectRedraw(ax, ay, bx, by); } - public void paintTileArray(final Point[] tile) { - view.paintTileArray(tile); - } - /** * Return the Action for selecting this window. * @return the Action for selecting this window This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 20:50:11
|
Revision: 1170 http://svn.sourceforge.net/gridarta/?rev=1170&view=rev Author: akirschbaum Date: 2006-12-17 12:50:11 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Make DefaultLevelRenderer aware of map model changes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 20:10:22 UTC (rev 1169) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 20:50:11 UTC (rev 1170) @@ -149,6 +149,7 @@ setViewportView(renderer); getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); + mapModel.addMapModelListener(renderer); mapModel.addMapModelListener(this); refreshDataFromModel(); @@ -700,19 +701,16 @@ /** {@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 + // ignore } /** {@inheritDoc} */ public void mapObjectsChanged(final MapModelEvent e) { - modelChanged(); - // TODO: only repaint a specific region + // ignore } public final class CPaintOp implements EditOperation { Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-17 20:10:22 UTC (rev 1169) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-17 20:50:11 UTC (rev 1170) @@ -51,6 +51,8 @@ import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.gui.map.MapGridEvent; import net.sf.gridarta.gui.map.MapGridListener; +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; @@ -60,7 +62,7 @@ * Flat version. * @author unknown */ -public final class DefaultLevelRenderer extends LevelRenderer implements MapGridListener { +public final class DefaultLevelRenderer extends LevelRenderer implements MapGridListener, MapModelListener { private static final Logger log = Logger.getLogger(DefaultLevelRenderer.class); @@ -396,6 +398,21 @@ modelChanged(); } + /** {@inheritDoc} */ + public void mapSizeChanged(final MapModelEvent e) { + // ignore: will trigger an mapGridChanged() callback + } + + /** {@inheritDoc} */ + public void mapSquaresChanged(final MapModelEvent e) { + modelChanged(); + } + + /** {@inheritDoc} */ + public void mapObjectsChanged(final MapModelEvent e) { + modelChanged(); + } + @Override public boolean resizeBackBuffer() { if (isPickmap) { return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 20:51:38
|
Revision: 1171 http://svn.sourceforge.net/gridarta/?rev=1171&view=rev Author: akirschbaum Date: 2006-12-17 12:51:37 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-17 20:50:11 UTC (rev 1170) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-17 20:51:37 UTC (rev 1171) @@ -465,10 +465,6 @@ return copybuffer; } - void setMapAndArchPosition(final GameObject gameObject, final Point pos) { - currentMap.getMapViewFrame().setMapAndArchPosition(gameObject, pos); - } - /** Set all global settings from the preferences. */ public void readGlobalSettings() { imageSet = CSettings.getInstance(IGUIConstants.APP_NAME).getProperty(USE_IMAGESET, "base"); Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 20:50:11 UTC (rev 1170) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 20:51:37 UTC (rev 1171) @@ -310,15 +310,6 @@ frame.updateTitle(); } - void setMapAndArchPosition(final GameObject gameObject, final Point pos) { - if (pos.x == -1 || pos.y == -1) { - mainControl.getMainView().setMapTileList(null, null); - } else { - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), gameObject); - } - modelChanged(); - } - /** * Determine which map-squares need to be painted if the given rectangle is * to be redrawn. Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-17 20:50:11 UTC (rev 1170) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-17 20:51:37 UTC (rev 1171) @@ -174,10 +174,6 @@ view.changedFlagNotify(); } - void setMapAndArchPosition(final GameObject gameObject, final Point pos) { - view.setMapAndArchPosition(gameObject, pos); - } - Point[] calcRectRedraw(final int ax, final int ay, final int bx, final int by) { return view.calcRectRedraw(ax, ay, bx, by); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 20:58:40
|
Revision: 1172 http://svn.sourceforge.net/gridarta/?rev=1172&view=rev Author: akirschbaum Date: 2006-12-17 12:58:40 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 20:51:37 UTC (rev 1171) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 20:58:40 UTC (rev 1172) @@ -310,40 +310,6 @@ frame.updateTitle(); } - /** - * Determine which map-squares need to be painted if the given rectangle is - * to be redrawn. - * @param ax map x-coords. of first corner of the rect - * @param ay map y-coords. of first corner of the rect - * @param bx map x-coords. of second corner of the rect (opposing edge to - * ax, ay) - * @param by map y-coords. of second corner of the rect (opposing edge to - * ax, ay) - * @return a <code>Point</code> array containing the coords of the tiles - * which need to be redrawn - */ - Point[] calcRectRedraw(final int ax, final int ay, final int bx, final int by) { - int i = 0; // counter - - // get rect. coords of highlighted area: top(left) and bot(tomright) corner - final int topx = Math.min(ax, bx); // left - final int topy = Math.min(ay, by); // top - final int botx = Math.max(ax, bx); // right - final int boty = Math.max(ay, by); // bottom - - final Point[] redraw = new Point[(botx - topx + 1) * (boty - topy + 1)]; // create instance of needed size - - for (int posx = topx; posx <= botx; posx++) { - for (int posy = topy; posy <= boty; posy++) { - // pack all tiles from the rect into the Point-array - redraw[i] = new Point(posx, posy); - i++; - } - } - - return redraw; - } - public Point[] getSelection() { final List<Point> selection = new ArrayList<Point>(); final Size2D mapSize = mapModel.getMapSize(); Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-17 20:51:37 UTC (rev 1171) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-17 20:58:40 UTC (rev 1172) @@ -174,10 +174,6 @@ view.changedFlagNotify(); } - Point[] calcRectRedraw(final int ax, final int ay, final int bx, final int by) { - return view.calcRectRedraw(ax, ay, bx, by); - } - /** * Return the Action for selecting this window. * @return the Action for selecting this window This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-12-17 21:24:29
|
Revision: 1175 http://svn.sourceforge.net/gridarta/?rev=1175&view=rev Author: akirschbaum Date: 2006-12-17 13:24:26 -0800 (Sun, 17 Dec 2006) Log Message: ----------- Move code to handle component size changes to DefaultLevelRenderer. Modified Paths: -------------- 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/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 21:18:38 UTC (rev 1174) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-17 21:24:26 UTC (rev 1175) @@ -29,7 +29,6 @@ import cfeditor.gui.map.DefaultLevelRenderer; import cfeditor.map.MapControl; import cfeditor.map.MapModel; -import java.awt.Dimension; import java.awt.Point; import java.awt.Rectangle; import java.awt.event.MouseAdapter; @@ -283,20 +282,8 @@ /** Refreshes the data in the view from the model. */ void refreshDataFromModel() { - - final Dimension forcedSize; - mapSize = mapControl.getMapSize(); - log.debug("refreshDataFromModel"); - // define how much drawing space we need for the map - forcedSize = new Dimension(mapSize.getWidth() * 32 + (isPickmap() ? 0 : 64), mapSize.getHeight() * 32 + (isPickmap() ? 0 : 64)); - renderer.setPreferredSize(forcedSize); - renderer.setMinimumSize(forcedSize); changedFlagNotify(); - if (renderer.resizeBackBuffer()) { - renderer.setSize(forcedSize); - renderer.revalidate(); - } renderer.modelChanged(); } Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-17 21:18:38 UTC (rev 1174) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2006-12-17 21:24:26 UTC (rev 1175) @@ -143,7 +143,7 @@ new Color(1.0f, 0.0f, 0.0f, 0.33f), new Color(0.0f, 1.0f, 0.0f, 0.33f), new Color(0.0f, 1.0f, 1.0f, 0.33f)}; - resizeBackBuffer(); + resizeMapGrid(); } /** This method is called when the look and feel has changed. */ @@ -386,7 +386,7 @@ /** {@inheritDoc} */ public void mapGridChanged(@NotNull final MapGridEvent e) { - modelChanged(); + resizeMapGrid(); } /** {@inheritDoc} */ @@ -410,7 +410,10 @@ modelChanged(); } - @Override public boolean resizeBackBuffer() { + /** + * Resize the backing buffer to the new grid size. + */ + private boolean resizeBackBuffer() { if (isPickmap) { return false; } @@ -502,4 +505,22 @@ } } + /** + * Update cached information to new map grid size. + */ + private void resizeMapGrid() { + // define how much drawing space we need for the map + mapSize = mapGrid.getSize(); + final Dimension forcedSize = new Dimension(mapSize.getWidth() * 32 + (isPickmap() ? 0 : 64), mapSize.getHeight() * 32 + (isPickmap() ? 0 : 64)); + setPreferredSize(forcedSize); + setMinimumSize(forcedSize); + + if (resizeBackBuffer()) { + setSize(forcedSize); + revalidate(); + } + + modelChanged(); + } + } // class DefaultLevelRenderer Modified: trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java 2006-12-17 21:18:38 UTC (rev 1174) +++ trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java 2006-12-17 21:24:26 UTC (rev 1175) @@ -56,8 +56,6 @@ public abstract void setHighlightTile(final Point point); - public abstract boolean resizeBackBuffer(); - public abstract void freeBackBuffer(); } // class LevelRenderer This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-02 15:08:07
|
Revision: 1404 http://svn.sourceforge.net/gridarta/?rev=1404&view=rev Author: christianhujer Date: 2007-01-02 07:08:06 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Removed references that use an int as index to get the face from the ArchetypeSet. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFTreasureListTree.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/ReplaceDialog.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gui/ArchComboBox.java trunk/crossfire/src/cfeditor/gui/ArchetypeChooser.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/crossfire/src/cfeditor/gui/selectedsquare/CellRenderer.java Modified: trunk/crossfire/src/cfeditor/CFTreasureListTree.java =================================================================== --- trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2007-01-02 14:45:37 UTC (rev 1403) +++ trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2007-01-02 15:08:06 UTC (rev 1404) @@ -911,7 +911,7 @@ final GameObject archetype = CMainControl.getInstance().getArchetypeSet().getArchetype(archetypeName); if (archetype != null) { if (!archetype.getFaceFlag()) { - setIcon(CMainControl.getInstance().getFace(archetype.getFaceNr())); + setIcon(CMainControl.getInstance().getArchetypeSet().getFace(archetype)); } else { setIcon(noface); } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-02 14:45:37 UTC (rev 1403) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-02 15:08:06 UTC (rev 1404) @@ -633,10 +633,6 @@ return mainView.getPanelArch(); } - public ImageIcon getFace(final int i) { - return archetypeSet.getFace(i); - } - public void setStatusText(final String string) { mainView.setStatusText(string); } Modified: trunk/crossfire/src/cfeditor/ReplaceDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/ReplaceDialog.java 2007-01-02 14:45:37 UTC (rev 1403) +++ trunk/crossfire/src/cfeditor/ReplaceDialog.java 2007-01-02 15:08:06 UTC (rev 1404) @@ -187,7 +187,7 @@ iconLabel = new JLabel(); if (replaceArch != null) { colonLabel = new JLabel(":"); - iconLabel.setIcon(mainControl.getArchetypeSet().getFace(replaceArch.getFaceNr())); + iconLabel.setIcon(mainControl.getArchetypeSet().getFace(replaceArch)); rfArchName = new JLabel(" " + replaceArch.getBestName()); } else { colonLabel = new JLabel(""); @@ -222,7 +222,7 @@ colonLabel.setText(""); } else { replaceWithBox.setSelectedIndex(0); - iconLabel.setIcon(mainControl.getArchetypeSet().getFace(replaceArch.getFaceNr())); + iconLabel.setIcon(mainControl.getArchetypeSet().getFace(replaceArch)); rfArchName.setText(" " + replaceArch.getBestName()); colonLabel.setText(":"); } @@ -253,7 +253,7 @@ if (newArch != null) { final Icon oldIcon = iconLabel.getIcon(); - iconLabel.setIcon(mainControl.getArchetypeSet().getFace(newArch.getFaceNr())); + iconLabel.setIcon(mainControl.getArchetypeSet().getFace(newArch)); rfArchName.setText(" " + newArch.getBestName()); colonLabel.setText(":"); Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2007-01-02 14:45:37 UTC (rev 1403) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2007-01-02 15:08:06 UTC (rev 1404) @@ -94,7 +94,7 @@ return faceMap.containsKey(faceName) ? faceMap.get(faceName) : -1; } - @Nullable public ImageIcon getFace(final int i) { + @Nullable private ImageIcon getFace(final int i) { if (i >= 0 && i < faceListCount) { return faceObjects[i].getFace(); } Modified: trunk/crossfire/src/cfeditor/gui/ArchComboBox.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2007-01-02 14:45:37 UTC (rev 1403) +++ trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2007-01-02 15:08:06 UTC (rev 1404) @@ -254,7 +254,7 @@ } else if (arch.getFaceNr() == -1) { icon.setIcon(CMainControl.getUnknownTileIcon()); } else { - icon.setIcon(mainControl.getFace(arch.getFaceNr())); + icon.setIcon(mainControl.getArchetypeSet().getFace(arch)); } if (arch == null) { @@ -407,7 +407,7 @@ } else if (arch.getFaceNr() == -1) { setIcon(CMainControl.getUnknownTileIcon()); } else { - setIcon(mainControl.getFace(arch.getFaceNr())); + setIcon(mainControl.getArchetypeSet().getFace(arch)); } return this; } Modified: trunk/crossfire/src/cfeditor/gui/ArchetypeChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchetypeChooser.java 2007-01-02 14:45:37 UTC (rev 1403) +++ trunk/crossfire/src/cfeditor/gui/ArchetypeChooser.java 2007-01-02 15:08:06 UTC (rev 1404) @@ -74,7 +74,7 @@ } else if (archetype.getFaceNr() == -1) { setIcon(CMainControl.getUnknownTileIcon()); } else { - setIcon(CMainControl.getInstance().getFace(archetype.getFaceNr())); + setIcon(CMainControl.getInstance().getArchetypeSet().getFace(archetype)); } return this; Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2007-01-02 14:45:37 UTC (rev 1403) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2007-01-02 15:08:06 UTC (rev 1404) @@ -133,7 +133,7 @@ /** {@inheritDoc} */ @Override protected ImageIcon getFace(@NotNull final GameObject gameObject) { - return ((CMainControl) mainControl).getArchetypeSet().getFace(gameObject.getFaceNr()); + return ((CMainControl) mainControl).getArchetypeSet().getFace(gameObject); } /** {@inheritDoc} */ @@ -422,7 +422,7 @@ } } } - imagePanel.setIcon(((CMainControl) mainControl).getArchetypeSet().getFace(gameObject.getFaceNr())); + imagePanel.setIcon(((CMainControl) mainControl).getArchetypeSet().getFace(gameObject)); if (newMsg != null) { // set new msg text only when it is not equal to Archetype Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-02 14:45:37 UTC (rev 1403) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-02 15:08:06 UTC (rev 1404) @@ -483,7 +483,7 @@ offset.x = 0; offset.y = 0; } else { - img = archlist.getFace(node.getFaceNr()); + img = archlist.getFace(node); if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { offset.x = 0; offset.y = 0; Modified: trunk/crossfire/src/cfeditor/gui/selectedsquare/CellRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/selectedsquare/CellRenderer.java 2007-01-02 14:45:37 UTC (rev 1403) +++ trunk/crossfire/src/cfeditor/gui/selectedsquare/CellRenderer.java 2007-01-02 15:08:06 UTC (rev 1404) @@ -66,7 +66,7 @@ } else if (arch.getFaceNr() == -1) { setIcon(CMainControl.getUnknownTileIcon()); } else { - setIcon(archetypeSet.getFace(arch.getFaceNr())); + setIcon(archetypeSet.getFace(arch)); } // In the map-tile-window the object names are displayed This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-07 01:50:38
|
Revision: 1475 http://svn.sourceforge.net/gridarta/?rev=1475&view=rev Author: akirschbaum Date: 2007-01-06 17:50:37 -0800 (Sat, 06 Jan 2007) Log Message: ----------- Remove now unused menu manager code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/menu/ Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2007-01-07 01:41:21 UTC (rev 1474) +++ trunk/crossfire/src/cfeditor/CMainView.java 2007-01-07 01:50:37 UTC (rev 1475) @@ -30,8 +30,6 @@ import cfeditor.gui.PickmapChooser; import cfeditor.gui.selectedsquare.SelectedSquareControl; import cfeditor.map.MapControl; -import cfeditor.menu.AggregateMenuLocation; -import cfeditor.menu.MenuManager; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; @@ -282,8 +280,6 @@ } //CStartupScreen startupScreen = new CStartupScreen(this); //startupScreen.show(); - - buildAggregates(); } /** Open the online help window. */ @@ -905,12 +901,6 @@ return statusBar; } - private void buildAggregates() { - MenuManager.getMenuManager().addMenuLocation(new AggregateMenuLocation("main")); - MenuManager.getMenuManager().addMenuLocation(new AggregateMenuLocation("toolbar")); - MenuManager.getMenuManager().addMenuLocation(new AggregateMenuLocation("currentmap")); - } - public SelectedSquareControl getMapTileListControl() { return selectedSquareControl; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-09 23:21:11
|
Revision: 1534 http://svn.sourceforge.net/gridarta/?rev=1534&view=rev Author: akirschbaum Date: 2007-01-09 15:21:10 -0800 (Tue, 09 Jan 2007) Log Message: ----------- Make variables more local. Modified Paths: -------------- trunk/crossfire/src/cfeditor/AutojoinList.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/JarResources.java trunk/crossfire/src/cfeditor/Spells.java trunk/crossfire/src/cfeditor/gui/ScriptEditor.java Modified: trunk/crossfire/src/cfeditor/AutojoinList.java =================================================================== --- trunk/crossfire/src/cfeditor/AutojoinList.java 2007-01-09 23:13:11 UTC (rev 1533) +++ trunk/crossfire/src/cfeditor/AutojoinList.java 2007-01-09 23:21:10 UTC (rev 1534) @@ -279,9 +279,7 @@ * @return index of the node in the array. */ private int getIndex(final String archname) { - int i; - - for (i = 0; i < 16; i++) { + for (int i = 0; i < 16; i++) { if (archnames[i].equals(archname)) { return i; } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-09 23:13:11 UTC (rev 1533) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-09 23:21:10 UTC (rev 1534) @@ -911,14 +911,13 @@ // ok, we have it all!! - final MapControl control; // go to ArchetypeParser and add the default arch list information to them if (!collectTempList(objects, file)) { // get face names, face id, etc. return null; } archetypeParser.sortTempList(objects); // sort the list (put multiparts at the end) - control = newLevel(objects, maparch, show, initial); // init the map + final MapControl control = newLevel(objects, maparch, show, initial); // init the map if (show) { // finally, show the map and refresh toolbars Modified: trunk/crossfire/src/cfeditor/JarResources.java =================================================================== --- trunk/crossfire/src/cfeditor/JarResources.java 2007-01-09 23:13:11 UTC (rev 1533) +++ trunk/crossfire/src/cfeditor/JarResources.java 2007-01-09 23:21:10 UTC (rev 1534) @@ -135,9 +135,8 @@ } final byte[] b = new byte[size]; int rb = 0; - int chunk; while (size - rb > 0) { - chunk = zis.read(b, rb, size - rb); + final int chunk = zis.read(b, rb, size - rb); if (chunk == -1) { break; } Modified: trunk/crossfire/src/cfeditor/Spells.java =================================================================== --- trunk/crossfire/src/cfeditor/Spells.java 2007-01-09 23:13:11 UTC (rev 1533) +++ trunk/crossfire/src/cfeditor/Spells.java 2007-01-09 23:21:10 UTC (rev 1534) @@ -54,7 +54,6 @@ */ @Override protected int importSpells(final File spellfile) { List<String> list = null; // growable array of spellnames+numbers - String tmp; // tmp String for spell names if (spellfile.getName().equalsIgnoreCase("spellist.h")) { list = new ArrayList<String>(); @@ -70,7 +69,6 @@ // reading spellnames one after the other, // this loop is terminated by an EOFException - int i; // index for insertion in the vector for (int counter = 0; true; counter++) { IOUtils.readUntil(bufferedReader, "{", "}"); IOUtils.readUntil(bufferedReader, "\"", null); @@ -79,8 +77,9 @@ name = name.trim(); // now insert this string lexographically into the vector + int i; for (i = 0; i < list.size(); i++) { - tmp = list.get(i); + String tmp = list.get(i); tmp = tmp.substring(tmp.indexOf(" ") + 1); if (name.compareTo(tmp) < 0) { Modified: trunk/crossfire/src/cfeditor/gui/ScriptEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ScriptEditor.java 2007-01-09 23:13:11 UTC (rev 1533) +++ trunk/crossfire/src/cfeditor/gui/ScriptEditor.java 2007-01-09 23:21:10 UTC (rev 1534) @@ -263,8 +263,7 @@ } private void redrawTable() { - final GridBagConstraints gbc; - gbc = new GridBagConstraints(0, 0, 1, 1, 0.1, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 5, 0); + final GridBagConstraints gbc = new GridBagConstraints(0, 0, 1, 1, 0.1, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 5, 0); paramTable.removeAll(); paramTable.add(new JLabel("Name"), gbc); gbc.gridx = 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-10 22:52:23
|
Revision: 1553 http://svn.sourceforge.net/gridarta/?rev=1553&view=rev Author: akirschbaum Date: 2007-01-10 14:52:20 -0800 (Wed, 10 Jan 2007) Log Message: ----------- Unify selected square control code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/IGUIConstants.java trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java Modified: trunk/crossfire/src/cfeditor/IGUIConstants.java =================================================================== --- trunk/crossfire/src/cfeditor/IGUIConstants.java 2007-01-10 22:50:15 UTC (rev 1552) +++ trunk/crossfire/src/cfeditor/IGUIConstants.java 2007-01-10 22:52:20 UTC (rev 1553) @@ -97,12 +97,6 @@ /** The amount of space to be left around the dialog borders. */ int DIALOG_INSETS = 4; - /** - * Two mouseclicks within 'DOUBLECLICK_MS' millisecs are considered a - * doubleclick. - */ - int DOUBLECLICK_MS = 300; - /** The Border object to be used when creating dialogs. */ Border DIALOG_BORDER = new EmptyBorder(new Insets(4, 4, 4, 4)); Modified: trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java 2007-01-10 22:50:15 UTC (rev 1552) +++ trunk/crossfire/src/cfeditor/gui/selectedsquare/SelectedSquareControl.java 2007-01-10 22:52:20 UTC (rev 1553) @@ -59,14 +59,6 @@ private final CMainView mainView; - /** - * Time of last click in the panel (value in msec by Date.getTime()) - * and arch-ID of arch that received last click. - */ - private long lastClick = -1; - - private GameObject lastClickGameObject = null; - /** The view for this controller. */ private final SelectedSquareView view; @@ -97,15 +89,11 @@ @Override public void mousePressed(final MouseEvent e) { if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { final long thisClick = (new Date()).getTime(); - if (thisClick - lastClick < IGUIConstants.DOUBLECLICK_MS && lastClickGameObject != null && lastClickGameObject == getMapTileSelection()) { + if (e.getClickCount() > 1) { // LMB Double click mainControl.openAttrDialog(getMapTileSelection()); } else { mainView.setMapArchPanelObject(getMapTileSelection()); } - - // save values for next click - lastClick = thisClick; - lastClickGameObject = getMapTileSelection(); } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { 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...> - 2007-01-11 21:53:12
|
Revision: 1581 http://svn.sourceforge.net/gridarta/?rev=1581&view=rev Author: akirschbaum Date: 2007-01-11 13:53:06 -0800 (Thu, 11 Jan 2007) Log Message: ----------- Extract code to manage AutojoinLists into separate class. Modified Paths: -------------- trunk/crossfire/src/cfeditor/AutojoinList.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/AutojoinLists.java Modified: trunk/crossfire/src/cfeditor/AutojoinList.java =================================================================== --- trunk/crossfire/src/cfeditor/AutojoinList.java 2007-01-11 21:23:12 UTC (rev 1580) +++ trunk/crossfire/src/cfeditor/AutojoinList.java 2007-01-11 21:53:06 UTC (rev 1581) @@ -130,7 +130,7 @@ jlist.archnames = new String[16]; // array to store the archetype names for (int i = 0; i < 16; i++) { jlist.archnames[i] = nbuf[i]; // store archetype name in the list - archstack.getArchetype(nbuf[i]).setJoinList(jlist); // set the link in the def. arch + AutojoinLists.addAutojoinList(archstack.getArchetype(nbuf[i]), jlist); if (log.isDebugEnabled()) { log.debug("(" + i + ") arch: '" + archstack.getArchetype(nbuf[i]).getArchetypeName() + "' -> (" + nbuf[i] + ")"); } @@ -329,7 +329,7 @@ @Nullable private GameObject findArchOfJoinlist(final MapModel map, final Point point) { // we look through the arches at the given location (top to bottom): for (final GameObject tmpArch : map.getMapSquare(point).reverse()) { - if (stack.getArchetype(tmpArch.getArchetypeName()).getJoinList() == this) { + if (AutojoinLists.getAutojoinList(stack.getArchetype(tmpArch.getArchetypeName())) == this) { return tmpArch; // we found an arch } } Added: trunk/crossfire/src/cfeditor/AutojoinLists.java =================================================================== --- trunk/crossfire/src/cfeditor/AutojoinLists.java (rev 0) +++ trunk/crossfire/src/cfeditor/AutojoinLists.java 2007-01-11 21:53:06 UTC (rev 1581) @@ -0,0 +1,73 @@ +/* + * Gridarta Map Editor. + * Copyright (C) 2007 The Gridarta Developers + * + * 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.util.IdentityHashMap; +import net.sf.gridarta.gameobject.Archetype; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Manages a mapping between archetypes to {@link AutojoinList}s. + * + * @author Andreas Kirschbaum + */ +public class AutojoinLists { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(AutojoinLists.class); + + /** + * Mapping of archetypes to autojoin lists. + */ + private static final IdentityHashMap<Archetype, AutojoinList> autojoinLists = new IdentityHashMap<Archetype, AutojoinList>(); + + /** + * Prevent instantiation. + */ + private AutojoinLists() { + } + + /** + * Add a new autojoin list. + * + * @param archetype the archetype to add the autojoin list for + * + * @param autojoinList the autojoin list to add + */ + public static void addAutojoinList(@NotNull final Archetype archetype, @NotNull final AutojoinList autojoinList) { + autojoinLists.put(archetype, autojoinList); + } + + /** + * Return an autojoin list for an archetype. + * + * @param archetype the archetype + * + * @return the autojoin list for the archetype, or <code>null</code> if the + * archetype does not autojoin + */ + @Nullable public static AutojoinList getAutojoinList(@NotNull final Archetype archetype) { + return autojoinLists.get(archetype); + } + +} Property changes on: trunk/crossfire/src/cfeditor/AutojoinLists.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-01-11 21:23:12 UTC (rev 1580) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-01-11 21:53:06 UTC (rev 1581) @@ -24,7 +24,6 @@ package cfeditor.gameobject; -import cfeditor.AutojoinList; import cfeditor.IGUIConstants; import cfeditor.gameobject.scripts.ScriptArchData; import cfeditor.gui.GameObjectAttributesPanel; @@ -75,8 +74,6 @@ */ private int archType; - private AutojoinList join; // if nonzero, pointing to the list of autojoining archetypes - /** Editor Folder. */ private String editorFolder; @@ -92,7 +89,6 @@ // if faceName == null and facenr != -1, we got the face from default arch! editflag = false; - join = null; // no autojoin list per default archType = TYPE_UNSET; // type must be set script = new ScriptArchData(this); } @@ -460,15 +456,6 @@ return archTextCount; } - // set/get autojoin list - public void setJoinList(final AutojoinList jlist) { - join = jlist; - } - - public AutojoinList getJoinList() { - return join; - } - /** {@inheritDoc} */ @Override public GameObject createClone(final int posx, final int posy) { final GameObject clone = new GameObject(); // The clone is a new object! @@ -743,7 +730,6 @@ && gameObject.facenr == facenr // ignore "editflag" && gameObject.archType == archType - // ignore "join" && (gameObject.editorFolder == null ? editorFolder == null : gameObject.editorFolder.equals(editorFolder)); } Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2007-01-11 21:23:12 UTC (rev 1580) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2007-01-11 21:53:06 UTC (rev 1581) @@ -24,6 +24,7 @@ package cfeditor.map; +import cfeditor.AutojoinLists; import cfeditor.CFArchTypeList; import cfeditor.CMainControl; import cfeditor.IGUIConstants; @@ -134,9 +135,9 @@ return false; } - if (mainControl.isAutoJoin() && join == JOIN_ENABLE && mainControl.getJoinlist() != null && archetype.getJoinList() != null && !archetype.isMulti()) { + if (mainControl.isAutoJoin() && join == JOIN_ENABLE && mainControl.getJoinlist() != null && AutojoinLists.getAutojoinList(archetype) != null && !archetype.isMulti()) { // do autojoining if enabled - archName = archetype.getJoinList().joinInsert(this, pos); + archName = AutojoinLists.getAutojoinList(archetype).joinInsert(this, pos); if (archName == null) { return false; // only one autojoin type per square allowed } @@ -319,9 +320,9 @@ // do autojoining final GameObject temp = getArchetype(node.getArchetypeName()); // get defarch - if (mainControl.isAutoJoin() && join == JOIN_ENABLE && mainControl.getJoinlist() != null && temp.getJoinList() != null && !temp.isMulti()) { + if (mainControl.isAutoJoin() && join == JOIN_ENABLE && mainControl.getJoinlist() != null && AutojoinLists.getAutojoinList(temp) != null && !temp.isMulti()) { // remove connections to the deleted arch - temp.getJoinList().joinDelete(this, pos); + AutojoinLists.getAutojoinList(temp).joinDelete(this, pos); } break; Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2007-01-11 21:23:12 UTC (rev 1580) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2007-01-11 21:53:06 UTC (rev 1581) @@ -24,6 +24,7 @@ package cfeditor.map; +import cfeditor.AutojoinLists; import cfeditor.CMainControl; import cfeditor.CopyBuffer; import cfeditor.IGUIConstants; @@ -428,7 +429,7 @@ final Point[] redraw; // return value (coords needing redraw) - if (mainControl.isAutoJoin() && gameObject.getArchetype().getJoinList() != null) { + if (mainControl.isAutoJoin() && AutojoinLists.getAutojoinList(gameObject.getArchetype()) != null) { // this gameObject does autojoining: // first look how many we need This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-11 22:23:39
|
Revision: 1582 http://svn.sourceforge.net/gridarta/?rev=1582&view=rev Author: akirschbaum Date: 2007-01-11 14:23:40 -0800 (Thu, 11 Jan 2007) Log Message: ----------- Replace cfeditor.gameobject.GameObject by net.sf.gridarta.GameObject. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFilterControl.java trunk/crossfire/src/cfeditor/filter/AttributeFilter.java trunk/crossfire/src/cfeditor/filter/Filter.java trunk/crossfire/src/cfeditor/filter/NamedFilterList.java Modified: trunk/crossfire/src/cfeditor/CFilterControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CFilterControl.java 2007-01-11 21:53:06 UTC (rev 1581) +++ trunk/crossfire/src/cfeditor/CFilterControl.java 2007-01-11 22:23:40 UTC (rev 1582) @@ -14,10 +14,10 @@ import cfeditor.filter.NamedFilterEvent; import cfeditor.filter.NamedFilterList; import cfeditor.filter.NamedFilterListener; -import cfeditor.gameobject.GameObject; import cfeditor.map.MapControl; import javax.swing.JMenu; import javax.swing.JMenuItem; +import net.sf.gridarta.gameobject.GameObject; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.Nullable; Modified: trunk/crossfire/src/cfeditor/filter/AttributeFilter.java =================================================================== --- trunk/crossfire/src/cfeditor/filter/AttributeFilter.java 2007-01-11 21:53:06 UTC (rev 1581) +++ trunk/crossfire/src/cfeditor/filter/AttributeFilter.java 2007-01-11 22:23:40 UTC (rev 1582) @@ -7,12 +7,12 @@ package cfeditor.filter; -import cfeditor.gameobject.GameObject; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.swing.JCheckBoxMenuItem; import javax.swing.JMenuItem; +import net.sf.gridarta.gameobject.GameObject; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; Modified: trunk/crossfire/src/cfeditor/filter/Filter.java =================================================================== --- trunk/crossfire/src/cfeditor/filter/Filter.java 2007-01-11 21:53:06 UTC (rev 1581) +++ trunk/crossfire/src/cfeditor/filter/Filter.java 2007-01-11 22:23:40 UTC (rev 1582) @@ -7,8 +7,8 @@ package cfeditor.filter; -import cfeditor.gameobject.GameObject; import javax.swing.JMenuItem; +import net.sf.gridarta.gameobject.GameObject; import org.jdom.Element; /** Modified: trunk/crossfire/src/cfeditor/filter/NamedFilterList.java =================================================================== --- trunk/crossfire/src/cfeditor/filter/NamedFilterList.java 2007-01-11 21:53:06 UTC (rev 1581) +++ trunk/crossfire/src/cfeditor/filter/NamedFilterList.java 2007-01-11 22:23:40 UTC (rev 1582) @@ -7,7 +7,6 @@ package cfeditor.filter; -import cfeditor.gameobject.GameObject; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.ArrayList; @@ -25,6 +24,7 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.EventListenerList; +import net.sf.gridarta.gameobject.GameObject; import org.apache.log4j.Logger; import org.jdom.Element; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-12 18:36:30
|
Revision: 1587 http://svn.sourceforge.net/gridarta/?rev=1587&view=rev Author: akirschbaum Date: 2007-01-12 10:36:30 -0800 (Fri, 12 Jan 2007) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-12 18:34:08 UTC (rev 1586) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-12 18:36:30 UTC (rev 1587) @@ -446,7 +446,6 @@ } } if (tmpArch != null) { - mapControl.calcArchRedraw(tmpArch); // get redraw info mapControl.getMapModel().beginTransaction("Delete Object"); mapControl.deleteMapArch(tmpArch, temp, MapModel.JOIN_ENABLE); mapControl.getMapModel().endTransaction(); @@ -488,7 +487,6 @@ } } if (tmpArch != null) { - mapControl.calcArchRedraw(tmpArch); // get redraw info mapControl.getMapModel().beginTransaction("Delete Object"); mapControl.deleteMapArch(tmpArch, mapLoc, MapModel.JOIN_ENABLE); mapControl.getMapModel().endTransaction(); @@ -512,7 +510,6 @@ // insert single tile from pickmap newarch = newarch.createClone(pos.x, pos.y); mapControl.addArchObjectToMap(newarch); - mapControl.calcArchRedraw(newarch); } else { // insert multi tile from pickmap: newarch = newarch.getHead(); @@ -540,8 +537,6 @@ newdef.setObjName(newarch.getObjName()); newdef.resetMsgText(); newdef.addMsgText(newarch.getMsgText()); - - mapControl.calcArchRedraw(newdef); } } } Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2007-01-12 18:34:08 UTC (rev 1586) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2007-01-12 18:36:30 UTC (rev 1587) @@ -341,15 +341,11 @@ /** * Take the currently selected arch (from archlist or pickmap) and insert - * it to the defined spot on the currently active map. Redraw info is - * stored to 'needRedraw', no views get redrawn/updated here. + * it to the defined spot on the currently active map. * @param pos coordinates on map * @param allowMany when true, it is possible to insert same arches many times - * @return array of coordinates for tiles that need to be redrawn */ - public Point[] insertSelArchToMap(final Point pos, final boolean allowMany) { - Point[] needRedraw = null; // returned array of points which need redraw - + public void insertSelArchToMap(final Point pos, final boolean allowMany) { // this is the arch that would get inserted from pickmap, but it also could // be a default arch (when pickmap has no selection) GameObject newarch = CopyBuffer.getRandomMapArch(mainControl.getMainView().getPickmapChooserControl().getCurrentPickmap(), 100); @@ -363,10 +359,6 @@ } else { // insertion successful, now get redraw info newarch = getTopArchObject(pos); - if (newarch != null) { - // now we've got the inserted arch - needRedraw = calcArchRedraw(newarch); - } } mapModel.endTransaction(); } else { @@ -387,7 +379,6 @@ // insert single tile from pickmap newarch = newarch.createClone(pos.x, pos.y); addArchObjectToMap(newarch); - needRedraw = calcArchRedraw(newarch); } else { // insert multi tile from pickmap: newarch = newarch.getHead(); @@ -403,86 +394,15 @@ newdef.setObjName(newarch.getObjName()); newdef.resetMsgText(); newdef.addMsgText(newarch.getMsgText()); - - needRedraw = calcArchRedraw(newdef); } } } } } } - - return needRedraw; } /** - * Determine which map-squares need to be redrawn after inserting/deleting - * the given GameObject. - * @param gameObject the gameObject that is inserted or deleted - * @return a <code>Point</code> array containing the coords of the tiles - * which need to be redrawn - */ - @Nullable public Point[] calcArchRedraw(GameObject gameObject) { - if (gameObject == null) { // safety check - return null; - } - - final Point[] redraw; // return value (coords needing redraw) - - if (mainControl.isAutoJoin() && AutojoinLists.getAutojoinList(gameObject.getArchetype()) != null) { - // this gameObject does autojoining: - - // first look how many we need - int num = 1; - if (isPointValid(new Point(gameObject.getMapX() + 1, gameObject.getMapY()))) { - num++; - } - if (isPointValid(new Point(gameObject.getMapX(), gameObject.getMapY() + 1))) { - num++; - } - if (isPointValid(new Point(gameObject.getMapX() - 1, gameObject.getMapY()))) { - num++; - } - if (isPointValid(new Point(gameObject.getMapX(), gameObject.getMapY() - 1))) { - num++; - } - - // now get the coordinates - redraw = new Point[num]; // create instance of needed size - redraw[--num] = new Point(gameObject.getMapX(), gameObject.getMapY()); // center square - if (isPointValid(new Point(gameObject.getMapX() + 1, gameObject.getMapY()))) { - redraw[--num] = new Point(gameObject.getMapX() + 1, gameObject.getMapY()); - } - if (isPointValid(new Point(gameObject.getMapX(), gameObject.getMapY() + 1))) { - redraw[--num] = new Point(gameObject.getMapX(), gameObject.getMapY() + 1); - } - if (isPointValid(new Point(gameObject.getMapX() - 1, gameObject.getMapY()))) { - redraw[--num] = new Point(gameObject.getMapX() - 1, gameObject.getMapY()); - } - if (isPointValid(new Point(gameObject.getMapX(), gameObject.getMapY() - 1))) { - redraw[--num] = new Point(gameObject.getMapX(), gameObject.getMapY() - 1); - } - assert num == 0; - } else if (gameObject.isMulti()) { - gameObject = gameObject.getHead(); // make sure we got the head - - int num = gameObject.getMultiRefCount(); // get number of parts - redraw = new Point[num]; // create instance of needed size - for (GameObject tmp = gameObject; num > 0 && tmp != null; - num--, tmp = tmp.getMultiNext()) { - redraw[num - 1] = new Point(tmp.getMapX(), tmp.getMapY()); - } - assert num == 0; - } else { - // just an ordinary single-square gameObject - redraw = new Point[1]; - redraw[0] = new Point(gameObject.getMapX(), gameObject.getMapY()); - } - - return redraw; - } - - /** * Notifies the view that data has changed in the model. */ public void notifyViews() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-20 20:44:11
|
Revision: 1637 http://svn.sourceforge.net/gridarta/?rev=1637&view=rev Author: christianhujer Date: 2007-01-20 12:44:12 -0800 (Sat, 20 Jan 2007) Log Message: ----------- Rationalized static field access. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/crossfire/src/cfeditor/gui/ReplaceDialog.java Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2007-01-20 20:37:10 UTC (rev 1636) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2007-01-20 20:44:12 UTC (rev 1637) @@ -303,7 +303,7 @@ if (objectSize == 1) { return objects.get(0); } - return objects.get(CMainControl.rnd.nextInt(objects.size())); + return objects.get(MainControl.rnd.nextInt(objects.size())); } /** Modified: trunk/crossfire/src/cfeditor/gui/ReplaceDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ReplaceDialog.java 2007-01-20 20:37:10 UTC (rev 1636) +++ trunk/crossfire/src/cfeditor/gui/ReplaceDialog.java 2007-01-20 20:44:12 UTC (rev 1637) @@ -47,6 +47,7 @@ import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.WindowConstants; +import net.sf.gridarta.MainControl; import net.sf.gridarta.map.MapSquare; import net.sf.japi.swing.ActionFactory; @@ -350,7 +351,7 @@ if (replaceListSize == 1) { randomArch = replaceList.get(0); } else { - randomArch = replaceList.get(CMainControl.rnd.nextInt(replaceList.size())); + randomArch = replaceList.get(MainControl.rnd.nextInt(replaceList.size())); } if (randomArch.isMulti()) { // multi's cannot be inserted properly, so we just put them ontop This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-22 18:10:05
|
Revision: 1656 http://svn.sourceforge.net/gridarta/?rev=1656&view=rev Author: akirschbaum Date: 2007-01-22 10:10:02 -0800 (Mon, 22 Jan 2007) Log Message: ----------- Do not export map model listener implementation from DefaultLevelRenderer. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-22 17:59:40 UTC (rev 1655) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-22 18:10:02 UTC (rev 1656) @@ -133,7 +133,6 @@ setViewportView(renderer); getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - mapModel.addMapModelListener(renderer); mapModel.addMapModelListener(this); refreshDataFromModel(); Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-22 17:59:40 UTC (rev 1655) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-22 18:10:02 UTC (rev 1656) @@ -53,7 +53,7 @@ * @author unknown * @author Andreas Kirschbaum */ -public final class DefaultLevelRenderer extends LevelRenderer implements MapGridListener, MapModelListener<GameObject, MapArchObject> { +public final class DefaultLevelRenderer extends LevelRenderer implements MapGridListener { private static final Logger log = Logger.getLogger(DefaultLevelRenderer.class); @@ -101,6 +101,61 @@ private final Point offset = new Point(); /** + * The map model listener to track changes in {@link #mapModel}. + */ + private final MapModelListener<GameObject, MapArchObject> mapModelListener = new MapModelListener<GameObject, MapArchObject>() { + + /** {@inheritDoc} */ + public void mapSizeChanged(final MapModelEvent e) { + // ignore: will trigger an mapGridChanged() callback + } + + /** {@inheritDoc} */ + public void mapSquaresChanged(final MapModelEvent<GameObject, MapArchObject> e) { + final MapSquare<GameObject, MapArchObject>[] 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} */ + public void mapObjectsChanged(final MapModelEvent e) { + modelChanged(); + } + + /** {@inheritDoc} */ + public void mapMetaChanged(@NotNull final MapArchObject mapArchObject) { + // ignore + } + + }; + + /** * Creates a DefaultLevelRenderer. * @param mapViewBasic MapView to render * @param mainControl MainControl, used for getting icons and similar @@ -132,6 +187,7 @@ new Color(0.0f, 1.0f, 0.0f, 0.33f), new Color(0.0f, 1.0f, 1.0f, 0.33f)}; resizeMapGrid(); + mapModel.addMapModelListener(mapModelListener); } /** This method is called when the look and feel has changed. */ @@ -366,54 +422,6 @@ resizeMapGrid(); } - /** {@inheritDoc} */ - public void mapSizeChanged(final MapModelEvent e) { - // ignore: will trigger an mapGridChanged() callback - } - - /** {@inheritDoc} */ - public void mapSquaresChanged(final MapModelEvent<GameObject, MapArchObject> e) { - final MapSquare<GameObject, MapArchObject>[] 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} */ - public void mapObjectsChanged(final MapModelEvent e) { - modelChanged(); - } - - /** {@inheritDoc} */ - public void mapMetaChanged(@NotNull final MapArchObject mapArchObject) { - // ignore - } - /** * Resize the backing buffer to the new grid size. * It will only be resized if the map is not a pickmap. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-22 19:19:18
|
Revision: 1661 http://svn.sourceforge.net/gridarta/?rev=1661&view=rev Author: akirschbaum Date: 2007-01-22 11:19:09 -0800 (Mon, 22 Jan 2007) Log Message: ----------- Extract MapUserListener class from CMapViewBasic. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-22 18:56:56 UTC (rev 1660) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-22 19:19:09 UTC (rev 1661) @@ -22,6 +22,8 @@ import cfeditor.gameobject.GameObject; import cfeditor.gui.MapView; import cfeditor.gui.map.DefaultLevelRenderer; +import cfeditor.gui.map.LevelRenderer; +import cfeditor.gui.map.MapUserListener; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; import cfeditor.map.MapModel; @@ -104,7 +106,7 @@ // interface for the mapview frame private final MapView frame; - @NotNull private final CListener listener; + @NotNull private final MapUserListener mapUserListener; /** * Constructs a level view. @@ -146,9 +148,9 @@ getViewport().setViewPosition(initial); } - listener = new CListener(); - renderer.addMouseListener(listener); - renderer.addMouseMotionListener(listener); + mapUserListener = new MapUserListener(mainControl, mapControl, this); + renderer.addMouseListener(mapUserListener); + renderer.addMouseMotionListener(mapUserListener); if (!isPickmap()) { renderer.addMouseMotionListener(mainControl.getMainView().getStatusBar()); } @@ -171,8 +173,8 @@ } setViewportView(null); mapModel.removeMapModelListener(this); - renderer.removeMouseListener(listener); - renderer.removeMouseMotionListener(listener); + renderer.removeMouseListener(mapUserListener); + renderer.removeMouseMotionListener(mapUserListener); if (!isPickmap()) { renderer.removeMouseMotionListener(mainControl.getMainView().getStatusBar()); } @@ -351,227 +353,6 @@ return mapSize; } - /** The mouse listener for the view. */ - public final class CListener extends MouseAdapter implements MouseMotionListener { - - private boolean fFilling = false; - - private Point startMapLoc = null; - - private Rectangle previewRect = null; - - /** {@inheritDoc} */ - @Override public void mousePressed(final MouseEvent e) { - requestFocus(); - final Point clickPoint = e.getPoint(); - final Point mapLoc = renderer.getTileLocationAt(clickPoint, null); - previewRect = null; - - if (mapLoc != null) { - // in "locked pickmaps" mode, pickmaps react only to leftclicks - if (mapControl.isPickmap() && mainControl.isLockAllPickmaps() && (e.getModifiers() & InputEvent.BUTTON1_MASK) == 0) { - return; - } - - // 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) { - 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(); - } - } 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); - } - endFill(); - } - - /** {@inheritDoc} */ - @Override public void mouseReleased(final MouseEvent e) { - final Point clickPoint = e.getPoint(); - final Point mapLoc = renderer.getTileLocationAt(clickPoint, null); - if (!mapCursor.isOnGrid(mapLoc)) { - mapCursor.dragRelease(); - } else if (e.isShiftDown()) { - mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); - } else if (e.isControlDown()) { - mapCursor.dragSelect(MapGrid.SelectionMode.SUB); - } else { - mapCursor.dragSelect(MapGrid.SelectionMode.ADD); - } - } - - /** {@inheritDoc} */ - @Override public void mouseExited(final MouseEvent e) { - // endFill(); - } - - /** {@inheritDoc} */ - public void mouseMoved(final MouseEvent e) { - // repaint(); // we should blt here with clipping... - // this paints the whole map again, but we want only the marker - } - - /** {@inheritDoc} */ - public void mouseDragged(final MouseEvent e) { - final Point dragPoint = e.getPoint(); // Mouse pointer - final Point temp = renderer.getTileLocationAt(dragPoint, null); // tile under Mouse pointer - - if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { - // Left Mouse Button: Selected area gets highlighted - - mapCursor.dragTo(temp); - } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { - // Right Mouse Button: Arches get inserted all the way - if (mapCursor.setLocation(temp) && temp != null) { - mapControl.getMapModel().beginTransaction("Insert Object"); - mapControl.insertSelArchToMap(temp, false); - mapControl.getMapModel().endTransaction(); - } - } else { - // Middle Mouse Button: Arches get deleted all the way - - if (mapCursor.setLocation(temp) && temp != null) { - // delete the topmost arch (matching the view settings) - // on that square and redraw the map - GameObject tmpArch = null; - for (final GameObject gameObject : mapControl.getMapModel().getMapSquare(temp).reverse()) { - tmpArch = gameObject; - - // now search backwards for matching view settings - if (mainControl.isTileEdit(tmpArch)) { - break; - } - } - if (tmpArch != null) { - mapControl.getMapModel().beginTransaction("Delete Object"); - mapControl.deleteMapArch(tmpArch, temp, MapModel.JOIN_ENABLE); - mapControl.getMapModel().endTransaction(); - } - } - } - } - - private void insertObject(final Point mapLoc) { - previewRect = new Rectangle(); - previewRect.x = mapLoc.x; - previewRect.y = mapLoc.y; - previewRect.width = 1; - previewRect.height = 1; - startMapLoc = mapLoc; - - if (mapLoc.x != -1 && mapLoc.y != -1) { - mapControl.getMapModel().beginTransaction("Insert Object"); - if (mapControl.isPickmap()) { - // insert on pickmap - insertMapArchToPickmap(mapLoc); - } else { - // insert on normal map - mapControl.insertSelArchToMap(mapLoc, true); - } - mapControl.getMapModel().endTransaction(); - } - } - - private void deleteObject(final Point mapLoc) { - if (mapLoc.x != -1 && mapLoc.y != -1) { - // delete the topmost arch (matching the view settings) on that square - // and redraw the map - GameObject tmpArch = null; - for (final GameObject gameObject : mapControl.getMapModel().getMapSquare(mapLoc).reverse()) { - tmpArch = gameObject; - if (mainControl.isTileEdit(tmpArch)) { - break; - } - } - if (tmpArch != null) { - mapControl.getMapModel().beginTransaction("Delete Object"); - mapControl.deleteMapArch(tmpArch, mapLoc, MapModel.JOIN_ENABLE); - mapControl.getMapModel().endTransaction(); - } - } - } - - /** - * This method is only called for pickmaps. Take the currently - * highlighted arch on the map (if any) and insert it on this pickmap. - * @param pos tile-coordinates in pickmap - */ - 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)) { - // get the currently selected map arch - GameObject newarch = mainControl.getMainView().getMapTileSelection(); - if (newarch != null) { - if (!newarch.isMulti()) { - // insert single tile from pickmap - newarch = newarch.createClone(pos.x, pos.y); - mapControl.addArchObjectToMap(newarch); - } else { - // insert multi tile from pickmap: - newarch = newarch.getHead(); - - // check if all spaces are free that the multi will occupy - boolean allSpacesFree = true; - final Point d = new Point(); - for (d.x = pos.x + newarch.getMinX(); d.x <= pos.x + newarch.getMaxX(); d.x++) { - for (d.y = pos.y + newarch.getMinX(); d.y <= pos.y + newarch.getMaxY(); d.y++) { - if (!mapControl.isPointValid(d) || mapControl.containsArchObject(d)) { - allSpacesFree = false; - } - } - } - - // first insert default arch from archlist - if (!allSpacesFree || !mapControl.addArchToMap(newarch.getArchetypeName(), pos, true, MapModel.JOIN_DISABLE)) { - // do nothing - } else { - // insertion successful, now get redraw info - final GameObject newdef = mapControl.getTopArchObject(pos); // new inserted default arch - if (newdef != null) { - // now we've got the inserted arch, copy the custom stuff from pickmap - newdef.setObjectText(newarch.getObjectText()); - newdef.setObjName(newarch.getObjName()); - newdef.resetMsgText(); - newdef.addMsgText(newarch.getMsgText()); - } - } - } - } - } - } - - void endFill() { - fFilling = false; - startMapLoc = null; - // repaint(); - } - - boolean isFilling() { - return fFilling; - } - } - /** {@inheritDoc} */ public void mapSizeChanged(final MapModelEvent e) { mapGrid.resize(e.getMapModel().getMapSize()); @@ -592,6 +373,10 @@ // ignore } + public LevelRenderer getRenderer() { + return renderer; + } + /** {@inheritDoc} */ public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { final MapCursor mapCursor = e.getSource(); Added: trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2007-01-22 19:19:09 UTC (rev 1661) @@ -0,0 +1,289 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package cfeditor.gui.map; + +import cfeditor.CMainControl; +import cfeditor.CMapViewBasic; +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapControl; +import cfeditor.map.MapModel; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapGrid; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; + +/** + * TODO Description. + * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> + */ +public final class MapUserListener implements MouseListener, MouseMotionListener { + + private boolean fFilling = false; + + private Point startMapLoc = null; + + private Rectangle previewRect = null; + + private MapCursor mapCursor; + + private LevelRenderer renderer; + + private MapControl mapControl; + + private CMainControl mainControl; + + @NotNull private final CMapViewBasic mapView; + + public MapUserListener(final CMainControl mainControl, final MapControl mapControl, final CMapViewBasic mapView) { + this.mainControl = mainControl; + this.mapControl = mapControl; + this.mapView = mapView; + mapCursor = mapView.getMapCursor(); + renderer = mapView.getRenderer(); + } + + /** {@inheritDoc} */ + public void mouseClicked(final MouseEvent e) { + // ignore + } + + /** {@inheritDoc} */ + public void mouseEntered(final MouseEvent e) { + /* ignore */ + } + + /** {@inheritDoc} */ + public void mouseExited(final MouseEvent e) { + // endFill(); + } + + /** {@inheritDoc} */ + public void mouseDragged(final MouseEvent e) { + final Point dragPoint = e.getPoint(); // Mouse pointer + final Point temp = renderer.getTileLocationAt(dragPoint, null); // tile under Mouse pointer + + if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { + // Left Mouse Button: Selected area gets highlighted + + mapCursor.dragTo(temp); + } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { + // Right Mouse Button: Arches get inserted all the way + if (mapCursor.setLocation(temp) && temp != null) { + mapControl.getMapModel().beginTransaction("Insert Object"); + mapControl.insertSelArchToMap(temp, false); + mapControl.getMapModel().endTransaction(); + } + } else { + // Middle Mouse Button: Arches get deleted all the way + + if (mapCursor.setLocation(temp) && temp != null) { + // delete the topmost arch (matching the view settings) + // on that square and redraw the map + GameObject tmpArch = null; + for (final GameObject gameObject : mapControl.getMapModel().getMapSquare(temp).reverse()) { + tmpArch = gameObject; + + // now search backwards for matching view settings + if (mainControl.isTileEdit(tmpArch)) { + break; + } + } + if (tmpArch != null) { + mapControl.getMapModel().beginTransaction("Delete Object"); + mapControl.deleteMapArch(tmpArch, temp, MapModel.JOIN_ENABLE); + mapControl.getMapModel().endTransaction(); + } + } + } + } + + /** {@inheritDoc} */ + public void mouseMoved(final MouseEvent e) { + // repaint(); // we should blt here with clipping... + // this paints the whole map again, but we want only the marker + } + + /** {@inheritDoc} */ + public void mousePressed(final MouseEvent e) { + mapView.requestFocus(); + final Point clickPoint = e.getPoint(); + final Point mapLoc = renderer.getTileLocationAt(clickPoint, null); + previewRect = null; + + if (mapLoc != null) { + // in "locked pickmaps" mode, pickmaps react only to leftclicks + if (mapControl.isPickmap() && mainControl.isLockAllPickmaps() && (e.getModifiers() & InputEvent.BUTTON1_MASK) == 0) { + return; + } + + // 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) { + 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(); + } + } 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); + } + endFill(); + } + + private void insertObject(final Point mapLoc) { + previewRect = new Rectangle(); + previewRect.x = mapLoc.x; + previewRect.y = mapLoc.y; + previewRect.width = 1; + previewRect.height = 1; + startMapLoc = mapLoc; + + if (mapLoc.x != -1 && mapLoc.y != -1) { + mapControl.getMapModel().beginTransaction("Insert Object"); + if (mapControl.isPickmap()) { + // insert on pickmap + insertMapArchToPickmap(mapLoc); + } else { + // insert on normal map + mapControl.insertSelArchToMap(mapLoc, true); + } + mapControl.getMapModel().endTransaction(); + } + } + + /** {@inheritDoc} */ + public void mouseReleased(final MouseEvent e) { + final Point clickPoint = e.getPoint(); + final Point mapLoc = renderer.getTileLocationAt(clickPoint, null); + if (!mapCursor.isOnGrid(mapLoc)) { + mapCursor.dragRelease(); + } else if (e.isShiftDown()) { + mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); + } else if (e.isControlDown()) { + mapCursor.dragSelect(MapGrid.SelectionMode.SUB); + } else { + mapCursor.dragSelect(MapGrid.SelectionMode.ADD); + } + } + + private void deleteObject(final Point mapLoc) { + if (mapLoc.x != -1 && mapLoc.y != -1) { + // delete the topmost arch (matching the view settings) on that square + // and redraw the map + GameObject tmpArch = null; + for (final GameObject gameObject : mapControl.getMapModel().getMapSquare(mapLoc).reverse()) { + tmpArch = gameObject; + if (mainControl.isTileEdit(tmpArch)) { + break; + } + } + if (tmpArch != null) { + mapControl.getMapModel().beginTransaction("Delete Object"); + mapControl.deleteMapArch(tmpArch, mapLoc, MapModel.JOIN_ENABLE); + mapControl.getMapModel().endTransaction(); + } + } + } + + /** + * This method is only called for pickmaps. Take the currently + * highlighted arch on the map (if any) and insert it on this pickmap. + * @param pos tile-coordinates in pickmap + */ + 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)) { + // get the currently selected map arch + GameObject newarch = mainControl.getMainView().getMapTileSelection(); + if (newarch != null) { + if (!newarch.isMulti()) { + // insert single tile from pickmap + newarch = newarch.createClone(pos.x, pos.y); + mapControl.addArchObjectToMap(newarch); + } else { + // insert multi tile from pickmap: + newarch = newarch.getHead(); + + // check if all spaces are free that the multi will occupy + boolean allSpacesFree = true; + final Point d = new Point(); + for (d.x = pos.x + newarch.getMinX(); d.x <= pos.x + newarch.getMaxX(); d.x++) { + for (d.y = pos.y + newarch.getMinX(); d.y <= pos.y + newarch.getMaxY(); d.y++) { + if (!mapControl.isPointValid(d) || mapControl.containsArchObject(d)) { + allSpacesFree = false; + } + } + } + + // first insert default arch from archlist + if (!allSpacesFree || !mapControl.addArchToMap(newarch.getArchetypeName(), pos, true, MapModel.JOIN_DISABLE)) { + // do nothing + } else { + // insertion successful, now get redraw info + final GameObject newdef = mapControl.getTopArchObject(pos); // new inserted default arch + if (newdef != null) { + // now we've got the inserted arch, copy the custom stuff from pickmap + newdef.setObjectText(newarch.getObjectText()); + newdef.setObjName(newarch.getObjName()); + newdef.resetMsgText(); + newdef.addMsgText(newarch.getMsgText()); + } + } + } + } + } + } + + void endFill() { + fFilling = false; + startMapLoc = null; + // repaint(); + } + + boolean isFilling() { + return fFilling; + } + +} // class MapUserListener Property changes on: trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-23 19:07:41
|
Revision: 1671 http://svn.sourceforge.net/gridarta/?rev=1671&view=rev Author: akirschbaum Date: 2007-01-23 11:07:37 -0800 (Tue, 23 Jan 2007) Log Message: ----------- Inline method to unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java trunk/crossfire/src/cfeditor/map/MapControl.java Modified: trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2007-01-23 19:02:05 UTC (rev 1670) +++ trunk/crossfire/src/cfeditor/gui/map/MapUserListener.java 2007-01-23 19:07:37 UTC (rev 1671) @@ -262,7 +262,7 @@ // do nothing } else { // insertion successful, now get redraw info - final GameObject newdef = mapControl.getTopArchObject(pos); // new inserted default arch + final GameObject newdef = mapControl.getMapModel().getMapSquare(pos).getLast(); // new inserted default arch if (newdef != null) { // now we've got the inserted arch, copy the custom stuff from pickmap newdef.setObjectText(newarch.getObjectText()); Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2007-01-23 19:02:05 UTC (rev 1670) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2007-01-23 19:07:37 UTC (rev 1671) @@ -259,10 +259,6 @@ return mapModel.containsArchObject(pos); } - public GameObject getTopArchObject(final Point pos) { - return mapModel.getMapSquare(pos).getLast(); - } - /** {@inheritDoc} */ public void save() { if (isPickmap()) { @@ -348,7 +344,7 @@ // Toolkit.getDefaultToolkit().beep(); } else { // insertion successful, now get redraw info - newarch = getTopArchObject(pos); + newarch = mapModel.getMapSquare(pos).getLast(); } mapModel.endTransaction(); } else { @@ -377,7 +373,7 @@ // do nothing } else { // insertion successful, now get redraw info - final GameObject newdef = getTopArchObject(pos); // new inserted default arch + final GameObject newdef = mapModel.getMapSquare(pos).getLast(); // new inserted default arch if (newdef != null) { // now we've got the inserted arch, copy the custom stuff from pickmap newdef.setObjectText(newarch.getObjectText()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-23 21:24:15
|
Revision: 1684 http://svn.sourceforge.net/gridarta/?rev=1684&view=rev Author: akirschbaum Date: 2007-01-23 13:24:11 -0800 (Tue, 23 Jan 2007) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-23 20:22:01 UTC (rev 1683) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-23 21:24:11 UTC (rev 1684) @@ -638,16 +638,6 @@ try { UIManager.setLookAndFeel(strClassName); SwingUtilities.updateComponentTreeUI(mainView); - - // update the look and feel for all open map views - if (!levels.isEmpty()) { - for (final MapControl mapControl : levels) { - mapControl.getMapViewFrame().updateLookAndFeel(); - if (log.isDebugEnabled()) { - log.debug("map " + mapControl.getMapArchObject().getMapName()); - } - } - } } catch (final UnsupportedLookAndFeelException noSuchLNF) { } catch (final IllegalAccessException noAccess) { } catch (final InstantiationException noInstance) { Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-23 20:22:01 UTC (rev 1683) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-23 21:24:11 UTC (rev 1684) @@ -154,7 +154,6 @@ if (!isPickmap()) { renderer.addMouseMotionListener(mainControl.getMainView().getStatusBar()); } - renderer.updateLookAndFeel(); mapGrid.addMapGridListener(renderer); renderer.setFocusable(true); setFocusable(true); @@ -215,11 +214,6 @@ modelChanged(); } - /** Update for a new look and feel (-> view menu). */ - public void updateLookAndFeel() { - renderer.updateLookAndFeel(); - } - /** * Returns whether there is a highlighted area in this mapview. * @return <code>true</code> if there is a highlighted area, otherwise <code>false</code>. Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2007-01-23 20:22:01 UTC (rev 1683) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2007-01-23 21:24:11 UTC (rev 1684) @@ -184,10 +184,6 @@ return view.isGridVisible(); } - public void updateLookAndFeel() { - view.updateLookAndFeel(); - } - public boolean isHighlight() { return view.isHighlight(); } Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-23 20:22:01 UTC (rev 1683) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-23 21:24:11 UTC (rev 1684) @@ -30,7 +30,6 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; -import java.awt.Image; import java.awt.Point; import java.awt.Rectangle; import java.awt.image.BufferedImage; @@ -62,13 +61,6 @@ private final CMapViewBasic mapViewBasic; - // 32x32 Image and Icon for temprary storing tiles before drawing - private Image tmpImage; - - private Graphics tmpGrfx; - - private ImageIcon tmpIcon; - /** * Declares this <code>DefaultLevelRenderer</code> as a renderer for a * Pickmap. Pickmaps have a special behaviour that's different from normal @@ -173,11 +165,6 @@ archlist = mainControl.getArchetypeSet(); isPickmap = pickmap; - // initialize the tmp. graphic buffer - tmpImage = new BufferedImage(32, 32, BufferedImage.TYPE_INT_ARGB); - tmpGrfx = tmpImage.getGraphics(); - setColor(tmpGrfx); - tmpIcon = new ImageIcon(); setFocusable(true); @@ -197,14 +184,6 @@ mapModel.removeMapModelListener(mapModelListener); } - /** This method is called when the look and feel has changed. */ - @Override public void updateLookAndFeel() { - // update background color of window - if (!isPickmap) { - tmpGrfx.setColor(getBackground()); - } - } - /** * Returns whether the rendered map is a pickmap. * @return <code>true</code> if the rendered map is a pickmap, otherwise <code>false</code> @@ -308,13 +287,6 @@ paintTile(grfx, point); - // We have been drawing to the tmp. buffer, now convert it to - // an ImageIcon and paint it into the mapview: - if (mapModel.containsArchObject(point)) { - tmpIcon.setImage(tmpImage); - tmpIcon.paintIcon(this, grfx, point.x * 32, point.y * 32); - } - // if grid is active, draw grid lines (right and bottom) if (mapViewBasic.isGridVisible()) { // horizontal: @@ -462,9 +434,6 @@ */ @Override public void freeBackBuffer() { backBuffer = null; - tmpGrfx = null; - tmpIcon = null; - tmpImage = null; } public void paintTile(final Graphics grfx, final Point point) { Modified: trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java 2007-01-23 20:22:01 UTC (rev 1683) +++ trunk/crossfire/src/cfeditor/gui/map/LevelRenderer.java 2007-01-23 21:24:11 UTC (rev 1684) @@ -28,8 +28,6 @@ */ public abstract class LevelRenderer extends JComponent implements net.sf.gridarta.gui.map.LevelRenderer { - public abstract void updateLookAndFeel(); - public abstract void modelChanged(); public abstract void freeBackBuffer(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-23 21:28:58
|
Revision: 1685 http://svn.sourceforge.net/gridarta/?rev=1685&view=rev Author: akirschbaum Date: 2007-01-23 13:28:58 -0800 (Tue, 23 Jan 2007) Log Message: ----------- Do not expose map grid listener functions to users of DefaultLevelRenderer. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-23 21:24:11 UTC (rev 1684) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2007-01-23 21:28:58 UTC (rev 1685) @@ -154,7 +154,6 @@ if (!isPickmap()) { renderer.addMouseMotionListener(mainControl.getMainView().getStatusBar()); } - mapGrid.addMapGridListener(renderer); renderer.setFocusable(true); setFocusable(true); } @@ -177,7 +176,6 @@ if (!isPickmap()) { renderer.removeMouseMotionListener(mainControl.getMainView().getStatusBar()); } - mapGrid.removeMapGridListener(renderer); } /** Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-23 21:24:11 UTC (rev 1684) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-23 21:28:58 UTC (rev 1685) @@ -52,7 +52,7 @@ * @author unknown * @author Andreas Kirschbaum */ -public final class DefaultLevelRenderer extends LevelRenderer implements MapGridListener { +public final class DefaultLevelRenderer extends LevelRenderer { private static final Logger log = Logger.getLogger(DefaultLevelRenderer.class); @@ -148,6 +148,32 @@ }; /** + * The map grid listener to track changes in {@link #mapGrid}. + */ + private final MapGridListener mapGridListener = new MapGridListener() { + + /** {@inheritDoc} */ + public void mapGridChanged(@NotNull final MapGridEvent e) { + 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) { + resizeMapGrid(); + } + + }; + + /** * Creates a DefaultLevelRenderer. * @param mapViewBasic MapView to render * @param mainControl MainControl, used for getting icons and similar @@ -175,6 +201,7 @@ new Color(0.0f, 1.0f, 1.0f, 0.33f)}; resizeMapGrid(); mapModel.addMapModelListener(mapModelListener); + mapGrid.addMapGridListener(mapGridListener); } /** @@ -182,6 +209,7 @@ */ public void closeNotify() { mapModel.removeMapModelListener(mapModelListener); + mapGrid.removeMapGridListener(mapGridListener); } /** @@ -382,25 +410,6 @@ return new Point(xm, ym); } - /** {@inheritDoc} */ - public void mapGridChanged(@NotNull final MapGridEvent e) { - 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) { - resizeMapGrid(); - } - /** * Resize the backing buffer to the new grid size. * It will only be resized if the map is not a pickmap. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-01-24 22:52:00
|
Revision: 1699 http://svn.sourceforge.net/gridarta/?rev=1699&view=rev Author: christianhujer Date: 2007-01-24 14:52:00 -0800 (Wed, 24 Jan 2007) Log Message: ----------- Fixed simple performance issues. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-24 22:45:45 UTC (rev 1698) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-24 22:52:00 UTC (rev 1699) @@ -978,7 +978,7 @@ if (faceName == null) { // no face set => copy from archetype gameObject.setFaceName(archetype != null ? archetype.getFaceName() : null); - } else if (faceName.equals("")) { + } else if (faceName.length() == 0) { // empty face set => no face gameObject.setFaceName(null); } Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2007-01-24 22:45:45 UTC (rev 1698) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2007-01-24 22:52:00 UTC (rev 1699) @@ -261,7 +261,7 @@ } } else if (thisLine.startsWith("face ")) { final String faceName = thisLine.substring(5).trim(); - archetype.setFaceName(faceName.equals("") ? null : faceName); + archetype.setFaceName(faceName.length() == 0 ? null : faceName); } else if (thisLine.startsWith("editor_folder ")) { editorFolder = thisLine.substring(14).trim(); } Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2007-01-24 22:45:45 UTC (rev 1698) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2007-01-24 22:52:00 UTC (rev 1699) @@ -22,7 +22,6 @@ import cfeditor.CFArchTypeList; import cfeditor.CFTreasureListTree; import cfeditor.CMainControl; -import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; import java.util.List; @@ -396,7 +395,7 @@ } if (newFace != null) { - gameObject.setFaceName(newFace.equals("") ? null : newFace); + gameObject.setFaceName(newFace.length() == 0 ? null : newFace); } imagePanel.setIcon(((CMainControl) mainControl).getArchetypeSet().getFace(gameObject)); Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2007-01-24 22:45:45 UTC (rev 1698) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2007-01-24 22:52:00 UTC (rev 1699) @@ -23,7 +23,6 @@ import cfeditor.CMainView; import cfeditor.CSettings; import cfeditor.IGUIConstants; -import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; import java.awt.BorderLayout; import java.awt.Color; @@ -753,7 +752,7 @@ final StringBuilder faceText = new StringBuilder("Image: "); final String faceName = gameObject.getFaceName(); if (faceName != null) { - faceText.append(faceName.equals("") ? ">no face<" : faceName); + faceText.append(faceName.length() == 0 ? ">no face<" : faceName); } else if (archetype == null) { faceText.append(">no face<"); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-25 01:35:34
|
Revision: 1694 http://svn.sourceforge.net/gridarta/?rev=1694&view=rev Author: akirschbaum Date: 2007-01-24 12:25:28 -0800 (Wed, 24 Jan 2007) Log Message: ----------- Remove use of face numbers; use face names instead. Modified Paths: -------------- trunk/crossfire/src/cfeditor/AutojoinList.java trunk/crossfire/src/cfeditor/CFTreasureListTree.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/gui/ArchComboBox.java trunk/crossfire/src/cfeditor/gui/ArchetypeChooser.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java trunk/crossfire/src/cfeditor/gui/selectedsquare/CellRenderer.java trunk/crossfire/src/cfeditor/io/CMapReader.java Modified: trunk/crossfire/src/cfeditor/AutojoinList.java =================================================================== --- trunk/crossfire/src/cfeditor/AutojoinList.java 2007-01-24 00:07:00 UTC (rev 1693) +++ trunk/crossfire/src/cfeditor/AutojoinList.java 2007-01-24 20:25:28 UTC (rev 1694) @@ -346,8 +346,6 @@ gameObject.setArchetypeName(archetypeName); // set face of new default arch - gameObject.setFaceNr(archetype.getFaceNr()); - gameObject.setFaceFlag(archetype.getFaceFlag()); if (gameObject.getFaceName() != null && gameObject.getFaceName().length() > 0) { gameObject.setFaceName(null); // take default face } Modified: trunk/crossfire/src/cfeditor/CFTreasureListTree.java =================================================================== --- trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2007-01-24 00:07:00 UTC (rev 1693) +++ trunk/crossfire/src/cfeditor/CFTreasureListTree.java 2007-01-24 20:25:28 UTC (rev 1694) @@ -905,11 +905,7 @@ final String archetypeName = content.getName(); final GameObject archetype = CMainControl.getInstance().getArchetypeSet().getArchetype(archetypeName); if (archetype != null) { - if (!archetype.getFaceFlag()) { - setIcon(CMainControl.getInstance().getArchetypeSet().getFace(archetype)); - } else { - setIcon(noface); - } + setIcon(CMainControl.getInstance().getArchetypeSet().getFace(archetype)); } else { setIcon(noarch); } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-24 00:07:00 UTC (rev 1693) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-24 20:25:28 UTC (rev 1694) @@ -972,16 +972,15 @@ } else { gameObject.setArchetype(archetype); } - // 2nd: attach the right face... - // if there was no special face added in map, get it from def object - if (gameObject.getFaceName() != null) { - final int index2 = ArchetypeSet.getFaceIndex(gameObject.getFaceName()); - if (index2 == -1) { // just warn here we have not the gfx - //showMessage("LOAD FILE", "Arch: "+arch.getFaceName()+" Face: " +arch.getFaceName()+" Face Name Unknown"); - } else { - gameObject.setFaceNr(index2); - } + // 2nd: attach the right face... + final String faceName = gameObject.getFaceName(); + if (faceName == null) { + // no face set => copy from archetype + gameObject.setFaceName(archetype != null ? archetype.getFaceName() : null); + } else if (faceName.equals("")) { + // empty face set => no face + gameObject.setFaceName(null); } // Ok, now is attached to default arch and loaded png Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2007-01-24 00:07:00 UTC (rev 1693) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2007-01-24 20:25:28 UTC (rev 1694) @@ -260,14 +260,8 @@ archetype.addObjectText(thisLine); } } else if (thisLine.startsWith("face ")) { - int x; - for (x = 4; x < thisLine.length(); x++) { - if (thisLine.charAt(x) != ' ') { - break; - } - } - archetype.setFaceFlag(false); // we HAVE a face - archetype.setFaceName(thisLine.substring(x, thisLine.length())); + final String faceName = thisLine.substring(5).trim(); + archetype.setFaceName(faceName.equals("") ? null : faceName); } else if (thisLine.startsWith("editor_folder ")) { editorFolder = thisLine.substring(14).trim(); } @@ -307,13 +301,7 @@ s = i + 1; } } - // so, lets check the stuff a last time - if (gameObject.getFaceName() == null) { - gameObject.setFaceNr(archetype.getFaceNr()); - gameObject.setFaceFlag(archetype.getFaceFlag()); - } - // if the type is still unset, then we take the default one if (gameObject.getArchTypNr() == net.sf.gridarta.gameobject.GameObject.TYPE_UNSET) { gameObject.setArchTypNr(archetype.getArchTypNr()); Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2007-01-24 00:07:00 UTC (rev 1693) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2007-01-24 20:25:28 UTC (rev 1694) @@ -61,10 +61,10 @@ private final FaceObject[] faceObjects = new FaceObject[10000]; - // The hash tables hold the name and the index for the field - // if one can show me, that storing and accessing names AND objects - // in the table is faster than in the static arrays, we can change this - private static final Map<String, Integer> faceMap = new HashMap<String, Integer>(); + /** + * Maps face names to {@link FaceObject}s. + */ + private final Map<String, FaceObject> faces = new HashMap<String, FaceObject>(); private int faceListCount; // all loaded face pictures @@ -79,26 +79,28 @@ faceListCount = 0; } - /** Returns the index of a face in the face map or -1. - * @param faceName name of face to get index for - * @return index of face in map or -1 if face is not in map - * @deprecated the index system is slow and unmaintainable and therefore will be removed - */ - @Deprecated public static int getFaceIndex(final String faceName) { - return faceMap.containsKey(faceName) ? faceMap.get(faceName) : -1; - } + /** {@inheritDoc} */ + @NotNull public ImageIcon getFace(@NotNull final GameObject gameObject) { + if (!gameObject.hasArchetype()) { + return CMainControl.getNoarchTileIcon(); + } - @Nullable private ImageIcon getFace(final int i) { - if (i >= 0 && i < faceListCount) { - return faceObjects[i].getFace(); + final String faceName = gameObject.getFaceName(); + if (faceName == null) { + return CMainControl.getNofaceTileIcon(); } - return null; - } + final FaceObject faceObject = faces.get(faceName); + if (faceObject == null) { + return CMainControl.getUnknownTileIcon(); + } - /** {@inheritDoc} */ - @Nullable public ImageIcon getFace(@NotNull final GameObject gameObject) { - return getFace(gameObject.getFaceNr()); + final ImageIcon face = faceObject.getFace(); + if (face == null) { + return CMainControl.getUnknownTileIcon(); + } + + return face; } /** {@inheritDoc} */ @@ -128,7 +130,6 @@ } mainControl.setStatusText("Sorting..."); - connectFaces(); // attach faces to arches mainControl.setTabPaneEnabled(true); mainControl.getMainView().finishArchPanelBuildProcess(); System.gc(); @@ -404,7 +405,7 @@ // put this png into the list of faces faceObjects[faceListCount].setName(face.toString()); faceObjects[faceListCount].setPath("null"); - faceMap.put(face.toString(), faceListCount); + faces.put(face.toString(), faceObjects[faceListCount]); faceListCount++; } } @@ -471,24 +472,10 @@ faceObjects[faceListCount].setName(face); faceObjects[faceListCount].setPath(fname); - faceMap.put(face, faceListCount); + faces.put(face, faceObjects[faceListCount]); faceListCount++; } - private void connectFaces() { - // run through arches - for (final GameObject arch : getArchetypes()) { - final String faceName = arch.getFaceName(); - if (faceName != null) { - final Integer num = faceMap.get(faceName); - if (num != null) { - arch.setFaceNr(num); - } - arch.setFaceFlag(false); - } - } - } - public boolean collectFaces(final Progress progress, final File destDir) throws IOException { try { final File dfile = new File(destDir, IGUIConstants.PNG_FILE); Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-01-24 00:07:00 UTC (rev 1693) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-01-24 20:25:28 UTC (rev 1694) @@ -273,34 +273,6 @@ squareChanged(); } - /* Set the default face. Number is index of face list */ - public void setFaceNr(final int nr) { - if (facenr == nr) { - return; - } - - facenr = nr; - squareChanged(); - } - - /* Get the default face. Number is index of face list */ - public int getFaceNr() { - return facenr; - } - - public boolean getFaceFlag() { - return noface; - } - - public void setFaceFlag(final boolean flag) { - if (noface == flag) { - return; - } - - noface = flag; - squareChanged(); - } - // face name public void setFaceName(final String name) { final String newFaceName = name != null ? name.intern() : null; @@ -485,8 +457,6 @@ clone.setArchetype(getArchetype()); // default arch - clone.noface = noface; // if true, arch has no face as default - clone.facenr = facenr; // the index of faceImages[] clone.editflag = editflag; // if true, object is in a editor clone.editType = editType; // bitmask for view-settings @@ -690,9 +660,7 @@ final GameObject arch = new GameObject(); arch.setArchetypeName(archetypeName); arch.setArchetype(this); - if (!getFaceFlag()) { - arch.setFaceNr(getFaceNr()); - } + arch.setFaceName(getFaceName()); arch.setMultiX(multiX); arch.setMultiY(multiY); return arch; Modified: trunk/crossfire/src/cfeditor/gui/ArchComboBox.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2007-01-24 00:07:00 UTC (rev 1693) +++ trunk/crossfire/src/cfeditor/gui/ArchComboBox.java 2007-01-24 20:25:28 UTC (rev 1694) @@ -264,10 +264,6 @@ if (anObject == null) { icon.setIcon(null); icon.setText("No item selected"); - } else if (arch.getFaceFlag()) { - icon.setIcon(CMainControl.getEmptyTileIcon()); - } else if (arch.getFaceNr() == -1) { - icon.setIcon(CMainControl.getUnknownTileIcon()); } else { icon.setIcon(mainControl.getArchetypeSet().getFace(arch)); } @@ -417,13 +413,8 @@ } setText(arch.getArchetypeName()); - if (arch.getFaceFlag()) { - setIcon(CMainControl.getEmptyTileIcon()); - } else if (arch.getFaceNr() == -1) { - setIcon(CMainControl.getUnknownTileIcon()); - } else { - setIcon(mainControl.getArchetypeSet().getFace(arch)); - } + setIcon(mainControl.getArchetypeSet().getFace(arch)); + return this; } Modified: trunk/crossfire/src/cfeditor/gui/ArchetypeChooser.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/ArchetypeChooser.java 2007-01-24 00:07:00 UTC (rev 1693) +++ trunk/crossfire/src/cfeditor/gui/ArchetypeChooser.java 2007-01-24 20:25:28 UTC (rev 1694) @@ -64,13 +64,7 @@ final GameObject archetype = (GameObject) value; setText(archetype.getArchetypeName()); - if (archetype.getFaceFlag()) { - setIcon(CMainControl.getNofaceTileIcon()); - } else if (archetype.getFaceNr() == -1) { - setIcon(CMainControl.getUnknownTileIcon()); - } else { - setIcon(CMainControl.getInstance().getArchetypeSet().getFace(archetype)); - } + setIcon(CMainControl.getInstance().getArchetypeSet().getFace(archetype)); return this; } Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2007-01-24 00:07:00 UTC (rev 1693) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesDialog.java 2007-01-24 20:25:28 UTC (rev 1694) @@ -396,29 +396,7 @@ } if (newFace != null) { - boolean faceChanged = false; // check if face changed - if ((gameObject.getFaceName() != null && gameObject.getFaceName().length() > 0 && !newFace.equals(gameObject.getFaceName())) || (newFace.length() > 0 && (gameObject.getFaceName() == null || gameObject.getFaceName().length() == 0))) { - faceChanged = true; - } - - if (newFace.length() == 0) { - gameObject.setFaceName(null); - } else { - gameObject.setFaceName(newFace); - } - - // now, if neccessary, set new face - if (faceChanged) { - if (gameObject.getFaceName() != null) { - // we have a non-default face - final int index = ArchetypeSet.getFaceIndex(gameObject.getFaceName()); - gameObject.setFaceNr(index); - } else { - // we have the default face - final int index = ArchetypeSet.getFaceIndex(archetype.getFaceName()); - gameObject.setFaceNr(index); - } - } + gameObject.setFaceName(newFace.equals("") ? null : newFace); } imagePanel.setIcon(((CMainControl) mainControl).getArchetypeSet().getFace(gameObject)); Modified: trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2007-01-24 00:07:00 UTC (rev 1693) +++ trunk/crossfire/src/cfeditor/gui/GameObjectAttributesPanel.java 2007-01-24 20:25:28 UTC (rev 1694) @@ -360,16 +360,6 @@ // also, no overrule... } - if (gameObject.getFaceName() != null) { - // we have a non-default face - final int index = ArchetypeSet.getFaceIndex(gameObject.getFaceName()); - gameObject.setFaceNr(index); - } else { - // we have the default face - final int index = ArchetypeSet.getFaceIndex(archetype.getFaceName()); - gameObject.setFaceNr(index); - } - // the msg TEXT!! ("msg ... endmsg") // if there is an entry in the archTextArea (msg window), this // overrules the default text (if any) @@ -682,15 +672,16 @@ // end msg text // SET FACE - if (gameObject.getFaceFlag()) { - archFaceField.setText(""); - } else if (gameObject.getFaceName() != null) { // custom face + if (gameObject.getFaceName() != null) { // custom face archFaceField.setForeground(Color.blue); archFaceField.setText(gameObject.getFaceName()); } else if (gameObject.getArchetypeName() != null) { archFaceField.setForeground(Color.black); archFaceField.setText(archetype.getFaceName()); - } // end face + } else { + archFaceField.setForeground(Color.black); + archFaceField.setText(""); + } // end face if (gameObject.getAnimName() != null || archetype != null && archetype.getAnimName() != null) { panelDesktop.setForegroundAt(3, Color.blue); } @@ -759,23 +750,15 @@ archTypeText.setText(typeText.toString()); - final StringBuilder faceText = new StringBuilder(); - if (gameObject.getFaceFlag()) { - faceText.append("Image: >no face<"); + final StringBuilder faceText = new StringBuilder("Image: "); + final String faceName = gameObject.getFaceName(); + if (faceName != null) { + faceText.append(faceName.equals("") ? ">no face<" : faceName); + } else if (archetype == null) { + faceText.append(">no face<"); } else { - final String faceName = gameObject.getFaceName(); - if (faceName != null) { - faceText.append("Image: ").append(faceName); - } else if (archetype == null) { - faceText.append("Image: >no face<"); - } else { - final String archFaceName = archetype.getFaceName(); - if (archFaceName != null) { - faceText.append("Image: ").append(archFaceName); - } else { - faceText.append("Image: >no face<"); - } - } + final String archFaceName = archetype.getFaceName(); + faceText.append(archFaceName == null ? ">no face<" : archFaceName); } archFaceText.setText(faceText.toString()); Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-24 00:07:00 UTC (rev 1693) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultLevelRenderer.java 2007-01-24 20:25:28 UTC (rev 1694) @@ -466,30 +466,15 @@ if (!isPickmap && !mainControl.isTileEdit(node)) { continue; } - final ImageIcon img; - if (node.getArchetypeName() == null) { - img = CMainControl.getNoarchTileIcon(); + final ImageIcon img = archlist.getFace(node); + if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { offset.x = 0; offset.y = 0; - } else if (node.getFaceFlag()) { - img = CMainControl.getNofaceTileIcon(); - offset.x = 0; - offset.y = 0; - } else if (node.getFaceNr() == -1) { - img = CMainControl.getUnknownTileIcon(); - offset.x = 0; - offset.y = 0; } else { - img = archlist.getFace(node); - if (!node.isMulti() || (img.getIconWidth() == 32 && img.getIconHeight() == 32)) { - offset.x = 0; - offset.y = 0; - } else { - // this is an oversized image, so it must be shifted - // XXX: it must also be clipped to not overwrite filter information - offset.x = -32 * node.getMultiX(); - offset.y = -32 * node.getMultiY(); - } + // this is an oversized image, so it must be shifted + // XXX: it must also be clipped to not overwrite filter information + offset.x = -32 * node.getMultiX(); + offset.y = -32 * node.getMultiY(); } img.paintIcon(DefaultLevelRenderer.this, grfx, point.x * 32 + offset.x, point.y * 32 + offset.y); } Modified: trunk/crossfire/src/cfeditor/gui/selectedsquare/CellRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/selectedsquare/CellRenderer.java 2007-01-24 00:07:00 UTC (rev 1693) +++ trunk/crossfire/src/cfeditor/gui/selectedsquare/CellRenderer.java 2007-01-24 20:25:28 UTC (rev 1694) @@ -57,15 +57,7 @@ if (arch != null) { arch = arch.getHead(); - if (!arch.hasArchetype()) { - setIcon(CMainControl.getNoarchTileIcon()); - } else if (arch.getFaceFlag()) { - setIcon(CMainControl.getNofaceTileIcon()); - } else if (arch.getFaceNr() == -1) { - setIcon(CMainControl.getUnknownTileIcon()); - } else { - setIcon(archetypeSet.getFace(arch)); - } + setIcon(archetypeSet.getFace(arch)); // In the map-tile-window the object names are displayed // next to the icons Modified: trunk/crossfire/src/cfeditor/io/CMapReader.java =================================================================== --- trunk/crossfire/src/cfeditor/io/CMapReader.java 2007-01-24 00:07:00 UTC (rev 1693) +++ trunk/crossfire/src/cfeditor/io/CMapReader.java 2007-01-24 20:25:28 UTC (rev 1694) @@ -145,7 +145,6 @@ gameObject.setArchTypNr(Integer.parseInt(thisLine.substring(5))); // don't load it into the archtext! (why?) } else if (thisLine.startsWith("face ")) { - gameObject.setFaceFlag(false); gameObject.setFaceName(thisLine.substring(5).trim()); } else { gameObject.addObjectText(thisLine); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2007-01-25 21:00:28
|
Revision: 1708 http://svn.sourceforge.net/gridarta/?rev=1708&view=rev Author: akirschbaum Date: 2007-01-25 13:00:22 -0800 (Thu, 25 Jan 2007) Log Message: ----------- Remove unused return value. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-25 19:44:34 UTC (rev 1707) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2007-01-25 21:00:22 UTC (rev 1708) @@ -899,9 +899,7 @@ // ok, we have it all!! // go to ArchetypeParser and add the default arch list information to them - if (!collectTempList(objects, file)) { // get face names, face id, etc. - return null; - } + collectTempList(objects, file); // get face names, face id, etc. archetypeParser.sortTempList(objects); // sort the list (put multiparts at the end) final MapControl mapControl = newLevel(objects, maparch, view, initial); // init the map @@ -956,11 +954,8 @@ * then browse through the face list and try to find the pictures. * @param objects List of GameObjects to collect * @param file File (for error messages). - * @return <code>true</code> in case of success, otherwise <code>false</code>. - * @note The current implementation always returns <code>true</code>. - * @todo Check whether <code>return false;</code> ever happens, and if not, change method return type to <code>void</code>. */ - public boolean collectTempList(final List<GameObject> objects, final File file) { + public void collectTempList(final List<GameObject> objects, final File file) { final List<GameObject> tailList = new ArrayList<GameObject>(); // first: attach our map sucker to a default arch we have loaded @@ -995,8 +990,6 @@ for (final GameObject tail : tailList) { objects.add(tail); } - - return true; } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-25 19:44:34 UTC (rev 1707) +++ trunk/crossfire/src/cfeditor/gui/pickmapchooser/PickmapChooserControl.java 2007-01-25 21:00:22 UTC (rev 1708) @@ -138,9 +138,7 @@ final MapArchObject maparch = decoder.getMapArch(); // go to ArchetypeParser and add the default arch list information to them - if (!mainControl.collectTempList(objects, mapFile)) { - return false; - } + mainControl.collectTempList(objects, mapFile); mainControl.getArchetypeParser().sortTempList(objects); newPickmap(objects, maparch, mapFile); // init the map return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |