From: <aki...@us...> - 2008-07-29 08:20:29
|
Revision: 4574 http://gridarta.svn.sourceforge.net/gridarta/?rev=4574&view=rev Author: akirschbaum Date: 2008-07-29 08:20:37 +0000 (Tue, 29 Jul 2008) Log Message: ----------- Remove calls to MainControl.getArchetypeSet(). Modified Paths: -------------- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-29 08:19:17 UTC (rev 4573) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-29 08:20:37 UTC (rev 4574) @@ -400,7 +400,7 @@ // now lets assign the visible face - perhaps we have still a anim gameObject.setObjectFace(); - imagePanel.setIcon(mainControl.getArchetypeSet().getFace(gameObject)); + imagePanel.setIcon(archetypeSet.getFace(gameObject)); if (newMsg != null) { // set new msg text only when it is not equal to Archetype Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-29 08:19:17 UTC (rev 4573) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-29 08:20:37 UTC (rev 4574) @@ -130,7 +130,7 @@ * The archetype set to use. */ @NotNull - private final ArchetypeSet<G, A, R> archetypeSet; + protected final ArchetypeSet<G, A, R> archetypeSet; /** The animation objects to use. */ @NotNull This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-29 20:07:15
|
Revision: 4577 http://gridarta.svn.sourceforge.net/gridarta/?rev=4577&view=rev Author: akirschbaum Date: 2008-07-29 20:07:21 +0000 (Tue, 29 Jul 2008) Log Message: ----------- Rename BitmaskAttrib to DialogAttribBitmask. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/archtype/CAttribBitmask.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/MaskChangeAL.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribBitmask.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/BitmaskAttrib.java Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-29 08:30:43 UTC (rev 4576) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-29 20:07:21 UTC (rev 4577) @@ -42,8 +42,8 @@ import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; -import net.sf.gridarta.gui.gameobjectattributesdialog.BitmaskAttrib; import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttrib; +import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribBitmask; import net.sf.gridarta.gui.gameobjectattributesdialog.StringKeyManager; import net.sf.gridarta.gui.map.TilePanel; import net.sf.gridarta.spells.GameObjectSpell; @@ -389,7 +389,7 @@ break; case BITMASK: { // a bitmask attribute (similar to integer, but easier because no parsing needed) - final String value = ((BitmaskAttrib) attr).getEncodedValue(); // get bitmask value + final String value = ((DialogAttribBitmask) attr).getEncodedValue(); // get bitmask value String oldValue = archetype.getAttributeString(attr.ref.getNameOld()); if (oldValue.length() == 0) { oldValue = "0"; Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-29 08:30:43 UTC (rev 4576) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-29 20:07:21 UTC (rev 4577) @@ -42,8 +42,8 @@ import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; -import net.sf.gridarta.gui.gameobjectattributesdialog.BitmaskAttrib; import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttrib; +import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribBitmask; import net.sf.gridarta.gui.gameobjectattributesdialog.StringKeyManager; import net.sf.gridarta.gui.map.TilePanel; import net.sf.gridarta.spells.NumberSpell; @@ -318,7 +318,7 @@ break; case BITMASK: { // a bitmask attribute (similar to integer, but easier because no parsing needed) - final String value = ((BitmaskAttrib) attr).getEncodedValue(); // get bitmask value + final String value = ((DialogAttribBitmask) attr).getEncodedValue(); // get bitmask value String oldValue = archetype.getAttributeString(attr.ref.getNameOld()); if (oldValue.length() == 0) { oldValue = "0"; Modified: trunk/src/app/net/sf/gridarta/archtype/CAttribBitmask.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/CAttribBitmask.java 2008-07-29 08:30:43 UTC (rev 4576) +++ trunk/src/app/net/sf/gridarta/archtype/CAttribBitmask.java 2008-07-29 20:07:21 UTC (rev 4577) @@ -31,7 +31,7 @@ import javax.swing.JPanel; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpressionException; -import net.sf.gridarta.gui.gameobjectattributesdialog.BitmaskAttrib; +import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribBitmask; import net.sf.gridarta.utils.WrappingStringBuilder; import net.sf.japi.xml.NodeListIterator; import org.apache.log4j.Logger; @@ -319,7 +319,7 @@ * the dialog */ @Nullable - public Integer showBitmaskDialog(final Component parentComponent, final BitmaskAttrib guiAttr) { + public Integer showBitmaskDialog(final Component parentComponent, final DialogAttribBitmask guiAttr) { final String title = "Choose " + guiAttr.ref.getNameNew().substring(0, 1).toUpperCase() + guiAttr.ref.getNameNew().substring(1); final JPanel gridPanel = new JPanel(new GridLayout(0, 2, 3, 3)); final JCheckBox[] checkbox = new JCheckBox[number]; Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-29 08:30:43 UTC (rev 4576) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-29 20:07:21 UTC (rev 4577) @@ -812,7 +812,7 @@ break; case BITMASK: { final JTextArea input = new JTextArea(); - final BitmaskAttrib tmpAttr = new BitmaskAttrib(attrib, input); + final DialogAttribBitmask tmpAttr = new DialogAttribBitmask(attrib, input); if (attrib.getMisc() != null && archetypeTypeSet.getBitmaskTable().containsKey(attrib.getMisc()[0])) { // fetch the bitmask data, then build the attribute panel final CAttribBitmask bitmask = archetypeTypeSet.getBitmaskTable().get(attrib.getMisc()[0]); Deleted: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/BitmaskAttrib.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/BitmaskAttrib.java 2008-07-29 08:30:43 UTC (rev 4576) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/BitmaskAttrib.java 2008-07-29 20:07:21 UTC (rev 4577) @@ -1,80 +0,0 @@ -package net.sf.gridarta.gui.gameobjectattributesdialog; - -import javax.swing.text.JTextComponent; -import net.sf.gridarta.archtype.ArchetypeAttribute; -import net.sf.gridarta.archtype.CAttribBitmask; -import org.apache.log4j.Logger; -import org.jetbrains.annotations.NotNull; - -/** - * DialogAttrib for types with bitmasks to choose from. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class BitmaskAttrib extends DialogAttrib<JTextComponent> { - - /** The Logger for printing log messages. */ - private static final Logger log = Logger.getLogger(BitmaskAttrib.class); - - /** Active bitmask value. */ - private int value; - - /** Reference to the bitmask data. */ - private CAttribBitmask bitmask; - - /** - * Create a BitmaskAttrib. - * @param ref reference to the attribute data - * @param input Input ui component for editing the value. - */ - public BitmaskAttrib(@NotNull final ArchetypeAttribute ref, @NotNull final JTextComponent input) { - super(ref, input); - } - - /** - * Get the active bitmask value. - * @return active bitmask value - */ - public int getValue() { - return value; - } - - /** - * Get the active bitmask value in external file representation. - * @return active bitmask value in external file representation - */ - public String getEncodedValue() { - return bitmask.encodeValue(value); - } - - /** - * Set the active bitmask value. - * @param value new active bitmask value - */ - public void setValue(final int value) { - this.value = value; - if (bitmask != null) { - getInput().setText(bitmask.getText(value)); - } else { - log.warn("null bitmask"); - } - } - - /** - * Set the active bitmask value in external file representation. - * @param encodedValue new active bitmask value in external file - * representation - */ - public void setEncodedValue(final String encodedValue) { - assert bitmask != null; - setValue(bitmask.decodeValue(encodedValue)); - } - - public CAttribBitmask getBitmask() { - return bitmask; - } - - public void setBitmask(final CAttribBitmask bitmask) { - this.bitmask = bitmask; - } - -} // class BitmaskAttrib Copied: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribBitmask.java (from rev 4576, trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/BitmaskAttrib.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribBitmask.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribBitmask.java 2008-07-29 20:07:21 UTC (rev 4577) @@ -0,0 +1,80 @@ +package net.sf.gridarta.gui.gameobjectattributesdialog; + +import javax.swing.text.JTextComponent; +import net.sf.gridarta.archtype.ArchetypeAttribute; +import net.sf.gridarta.archtype.CAttribBitmask; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; + +/** + * DialogAttrib for types with bitmasks to choose from. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public final class DialogAttribBitmask extends DialogAttrib<JTextComponent> { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(DialogAttribBitmask.class); + + /** Active bitmask value. */ + private int value; + + /** Reference to the bitmask data. */ + private CAttribBitmask bitmask; + + /** + * Create a BitmaskAttrib. + * @param ref reference to the attribute data + * @param input Input ui component for editing the value. + */ + public DialogAttribBitmask(@NotNull final ArchetypeAttribute ref, @NotNull final JTextComponent input) { + super(ref, input); + } + + /** + * Get the active bitmask value. + * @return active bitmask value + */ + public int getValue() { + return value; + } + + /** + * Get the active bitmask value in external file representation. + * @return active bitmask value in external file representation + */ + public String getEncodedValue() { + return bitmask.encodeValue(value); + } + + /** + * Set the active bitmask value. + * @param value new active bitmask value + */ + public void setValue(final int value) { + this.value = value; + if (bitmask != null) { + getInput().setText(bitmask.getText(value)); + } else { + log.warn("null bitmask"); + } + } + + /** + * Set the active bitmask value in external file representation. + * @param encodedValue new active bitmask value in external file + * representation + */ + public void setEncodedValue(final String encodedValue) { + assert bitmask != null; + setValue(bitmask.decodeValue(encodedValue)); + } + + public CAttribBitmask getBitmask() { + return bitmask; + } + + public void setBitmask(final CAttribBitmask bitmask) { + this.bitmask = bitmask; + } + +} // class DialogAttribBitmask Property changes on: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribBitmask.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mergeinfo + Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/MaskChangeAL.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/MaskChangeAL.java 2008-07-29 08:30:43 UTC (rev 4576) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/MaskChangeAL.java 2008-07-29 20:07:21 UTC (rev 4577) @@ -12,7 +12,7 @@ /** The serial version UID. */ private static final long serialVersionUID = 1; - private final BitmaskAttrib bmAttr; // attribute structure + private final DialogAttribBitmask bmAttr; // attribute structure /** * Constructor. @@ -20,7 +20,7 @@ * @param newAttr the GUI-bitmask attribute where the change button belongs * to */ - public MaskChangeAL(final String label, final BitmaskAttrib newAttr) { + public MaskChangeAL(final String label, final DialogAttribBitmask newAttr) { super(label); bmAttr = newAttr; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-29 20:17:44
|
Revision: 4578 http://gridarta.svn.sourceforge.net/gridarta/?rev=4578&view=rev Author: akirschbaum Date: 2008-07-29 20:17:49 +0000 (Tue, 29 Jul 2008) Log Message: ----------- Rename ArchAttribType to ArchetypeAttributeType. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeType.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gameobject/ArchAttribType.java Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-29 20:07:21 UTC (rev 4577) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-29 20:17:49 UTC (rev 4578) @@ -34,9 +34,9 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.archtype.ArchetypeAttribute; +import net.sf.gridarta.archtype.ArchetypeAttributeType; import net.sf.gridarta.archtype.ArchetypeType; import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; @@ -99,7 +99,7 @@ // do we have "none" spell? final int selectedIndex; - if (spnum == 0 && attr.getDataType() == ArchAttribType.ZSPELL) { + if (spnum == 0 && attr.getDataType() == ArchetypeAttributeType.ZSPELL) { selectedIndex = 0; } else { // now look up the spell-number in the array of spells @@ -148,7 +148,7 @@ String newFace = null; String newMsg = null; for (final DialogAttrib<?> attr : dialogAttribs) { - final ArchAttribType dType = attr.ref.getDataType(); + final ArchetypeAttributeType dType = attr.ref.getDataType(); switch (dType) { case BOOL: { @@ -176,17 +176,17 @@ case LONG: case FLOAT: { // an int attribute - if (dType == ArchAttribType.INT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { + if (dType == ArchetypeAttributeType.INT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { if (archetype.getAttributeInt(attr.ref.getNameOld()) != 0) { newArchText.append(attr.ref.getNameOld()).append(" 0\n"); } } else - if (dType == ArchAttribType.LONG && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { + if (dType == ArchetypeAttributeType.LONG && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { if (archetype.getAttributeLong(attr.ref.getNameOld()) != 0) { newArchText.append(attr.ref.getNameOld()).append(" 0\n"); } } else - if (dType == ArchAttribType.FLOAT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { + if (dType == ArchetypeAttributeType.FLOAT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { if (archetype.getAttributeString(attr.ref.getNameOld()).length() > 0) { newArchText.append(attr.ref.getNameOld()).append(" 0.0\n"); } @@ -325,7 +325,7 @@ case INV_SPELL_OPTIONAL: { final JComboBox comboBox = ((DialogAttrib<JComboBox>) attr).getInput(); final int index = comboBox.getSelectedIndex(); - final boolean isOptionalSpell = dType == ArchAttribType.INV_SPELL_OPTIONAL; + final boolean isOptionalSpell = dType == ArchetypeAttributeType.INV_SPELL_OPTIONAL; if (index < mainControl.getGameObjectSpells().size() + (isOptionalSpell ? 1 : 0)) { final boolean isModified; switch (gameObject.countInvObjects()) { @@ -430,7 +430,7 @@ // Also write all the 'fixed' attributes into the archtext for (int i = 0; type.getAttr().length > i; i++) { // ### TODO: for changed types, copy fixed attributes over default arches ### - if (type.getAttr()[i].getDataType() == ArchAttribType.FIXED) { + if (type.getAttr()[i].getDataType() == ArchetypeAttributeType.FIXED) { final String defaultValue = archetype.getAttributeString(type.getAttr()[i].getNameOld()); if (defaultValue.length() == 0 || (gameObject.getArchTypNr() != archetype.getArchTypNr() && !defaultValue.equalsIgnoreCase(type.getAttr()[i].getNameNew()))) { // usually, fixed attributes are only applied when *not* defined in the archetype. Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-29 20:07:21 UTC (rev 4577) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-29 20:17:49 UTC (rev 4578) @@ -34,9 +34,9 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.archtype.ArchetypeAttribute; +import net.sf.gridarta.archtype.ArchetypeAttributeType; import net.sf.gridarta.archtype.ArchetypeType; import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; @@ -98,7 +98,7 @@ // do we have "none" spell? final int selectedIndex; - if (spnum == -1 && attr.getDataType() == ArchAttribType.ZSPELL) { + if (spnum == -1 && attr.getDataType() == ArchetypeAttributeType.ZSPELL) { selectedIndex = 0; } else { // now look up the spell-number in the array of spells @@ -147,7 +147,7 @@ String newFace = null; String newMsg = null; for (final DialogAttrib<?> attr : dialogAttribs) { - final ArchAttribType dType = attr.ref.getDataType(); + final ArchetypeAttributeType dType = attr.ref.getDataType(); switch (dType) { case BOOL: { @@ -177,7 +177,7 @@ // an int attribute if (((DialogAttrib<JFormattedTextField>) attr).getInput().getText().equals("0")) { if (archetype.getAttributeDouble(attr.ref.getNameOld()) != 0.0) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(dType == ArchAttribType.FLOAT ? "0.0" : "0").append("\n"); + newArchText.append(attr.ref.getNameOld()).append(" ").append(dType == ArchetypeAttributeType.FLOAT ? "0.0" : "0").append("\n"); } } else { try { @@ -359,7 +359,7 @@ // Also write all the 'fixed' attributes into the archtext for (int i = 0; type.getAttr().length > i; i++) { // ### TODO: for changed types, copy fixed attributes over default arches ### - if (type.getAttr()[i].getDataType() == ArchAttribType.FIXED) { + if (type.getAttr()[i].getDataType() == ArchetypeAttributeType.FIXED) { final String defaultValue = archetype.getAttributeString(type.getAttr()[i].getNameOld()); if (defaultValue.length() == 0 || (gameObject.getArchTypNr() != archetype.getArchTypNr() && !defaultValue.equalsIgnoreCase(type.getAttr()[i].getNameNew()))) { // usually, fixed attributes are only applied when *not* defined in the archetype. Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java 2008-07-29 20:07:21 UTC (rev 4577) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java 2008-07-29 20:17:49 UTC (rev 4578) @@ -19,7 +19,6 @@ package net.sf.gridarta.archtype; -import net.sf.gridarta.gameobject.ArchAttribType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -38,14 +37,14 @@ private final String nameOld; @Nullable - private final String endingOld; // for dataType = ArchAttribType.TEXT this is the terminating string + private final String endingOld; // for dataType = ArchetypeAttributeType.TEXT this is the terminating string // (example: 'endmsg' for arch message) @NotNull private final String nameNew; // new attr. name (for the user-friendly GUI) /** Datatype of this attribute. */ - private final ArchAttribType dataType; + private final ArchetypeAttributeType dataType; /** Description of this attribute. */ private final String text; @@ -55,10 +54,10 @@ @Nullable private final String[] misc; // string array for misc. use - // ArchAttribType.BOOL_SPEC uses misc[0] = true value, misc[1] = false value - // ArchAttribType.BITMASK uses misc[0] = bitmask name - // ArchAttribType.LIST uses misc[0] = list name - // ArchAttribType.TEXT uses misc[0] = file extension; may be null + // ArchetypeAttributeType.BOOL_SPEC uses misc[0] = true value, misc[1] = false value + // ArchetypeAttributeType.BITMASK uses misc[0] = bitmask name + // ArchetypeAttributeType.LIST uses misc[0] = list name + // ArchetypeAttributeType.TEXT uses misc[0] = file extension; may be null /** Identifier of the section this CFArchAttrib is in. */ private int secId; @@ -67,7 +66,7 @@ private String section; /** Create a CFArchAttrib. */ - public ArchetypeAttribute(@NotNull final String nameOld, @Nullable final String endingOld, @NotNull final String nameNew, final ArchAttribType dataType, final String text, final int inputLength, final String[] misc) { + public ArchetypeAttribute(@NotNull final String nameOld, @Nullable final String endingOld, @NotNull final String nameNew, final ArchetypeAttributeType dataType, final String text, final int inputLength, final String[] misc) { this.nameOld = nameOld; this.endingOld = endingOld; this.nameNew = nameNew; @@ -122,7 +121,7 @@ return nameNew; } - public ArchAttribType getDataType() { + public ArchetypeAttributeType getDataType() { return dataType; } Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-07-29 20:07:21 UTC (rev 4577) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-07-29 20:17:49 UTC (rev 4578) @@ -20,7 +20,6 @@ package net.sf.gridarta.archtype; import net.sf.gridarta.CommonConstants; -import net.sf.gridarta.gameobject.ArchAttribType; import org.apache.log4j.Logger; import org.w3c.dom.Attr; import org.w3c.dom.Element; @@ -75,7 +74,7 @@ String nameOld = ""; String endingOld = null; String nameNew = ""; - ArchAttribType dataType = null; + ArchetypeAttributeType dataType = null; int inputLength = 0; String[] misc = null; @@ -111,10 +110,10 @@ // which type of attribute is it? if (atype.equalsIgnoreCase("bool")) { - dataType = ArchAttribType.BOOL; // normal bool + dataType = ArchetypeAttributeType.BOOL; // normal bool } else if (atype.equalsIgnoreCase("bool_special")) { // customized boolean type: - dataType = ArchAttribType.BOOL_SPEC; + dataType = ArchetypeAttributeType.BOOL_SPEC; // parse true and false values: a1 = root.getAttributeNode("true"); @@ -128,23 +127,23 @@ misc[0] = a1.getValue().trim(); // string for true misc[1] = a2.getValue().trim(); // string for false } else if (atype.equalsIgnoreCase("int")) { - dataType = ArchAttribType.INT; + dataType = ArchetypeAttributeType.INT; } else if (atype.equalsIgnoreCase("long")) { - dataType = ArchAttribType.LONG; + dataType = ArchetypeAttributeType.LONG; } else if (atype.equalsIgnoreCase("float")) { - dataType = ArchAttribType.FLOAT; + dataType = ArchetypeAttributeType.FLOAT; } else if (atype.equalsIgnoreCase("string")) { - dataType = ArchAttribType.STRING; + dataType = ArchetypeAttributeType.STRING; } else if (atype.equalsIgnoreCase("map_path")) { - dataType = ArchAttribType.MAP_PATH; + dataType = ArchetypeAttributeType.MAP_PATH; } else if (atype.equalsIgnoreCase("script_file")) { - dataType = ArchAttribType.SCRIPT_FILE; + dataType = ArchetypeAttributeType.SCRIPT_FILE; } else if (atype.equalsIgnoreCase("facename")) { - dataType = ArchAttribType.FACENAME; + dataType = ArchetypeAttributeType.FACENAME; } else if (atype.equalsIgnoreCase("animname")) { - dataType = ArchAttribType.ANIMNAME; + dataType = ArchetypeAttributeType.ANIMNAME; } else if (atype.equalsIgnoreCase("text")) { - dataType = ArchAttribType.TEXT; + dataType = ArchetypeAttributeType.TEXT; // for text data, the terminating string has to be read too if ((a1 = root.getAttributeNode(XML_KEY_ARCH_BEGIN)) != null) { nameOld = a1.getValue().trim(); @@ -165,7 +164,7 @@ } } else if ("fixed".equalsIgnoreCase(atype)) { // fixed attribute - dataType = ArchAttribType.FIXED; + dataType = ArchetypeAttributeType.FIXED; if ((a1 = root.getAttributeNode("value")) != null) { nameNew = a1.getValue().trim(); } else { @@ -174,23 +173,23 @@ } } else if ("spell".equalsIgnoreCase(atype)) { // spell attribute - dataType = ArchAttribType.SPELL; + dataType = ArchetypeAttributeType.SPELL; } else if ("nz_spell".equalsIgnoreCase(atype)) { // spell attribute - dataType = ArchAttribType.ZSPELL; + dataType = ArchetypeAttributeType.ZSPELL; } else if ("inv_spell".equalsIgnoreCase(atype)) { // spell attribute - dataType = ArchAttribType.INV_SPELL; + dataType = ArchetypeAttributeType.INV_SPELL; } else if ("inv_spell_optional".equalsIgnoreCase(atype)) { // spell attribute - dataType = ArchAttribType.INV_SPELL_OPTIONAL; + dataType = ArchetypeAttributeType.INV_SPELL_OPTIONAL; } else if (atype.startsWith("bitmask")) { // got a bitmask attribute final String bitmaskName = atype.substring(8).trim(); if (tlist.getBitmaskTable().containsKey(bitmaskName)) { // the bitmask is well defined - dataType = ArchAttribType.BITMASK; + dataType = ArchetypeAttributeType.BITMASK; misc = new String[1]; misc[0] = bitmaskName; // store bitmask name in misc[0] } else { @@ -202,7 +201,7 @@ final String listName = atype.substring(5).trim(); if (tlist.getListTable().containsKey(listName)) { // the list is well defined - dataType = ArchAttribType.LIST; + dataType = ArchetypeAttributeType.LIST; misc = new String[1]; misc[0] = listName; // store list name in misc[0] } else { @@ -224,7 +223,7 @@ if (tlist.getListTable().containsKey(listName1) && tlist.getListTable().containsKey(listName2)) { // the lists are well defined - dataType = ArchAttribType.DBLLIST; + dataType = ArchetypeAttributeType.DBLLIST; misc = new String[2]; misc[0] = listName1; // store list name in misc[0] misc[1] = listName2; // store list name in misc[1] @@ -232,7 +231,7 @@ log.error("In '" + CommonConstants.TYPEDEF_FILE + "', type " + typeName + ": List \"" + listName1 + "\" or \"" + listName2 + "\" is undefined."); } } else if ("treasurelist".equalsIgnoreCase(atype)) { - dataType = ArchAttribType.TREASURE; + dataType = ArchetypeAttributeType.TREASURE; } else { // unknown type log.warn("In '" + CommonConstants.TYPEDEF_FILE + "': Type " + typeName + " has an attribute with unknown type: '" + atype + "'."); Copied: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeType.java (from rev 4577, trunk/src/app/net/sf/gridarta/gameobject/ArchAttribType.java) =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeType.java (rev 0) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeType.java 2008-07-29 20:17:49 UTC (rev 4578) @@ -0,0 +1,88 @@ +/* + * 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 net.sf.gridarta.archtype; + +/** + * Enumeration for Archetype Attribute Types. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public enum ArchetypeAttributeType { + + /** Boolean -> Checkbox. */ + BOOL, + + /** Boolean -> Checkbox, with customized true/false values. */ + BOOL_SPEC, + + /** Integer -> Textfield. */ + INT, + + /** Long -> Textfield. */ + LONG, + + /** Float -> Textfield. */ + FLOAT, + + /** String -> Textfield. */ + STRING, + + /** Map path name. */ + MAP_PATH, + + /** Script file name. */ + SCRIPT_FILE, + + /** Text -> Textarea. */ + TEXT, + + /** Fixed String -> (No input). */ + FIXED, + + /** Spell -> Spell number (Combobox). */ + SPELL, + + /** ZSpell -> Spell number (except that 0 is always 0, not magic bullet). */ + ZSPELL, + + /** Spell object in inventory -> Spell name (Combobox). */ + INV_SPELL, + + /** Optional spell object in inventory -> Spell name (Combobox). */ + INV_SPELL_OPTIONAL, + + /** Bitmask -> Special input with popup frame. */ + BITMASK, + + /** List -> Combobox. */ + LIST, + + /** Treasure -> treasurelist (Textfield and Tree). */ + TREASURE, + + /** Double List -> 2 × Combobox. */ + DBLLIST, + + /** Face name -> Textfield and Tree. */ + FACENAME, + + /** Animation name -> Textfield and Tree. */ + ANIMNAME + +} // enum ArchetypeAttributeType Property changes on: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeType.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mergeinfo + Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java 2008-07-29 20:07:21 UTC (rev 4577) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java 2008-07-29 20:17:49 UTC (rev 4578) @@ -26,7 +26,6 @@ import java.util.Map; import java.util.Set; import net.sf.gridarta.CommonConstants; -import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.japi.xml.NodeListIterator; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -357,7 +356,7 @@ attrList.add(attrib); // parsing succeeded, now assign this attribute to a section - if (attrib.getDataType() == ArchAttribType.TEXT) { + if (attrib.getDataType() == ArchetypeAttributeType.TEXT) { // text attributes all have their own section attrib.setSection(archetypeType.sectionNum, attrib.getNameNew()); archetypeType.sectionNum++; Deleted: trunk/src/app/net/sf/gridarta/gameobject/ArchAttribType.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/ArchAttribType.java 2008-07-29 20:07:21 UTC (rev 4577) +++ trunk/src/app/net/sf/gridarta/gameobject/ArchAttribType.java 2008-07-29 20:17:49 UTC (rev 4578) @@ -1,88 +0,0 @@ -/* - * 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 net.sf.gridarta.gameobject; - -/** - * Enumeration for Archetype Attribute Types. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public enum ArchAttribType { - - /** Boolean -> Checkbox. */ - BOOL, - - /** Boolean -> Checkbox, with customized true/false values. */ - BOOL_SPEC, - - /** Integer -> Textfield. */ - INT, - - /** Long -> Textfield. */ - LONG, - - /** Float -> Textfield. */ - FLOAT, - - /** String -> Textfield. */ - STRING, - - /** Map path name. */ - MAP_PATH, - - /** Script file name. */ - SCRIPT_FILE, - - /** Text -> Textarea. */ - TEXT, - - /** Fixed String -> (No input). */ - FIXED, - - /** Spell -> Spell number (Combobox). */ - SPELL, - - /** ZSpell -> Spell number (except that 0 is always 0, not magic bullet). */ - ZSPELL, - - /** Spell object in inventory -> Spell name (Combobox). */ - INV_SPELL, - - /** Optional spell object in inventory -> Spell name (Combobox). */ - INV_SPELL_OPTIONAL, - - /** Bitmask -> Special input with popup frame. */ - BITMASK, - - /** List -> Combobox. */ - LIST, - - /** Treasure -> treasurelist (Textfield and Tree). */ - TREASURE, - - /** Double List -> 2 × Combobox. */ - DBLLIST, - - /** Face name -> Textfield and Tree. */ - FACENAME, - - /** Animation name -> Textfield and Tree. */ - ANIMNAME - -} // enum ArchAttribType Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-29 20:07:21 UTC (rev 4577) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-29 20:17:49 UTC (rev 4578) @@ -74,10 +74,10 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; import net.sf.gridarta.archtype.ArchetypeAttribute; +import net.sf.gridarta.archtype.ArchetypeAttributeType; import net.sf.gridarta.archtype.ArchetypeType; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.archtype.CAttribBitmask; -import net.sf.gridarta.gameobject.ArchAttribType; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; @@ -304,7 +304,7 @@ * @return the completed <code>JComboBox</code> */ private JComboBox buildInvSpellBox(final ArchetypeAttribute attr) { - final boolean isOptionalSpell = attr.getDataType() == ArchAttribType.INV_SPELL_OPTIONAL; + final boolean isOptionalSpell = attr.getDataType() == ArchetypeAttributeType.INV_SPELL_OPTIONAL; final Vector<String> content = new Vector<String>(); final int selectedIndex; @Nullable final String title; @@ -532,11 +532,11 @@ for (int i = 0; type.getAttr().length > i; i++) { if (type.getAttr()[i].getSecId() == secId) { // count number of attributes - if (type.getAttr()[i].getDataType() != ArchAttribType.FIXED) { + if (type.getAttr()[i].getDataType() != ArchetypeAttributeType.FIXED) { number++; } // check for bitmask attributes - if (!hasBitmask && type.getAttr()[i].getDataType() == ArchAttribType.BITMASK) { + if (!hasBitmask && type.getAttr()[i].getDataType() == ArchetypeAttributeType.BITMASK) { hasBitmask = true; } } @@ -568,8 +568,8 @@ // now add the entrys, line by line for (int i = 0; attribs.length > i; i++) { final ArchetypeAttribute attrib = attribs[i]; - final ArchAttribType dType = attrib.getDataType(); // data type of the attribute - if (attrib.getSecId() == secId && dType != ArchAttribType.FIXED) { + final ArchetypeAttributeType dType = attrib.getDataType(); // data type of the attribute + if (attrib.getSecId() == secId && dType != ArchetypeAttributeType.FIXED) { final String nameOld = attrib.getNameOld(); final JButton helpButton = new JButton("?"); helpButton.setMargin(new Insets(0, 5, 0, 5)); @@ -636,7 +636,7 @@ case LONG: case FLOAT: { cLabel = new JLabel(attrib.getNameNew() + ": "); - cLabel.setForeground(dType == ArchAttribType.FLOAT ? CommonConstants.FLOAT_COLOR : CommonConstants.INT_COLOR); + cLabel.setForeground(dType == ArchetypeAttributeType.FLOAT ? CommonConstants.FLOAT_COLOR : CommonConstants.INT_COLOR); final int fieldLength = attrib.getInputLength() == 0 ? TEXTFIELD_COLUMNS : attrib.getInputLength(); final NumberFormat format; switch (dType) { @@ -725,11 +725,11 @@ case MAP_PATH: case SCRIPT_FILE: { cLabel = new JLabel(attrib.getNameNew() + ": "); - final TilePanel tilePanel = new TilePanel(dType == ArchAttribType.MAP_PATH ? mapFileFilter : mainControl.getScriptFileFilter()); - tilePanel.setAbsoluteReference(dType == ArchAttribType.MAP_PATH ? mainControl.getGlobalSettings().getMapDir() : mainControl.getGlobalSettings().getMapDir()); + final TilePanel tilePanel = new TilePanel(dType == ArchetypeAttributeType.MAP_PATH ? mapFileFilter : mainControl.getScriptFileFilter()); + tilePanel.setAbsoluteReference(dType == ArchetypeAttributeType.MAP_PATH ? mainControl.getGlobalSettings().getMapDir() : mainControl.getGlobalSettings().getMapDir()); tilePanel.setOriginal(gameObject.getAttributeString(nameOld)); File relativeReference; - if (dType == ArchAttribType.MAP_PATH) { + if (dType == ArchetypeAttributeType.MAP_PATH) { relativeReference = gameObject.getMapSquare().getMapModel().getMapControl().getMapFile(); if (relativeReference == null) { relativeReference = new File(mainControl.getGlobalSettings().getMapDir(), "dummy"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-30 07:47:44
|
Revision: 4582 http://gridarta.svn.sourceforge.net/gridarta/?rev=4582&view=rev Author: akirschbaum Date: 2008-07-30 07:47:52 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-29 20:56:23 UTC (rev 4581) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 07:47:52 UTC (rev 4582) @@ -70,6 +70,11 @@ private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; /** + * The index used for "no" spell. + */ + private final int undefinedSpellIndex; + + /** * Constructor, creates the GUI layout. * @param gameObjectAttributesDialogFactory the associated factory * @param archetypeTypeSet the list of CF type-data @@ -81,10 +86,12 @@ * @param treasureListTree the treasure list tree * @param faceObjects the FaceObjects instance to use * @param mapFileFilter the Swing file filter to use + * @param undefinedSpellIndex the index used for "no" spell */ - public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { + public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int undefinedSpellIndex) { super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter); this.mapManager = mapManager; + this.undefinedSpellIndex = undefinedSpellIndex; } /** {@inheritDoc} */ @@ -94,12 +101,12 @@ int spnum = gameObject.getAttributeInt(attr.getNameOld()); // spell number if (spnum < 0 || spnum >= mainControl.getNumberSpells().size()) { - spnum = 0; // undefined spellnumbers be 0 + spnum = undefinedSpellIndex; } // do we have "none" spell? final int selectedIndex; - if (spnum == 0 && attr.getDataType() == ArchetypeAttributeType.ZSPELL) { + if (spnum == undefinedSpellIndex && attr.getDataType() == ArchetypeAttributeType.ZSPELL) { selectedIndex = 0; } else { // now look up the spell-number in the array of spells @@ -296,7 +303,7 @@ case SPELL: case ZSPELL: final int index = ((DialogAttrib<JComboBox>) attr).getInput().getSelectedIndex(); - attrVal = index == 0 ? 0 : mainControl.getNumberSpells().getSpell(index - 1).getNumber(); + attrVal = index == 0 ? undefinedSpellIndex : mainControl.getNumberSpells().getSpell(index - 1).getNumber(); break; case LIST: // get selected index of ComboBox Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-29 20:56:23 UTC (rev 4581) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 07:47:52 UTC (rev 4582) @@ -54,7 +54,7 @@ /** {@inheritDoc} */ @Override protected GameObjectAttributesDialog newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { - return new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter); + return new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, 0); } } // class GameObjectAttributesDialogFactory Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-29 20:56:23 UTC (rev 4581) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 07:47:52 UTC (rev 4582) @@ -69,6 +69,11 @@ private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; /** + * The index used for "no" spell. + */ + private final int undefinedSpellIndex; + + /** * Constructor, creates the GUI layout. * @param gameObjectAttributesDialogFactory the associated factory * @param archetypeTypeSet the list of CF type-data @@ -80,10 +85,12 @@ * @param treasureListTree the treasure list tree * @param faceObjects the FaceObjects instance to use * @param mapFileFilter the Swing file filter to use + * @param undefinedSpellIndex the index used for "no" spell */ - public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { + public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int undefinedSpellIndex) { super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter); this.mapManager = mapManager; + this.undefinedSpellIndex = undefinedSpellIndex; } /** {@inheritDoc} */ @@ -92,13 +99,13 @@ // first parse the spell-number value from gameObject int spnum = gameObject.getAttributeInt(attr.getNameOld()); // spell number - if (spnum < -1 || spnum >= mainControl.getNumberSpells().size()) { - spnum = -1; // undefined spellnumbers be -1 + if (spnum < 0 || spnum >= mainControl.getNumberSpells().size()) { + spnum = undefinedSpellIndex; } // do we have "none" spell? final int selectedIndex; - if (spnum == -1 && attr.getDataType() == ArchetypeAttributeType.ZSPELL) { + if (spnum == undefinedSpellIndex && attr.getDataType() == ArchetypeAttributeType.ZSPELL) { selectedIndex = 0; } else { // now look up the spell-number in the array of spells @@ -287,7 +294,7 @@ case SPELL: case ZSPELL: final int index = ((DialogAttrib<JComboBox>) attr).getInput().getSelectedIndex(); - attrVal = index == 0 ? -1 : mainControl.getNumberSpells().getSpell(index - 1).getNumber(); + attrVal = index == 0 ? undefinedSpellIndex : mainControl.getNumberSpells().getSpell(index - 1).getNumber(); break; case LIST: // get selected index of ComboBox Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-29 20:56:23 UTC (rev 4581) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 07:47:52 UTC (rev 4582) @@ -54,7 +54,7 @@ /** {@inheritDoc} */ @Override protected GameObjectAttributesDialog newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { - return new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter); + return new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, -1); } } // class GameObjectAttributesDialogFactory This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-30 18:42:00
|
Revision: 4585 http://gridarta.svn.sourceforge.net/gridarta/?rev=4585&view=rev Author: akirschbaum Date: 2008-07-30 18:42:01 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 18:32:56 UTC (rev 4584) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 18:42:01 UTC (rev 4585) @@ -70,6 +70,11 @@ private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; /** + * The object type for event objects. + */ + private final int typeNoEventConnector; + + /** * The index used for "no" spell. */ private final int undefinedSpellIndex; @@ -86,11 +91,13 @@ * @param treasureListTree the treasure list tree * @param faceObjects the FaceObjects instance to use * @param mapFileFilter the Swing file filter to use + * @param typeNoEventConnector the object type for event objects * @param undefinedSpellIndex the index used for "no" spell */ - public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int undefinedSpellIndex) { + public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex) { super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter); this.mapManager = mapManager; + this.typeNoEventConnector = typeNoEventConnector; this.undefinedSpellIndex = undefinedSpellIndex; } @@ -244,7 +251,7 @@ if (inline != null) { if (attr.ref.getNameOld().equalsIgnoreCase("name")) { // special case #1: "name"-textfield - if (typeStruct.getTypeNo() == Archetype.TYPE_EVENT_CONNECTOR) { + if (typeNoEventConnector != 0 && typeStruct.getTypeNo() == typeNoEventConnector) { // events are special: they do not inherit the // archetype name for empty names newName = inline; Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 18:32:56 UTC (rev 4584) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 18:42:01 UTC (rev 4585) @@ -54,7 +54,7 @@ /** {@inheritDoc} */ @Override protected GameObjectAttributesDialog newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { - return new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, 0); + return new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, Archetype.TYPE_EVENT_CONNECTOR, 0); } } // class GameObjectAttributesDialogFactory Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 18:32:56 UTC (rev 4584) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 18:42:01 UTC (rev 4585) @@ -70,6 +70,11 @@ private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; /** + * The object type for event objects. + */ + private final int typeNoEventConnector; + + /** * The index used for "no" spell. */ private final int undefinedSpellIndex; @@ -86,11 +91,13 @@ * @param treasureListTree the treasure list tree * @param faceObjects the FaceObjects instance to use * @param mapFileFilter the Swing file filter to use + * @param typeNoEventConnector the object type for event objects * @param undefinedSpellIndex the index used for "no" spell */ - public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int undefinedSpellIndex) { + public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex) { super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter); this.mapManager = mapManager; + this.typeNoEventConnector = typeNoEventConnector; this.undefinedSpellIndex = undefinedSpellIndex; } @@ -244,6 +251,11 @@ if (inline != null) { if (attr.ref.getNameOld().equalsIgnoreCase("name")) { // special case #1: "name"-textfield + if (typeNoEventConnector != 0 && typeStruct.getTypeNo() == typeNoEventConnector) { + // events are special: they do not inherit the + // archetype name for empty names + newName = inline; + } else if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { if (!inline.equals(archetype.getObjName())) { newName = inline; Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 18:32:56 UTC (rev 4584) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 18:42:01 UTC (rev 4585) @@ -54,7 +54,7 @@ /** {@inheritDoc} */ @Override protected GameObjectAttributesDialog newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { - return new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, -1); + return new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, 0, -1); } } // class GameObjectAttributesDialogFactory This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-30 18:51:42
|
Revision: 4586 http://gridarta.svn.sourceforge.net/gridarta/?rev=4586&view=rev Author: akirschbaum Date: 2008-07-30 18:51:39 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 18:42:01 UTC (rev 4585) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 18:51:39 UTC (rev 4586) @@ -95,7 +95,7 @@ * @param undefinedSpellIndex the index used for "no" spell */ public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex) { - super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter); + super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector); this.mapManager = mapManager; this.typeNoEventConnector = typeNoEventConnector; this.undefinedSpellIndex = undefinedSpellIndex; @@ -515,10 +515,4 @@ return true; // apply succeeded } - /** {@inheritDoc} */ - @Override - protected boolean isSpecialNameHandling() { - return type.getTypeNo() != Archetype.TYPE_EVENT_CONNECTOR; - } - } // class GameObjectAttributesDialog Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 18:42:01 UTC (rev 4585) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 18:51:39 UTC (rev 4586) @@ -95,7 +95,7 @@ * @param undefinedSpellIndex the index used for "no" spell */ public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex) { - super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter); + super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector); this.mapManager = mapManager; this.typeNoEventConnector = typeNoEventConnector; this.undefinedSpellIndex = undefinedSpellIndex; Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-30 18:42:01 UTC (rev 4585) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-30 18:51:39 UTC (rev 4586) @@ -146,6 +146,11 @@ /** Swing FileFilter for map files. */ private final FileFilter mapFileFilter; + /** + * The object type for event objects. + */ + private int typeNoEventConnector; + protected final List<DialogAttrib<?>> dialogAttribs = new ArrayList<DialogAttrib<?>>(); private JComboBox typesel; // selection box for type @@ -203,8 +208,9 @@ * @param treasureListTree the treasure list tree * @param faceObjects the face objects instance to use * @param mapFileFilter the Swing FileFilter for map files + * @param typeNoEventConnector the object type for event objects */ - protected AbstractGameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<G, A, R, ?> gameObjectAttributesDialogFactory, final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, ?> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { + protected AbstractGameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<G, A, R, ?> gameObjectAttributesDialogFactory, final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, ?> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector) { this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.archetypeTypeSet = archetypeTypeSet; this.gameObject = gameObject.getHead(); @@ -214,6 +220,7 @@ this.treasureListTree = treasureListTree; this.faceObjects = faceObjects; this.mapFileFilter = mapFileFilter; + this.typeNoEventConnector = typeNoEventConnector; archetype = this.gameObject.getArchetype(); type = archetypeTypeSet.getArchetypeType(gameObject); @@ -680,7 +687,7 @@ case ANIMNAME: { final String dtxt; if (nameOld.equalsIgnoreCase("name")) { - if (!isSpecialNameHandling()) { + if (typeNoEventConnector != 0 && type.getTypeNo() == typeNoEventConnector) { dtxt = gameObject.getObjName(); } else if (gameObject.getObjName() != null && gameObject.getObjName().length() > 0) { @@ -880,17 +887,6 @@ } /** - * Determine if the "name" attribute should inherit its default value from - * the archetype name. - * @return <code>true</code> if the archetype name should be used for an - * empty "name" attribute, or <code>false</code> if an empty name - * should be used - */ - protected boolean isSpecialNameHandling() { - return true; - } - - /** * Looks up the section name from the ID. * @param secId ID of the section * @return name of that section This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-30 19:10:50
|
Revision: 4587 http://gridarta.svn.sourceforge.net/gridarta/?rev=4587&view=rev Author: akirschbaum Date: 2008-07-30 19:10:44 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 18:51:39 UTC (rev 4586) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 19:10:44 UTC (rev 4587) @@ -80,6 +80,11 @@ private final int undefinedSpellIndex; /** + * Whether face names are included in the object text. + */ + private final boolean includeFaceText; + + /** * Constructor, creates the GUI layout. * @param gameObjectAttributesDialogFactory the associated factory * @param archetypeTypeSet the list of CF type-data @@ -93,12 +98,15 @@ * @param mapFileFilter the Swing file filter to use * @param typeNoEventConnector the object type for event objects * @param undefinedSpellIndex the index used for "no" spell + * @param includeFaceText whether face names are included in the object + * text */ - public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex) { + public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector); this.mapManager = mapManager; this.typeNoEventConnector = typeNoEventConnector; this.undefinedSpellIndex = undefinedSpellIndex; + this.includeFaceText = includeFaceText; } /** {@inheritDoc} */ @@ -277,6 +285,13 @@ gameObject.setAnimName(archetype.getAnimName()); } } else if (attr.ref.getNameOld().equalsIgnoreCase("face")) { + if (includeFaceText && inline.length() > 0) { + // decide we have to add a "face <name>" string to the gameObject text + // Note, that the realFaceName itself is set below + if (archetype.getFaceName() == null || archetype.getFaceName().compareTo(inline.trim()) != 0) { + newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); + } + } newFace = inline; } else { if (!inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 18:51:39 UTC (rev 4586) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 19:10:44 UTC (rev 4587) @@ -54,7 +54,7 @@ /** {@inheritDoc} */ @Override protected GameObjectAttributesDialog newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { - return new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, Archetype.TYPE_EVENT_CONNECTOR, 0); + return new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, Archetype.TYPE_EVENT_CONNECTOR, 0, false); } } // class GameObjectAttributesDialogFactory Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 18:51:39 UTC (rev 4586) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 19:10:44 UTC (rev 4587) @@ -80,6 +80,11 @@ private final int undefinedSpellIndex; /** + * Whether face names are included in the object text. + */ + private final boolean includeFaceText; + + /** * Constructor, creates the GUI layout. * @param gameObjectAttributesDialogFactory the associated factory * @param archetypeTypeSet the list of CF type-data @@ -93,12 +98,15 @@ * @param mapFileFilter the Swing file filter to use * @param typeNoEventConnector the object type for event objects * @param undefinedSpellIndex the index used for "no" spell + * @param includeFaceText whether face names are included in the object + * text */ - public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex) { + public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector); this.mapManager = mapManager; this.typeNoEventConnector = typeNoEventConnector; this.undefinedSpellIndex = undefinedSpellIndex; + this.includeFaceText = includeFaceText; } /** {@inheritDoc} */ @@ -277,7 +285,7 @@ gameObject.setAnimName(archetype.getAnimName()); } } else if (attr.ref.getNameOld().equalsIgnoreCase("face")) { - if (inline.length() > 0) { + if (includeFaceText && inline.length() > 0) { // decide we have to add a "face <name>" string to the gameObject text // Note, that the realFaceName itself is set below if (archetype.getFaceName() == null || archetype.getFaceName().compareTo(inline.trim()) != 0) { Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 18:51:39 UTC (rev 4586) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 19:10:44 UTC (rev 4587) @@ -54,7 +54,7 @@ /** {@inheritDoc} */ @Override protected GameObjectAttributesDialog newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { - return new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, 0, -1); + return new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, 0, -1, true); } } // class GameObjectAttributesDialogFactory This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-30 19:49:01
|
Revision: 4588 http://gridarta.svn.sourceforge.net/gridarta/?rev=4588&view=rev Author: akirschbaum Date: 2008-07-30 19:48:39 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Split ArchetypeAttributeType and DialogAttrib classes into sub-classes, one for each archetype attribute type. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeType.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttrib.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribBitmask.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/MaskChangeAL.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/ViewTreasurelistAL.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeAnimName.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeBitmask.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeBool.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeBoolSpec.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeDoubleList.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeFaceName.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeFactory.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeFixed.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeFloat.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeInt.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeInvSpell.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeInvSpellOptional.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeList.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeLong.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeMapPath.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeScriptFile.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeSpell.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeString.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeText.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeTreasure.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeVisitor.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTypeZSpell.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribAnimName.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribBool.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribBoolSpec.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribDoubleList.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribFaceName.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribFloat.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribInt.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribInvSpell.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribInvSpellOptional.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribList.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribLong.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribMapPath.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribScriptFile.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribSpell.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribString.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribText.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribTreasure.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribZSpell.java Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 19:10:44 UTC (rev 4587) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 19:48:39 UTC (rev 4588) @@ -23,18 +23,14 @@ import cfeditor.gameobject.GameObject; import cfeditor.gui.map.CMapViewBasic; import cfeditor.map.MapArchObject; -import java.util.List; import java.util.Vector; -import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JFormattedTextField; -import javax.swing.JTextField; import javax.swing.filechooser.FileFilter; -import javax.swing.text.JTextComponent; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.archtype.ArchetypeAttribute; -import net.sf.gridarta.archtype.ArchetypeAttributeType; +import net.sf.gridarta.archtype.ArchetypeAttributeTypeFixed; +import net.sf.gridarta.archtype.ArchetypeAttributeTypeZSpell; import net.sf.gridarta.archtype.ArchetypeType; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.ArchetypeSet; @@ -43,14 +39,10 @@ import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttrib; -import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribBitmask; import net.sf.gridarta.gui.gameobjectattributesdialog.StringKeyManager; -import net.sf.gridarta.gui.map.TilePanel; -import net.sf.gridarta.spells.GameObjectSpell; import net.sf.gridarta.spells.NumberSpell; import net.sf.gridarta.spells.Spell; import net.sf.gridarta.spells.Spells; -import net.sf.gridarta.textedit.textarea.JEditTextArea; import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; @@ -70,21 +62,11 @@ private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; /** - * The object type for event objects. - */ - private final int typeNoEventConnector; - - /** * The index used for "no" spell. */ private final int undefinedSpellIndex; /** - * Whether face names are included in the object text. - */ - private final boolean includeFaceText; - - /** * Constructor, creates the GUI layout. * @param gameObjectAttributesDialogFactory the associated factory * @param archetypeTypeSet the list of CF type-data @@ -102,11 +84,9 @@ * text */ public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { - super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector); + super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); this.mapManager = mapManager; - this.typeNoEventConnector = typeNoEventConnector; this.undefinedSpellIndex = undefinedSpellIndex; - this.includeFaceText = includeFaceText; } /** {@inheritDoc} */ @@ -121,7 +101,7 @@ // do we have "none" spell? final int selectedIndex; - if (spnum == undefinedSpellIndex && attr.getDataType() == ArchetypeAttributeType.ZSPELL) { + if (spnum == undefinedSpellIndex && attr.getDataType() instanceof ArchetypeAttributeTypeZSpell) { selectedIndex = 0; } else { // now look up the spell-number in the array of spells @@ -156,304 +136,30 @@ return -1; } - /** - * 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 - */ + /** {@inheritDoc} */ @Override protected boolean applySettings2() { final ArchetypeType typeStruct = archetypeTypeSet.getTypeOfArch(gameObject); // the type structure for this gameObject final StringBuilder newArchText = new StringBuilder(); - String newName = null; - String newFace = null; - String newMsg = null; - for (final DialogAttrib<?> attr : dialogAttribs) { - final ArchetypeAttributeType dType = attr.ref.getDataType(); - - switch (dType) { - case BOOL: { - // a boolean attribute (flag) - if (((DialogAttrib<JCheckBox>) attr).getInput().isSelected() != (archetype.getAttributeInt(attr.ref.getNameOld()) == 1)) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(((DialogAttrib<JCheckBox>) attr).getInput().isSelected() ? 1 : 0).append("\n"); - } + final String[] newName = new String[1]; + final String[] newFace = new String[1]; + final String[] newMsg = new String[1]; + final String[] newAnim = new String[1]; + for (final DialogAttrib<GameObject, MapArchObject, Archetype, ?> attr : dialogAttribs) { + final String text = attr.getText2(gameObject, archetype, newName, newFace, newMsg, newAnim, typeStruct, this); + if (text == null) { + return false; } - break; - case BOOL_SPEC: { - // a boolean attribute with customized true/false values - final String valString; // value-string to apply - if (((DialogAttrib<JCheckBox>) attr).getInput().isSelected()) { - valString = attr.ref.getMisc()[0]; // true string - } else { - valString = attr.ref.getMisc()[1]; // false string - } - // now see if we need to write it into the archtext or not - if ((valString.equals("0") && !(archetype.getAttributeString(attr.ref.getNameOld()).length() == 0)) || (!valString.equals("0") && !archetype.getAttributeString(attr.ref.getNameOld()).equals(valString))) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(valString).append("\n"); - } + if (text.length() > 0) { + newArchText.append(text).append("\n"); } - break; - case INT: - case LONG: - case FLOAT: { - // an int attribute - if (dType == ArchetypeAttributeType.INT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { - if (archetype.getAttributeInt(attr.ref.getNameOld()) != 0) { - newArchText.append(attr.ref.getNameOld()).append(" 0\n"); - } - } else - if (dType == ArchetypeAttributeType.LONG && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { - if (archetype.getAttributeLong(attr.ref.getNameOld()) != 0) { - newArchText.append(attr.ref.getNameOld()).append(" 0\n"); - } - } else - if (dType == ArchetypeAttributeType.FLOAT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { - if (archetype.getAttributeString(attr.ref.getNameOld()).length() > 0) { - newArchText.append(attr.ref.getNameOld()).append(" 0.0\n"); - } - } else { - try { - switch (dType) { - case INT: { - final int value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).intValue(); - if (archetype.getAttributeInt(attr.ref.getNameOld()) != value) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - case LONG: { - final long value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).longValue(); - if (archetype.getAttributeLong(attr.ref.getNameOld()) != value) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - case FLOAT: { - final double value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).doubleValue(); - // The following floating point equality comparison is okay and known not to cause problems. - //noinspection FloatingPointEquality - if (archetype.getAttributeDouble(attr.ref.getNameOld()) != value) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - default: - assert false; - break; - } - } catch (final NumberFormatException e) { - // parsing failed: wrong entry!! - showMessageDialog(this, "Attribute '" + attr.ref.getNameNew() + "' must be a number!", "Input Error", ERROR_MESSAGE); - return false; - } - } - } - break; - case STRING: - case FACENAME: - case ANIMNAME: { - // a String attribute - final String inline = ((DialogAttrib<JTextField>) attr).getInput().getText().trim(); - - if (inline != null) { - if (attr.ref.getNameOld().equalsIgnoreCase("name")) { - // special case #1: "name"-textfield - if (typeNoEventConnector != 0 && typeStruct.getTypeNo() == typeNoEventConnector) { - // events are special: they do not inherit the - // archetype name for empty names - newName = inline; - } else - if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { - if (!inline.equals(archetype.getObjName())) { - newName = inline; - } else { - newName = ""; - } - } else - if (!inline.equals(archetype.getArchetypeName())) { - newName = inline; - } else { - newName = ""; - } - } else - if (attr.ref.getNameOld().equalsIgnoreCase("animation")) { - if (inline.length() > 0 && !inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - gameObject.setAnimName(inline); - } else { - gameObject.setAnimName(archetype.getAnimName()); - } - } else if (attr.ref.getNameOld().equalsIgnoreCase("face")) { - if (includeFaceText && inline.length() > 0) { - // decide we have to add a "face <name>" string to the gameObject text - // Note, that the realFaceName itself is set below - if (archetype.getFaceName() == null || archetype.getFaceName().compareTo(inline.trim()) != 0) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - } - } - newFace = inline; - } else { - if (!inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - } - } - } - } - break; - case MAP_PATH: - case SCRIPT_FILE: { - final String newString = ((DialogAttrib<TilePanel>) attr).getInput().getText().trim(); - if (!archetype.getAttributeString(attr.ref.getNameOld()).equals(newString)) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(newString).append("\n"); - } - } - break; - case TEXT: { - // a String attribute - if (attr.ref.getNameOld().equalsIgnoreCase("msg") && ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim().length() > 0) { - newMsg = ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim(); - } - } - break; - case SPELL: - case ZSPELL: - case LIST: { - // get attribute value that should go into the gameObject - final int attrVal; // attribute value - switch (dType) { - case SPELL: - case ZSPELL: - final int index = ((DialogAttrib<JComboBox>) attr).getInput().getSelectedIndex(); - attrVal = index == 0 ? undefinedSpellIndex : mainControl.getNumberSpells().getSpell(index - 1).getNumber(); - break; - case LIST: - // get selected index of ComboBox - final int attrValTmp = ((JComboBox) attr.getInput()).getSelectedIndex(); - // fetch value according to this list entry: - attrVal = ((List<Integer>) archetypeTypeSet.getListTable().get(attr.ref.getMisc()[0])).get(2 * attrValTmp); - break; - default: - assert false; - attrVal = 0; - break; - } - - if (archetype.getAttributeInt(attr.ref.getNameOld()) != attrVal) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(attrVal).append("\n"); - } - } - break; - case INV_SPELL: - case INV_SPELL_OPTIONAL: { - final JComboBox comboBox = ((DialogAttrib<JComboBox>) attr).getInput(); - final int index = comboBox.getSelectedIndex(); - final boolean isOptionalSpell = dType == ArchetypeAttributeType.INV_SPELL_OPTIONAL; - if (index < mainControl.getGameObjectSpells().size() + (isOptionalSpell ? 1 : 0)) { - final boolean isModified; - switch (gameObject.countInvObjects()) { - case 0: - // game object has no inventory ==> isModified if - // anything other than <none> is selected - isModified = index != mainControl.getGameObjectSpells().size(); - break; - - default: - // game object has multiple inventories ==> always isModified - isModified = true; - break; - - case 1: - if (index >= mainControl.getGameObjectSpells().size()) { - // game object has one inventory, <none> is - // selected ==> isModified - isModified = true; - } else { - // game object has one inventory, a spell is - // selected ==> isModified if a different spell is - // selected - final GameObject invObject = gameObject.iterator().next(); - if (!invObject.isDefaultGameObject()) { - isModified = true; - } else { - final String invObjectArchetypeName = invObject.getArchetype().getArchetypeName(); - final GameObjectSpell<GameObject, MapArchObject, Archetype> spellObject = mainControl.getGameObjectSpells().getSpell(index); - isModified = !invObjectArchetypeName.equals(spellObject.getArchetypeName()); - } - } - break; - } - if (isModified) { - gameObject.removeAll(); - if (index < mainControl.getGameObjectSpells().size()) { - final GameObject spellObject = mainControl.getGameObjectSpells().getSpell(index).createGameObject(); - spellObject.postParseGameObject(0); - gameObject.addLast(spellObject); - } - - // remove the entry for a customized spell - final int modelSize = comboBox.getModel().getSize(); - if (modelSize > mainControl.getGameObjectSpells().size() + (isOptionalSpell ? 1 : 0)) { - comboBox.removeItemAt(modelSize - 1); - } - } - } - } - break; - case DBLLIST: { - final int val1 = ((List<Integer>) archetypeTypeSet.getListTable().get(attr.ref.getMisc()[0])).get(2 * ((JComboBox[]) attr.getInput())[0].getSelectedIndex()); - final int val2 = ((List<Integer>) archetypeTypeSet.getListTable().get(attr.ref.getMisc()[1])).get(2 * ((JComboBox[]) attr.getInput())[1].getSelectedIndex()); - final int combinedVal = val1 + val2; - - if (archetype.getAttributeInt(attr.ref.getNameOld()) != combinedVal) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(combinedVal).append("\n"); - } - } - break; - case BITMASK: { - // a bitmask attribute (similar to integer, but easier because no parsing needed) - final String value = ((DialogAttribBitmask) attr).getEncodedValue(); // get bitmask value - String oldValue = archetype.getAttributeString(attr.ref.getNameOld()); - if (oldValue.length() == 0) { - oldValue = "0"; - } - - if (!oldValue.equals(value)) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - case TREASURE: { - // a treasurelist attribute - final String inline = ((JTextComponent) attr.getInput()).getText().trim(); // input string - - if (inline != null) { - final boolean isNone = inline.equals(CFTreasureListTree.NONE_SYM) || inline.length() == 0; - - if (!isNone && !CFTreasureListTree.containsTreasureList(inline) && !inline.equalsIgnoreCase(archetype.getAttributeString(attr.ref.getNameOld()))) { - // The user has specified a WRONG treasurelist name, and it does not come - // from the default gameObject. -> Error and out. - showMessageDialog(this, "In attribute '" + attr.ref.getNameNew() + "':\n" + "'" + inline + "' is not a known treasurelist name!", "Input Error", ERROR_MESSAGE); - return false; - } - - if (!inline.equalsIgnoreCase(archetype.getAttributeString(attr.ref.getNameOld())) && !(isNone && archetype.getAttributeString(attr.ref.getNameOld()).length() == 0)) { - if (isNone) { - newArchText.append(attr.ref.getNameOld()).append(" none\n"); - } else { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - } - } - } - } - break; - } } // Also write all the 'fixed' attributes into the archtext for (int i = 0; type.getAttr().length > i; i++) { // ### TODO: for changed types, copy fixed attributes over default arches ### - if (type.getAttr()[i].getDataType() == ArchetypeAttributeType.FIXED) { + if (type.getAttr()[i].getDataType() instanceof ArchetypeAttributeTypeFixed) { final String defaultValue = archetype.getAttributeString(type.getAttr()[i].getNameOld()); if (defaultValue.length() == 0 || (gameObject.getArchTypNr() != archetype.getArchTypNr() && !defaultValue.equalsIgnoreCase(type.getAttr()[i].getNameNew()))) { // usually, fixed attributes are only applied when *not* defined in the archetype. @@ -480,27 +186,27 @@ // --- parsing succeeded, now we write it into the gameObject/map --- gameObject.setObjectText(newArchText.toString()); //gameObject.setArchTypNr(); - if (newName != null) { - if (newName.length() == 0) { + if (newName[0] != null) { + if (newName[0].length() == 0) { gameObject.setObjName(null); } else { - gameObject.setObjName(newName); + gameObject.setObjName(newName[0]); } } - if (newFace != null) { - gameObject.setRealFace(newFace); + if (newFace[0] != null) { + gameObject.setRealFace(newFace[0]); } // now lets assign the visible face - perhaps we have still a anim gameObject.setObjectFace(); imagePanel.setIcon(getFace(gameObject)); - if (newMsg != null) { + if (newMsg[0] != null) { // set new msg text only when it is not equal to Archetype - if (!newMsg.trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { + if (!newMsg[0].trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { gameObject.deleteMsgText(); - gameObject.addMsgText(newMsg); + gameObject.addMsgText(newMsg[0]); } else { gameObject.deleteMsgText(); } @@ -513,6 +219,10 @@ gameObject.deleteMsgText(); // all empty } + if (newAnim[0] != null) { + gameObject.setAnimName(newAnim[0]); + } + // deal with syntax errors now if (errors != null) { if (typeStruct == archetypeTypeSet.getArchetypeType(0)) { Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 19:10:44 UTC (rev 4587) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 19:48:39 UTC (rev 4588) @@ -23,18 +23,14 @@ import daieditor.gameobject.GameObject; import daieditor.gui.map.CMapViewBasic; import daieditor.map.MapArchObject; -import java.util.List; import java.util.Vector; -import javax.swing.JCheckBox; import javax.swing.JComboBox; -import javax.swing.JFormattedTextField; -import javax.swing.JTextField; import javax.swing.filechooser.FileFilter; -import javax.swing.text.JTextComponent; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.archtype.ArchetypeAttribute; -import net.sf.gridarta.archtype.ArchetypeAttributeType; +import net.sf.gridarta.archtype.ArchetypeAttributeTypeFixed; +import net.sf.gridarta.archtype.ArchetypeAttributeTypeZSpell; import net.sf.gridarta.archtype.ArchetypeType; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.ArchetypeSet; @@ -43,14 +39,10 @@ import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttrib; -import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribBitmask; import net.sf.gridarta.gui.gameobjectattributesdialog.StringKeyManager; -import net.sf.gridarta.gui.map.TilePanel; -import net.sf.gridarta.spells.GameObjectSpell; import net.sf.gridarta.spells.NumberSpell; import net.sf.gridarta.spells.Spell; import net.sf.gridarta.spells.Spells; -import net.sf.gridarta.textedit.textarea.JEditTextArea; import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; @@ -70,21 +62,11 @@ private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; /** - * The object type for event objects. - */ - private final int typeNoEventConnector; - - /** * The index used for "no" spell. */ private final int undefinedSpellIndex; /** - * Whether face names are included in the object text. - */ - private final boolean includeFaceText; - - /** * Constructor, creates the GUI layout. * @param gameObjectAttributesDialogFactory the associated factory * @param archetypeTypeSet the list of CF type-data @@ -102,11 +84,9 @@ * text */ public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { - super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector); + super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); this.mapManager = mapManager; - this.typeNoEventConnector = typeNoEventConnector; this.undefinedSpellIndex = undefinedSpellIndex; - this.includeFaceText = includeFaceText; } /** {@inheritDoc} */ @@ -121,7 +101,7 @@ // do we have "none" spell? final int selectedIndex; - if (spnum == undefinedSpellIndex && attr.getDataType() == ArchetypeAttributeType.ZSPELL) { + if (spnum == undefinedSpellIndex && attr.getDataType() instanceof ArchetypeAttributeTypeZSpell) { selectedIndex = 0; } else { // now look up the spell-number in the array of spells @@ -156,304 +136,30 @@ return -1; } - /** - * 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 - */ + /** {@inheritDoc} */ @Override protected boolean applySettings2() { final ArchetypeType typeStruct = archetypeTypeSet.getTypeOfArch(gameObject); // the type structure for this gameObject final StringBuilder newArchText = new StringBuilder(); - String newName = null; - String newFace = null; - String newMsg = null; - for (final DialogAttrib<?> attr : dialogAttribs) { - final ArchetypeAttributeType dType = attr.ref.getDataType(); - - switch (dType) { - case BOOL: { - // a boolean attribute (flag) - if (((DialogAttrib<JCheckBox>) attr).getInput().isSelected() != (archetype.getAttributeInt(attr.ref.getNameOld()) == 1)) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(((DialogAttrib<JCheckBox>) attr).getInput().isSelected() ? 1 : 0).append("\n"); - } + final String[] newName = new String[1]; + final String[] newFace = new String[1]; + final String[] newMsg = new String[1]; + final String[] newAnim = new String[1]; + for (final DialogAttrib<GameObject, MapArchObject, Archetype, ?> attr : dialogAttribs) { + final String text = attr.getText2(gameObject, archetype, newName, newFace, newMsg, newAnim, typeStruct, this); + if (text == null) { + return false; } - break; - case BOOL_SPEC: { - // a boolean attribute with customized true/false values - final String valString; // value-string to apply - if (((DialogAttrib<JCheckBox>) attr).getInput().isSelected()) { - valString = attr.ref.getMisc()[0]; // true string - } else { - valString = attr.ref.getMisc()[1]; // false string - } - // now see if we need to write it into the archtext or not - if ((valString.equals("0") && !(archetype.getAttributeString(attr.ref.getNameOld()).length() == 0)) || (!valString.equals("0") && !archetype.getAttributeString(attr.ref.getNameOld()).equals(valString))) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(valString).append("\n"); - } + if (text.length() > 0) { + newArchText.append(text).append("\n"); } - break; - case INT: - case LONG: - case FLOAT: { - // an int attribute - if (dType == ArchetypeAttributeType.INT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { - if (archetype.getAttributeInt(attr.ref.getNameOld()) != 0) { - newArchText.append(attr.ref.getNameOld()).append(" 0\n"); - } - } else - if (dType == ArchetypeAttributeType.LONG && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { - if (archetype.getAttributeLong(attr.ref.getNameOld()) != 0) { - newArchText.append(attr.ref.getNameOld()).append(" 0\n"); - } - } else - if (dType == ArchetypeAttributeType.FLOAT && ((DialogAttrib<JFormattedTextField>) attr).getInput().getText().trim().length() == 0) { - if (archetype.getAttributeString(attr.ref.getNameOld()).length() > 0) { - newArchText.append(attr.ref.getNameOld()).append(" 0.0\n"); - } - } else { - try { - switch (dType) { - case INT: { - final int value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).intValue(); - if (archetype.getAttributeInt(attr.ref.getNameOld()) != value) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - case LONG: { - final long value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).longValue(); - if (archetype.getAttributeLong(attr.ref.getNameOld()) != value) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - case FLOAT: { - final double value = ((Number) ((DialogAttrib<JFormattedTextField>) attr).getInput().getValue()).doubleValue(); - // The following floating point equality comparison is okay and known not to cause problems. - //noinspection FloatingPointEquality - if (archetype.getAttributeDouble(attr.ref.getNameOld()) != value) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - default: - assert false; - break; - } - } catch (final NumberFormatException e) { - // parsing failed: wrong entry!! - showMessageDialog(this, "Attribute '" + attr.ref.getNameNew() + "' must be a number!", "Input Error", ERROR_MESSAGE); - return false; - } - } - } - break; - case STRING: - case FACENAME: - case ANIMNAME: { - // a String attribute - final String inline = ((DialogAttrib<JTextField>) attr).getInput().getText().trim(); - - if (inline != null) { - if (attr.ref.getNameOld().equalsIgnoreCase("name")) { - // special case #1: "name"-textfield - if (typeNoEventConnector != 0 && typeStruct.getTypeNo() == typeNoEventConnector) { - // events are special: they do not inherit the - // archetype name for empty names - newName = inline; - } else - if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { - if (!inline.equals(archetype.getObjName())) { - newName = inline; - } else { - newName = ""; - } - } else - if (!inline.equals(archetype.getArchetypeName())) { - newName = inline; - } else { - newName = ""; - } - } else - if (attr.ref.getNameOld().equalsIgnoreCase("animation")) { - if (inline.length() > 0 && !inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - gameObject.setAnimName(inline); - } else { - gameObject.setAnimName(archetype.getAnimName()); - } - } else if (attr.ref.getNameOld().equalsIgnoreCase("face")) { - if (includeFaceText && inline.length() > 0) { - // decide we have to add a "face <name>" string to the gameObject text - // Note, that the realFaceName itself is set below - if (archetype.getFaceName() == null || archetype.getFaceName().compareTo(inline.trim()) != 0) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - } - } - newFace = inline; - } else { - if (!inline.equals(archetype.getAttributeString(attr.ref.getNameOld()))) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - } - } - } - } - break; - case MAP_PATH: - case SCRIPT_FILE: { - final String newString = ((DialogAttrib<TilePanel>) attr).getInput().getText().trim(); - if (!archetype.getAttributeString(attr.ref.getNameOld()).equals(newString)) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(newString).append("\n"); - } - } - break; - case TEXT: { - // a String attribute - if (attr.ref.getNameOld().equalsIgnoreCase("msg") && ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim().length() > 0) { - newMsg = ((DialogAttrib<JEditTextArea>) attr).getInput().getText().trim(); - } - } - break; - case SPELL: - case ZSPELL: - case LIST: { - // get attribute value that should go into the gameObject - final int attrVal; // attribute value - switch (dType) { - case SPELL: - case ZSPELL: - final int index = ((DialogAttrib<JComboBox>) attr).getInput().getSelectedIndex(); - attrVal = index == 0 ? undefinedSpellIndex : mainControl.getNumberSpells().getSpell(index - 1).getNumber(); - break; - case LIST: - // get selected index of ComboBox - final int attrValTmp = ((JComboBox) attr.getInput()).getSelectedIndex(); - // fetch value according to this list entry: - attrVal = ((List<Integer>) archetypeTypeSet.getListTable().get(attr.ref.getMisc()[0])).get(2 * attrValTmp); - break; - default: - assert false; - attrVal = 0; - break; - } - - if (archetype.getAttributeInt(attr.ref.getNameOld()) != attrVal) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(attrVal).append("\n"); - } - } - break; - case INV_SPELL: - case INV_SPELL_OPTIONAL: { - final JComboBox comboBox = ((DialogAttrib<JComboBox>) attr).getInput(); - final int index = comboBox.getSelectedIndex(); - final boolean isOptionalSpell = dType == ArchetypeAttributeType.INV_SPELL_OPTIONAL; - if (index < mainControl.getGameObjectSpells().size() + (isOptionalSpell ? 1 : 0)) { - final boolean isModified; - switch (gameObject.countInvObjects()) { - case 0: - // game object has no inventory ==> isModified if - // anything other than <none> is selected - isModified = index != mainControl.getGameObjectSpells().size(); - break; - - default: - // game object has multiple inventories ==> always isModified - isModified = true; - break; - - case 1: - if (index >= mainControl.getGameObjectSpells().size()) { - // game object has one inventory, <none> is - // selected ==> isModified - isModified = true; - } else { - // game object has one inventory, a spell is - // selected ==> isModified if a different spell is - // selected - final GameObject invObject = gameObject.iterator().next(); - if (!invObject.isDefaultGameObject()) { - isModified = true; - } else { - final String invObjectArchetypeName = invObject.getArchetype().getArchetypeName(); - final GameObjectSpell<GameObject, MapArchObject, Archetype> spellObject = mainControl.getGameObjectSpells().getSpell(index); - isModified = !invObjectArchetypeName.equals(spellObject.getArchetypeName()); - } - } - break; - } - if (isModified) { - gameObject.removeAll(); - if (index < mainControl.getGameObjectSpells().size()) { - final GameObject spellObject = mainControl.getGameObjectSpells().getSpell(index).createGameObject(); - spellObject.postParseGameObject(0); - gameObject.addLast(spellObject); - } - - // remove the entry for a customized spell - final int modelSize = comboBox.getModel().getSize(); - if (modelSize > mainControl.getGameObjectSpells().size() + (isOptionalSpell ? 1 : 0)) { - comboBox.removeItemAt(modelSize - 1); - } - } - } - } - break; - case DBLLIST: { - final int val1 = ((List<Integer>) archetypeTypeSet.getListTable().get(attr.ref.getMisc()[0])).get(2 * ((JComboBox[]) attr.getInput())[0].getSelectedIndex()); - final int val2 = ((List<Integer>) archetypeTypeSet.getListTable().get(attr.ref.getMisc()[1])).get(2 * ((JComboBox[]) attr.getInput())[1].getSelectedIndex()); - final int combinedVal = val1 + val2; - - if (archetype.getAttributeInt(attr.ref.getNameOld()) != combinedVal) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(combinedVal).append("\n"); - } - } - break; - case BITMASK: { - // a bitmask attribute (similar to integer, but easier because no parsing needed) - final String value = ((DialogAttribBitmask) attr).getEncodedValue(); // get bitmask value - String oldValue = archetype.getAttributeString(attr.ref.getNameOld()); - if (oldValue.length() == 0) { - oldValue = "0"; - } - - if (!oldValue.equals(value)) { - newArchText.append(attr.ref.getNameOld()).append(" ").append(value).append("\n"); - } - } - break; - case TREASURE: { - // a treasurelist attribute - final String inline = ((JTextComponent) attr.getInput()).getText().trim(); // input string - - if (inline != null) { - final boolean isNone = inline.equals(CFTreasureListTree.NONE_SYM) || inline.length() == 0; - - if (!isNone && !CFTreasureListTree.containsTreasureList(inline) && !inline.equalsIgnoreCase(archetype.getAttributeString(attr.ref.getNameOld()))) { - // The user has specified a WRONG treasurelist name, and it does not come - // from the default gameObject. -> Error and out. - showMessageDialog(this, "In attribute '" + attr.ref.getNameNew() + "':\n" + "'" + inline + "' is not a known treasurelist name!", "Input Error", ERROR_MESSAGE); - return false; - } - - if (!inline.equalsIgnoreCase(archetype.getAttributeString(attr.ref.getNameOld())) && !(isNone && archetype.getAttributeString(attr.ref.getNameOld()).length() == 0)) { - if (isNone) { - newArchText.append(attr.ref.getNameOld()).append(" none\n"); - } else { - newArchText.append(attr.ref.getNameOld()).append(" ").append(inline).append("\n"); - } - } - } - } - break; - } } // Also write all the 'fixed' attributes into the archtext for (int i = 0; type.getAttr().length > i; i++) { // ### TODO: for changed types, copy fixed attributes over default arches ### - if (type.getAttr()[i].getDataType() == ArchetypeAttributeType.FIXED) { + if (type.getAttr()[i].getDataType() instanceof ArchetypeAttributeTypeFixed) { final String defaultValue = archetype.getAttributeString(type.getAttr()[i].getNameOld()); if (defaultValue.length() == 0 || (gameObject.getArchTypNr() != archetype.getArchTypNr() && !defaultValue.equalsIgnoreCase(type.getAttr()[i].getNameNew()))) { // usually, fixed attributes are only applied when *not* defined in the archetype. @@ -480,27 +186,27 @@ // --- parsing succeeded, now we write it into the gameObject/map --- gameObject.setObjectText(newArchText.toString()); //gameObject.setArchTypNr(); - if (newName != null) { - if (newName.length() == 0) { + if (newName[0] != null) { + if (newName[0].length() == 0) { gameObject.setObjName(null); } else { - gameObject.setObjName(newName); + gameObject.setObjName(newName[0]); } } - if (newFace != null) { - gameObject.setRealFace(newFace); + if (newFace[0] != null) { + gameObject.setRealFace(newFace[0]); } // now lets assign the visible face - perhaps we have still a anim gameObject.setObjectFace(); imagePanel.setIcon(getFace(gameObject)); - if (newMsg != null) { + if (newMsg[0] != null) { // set new msg text only when it is not equal to Archetype - if (!newMsg.trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { + if (!newMsg[0].trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { gameObject.deleteMsgText(); - gameObject.addMsgText(newMsg); + gameObject.addMsgText(newMsg[0]); } else { gameObject.deleteMsgText(); } @@ -513,6 +219,10 @@ gameObject.deleteMsgText(); // all empty } + if (newAnim[0] != null) { + gameObject.setAnimName(newAnim[0]); + } + // deal with syntax errors now if (errors != null) { if (typeStruct == archetypeTypeSet.getArchetypeType(0)) { Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-07-30 19:10:44 UTC (rev 4587) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java 2008-07-30 19:48:39 UTC (rev 4588) @@ -110,10 +110,10 @@ // which type of attribute is it? if (atype.equalsIgnoreCase("bool")) { - dataType = ArchetypeAttributeType.BOOL; // normal bool + dataType = ArchetypeAttributeTypeFactory.BOOL; // normal bool } else if (atype.equalsIgnoreCase("bool_special")) { // customized boolean type: - dataType = ArchetypeAttributeType.BOOL_SPEC; + dataType = ArchetypeAttributeTypeFactory.BOOL_SPEC; // parse true and false values: a1 = root.getAttributeNode("true"); @@ -127,23 +127,23 @@ misc[0] = a1.getValue().trim(); // string for true misc[1] = a2.getValue().trim(); // string for false } else if (atype.equalsIgnoreCase("int")) { - dataType = ArchetypeAttributeType.INT; + dataType = ArchetypeAttributeTypeFactory.INT; } else if (atype.equalsIgnoreCase("long")) { - dataType = ArchetypeAttributeType.LONG; + dataType = ArchetypeAttributeTypeFactory.LONG; } else if (atype.equalsIgnoreCase("float")) { - dataType = ArchetypeAttributeType.FLOAT; + dataType = ArchetypeAttributeTypeFactory.FLOAT; } else if (atype.equalsIgnoreCase("string")) { - dataType = ArchetypeAttributeType.STRING; + dataType = ArchetypeAttributeTypeFactory.STRING; } else if (atype.equalsIgnoreCase("map_path")) { - dataType = ArchetypeAttributeType.MAP_PATH; + dataType = ArchetypeAttributeTypeFactory.MAP_PATH; } else if (atype.equalsIgnoreCase("script_file")) { - dataType = ArchetypeAttributeType.SCRIPT_FILE; + dataType = ArchetypeAttributeTypeFactory.SCRIPT_FILE; } else if (atype.equalsIgnoreCase("facename")) { - dataType = ArchetypeAttributeType.FACENAME; + dataType = ArchetypeAttributeTypeFactory.FACENAME; } else if (atype.equalsIgnoreCase("animname")) { - dataType = ArchetypeAttributeType.ANIMNAME; + dataType = ArchetypeAttributeTypeFactory.ANIMNAME; } else if (atype.equalsIgnoreCase("text")) { - dataType = ArchetypeAttributeType.TEXT; + dataType = ArchetypeAttributeTypeFactory.TEXT; // for text data, the terminating string has to be read too if ((a1 = root.getAttributeNode(XML_KEY_ARCH_BEGIN)) != null) { nameOld = a1.getValue().trim(); @@ -164,7 +164,7 @@ } } else if ("fixed".equalsIgnoreCase(atype)) { // fixed attribute - dataType = ArchetypeAttributeType.FIXED; + dataType = ArchetypeAttributeTypeFactory.FIXED; if ((a1 = root.getAttributeNode("value")) != null) { nameNew = a1.getValue().trim(); } else { @@ -173,23 +173,23 @@ } } else if ("spell".equalsIgnoreCase(atype)) { // spell attribute - dataType = ArchetypeAttributeType.SPELL; + dataType = ArchetypeAttributeTypeFactory.SPELL; } else if ("nz_spell".equalsIgnoreCase(atype)) { // spell attribute - dataType = ArchetypeAttributeType.ZSPELL; + dataType = ArchetypeAttributeTypeFactory.ZSPELL; } else if ("inv_spell".equalsIgnoreCase(atype)) { // spell attribute - dataType = ArchetypeAttributeType.INV_SPELL; + dataType = ArchetypeAttributeTypeFactory.INV_SPELL; } else if ("inv_spell_optional".equalsIgnoreCase(atype)) { // spell attribute - dataType = ArchetypeAttributeType.INV_SPELL_OPTIONAL; + dataType = ArchetypeAttributeTypeFactory.INV_SPELL_OPTIONAL; } else if (atype.startsWith("bitmask")) { // got a bitmask attribute final String bitmaskName = atype.substring(8).trim(); if (tlist.getBitmaskTable().containsKey(bitmaskName)) { // the bitmask is well defined - dataType = ArchetypeAttributeType.BITMASK; + dataType = ArchetypeAttributeTypeFactory.BITMASK; misc = new String[1]; misc[0] = bitmaskName; // store bitmask name in misc[0] } else { @@ -201,7 +201,7 @@ final String listName = atype.substring(5).trim(); if (tlist.getListTable().containsKey(listName)) { // the list is well defined - dataType = ArchetypeAttributeType.LIST; + dataType = ArchetypeAttributeTypeFactory.LIST; misc = new String[1]; misc[0] = listName; // store list name in misc[0] } else { @@ -223,7 +223,7 @@ if (tlist.getListTable().containsKey(listName1) && tlist.getListTable().containsKey(listName2)) { // the lists are well defined - dataType = ArchetypeAttributeType.DBLLIST; + dataType = ArchetypeAttributeTypeFactory.DBLLIST; misc = new String[2]; misc[0] = listName1; // store list name in misc[0] misc[1] = listName2; // store list name in misc[1] @@ -231,7 +231,7 @@ log.error("In '" + CommonConstants.TYPEDEF_FILE + "', type " + typeName + ": List \"" + listName1 + "\" or \"" + listName2 + "\" is undefined."); } } else if ("treasurelist".equalsIgnoreCase(atype)) { - dataType = ArchetypeAttributeType.TREASURE; + dataType = ArchetypeAttributeTypeFactory.TREASURE; } else { // unknown type log.warn("In '" + CommonConstants.TYPEDEF_FILE + "': Type " + typeName + " has an attribute with unknown type: '" + atype + "'."); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeType.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeType.java 2008-07-30 19:10:44 UTC (rev 4587) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeType.java 2008-07-30 19:48:39 UTC (rev 4588) @@ -23,66 +23,8 @@ * Enumeration for Archetype Attribute Types. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public enum ArchetypeAttributeType { +public interface ArchetypeAttributeType { - /** Boolean -> Checkbox. */ - BOOL, + void accept(ArchetypeAttributeTypeVisitor visitor); - /** Boolean -> Checkbox, with customized true/false values. */ - BOOL_SPEC, - - /** Integer -> Textfield. */ - INT, - - /** Long -> Textfield. */ - LONG, - - /** Float -> Textfield. */ - FLOAT, - - /** String -> Textfield. */ - STRING, - - /** Map path name. */ - MAP_PATH, - - /** Script file n... [truncated message content] |
From: <aki...@us...> - 2008-07-30 20:05:23
|
Revision: 4589 http://gridarta.svn.sourceforge.net/gridarta/?rev=4589&view=rev Author: akirschbaum Date: 2008-07-30 20:05:21 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Move code to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 19:48:39 UTC (rev 4588) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 20:05:21 UTC (rev 4589) @@ -23,26 +23,15 @@ import cfeditor.gameobject.GameObject; import cfeditor.gui.map.CMapViewBasic; import cfeditor.map.MapArchObject; -import java.util.Vector; -import javax.swing.JComboBox; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; -import net.sf.gridarta.archtype.ArchetypeAttribute; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeFixed; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeZSpell; -import net.sf.gridarta.archtype.ArchetypeType; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; -import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttrib; -import net.sf.gridarta.gui.gameobjectattributesdialog.StringKeyManager; -import net.sf.gridarta.spells.NumberSpell; -import net.sf.gridarta.spells.Spell; -import net.sf.gridarta.spells.Spells; import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; @@ -57,16 +46,7 @@ /** Serial Version UID. */ private static final long serialVersionUID = 1L; - /** The map manager. */ - @NotNull - private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; - /** - * The index used for "no" spell. - */ - private final int undefinedSpellIndex; - - /** * Constructor, creates the GUI layout. * @param gameObjectAttributesDialogFactory the associated factory * @param archetypeTypeSet the list of CF type-data @@ -84,160 +64,7 @@ * text */ public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { - super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); - this.mapManager = mapManager; - this.undefinedSpellIndex = undefinedSpellIndex; + super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); } - /** {@inheritDoc} */ - @Override - protected JComboBox buildSpellBox(final ArchetypeAttribute attr) { - // first parse the spell-number value from gameObject - int spnum = gameObject.getAttributeInt(attr.getNameOld()); // spell number - - if (spnum < 0 || spnum >= mainControl.getNumberSpells().size()) { - spnum = undefinedSpellIndex; - } - - // do we have "none" spell? - final int selectedIndex; - if (spnum == undefinedSpellIndex && attr.getDataType() instanceof ArchetypeAttributeTypeZSpell) { - selectedIndex = 0; - } else { - // now look up the spell-number in the array of spells - selectedIndex = 1 + findSpellIndex(spnum); - } - - final Vector<String> content = new Vector<String>(); - content.add("<none>"); - for (final Spell spell : mainControl.getNumberSpells()) { - content.add(spell.getName()); - } - final JComboBox comboBox = new JComboBox(content); - comboBox.setSelectedIndex(selectedIndex); - comboBox.setMaximumRowCount(10); - comboBox.setKeySelectionManager(new StringKeyManager(comboBox)); - comboBox.setName(attr.getNameNew()); - return comboBox; - } - - /** - * Return the spell index for a spell number. - * @param number The spell number. - * @return The spell object. - */ - private int findSpellIndex(final int number) { - final Spells<NumberSpell> spells = mainControl.getNumberSpells(); - for (int i = 0; i < spells.size(); i++) { - if (spells.getSpell(i).getNumber() == number) { - return i; - } - } - return -1; - } - - /** {@inheritDoc} */ - @Override - protected boolean applySettings2() { - final ArchetypeType typeStruct = archetypeTypeSet.getTypeOfArch(gameObject); // the type structure for this gameObject - - final StringBuilder newArchText = new StringBuilder(); - final String[] newName = new String[1]; - final String[] newFace = new String[1]; - final String[] newMsg = new String[1]; - final String[] newAnim = new String[1]; - for (final DialogAttrib<GameObject, MapArchObject, Archetype, ?> attr : dialogAttribs) { - final String text = attr.getText2(gameObject, archetype, newName, newFace, newMsg, newAnim, typeStruct, this); - if (text == null) { - return false; - } - if (text.length() > 0) { - newArchText.append(text).append("\n"); - } - } - - // Also write all the 'fixed' attributes into the archtext - for (int i = 0; type.getAttr().length > i; i++) { - // ### TODO: for changed types, copy fixed attributes over default arches ### - if (type.getAttr()[i].getDataType() instanceof ArchetypeAttributeTypeFixed) { - final String defaultValue = archetype.getAttributeString(type.getAttr()[i].getNameOld()); - if (defaultValue.length() == 0 || (gameObject.getArchTypNr() != archetype.getArchTypNr() && !defaultValue.equalsIgnoreCase(type.getAttr()[i].getNameNew()))) { - // usually, fixed attributes are only applied when *not* defined in the archetype. - // the reason behind this is: if the default gameObject violates our fixed attribute, - // we assume the default gameObject is "right" and we are "wrong". The typedefs aren't that trustworthy. - // BUT - if the gameObject has a changed type, the archetype has lost it's credibility. - // So, in this special case, the fixed attribute applies always. - newArchText.append(type.getAttr()[i].getNameOld()).append(" ").append(type.getAttr()[i].getNameNew()).append("\n"); - } - } - } - - /* we have excluded direction hard coded from the attribut panel - * because we have a better interface in the gameObject panel. - * But we need to add when needed the gameObject text - we do it here. - */ - if (gameObject.getDirection() != archetype.getDirection()) { - newArchText.append("direction ").append(gameObject.getDirection()).append("\n"); - } - // before we modify the archtext, we look for errors and save them. - // later the user must confirm whether to keep or dump those errors - final String errors = gameObject.getSyntaxErrors(typeStruct); - - // --- parsing succeeded, now we write it into the gameObject/map --- - gameObject.setObjectText(newArchText.toString()); - //gameObject.setArchTypNr(); - if (newName[0] != null) { - if (newName[0].length() == 0) { - gameObject.setObjName(null); - } else { - gameObject.setObjName(newName[0]); - } - } - - if (newFace[0] != null) { - gameObject.setRealFace(newFace[0]); - } - - // now lets assign the visible face - perhaps we have still a anim - gameObject.setObjectFace(); - imagePanel.setIcon(getFace(gameObject)); - - if (newMsg[0] != null) { - // set new msg text only when it is not equal to Archetype - if (!newMsg[0].trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { - gameObject.deleteMsgText(); - gameObject.addMsgText(newMsg[0]); - } else { - gameObject.deleteMsgText(); - } - } else - if (archetype.getMsgText() != null && archetype.getMsgText().trim().length() > 0) { - // we must override archetype msg by an empty msg - gameObject.deleteMsgText(); - gameObject.addMsgText(""); - } else { - gameObject.deleteMsgText(); // all empty - } - - if (newAnim[0] != null) { - gameObject.setAnimName(newAnim[0]); - } - - // deal with syntax errors now - if (errors != null) { - if (typeStruct == archetypeTypeSet.getArchetypeType(0)) { - // for generic (misc) type, all errors are automatically kept. - // "misc" is no real type - it is more a default mask for unknown types - gameObject.addObjectText(errors.trim()); - } else { - // open a popup dialog and ask user to decide what to do with his errors - askConfirmErrors(errors); - } - } - - gameObject.updateEditType(mapManager.getCurrentMap().getActiveEditType()); - - return true; // apply succeeded - } - } // class GameObjectAttributesDialog Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 19:48:39 UTC (rev 4588) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 20:05:21 UTC (rev 4589) @@ -23,26 +23,15 @@ import daieditor.gameobject.GameObject; import daieditor.gui.map.CMapViewBasic; import daieditor.map.MapArchObject; -import java.util.Vector; -import javax.swing.JComboBox; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; -import net.sf.gridarta.archtype.ArchetypeAttribute; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeFixed; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeZSpell; -import net.sf.gridarta.archtype.ArchetypeType; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; -import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttrib; -import net.sf.gridarta.gui.gameobjectattributesdialog.StringKeyManager; -import net.sf.gridarta.spells.NumberSpell; -import net.sf.gridarta.spells.Spell; -import net.sf.gridarta.spells.Spells; import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; @@ -57,16 +46,7 @@ /** Serial Version UID. */ private static final long serialVersionUID = 1L; - /** The map manager. */ - @NotNull - private final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager; - /** - * The index used for "no" spell. - */ - private final int undefinedSpellIndex; - - /** * Constructor, creates the GUI layout. * @param gameObjectAttributesDialogFactory the associated factory * @param archetypeTypeSet the list of CF type-data @@ -84,160 +64,7 @@ * text */ public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { - super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); - this.mapManager = mapManager; - this.undefinedSpellIndex = undefinedSpellIndex; + super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); } - /** {@inheritDoc} */ - @Override - protected JComboBox buildSpellBox(final ArchetypeAttribute attr) { - // first parse the spell-number value from gameObject - int spnum = gameObject.getAttributeInt(attr.getNameOld()); // spell number - - if (spnum < 0 || spnum >= mainControl.getNumberSpells().size()) { - spnum = undefinedSpellIndex; - } - - // do we have "none" spell? - final int selectedIndex; - if (spnum == undefinedSpellIndex && attr.getDataType() instanceof ArchetypeAttributeTypeZSpell) { - selectedIndex = 0; - } else { - // now look up the spell-number in the array of spells - selectedIndex = 1 + findSpellIndex(spnum); - } - - final Vector<String> content = new Vector<String>(); - content.add("<none>"); - for (final Spell spell : mainControl.getNumberSpells()) { - content.add(spell.getName()); - } - final JComboBox comboBox = new JComboBox(content); - comboBox.setSelectedIndex(selectedIndex); - comboBox.setMaximumRowCount(10); - comboBox.setKeySelectionManager(new StringKeyManager(comboBox)); - comboBox.setName(attr.getNameNew()); - return comboBox; - } - - /** - * Return the spell index for a spell number. - * @param number The spell number. - * @return The spell object. - */ - private int findSpellIndex(final int number) { - final Spells<NumberSpell> spells = mainControl.getNumberSpells(); - for (int i = 0; i < spells.size(); i++) { - if (spells.getSpell(i).getNumber() == number) { - return i; - } - } - return -1; - } - - /** {@inheritDoc} */ - @Override - protected boolean applySettings2() { - final ArchetypeType typeStruct = archetypeTypeSet.getTypeOfArch(gameObject); // the type structure for this gameObject - - final StringBuilder newArchText = new StringBuilder(); - final String[] newName = new String[1]; - final String[] newFace = new String[1]; - final String[] newMsg = new String[1]; - final String[] newAnim = new String[1]; - for (final DialogAttrib<GameObject, MapArchObject, Archetype, ?> attr : dialogAttribs) { - final String text = attr.getText2(gameObject, archetype, newName, newFace, newMsg, newAnim, typeStruct, this); - if (text == null) { - return false; - } - if (text.length() > 0) { - newArchText.append(text).append("\n"); - } - } - - // Also write all the 'fixed' attributes into the archtext - for (int i = 0; type.getAttr().length > i; i++) { - // ### TODO: for changed types, copy fixed attributes over default arches ### - if (type.getAttr()[i].getDataType() instanceof ArchetypeAttributeTypeFixed) { - final String defaultValue = archetype.getAttributeString(type.getAttr()[i].getNameOld()); - if (defaultValue.length() == 0 || (gameObject.getArchTypNr() != archetype.getArchTypNr() && !defaultValue.equalsIgnoreCase(type.getAttr()[i].getNameNew()))) { - // usually, fixed attributes are only applied when *not* defined in the archetype. - // the reason behind this is: if the default gameObject violates our fixed attribute, - // we assume the default gameObject is "right" and we are "wrong". The typedefs aren't that trustworthy. - // BUT - if the gameObject has a changed type, the archetype has lost it's credibility. - // So, in this special case, the fixed attribute applies always. - newArchText.append(type.getAttr()[i].getNameOld()).append(" ").append(type.getAttr()[i].getNameNew()).append("\n"); - } - } - } - - /* we have excluded direction hard coded from the attribut panel - * because we have a better interface in the gameObject panel. - * But we need to add when needed the gameObject text - we do it here. - */ - if (gameObject.getDirection() != archetype.getDirection()) { - newArchText.append("direction ").append(gameObject.getDirection()).append("\n"); - } - // before we modify the archtext, we look for errors and save them. - // later the user must confirm whether to keep or dump those errors - final String errors = gameObject.getSyntaxErrors(typeStruct); - - // --- parsing succeeded, now we write it into the gameObject/map --- - gameObject.setObjectText(newArchText.toString()); - //gameObject.setArchTypNr(); - if (newName[0] != null) { - if (newName[0].length() == 0) { - gameObject.setObjName(null); - } else { - gameObject.setObjName(newName[0]); - } - } - - if (newFace[0] != null) { - gameObject.setRealFace(newFace[0]); - } - - // now lets assign the visible face - perhaps we have still a anim - gameObject.setObjectFace(); - imagePanel.setIcon(getFace(gameObject)); - - if (newMsg[0] != null) { - // set new msg text only when it is not equal to Archetype - if (!newMsg[0].trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { - gameObject.deleteMsgText(); - gameObject.addMsgText(newMsg[0]); - } else { - gameObject.deleteMsgText(); - } - } else - if (archetype.getMsgText() != null && archetype.getMsgText().trim().length() > 0) { - // we must override archetype msg by an empty msg - gameObject.deleteMsgText(); - gameObject.addMsgText(""); - } else { - gameObject.deleteMsgText(); // all empty - } - - if (newAnim[0] != null) { - gameObject.setAnimName(newAnim[0]); - } - - // deal with syntax errors now - if (errors != null) { - if (typeStruct == archetypeTypeSet.getArchetypeType(0)) { - // for generic (misc) type, all errors are automatically kept. - // "misc" is no real type - it is more a default mask for unknown types - gameObject.addObjectText(errors.trim()); - } else { - // open a popup dialog and ask user to decide what to do with his errors - askConfirmErrors(errors); - } - } - - gameObject.updateEditType(mapManager.getCurrentMap().getActiveEditType()); - - return true; // apply succeeded - } - } // class GameObjectAttributesDialog Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-30 19:48:39 UTC (rev 4588) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-30 20:05:21 UTC (rev 4589) @@ -73,6 +73,7 @@ import javax.swing.text.StyleContext; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; import net.sf.gridarta.archtype.ArchetypeAttribute; import net.sf.gridarta.archtype.ArchetypeAttributeType; import net.sf.gridarta.archtype.ArchetypeAttributeTypeAnimName; @@ -110,7 +111,9 @@ import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.spells.GameObjectSpell; +import net.sf.gridarta.spells.NumberSpell; import net.sf.gridarta.spells.Spell; +import net.sf.gridarta.spells.Spells; import net.sf.gridarta.textedit.textarea.JEditTextArea; import net.sf.gridarta.textedit.textarea.SyntaxDocument; import net.sf.gridarta.textedit.textarea.tokenmarker.TokenMarkerFactory; @@ -142,7 +145,7 @@ private final AbstractGameObjectAttributesDialogFactory<G, A, R, ?> gameObjectAttributesDialogFactory; /** Reference to the {@link ArchetypeTypeSet}. */ - protected final ArchetypeTypeSet archetypeTypeSet; + private final ArchetypeTypeSet archetypeTypeSet; /** * The index used for "no" spell. @@ -155,14 +158,18 @@ private final boolean includeFaceText; /** Reference to MainControl. */ - protected final MainControl<G, A, R, ?> mainControl; + private final MainControl<G, A, R, ?> mainControl; /** * The archetype set to use. */ @NotNull - protected final ArchetypeSet<G, A, R> archetypeSet; + private final ArchetypeSet<G, A, R> archetypeSet; + /** The map manager. */ + @NotNull + private final MapManager<G, A, R, ?> mapManager; + /** The animation objects to use. */ @NotNull private final AnimationObjects<?> animationObjects; @@ -182,19 +189,19 @@ */ private int typeNoEventConnector; - protected final List<DialogAttrib<G, A, R, ?>> dialogAttribs = new ArrayList<DialogAttrib<G, A, R, ?>>(); + private final List<DialogAttrib<G, A, R, ?>> dialogAttribs = new ArrayList<DialogAttrib<G, A, R, ?>>(); private JComboBox typesel; // selection box for type - protected JLabel imagePanel; // panel for object's face (png) + private JLabel imagePanel; // panel for object's face (png) /** The game object being modified. */ @NotNull public final G gameObject; - protected final R archetype; + private final R archetype; - protected ArchetypeType type; // reference to the type data + private ArchetypeType type; // reference to the type data // this differs from the GameObject if the type is undefined private int listNr; // the position of this type in the type list @@ -235,6 +242,7 @@ * @param gameObject GameObject to show dialog for. * @param mainControl MainControl, for retrieving AnimationObjects etc. * @param archetypeSet the archetype set to use + * @param mapManager the map manager to use * @param animationObjects the animation objects instance to use * @param treasureListTree the treasure list tree * @param faceObjects the face objects instance to use @@ -244,7 +252,7 @@ * @param includeFaceText whether face names are included in the object * text */ - protected AbstractGameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<G, A, R, ?> gameObjectAttributesDialogFactory, final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, ?> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { + protected AbstractGameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<G, A, R, ?> gameObjectAttributesDialogFactory, final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, ?> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapManager<G, A, R, ?> mapManager, @NotNull final AnimationObjects<?> animationObjects, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.archetypeTypeSet = archetypeTypeSet; this.typeNoEventConnector = typeNoEventConnector; @@ -253,6 +261,7 @@ this.gameObject = gameObject.getHead(); this.mainControl = mainControl; this.archetypeSet = archetypeSet; + this.mapManager = mapManager; this.animationObjects = animationObjects; this.treasureListTree = treasureListTree; this.faceObjects = faceObjects; @@ -340,8 +349,36 @@ * @param attr spell attribute * @return the completed <code>JComboBox</code> */ - protected abstract JComboBox buildSpellBox(final ArchetypeAttribute attr); + private JComboBox buildSpellBox(final ArchetypeAttribute attr) { + // first parse the spell-number value from gameObject + int spnum = gameObject.getAttributeInt(attr.getNameOld()); // spell number + if (spnum < 0 || spnum >= mainControl.getNumberSpells().size()) { + spnum = undefinedSpellIndex; + } + + // do we have "none" spell? + final int selectedIndex; + if (spnum == undefinedSpellIndex && attr.getDataType() instanceof ArchetypeAttributeTypeZSpell) { + selectedIndex = 0; + } else { + // now look up the spell-number in the array of spells + selectedIndex = 1 + findSpellIndex(spnum); + } + + final Vector<String> content = new Vector<String>(); + content.add("<none>"); + for (final Spell spell : mainControl.getNumberSpells()) { + content.add(spell.getName()); + } + final JComboBox comboBox = new JComboBox(content); + comboBox.setSelectedIndex(selectedIndex); + comboBox.setMaximumRowCount(10); + comboBox.setKeySelectionManager(new StringKeyManager(comboBox)); + comboBox.setName(attr.getNameNew()); + return comboBox; + } + /** * Construct the Combo box of the available spells. * @param attr spell attribute @@ -769,8 +806,108 @@ * settings from the dialog get written into the GameObject. * @return true if the settings were applied, false if error occurred */ - protected abstract boolean applySettings2(); + private boolean applySettings2() { + final ArchetypeType typeStruct = archetypeTypeSet.getTypeOfArch(gameObject); // the type structure for this gameObject + final StringBuilder newArchText = new StringBuilder(); + final String[] newName = new String[1]; + final String[] newFace = new String[1]; + final String[] newMsg = new String[1]; + final String[] newAnim = new String[1]; + for (final DialogAttrib<G, A, R, ?> attr : dialogAttribs) { + final String text = attr.getText2(gameObject, archetype, newName, newFace, newMsg, newAnim, typeStruct, this); + if (text == null) { + return false; + } + if (text.length() > 0) { + newArchText.append(text).append("\n"); + } + } + + // Also write all the 'fixed' attributes into the archtext + for (int i = 0; type.getAttr().length > i; i++) { + // ### TODO: for changed types, copy fixed attributes over default arches ### + if (type.getAttr()[i].getDataType() instanceof ArchetypeAttributeTypeFixed) { + final String defaultValue = archetype.getAttributeString(type.getAttr()[i].getNameOld()); + if (defaultValue.length() == 0 || (gameObject.getArchTypNr() != archetype.getArchTypNr() && !defaultValue.equalsIgnoreCase(type.getAttr()[i].getNameNew()))) { + // usually, fixed attributes are only applied when *not* defined in the archetype. + // the reason behind this is: if the default gameObject violates our fixed attribute, + // we assume the default gameObject is "right" and we are "wrong". The typedefs aren't that trustworthy. + // BUT - if the gameObject has a changed type, the archetype has lost it's credibility. + // So, in this special case, the fixed attribute applies always. + newArchText.append(type.getAttr()[i].getNameOld()).append(" ").append(type.getAttr()[i].getNameNew()).append("\n"); + } + } + } + + /* we have excluded direction hard coded from the attribut panel + * because we have a better interface in the gameObject panel. + * But we need to add when needed the gameObject text - we do it here. + */ + if (gameObject.getDirection() != archetype.getDirection()) { + newArchText.append("direction ").append(gameObject.getDirection()).append("\n"); + } + // before we modify the archtext, we look for errors and save them. + // later the user must confirm whether to keep or dump those errors + final String errors = gameObject.getSyntaxErrors(typeStruct); + + // --- parsing succeeded, now we write it into the gameObject/map --- + gameObject.setObjectText(newArchText.toString()); + //gameObject.setArchTypNr(); + if (newName[0] != null) { + if (newName[0].length() == 0) { + gameObject.setObjName(null); + } else { + gameObject.setObjName(newName[0]); + } + } + + if (newFace[0] != null) { + gameObject.setRealFace(newFace[0]); + } + + // now lets assign the visible face - perhaps we have still a anim + gameObject.setObjectFace(); + imagePanel.setIcon(getFace(gameObject)); + + if (newMsg[0] != null) { + // set new msg text only when it is not equal to Archetype + if (!newMsg[0].trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { + gameObject.deleteMsgText(); + gameObject.addMsgText(newMsg[0]); + } else { + gameObject.deleteMsgText(); + } + } else + if (archetype.getMsgText() != null && archetype.getMsgText().trim().length() > 0) { + // we must override archetype msg by an empty msg + gameObject.deleteMsgText(); + gameObject.addMsgText(""); + } else { + gameObject.deleteMsgText(); // all empty + } + + if (newAnim[0] != null) { + gameObject.setAnimName(newAnim[0]); + } + + // deal with syntax errors now + if (errors != null) { + if (typeStruct == archetypeTypeSet.getArchetypeType(0)) { + // for generic (misc) type, all errors are automatically kept. + // "misc" is no real type - it is more a default mask for unknown types + gameObject.addObjectText(errors.trim()); + } else { + // open a popup dialog and ask user to decide what to do with his errors + askConfirmErrors(errors); + } + } + + gameObject.updateEditType(mapManager.getCurrentMap().getActiveEditType()); + + return true; // apply succeeded + } + /** * Open a popup dialog and ask the user to confirm (or modify) the * encountered syntax errors. If the user chooses to keep any errors, these @@ -831,6 +968,21 @@ frame.setVisible(true); } + /** + * Return the spell index for a spell number. + * @param number The spell number. + * @return The spell object. + */ + private int findSpellIndex(final int number) { + final Spells<NumberSpell> spells = mainControl.getNumberSpells(); + for (int i = 0; i < spells.size(); i++) { + if (spells.getSpell(i).getNumber() == number) { + return i; + } + } + return -1; + } + /** ItemListener for the type-selection box on the attribute-dialog. */ private final class TypesBoxAL implements ItemListener { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-30 20:13:28
|
Revision: 4590 http://gridarta.svn.sourceforge.net/gridarta/?rev=4590&view=rev Author: akirschbaum Date: 2008-07-30 20:13:25 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Remove empty class GameObjectAttributesDialog. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java Deleted: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 20:05:21 UTC (rev 4589) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 20:13:25 UTC (rev 4590) @@ -1,70 +0,0 @@ -/* - * 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.gameobjectattributesdialog; - -import cfeditor.gameobject.Archetype; -import cfeditor.gameobject.GameObject; -import cfeditor.gui.map.CMapViewBasic; -import cfeditor.map.MapArchObject; -import javax.swing.filechooser.FileFilter; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gameobject.ArchetypeSet; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; -import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; -import net.sf.gridarta.treasurelist.CFTreasureListTree; -import org.jetbrains.annotations.NotNull; - -/** - * GameObjectAttributesDialog poses the GUI for Crossfire object attributes. - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @fixme I suck - */ -public final class GameObjectAttributesDialog extends AbstractGameObjectAttributesDialog<GameObject, MapArchObject, Archetype> { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** - * Constructor, creates the GUI layout. - * @param gameObjectAttributesDialogFactory the associated factory - * @param archetypeTypeSet the list of CF type-data - * @param gameObject the GameObject to be displayed by this dialog - * @param mainControl main control - * @param archetypeSet the archetype set to use - * @param animationObjects the animation objects instance to use - * @param mapManager the map manager - * @param treasureListTree the treasure list tree - * @param faceObjects the FaceObjects instance to use - * @param mapFileFilter the Swing file filter to use - * @param typeNoEventConnector the object type for event objects - * @param undefinedSpellIndex the index used for "no" spell - * @param includeFaceText whether face names are included in the object - * text - */ - public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { - super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); - } - -} // class GameObjectAttributesDialog Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:05:21 UTC (rev 4589) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:13:25 UTC (rev 4590) @@ -30,6 +30,7 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; @@ -53,8 +54,8 @@ /** {@inheritDoc} */ @Override - protected GameObjectAttributesDialog newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { - return new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, Archetype.TYPE_EVENT_CONNECTOR, 0, false); + protected AbstractGameObjectAttributesDialog<GameObject, MapArchObject, Archetype> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { + return new AbstractGameObjectAttributesDialog<GameObject, MapArchObject, Archetype>(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, Archetype.TYPE_EVENT_CONNECTOR, 0, false); } } // class GameObjectAttributesDialogFactory Deleted: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 20:05:21 UTC (rev 4589) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 20:13:25 UTC (rev 4590) @@ -1,70 +0,0 @@ -/* - * 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 daieditor.gui.gameobjectattributesdialog; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import javax.swing.filechooser.FileFilter; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gameobject.ArchetypeSet; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; -import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; -import net.sf.gridarta.treasurelist.CFTreasureListTree; -import org.jetbrains.annotations.NotNull; - -/** - * GameObjectAttributesDialog poses the GUI for Daimonin object attributes. - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @fixme I suck - */ -public final class GameObjectAttributesDialog extends AbstractGameObjectAttributesDialog<GameObject, MapArchObject, Archetype> { - - /** Serial Version UID. */ - private static final long serialVersionUID = 1L; - - /** - * Constructor, creates the GUI layout. - * @param gameObjectAttributesDialogFactory the associated factory - * @param archetypeTypeSet the list of CF type-data - * @param gameObject the GameObject to be displayed by this dialog - * @param mainControl main control - * @param archetypeSet the archetype set to use - * @param animationObjects the animation objects instance to use - * @param mapManager the map manager - * @param treasureListTree the treasure list tree - * @param faceObjects the FaceObjects instance to use - * @param mapFileFilter the Swing file filter to use - * @param typeNoEventConnector the object type for event objects - * @param undefinedSpellIndex the index used for "no" spell - * @param includeFaceText whether face names are included in the object - * text - */ - public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { - super(gameObjectAttributesDialogFactory, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); - } - -} // class GameObjectAttributesDialog Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:05:21 UTC (rev 4589) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:13:25 UTC (rev 4590) @@ -30,6 +30,7 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; @@ -53,8 +54,8 @@ /** {@inheritDoc} */ @Override - protected GameObjectAttributesDialog newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { - return new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, 0, -1, true); + protected AbstractGameObjectAttributesDialog<GameObject, MapArchObject, Archetype> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { + return new AbstractGameObjectAttributesDialog<GameObject, MapArchObject, Archetype>(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, 0, -1, true); } } // class GameObjectAttributesDialogFactory Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-30 20:05:21 UTC (rev 4589) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-30 20:13:25 UTC (rev 4590) @@ -127,7 +127,7 @@ * Common base class for game object attributes dialogs. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public abstract class AbstractGameObjectAttributesDialog<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends JOptionPane { +public class AbstractGameObjectAttributesDialog<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends JOptionPane { /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(AbstractGameObjectAttributesDialog.class); @@ -252,7 +252,7 @@ * @param includeFaceText whether face names are included in the object * text */ - protected AbstractGameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<G, A, R, ?> gameObjectAttributesDialogFactory, final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, ?> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapManager<G, A, R, ?> mapManager, @NotNull final AnimationObjects<?> animationObjects, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { + public AbstractGameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<G, A, R, ?> gameObjectAttributesDialogFactory, final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, ?> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapManager<G, A, R, ?> mapManager, @NotNull final AnimationObjects<?> animationObjects, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.archetypeTypeSet = archetypeTypeSet; this.typeNoEventConnector = typeNoEventConnector; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-30 20:18:02
|
Revision: 4591 http://gridarta.svn.sourceforge.net/gridarta/?rev=4591&view=rev Author: akirschbaum Date: 2008-07-30 20:17:58 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Rename AbstractGameObjectAttributesDialog to GameObjectAttributesDialog since it is not abstract anymore. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/ViewTreasurelistAL.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:13:25 UTC (rev 4590) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:17:58 UTC (rev 4591) @@ -30,8 +30,8 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; +import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialog; import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; @@ -54,8 +54,8 @@ /** {@inheritDoc} */ @Override - protected AbstractGameObjectAttributesDialog<GameObject, MapArchObject, Archetype> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { - return new AbstractGameObjectAttributesDialog<GameObject, MapArchObject, Archetype>(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, Archetype.TYPE_EVENT_CONNECTOR, 0, false); + protected GameObjectAttributesDialog<GameObject, MapArchObject, Archetype> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { + return new GameObjectAttributesDialog<GameObject, MapArchObject, Archetype>(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, Archetype.TYPE_EVENT_CONNECTOR, 0, false); } } // class GameObjectAttributesDialogFactory Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:13:25 UTC (rev 4590) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:17:58 UTC (rev 4591) @@ -30,8 +30,8 @@ import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialog; import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; +import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialog; import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; @@ -54,8 +54,8 @@ /** {@inheritDoc} */ @Override - protected AbstractGameObjectAttributesDialog<GameObject, MapArchObject, Archetype> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { - return new AbstractGameObjectAttributesDialog<GameObject, MapArchObject, Archetype>(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, 0, -1, true); + protected GameObjectAttributesDialog<GameObject, MapArchObject, Archetype> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { + return new GameObjectAttributesDialog<GameObject, MapArchObject, Archetype>(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, 0, -1, true); } } // class GameObjectAttributesDialogFactory Deleted: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-30 20:13:25 UTC (rev 4590) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialog.java 2008-07-30 20:17:58 UTC (rev 4591) @@ -1,1614 +0,0 @@ -/* - * 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 net.sf.gridarta.gui.gameobjectattributesdialog; - -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.GridLayout; -import java.awt.Insets; -import java.awt.event.FocusListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.io.File; -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Vector; -import javax.swing.Action; -import javax.swing.BorderFactory; -import javax.swing.Box; -import javax.swing.BoxLayout; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JDialog; -import javax.swing.JFormattedTextField; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JSplitPane; -import javax.swing.JTabbedPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.JTextPane; -import javax.swing.JViewport; -import javax.swing.ScrollPaneConstants; -import javax.swing.SwingConstants; -import javax.swing.WindowConstants; -import javax.swing.filechooser.FileFilter; -import javax.swing.text.BadLocationException; -import javax.swing.text.DefaultFormatterFactory; -import javax.swing.text.Document; -import javax.swing.text.JTextComponent; -import javax.swing.text.NumberFormatter; -import javax.swing.text.Style; -import javax.swing.text.StyleConstants; -import javax.swing.text.StyleContext; -import net.sf.gridarta.CommonConstants; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.archtype.ArchetypeAttribute; -import net.sf.gridarta.archtype.ArchetypeAttributeType; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeAnimName; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeBitmask; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeBool; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeBoolSpec; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeDoubleList; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeFaceName; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeFixed; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeFloat; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeInt; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeInvSpell; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeInvSpellOptional; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeList; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeLong; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeMapPath; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeScriptFile; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeSpell; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeString; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeText; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeTreasure; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeVisitor; -import net.sf.gridarta.archtype.ArchetypeAttributeTypeZSpell; -import net.sf.gridarta.archtype.ArchetypeType; -import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.archtype.CAttribBitmask; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.ArchetypeSet; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gui.map.TilePanel; -import net.sf.gridarta.help.Help; -import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.spells.GameObjectSpell; -import net.sf.gridarta.spells.NumberSpell; -import net.sf.gridarta.spells.Spell; -import net.sf.gridarta.spells.Spells; -import net.sf.gridarta.textedit.textarea.JEditTextArea; -import net.sf.gridarta.textedit.textarea.SyntaxDocument; -import net.sf.gridarta.textedit.textarea.tokenmarker.TokenMarkerFactory; -import net.sf.gridarta.treasurelist.CFTreasureListTree; -import net.sf.japi.swing.ActionFactory; -import org.apache.log4j.Logger; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Common base class for game object attributes dialogs. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class AbstractGameObjectAttributesDialog<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends JOptionPane { - - /** The Logger for printing log messages. */ - private static final Logger log = Logger.getLogger(AbstractGameObjectAttributesDialog.class); - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - - /** The width (columns) for input fields like textfields or JChooseBoxes. */ - public static final int TEXTFIELD_COLUMNS = 18; - - /** - * The associated factory. - */ - @NotNull - private final AbstractGameObjectAttributesDialogFactory<G, A, R, ?> gameObjectAttributesDialogFactory; - - /** Reference to the {@link ArchetypeTypeSet}. */ - private final ArchetypeTypeSet archetypeTypeSet; - - /** - * The index used for "no" spell. - */ - private final int undefinedSpellIndex; - - /** - * Whether face names are included in the object text. - */ - private final boolean includeFaceText; - - /** Reference to MainControl. */ - private final MainControl<G, A, R, ?> mainControl; - - /** - * The archetype set to use. - */ - @NotNull - private final ArchetypeSet<G, A, R> archetypeSet; - - /** The map manager. */ - @NotNull - private final MapManager<G, A, R, ?> mapManager; - - /** The animation objects to use. */ - @NotNull - private final AnimationObjects<?> animationObjects; - - @NotNull - private final CFTreasureListTree<G, A, R> treasureListTree; - - /** The FaceObjects instance to use. */ - @NotNull - private final FaceObjects faceObjects; - - /** Swing FileFilter for map files. */ - private final FileFilter mapFileFilter; - - /** - * The object type for event objects. - */ - private int typeNoEventConnector; - - private final List<DialogAttrib<G, A, R, ?>> dialogAttribs = new ArrayList<DialogAttrib<G, A, R, ?>>(); - - private JComboBox typesel; // selection box for type - - private JLabel imagePanel; // panel for object's face (png) - - /** The game object being modified. */ - @NotNull - public final G gameObject; - - private final R archetype; - - private ArchetypeType type; // reference to the type data - - // this differs from the GameObject if the type is undefined - private int listNr; // the position of this type in the type list - - /** The CardLayout for toggling between edit and summary. */ - private final CardLayout cardLayout = new CardLayout(); - - /** The Action for switching to the summary. */ - private final Action summaryAction = ACTION_FACTORY.createAction(false, "attribSummary", this); - - /** The Action for switching to the edit. */ - private final Action editAction = ACTION_FACTORY.createAction(false, "attribEdit", this); - - /** The Button for toggling the summary. */ - private JButton summaryEditButton; - - /** The Button for cancel. */ - private JButton cancelButton; - - /** The Button for ok. */ - public JButton okButton; - - /** Central tabbed pane (the place where all the attribute tabs are). */ - private JTabbedPane tabbedPane; - - /** Central pane, this is the parent component of above tabbed pane. */ - private final JPanel centerPane; - - /** Text pane where the summary is displayed. */ - private final JTextPane summaryTP; - - private final FocusListener focusListener = new ScrollToVisibleFocusListener(); - - /** - * Create an AbstractGameObjectAttributesDialog. - * @param gameObjectAttributesDialogFactory the associated factory - * @param archetypeTypeSet Reference to the list of archetype types. - * @param gameObject GameObject to show dialog for. - * @param mainControl MainControl, for retrieving AnimationObjects etc. - * @param archetypeSet the archetype set to use - * @param mapManager the map manager to use - * @param animationObjects the animation objects instance to use - * @param treasureListTree the treasure list tree - * @param faceObjects the face objects instance to use - * @param mapFileFilter the Swing FileFilter for map files - * @param typeNoEventConnector the object type for event objects - * @param undefinedSpellIndex the index used for "no" spell - * @param includeFaceText whether face names are included in the object - * text - */ - public AbstractGameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<G, A, R, ?> gameObjectAttributesDialogFactory, final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, ?> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapManager<G, A, R, ?> mapManager, @NotNull final AnimationObjects<?> animationObjects, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { - this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; - this.archetypeTypeSet = archetypeTypeSet; - this.typeNoEventConnector = typeNoEventConnector; - this.undefinedSpellIndex = undefinedSpellIndex; - this.includeFaceText = includeFaceText; - this.gameObject = gameObject.getHead(); - this.mainControl = mainControl; - this.archetypeSet = archetypeSet; - this.mapManager = mapManager; - this.animationObjects = animationObjects; - this.treasureListTree = treasureListTree; - this.faceObjects = faceObjects; - this.mapFileFilter = mapFileFilter; - this.typeNoEventConnector = typeNoEventConnector; - archetype = this.gameObject.getArchetype(); - - type = archetypeTypeSet.getArchetypeType(gameObject); - listNr = archetypeTypeSet.getArchetypeTypeIndex(type); - - // first split top-left and -right - final JComponent leftPane = buildHeader(); - final JScrollPane rightPane = buildInv(); - - //Create a split pane with the two scroll panes in it. - final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPane, rightPane); - - // Now split horizontally - //JScrollPane centerPane = buildAttr(); - centerPane = new JPanel(cardLayout); - centerPane.add("edit", buildAttr()); - summaryTP = new JTextPane(); - summaryTP.setEditable(false); - summaryTP.setBorder(BorderFactory.createEmptyBorder(3, 15, 0, 0)); - centerPane.add("summary", new JScrollPane(summaryTP)); - final Dimension size = centerPane.getPreferredSize(); - size.height = 256; - centerPane.setMinimumSize(size); - centerPane.setPreferredSize(size); - - final JPanel contentPanel = new JPanel(new GridBagLayout()); - final GridBagConstraints gbc = new GridBagConstraints(); - gbc.weightx = 1.0; - gbc.fill = GridBagConstraints.BOTH; - gbc.gridwidth = GridBagConstraints.REMAINDER; - gbc.weighty = 0.0; - contentPanel.add(splitPane, gbc); - gbc.weighty = 1.0; - contentPanel.add(centerPane, gbc); - - setOptions(buildOptions()); - - setMessage(contentPanel); - } - - /** {@inheritDoc} */ - @Override - public void setValue(final Object newValue) { - super.setValue(newValue); - if (newValue != UNINITIALIZED_VALUE) { - gameObjectAttributesDialogFactory.hideAttribDialog(gameObject); - } - } - - /** - * Construct the Combo box of the available archetypes. - * @return a <code>JComponent</code> with the combo box in it - */ - private JComponent buildTypesBox() { - final String[] namelist = new String[archetypeTypeSet.getLength()]; // list of typenames - - // read all type names - int i = 0; - for (final ArchetypeType tmp : archetypeTypeSet) { - namelist[i++] = " " + tmp.getTypeName(); - } - - // the active type appears selected in the box - final int selection = listNr; // position of selected type in the list - - typesel = new JComboBox(namelist); // set "content" - typesel.setSelectedIndex(selection); // set active selection - - //typesel.setKeySelectionManager(new StringKeyManager(typesel)); - - typesel.setName("Types"); - - // the listener: - typesel.addItemListener(new TypesBoxAL(this, gameObject)); - return typesel; - } - - /** - * Construct the Combo box of the available spells. - * @param attr spell attribute - * @return the completed <code>JComboBox</code> - */ - private JComboBox buildSpellBox(final ArchetypeAttribute attr) { - // first parse the spell-number value from gameObject - int spnum = gameObject.getAttributeInt(attr.getNameOld()); // spell number - - if (spnum < 0 || spnum >= mainControl.getNumberSpells().size()) { - spnum = undefinedSpellIndex; - } - - // do we have "none" spell? - final int selectedIndex; - if (spnum == undefinedSpellIndex && attr.getDataType() instanceof ArchetypeAttributeTypeZSpell) { - selectedIndex = 0; - } else { - // now look up the spell-number in the array of spells - selectedIndex = 1 + findSpellIndex(spnum); - } - - final Vector<String> content = new Vector<String>(); - content.add("<none>"); - for (final Spell spell : mainControl.getNumberSpells()) { - content.add(spell.getName()); - } - final JComboBox comboBox = new JComboBox(content); - comboBox.setSelectedIndex(selectedIndex); - comboBox.setMaximumRowCount(10); - comboBox.setKeySelectionManager(new StringKeyManager(comboBox)); - comboBox.setName(attr.getNameNew()); - return comboBox; - } - - /** - * Construct the Combo box of the available spells. - * @param attr spell attribute - * @return the completed <code>JComboBox</code> - */ - private JComboBox buildInvSpellBox(final ArchetypeAttribute attr) { - final boolean isOptionalSpell = attr.getDataType() instanceof ArchetypeAttributeTypeInvSpellOptional; - final Vector<String> content = new Vector<String>(); - final int selectedIndex; - @Nullable final String title; - switch (gameObject.countInvObjects()) { - case 0: - selectedIndex = mainControl.getGameObjectSpells().size(); - title = isOptionalSpell ? null : "<none>"; - break; - - default: - selectedIndex = mainControl.getGameObjectSpells().size() + (isOptionalSpell ? 1 : 0); - title = "<multiple>"; - break; - - case 1: - final G invObject = gameObject.iterator().next(); - final String invObjectArchetypeName = invObject.getArchetype().getArchetypeName(); - int index = 0; - @Nullable String tmpTitle = "<customized spell>"; - for (final GameObjectSpell<G, A, R> spellObject : mainControl.getGameObjectSpells()) { - if (invObjectArchetypeName.equals(spellObject.getArchetypeName())) { - if (invObject.isDefaultGameObject()) { - tmpTitle = null; - } else { - tmpTitle = spellObject.getName() + " <customized>"; - } - break; - } - index++; - } - if (tmpTitle != null) { - selectedIndex = mainControl.getGameObjectSpells().size() + (isOptionalSpell ? 1 : 0); - } else { - selectedIndex = index; - } - title = tmpTitle; - break; - } - - for (final Spell spell : mainControl.getGameObjectSpells()) { - content.add(spell.getName()); - } - if (isOptionalSpell) { - content.add("<none>"); - } - if (title != null) { - content.add(title); - } - - final JComboBox comboBox = new JComboBox(content); - comboBox.setSelectedIndex(selectedIndex); - comboBox.setMaximumRowCount(10); - comboBox.setKeySelectionManager(new StringKeyManager(comboBox)); - comboBox.setName(attr.getNameNew()); - return comboBox; - } - - /** - * Construct the Combo box for arrays of "list data" (this is used for - * ArchAttribType.LIST). - * @param attr list attribute - * @param listData List with list items and corresponding values, that means - * the types are altering: String,Integer - * @return the completed <code>JComboBox</code> - */ - private JComboBox buildArrayBox(final ArchetypeAttribute attr, final List<?> listData) { - // build the array of list-items - final String[] array = new String[(int) (listData.size() / 2.0)]; - boolean hasSelection = false; - int active = gameObject.getAttributeInt(attr.getNameOld()); - for (int i = 0; i < array.length; i++) { - array[i] = (String) listData.get(i * 2 + 1); // put string to array - if (!hasSelection && (Integer) listData.get(i * 2) == active) { - hasSelection = true; // the selection is valid - active = i; // set selection to this index in the array - } - } - // if there is no valid pre-selection, show first element of list - if (!hasSelection) { - active = 0; - } - final JComboBox arraysel = new JComboBox(array); // set "content" - arraysel.setSelectedIndex(active); // set active selection - arraysel.setMaximumRowCount(10); - arraysel.setKeySelectionManager(new StringKeyManager(arraysel)); - arraysel.setName(attr.getNameNew()); - return arraysel; - } - - /** - * Returns the face for a GameObject. - * @param gameObject GameObject to return face for. - * @return Face for the supplied GameObject. - */ - protected ImageIcon getFace(@NotNull final G gameObject) { - return archetypeSet.getFace(gameObject); - } - - /** - * Construct the upper left part of the attribute dialog, containing name, - * type, archetype name and face. - * @return a <code>JScrollPane</code> with the upper left part of the dialog - * window - */ - private JComponent buildHeader() { - final JPanel header = new JPanel(new GridBagLayout()); // the final thing, in a panel - final GridBagConstraints gbc = new GridBagConstraints(); - gbc.fill = GridBagConstraints.BOTH; - gbc.insets = new Insets(2, 2, 2, 2); - gbc.gridx = 1; - gbc.gridy = 1; - gbc.weightx = 0.0; - gbc.weighty = 3.0; - gbc.gridheight = 3; - imagePanel = new JLabel(getFace(gameObject)); - imagePanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10)); - header.add(imagePanel, gbc); - gbc.gridheight = 1; - gbc.weighty = 1.0; - gbc.fill = GridBagConstraints.HORIZONTAL; - - gbc.weightx = 0.0; - gbc.gridx = 2; - gbc.gridy = 1; - header.add(new JLabel("Name: ", SwingConstants.TRAILING), gbc); // create label - gbc.gridy++; - header.add(new JLabel("Type: ", SwingConstants.TRAILING), gbc); - gbc.gridy++; - header.add(new JLabel("Archetype: ", SwingConstants.TRAILING), gbc); // create label - - gbc.gridx = 3; - gbc.gridy = 1; - gbc.weightx = 1.0; - final JTextField nameTF; - final String objName = gameObject.getObjName(); - if (objName != null && objName.length() > 0) { - nameTF = new JTextField(objName, 16); - } else { - final String archObjName = archetype.getObjName(); - if (archObjName != null && archObjName.length() > 0) { - nameTF = new JTextField(archObjName, 16); - } else { - nameTF = new JTextField(archetype.getArchetypeName(), 16); - } - } - nameTF.setEditable(false); - header.add(nameTF, gbc); - gbc.gridy++; - header.add(buildTypesBox(), gbc); // build type-selection box - gbc.gridy++; - final JTextField archetypeTF = new JTextField(archetype.getArchetypeName(), 16); - archetypeTF.setEditable(false); - header.add(archetypeTF, gbc); - - return header; - } - - /** - * Construct the upper right part of the attribute dialog, containing the - * object's inventory. - * @return a <code>JScrollPane</code> with the upper right part of the - * dialog window - */ - private static JScrollPane buildInv() { - final JPanel inv = new JPanel(); // the final thing, in a panel - inv.add(new JLabel("Inventory:")); // create label - - final JScrollPane scrollPane = new JScrollPane(inv); - scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); - scrollPane.setSize(80, 70); - - return scrollPane; - } - - /** - * Construct the central part of the attribute dialog, containing the - * object's gameObject attributes. - * @return When this method is called the first time: a - * <code>JScrollPane</code> with the central part of the dialog - * window. All further calls rebuild the existing tabbedpane and - * return null. - */ - @Nullable - JComponent buildAttr() { - boolean initialCall = false; - - if (tabbedPane == null) { - tabbedPane = new JTabbedPane(); - initialCall = true; - } - - for (int i = 0; i < type.getSectionNum(); i++) { - final Component panel1 = makeAttribPanel(i); - if (panel1 != null) { - tabbedPane.addTab(getSectionName(i), null, panel1); - } - } - - // set selected tab - tabbedPane.setSelectedIndex(0); - - if (initialCall) { - return tabbedPane; - } else { - return null; - } - } - - /** - * This method creates an attribute panel for one section of attributes. If - * the section is empty, null is returned. - * @param secId the identifier of the section - * @return a <code>Component</code> containing the attribute panel - * (currently always a JScrollPane) - */ - @Nullable - private Component makeAttribPanel(final int secId) { - int number = 0; // number of attributes in this section - boolean hasBitmask = false; // true if this section contains a bitmask attribute - - // first we check how many attribs this section has - for (int i = 0; type.getAttr().length > i; i++) { - if (type.getAttr()[i].getSecId() == secId) { - // count number of attributes - if (!(type.getAttr()[i].getDataType() instanceof ArchetypeAttributeTypeFixed)) { - number++; - } - // check for bitmask attributes - if (!hasBitmask && type.getAttr()[i].getDataType() instanceof ArchetypeAttributeTypeBitmask) { - hasBitmask = true; - } - } - } - if (number == 0) { - return null; - } - - // All attribute-"lines" go into this panel: - final JPanel panel = new JPanel(new GridBagLayout()); - final Insets gbcInsets = new Insets(2, 2, 2, 2); - - final GridBagConstraints gbc = new GridBagConstraints(); - gbc.insets = gbcInsets; - final Object helpGbc = gbc.clone(); - gbc.fill = GridBagConstraints.HORIZONTAL; - final Object labelGbc = gbc.clone(); - gbc.weightx = 1.0; - gbc.gridwidth = GridBagConstraints.REMAINDER; - final Object compGbc = gbc.clone(); - gbc.anchor = GridBagConstraints.WEST; - final Object rowGbc = gbc.clone(); - gbc.fill = GridBagConstraints.BOTH; - gbc.weighty = 1.0; - final Object glueGbc = gbc.clone(); - final MakeAttribPanelVisitor makeAttribPanelVisitor = new MakeAttribPanelVisitor(typeNoEventConnector); - - final ArchetypeAttribute[] attribs = type.getAttr(); - // now add the entrys, line by line - for (int i = 0; attribs.length > i; i++) { - final ArchetypeAttribute attrib = attribs[i]; - final ArchetypeAttributeType dType = attrib.getDataType(); // data type of the attribute - if (attrib.getSecId() == secId && !(dType instanceof ArchetypeAttributeTypeFixed)) { - final String nameOld = attrib.getNameOld(); - final JButton helpButton = new JButton("?"); - helpButton.setMargin(new Insets(0, 5, 0, 5)); - panel.add(helpButton, helpGbc); - helpButton.addFocusListener(focusListener); - - makeAttribPanelVisitor.process(nameOld, attrib, dType); - - assert makeAttribPanelVisitor.newAttr != null; - dialogAttribs.add(makeAttribPanelVisitor.newAttr); - helpButton.addActionListener(new HelpActionListener(makeAttribPanelVisitor.newAttr.ref, this)); - if (makeAttribPanelVisitor.cLabel != null) { - panel.add(makeAttribPanelVisitor.cLabel, labelGbc); - makeAttribPanelVisitor.cLabel.addFocusListener(focusListener); - } - if (makeAttribPanelVisitor.cComp != null) { - panel.add(makeAttribPanelVisitor.cComp, compGbc); - makeAttribPanelVisitor.cComp.addFocusListener(focusListener); - } - if (makeAttribPanelVisitor.cRow != null) { - panel.add(makeAttribPanelVisitor.cRow, rowGbc); - makeAttribPanelVisitor.cRow.addFocusListener(focusListener); - } - if (makeAttribPanelVisitor.cGlue != null) { - panel.add(makeAttribPanelVisitor.cGlue, glueGbc); - makeAttribPanelVisitor.cGlue.addFocusListener(focusListener); - } - } - } - - if (!makeAttribPanelVisitor.isText) { - // if the component does not already have glue, put glue inside to align its contents to the top. - panel.add(Box.createGlue(), glueGbc); - } - final JScrollPane panelReturn = new JScrollPane(panel); - panelReturn.getVerticalScrollBar().setUnitIncrement(8); - return panelReturn; - } - - /** - * Looks up the section name from the ID. - * @param secId ID of the section - * @return name of that section - */ - private String getSectionName(final int secId) { - for (int i = 0; type.getAttr().length > i; i++) { - if (type.getAttr()[i].getSecId() == secId) { - // we've got the string, now capitalize the first letter - String s = type.getAttr()[i].getSecName(); - if (s.length() > 1) { - s = s.substring(0, 1).toUpperCase() + s.substring(1); - } - return s; - } - } - - return "???"; - } - - /** - * Construct the dialog options: help, default, okay, apply, cancel. - * @return Object[] with dialog options - */ - private Object[] buildOptions() { - return new Object[] { - new JButton(ACTION_FACTORY.createAction(false, "attribHelp", this)), - summaryEditButton = new JButton(summaryAction), - Box.createHorizontalStrut(32), - okButton = new JButton(ACTION_FACTORY.createAction(false, "attribOk", this)), - new JButton(ACTION_FACTORY.createAction(false, "attribApply", this)), - cancelButton = new JButton(ACTION_FACTORY.createAction(false, "attribCancel", this)), - }; - } - - /** Action method for help. */ - public void attribHelp() { - new Help(/* XXX */ mainControl.getMainView(), type.createHtmlDocu()).setVisible(true); - } - - /** Action method for ok. */ - public void attribOk() { - if (applySettings()) { - setValue(okButton); - } - } - - /** Action method for apply. */ - public void attribApply() { - applySettings(); - } - - /** Action method for cancel. */ - public void attribCancel() { - setValue(cancelButton); - } - - /** - * Action method for summary. Switches the cardlayout to the summary list of - * all nonzero attributes. - */ - public void attribSummary() { - // interface is displayed, switch to summary - final Document doc = summaryTP.getDocument(); - - try { - // clear document - if (doc.getLength() > 0) { - doc.remove(0, doc.getLength()); - } - - final AttribSummaryVisitor attribSummaryVisitor = new AttribSummaryVisitor(doc); - - // now loop through all attributes and write out nonzero ones - for (final DialogAttrib<?, ?, ?, ?> attr : dialogAttribs) { - attribSummaryVisitor.process(attr); - } - } catch (final BadLocationException e) { - log.error("toggleSummary: Bad Location in Document!", e); - } - - summaryTP.setCaretPosition(0); // this prevents the document from scrolling down - summaryEditButton.setAction(editAction); - cardLayout.show(centerPane, "summary"); - } - - /** - * Turns the summary off. Switches to the input-interface for all attributes - * and the summary list of all nonzero attributes. - */ - public void attribEdit() { - summaryEditButton.setAction(summaryAction); - cardLayout.show(centerPane, "edit"); - } - - /** - * 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 applySettings() { - final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); - assert mapSquare != null; - final MapModel<G, A, R> mapModel = mapSquare.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 ArchetypeType typeStruct = archetypeTypeSet.getTypeOfArch(gameObject); // the type structure for this gameObject - - final StringBuilder newArchText = new StringBuilder(); - final String[] newName = new String[1]; - final String[] newFace = new String[1]; - final String[] newMsg = new String[1]; - final String[] newAnim = new String[1]; - for (final DialogAttrib<G, A, R, ?> attr : dialogAttribs) { - final String text = attr.getText2(gameObject, archetype, newName, newFace, newMsg, newAnim, typeStruct, this); - if (text == null) { - return false; - } - if (text.length() > 0) { - newArchText.append(text).append("\n"); - } - } - - // Also write all the 'fixed' attributes into the archtext - for (int i = 0; type.getAttr().length > i; i++) { - // ### TODO: for changed types, copy fixed attributes over default arches ### - if (type.getAttr()[i].getDataType() instanceof ArchetypeAttributeTypeFixed) { - final String defaultValue = archetype.getAttributeString(type.getAttr()[i].getNameOld()); - if (defaultValue.length() == 0 || (gameObject.getArchTypNr() != archetype.getArchTypNr() && !defaultValue.equalsIgnoreCase(type.getAttr()[i].getNameNew()))) { - // usually, fixed attributes are only applied when *not* defined in the archetype. - // the reason behind this is: if the default gameObject violates our fixed attribute, - // we assume the default gameObject is "right" and we are "wrong". The typedefs aren't that trustworthy. - // BUT - if the gameObject has a changed type, the archetype has lost it's credibility. - // So, in this special case, the fixed attribute applies always. - newArchText.append(type.getAttr()[i].getNameOld()).append(" ").append(type.getAttr()[i].getNameNew()).append("\n"); - } - } - } - - /* we have excluded direction hard coded from the attribut panel - * because we have a better interface in the gameObject panel. - * But we need to add when needed the gameObject text - we do it here. - */ - if (gameObject.getDirection() != archetype.getDirection()) { - newArchText.append("direction ").append(gameObject.getDirection()).append("\n"); - } - // before we modify the archtext, we look for errors and save them. - // later the user must confirm whether to keep or dump those errors - final String errors = gameObject.getSyntaxErrors(typeStruct); - - // --- parsing succeeded, now we write it into the gameObject/map --- - gameObject.setObjectText(newArchText.toString()); - //gameObject.setArchTypNr(); - if (newName[0] != null) { - if (newName[0].length() == 0) { - gameObject.setObjName(null); - } else { - gameObject.setObjName(newName[0]); - } - } - - if (newFace[0] != null) { - gameObject.setRealFace(newFace[0]); - } - - // now lets assign the visible face - perhaps we have still a anim - gameObject.setObjectFace(); - imagePanel.setIcon(getFace(gameObject)); - - if (newMsg[0] != null) { - // set new msg text only when it is not equal to Archetype - if (!newMsg[0].trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { - gameObject.deleteMsgText(); - gameObject.addMsgText(newMsg[0]); - } else { - gameObject.deleteMsgText(); - } - } else - if (archetype.getMsgText() != null && archetype.getMsgText().trim().length() > 0) { - // we must override archetype msg by an empty msg - gameObject.deleteMsgText(); - gameObject.addMsgText(""); - } else { - gameObject.deleteMsgText(); // all empty - } - - if (newAnim[0] != null) { - gameObject.setAnimName(newAnim[0]); - } - - // deal with syntax errors now - if (errors != null) { - if (typeStruct == archetypeTypeSet.getArchetypeType(0)) { - // for generic (misc) type, all errors are automatically kept. - // "misc" is no real type - it is more a default mask for unknown types - gameObject.addObjectText(errors.trim()); - } else { - // open a popup dialog and ask user to decide what to do with his errors - askConfirmErrors(errors); - } - } - - gameObject.updateEditType(mapManager.getCurrentMap().getActiveEditType()); - - return true; // apply succeeded - } - - /** - * Open a popup dialog and ask the user to confirm (or modify) the - * encountered syntax errors. If the user chooses to keep any errors, these - * get attached to the archtext by the actionlistener - * (<code>ConfirmErrorsAL</code>). - * <p/> - * Note that this method does not fork off with a new thread. It freezes the - * parent frames (and threads) until the popup window is closed, which - * mimics non-event-driven behaviour. - * @param errors a textual list of the encountered errors - */ - protected void askConfirmErrors(final String errors) { - final JDialog frame = new JDialog((JFrame) null, "Syntax Errors", true); // dialog freezes parents - frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); // closing is handled by listener - - final JPanel mainPanel = new JPanel(); - mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); - final JPanel headerPanel = new JPanel(new GridLayout(2, 1)); - final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); - - // create header labels - final JLabel header1 = new JLabel("The following lines from the archtext appear to be wrong."); - final JLabel header2 = new JLabel("They do not match the type definitions:"); - headerPanel.add(header1); - headerPanel.add(header2); - - // create textarea for showing errors - final JTextArea textarea = new JTextArea(errors, 7, 25); - textarea.setBorder(BorderFactory.createEmptyBorder(1, 4, 0, 0)); - final JScrollPane scrollPane = new JScrollPane(textarea); - scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - - // create buttons - final JButton dumpButton = new JButton("Dump All Errors"); - final JButton keepButton = new JButton("Keep Above Text"); - buttonPanel.add(dumpButton); - buttonPanel.add(keepButton); - - // attach actionlistener to the buttons (and the frame) - final ConfirmErrorsAL listener = new ConfirmErrorsAL(frame, gameObject, errors, keepButton, textarea); - keepButton.addActionListener(listener); - dumpButton.addActionListener(listener); - frame.addWindowListener(listener); - - // stick panels together - mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - mainPanel.add(headerPanel); - mainPanel.add(Box.createVerticalStrut(10)); - mainPanel.add(scrollPane); - mainPanel.add(Box.createVerticalStrut(10)); - mainPanel.add(buttonPanel); - - frame.getContentPane().add(mainPanel); - - // pack, position and show the popup - frame.pack(); - frame.setLocationRelativeTo(this); - frame.setVisible(true); - } - - /** - * Return the spell index for a spell number. - * @param number The spell number. - * @return The spell object. - */ - private int findSpellIndex(final int number) { - final Spells<NumberSpell> spells = mainControl.getNumberSpells(); - for (int i = 0; i < spells.size(); i++) { - if (spells.getSpell(i).getNumber() == number) { - return i; - } - } - return -1; - } - - /** ItemListener for the type-selection box on the attribute-dialog. */ - private final class TypesBoxAL implements ItemListener { - - private final AbstractGameObjectAttributesDialog<G, A, R> frame; // the entire frame - - private final G gameObject; // the according gameObject - - private String deselected; // the latest deselected item - - private boolean ignoreEvent; // while true, this listener ignores all events - - /** - * Constructor. - * @param frameNew the attribute-dialog mainframe - * @param gameObject the gameObject which has the error to be added - */ - private TypesBoxAL(final AbstractGameObjectAttributesDialog<G, A, R> frameNew, final G gameObject) { - frame = frameNew; - this.gameObject = gameObject; - ignoreEvent = false; - } - - /** {@inheritDoc} */ - public void itemStateChanged(final ItemEvent e) { - if (ignoreEvent) { - return; - } - - if (e.getStateChange() == ItemEvent.DESELECTED) { - // remember the deselected type - deselected = ((String) e.getItem()).trim(); - } else - if (e.getStateChange() == ItemEvent.SELECTED && !e.getItem().equals(deselected)) { - // new type was selected - // first, get new type structure - final ArchetypeType newType = archetypeTypeSet.getTypeByName((String) e.getItem()); - - frame.typesel.hidePopup(); - frame.update(frame.getGraphics()); - - if (deselected == null) { - deselected = frame.type.getTypeName(); - } - if (showConfirmDialog(frame, "Do you really want to change the type of this\nobject from \"" + deselected + "\" to \"" + newType.getTypeName() + "\"?", "Confirm", YES_NO_OPTION, INFORMATION_MESSAGE) == YES_OPTION) { - // change is confirmed, now get it on... - frame.type = newType; // set new type structure - - // change the gameObject to be of the new type: - gameObject.setArchTypNr(newType.getTypeNo()); - dialogAttribs.clear(); - - listNr = frame.typesel.getSelectedIndex(); - - // rebuild the dialog frame to show the new tabs - frame.tabbedPane.removeAll(); - frame.buildAttr(); - frame.tabbedPane.validate(); - frame.update(frame.getGraphics()); - - // recalculate the editType value - gameObject.updateEditType(mainControl.getMapManager().getCurrentMap().getActiveEditType()); - } else { - // change not wanted -> reset the choosebox - ignoreEvent = true; // ignore events thrown by the forced reset - frame.typesel.setSelectedIndex(listNr); - ignoreEvent = false; - } - } - } - - } // class TypesBoxAL - - private class MakeAttribPanelVisitor implements ArchetypeAttributeTypeVisitor { - - private boolean isText = false; - - // now create the attribute-GUI-instance - private DialogAttrib<G, A, R, ?> newAttr; - - private JComponent cLabel = null; - - private JComponent cComp = null; - - private JComponent cRow = null; - - private JComponent cGlue = null; - - private String nameOld; - - private ArchetypeAttribute attrib2; - - private final int typeNoEventConnector; - - public MakeAttribPanelVisitor(final int typeNoEventConnector) { - this.typeNoEventConnector = typeNoEventConnector; - } - - public void process(@NotNull final String nameOld, @NotNull final ArchetypeAttribute attrib2, @NotNull final ArchetypeAttributeType dType) { - this.nameOld = nameOld; - this.attrib2 = attrib2; - dType.accept(this); - } - - /** {@inheritDoc} */ - public void visit(final ArchetypeAttributeTypeAnimName attrib) { - final String dtxt; - if (nameOld.equalsIgnoreCase("name")) { - if (typeNoEventConnector != 0 && type.getTypeNo() == typeNoEventConnector) { - dtxt = gameObject.getObjName(); - } else - if (gameObject.getObjName() != null && gameObject.getObjName().length() > 0) { - dtxt = gameObject.getObjName(); - } else - if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { - dtxt = archetype.getObjName(); - } else { - dtxt = archetype.getArchetypeName(); - } - } else if (nameOld.equalsIgnoreCase("face")) { - dtxt = gameObject.getEffectiveFaceName(); - } else { - dtxt = gameObject.getAttributeString(nameOld); - } - final JTextField input = new JTextField(dtxt, TEXTFIELD_COLUMNS); - cLabel = new JButton(new TreeChooseAction(attrib2.getNameNew() + ": ", input, animationObjects)); - cComp = input; - newAttr = new DialogAttribAnimName<G, A, R>(attrib2, input, typeNoEventConnector, includeFaceText); - } - - /** {@inheritDoc} */ - public void visit(final ArchetypeAttributeTypeBitmask attrib) { - final JTextArea input = new JTextArea(); - final DialogAttribBitmask<G, A, R> tmpAttr = new DialogAttribBitmask<G, A, R>(attrib2, input); - if (attrib2.getMisc() != null && archetypeTypeSet.getBitmaskTable().containsKey(attrib2.getMisc()[0])) { - // fetch the bitmask data, then build the attribute panel - final CAttribBitmask bitmask = archetypeTypeSet.getBitmaskTable().get(attrib2.getMisc()[0]); - tmpAttr.setBitmask(bitmask); - cLabel = new JButton(new MaskChangeAL(attrib2.getNameNew() + ":", tmpAttr)); - input.setBackground(getBackground()); - input.setEditable(false); - input.setBorder(BorderFactory.createLineBorder(Color.gray)); - input.setText(bitmask.getText(tmpAttr.getValue())); - cComp = input; - tmpAttr.setEncodedValue(gameObject.getAttributeString(nameOld)); - } else { - cRow = new JLabel("Error: Undefined Bitmask"); - } - newAttr = tmpAttr; - } - - /** {@inheritDoc} */ - public void visit(final ArchetypeAttributeTypeBool attrib) { - final JCheckBox input = new JCheckBox(attrib2.getNameNew(), gameObject.getAttributeInt(nameOld) == 1); - newAttr = new DialogAttribBool<G, A, R>(attrib2, input); - cRow = input; - } - - /** {@inheritDoc} */ - public void visit(final ArchetypeAttributeTypeBoolSpec attrib) { - final JCheckBox input; - final String trueVal = attrib2.getMisc()[0]; - if (trueVal.equals("0")) { - final String attrString = gameObject.getAttributeString(nameOld); - input = new JCheckBox(attrib2.getNameNew(), attrString.length() == 0 || attrString.equals("0")); - } else { - input = new JCheckBox(attrib2.getNameNew(), gameObject.getAttributeString(nameOld).equals(trueVal)); - } - newAttr = new DialogAttribBoolSpec<G, A, R>(attrib2, input); - cRow = input; - } - - /** {@inheritDoc} */ - public void visit(final ArchetypeAttributeTypeDoubleList attrib) { - final JPanel compo = new JPanel(new BorderLayout()); - cLabel = new JLabel(attrib2.getNameNew() + ": "); - cLabel.setForeground(CommonConstants.INT_COLOR); - // create ComboBox with parsed selection - final JComboBox[] inputs = new JComboBox[2]; - if (attrib2.getMisc() != null && archetypeTypeSet.getListTable().containsKey(attrib2.getMisc()[0]) && archetypeTypeSet.getListTable().containsKey(attrib2.getMisc()[1])) { - // Hack to set preselected if available - final int active = gameObject.getAttributeInt(nameOld); - final int[] activepart = {active & 0x0F, active & 0xF0}; - // build the lists from vector data - for (int j = 0; j < 2; j++) { - final List<?> listData = archetypeTypeSet.getListTable().get(attrib2.getMisc()[j]); - inputs[j] = buildArrayBox(attrib2, listData); - for (int k = 0; (double) k < listData.size() / 2.0; k++) { - if ((Integer) listData.get(k * 2) == activepart[j]) { - inputs[j].setSelectedIndex(k); // set active selection - break; - } - } - } - compo.add(inputs[0], BorderLayout.NORTH); - compo.add(inputs[1], BorderLayout.SOUTH); - cComp = compo; - } else { - // error: list data is missing or corrupt - cComp = new JLabel("Error: Undefined List"); - } - newAttr = new DialogAttribDoubleList<G, A, R>(attrib2, inputs, archetypeTypeSet); - } - - /** {@inheritDoc} */ - public void visit(final ArchetypeAttributeTypeFaceName attrib) { - final String dtxt; - if (nameOld.equalsIgnoreCase("name")) { - if (typeNoEventConnector != 0 && type.getTypeNo() == typeNoEventConnector) { - dtxt = gameObject.getObjName(); - } else - if (gameObject.getObjName() != null && gameObject.getObjName().length() > 0) { - dtxt = gameObject.getObjName(); - } else - if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { - dtxt = archetype.getObjName(); - } else { - dtxt = archetype.getArchetypeName(); - } - } else if (nameOld.equalsIgnoreCase("face")) { - dtxt = gameObject.getEffectiveFaceName(); - } else { - dtxt = gameObject.getAttributeString(nameOld); - } - final JTextField input = new JTextField(dtxt, TEXTFIELD_COLUMNS); - cLabel = new JButton(new TreeChooseAction(attrib2.getNameNew() + ": ", input, faceObjects)); - cComp = input; - newAttr = new DialogAttribFaceName<G, A, R>(attrib2, input, typeNoEventConnector, includeFaceText); - } - - /** {@inheritDoc} */ - public void visit(final ArchetypeAttributeTypeFixed attrib) { - // XXX - } - - /** {@inheritDoc} */ - public void visit(final ArchetypeAttributeTypeFloat attrib) { - cLabel = new JLabel(attrib2.getNameNew() + ": "); - cLabel.setForeground(CommonConstants.FLOAT_COLOR); - final int fieldLength = attrib2.getInputLength() == 0 ? TEXTFIELD_COLUMNS : attrib2.getInputLength(); - final NumberFormat format = NumberFormat.getInstance(); - format.setMaximumFractionDigits(10); - format.setGroupingUsed(false); - final NumberFormatter formatter = new NumberFormatter(format); - final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); - // parse value from gameObject - final Number value = gameObject.getAttributeDouble(nameOld); - final JFormattedTextField input = new JFormattedTextField(factory, value); - input.setColumns(fieldLength); - cComp = input; - newAttr = new DialogAttribFloat<G, A, R>(attrib2, input); - } - - /** {@inheritDoc} */ - public void visit(final ArchetypeAttribu... [truncated message content] |
From: <aki...@us...> - 2008-07-30 20:27:47
|
Revision: 4592 http://gridarta.svn.sourceforge.net/gridarta/?rev=4592&view=rev Author: akirschbaum Date: 2008-07-30 20:27:47 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-30 20:17:58 UTC (rev 4591) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-30 20:27:47 UTC (rev 4592) @@ -366,7 +366,7 @@ recentManager.initRecent(); validators = createMapValidators(); new AutoValidator<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, PREFS_VALIDATOR_AUTO_DEFAULT); - gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory(archetypeTypeSet, this, archetypeSet, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter); + gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory(archetypeTypeSet, this, archetypeSet, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter, Archetype.TYPE_EVENT_CONNECTOR, 0, false); } /** Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:17:58 UTC (rev 4591) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:27:47 UTC (rev 4592) @@ -47,15 +47,19 @@ * @param treasureListTree the treasure list tree instance to use * @param faceObjects the FaceObjects instance to use * @param mapFileFilter the Swing file filter to use + * @param typeNoEventConnector the object type for event objects + * @param undefinedSpellIndex the index used for "no" spell + * @param includeFaceText whether face names are included in the object + * text */ - public GameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { - super(archetypeTypeSet, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter); + public GameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { + super(archetypeTypeSet, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); } /** {@inheritDoc} */ @Override - protected GameObjectAttributesDialog<GameObject, MapArchObject, Archetype> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { - return new GameObjectAttributesDialog<GameObject, MapArchObject, Archetype>(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, Archetype.TYPE_EVENT_CONNECTOR, 0, false); + protected GameObjectAttributesDialog<GameObject, MapArchObject, Archetype> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { + return new GameObjectAttributesDialog<GameObject, MapArchObject, Archetype>(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); } } // class GameObjectAttributesDialogFactory Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-30 20:17:58 UTC (rev 4591) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-30 20:27:47 UTC (rev 4592) @@ -439,7 +439,7 @@ recentManager.initRecent(); validators = createMapValidators(); new AutoValidator<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, PREFS_VALIDATOR_AUTO_DEFAULT); - gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory(archetypeTypeSet, this, archetypeSet, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter); + gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory(archetypeTypeSet, this, archetypeSet, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter, 0, -1, true); } /** Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:17:58 UTC (rev 4591) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:27:47 UTC (rev 4592) @@ -47,15 +47,19 @@ * @param treasureListTree the treasure list tree instance to use * @param faceObjects the FaceObjects instance to use * @param mapFileFilter the Swing file filter to use + * @param typeNoEventConnector the object type for event objects + * @param undefinedSpellIndex the index used for "no" spell + * @param includeFaceText whether face names are included in the object + * text */ - public GameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { - super(archetypeTypeSet, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter); + public GameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { + super(archetypeTypeSet, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); } /** {@inheritDoc} */ @Override - protected GameObjectAttributesDialog<GameObject, MapArchObject, Archetype> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { - return new GameObjectAttributesDialog<GameObject, MapArchObject, Archetype>(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, 0, -1, true); + protected GameObjectAttributesDialog<GameObject, MapArchObject, Archetype> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { + return new GameObjectAttributesDialog<GameObject, MapArchObject, Archetype>(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); } } // class GameObjectAttributesDialogFactory Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java 2008-07-30 20:17:58 UTC (rev 4591) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java 2008-07-30 20:27:47 UTC (rev 4592) @@ -97,6 +97,21 @@ private final FileFilter mapFileFilter; /** + * The object type for event objects. + */ + private final int typeNoEventConnector; + + /** + * The index used for "no" spell. + */ + private final int undefinedSpellIndex; + + /** + * Whether face names are included in the object text. + */ + private final boolean includeFaceText; + + /** * Creates a new instance. * @param archetypeTypeSet the list of CF type-data * @param mainControl the main control @@ -106,8 +121,12 @@ * @param treasureListTree the treasure list tree instance to use * @param faceObjects the FaceObjects instance to use * @param mapFileFilter the Swing file filter to use + * @param typeNoEventConnector the object type for event objects + * @param undefinedSpellIndex the index used for "no" spell + * @param includeFaceText whether face names are included in the object + * text */ - protected AbstractGameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter) { + protected AbstractGameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { this.archetypeTypeSet = archetypeTypeSet; this.mainControl = mainControl; this.archetypeSet = archetypeSet; @@ -116,6 +135,9 @@ this.treasureListTree = treasureListTree; this.faceObjects = faceObjects; this.mapFileFilter = mapFileFilter; + this.typeNoEventConnector = typeNoEventConnector; + this.undefinedSpellIndex = undefinedSpellIndex; + this.includeFaceText = includeFaceText; } /** @@ -128,7 +150,7 @@ if (dialogs.containsKey(gameObject)) { dialogs.get(gameObject).toFront(); } else { - final GameObjectAttributesDialog<G, A, R> pane = newGameObjectAttributesDialog(archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter); + final GameObjectAttributesDialog<G, A, R> pane = newGameObjectAttributesDialog(archetypeTypeSet, gameObject, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); dialog.getRootPane().setDefaultButton(pane.okButton); dialog.setResizable(true); @@ -163,7 +185,11 @@ * @param treasureListTree the treasure list tree * @param faceObjects the FaceObjects instance to use * @param mapFileFilter the Swing file filter to use + * @param typeNoEventConnector the object type for event objects + * @param undefinedSpellIndex the index used for "no" spell + * @param includeFaceText whether face names are included in the object + * text */ - protected abstract GameObjectAttributesDialog<G, A, R> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter); + protected abstract GameObjectAttributesDialog<G, A, R> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText); } // class AbstractGameObjectAttributesDialogFactory This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-30 20:30:32
|
Revision: 4593 http://gridarta.svn.sourceforge.net/gridarta/?rev=4593&view=rev Author: akirschbaum Date: 2008-07-30 20:30:33 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Remove GameObjectAttributesDialogFactory.newGameObjectAttributesDialog(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java Modified: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:27:47 UTC (rev 4592) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:30:33 UTC (rev 4593) @@ -56,10 +56,4 @@ super(archetypeTypeSet, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); } - /** {@inheritDoc} */ - @Override - protected GameObjectAttributesDialog<GameObject, MapArchObject, Archetype> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { - return new GameObjectAttributesDialog<GameObject, MapArchObject, Archetype>(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); - } - } // class GameObjectAttributesDialogFactory Modified: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:27:47 UTC (rev 4592) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:30:33 UTC (rev 4593) @@ -56,10 +56,4 @@ super(archetypeTypeSet, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); } - /** {@inheritDoc} */ - @Override - protected GameObjectAttributesDialog<GameObject, MapArchObject, Archetype> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final GameObject gameObject, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { - return new GameObjectAttributesDialog<GameObject, MapArchObject, Archetype>(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); - } - } // class GameObjectAttributesDialogFactory Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java 2008-07-30 20:27:47 UTC (rev 4592) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java 2008-07-30 20:30:33 UTC (rev 4593) @@ -190,6 +190,9 @@ * @param includeFaceText whether face names are included in the object * text */ - protected abstract GameObjectAttributesDialog<G, A, R> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText); + private GameObjectAttributesDialog<G, A, R> newGameObjectAttributesDialog(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { + return new GameObjectAttributesDialog<G, A, R>(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); + } + } // class AbstractGameObjectAttributesDialogFactory This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-30 20:40:31
|
Revision: 4595 http://gridarta.svn.sourceforge.net/gridarta/?rev=4595&view=rev Author: akirschbaum Date: 2008-07-30 20:40:26 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Remove empty class GameObjectAttributesDialogFactory. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-30 20:32:56 UTC (rev 4594) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-30 20:40:26 UTC (rev 4595) @@ -28,7 +28,6 @@ import cfeditor.gameobject.face.FaceObjects; import cfeditor.gameobject.scripts.ScriptArchUtils; import cfeditor.gui.GameObjectAttributesPanel; -import cfeditor.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import cfeditor.gui.map.CMapViewBasic; import cfeditor.gui.prefs.GUIPrefs; import cfeditor.gui.prefs.ResPrefs; @@ -74,6 +73,7 @@ import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.connectionview.LockedItemsControl; +import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.DeletionTool; @@ -206,10 +206,10 @@ private final NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapDialogFactory; /** - * The {@link GameObjectAttributesDialogFactory} to use. + * The {@link AbstractGameObjectAttributesDialogFactory} to use. */ @NotNull - private final GameObjectAttributesDialogFactory gameObjectAttributesDialogFactory; + private final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory; @NotNull private final GameObjectAttributesPanel gameObjectAttributesPanel; @@ -366,7 +366,7 @@ recentManager.initRecent(); validators = createMapValidators(); new AutoValidator<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, PREFS_VALIDATOR_AUTO_DEFAULT); - gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory(archetypeTypeSet, this, archetypeSet, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter, Archetype.TYPE_EVENT_CONNECTOR, 0, false); + gameObjectAttributesDialogFactory = new AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, this, archetypeSet, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter, Archetype.TYPE_EVENT_CONNECTOR, 0, false); } /** Deleted: trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:32:56 UTC (rev 4594) +++ trunk/crossfire/src/cfeditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:40:26 UTC (rev 4595) @@ -1,59 +0,0 @@ -/* - * 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.gameobjectattributesdialog; - -import cfeditor.gameobject.Archetype; -import cfeditor.gameobject.GameObject; -import cfeditor.gui.map.CMapViewBasic; -import cfeditor.map.MapArchObject; -import javax.swing.filechooser.FileFilter; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gameobject.ArchetypeSet; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; -import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialog; -import net.sf.gridarta.treasurelist.CFTreasureListTree; -import org.jetbrains.annotations.NotNull; - -public class GameObjectAttributesDialogFactory extends AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> { - - /** - * Creates a new instance. - * @param archetypeTypeSet the list of CF type-data - * @param mainControl main control - * @param archetypeSet the archetype set to use - * @param animationObjects the animation objects instance to use - * @param mapManager the map manager - * @param treasureListTree the treasure list tree instance to use - * @param faceObjects the FaceObjects instance to use - * @param mapFileFilter the Swing file filter to use - * @param typeNoEventConnector the object type for event objects - * @param undefinedSpellIndex the index used for "no" spell - * @param includeFaceText whether face names are included in the object - * text - */ - public GameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { - super(archetypeTypeSet, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); - } - -} // class GameObjectAttributesDialogFactory Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-30 20:32:56 UTC (rev 4594) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-30 20:40:26 UTC (rev 4595) @@ -27,7 +27,6 @@ import daieditor.gameobject.face.FaceObjects; import daieditor.gameobject.scripts.ScriptArchUtils; import daieditor.gui.GameObjectAttributesPanel; -import daieditor.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import daieditor.gui.map.CMapViewBasic; import daieditor.gui.prefs.AppPrefs; import daieditor.gui.prefs.DevPrefs; @@ -82,6 +81,7 @@ import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.connectionview.LockedItemsControl; +import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.DeletionTool; @@ -261,10 +261,10 @@ private final NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapDialogFactory; /** - * The {@link GameObjectAttributesDialogFactory} to use. + * The {@link AbstractGameObjectAttributesDialogFactory} to use. */ @NotNull - private final GameObjectAttributesDialogFactory gameObjectAttributesDialogFactory; + private final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory; @NotNull private final GameObjectAttributesPanel gameObjectAttributesPanel; @@ -439,7 +439,7 @@ recentManager.initRecent(); validators = createMapValidators(); new AutoValidator<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, PREFS_VALIDATOR_AUTO_DEFAULT); - gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory(archetypeTypeSet, this, archetypeSet, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter, 0, -1, true); + gameObjectAttributesDialogFactory = new AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, this, archetypeSet, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter, 0, -1, true); } /** Deleted: trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:32:56 UTC (rev 4594) +++ trunk/daimonin/src/daieditor/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:40:26 UTC (rev 4595) @@ -1,59 +0,0 @@ -/* - * 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 daieditor.gui.gameobjectattributesdialog; - -import daieditor.gameobject.Archetype; -import daieditor.gameobject.GameObject; -import daieditor.gui.map.CMapViewBasic; -import daieditor.map.MapArchObject; -import javax.swing.filechooser.FileFilter; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gameobject.ArchetypeSet; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; -import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialog; -import net.sf.gridarta.treasurelist.CFTreasureListTree; -import org.jetbrains.annotations.NotNull; - -public class GameObjectAttributesDialogFactory extends AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> { - - /** - * Creates a new instance. - * @param archetypeTypeSet the list of CF type-data - * @param mainControl main control - * @param archetypeSet the archetype set to use - * @param animationObjects the animation objects instance to use - * @param mapManager the map manager - * @param treasureListTree the treasure list tree instance to use - * @param faceObjects the FaceObjects instance to use - * @param mapFileFilter the Swing file filter to use - * @param typeNoEventConnector the object type for event objects - * @param undefinedSpellIndex the index used for "no" spell - * @param includeFaceText whether face names are included in the object - * text - */ - public GameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManager, @NotNull final CFTreasureListTree<GameObject, MapArchObject, Archetype> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { - super(archetypeTypeSet, mainControl, archetypeSet, animationObjects, mapManager, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); - } - -} // class GameObjectAttributesDialogFactory Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java 2008-07-30 20:32:56 UTC (rev 4594) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java 2008-07-30 20:40:26 UTC (rev 4595) @@ -37,7 +37,7 @@ import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; -public abstract class AbstractGameObjectAttributesDialogFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { +public class AbstractGameObjectAttributesDialogFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); @@ -126,7 +126,7 @@ * @param includeFaceText whether face names are included in the object * text */ - protected AbstractGameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { + public AbstractGameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { this.archetypeTypeSet = archetypeTypeSet; this.mainControl = mainControl; this.archetypeSet = archetypeSet; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-30 20:44:12
|
Revision: 4596 http://gridarta.svn.sourceforge.net/gridarta/?rev=4596&view=rev Author: akirschbaum Date: 2008-07-30 20:44:10 +0000 (Wed, 30 Jul 2008) Log Message: ----------- Rename AbstractGameObjectAttributesDialogFactory to GameObjectAttributesDialogFactory since it is not abstract anymore. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-30 20:40:26 UTC (rev 4595) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-30 20:44:10 UTC (rev 4596) @@ -73,7 +73,7 @@ import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.connectionview.LockedItemsControl; -import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; +import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.DeletionTool; @@ -206,10 +206,10 @@ private final NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapDialogFactory; /** - * The {@link AbstractGameObjectAttributesDialogFactory} to use. + * The {@link GameObjectAttributesDialogFactory} to use. */ @NotNull - private final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory; + private final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory; @NotNull private final GameObjectAttributesPanel gameObjectAttributesPanel; @@ -366,7 +366,7 @@ recentManager.initRecent(); validators = createMapValidators(); new AutoValidator<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, PREFS_VALIDATOR_AUTO_DEFAULT); - gameObjectAttributesDialogFactory = new AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, this, archetypeSet, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter, Archetype.TYPE_EVENT_CONNECTOR, 0, false); + gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, this, archetypeSet, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter, Archetype.TYPE_EVENT_CONNECTOR, 0, false); } /** Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-30 20:40:26 UTC (rev 4595) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-30 20:44:10 UTC (rev 4596) @@ -81,7 +81,7 @@ import net.sf.gridarta.gui.SystemIcons; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.connectionview.LockedItemsControl; -import net.sf.gridarta.gui.gameobjectattributesdialog.AbstractGameObjectAttributesDialogFactory; +import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.map.MapCursorControl; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.DeletionTool; @@ -261,10 +261,10 @@ private final NewMapDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapDialogFactory; /** - * The {@link AbstractGameObjectAttributesDialogFactory} to use. + * The {@link GameObjectAttributesDialogFactory} to use. */ @NotNull - private final AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory; + private final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory; @NotNull private final GameObjectAttributesPanel gameObjectAttributesPanel; @@ -439,7 +439,7 @@ recentManager.initRecent(); validators = createMapValidators(); new AutoValidator<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, PREFS_VALIDATOR_AUTO_DEFAULT); - gameObjectAttributesDialogFactory = new AbstractGameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, this, archetypeSet, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter, 0, -1, true); + gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, this, archetypeSet, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter, 0, -1, true); } /** Deleted: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java 2008-07-30 20:40:26 UTC (rev 4595) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java 2008-07-30 20:44:10 UTC (rev 4596) @@ -1,177 +0,0 @@ -/* - * 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 net.sf.gridarta.gui.gameobjectattributesdialog; - -import java.util.HashMap; -import java.util.Map; -import javax.swing.JDialog; -import javax.swing.filechooser.FileFilter; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.MapManager; -import net.sf.gridarta.archtype.ArchetypeTypeSet; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.ArchetypeSet; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.face.FaceObjects; -import net.sf.gridarta.gui.map.MapViewBasic; -import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.treasurelist.CFTreasureListTree; -import net.sf.japi.swing.ActionFactory; -import org.jetbrains.annotations.NotNull; - -public class AbstractGameObjectAttributesDialogFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - - /** - * The gameObject objects that already are shown, to avoid opening a dialog - * twice. - */ - private final Map<G, JDialog> dialogs = new HashMap<G, JDialog>(); - - /** - * The list of CF type-data. - */ - @NotNull - private final ArchetypeTypeSet archetypeTypeSet; - - /** - * The main control. - */ - @NotNull - private final MainControl<G, A, R, V> mainControl; - - /** - * The archetype set to use. - */ - @NotNull - private final ArchetypeSet<G, A, R> archetypeSet; - - /** - * The animation objects instance to use. - */ - @NotNull - private final AnimationObjects<?> animationObjects; - - /** - * The map manager. - */ - @NotNull - private final MapManager<G, A, R, V> mapManager; - - /** - * The treasure list tree instance to use. - */ - @NotNull - private final CFTreasureListTree<G, A, R> treasureListTree; - - /** - * The FaceObjects instance to use. - */ - @NotNull - private final FaceObjects faceObjects; - - /** - * The Swing file filter to use. - */ - @NotNull - private final FileFilter mapFileFilter; - - /** - * The object type for event objects. - */ - private final int typeNoEventConnector; - - /** - * The index used for "no" spell. - */ - private final int undefinedSpellIndex; - - /** - * Whether face names are included in the object text. - */ - private final boolean includeFaceText; - - /** - * Creates a new instance. - * @param archetypeTypeSet the list of CF type-data - * @param mainControl the main control - * @param archetypeSet the archetype set to use - * @param animationObjects the animation objects instance to use - * @param mapManager the map manager - * @param treasureListTree the treasure list tree instance to use - * @param faceObjects the FaceObjects instance to use - * @param mapFileFilter the Swing file filter to use - * @param typeNoEventConnector the object type for event objects - * @param undefinedSpellIndex the index used for "no" spell - * @param includeFaceText whether face names are included in the object - * text - */ - public AbstractGameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { - this.archetypeTypeSet = archetypeTypeSet; - this.mainControl = mainControl; - this.archetypeSet = archetypeSet; - this.animationObjects = animationObjects; - this.mapManager = mapManager; - this.treasureListTree = treasureListTree; - this.faceObjects = faceObjects; - this.mapFileFilter = mapFileFilter; - this.typeNoEventConnector = typeNoEventConnector; - this.undefinedSpellIndex = undefinedSpellIndex; - this.includeFaceText = includeFaceText; - } - - /** - * Shows the game object attributes dialog for a given {@link GameObject} - * instance. - * @param gameObject the GameObject to be displayed by this dialog - */ - public void showAttribDialog(@NotNull final G gameObject) { - synchronized (dialogs) { - if (dialogs.containsKey(gameObject)) { - dialogs.get(gameObject).toFront(); - } else { - final GameObjectAttributesDialog<G, A, R> pane = new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); - final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); - dialog.getRootPane().setDefaultButton(pane.okButton); - dialog.setResizable(true); - dialog.setModal(false); - dialog.setVisible(true); - dialogs.put(pane.gameObject, dialog); - } - } - } - - - /** - * Hides the game object attributes dialog for a given {@link GameObject} - * instance. - * @param gameObject the GameObject to be displayed by this dialog - */ - public void hideAttribDialog(@NotNull final G gameObject) { - final JDialog dialog = dialogs.remove(gameObject); - if (dialog != null) { - dialog.dispose(); - } - } - -} // class AbstractGameObjectAttributesDialogFactory Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 20:40:26 UTC (rev 4595) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-07-30 20:44:10 UTC (rev 4596) @@ -142,7 +142,7 @@ * The associated factory. */ @NotNull - private final AbstractGameObjectAttributesDialogFactory<G, A, R, ?> gameObjectAttributesDialogFactory; + private final GameObjectAttributesDialogFactory<G, A, R, ?> gameObjectAttributesDialogFactory; /** Reference to the {@link ArchetypeTypeSet}. */ private final ArchetypeTypeSet archetypeTypeSet; @@ -252,7 +252,7 @@ * @param includeFaceText whether face names are included in the object * text */ - public GameObjectAttributesDialog(@NotNull final AbstractGameObjectAttributesDialogFactory<G, A, R, ?> gameObjectAttributesDialogFactory, final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, ?> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapManager<G, A, R, ?> mapManager, @NotNull final AnimationObjects<?> animationObjects, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { + public GameObjectAttributesDialog(@NotNull final GameObjectAttributesDialogFactory<G, A, R, ?> gameObjectAttributesDialogFactory, final ArchetypeTypeSet archetypeTypeSet, @NotNull final G gameObject, @NotNull final MainControl<G, A, R, ?> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapManager<G, A, R, ?> mapManager, @NotNull final AnimationObjects<?> animationObjects, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.archetypeTypeSet = archetypeTypeSet; this.typeNoEventConnector = typeNoEventConnector; Copied: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java (from rev 4595, trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/AbstractGameObjectAttributesDialogFactory.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2008-07-30 20:44:10 UTC (rev 4596) @@ -0,0 +1,177 @@ +/* + * 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 net.sf.gridarta.gui.gameobjectattributesdialog; + +import java.util.HashMap; +import java.util.Map; +import javax.swing.JDialog; +import javax.swing.filechooser.FileFilter; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.MapManager; +import net.sf.gridarta.archtype.ArchetypeTypeSet; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.ArchetypeSet; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.anim.AnimationObjects; +import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.treasurelist.CFTreasureListTree; +import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; + +public class GameObjectAttributesDialogFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** + * The gameObject objects that already are shown, to avoid opening a dialog + * twice. + */ + private final Map<G, JDialog> dialogs = new HashMap<G, JDialog>(); + + /** + * The list of CF type-data. + */ + @NotNull + private final ArchetypeTypeSet archetypeTypeSet; + + /** + * The main control. + */ + @NotNull + private final MainControl<G, A, R, V> mainControl; + + /** + * The archetype set to use. + */ + @NotNull + private final ArchetypeSet<G, A, R> archetypeSet; + + /** + * The animation objects instance to use. + */ + @NotNull + private final AnimationObjects<?> animationObjects; + + /** + * The map manager. + */ + @NotNull + private final MapManager<G, A, R, V> mapManager; + + /** + * The treasure list tree instance to use. + */ + @NotNull + private final CFTreasureListTree<G, A, R> treasureListTree; + + /** + * The FaceObjects instance to use. + */ + @NotNull + private final FaceObjects faceObjects; + + /** + * The Swing file filter to use. + */ + @NotNull + private final FileFilter mapFileFilter; + + /** + * The object type for event objects. + */ + private final int typeNoEventConnector; + + /** + * The index used for "no" spell. + */ + private final int undefinedSpellIndex; + + /** + * Whether face names are included in the object text. + */ + private final boolean includeFaceText; + + /** + * Creates a new instance. + * @param archetypeTypeSet the list of CF type-data + * @param mainControl the main control + * @param archetypeSet the archetype set to use + * @param animationObjects the animation objects instance to use + * @param mapManager the map manager + * @param treasureListTree the treasure list tree instance to use + * @param faceObjects the FaceObjects instance to use + * @param mapFileFilter the Swing file filter to use + * @param typeNoEventConnector the object type for event objects + * @param undefinedSpellIndex the index used for "no" spell + * @param includeFaceText whether face names are included in the object + * text + */ + public GameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final AnimationObjects<?> animationObjects, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final FaceObjects faceObjects, @NotNull final FileFilter mapFileFilter, final int typeNoEventConnector, final int undefinedSpellIndex, final boolean includeFaceText) { + this.archetypeTypeSet = archetypeTypeSet; + this.mainControl = mainControl; + this.archetypeSet = archetypeSet; + this.animationObjects = animationObjects; + this.mapManager = mapManager; + this.treasureListTree = treasureListTree; + this.faceObjects = faceObjects; + this.mapFileFilter = mapFileFilter; + this.typeNoEventConnector = typeNoEventConnector; + this.undefinedSpellIndex = undefinedSpellIndex; + this.includeFaceText = includeFaceText; + } + + /** + * Shows the game object attributes dialog for a given {@link GameObject} + * instance. + * @param gameObject the GameObject to be displayed by this dialog + */ + public void showAttribDialog(@NotNull final G gameObject) { + synchronized (dialogs) { + if (dialogs.containsKey(gameObject)) { + dialogs.get(gameObject).toFront(); + } else { + final GameObjectAttributesDialog<G, A, R> pane = new GameObjectAttributesDialog(this, archetypeTypeSet, gameObject, mainControl, archetypeSet, mapManager, animationObjects, treasureListTree, faceObjects, mapFileFilter, typeNoEventConnector, undefinedSpellIndex, includeFaceText); + final JDialog dialog = pane.createDialog(mainControl.getMainView(), ACTION_FACTORY.getString("attribTitle")); + dialog.getRootPane().setDefaultButton(pane.okButton); + dialog.setResizable(true); + dialog.setModal(false); + dialog.setVisible(true); + dialogs.put(pane.gameObject, dialog); + } + } + } + + + /** + * Hides the game object attributes dialog for a given {@link GameObject} + * instance. + * @param gameObject the GameObject to be displayed by this dialog + */ + public void hideAttribDialog(@NotNull final G gameObject) { + final JDialog dialog = dialogs.remove(gameObject); + if (dialog != null) { + dialog.dispose(); + } + } + +} // class GameObjectAttributesDialogFactory Property changes on: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mergeinfo + Added: 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...> - 2008-07-31 10:00:04
|
Revision: 4603 http://gridarta.svn.sourceforge.net/gridarta/?rev=4603&view=rev Author: akirschbaum Date: 2008-07-31 10:00:10 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Extract ArchetypeTypeSetParser from ArchetypeTypeSet. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSet.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSetParser.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-30 22:53:45 UTC (rev 4602) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 10:00:10 UTC (rev 4603) @@ -54,6 +54,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.XmlHelper; import net.sf.gridarta.archtype.ArchetypeTypeSet; +import net.sf.gridarta.archtype.ArchetypeTypeSetParser; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gameobject.match.GameObjectMatchers; @@ -257,7 +258,7 @@ log.error("Cannot create XML parser: " + ex.getMessage()); throw new MissingResourceException("Cannot create XML parser: " + ex.getMessage(), null, null); } - archetypeTypeSet = new ArchetypeTypeSet(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); + archetypeTypeSet = new ArchetypeTypeSet(); final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); new ArchetypeSetSpellLoader<GameObject, MapArchObject, Archetype>().load(archetypeSet, Archetype.TYPE_SPELL, gameObjectSpells); gameObjectSpells.sort(); @@ -289,9 +290,10 @@ } final MapActions mapActions = new MapActions(mainView, this, getMapManager(), exitMatcher, mapFileFilter, selectedSquareView); archetypeTypeSet.getListTable().put("event", ScriptArchUtils.getEventTypes()); + final ArchetypeTypeSetParser archetypeTypeSetParser = new ArchetypeTypeSetParser(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath(), archetypeTypeSet); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); - archetypeTypeSet.loadTypesFromXML(filename); + archetypeTypeSetParser.loadTypesFromXML(filename); } catch (final FileNotFoundException ex) { log.error("Cannot read " + CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage()); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-30 22:53:45 UTC (rev 4602) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 10:00:10 UTC (rev 4603) @@ -58,6 +58,7 @@ import net.sf.gridarta.MainControl; import net.sf.gridarta.XmlHelper; import net.sf.gridarta.archtype.ArchetypeTypeSet; +import net.sf.gridarta.archtype.ArchetypeTypeSetParser; import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gameobject.match.GameObjectMatcher; @@ -317,7 +318,7 @@ log.error("Cannot create XML parser: " + ex.getMessage()); throw new MissingResourceException("Cannot create XML parser: " + ex.getMessage(), null, null); } - archetypeTypeSet = new ArchetypeTypeSet(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); + archetypeTypeSet = new ArchetypeTypeSet(); final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); gameObjectSpells.sort(); XMLSpellLoader.load(getConfigurationDirectory(), CommonConstants.SPELL_FILE, xmlHelper.getDocumentBuilder(), numberSpells); @@ -348,9 +349,10 @@ throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); } final MapActions mapActions = new MapActions(mainView, this, getMapManager(), exitMatcher, mapFileFilter, selectedSquareView); + final ArchetypeTypeSetParser archetypeTypeSetParser = new ArchetypeTypeSetParser(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath(), archetypeTypeSet); try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); - archetypeTypeSet.loadTypesFromXML(filename); + archetypeTypeSetParser.loadTypesFromXML(filename); } catch (final FileNotFoundException ex) { log.error("Cannot read " + CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage()); } Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSet.java 2008-07-30 22:53:45 UTC (rev 4602) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSet.java 2008-07-31 10:00:10 UTC (rev 4603) @@ -19,25 +19,15 @@ package net.sf.gridarta.archtype; -import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathExpressionException; -import net.sf.gridarta.CommonConstants; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.japi.xml.NodeListIterator; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.SAXException; /** * Common base class for ArchetypeTypeSet. @@ -48,20 +38,14 @@ /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(ArchetypeTypeSet.class); - /** DocumentBuilder. */ - private final DocumentBuilder documentBuilder; - - /** The XPath for using XPath. */ - private final XPath xpath; - /** The default type. */ - private ArchetypeType defaultArchetypeType = null; + ArchetypeType defaultArchetypeType = null; /** * The default (fallback) type used for game objects not matching any * defined type. */ - private ArchetypeType fallbackArchetypeType = null; + ArchetypeType fallbackArchetypeType = null; /** * Lists with all ArchetypeTypes. Contains all but the default @@ -69,7 +53,7 @@ * @todo verify whether the default ArchetypeType really is not included in * this list. */ - private final List<ArchetypeType> archetypeTypeList = new ArrayList<ArchetypeType>(); // All but the default ArchetypeType + final List<ArchetypeType> archetypeTypeList = new ArrayList<ArchetypeType>(); // All but the default ArchetypeType /** * Table with List objects for lists (value) accessible by name (key). The @@ -78,151 +62,27 @@ * @todo Refactor the List to contain Pairs or something like that so it * doesn't contain two types. */ - private final Map<String, List<?>> listTable; + final Map<String, List<?>> listTable; /** Table with CAttribBitmask objects (value) accessible by name (key). */ - private final Map<String, CAttribBitmask> bitmaskTable; + final Map<String, CAttribBitmask> bitmaskTable; // table with type arch type name as keys (String), and arch type object as values (ArchetypeType) - private final Map<String, ArchetypeType> archetypeTypeNames = new HashMap<String, ArchetypeType>(); + final Map<String, ArchetypeType> archetypeTypeNames = new HashMap<String, ArchetypeType>(); /** * Constructor - Parsing all the data from the xml definitions file * 'types.xml'. - * @param documentBuilder DocumentBuilder to use for parsing XML. - * @param xpath XPath to use for applying for XPath expressions. * @todo I consume too much time. Why? XPath is too slow. Let's hope Beta4 * arrives soon, then some XPath that contains backup compatible expressions * can be replaced by faster direct access */ - public ArchetypeTypeSet(@NotNull final DocumentBuilder documentBuilder, @NotNull final XPath xpath) { - this.xpath = xpath; - this.documentBuilder = documentBuilder; + public ArchetypeTypeSet() { listTable = new HashMap<String, List<?>>(); bitmaskTable = new HashMap<String, CAttribBitmask>(); } - public void loadTypesFromXML(@NotNull final String filename) { - final Map<String, List<String>> ignoreListTable = new HashMap<String, List<String>>(); - try { - // parse xml document - final Document doc = documentBuilder.parse(filename); - - // start parsing the xml - final Element root = doc.getDocumentElement(); - parseBitmasks(root); - parseLists(root); - parseIgnoreLists(root, ignoreListTable); - defaultArchetypeType = parseDefaultType(root, ignoreListTable); - parseTypes(root, ignoreListTable); - - if (log.isInfoEnabled()) { - log.info("Loaded " + archetypeTypeList.size() + " types from '" + filename + "\'"); - } - } catch (final SAXException e) { - log.error("Parsing error in '" + filename + "':\n" + e.getMessage()); - } catch (final IOException e) { - log.error("Cannot read file '" + filename + "'!"); - } catch (final XPathExpressionException e) { - log.error("XPath error: " + e.getMessage()); - } - - fallbackArchetypeType = archetypeTypeNames.get("Misc"); - if (fallbackArchetypeType == null) { - fallbackArchetypeType = new ArchetypeType(defaultArchetypeType); - } - } - - private void parseBitmasks(final Element root) throws XPathExpressionException { - for (final Element elem : new NodeListIterator<Element>(xpath, root, "bitmasks/bitmask")) { - bitmaskTable.put(elem.getAttribute("name"), new CAttribBitmask(xpath, elem)); - } - } - - private void parseLists(final Element root) throws ArchetypeTypeParseException, XPathExpressionException { - for (final Element elem : new NodeListIterator<Element>(xpath, root, "lists/list")) { - if (elem.getAttribute("name") == null) { - throw new ArchetypeTypeParseException("In file '" + CommonConstants.TYPEDEF_FILE + "': cannot load list element without 'name'."); - } else { - final List<?> list = parseListFromElement(elem); - if (list != null && !list.isEmpty()) { - listTable.put(elem.getAttribute("name"), list); - } - } - } - } - /** - * Parse a list vector from an xml list element. - * @param root element to parse - * @return List with data parsed from <var>root</var> - * @throws XPathExpressionException In case of XPath issues (should never - * happen). - * @todo improve this comment - */ - private List<?> parseListFromElement(final Element root) throws ArchetypeTypeParseException, XPathExpressionException { - // XXX The list created here contains altering types: Integer for even, String for odd indices. - final List<Object> list = new ArrayList<Object>(); - for (final Element elem : new NodeListIterator<Element>(xpath, root, "listentry")) { - // every list entry adds value (Integer) and name (String) to the vector - try { - list.add(Integer.valueOf(elem.getAttribute("value"))); - list.add(" " + elem.getAttribute("name").trim()); - } catch (final NumberFormatException ignore) { - throw new ArchetypeTypeParseException("In '" + CommonConstants.TYPEDEF_FILE + "', list " + root.getAttribute("name") + ": value '" + elem.getAttribute("value") + "' is not an integer."); - } - } - return list; - } - - private void parseIgnoreLists(final Element root, @NotNull final Map<String, List<String>> ignoreListTable) throws ArchetypeTypeParseException, XPathExpressionException { - for (final Element elem : new NodeListIterator<Element>(xpath, root, "ignore_list|ignorelists/ignore_list")) { - if (elem.getAttribute("name") == null) { - throw new ArchetypeTypeParseException("In file '" + CommonConstants.TYPEDEF_FILE + "': cannot load ignore_list element without 'name'."); - } else { - final String lname = elem.getAttribute("name").trim(); - final List<String> content = new ArrayList<String>(); - for (final Element el2 : new NodeListIterator<Element>(elem, ArchetypeTypeParser.XML_ATTRIBUTE)) { - final Attr a = el2.getAttributeNode(ArchetypeAttributeParser.XML_KEY_ARCH); - if (a != null) { - content.add(a.getValue().trim()); - } else { - throw new ArchetypeTypeParseException("In file '" + CommonConstants.TYPEDEF_FILE + "': ignore_list '" + lname + "' has " + ArchetypeTypeParser.XML_ATTRIBUTE + " missing '" + ArchetypeAttributeParser.XML_KEY_ARCH + "'."); - } - } - // now add the list vector to the ignoreListTable: - if (!content.isEmpty()) { - ignoreListTable.put(lname, content); - } - } - } - } - - private ArchetypeType parseDefaultType(final Element root, @NotNull final Map<String, List<String>> ignoreListTable) throws ArchetypeTypeParseException { - // parse default type - final Element el = NodeListIterator.getFirstChild(root, "default_type"); - if (el == null) { - throw new ArchetypeTypeParseException("In file '" + CommonConstants.TYPEDEF_FILE + "': default_type element is missing!"); - } - - return ArchetypeTypeParser.load(null, el, this, ignoreListTable); - } - - private void parseTypes(final Element root, @NotNull final Map<String, List<String>> ignoreListTable) throws ArchetypeTypeParseException { - // parse all type elements - for (final Element elem : new NodeListIterator<Element>(root, "type")) { - if (!"no".equals(elem.getAttribute("available"))) { - final ArchetypeType newType = ArchetypeTypeParser.load(defaultArchetypeType, elem, this, ignoreListTable); - if (newType != null) { - // attach the new ArchetypeType element to the list - archetypeTypeList.add(newType); - archetypeTypeNames.put(newType.getTypeName(), newType); - } - } - } - } - - /** * Returns the list table which contains all definitions of list types for * arch attributes. * @return list table Added: trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSetParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSetParser.java (rev 0) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSetParser.java 2008-07-31 10:00:10 UTC (rev 4603) @@ -0,0 +1,200 @@ +/* + * 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 net.sf.gridarta.archtype; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.xpath.XPath; +import javax.xml.xpath.XPathExpressionException; +import net.sf.gridarta.CommonConstants; +import net.sf.japi.xml.NodeListIterator; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.xml.sax.SAXException; + +/** + * Parser for {@link ArchetypeTypeSet}s. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ +public class ArchetypeTypeSetParser { + + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(ArchetypeTypeSetParser.class); + + /** + * The document builder to use. + */ + @NotNull + private final DocumentBuilder documentBuilder; + + /** + * The XPath for using XPath. + */ + @NotNull + private final XPath xpath; + + /** + * The archetype type set to update. + */ + @NotNull + private final ArchetypeTypeSet archetypeTypeSet; + + /** + * Creates a new instance. + * @param documentBuilder the document builder to use + * @param xpath the XPath instance to use for applying for XPath + * expressions + * @param archetypeTypeSet the archetype type set to update + */ + public ArchetypeTypeSetParser(@NotNull final DocumentBuilder documentBuilder, @NotNull final XPath xpath, @NotNull final ArchetypeTypeSet archetypeTypeSet) { + this.documentBuilder = documentBuilder; + this.xpath = xpath; + this.archetypeTypeSet = archetypeTypeSet; + } + + public void loadTypesFromXML(@NotNull final String filename) { + final Map<String, List<String>> ignoreListTable = new HashMap<String, List<String>>(); + try { + // parse xml document + final Document doc = documentBuilder.parse(filename); + + // start parsing the xml + final Element root = doc.getDocumentElement(); + parseBitmasks(root); + parseLists(root); + parseIgnoreLists(root, ignoreListTable); + archetypeTypeSet.defaultArchetypeType = parseDefaultType(root, ignoreListTable); + parseTypes(root, ignoreListTable); + + if (log.isInfoEnabled()) { + log.info("Loaded " + archetypeTypeSet.archetypeTypeList.size() + " types from '" + filename + "\'"); + } + } catch (final SAXException e) { + log.error("Parsing error in '" + filename + "':\n" + e.getMessage()); + } catch (final IOException e) { + log.error("Cannot read file '" + filename + "'!"); + } catch (final XPathExpressionException e) { + log.error("XPath error: " + e.getMessage()); + } + + archetypeTypeSet.fallbackArchetypeType = archetypeTypeSet.archetypeTypeNames.get("Misc"); + if (archetypeTypeSet.fallbackArchetypeType == null) { + archetypeTypeSet.fallbackArchetypeType = new ArchetypeType(archetypeTypeSet.defaultArchetypeType); + } + } + + private void parseBitmasks(final Element root) throws XPathExpressionException { + for (final Element elem : new NodeListIterator<Element>(xpath, root, "bitmasks/bitmask")) { + archetypeTypeSet.bitmaskTable.put(elem.getAttribute("name"), new CAttribBitmask(xpath, elem)); + } + } + + private void parseLists(final Element root) throws ArchetypeTypeParseException, XPathExpressionException { + for (final Element elem : new NodeListIterator<Element>(xpath, root, "lists/list")) { + if (elem.getAttribute("name") == null) { + throw new ArchetypeTypeParseException("In file '" + CommonConstants.TYPEDEF_FILE + "': cannot load list element without 'name'."); + } else { + final List<?> list = parseListFromElement(elem); + if (list != null && !list.isEmpty()) { + archetypeTypeSet.listTable.put(elem.getAttribute("name"), list); + } + } + } + } + + /** + * Parse a list vector from an xml list element. + * @param root element to parse + * @return List with data parsed from <var>root</var> + * @throws XPathExpressionException In case of XPath issues (should never + * happen). + * @todo improve this comment + */ + private List<?> parseListFromElement(final Element root) throws ArchetypeTypeParseException, XPathExpressionException { + // XXX The list created here contains altering types: Integer for even, String for odd indices. + final List<Object> list = new ArrayList<Object>(); + for (final Element elem : new NodeListIterator<Element>(xpath, root, "listentry")) { + // every list entry adds value (Integer) and name (String) to the vector + try { + list.add(Integer.valueOf(elem.getAttribute("value"))); + list.add(" " + elem.getAttribute("name").trim()); + } catch (final NumberFormatException ignore) { + throw new ArchetypeTypeParseException("In '" + CommonConstants.TYPEDEF_FILE + "', list " + root.getAttribute("name") + ": value '" + elem.getAttribute("value") + "' is not an integer."); + } + } + return list; + } + + private void parseIgnoreLists(final Element root, @NotNull final Map<String, List<String>> ignoreListTable) throws ArchetypeTypeParseException, XPathExpressionException { + for (final Element elem : new NodeListIterator<Element>(xpath, root, "ignore_list|ignorelists/ignore_list")) { + if (elem.getAttribute("name") == null) { + throw new ArchetypeTypeParseException("In file '" + CommonConstants.TYPEDEF_FILE + "': cannot load ignore_list element without 'name'."); + } else { + final String lname = elem.getAttribute("name").trim(); + final List<String> content = new ArrayList<String>(); + for (final Element el2 : new NodeListIterator<Element>(elem, ArchetypeTypeParser.XML_ATTRIBUTE)) { + final Attr a = el2.getAttributeNode(ArchetypeAttributeParser.XML_KEY_ARCH); + if (a != null) { + content.add(a.getValue().trim()); + } else { + throw new ArchetypeTypeParseException("In file '" + CommonConstants.TYPEDEF_FILE + "': ignore_list '" + lname + "' has " + ArchetypeTypeParser.XML_ATTRIBUTE + " missing '" + ArchetypeAttributeParser.XML_KEY_ARCH + "'."); + } + } + // now add the list vector to the ignoreListTable: + if (!content.isEmpty()) { + ignoreListTable.put(lname, content); + } + } + } + } + + private ArchetypeType parseDefaultType(final Element root, @NotNull final Map<String, List<String>> ignoreListTable) throws ArchetypeTypeParseException { + // parse default type + final Element el = NodeListIterator.getFirstChild(root, "default_type"); + if (el == null) { + throw new ArchetypeTypeParseException("In file '" + CommonConstants.TYPEDEF_FILE + "': default_type element is missing!"); + } + + return ArchetypeTypeParser.load(null, el, archetypeTypeSet, ignoreListTable); + } + + private void parseTypes(final Element root, @NotNull final Map<String, List<String>> ignoreListTable) throws ArchetypeTypeParseException { + // parse all type elements + for (final Element elem : new NodeListIterator<Element>(root, "type")) { + if (!"no".equals(elem.getAttribute("available"))) { + final ArchetypeType newType = ArchetypeTypeParser.load(archetypeTypeSet.defaultArchetypeType, elem, archetypeTypeSet, ignoreListTable); + if (newType != null) { + // attach the new ArchetypeType element to the list + archetypeTypeSet.archetypeTypeList.add(newType); + archetypeTypeSet.archetypeTypeNames.put(newType.getTypeName(), newType); + } + } + } + } + +} // class ArchetypeTypeSetParser Property changes on: trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSetParser.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: 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...> - 2008-07-31 19:43:06
|
Revision: 4605 http://gridarta.svn.sourceforge.net/gridarta/?rev=4605&view=rev Author: akirschbaum Date: 2008-07-31 19:42:54 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Split ArchetypeAttribute into sub-classes; rewrite game object attributes dialog and archetype attribute parser accordingly. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeParser.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSet.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSetParser.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/ViewTreasurelistAL.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBitmask.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBool.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBoolSpec.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeDoubleList.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFaceName.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFixed.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFloat.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInt.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInvSpell.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInvSpellOptional.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeList.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeLong.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeMapPath.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeScriptFile.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeSpell.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeString.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeText.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTreasure.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeZSpell.java trunk/src/app/net/sf/gridarta/archtype/GuiInfo.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 17:06:56 UTC (rev 4604) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 19:42:54 UTC (rev 4605) @@ -53,6 +53,8 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; import net.sf.gridarta.XmlHelper; +import net.sf.gridarta.archtype.ArchetypeAttributeParser; +import net.sf.gridarta.archtype.ArchetypeTypeParser; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.archtype.ArchetypeTypeSetParser; import net.sf.gridarta.gameobject.anim.AnimationObjects; @@ -183,7 +185,7 @@ private final GlobalSettingsImpl globalSettings = new GlobalSettingsImpl(); /** The list of archtype-data (loaded from "types.xml"). */ - private ArchetypeTypeSet archetypeTypeSet = null; + private final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet; /** The map validators. */ private final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators; @@ -258,7 +260,7 @@ log.error("Cannot create XML parser: " + ex.getMessage()); throw new MissingResourceException("Cannot create XML parser: " + ex.getMessage(), null, null); } - archetypeTypeSet = new ArchetypeTypeSet(); + archetypeTypeSet = new ArchetypeTypeSet<GameObject, MapArchObject, Archetype>(); final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); new ArchetypeSetSpellLoader<GameObject, MapArchObject, Archetype>().load(archetypeSet, Archetype.TYPE_SPELL, gameObjectSpells); gameObjectSpells.sort(); @@ -290,8 +292,24 @@ } final MapActions mapActions = new MapActions(mainView, this, getMapManager(), exitMatcher, mapFileFilter, selectedSquareView); archetypeTypeSet.getListTable().put("event", ScriptArchUtils.getEventTypes()); - final ArchetypeTypeSetParser archetypeTypeSetParser = new ArchetypeTypeSetParser(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath(), archetypeTypeSet); + Map<String, TreasureTreeNode> specialTreasureLists; try { + final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); + specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument); + } catch (final IOException ex) { + log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); + specialTreasureLists = Collections.emptyMap(); + } catch (final SAXException ex) { + log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); + specialTreasureLists = Collections.emptyMap(); + } + treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(mainView, archetypeSet, specialTreasureLists, + new TreasureLocation(getCollectedDirectory(), IGUIConstants.TREASURES_FILE) + ); + final ArchetypeAttributeParser<GameObject, MapArchObject, Archetype> archetypeAttributeParser = new ArchetypeAttributeParser<GameObject, MapArchObject, Archetype>(Archetype.TYPE_EVENT_CONNECTOR, false, globalSettings, mapFileFilter, pythonFileFilter, faceObjects, animationObjects, numberSpells, gameObjectSpells, 0, archetypeTypeSet, treasureListTree); + final ArchetypeTypeParser<GameObject, MapArchObject, Archetype> archetypeTypeParser = new ArchetypeTypeParser<GameObject, MapArchObject, Archetype>(archetypeAttributeParser); + final ArchetypeTypeSetParser<GameObject, MapArchObject, Archetype> archetypeTypeSetParser = new ArchetypeTypeSetParser(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath(), archetypeTypeSet, archetypeTypeParser); + try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); archetypeTypeSetParser.loadTypesFromXML(filename); } catch (final FileNotFoundException ex) { @@ -351,24 +369,10 @@ objectChooser.movePickmapChooserToFront(); } } - Map<String, TreasureTreeNode> specialTreasureLists; - try { - final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); - specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument); - } catch (final IOException ex) { - log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); - specialTreasureLists = Collections.emptyMap(); - } catch (final SAXException ex) { - log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); - specialTreasureLists = Collections.emptyMap(); - } - treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(mainView, archetypeSet, specialTreasureLists, - new TreasureLocation(getCollectedDirectory(), IGUIConstants.TREASURES_FILE) - ); recentManager.initRecent(); validators = createMapValidators(); new AutoValidator<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, PREFS_VALIDATOR_AUTO_DEFAULT); - gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, this, archetypeSet, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter, Archetype.TYPE_EVENT_CONNECTOR, 0, false); + gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, this, archetypeSet, getMapManager()); } /** @@ -783,7 +787,7 @@ } /** {@inheritDoc} */ - public ArchetypeTypeSet getArchetypeTypeSet() { + public ArchetypeTypeSet<GameObject, MapArchObject, Archetype> getArchetypeTypeSet() { return archetypeTypeSet; } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 17:06:56 UTC (rev 4604) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 19:42:54 UTC (rev 4605) @@ -57,6 +57,8 @@ import net.sf.gridarta.CommonConstants; import net.sf.gridarta.MainControl; import net.sf.gridarta.XmlHelper; +import net.sf.gridarta.archtype.ArchetypeAttributeParser; +import net.sf.gridarta.archtype.ArchetypeTypeParser; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.archtype.ArchetypeTypeSetParser; import net.sf.gridarta.gameobject.anim.AnimationObjects; @@ -223,7 +225,7 @@ private final GlobalSettingsImpl globalSettings = new GlobalSettingsImpl(); /** The list of archtype-data (loaded from "types.xml"). */ - private ArchetypeTypeSet archetypeTypeSet = null; + private final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet; /** Client Control Component. */ private ProcessRunner controlClient; @@ -318,7 +320,7 @@ log.error("Cannot create XML parser: " + ex.getMessage()); throw new MissingResourceException("Cannot create XML parser: " + ex.getMessage(), null, null); } - archetypeTypeSet = new ArchetypeTypeSet(); + archetypeTypeSet = new ArchetypeTypeSet<GameObject, MapArchObject, Archetype>(); final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath()); gameObjectSpells.sort(); XMLSpellLoader.load(getConfigurationDirectory(), CommonConstants.SPELL_FILE, xmlHelper.getDocumentBuilder(), numberSpells); @@ -349,8 +351,25 @@ throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); } final MapActions mapActions = new MapActions(mainView, this, getMapManager(), exitMatcher, mapFileFilter, selectedSquareView); - final ArchetypeTypeSetParser archetypeTypeSetParser = new ArchetypeTypeSetParser(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath(), archetypeTypeSet); + Map<String, TreasureTreeNode> specialTreasureLists; try { + final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); + specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument); + } catch (final IOException ex) { + log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); + specialTreasureLists = Collections.emptyMap(); + } catch (final SAXException ex) { + log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); + specialTreasureLists = Collections.emptyMap(); + } + treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(mainView, archetypeSet, specialTreasureLists, + new TreasureLocation(getCollectedDirectory(), IGUIConstants.TREASURES_FILE), + new TreasureLocation(globalSettings.getMapDefaultFolder(), null) + ); + final ArchetypeAttributeParser<GameObject, MapArchObject, Archetype> archetypeAttributeParser = new ArchetypeAttributeParser<GameObject, MapArchObject, Archetype>(0, true, globalSettings, mapFileFilter, luaFileFilter, faceObjects, animationObjects, numberSpells, gameObjectSpells, -1, archetypeTypeSet, treasureListTree); + final ArchetypeTypeParser<GameObject, MapArchObject, Archetype> archetypeTypeParser = new ArchetypeTypeParser<GameObject, MapArchObject, Archetype>(archetypeAttributeParser); + final ArchetypeTypeSetParser<GameObject, MapArchObject, Archetype> archetypeTypeSetParser = new ArchetypeTypeSetParser<GameObject, MapArchObject, Archetype>(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath(), archetypeTypeSet, archetypeTypeParser); + try { final String filename = IOUtils.getResourceURLAsString(getConfigurationDirectory(), CommonConstants.TYPEDEF_FILE); archetypeTypeSetParser.loadTypesFromXML(filename); } catch (final FileNotFoundException ex) { @@ -423,25 +442,10 @@ objectChooser.movePickmapChooserToFront(); } } - Map<String, TreasureTreeNode> specialTreasureLists; - try { - final Document specialTreasureListsDocument = xmlHelper.getDocumentBuilder().parse(IOUtils.getResourceURLAsString(getConfigurationDirectory(), "TreasureLists.xml")); - specialTreasureLists = TreasureListsParser.parseTreasureLists(specialTreasureListsDocument); - } catch (final IOException ex) { - log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); - specialTreasureLists = Collections.emptyMap(); - } catch (final SAXException ex) { - log.warn("Cannot read TreasureLists.xml: " + ex.getMessage()); - specialTreasureLists = Collections.emptyMap(); - } - treasureListTree = new CFTreasureListTree<GameObject, MapArchObject, Archetype>(mainView, archetypeSet, specialTreasureLists, - new TreasureLocation(getCollectedDirectory(), IGUIConstants.TREASURES_FILE), - new TreasureLocation(globalSettings.getMapDefaultFolder(), null) - ); recentManager.initRecent(); validators = createMapValidators(); new AutoValidator<GameObject, MapArchObject, Archetype, CMapViewBasic>(this, PREFS_VALIDATOR_AUTO_DEFAULT); - gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, this, archetypeSet, animationObjects, getMapManager(), treasureListTree, faceObjects, mapFileFilter, 0, -1, true); + gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, this, archetypeSet, getMapManager()); } /** @@ -962,7 +966,7 @@ } /** {@inheritDoc} */ - public ArchetypeTypeSet getArchetypeTypeSet() { + public ArchetypeTypeSet<GameObject, MapArchObject, Archetype> getArchetypeTypeSet() { return archetypeTypeSet; } Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java 2008-07-31 17:06:56 UTC (rev 4604) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java 2008-07-31 19:42:54 UTC (rev 4605) @@ -19,6 +19,19 @@ package net.sf.gridarta.archtype; +import java.awt.Color; +import java.awt.Component; +import java.util.List; +import java.util.Vector; +import javax.swing.JComboBox; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.gameobjectattributesdialog.StringKeyManager; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.spells.GameObjectSpell; +import net.sf.gridarta.spells.NumberSpell; +import net.sf.gridarta.spells.Spell; +import net.sf.gridarta.spells.Spells; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -27,10 +40,13 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @todo don't use a manually linked list. */ -public final class ArchetypeAttribute { +public abstract class ArchetypeAttribute<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements Cloneable { + /** The width (columns) for input fields like textfields or JChooseBoxes. */ + public static final int TEXTFIELD_COLUMNS = 18; + /** Next CFArchAttrib in linked list. */ - private ArchetypeAttribute next; + private ArchetypeAttribute<G, A, R> next; /** Original attribute name (from the CF arches). */ @NotNull @@ -66,7 +82,7 @@ private String section; /** Create a CFArchAttrib. */ - public ArchetypeAttribute(@NotNull final String nameOld, @Nullable final String endingOld, @NotNull final String nameNew, final ArchetypeAttributeType dataType, final String text, final int inputLength, final String[] misc) { + public ArchetypeAttribute(@NotNull final String nameOld, @Nullable final String endingOld, @NotNull final String nameNew, @NotNull final ArchetypeAttributeType dataType, @NotNull final String text, final int inputLength, @Nullable final String[] misc) { this.nameOld = nameOld; this.endingOld = endingOld; this.nameNew = nameNew; @@ -86,17 +102,11 @@ section = sname; } - /** - * Get a new instance of this object with identical content. - * @return clone instance of this <code>CFArchAttrib</code> - */ - public ArchetypeAttribute getClone() { + /** {@inheritDoc} */ + @Override + public ArchetypeAttribute<G, A, R> clone() throws CloneNotSupportedException { // important: we don't create a new instance of 'misc', only a reference - final ArchetypeAttribute newattr = new ArchetypeAttribute(nameOld, endingOld, nameNew, dataType, text, inputLength, misc); - newattr.next = next; - newattr.secId = secId; - newattr.section = section; - return newattr; + return (ArchetypeAttribute<G, A, R>) super.clone(); } public int getSecId() { @@ -138,8 +148,152 @@ return inputLength; } - public void setNext(final ArchetypeAttribute cfAttr) { + public void setNext(final ArchetypeAttribute<G, A, R> cfAttr) { next = cfAttr; } + public abstract GuiInfo<G, A, R> createGui(@NotNull final String nameOld, @NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType type, @NotNull final Color background, final Component parent); + + /** + * Construct the Combo box for arrays of "list data" (this is used for + * ArchAttribType.LIST). + * @param listData List with list items and corresponding values, that means + * the types are altering: String,Integer + * @return the completed <code>JComboBox</code> + */ + protected JComboBox buildArrayBox(@NotNull final List<?> listData, @NotNull final G gameObject) { + // build the array of list-items + final String[] array = new String[(int) (listData.size() / 2.0)]; + boolean hasSelection = false; + int active = gameObject.getAttributeInt(nameOld); + for (int i = 0; i < array.length; i++) { + array[i] = (String) listData.get(i * 2 + 1); // put string to array + if (!hasSelection && (Integer) listData.get(i * 2) == active) { + hasSelection = true; // the selection is valid + active = i; // set selection to this index in the array + } + } + // if there is no valid pre-selection, show first element of list + if (!hasSelection) { + active = 0; + } + final JComboBox arraysel = new JComboBox(array); // set "content" + arraysel.setSelectedIndex(active); // set active selection + arraysel.setMaximumRowCount(10); + arraysel.setKeySelectionManager(new StringKeyManager(arraysel)); + arraysel.setName(nameNew); + return arraysel; + } + + /** + * Construct the Combo box of the available spells. + * @return the completed <code>JComboBox</code> + */ + protected JComboBox buildSpellBox(@NotNull final G gameObject, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex) { + // first parse the spell-number value from gameObject + int spnum = gameObject.getAttributeInt(nameOld); // spell number + + if (spnum < 0 || spnum >= numberSpells.size()) { + spnum = undefinedSpellIndex; + } + + // do we have "none" spell? + final int selectedIndex; + if (spnum == undefinedSpellIndex && dataType instanceof ArchetypeAttributeTypeZSpell) { + selectedIndex = 0; + } else { + // now look up the spell-number in the array of spells + selectedIndex = 1 + findSpellIndex(numberSpells, spnum); + } + + final Vector<String> content = new Vector<String>(); + content.add("<none>"); + for (final Spell spell : numberSpells) { + content.add(spell.getName()); + } + final JComboBox comboBox = new JComboBox(content); + comboBox.setSelectedIndex(selectedIndex); + comboBox.setMaximumRowCount(10); + comboBox.setKeySelectionManager(new StringKeyManager(comboBox)); + comboBox.setName(nameNew); + return comboBox; + } + + /** + * Return the spell index for a spell number. + * @param number The spell number. + * @return The spell object. + */ + private static int findSpellIndex(@NotNull final Spells<NumberSpell> numberSpells, final int number) { + for (int i = 0; i < numberSpells.size(); i++) { + if (numberSpells.getSpell(i).getNumber() == number) { + return i; + } + } + return -1; + } + + /** + * Construct the Combo box of the available spells. + * @return the completed <code>JComboBox</code> + */ + protected JComboBox buildInvSpellBox(@NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpellSpells, @NotNull final G gameObject) { + final boolean isOptionalSpell = dataType instanceof ArchetypeAttributeTypeInvSpellOptional; + final Vector<String> content = new Vector<String>(); + final int selectedIndex; + @Nullable final String title; + switch (gameObject.countInvObjects()) { + case 0: + selectedIndex = gameObjectSpellSpells.size(); + title = isOptionalSpell ? null : "<none>"; + break; + + default: + selectedIndex = gameObjectSpellSpells.size() + (isOptionalSpell ? 1 : 0); + title = "<multiple>"; + break; + + case 1: + final G invObject = gameObject.iterator().next(); + final String invObjectArchetypeName = invObject.getArchetype().getArchetypeName(); + int index = 0; + @Nullable String tmpTitle = "<customized spell>"; + for (final GameObjectSpell<G, A, R> spellObject : gameObjectSpellSpells) { + if (invObjectArchetypeName.equals(spellObject.getArchetypeName())) { + if (invObject.isDefaultGameObject()) { + tmpTitle = null; + } else { + tmpTitle = spellObject.getName() + " <customized>"; + } + break; + } + index++; + } + if (tmpTitle != null) { + selectedIndex = gameObjectSpellSpells.size() + (isOptionalSpell ? 1 : 0); + } else { + selectedIndex = index; + } + title = tmpTitle; + break; + } + + for (final Spell spell : gameObjectSpellSpells) { + content.add(spell.getName()); + } + if (isOptionalSpell) { + content.add("<none>"); + } + if (title != null) { + content.add(title); + } + + final JComboBox comboBox = new JComboBox(content); + comboBox.setSelectedIndex(selectedIndex); + comboBox.setMaximumRowCount(10); + comboBox.setKeySelectionManager(new StringKeyManager(comboBox)); + comboBox.setName(nameNew); + return comboBox; + } + } // class ArchetypeAttribute Added: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java (rev 0) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java 2008-07-31 19:42:54 UTC (rev 4605) @@ -0,0 +1,80 @@ +/* + * 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 net.sf.gridarta.archtype; + +import java.awt.Color; +import java.awt.Component; +import javax.swing.JButton; +import javax.swing.JTextField; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.anim.AnimationObjects; +import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribAnimName; +import net.sf.gridarta.gui.gameobjectattributesdialog.TreeChooseAction; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class ArchetypeAttributeAnimName<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends ArchetypeAttribute<G, A, R> { + + private final int typeNoEventConnector; + + @NotNull + private final AnimationObjects<?> animationObjects; + + private final boolean includeFaceText; + + /** + * Creates a new instance. + */ + public ArchetypeAttributeAnimName(@NotNull final String nameOld, @Nullable final String endingOld, @NotNull final String nameNew, @NotNull final ArchetypeAttributeType dataType, @NotNull final String text, final int inputLength, @Nullable final String[] misc, final int typeNoEventConnector, @NotNull final AnimationObjects<?> animationObjects, final boolean includeFaceText) { + super(nameOld, endingOld, nameNew, dataType, text, inputLength, misc); + this.typeNoEventConnector = typeNoEventConnector; + this.animationObjects = animationObjects; + this.includeFaceText = includeFaceText; + } + + /** {@inheritDoc} */ + @Override + public GuiInfo<G, A, R> createGui(@NotNull final String nameOld, @NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType type, @NotNull final Color background, final Component parent) { + final String dtxt; + if (nameOld.equalsIgnoreCase("name")) { + if (typeNoEventConnector != 0 && type.getTypeNo() == typeNoEventConnector) { + dtxt = gameObject.getObjName(); + } else + if (gameObject.getObjName() != null && gameObject.getObjName().length() > 0) { + dtxt = gameObject.getObjName(); + } else + if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { + dtxt = archetype.getObjName(); + } else { + dtxt = archetype.getArchetypeName(); + } + } else if (nameOld.equalsIgnoreCase("face")) { + dtxt = gameObject.getEffectiveFaceName(); + } else { + dtxt = gameObject.getAttributeString(nameOld); + } + final JTextField input = new JTextField(dtxt, TEXTFIELD_COLUMNS); + final JButton cLabel = new JButton(new TreeChooseAction(getNameNew() + ": ", input, animationObjects)); + return new GuiInfo<G, A, R>(new DialogAttribAnimName<G, A, R>(this, input, typeNoEventConnector, includeFaceText), cLabel, input, null, null, false); + } + +} // class ArchetypeAttributeAnimName Property changes on: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBitmask.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBitmask.java (rev 0) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBitmask.java 2008-07-31 19:42:54 UTC (rev 4605) @@ -0,0 +1,77 @@ +/* + * 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 net.sf.gridarta.archtype; + +import java.awt.Color; +import java.awt.Component; +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JTextArea; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribBitmask; +import net.sf.gridarta.gui.gameobjectattributesdialog.MaskChangeAL; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class ArchetypeAttributeBitmask<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends ArchetypeAttribute<G, A, R> { + + @NotNull + private final ArchetypeTypeSet<G, A, R> archetypeTypeSet; + + /** + * Creates a new instance. + */ + public ArchetypeAttributeBitmask(@NotNull final String nameOld, @Nullable final String endingOld, @NotNull final String nameNew, @NotNull final ArchetypeAttributeType dataType, @NotNull final String text, final int inputLength, @Nullable final String[] misc, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet) { + super(nameOld, endingOld, nameNew, dataType, text, inputLength, misc); + this.archetypeTypeSet = archetypeTypeSet; + } + + /** {@inheritDoc} */ + @Override + public GuiInfo<G, A, R> createGui(@NotNull final String nameOld, @NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType type, @NotNull final Color background, final Component parent) { + final JTextArea input = new JTextArea(); + final DialogAttribBitmask<G, A, R> tmpAttr = new DialogAttribBitmask<G, A, R>(this, input); + final JTextArea cComp; + final JButton cLabel; + final JLabel cRow; + if (getMisc() != null && archetypeTypeSet.getBitmaskTable().containsKey(getMisc()[0])) { + // fetch the bitmask data, then build the attribute panel + final CAttribBitmask bitmask = archetypeTypeSet.getBitmaskTable().get(getMisc()[0]); + tmpAttr.setBitmask(bitmask); + cLabel = new JButton(new MaskChangeAL(getNameNew() + ":", tmpAttr)); + input.setBackground(background); + input.setEditable(false); + input.setBorder(BorderFactory.createLineBorder(Color.gray)); + input.setText(bitmask.getText(tmpAttr.getValue())); + cComp = input; + tmpAttr.setEncodedValue(gameObject.getAttributeString(nameOld)); + cRow = null; + } else { + cLabel = null; + cComp = null; + cRow = new JLabel("Error: Undefined Bitmask"); + } + return new GuiInfo<G, A, R>(tmpAttr, cLabel, cComp, cRow, null, false); + } + +} // class ArchetypeAttributeBitmask Property changes on: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBitmask.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBool.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBool.java (rev 0) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBool.java 2008-07-31 19:42:54 UTC (rev 4605) @@ -0,0 +1,48 @@ +/* + * 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 net.sf.gridarta.archtype; + +import java.awt.Color; +import java.awt.Component; +import javax.swing.JCheckBox; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribBool; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class ArchetypeAttributeBool<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends ArchetypeAttribute<G, A, R> { + + /** + * Creates a new instance. + */ + public ArchetypeAttributeBool(@NotNull final String nameOld, @Nullable final String endingOld, @NotNull final String nameNew, @NotNull final ArchetypeAttributeType dataType, @NotNull final String text, final int inputLength, @Nullable final String[] misc) { + super(nameOld, endingOld, nameNew, dataType, text, inputLength, misc); + } + + /** {@inheritDoc} */ + @Override + public GuiInfo<G, A, R> createGui(@NotNull final String nameOld, @NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType type, @NotNull final Color background, final Component parent) { + final JCheckBox input = new JCheckBox(getNameNew(), gameObject.getAttributeInt(nameOld) == 1); + return new GuiInfo<G, A, R>(new DialogAttribBool<G, A, R>(this, input), null, null, input, null, false); + } + +} // class ArchetypeAttributeBool Property changes on: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBool.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBoolSpec.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBoolSpec.java (rev 0) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBoolSpec.java 2008-07-31 19:42:54 UTC (rev 4605) @@ -0,0 +1,55 @@ +/* + * 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 net.sf.gridarta.archtype; + +import java.awt.Color; +import java.awt.Component; +import javax.swing.JCheckBox; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribBoolSpec; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class ArchetypeAttributeBoolSpec<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends ArchetypeAttribute<G, A, R> { + + /** + * Creates a new instance. + */ + public ArchetypeAttributeBoolSpec(@NotNull final String nameOld, @Nullable final String endingOld, @NotNull final String nameNew, @NotNull final ArchetypeAttributeType dataType, @NotNull final String text, final int inputLength, @Nullable final String[] misc) { + super(nameOld, endingOld, nameNew, dataType, text, inputLength, misc); + } + + /** {@inheritDoc} */ + @Override + public GuiInfo<G, A, R> createGui(@NotNull final String nameOld, @NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType type, @NotNull final Color background, final Component parent) { + final JCheckBox input; + final String trueVal = getMisc()[0]; + if (trueVal.equals("0")) { + final String attrString = gameObject.getAttributeString(nameOld); + input = new JCheckBox(getNameNew(), attrString.length() == 0 || attrString.equals("0")); + } else { + input = new JCheckBox(getNameNew(), gameObject.getAttributeString(nameOld).equals(trueVal)); + } + return new GuiInfo<G, A, R>(new DialogAttribBoolSpec<G, A, R>(this, input), null, input, null, null, false); + } + +} // class ArchetypeAttributeBoolSpec Property changes on: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBoolSpec.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeDoubleList.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeDoubleList.java (rev 0) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeDoubleList.java 2008-07-31 19:42:54 UTC (rev 4605) @@ -0,0 +1,84 @@ +/* + * 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 net.sf.gridarta.archtype; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.util.List; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import net.sf.gridarta.CommonConstants; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribDoubleList; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class ArchetypeAttributeDoubleList<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends ArchetypeAttribute<G, A, R> { + + private final ArchetypeTypeSet<G, A, R> archetypeTypeSet; + + /** + * Creates a new instance. + */ + public ArchetypeAttributeDoubleList(@NotNull final String nameOld, @Nullable final String endingOld, @NotNull final String nameNew, @NotNull final ArchetypeAttributeType dataType, @NotNull final String text, final int inputLength, @Nullable final String[] misc, final ArchetypeTypeSet<G, A, R> archetypeTypeSet) { + super(nameOld, endingOld, nameNew, dataType, text, inputLength, misc); + this.archetypeTypeSet = archetypeTypeSet; + } + + /** {@inheritDoc} */ + @Override + public GuiInfo<G, A, R> createGui(@NotNull final String nameOld, @NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType type, @NotNull final Color background, final Component parent) { + final JPanel compo = new JPanel(new BorderLayout()); + final JLabel cLabel = new JLabel(getNameNew() + ": "); + cLabel.setForeground(CommonConstants.INT_COLOR); + // create ComboBox with parsed selection + final JComboBox[] inputs = new JComboBox[2]; + final JComponent cComp; + if (getMisc() != null && archetypeTypeSet.getListTable().containsKey(getMisc()[0]) && archetypeTypeSet.getListTable().containsKey(getMisc()[1])) { + // Hack to set preselected if available + final int active = gameObject.getAttributeInt(nameOld); + final int[] activepart = {active & 0x0F, active & 0xF0}; + // build the lists from vector data + for (int j = 0; j < 2; j++) { + final List<?> listData = archetypeTypeSet.getListTable().get(getMisc()[j]); + inputs[j] = buildArrayBox(listData, gameObject); + for (int k = 0; (double) k < listData.size() / 2.0; k++) { + if ((Integer) listData.get(k * 2) == activepart[j]) { + inputs[j].setSelectedIndex(k); // set active selection + break; + } + } + } + compo.add(inputs[0], BorderLayout.NORTH); + compo.add(inputs[1], BorderLayout.SOUTH); + cComp = compo; + } else { + // error: list data is missing or corrupt + cComp = new JLabel("Error: Undefined List"); + } + return new GuiInfo<G, A, R>(new DialogAttribDoubleList<G, A, R>(this, inputs, archetypeTypeSet), cLabel, cComp, null, null, false); + } + +} // class ArchetypeAttributeDoubleList Property changes on: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeDoubleList.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFaceName.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFaceName.java (rev 0) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFaceName.java 2008-07-31 19:42:54 UTC (rev 4605) @@ -0,0 +1,80 @@ +/* + * 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 net.sf.gridarta.archtype; + +import java.awt.Color; +import java.awt.Component; +import javax.swing.JButton; +import javax.swing.JTextField; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.face.FaceObjects; +import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribFaceName; +import net.sf.gridarta.gui.gameobjectattributesdialog.TreeChooseAction; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class ArchetypeAttributeFaceName<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends ArchetypeAttribute<G, A, R> { + + private final int typeNoEventConnector; + + @NotNull + private final FaceObjects faceObjects; + + private final boolean includeFaceText; + + /** + * Creates a new instance. + */ + public ArchetypeAttributeFaceName(@NotNull final String nameOld, @Nullable final String endingOld, @NotNull final String nameNew, @NotNull final ArchetypeAttributeType dataType, @NotNull final String text, final int inputLength, @Nullable final String[] misc, final int typeNoEventConnector, @NotNull final FaceObjects faceObjects, final boolean includeFaceText) { + super(nameOld, endingOld, nameNew, dataType, text, inputLength, misc); + this.typeNoEventConnector = typeNoEventConnector; + this.faceObjects = faceObjects; + this.includeFaceText = includeFaceText; + } + + /** {@inheritDoc} */ + @Override + public GuiInfo<G, A, R> createGui(@NotNull final String nameOld, @NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType type, @NotNull final Color background, final Component parent) { + final String dtxt; + if (nameOld.equalsIgnoreCase("name")) { + if (typeNoEventConnector != 0 && type.getTypeNo() == typeNoEventConnector) { + dtxt = gameObject.getObjName(); + } else + if (gameObject.getObjName() != null && gameObject.getObjName().length() > 0) { + dtxt = gameObject.getObjName(); + } else + if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { + dtxt = archetype.getObjName(); + } else { + dtxt = archetype.getArchetypeName(); + } + } else if (nameOld.equalsIgnoreCase("face")) { + dtxt = gameObject.getEffectiveFaceName(); + } else { + dtxt = gameObject.getAttributeString(nameOld); + } + final JTextField input = new JTextField(dtxt, TEXTFIELD_COLUMNS); + final JButton cLabel = new JButton(new TreeChooseAction(getNameNew() + ": ", input, faceObjects)); + return new GuiInfo<G, A, R>(new DialogAttribFaceName<G, A, R>(this, input, typeNoEventConnector, includeFaceText), cLabel, input, null, null, false); + } + +} // class ArchetypeAttributeFaceName Property changes on: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFaceName.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFixed.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFixed.java (rev 0) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFixed.java 2008-07-31 19:42:54 UTC (rev 4605) @@ -0,0 +1,45 @@ +/* + * 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 net.sf.gridarta.archtype; + +import java.awt.Color; +import java.awt.Component; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class ArchetypeAttributeFixed<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends ArchetypeAttribute<G, A, R> { + + /** + * Creates a new instance. + */ + public ArchetypeAttributeFixed(@NotNull final String nameOld, @Nullable final String endingOld, @NotNull final String nameNew, @NotNull final ArchetypeAttributeType dataType, @NotNull final String text, final int inputLength, @Nullable final String[] misc) { + super(nameOld, endingOld, nameNew, dataType, text, inputLength, misc); + } + + /** {@inheritDoc} */ + @Override + public GuiInfo<G, A, R> createGui(@NotNull final String nameOld, @NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType type, @NotNull final Color background, final Component parent) { + throw new AssertionError(); + } + +} // class ArchetypeAttributeFixed Property changes on: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFixed.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFloat.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFloat.java (rev 0) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFloat.java 2008-07-31 19:42:54 UTC (rev 4605) @@ -0,0 +1,64 @@ +/* + * 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 net.sf.gridarta.archtype; + +import java.awt.Color; +import java.awt.Component; +import java.text.NumberFormat; +import javax.swing.JFormattedTextField; +import javax.swing.JLabel; +import javax.swing.text.DefaultFormatterFactory; +import javax.swing.text.NumberFormatter; +import net.sf.gridarta.CommonConstants; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribFloat; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class ArchetypeAttributeFloat<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends ArchetypeAttribute<G, A, R> { + + /** + * Creates a new instance. + */ + public ArchetypeAttributeFloat(@NotNull final String nameOld, @Nullable final String endingOld, @NotNull final String nameNew, @NotNull final ArchetypeAttributeType dataType, @NotNull final String text, final int inputLength, @Nullable final String[] misc) { + super(nameOld, endingOld, nameNew, dataType, text, inputLength, misc); + } + + /** {@inheritDoc} */ + @Override + public GuiInfo<G, A, R> createGui(@NotNull final String nameOld, @NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType type, @NotNull final Color background, final Component parent) { + final JLabel cLabel = new JLabel(getNameNew() + ": "); + cLabel.setForeground(CommonConstants.FLOAT_COLOR); + final int fieldLength = getInputLength() == 0 ? TEXTFIELD_COLUMNS : getInputLength(); + final NumberFormat format = NumberFormat.getInstance(); + format.setMaximumFractionDigits(10); + format.setGroupingUsed(false); + final NumberFormatter formatter = new NumberFormatter(format); + final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); + // parse value from gameObject + final Number value = gameObject.getAttributeDouble(nameOld); + final JFormattedTextField input = new JFormattedTextField(factory, value); + input.setColumns(fieldLength); + return new GuiInfo<G, A, R>(new DialogAttribFloat<G, A, R>(this, input), cLabel, input, null, null, false); + } + +} // class ArchetypeAttributeBoolSpec Property changes on: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFloat.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInt.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInt.java (rev 0) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInt.java 2008-07-31 19:42:54 UTC (rev 4605) @@ -0,0 +1,63 @@ +/* + * 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 net.sf.gridarta.archtype; + +import java.awt.Color; +import java.awt.Component; +import java.text.NumberFormat; +import javax.swing.JFormattedTextField; +import javax.swing.JLabel; +import javax.swing.text.DefaultFormatterFactory; +import javax.swing.text.NumberFormatter; +import net.sf.gridarta.CommonConstants; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribInt; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class ArchetypeAttributeInt<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends ArchetypeAttribute<G, A, R> { + + /** + * Creates a new instance. + */ + public ArchetypeAttributeInt(@NotNull final String nameOld, @Nullable final String endingOld, @NotNull final String nameNew, @NotNull final ArchetypeAttributeType dataType, @NotNull final String text, final int inputLength, @Nullable final String[] misc) { + super(nameOld, endingOld, nameNew, dataType, text, inputLength, misc); + } + + /** {@inheritDoc} */ + @Override + public GuiInfo<G, A, R> createGui(@NotNull final String nameOld, @NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType type, @NotNull final Color background, final Component parent) { + final JLabel cLabel = new JLabel(getNameNew() + ": "); + cLabel.setForeground(CommonConstants.INT_COLOR); + final int fieldLength = getInputLength() == 0 ? TEXTFIELD_COLUMNS : getInputLength(); + final NumberFormat format = NumberFormat.getIntegerInstance(); + format.setGroupingUsed(false); + final NumberFormatter formatter = new NumberFormatter(format); + final DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); + // parse value from gameObject + final Number value = gameObject.getAttributeInt(nameOld); + final JFormattedTextField input = new JFormattedTextField(factory, value); + input.setColumns(fieldLength); + return new GuiInfo<G, A, R>(new DialogAttribInt<G, A, R>(this, input), cLabel, input, null, null, false); + } + +} // class ArchetypeAttributeInt Property changes on: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInt.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInvSpell.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInvSpell.java (rev 0) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInvSpell.java 2008-07-31 19:42:54 UTC (rev 4605) @@ -0,0 +1,59 @@ +/* + * 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... [truncated message content] |
From: <aki...@us...> - 2008-07-31 20:46:40
|
Revision: 4613 http://gridarta.svn.sourceforge.net/gridarta/?rev=4613&view=rev Author: akirschbaum Date: 2008-07-31 20:46:44 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Remove MainControl.getAnimationObjects(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 20:35:27 UTC (rev 4612) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 20:46:44 UTC (rev 4613) @@ -442,14 +442,6 @@ return mapValidators; } - /** - * Get the Animation Objects. - * @return animationObjects - */ - public AnimationObjects<AnimationObject> getAnimationObjects() { - return animationObjects; - } - /** {@inheritDoc} */ public void validateMap(final MapModel<GameObject, MapArchObject, Archetype> map) { final ErrorCollector<GameObject, MapArchObject, Archetype> errorCollector = new DefaultErrorCollector<GameObject, MapArchObject, Archetype>(); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 20:35:27 UTC (rev 4612) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 20:46:44 UTC (rev 4613) @@ -281,6 +281,7 @@ CMainControlInstance.instance = this; globalSettings.readGlobalSettings(); animationObjects = new daieditor.gameobject.anim.AnimationObjects(); + GameObject.setAnimationObjects(animationObjects); archetypeSet = new ArchetypeSet(this, getEditTypes(), animationObjects, faceObjects); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, getEditTypes(), mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), archetypeSet); @@ -551,14 +552,6 @@ getMapManager().refreshCurrentMap(); } - /** - * Get the Animation Objects. - * @return animationObjects - */ - public AnimationObjects<AnimationObject> getAnimationObjects() { - return animationObjects; - } - /** Control the server. */ @ActionMethod public void controlServer() { Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-07-31 20:35:27 UTC (rev 4612) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-07-31 20:46:44 UTC (rev 4613) @@ -52,6 +52,9 @@ /** The serial version UID. */ private static final long serialVersionUID = 1; + @Nullable + private static AnimationObjects<AnimationObject> animationObjects = null; + /** * Face name, can be from animation or face. This is determined by taking * {@link #faceName} or {@link #animName} and takes {@link #direction} into @@ -89,6 +92,10 @@ /** The transparent face. */ private ImageIcon transFace; + public static void setAnimationObjects(@Nullable final AnimationObjects<AnimationObject> animationObjects) { + GameObject.animationObjects = animationObjects; + } + /** {@inheritDoc} */ public int getMultiShapeID() { return multi != null ? multi.getMultiShapeID() : 0; @@ -204,18 +211,21 @@ @Nullable String effectiveFaceObjName; if (effectiveAnimName != null) { // we have a animation - get the frame picture - final AnimationObjects<AnimationObject> animationObjects = CMainControlInstance.getInstance().getAnimationObjects(); - final AnimationObject animationObject = animationObjects.get(effectiveAnimName); - if (animationObject != null) { - noface = false; - //faceObjName = animationObjects.getAnimFrame(animnr, getDirection()); - try { - effectiveFaceObjName = animationObject.getFirstFrame(getDirection()); - } catch (final IndexOutOfBoundsException ex) { + if (animationObjects == null) { + effectiveFaceObjName = null; + } else { + final AnimationObject animationObject = animationObjects.get(effectiveAnimName); + if (animationObject != null) { + noface = false; + //faceObjName = animationObjects.getAnimFrame(animnr, getDirection()); + try { + effectiveFaceObjName = animationObject.getFirstFrame(getDirection()); + } catch (final IndexOutOfBoundsException ex) { + effectiveFaceObjName = null; + } + } else { effectiveFaceObjName = null; } - } else { - effectiveFaceObjName = null; } if (effectiveFaceObjName == null) { faceObjSource = FaceSource.FACE_NOT_FOUND; Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-31 20:35:27 UTC (rev 4612) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-31 20:46:44 UTC (rev 4613) @@ -26,7 +26,6 @@ import net.sf.gridarta.gameobject.ArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gameobject.anim.AnimationObjects; import net.sf.gridarta.gui.MainActions; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.ObjectChooser; @@ -97,12 +96,6 @@ ArchetypeParser<G, A, R> getArchetypeParser(); /** - * Get the AnimationObjects for the available Animations. - * @return AnimationObjects - */ - AnimationObjects<?> getAnimationObjects(); - - /** * Returns the MainView of this MainControl. * @return The MainView of this MainControl. */ Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-07-31 20:35:27 UTC (rev 4612) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-07-31 20:46:44 UTC (rev 4613) @@ -437,11 +437,6 @@ } /** {@inheritDoc} */ - public AnimationObjects<?> getAnimationObjects() { - throw new AssertionError(); - } - - /** {@inheritDoc} */ public MainView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> getMainView() { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-31 20:53:53
|
Revision: 4614 http://gridarta.svn.sourceforge.net/gridarta/?rev=4614&view=rev Author: akirschbaum Date: 2008-07-31 20:54:00 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Remove calls to CMainControlInstance.getInstance() and MainControl.getArchetypeSet(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 20:46:44 UTC (rev 4613) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 20:54:00 UTC (rev 4614) @@ -227,6 +227,7 @@ globalSettings.readGlobalSettings(); animationObjects = new cfeditor.gameobject.anim.AnimationObjects(); archetypeSet = new ArchetypeSet(this, getEditTypes(), animationObjects, faceObjects, globalSettings.getImageSet()); + GameObject.setArchetypeSet(archetypeSet); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, getEditTypes(), mapTileListBottom, null, archetypeSet); final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView = selectedSquareControl.getSelectedSquareView(); Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-07-31 20:46:44 UTC (rev 4613) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-07-31 20:54:00 UTC (rev 4614) @@ -19,11 +19,11 @@ package cfeditor.gameobject; -import cfeditor.CMainControlInstance; import cfeditor.gameobject.scripts.ScriptArchData; import cfeditor.map.MapArchObject; import javax.swing.ImageIcon; import javax.swing.JList; +import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; import net.sf.gridarta.gui.GameObjectAttributesPanel; import net.sf.gridarta.utils.StringUtils; @@ -64,6 +64,13 @@ /** The normal face. */ private ImageIcon normalFace; + @Nullable + private static ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet = null; + + public static void setArchetypeSet(@Nullable final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + GameObject.archetypeSet = archetypeSet; + } + /** {@inheritDoc} */ @Override public void propagateElevation(@NotNull final GameObject gameObject) { @@ -109,8 +116,7 @@ /** {@inheritDoc} */ public void setObjectFace() { - if (!isArchetype()) { - final ArchetypeSet archetypeSet = CMainControlInstance.getInstance().getArchetypeSet(); + if (!isArchetype() && archetypeSet != null) { normalFace = archetypeSet.getFace(this); } } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 20:46:44 UTC (rev 4613) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 20:54:00 UTC (rev 4614) @@ -283,6 +283,7 @@ animationObjects = new daieditor.gameobject.anim.AnimationObjects(); GameObject.setAnimationObjects(animationObjects); archetypeSet = new ArchetypeSet(this, getEditTypes(), animationObjects, faceObjects); + GameObject.setArchetypeSet(archetypeSet); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, getEditTypes(), mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), archetypeSet); final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView = selectedSquareControl.getSelectedSquareView(); Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-07-31 20:46:44 UTC (rev 4613) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-07-31 20:54:00 UTC (rev 4614) @@ -19,7 +19,6 @@ package daieditor.gameobject; -import daieditor.CMainControlInstance; import daieditor.gameobject.anim.AnimationObject; import daieditor.gameobject.scripts.ScriptArchData; import daieditor.map.MapArchObject; @@ -96,6 +95,13 @@ GameObject.animationObjects = animationObjects; } + @Nullable + private static ArchetypeSet archetypeSet = null; + + public static void setArchetypeSet(@Nullable final ArchetypeSet archetypeSet) { + GameObject.archetypeSet = archetypeSet; + } + /** {@inheritDoc} */ public int getMultiShapeID() { return multi != null ? multi.getMultiShapeID() : 0; @@ -253,7 +259,6 @@ faceObjSource = FaceSource.FACE_NOT_FOUND; } if (!isArchetype()) { - final ArchetypeSet archetypeSet = CMainControlInstance.getInstance().getArchetypeSet(); normalFace = archetypeSet.getFace(this); transFace = archetypeSet.getTrans(this); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-31 21:01:44
|
Revision: 4615 http://gridarta.svn.sourceforge.net/gridarta/?rev=4615&view=rev Author: akirschbaum Date: 2008-07-31 21:01:52 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Remove calls to CMainControlInstance.getInstance() and MainControl.getArchetypeSet(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 20:54:00 UTC (rev 4614) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 21:01:52 UTC (rev 4615) @@ -27,6 +27,7 @@ import cfeditor.gameobject.anim.AnimationObject; import cfeditor.gameobject.face.FaceObjects; import cfeditor.gameobject.scripts.ScriptArchUtils; +import cfeditor.gameobject.scripts.ScriptedEvent; import cfeditor.gui.GameObjectAttributesPanel; import cfeditor.gui.map.CMapViewBasic; import cfeditor.gui.prefs.GUIPrefs; @@ -228,6 +229,7 @@ animationObjects = new cfeditor.gameobject.anim.AnimationObjects(); archetypeSet = new ArchetypeSet(this, getEditTypes(), animationObjects, faceObjects, globalSettings.getImageSet()); GameObject.setArchetypeSet(archetypeSet); + ScriptedEvent.setArchetypeSet(archetypeSet); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, getEditTypes(), mapTileListBottom, null, archetypeSet); final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView = selectedSquareControl.getSelectedSquareView(); Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-07-31 20:54:00 UTC (rev 4614) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-07-31 21:01:52 UTC (rev 4615) @@ -19,15 +19,17 @@ package cfeditor.gameobject.scripts; -import cfeditor.CMainControlInstance; import cfeditor.gameobject.Archetype; import cfeditor.gameobject.GameObject; +import cfeditor.map.MapArchObject; +import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeNameException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeTypeException; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Class which stores information about one scripted event. @@ -38,6 +40,9 @@ /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(ScriptedEvent.class); + @Nullable + private static ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet; + /** The underlying game object that represents the event. */ private final GameObject event; @@ -63,6 +68,10 @@ setEventData(pluginName, scriptPath, options); } + public static void setArchetypeSet(@Nullable final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + ScriptedEvent.archetypeSet = archetypeSet; + } + /** * Validate this event object: Check if there is sufficient data. * @return true if this object is valid, otherwise false @@ -172,7 +181,10 @@ if (eventArchetypeName == null) { throw new UndefinedEventArchetypeTypeException(eventType); } - final Archetype eventArchetype = CMainControlInstance.getInstance().getArchetypeSet().getArchetype(eventArchetypeName); + if (archetypeSet == null) { + throw new UndefinedEventArchetypeNameException(eventArchetypeName); + } + final Archetype eventArchetype = archetypeSet.getArchetype(eventArchetypeName); if (eventArchetype == null) { throw new UndefinedEventArchetypeNameException(eventArchetypeName); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 20:54:00 UTC (rev 4614) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 21:01:52 UTC (rev 4615) @@ -26,6 +26,7 @@ import daieditor.gameobject.anim.AnimationObject; import daieditor.gameobject.face.FaceObjects; import daieditor.gameobject.scripts.ScriptArchUtils; +import daieditor.gameobject.scripts.ScriptedEvent; import daieditor.gui.GameObjectAttributesPanel; import daieditor.gui.map.CMapViewBasic; import daieditor.gui.prefs.AppPrefs; @@ -284,6 +285,7 @@ GameObject.setAnimationObjects(animationObjects); archetypeSet = new ArchetypeSet(this, getEditTypes(), animationObjects, faceObjects); GameObject.setArchetypeSet(archetypeSet); + ScriptedEvent.setArchetypeSet(archetypeSet); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); final SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareControl = new SelectedSquareControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(ACTION_FACTORY, this, getEditTypes(), mapTileListBottom, GUIUtils.getSysIcon(IGUIConstants.TILE_NORTH), archetypeSet); final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView = selectedSquareControl.getSelectedSquareView(); Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-07-31 20:54:00 UTC (rev 4614) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-07-31 21:01:52 UTC (rev 4615) @@ -19,14 +19,16 @@ package daieditor.gameobject.scripts; -import daieditor.CMainControlInstance; import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; +import daieditor.map.MapArchObject; +import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeNameException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeTypeException; import org.apache.log4j.Logger; +import org.jetbrains.annotations.Nullable; /** * Class which stores information about one scripted event. @@ -37,6 +39,9 @@ /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(ScriptedEvent.class); + @Nullable + private static ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet; + /** The underlying game object that represents the event. */ private final GameObject event; @@ -62,6 +67,10 @@ setEventData(pluginName, scriptPath, options); } + public static void setArchetypeSet(@Nullable final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + ScriptedEvent.archetypeSet = archetypeSet; + } + /** * Validate this event object: Check if there is sufficient data. * @return true if this object is valid, otherwise false @@ -168,7 +177,10 @@ if (eventArchetypeName == null) { throw new UndefinedEventArchetypeTypeException(eventType); } - final Archetype eventArchetype = CMainControlInstance.getInstance().getArchetypeSet().getArchetype(eventArchetypeName); + if (archetypeSet == null) { + throw new UndefinedEventArchetypeNameException(eventArchetypeName); + } + final Archetype eventArchetype = archetypeSet.getArchetype(eventArchetypeName); if (eventArchetype == null) { throw new UndefinedEventArchetypeNameException(eventArchetypeName); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-31 21:06:07
|
Revision: 4617 http://gridarta.svn.sourceforge.net/gridarta/?rev=4617&view=rev Author: akirschbaum Date: 2008-07-31 21:06:13 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Remove MainControl.getArchetypeSet(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 21:04:27 UTC (rev 4616) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 21:06:13 UTC (rev 4617) @@ -497,11 +497,6 @@ return mainView; } - /** {@inheritDoc} */ - public ArchetypeSet getArchetypeSet() { - return archetypeSet; - } - /** Invoked when user wants to begin editing a new (empty) map. */ public void createNew() { newLevelWanted(null); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 21:04:27 UTC (rev 4616) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 21:06:13 UTC (rev 4617) @@ -678,11 +678,6 @@ return mainView; } - /** {@inheritDoc} */ - public ArchetypeSet getArchetypeSet() { - return archetypeSet; - } - /** Invoked when user wants to begin editing a new (empty) map. */ public void createNew() { newLevelWanted(null); Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-31 21:04:27 UTC (rev 4616) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-31 21:06:13 UTC (rev 4617) @@ -24,7 +24,6 @@ import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeParser; -import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.MainActions; import net.sf.gridarta.gui.MainView; @@ -84,12 +83,6 @@ String getScriptSuffix(); /** - * Get the ArchetypeSet for the available Archetypes. - * @return ArchetypeSet - */ - ArchetypeSet<G, A, R> getArchetypeSet(); - - /** * Get the ArchetypeParser that parsers Archetypes. * @return ArchetypeParser */ Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-07-31 21:04:27 UTC (rev 4616) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-07-31 21:06:13 UTC (rev 4617) @@ -427,11 +427,6 @@ } /** {@inheritDoc} */ - public ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> getArchetypeSet() { - throw new AssertionError(); - } - - /** {@inheritDoc} */ public ArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype> getArchetypeParser() { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-31 21:07:31
|
Revision: 4618 http://gridarta.svn.sourceforge.net/gridarta/?rev=4618&view=rev Author: akirschbaum Date: 2008-07-31 21:07:38 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Remove MainControl.getArchetypeParser(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 21:06:13 UTC (rev 4617) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 21:07:38 UTC (rev 4618) @@ -801,14 +801,6 @@ return mainView == null ? null : mainView.getCurrentMapView(); } - /** - * Get the ArchetypeParser. - * @return ArchetypeParser - */ - public ArchetypeParser getArchetypeParser() { - return archetypeParser; - } - /** {@inheritDoc} */ @NotNull public String getConfigurationDirectory() { Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 21:06:13 UTC (rev 4617) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 21:07:38 UTC (rev 4618) @@ -981,14 +981,6 @@ return mainView == null ? null : mainView.getCurrentMapView(); } - /** - * Get the ArchetypeParser. - * @return ArchetypeParser - */ - public ArchetypeParser getArchetypeParser() { - return archetypeParser; - } - /** {@inheritDoc} */ @NotNull public String getConfigurationDirectory() { Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-31 21:06:13 UTC (rev 4617) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-31 21:07:38 UTC (rev 4618) @@ -23,7 +23,6 @@ import javax.swing.filechooser.FileFilter; import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.ArchetypeParser; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.MainActions; import net.sf.gridarta.gui.MainView; @@ -83,12 +82,6 @@ String getScriptSuffix(); /** - * Get the ArchetypeParser that parsers Archetypes. - * @return ArchetypeParser - */ - ArchetypeParser<G, A, R> getArchetypeParser(); - - /** * Returns the MainView of this MainControl. * @return The MainView of this MainControl. */ Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-07-31 21:06:13 UTC (rev 4617) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-07-31 21:07:38 UTC (rev 4618) @@ -427,11 +427,6 @@ } /** {@inheritDoc} */ - public ArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype> getArchetypeParser() { - throw new AssertionError(); - } - - /** {@inheritDoc} */ public MainView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> getMainView() { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-31 21:13:11
|
Revision: 4619 http://gridarta.svn.sourceforge.net/gridarta/?rev=4619&view=rev Author: akirschbaum Date: 2008-07-31 21:13:19 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Remove calls to Abstract[CMainControl.getInstance() and MainControl.getScriptFileFilter(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 21:07:38 UTC (rev 4618) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 21:13:19 UTC (rev 4619) @@ -319,7 +319,7 @@ log.error("Cannot read " + CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage()); } - AbstractScriptArchEditor.initEventTypeBoxes(".py", "Python", ScriptArchUtils.createEventTypeBox()); + AbstractScriptArchEditor.initEventTypeBoxes(".py", "Python", ScriptArchUtils.createEventTypeBox(), pythonFileFilter); // Initialize the main view final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager(), Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 21:07:38 UTC (rev 4618) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 21:13:19 UTC (rev 4619) @@ -380,7 +380,7 @@ log.error("Cannot read " + CommonConstants.TYPEDEF_FILE + ": " + ex.getMessage()); } - AbstractScriptArchEditor.initEventTypeBoxes(".lua", "Lua", ScriptArchUtils.createEventTypeBox()); + AbstractScriptArchEditor.initEventTypeBoxes(".lua", "Lua", ScriptArchUtils.createEventTypeBox(), luaFileFilter); // Initialize the main view final LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic> lockedItemsControl = new LockedItemsControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(getMapManager(), Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER); Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-07-31 21:07:38 UTC (rev 4618) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptArchEditor.java 2008-07-31 21:13:19 UTC (rev 4619) @@ -36,9 +36,11 @@ import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.WindowConstants; +import javax.swing.filechooser.FileFilter; import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.gameobject.GameObject; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; public abstract class AbstractScriptArchEditor { @@ -50,6 +52,8 @@ protected static JComboBox eventTypeBox; + private static FileFilter scriptFileFilter; + protected static JComboBox pluginNameBox; // popup frame for new scripts: @@ -74,13 +78,14 @@ * @param eventTypeBox the <code>JComboBox</code> containing all event * types */ - public static synchronized void initEventTypeBoxes(final String ending, final String name, final JComboBox eventTypeBox) { + public static synchronized void initEventTypeBoxes(final String ending, final String name, final JComboBox eventTypeBox, @NotNull final FileFilter scriptFileFilter) { scriptEnding = ending; pluginNameBox = new JComboBox(new String[] {name}); pluginNameBox.setSelectedIndex(0); AbstractScriptArchEditor.eventTypeBox = eventTypeBox; + AbstractScriptArchEditor.scriptFileFilter = scriptFileFilter; } /** @@ -144,7 +149,7 @@ fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setCurrentDirectory(home); fileChooser.setMultiSelectionEnabled(false); - fileChooser.setFileFilter(AbstractMainControl.getInstance().getScriptFileFilter()); + fileChooser.setFileFilter(scriptFileFilter); if (fileChooser.showOpenDialog(newScriptFrame) == JFileChooser.APPROVE_OPTION) { // user has selected a file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-31 21:27:24
|
Revision: 4623 http://gridarta.svn.sourceforge.net/gridarta/?rev=4623&view=rev Author: akirschbaum Date: 2008-07-31 21:27:32 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Remove calls to MainControl.getScriptFileFilter(), MainControl.getScriptSuffix(), and MainControl.getMainView(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControlInstance.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 21:17:53 UTC (rev 4622) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 21:27:32 UTC (rev 4623) @@ -253,7 +253,7 @@ updaterManager.startup(); // initialize the script-editor pad - ScriptEditControlInstance.init(this, new File(globalSettings.getMapDefaultFolder())); + ScriptEditControlInstance.init(pythonFileFilter, ".py", mainView, new File(globalSettings.getMapDefaultFolder())); // load the list with archtype-data from "types.xml" final XmlHelper xmlHelper; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 21:17:53 UTC (rev 4622) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 21:27:32 UTC (rev 4623) @@ -314,7 +314,7 @@ MultiPositionData.init(getConfigurationDirectory()); // initialize the script-editor pad - ScriptEditControlInstance.init(this, new File(globalSettings.getMapDefaultFolder())); + ScriptEditControlInstance.init(luaFileFilter, ".lua", mainView, new File(globalSettings.getMapDefaultFolder())); // load the list with archtype-data from "types.xml" final XmlHelper xmlHelper; Modified: trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java 2008-07-31 21:17:53 UTC (rev 4622) +++ trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java 2008-07-31 21:27:32 UTC (rev 4623) @@ -23,6 +23,7 @@ package net.sf.gridarta.textedit.scripteditor; +import java.awt.Frame; import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -30,10 +31,11 @@ import java.util.List; import javax.swing.JFileChooser; import javax.swing.JOptionPane; -import net.sf.gridarta.MainControl; +import javax.swing.filechooser.FileFilter; import net.sf.gridarta.textedit.textarea.JEditTextArea; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -53,8 +55,6 @@ // last active popup is stored here private static CFPythonPopup activePopup = null; - private final MainControl<?, ?, ?, ?> mainControl; // gridarta main control (is null in stand-alone configuration!) - private final ScriptEditView view; // view (window with textareas) private final List<String> tabs; // open tabs, contains absolute filenames (or "<>") in order left to right @@ -62,10 +62,17 @@ /** JFileChooser for opening script files. */ private final JFileChooser openFileChooser; - public ScriptEditControl(final MainControl<?, ?, ?, ?> mainControl, final File defaultScriptDir) { + @NotNull + private FileFilter scriptFileFilter; + + @NotNull + private String scriptSuffix; + + public ScriptEditControl(@NotNull final FileFilter scriptFileFilter, @NotNull final String scriptSuffix, @NotNull final Frame owner, final File defaultScriptDir) { + this.scriptFileFilter = scriptFileFilter; + this.scriptSuffix = scriptSuffix; tabs = new ArrayList<String>(); // start with empty vector - this.mainControl = mainControl; - view = new ScriptEditView(this, mainControl.getMainView()); // initialize window + view = new ScriptEditView(this, owner); // initialize window openFileChooser = createOpenFileChooser(defaultScriptDir); } @@ -115,7 +122,7 @@ final JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.setMultiSelectionEnabled(false); - fileChooser.setFileFilter(mainControl.getScriptFileFilter()); + fileChooser.setFileFilter(scriptFileFilter); // set default folder for new scripts if (defaultScriptDir.exists() && defaultScriptDir.isDirectory()) { @@ -221,9 +228,9 @@ } File file = openFileChooser.getSelectedFile(); - if (!file.getName().endsWith(mainControl.getScriptSuffix())) { + if (!file.getName().endsWith(scriptSuffix)) { final String fname = file.getAbsolutePath(); - file = new File(fname + mainControl.getScriptSuffix()); + file = new File(fname + scriptSuffix); } // now it is our duty to doublecheck if user attempts to overwrite Modified: trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControlInstance.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControlInstance.java 2008-07-31 21:17:53 UTC (rev 4622) +++ trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControlInstance.java 2008-07-31 21:27:32 UTC (rev 4623) @@ -23,8 +23,10 @@ package net.sf.gridarta.textedit.scripteditor; +import java.awt.Frame; import java.io.File; -import net.sf.gridarta.MainControl; +import javax.swing.filechooser.FileFilter; +import org.jetbrains.annotations.NotNull; /** * Utility class holding the singleton {@link ScriptEditControl} instance. @@ -45,12 +47,14 @@ /** * Init method initializes static instance of this controller. Has to be * called before once using this class. - * @param mainControl the main control instance + * @param scriptFileFilter the file filter for selecting script files + * @param scriptSuffix the file suffix for script files + * @param owner the owner frame for the editor * @param defaultScriptDir map default folder */ - public static void init(final MainControl<?, ?, ?, ?> mainControl, final File defaultScriptDir) { + public static void init(@NotNull final FileFilter scriptFileFilter, @NotNull final String scriptSuffix, @NotNull final Frame owner, final File defaultScriptDir) { if (instance == null) { - instance = new ScriptEditControl(mainControl, defaultScriptDir); + instance = new ScriptEditControl(scriptFileFilter, scriptSuffix, owner, defaultScriptDir); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-31 21:29:52
|
Revision: 4624 http://gridarta.svn.sourceforge.net/gridarta/?rev=4624&view=rev Author: akirschbaum Date: 2008-07-31 21:29:57 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Remove MainControl.getScriptFileFilter(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 21:27:32 UTC (rev 4623) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-07-31 21:29:57 UTC (rev 4624) @@ -480,11 +480,6 @@ } /** {@inheritDoc} */ - public FileFilter getScriptFileFilter() { - return pythonFileFilter; - } - - /** {@inheritDoc} */ public String getScriptSuffix() { return ".py"; } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 21:27:32 UTC (rev 4623) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-07-31 21:29:57 UTC (rev 4624) @@ -661,11 +661,6 @@ } /** {@inheritDoc} */ - public FileFilter getScriptFileFilter() { - return luaFileFilter; - } - - /** {@inheritDoc} */ public String getScriptSuffix() { return ".lua"; } Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-31 21:27:32 UTC (rev 4623) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-07-31 21:29:57 UTC (rev 4624) @@ -63,15 +63,6 @@ GlobalSettings getGlobalSettings(); /** - * Get the FileFilter that matches script files of this implementation's - * server side scripting language. - * @return FileFilter that matches script files of this implementation's - * server side scripting language. - * @see #getScriptSuffix() - */ - FileFilter getScriptFileFilter(); - - /** * Get the suffix for script files of this implementation's server side * scripting language. The returned suffix includes the infix character * ".". Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-07-31 21:27:32 UTC (rev 4623) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-07-31 21:29:57 UTC (rev 4624) @@ -417,11 +417,6 @@ } /** {@inheritDoc} */ - public FileFilter getScriptFileFilter() { - throw new AssertionError(); - } - - /** {@inheritDoc} */ public String getScriptSuffix() { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |