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] |