From: <aki...@us...> - 2006-12-21 22:09:55
|
Revision: 1199 http://svn.sourceforge.net/gridarta/?rev=1199&view=rev Author: akirschbaum Date: 2006-12-21 14:09:55 -0800 (Thu, 21 Dec 2006) Log Message: ----------- Properly update connection view when the map changes. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/CAttribDialog.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-21 21:56:42 UTC (rev 1198) +++ trunk/crossfire/ChangeLog 2006-12-21 22:09:55 UTC (rev 1199) @@ -1,5 +1,7 @@ 2006-12-21 Andreas Kirschbaum + * Properly update connection view when the map changes. + * Sort connection numbers in connection view. * Add connection view. Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-21 21:56:42 UTC (rev 1198) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-12-21 22:09:55 UTC (rev 1199) @@ -89,6 +89,7 @@ import net.sf.gridarta.gameobject.NamedObject; import net.sf.gridarta.gameobject.NamedObjects; import net.sf.gridarta.help.Help; +import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; @@ -1058,6 +1059,22 @@ * @return true if the settings were applied, false if error occurred */ private boolean applySettings() { + final MapModel mapModel = mainControl.getCurrentMap().getMapModel(); + mapModel.beginTransaction("Change object attributes"); + try { + return applySettings2(); + } finally { + mapModel.endTransaction(); + } + } + + /** + * This method is called when the "apply"-button has been + * pressed. All the settings from the dialog get + * written into the GameObject. + * @return true if the settings were applied, false if error occurred + */ + private boolean applySettings2() { final String oldArchText = gameObject.getObjectText(); // the old ArchText final String oldMsg = gameObject.getMsgText(); // old gameObject msg final CFArchType typeStruct = archTypeList.getTypeOfArch(gameObject); // the type structure for this gameObject @@ -1326,7 +1343,6 @@ final int index = ArchetypeSet.getFaceIndex(archetype.getFaceName()); gameObject.setFaceNr(index); } - mainControl.getCurrentMap().repaint(); // repaint map } } imagePanel.setIcon(mainControl.getArchetypeSet().getFace(gameObject.getFaceNr())); Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-12-21 21:56:42 UTC (rev 1198) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-12-21 22:09:55 UTC (rev 1199) @@ -421,12 +421,22 @@ } public void setArchTypNr(final int typNr) { + if (archType == typNr) { + return; + } + archType = typNr; + 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 */ @@ -439,12 +449,23 @@ } public void setFaceFlag(final boolean flag) { + if (noface == flag) { + return; + } + noface = flag; + squareChanged(); } // face name public void setFaceName(final String name) { - faceName = name != null ? name.intern() : null; + final String newFaceName = name != null ? name.intern() : null; + if (faceName == newFaceName) { + return; + } + + faceName = newFaceName; + squareChanged(); } public String getFaceName() { Modified: trunk/daimonin/src/daieditor/CAttribDialog.java =================================================================== --- trunk/daimonin/src/daieditor/CAttribDialog.java 2006-12-21 21:56:42 UTC (rev 1198) +++ trunk/daimonin/src/daieditor/CAttribDialog.java 2006-12-21 22:09:55 UTC (rev 1199) @@ -88,6 +88,7 @@ import net.sf.gridarta.gameobject.NamedObject; import net.sf.gridarta.gameobject.NamedObjects; import net.sf.gridarta.help.Help; +import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.util.Arrays2.linearSearch; import org.apache.log4j.Logger; @@ -1052,6 +1053,23 @@ * @return true if the settings were applied, false if error occurred */ private boolean applySettings() { + final MapModel mapModel = mainControl.getCurrentMap().getMapModel(); + mapModel.beginTransaction("Change object attributes"); + try { + return applySettings2(); + } finally { + mapModel.endTransaction(); + } + } + + + /** + * This method is called when the "apply"-button has been + * pressed. All the settings from the dialog get + * written into the GameObject. + * @return true if the settings were applied, false if error occurred + */ + private boolean applySettings2() { final CFArchType typeStruct = archTypeList.getTypeOfArch(gameObject); // the type structure for this gameObject String newArchText = ""; @@ -1347,7 +1365,6 @@ // It is just a hack to fix #0000306: When changing the face (image) of an item by hitting the image button, the image in the selected tile window does not change // In fact, this hack always refreshes the whole map tile list, no matter whether it is still showing the currently selected gameObject. mainControl.getMainView().refreshMapTileList(); - mainControl.getCurrentMap().repaint(); return true; // apply succeeded } Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-12-21 21:56:42 UTC (rev 1198) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-12-21 22:09:55 UTC (rev 1199) @@ -375,7 +375,12 @@ } public void setArchTypNr(final int typNr) { + if (archType == typNr) { + return; + } + archType = typNr; + squareChanged(); } /** {@inheritDoc} */ @@ -401,7 +406,12 @@ } public void setDirection(final int direction) { + if (this.direction == direction) { + return; + } + this.direction = direction; + squareChanged(); } public boolean hasFaceObject() { @@ -414,11 +424,13 @@ // face name private void setFaceObjName(final String faceObjName) { - if (faceObjName != null) { - this.faceObjName = faceObjName.intern(); - } else { - this.faceObjName = null; + final String newFaceObjName = faceObjName != null ? faceObjName.intern() : null; + if (this.faceObjName == newFaceObjName) { + return; } + + this.faceObjName = newFaceObjName; + squareChanged(); } public String getFaceObjName() { @@ -427,7 +439,13 @@ // face name public void setFaceRealName(final String faceRealName) { - this.faceRealName = faceRealName != null ? faceRealName.intern() : null; + final String newFaceRealName = faceRealName != null ? faceRealName.intern() : null; + if (this.faceRealName == newFaceRealName) { + return; + } + + this.faceRealName = newFaceRealName; + squareChanged(); } public String getFaceRealName() { @@ -606,7 +624,13 @@ * <var>animName</var></code> */ public void setAnimName(final String animName) { - this.animName = animName != null ? animName.intern() : null; + final String newAnimName = animName != null ? animName.intern() : null; + if (this.animName == newAnimName) { + return; + } + + this.animName = newAnimName; + squareChanged(); } /** Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-12-21 21:56:42 UTC (rev 1198) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-12-21 22:09:55 UTC (rev 1199) @@ -577,7 +577,12 @@ * @see #getEditType() */ public void setEditType(final int editType) { + if (this.editType == editType) { + return; + } + this.editType = editType; + squareChanged(); } /** Delete message text by nullification. */ @@ -735,7 +740,13 @@ * @param objName the name of this object. */ public void setObjName(@Nullable final String objName) { - this.objName = objName != null ? objName.intern() : null; + final String newObjName = objName != null ? objName.intern() : null; + if (this.objName == newObjName) { + return; + } + + this.objName = newObjName; + squareChanged(); } /** @@ -787,7 +798,12 @@ /** Clears the object text of this GameObject. */ public void resetObjectText() { + if (objectText.length() == 0) { + return; + } + objectText.delete(0, objectText.length()); + squareChanged(); } /** @@ -795,9 +811,14 @@ * @param objectText text to set as object text */ public void setObjectText(final String objectText) { + if (this.objectText.toString().equals(objectText)) { + return; + } + resetObjectText(); this.objectText.append(objectText); clearAttributeCache(); + squareChanged(); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |