From: <aki...@us...> - 2007-03-21 22:04:07
|
Revision: 1946 http://svn.sourceforge.net/gridarta/?rev=1946&view=rev Author: akirschbaum Date: 2007-03-21 15:04:07 -0700 (Wed, 21 Mar 2007) Log Message: ----------- Move logic for edit types from Java code to GameObjectMatchers.xml. Modified Paths: -------------- trunk/crossfire/resource/conf/GameObjectMatchers.xml trunk/crossfire/src/cfeditor/CFArchTypeList.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java Modified: trunk/crossfire/resource/conf/GameObjectMatchers.xml =================================================================== --- trunk/crossfire/resource/conf/GameObjectMatchers.xml 2007-03-21 22:01:20 UTC (rev 1945) +++ trunk/crossfire/resource/conf/GameObjectMatchers.xml 2007-03-21 22:04:07 UTC (rev 1946) @@ -1,9 +1,62 @@ <?xml version="1.0"?> <!DOCTYPE GameObjectMatchers SYSTEM "GameObjectMatchers.dtd"> <GameObjectMatchers> - <GameObjectMatcher id="exits"> - <title xml:lang="en">Exits</title> - <title xml:lang="de">Ausgänge</title> + <GameObjectMatcher id="background"> + <title xml:lang="en">Background</title> + <title xml:lang="de">Hintergrund</title> + <And> + <Attrib name="is_floor" /> + <Attrib name="no_pick" /> + </And> + </GameObjectMatcher> + <GameObjectMatcher id="monster"> + <title xml:lang="en">Monster</title> + <title xml:lang="de">Monster</title> + <And> + <Attrib name="alive" /> + <Or> + <Attrib name="monster" /> + <Attrib name="generator" /> + </Or> + </And> + </GameObjectMatcher> + <GameObjectMatcher id="wall"> + <title xml:lang="en">Wall</title> + <title xml:lang="de">Wand</title> + <And> + <TypeNrs numbers="0" /> + <Attrib name="no_pass" /> + </And> + </GameObjectMatcher> + <GameObjectMatcher id="connected"> + <title xml:lang="en">Connected</title> + <title xml:lang="de">Verbunden</title> + <Attrib name="connected" op="ne" value="" /> + </GameObjectMatcher> + <GameObjectMatcher id="exit"> + <title xml:lang="en">Exit</title> + <title xml:lang="de">Ausgang</title> <TypeNrs numbers="41 57 58 66 94 95" /> </GameObjectMatcher> + <GameObjectMatcher id="treasure"> + <title xml:lang="en">Treasure</title> + <title xml:lang="de">Schatz</title> + <And> + <TypeNrs numbers="4 5 36 60 85 111 123 124 130" /> + <Attrib name="no_pick" value="" /> + </And> + </GameObjectMatcher> + <GameObjectMatcher id="door"> + <title xml:lang="en">Doors and Keys</title> + <title xml:lang="de">Türen und Schlüssel</title> + <TypeNrs numbers="20 21 23 24 26 91" /> + </GameObjectMatcher> + <GameObjectMatcher id="equipment"> + <title xml:lang="en">Equipment</title> + <title xml:lang="de">Ausrüstung</title> + <And> + <TypeNrs numbers="3 13 14 15 16 33 34 35 39 70 87 99 100 104 109 113 122" /> + <Attrib name="no_pick" value="" /> + </And> + </GameObjectMatcher> </GameObjectMatchers> Modified: trunk/crossfire/src/cfeditor/CFArchTypeList.java =================================================================== --- trunk/crossfire/src/cfeditor/CFArchTypeList.java 2007-03-21 22:01:20 UTC (rev 1945) +++ trunk/crossfire/src/cfeditor/CFArchTypeList.java 2007-03-21 22:04:07 UTC (rev 1946) @@ -63,19 +63,101 @@ private final List<NamedGameObjectMatcher> archObjectMatchers = new ArrayList<NamedGameObjectMatcher>(); /** - * Check whether the GameObject is an exit. + * Check whether the GameObject has a given type. * @param arch GameObject to check - * @return <code>true</code> if <var>arch</var> is an exit, otherwise <code>false</code> + * @param id the type to check for + * @return <code>true</code> if <var>arch</var> is of the given type, + * otherwise <code>false</code> */ - public static boolean isExitType(final GameObject arch) { + private static boolean isType(final GameObject arch, final String id) { if (arch == null) { return false; } - final NamedGameObjectMatcher exits = archObjectMatchersByIds.get("exits"); - return exits != null && exits.isMatching(arch); + final NamedGameObjectMatcher matcher = archObjectMatchersByIds.get(id); + return matcher != null && matcher.isMatching(arch); } + /** + * Check whether the GameObject is background. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is background, otherwise + * <code>false</code> + */ + public static boolean isBackgroundType(final GameObject arch) { + return isType(arch, "background"); + } + + /** + * Check whether the GameObject is a monster. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is a monster, otherwise + * <code>false</code> + */ + public static boolean isMonsterType(final GameObject arch) { + return isType(arch, "monster"); + } + + /** + * Check whether the GameObject is a wall. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is a wall, otherwise + * <code>false</code> + */ + public static boolean isWallType(final GameObject arch) { + return isType(arch, "wall"); + } + + /** + * Check whether the GameObject is connected. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is connected, otherwise + * <code>false</code> + */ + public static boolean isConnectedType(final GameObject arch) { + return isType(arch, "connected"); + } + + /** + * Check whether the GameObject is an exit. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is an exit, otherwise + * <code>false</code> + */ + public static boolean isExitType(final GameObject arch) { + return isType(arch, "exit"); + } + + /** + * Check whether the GameObject is a treasure. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is a treasure, otherwise + * <code>false</code> + */ + public static boolean isTreasureType(final GameObject arch) { + return isType(arch, "treasure"); + } + + /** + * Check whether the GameObject is a door/gate/key. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is a door/gate/key, + * otherwise <code>false</code> + */ + public static boolean isDoorType(final GameObject arch) { + return isType(arch, "door"); + } + + /** + * Check whether the GameObject is equipment. + * @param arch GameObject to check + * @return <code>true</code> if <var>arch</var> is equipment, + * otherwise <code>false</code> + */ + public static boolean isEquipmentType(final GameObject arch) { + return isType(arch, "equipment"); + } + /** {@inheritDoc} */ @Override public Spells getSpells() { return spells; Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-03-21 22:01:20 UTC (rev 1945) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2007-03-21 22:04:07 UTC (rev 1946) @@ -19,6 +19,7 @@ package cfeditor.gameobject; +import cfeditor.CFArchTypeList; import cfeditor.IGUIConstants; import cfeditor.gameobject.scripts.ScriptArchData; import cfeditor.gui.GameObjectAttributesPanel; @@ -79,49 +80,28 @@ editType &= ~checkType; } - if ((checkType & IGUIConstants.TILE_EDIT_BACKGROUND) != 0 - && getAttributeInt("is_floor") == 1 - && getAttributeInt("no_pick") == 1) { - // Backgroud: floors + if ((checkType & IGUIConstants.TILE_EDIT_BACKGROUND) != 0 && CFArchTypeList.isBackgroundType(this)) { editType |= IGUIConstants.TILE_EDIT_BACKGROUND; } - if ((checkType & IGUIConstants.TILE_EDIT_MONSTER) != 0 - && getAttributeInt("alive") == 1 - && (getAttributeInt("monster") == 1 || getAttributeInt("generator") == 1)) { - // Monster: monsters/npcs/generators + if ((checkType & IGUIConstants.TILE_EDIT_MONSTER) != 0 && CFArchTypeList.isMonsterType(this)) { editType |= IGUIConstants.TILE_EDIT_MONSTER; } - if ((checkType & IGUIConstants.TILE_EDIT_WALL) != 0 - && archType == 0 - && getAttributeInt("no_pass") == 1) { - // Walls + if ((checkType & IGUIConstants.TILE_EDIT_WALL) != 0 && CFArchTypeList.isWallType(this)) { editType |= IGUIConstants.TILE_EDIT_WALL; } - if ((checkType & IGUIConstants.TILE_EDIT_CONNECTED) != 0 - && getAttributeInt("connected") != 0) { - // Connected Objects + if ((checkType & IGUIConstants.TILE_EDIT_CONNECTED) != 0 && CFArchTypeList.isConnectedType(this)) { editType |= IGUIConstants.TILE_EDIT_CONNECTED; } - if ((checkType & IGUIConstants.TILE_EDIT_EXIT) != 0 - && (archType == 66 || archType == 41 || archType == 95)) { - // Exit: teleporter/exit/trapdoors + if ((checkType & IGUIConstants.TILE_EDIT_EXIT) != 0 && CFArchTypeList.isExitType(this)) { editType |= IGUIConstants.TILE_EDIT_EXIT; } - if ((checkType & IGUIConstants.TILE_EDIT_TREASURE) != 0 - && getAttributeInt("no_pick") == 0 - && (archType == 4 || archType == 5 || archType == 36 || archType == 60 || archType == 85 || archType == 111 || archType == 123 || archType == 124 || archType == 130)) { - // Treasure: randomtreasure/money/gems/potions/spellbooks/scrolls + if ((checkType & IGUIConstants.TILE_EDIT_TREASURE) != 0 && CFArchTypeList.isTreasureType(this)) { editType |= IGUIConstants.TILE_EDIT_TREASURE; } - if ((checkType & IGUIConstants.TILE_EDIT_DOOR) != 0 - && (archType == 20 || archType == 23 || archType == 26 || archType == 91 || archType == 21 || archType == 24)) { - // Door: door/special door/gates + keys + if ((checkType & IGUIConstants.TILE_EDIT_DOOR) != 0 && CFArchTypeList.isDoorType(this)) { editType |= IGUIConstants.TILE_EDIT_DOOR; } - if ((checkType & IGUIConstants.TILE_EDIT_EQUIP) != 0 - && getAttributeInt("no_pick") == 0 - && (archType >= 13 && archType <= 16 || archType == 33 || archType == 34 || archType == 35 || archType == 39 || archType == 70 || archType == 87 || archType == 99 || archType == 100 || archType == 104 || archType == 109 || archType == 113 || archType == 122 || archType == 3)) { - // Equipment: weapons/armour/wands/rods + if ((checkType & IGUIConstants.TILE_EDIT_EQUIP) != 0 && CFArchTypeList.isEquipmentType(this)) { editType |= IGUIConstants.TILE_EDIT_EQUIP; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |