You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(103) |
Jun
(121) |
Jul
(16) |
Aug
(67) |
Sep
(126) |
Oct
(161) |
Nov
(164) |
Dec
(588) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(394) |
Feb
(181) |
Mar
(131) |
Apr
(180) |
May
(255) |
Jun
(11) |
Jul
(79) |
Aug
(70) |
Sep
(274) |
Oct
(138) |
Nov
(195) |
Dec
(8) |
2008 |
Jan
(3) |
Feb
(142) |
Mar
(162) |
Apr
(124) |
May
(148) |
Jun
(157) |
Jul
(425) |
Aug
(373) |
Sep
(264) |
Oct
(315) |
Nov
(225) |
Dec
(6) |
2009 |
Jan
(67) |
Feb
(78) |
Mar
(279) |
Apr
(294) |
May
(92) |
Jun
(65) |
Jul
(134) |
Aug
(41) |
Sep
(138) |
Oct
(125) |
Nov
(126) |
Dec
(122) |
2010 |
Jan
(15) |
Feb
(48) |
Mar
(9) |
Apr
(195) |
May
(373) |
Jun
(507) |
Jul
(42) |
Aug
(16) |
Sep
(38) |
Oct
(81) |
Nov
(64) |
Dec
(18) |
2011 |
Jan
(13) |
Feb
(12) |
Mar
(39) |
Apr
(1) |
May
(2) |
Jun
(27) |
Jul
(27) |
Aug
(31) |
Sep
(14) |
Oct
(102) |
Nov
(20) |
Dec
(37) |
2012 |
Jan
(22) |
Feb
(1) |
Mar
(1) |
Apr
(2) |
May
(2) |
Jun
(18) |
Jul
(6) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
(47) |
Jun
(7) |
Jul
(107) |
Aug
|
Sep
|
Oct
(112) |
Nov
(31) |
Dec
(17) |
2014 |
Jan
(29) |
Feb
(111) |
Mar
(34) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(18) |
Dec
(10) |
From: <chr...@us...> - 2006-10-08 23:38:27
|
Revision: 509 http://svn.sourceforge.net/gridarta/?rev=509&view=rev Author: christianhujer Date: 2006-10-08 16:38:11 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Merged common msgText property of GameObjects. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-08 23:31:45 UTC (rev 508) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-08 23:38:11 UTC (rev 509) @@ -66,14 +66,6 @@ /** The name of this object. */ private String objName; - /** - * The msgText. - * @note Every line in msgText must end on '\n', including the last line. - * @note If the value is <code>null</code>, the arch has no message text, - * if the value exists but is empty, the arch has an empty message text (unconfirmed). - */ - @Nullable private StringBuffer msgText; - private StringBuffer animText; // anim text buffer private StringBuffer loreText; // lore text buffer @@ -118,7 +110,7 @@ myId = myIdCounter++; // increase ID counter for every new arch created - msgText = animText = loreText = null; + animText = loreText = null; archTextCount = 0; // lines inserted in objectText objName = null; @@ -638,48 +630,6 @@ return null; } - /** Delete message text by nullification. */ - public void deleteMsgText() { - msgText = null; - } - - /** Delete message text by emptying. */ - public void resetMsgText() { - if (msgText == null) { - return; - } - - msgText.delete(0, msgText.length()); - } - - /** - * Add a line of message text. This is used when creating the GameObject - * from the ArchetypeParser. Special: invoking this method with - * <code>null</code> creates an empty string. - * @param text text to append to message text - */ - public void addMsgText(final String text) { - if (msgText == null) { - msgText = new StringBuffer(); - } - - if (text == null) { - // special, this adds a clear string - // That's why it's after checking msgText for null. - return; - } - - msgText.append(text); - } - - /** - * Get the complete message text. - * @return message text - */ - @Nullable public String getMsgText() { - return msgText != null ? msgText.toString() : null; - } - // ANIMText! public void addAnimText(final String text) { if (animText == null) { Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-08 23:31:45 UTC (rev 508) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-08 23:38:11 UTC (rev 509) @@ -78,14 +78,6 @@ private String animName; /** - * The msgText. - * @note Every line in msgText must end on '\n', including the last line. - * @note If the value is <code>null</code>, the arch has no message text, - * if the value exists but is empty, the arch has an empty message text (unconfirmed). - */ - @Nullable private StringBuffer msgText; - - /** * Data for multitile-arches. * Stays null for singlesquare-arches. */ @@ -655,49 +647,7 @@ return null; } - /** Delete message text by nullification. */ - public void deleteMsgText() { - msgText = null; - } - - /** Delete message text by emptying. */ - public void resetMsgText() { - if (msgText == null) { - return; - } - - msgText.delete(0, msgText.length()); - } - /** - * Add a line of message text. This is used when creating the GameObject - * from the ArchetypeParser. Special: invoking this method with - * <code>null</code> creates an empty string. - * @param text text to append to message text - */ - public void addMsgText(final String text) { - if (msgText == null) { - msgText = new StringBuffer(); - } - - if (text == null) { - // special, this adds a clear string - // That's why it's after checking msgText for null. - return; - } - - msgText.append(text); - } - - /** - * Get the complete message text. - * @return message text - */ - @Nullable public String getMsgText() { - return msgText != null ? msgText.toString() : null; - } - - /** * Returns whether the direction is set. <code>true</code> if direction is set, * otherwise <code>false</code>. * @return whether the direction is set. Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-08 23:31:45 UTC (rev 508) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-08 23:38:11 UTC (rev 509) @@ -44,6 +44,14 @@ */ @NotNull protected StringBuffer objectText = new StringBuffer(); + /** + * The msgText. + * @note Every line in msgText must end on '\n', including the last line. + * @note If the value is <code>null</code>, the arch has no message text, + * if the value exists but is empty, the arch has an empty message text (unconfirmed). + */ + @Nullable protected StringBuffer msgText; + /** Map x position if on map. */ private int mapx; @@ -531,7 +539,48 @@ */ public abstract void setEditType(int editType); + /** Delete message text by nullification. */ + public void deleteMsgText() { + msgText = null; + } + + /** Delete message text by emptying. */ + public void resetMsgText() { + if (msgText == null) { + return; + } + + msgText.delete(0, msgText.length()); + } + /** + * Add a line of message text. This is used when creating the GameObject + * from the ArchetypeParser. Special: invoking this method with + * <code>null</code> creates an empty string. + * @param text text to append to message text + */ + public void addMsgText(final String text) { + if (msgText == null) { + msgText = new StringBuffer(); + } + + if (text == null) { + // special, this adds a clear string + // That's why it's after checking msgText for null. + return; + } + + msgText.append(text); + } + + /** + * Get the complete message text. + * @return message text + */ + @Nullable public String getMsgText() { + return msgText != null ? msgText.toString() : null; + } + /** * Get the X coordinate of this GameObject on its map. * This method only guarantees a reasonable value for GameObjects that are directly bound to a map (i.e. {@link #getTopContainer()} returns <code>null</code>). * Implementations may also return reasonable values for GameObjects inside containers, but they are not required to do so. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-08 23:31:55
|
Revision: 508 http://svn.sourceforge.net/gridarta/?rev=508&view=rev Author: christianhujer Date: 2006-10-08 16:31:45 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Fixed bogus naming of GameObject and Archetype variables. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/daimonin/src/daieditor/CAttribDialog.java Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-10-08 23:18:57 UTC (rev 507) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-10-08 23:31:45 UTC (rev 508) @@ -116,7 +116,7 @@ private JTextField nameTF; // textfield for gameObject name - private JTextField defarchTF; // textfield for name of default gameObject + private JTextField archetypeTF; // textfield for name of the Archetype private JLabel imagePanel; // panel for object's face (png) @@ -337,7 +337,7 @@ typesel.setName("Types"); // the listener: - typesel.addItemListener(new TypesBoxAL(this, gameObject, archetype)); + typesel.addItemListener(new TypesBoxAL(this, gameObject)); lineLayout.add(typesel); return lineLayout; @@ -484,9 +484,9 @@ final JPanel layout4 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); layout4.add(new JLabel("Archetype: ")); // create label - defarchTF = new JTextField(archetype.getArchetypeName(), 16); - defarchTF.setEditable(false); - layout4.add(defarchTF); + archetypeTF = new JTextField(archetype.getArchetypeName(), 16); + archetypeTF.setEditable(false); + layout4.add(archetypeTF); final JPanel layout5 = new JPanel(); layout5.add(layout4); @@ -1761,10 +1761,8 @@ final CAttribDialog frame; // the entire frame - final GameObject arch; // the according gameObject + final GameObject gameObject; // the according gameObject - final GameObject defarch; // default gameObject of 'gameObject' - String deselected; // the latest deselected item public boolean ignoreEvent; // while true, this listener ignores all events @@ -1772,13 +1770,11 @@ /** * Constructor. * @param frameNew the attribute-dialog mainframe - * @param archNew the gameObject which has the error to be added - * @param defarchNew the default gameObject of 'gameObject' + * @param gameObject the gameObject which has the error to be added */ - public TypesBoxAL(final CAttribDialog frameNew, final GameObject archNew, final GameObject defarchNew) { + public TypesBoxAL(final CAttribDialog frameNew, final GameObject gameObject ) { frame = frameNew; - arch = archNew; - defarch = defarchNew; + this.gameObject = gameObject; ignoreEvent = false; } @@ -1808,7 +1804,7 @@ frame.type = newType; // set new type structure // change the gameObject to be of the new type: - arch.setArchTypNr(newType.getTypeNr()); + gameObject.setArchTypNr(newType.getTypeNr()); attrHead = null; // clear list of attributes listNr = frame.typesel.getSelectedIndex(); @@ -1820,7 +1816,7 @@ frame.update(frame.getGraphics()); // recalculate the editType value - arch.calculateEditType(mainControl.getCurrentMap().getActiveEditType()); + gameObject.calculateEditType(mainControl.getCurrentMap().getActiveEditType()); // also update the gameObject panel (bottom) mainControl.getMainView().refreshMapArchPanel(); // map content has changed Modified: trunk/daimonin/src/daieditor/CAttribDialog.java =================================================================== --- trunk/daimonin/src/daieditor/CAttribDialog.java 2006-10-08 23:18:57 UTC (rev 507) +++ trunk/daimonin/src/daieditor/CAttribDialog.java 2006-10-08 23:31:45 UTC (rev 508) @@ -138,7 +138,7 @@ private JTextField nameTF; // textfield for gameObject name - private JTextField defarchTF; // textfield for name of default gameObject + private JTextField archetypeTF; // textfield for name of the Archetype private JLabel imagePanel; // panel for object's face (png) @@ -460,9 +460,9 @@ gbc.gridy++; header.add(buildTypesBox(), gbc); // build type-selection box gbc.gridy++; - defarchTF = new JTextField(archetype.getArchetypeName(), 16); - defarchTF.setEditable(false); - header.add(defarchTF, gbc); + archetypeTF = new JTextField(archetype.getArchetypeName(), 16); + archetypeTF.setEditable(false); + header.add(archetypeTF, gbc); return header; } @@ -1248,7 +1248,7 @@ imagePanel.setIcon(mainControl.getArchetypeSet().getFace(gameObject.getFaceObjName())); if (newMsg != null) { - // set new msg text only when it is not equal to default gameObject + // set new msg text only when it is not equal to Archetype if (!newMsg.trim().equals(archetype.getMsgText() == null ? "" : archetype.getMsgText().trim())) { gameObject.deleteMsgText(); gameObject.addMsgText(newMsg); @@ -1581,7 +1581,7 @@ private final CAttribDialog frame; // the entire frame - private final GameObject arch; // the according gameObject + private final GameObject gameObject; // the according gameObject private String deselected; // the latest deselected item @@ -1594,7 +1594,7 @@ */ TypesBoxAL(final CAttribDialog frameNew, final GameObject archNew) { frame = frameNew; - arch = archNew; + gameObject = archNew; ignoreEvent = false; } @@ -1624,7 +1624,7 @@ frame.type = newType; // set new type structure // change the gameObject to be of the new type: - arch.setArchTypNr(newType.getTypeNr()); + gameObject.setArchTypNr(newType.getTypeNr()); dialogAttribs.clear(); listNr = frame.typesel.getSelectedIndex(); @@ -1636,7 +1636,7 @@ frame.update(frame.getGraphics()); // recalculate the editType value - arch.calculateEditType(mainControl.getCurrentMap().getActiveEditType()); + gameObject.calculateEditType(mainControl.getCurrentMap().getActiveEditType()); // also update the gameObject panel (bottom) mainControl.getMainView().refreshMapArchPanel(); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-08 23:19:05
|
Revision: 507 http://svn.sourceforge.net/gridarta/?rev=507&view=rev Author: christianhujer Date: 2006-10-08 16:18:57 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Introduced Archetype interface. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/Archetype.java Added: trunk/src/app/net/sf/gridarta/gameobject/Archetype.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Archetype.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2006-10-08 23:18:57 UTC (rev 507) @@ -0,0 +1,23 @@ +package net.sf.gridarta.gameobject; + +import org.jetbrains.annotations.NotNull; + +/** + * Reflects an Archetype. + * This interface is part of extracting the Archetype functionality from GameObject into a class of its own. + * The plan is to let GameObject implement this interface and change the type of getArchetype() and other Archetype related methods from {@link GameObject} to {@link Archetype} and see what breaks. + * Then all method signatures are copied to this interface. + * Once that is done we technically know what an Archetype is and can create a class for it. + * Once the Archetype classes are finnished, GameObject will no longer implement Archetype and we've separated Archetype from GameObject. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface Archetype<G extends GameObject<G>> { + + /** + * Returns an attribute value of this Archetype. + * @param attributeName Name of the attribute value to return + * @return Attribute value or <code>""</code> (empty String) if not found. + */ + String getAttributeString(@NotNull String attributeName); + +} // interface Archetype Property changes on: trunk/src/app/net/sf/gridarta/gameobject/Archetype.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-08 22:58:58 UTC (rev 506) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-08 23:18:57 UTC (rev 507) @@ -13,7 +13,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ @SuppressWarnings({"ClassReferencesSubclass"}) -public abstract class GameObject<G extends GameObject<G>> extends GameObjectContainer<G> { +public abstract class GameObject<G extends GameObject<G>> extends GameObjectContainer<G> implements Archetype<G> { /** Special constant that's used if a GameObject has no arch type set. */ public static final int TYPE_UNSET = -666; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-08 22:59:41
|
Revision: 506 http://svn.sourceforge.net/gridarta/?rev=506&view=rev Author: christianhujer Date: 2006-10-08 15:58:58 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Renamed ArchObjectParser to ArchetypeParser. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CArchQuickView.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMapArchPanel.java trunk/crossfire/src/cfeditor/CPickmapPanel.java trunk/crossfire/src/cfeditor/CopyBuffer.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapArchPanel.java trunk/daimonin/src/daieditor/CMapFileDecode.java trunk/daimonin/src/daieditor/CPickmapPanel.java trunk/daimonin/src/daieditor/CopyBuffer.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/MainControl.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java trunk/src/app/net/sf/gridarta/gameobject/ArchetypeParser.java Removed Paths: ------------- trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java trunk/src/app/net/sf/gridarta/gameobject/ArchObjectParser.java Modified: trunk/crossfire/src/cfeditor/CArchQuickView.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchQuickView.java 2006-10-08 22:53:19 UTC (rev 505) +++ trunk/crossfire/src/cfeditor/CArchQuickView.java 2006-10-08 22:58:58 UTC (rev 506) @@ -137,7 +137,7 @@ archObjNameText.setText("<html><font color=black>Name: " + arch.getObjName() + "</font></html>"); } - archTypeText.setText("<html><font color=black>Type: " + mainControl.getArchObjectParser().getArchTypeName(arch.getArchTypNr()) + " (" + arch.getArchTypNr() + ") </font></html>"); + archTypeText.setText("<html><font color=black>Type: " + mainControl.getArchetypeParser().getArchTypeName(arch.getArchTypNr()) + " (" + arch.getArchTypNr() + ") </font></html>"); if (arch.isMulti()) { archTileText.setText("<html><font color=black>Tile: </font><font color=green> multi</font><font color=black> (" + arch.getMultiRefCount() + " parts) (" + arch.getSizeX() + "," + arch.getSizeY() + ")</font></html>"); Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-08 22:53:19 UTC (rev 505) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-08 22:58:58 UTC (rev 506) @@ -24,7 +24,7 @@ package cfeditor; -import cfeditor.gameobject.ArchObjectParser; +import cfeditor.gameobject.ArchetypeParser; import cfeditor.gameobject.ArchetypeSet; import cfeditor.gameobject.GameObject; import cfeditor.gameobject.anim.AnimationObjects; @@ -113,7 +113,7 @@ private CMapFileEncode mapFileEncoder; - private ArchObjectParser archObjectParser; + private ArchetypeParser archetypeParser; /** The Animation Objects. */ private AnimationObjects animationObjects; @@ -244,11 +244,11 @@ mapFileEncoder = new CMapFileEncode(this); // our global object parser - archObjectParser = new ArchObjectParser(this); + archetypeParser = new ArchetypeParser(this); animationObjects = new AnimationObjects(); // read in the type & type field definitions - archObjectParser.loadTypeNumbers(); + archetypeParser.loadTypeNumbers(); //loadTypeDef(); // load the list with archtype-data from "types.txt" @@ -891,12 +891,12 @@ // ok, we have it all!! final MapControl control; - // go to ArchObjectParser and add the default arch list information to them + // go to ArchetypeParser and add the default arch list information to them if (!collectTempList(objects, file)) { // get face names, face id, etc. return null; } - archObjectParser.sortTempList(objects); // sort the list (put multiparts at the end) + archetypeParser.sortTempList(objects); // sort the list (put multiparts at the end) control = newLevel(objects, maparch, show, initial); // init the map if (show) { @@ -971,9 +971,9 @@ // Ok, now is attached to default arch and loaded png // NOW we post parse the object... // (We calculate only edit types that are active, to save time) - archObjectParser.postParseMapArch(gameObject, tileEdit); + archetypeParser.postParseMapArch(gameObject, tileEdit); - archObjectParser.expandMulti(gameObject, tailList); + archetypeParser.expandMulti(gameObject, tailList); } for (final GameObject tail : tailList) { @@ -1722,8 +1722,8 @@ return currentMap; } - public ArchObjectParser getArchObjectParser() { - return archObjectParser; + public ArchetypeParser getArchetypeParser() { + return archetypeParser; } public AnimationObjects getAnimationObject() { Modified: trunk/crossfire/src/cfeditor/CMapArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-10-08 22:53:19 UTC (rev 505) +++ trunk/crossfire/src/cfeditor/CMapArchPanel.java 2006-10-08 22:58:58 UTC (rev 506) @@ -285,7 +285,7 @@ } inv.addLast(invnew); - mainControl.getArchObjectParser().postParseMapArch(invnew, 0); + mainControl.getArchetypeParser().postParseMapArch(invnew, 0); mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), inv.getMyID()); mainControl.getCurrentMap().setLevelChangedFlag(); // the map has been modified } @@ -729,7 +729,7 @@ archMapPos.setText("Map: " + gameObject.getMapX() + ", " + gameObject.getMapY()); if (gameObject.getArchetypeName() != null) { - archTypeText.setText("Type: " + mainControl.getArchObjectParser().getArchTypeName(gameObject.getArchTypNr()) + archTypeText.setText("Type: " + mainControl.getArchetypeParser().getArchTypeName(gameObject.getArchTypNr()) + " (" + gameObject.getArchTypNr() + ") [" + gameObject.getArchetypeName() + "]"); } else { archTypeText.setText("Type: <unknown>"); Modified: trunk/crossfire/src/cfeditor/CPickmapPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CPickmapPanel.java 2006-10-08 22:53:19 UTC (rev 505) +++ trunk/crossfire/src/cfeditor/CPickmapPanel.java 2006-10-08 22:58:58 UTC (rev 506) @@ -141,11 +141,11 @@ // The map is totally empty bmapview = newPickmap(null, maparch, mapFile); // init the map } else { - // go to ArchObjectParser and add the default arch list information to them + // go to ArchetypeParser and add the default arch list information to them if (!mainControl.collectTempList(objects, mapFile)) { // get face names, face id, etc. return false; } - mainControl.getArchObjectParser().sortTempList(objects); // sort the list (put multiparts at the end) + mainControl.getArchetypeParser().sortTempList(objects); // sort the list (put multiparts at the end) bmapview = newPickmap(objects, maparch, mapFile); // init the map } Modified: trunk/crossfire/src/cfeditor/CopyBuffer.java =================================================================== --- trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-10-08 22:53:19 UTC (rev 505) +++ trunk/crossfire/src/cfeditor/CopyBuffer.java 2006-10-08 22:58:58 UTC (rev 506) @@ -383,7 +383,7 @@ mapControl.addArchObjectToMap(newHead, fillBelow); for (GameObject tmp = newHead.getMultiNext(); tmp != null; tmp = tmp.getMultiNext()) { mapControl.addArchObjectToMap(tmp, fillBelow); - mainControl.getArchObjectParser().postParseMapArch(tmp, mapControl.getActiveEditType()); + mainControl.getArchetypeParser().postParseMapArch(tmp, mapControl.getActiveEditType()); } } } Deleted: trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-08 22:53:19 UTC (rev 505) +++ trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-08 22:58:58 UTC (rev 506) @@ -1,558 +0,0 @@ -/* - * Crossfire Java Editor. - * Copyright (C) 2000 Michael Toennies - * Copyright (C) 2001 Andreas Vogl - * - * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - * - */ - -package cfeditor.gameobject; - -import cfeditor.CMainControl; -import cfeditor.IGUIConstants; -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import net.sf.gridarta.io.IOUtils; -import org.apache.log4j.Logger; -import org.jdom.DataConversionException; -import org.jdom.Document; -import org.jdom.Element; -import org.jdom.JDOMException; -import org.jdom.input.SAXBuilder; -import org.jetbrains.annotations.Nullable; - -/** - * The <code>ArchObjectParser</code> class handles the parsing of arches. It is - * a class separated from ArchetypeSet because it is also involved in - * loading arches in map files. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public final class ArchObjectParser implements net.sf.gridarta.gameobject.ArchObjectParser<GameObject> { - - /** Logger. */ - private static final Logger log = Logger.getLogger(ArchObjectParser.class); - - // name of the system-arch containing path of starting map - public static final String STARTARCH_NAME = "map"; - - // table with type numbers as keys (Integer), and type names as values (String) - private Map<Integer,String> archTypeNumbers; - - private final CMainControl mainControl; - - /** - * Constructor - * @param mainControl main control - */ - public ArchObjectParser(final CMainControl mainControl) { - this.mainControl = mainControl; - archTypeNumbers = null; - } - - /** - * Parse the typenumbers file (associate names with type numbers) - * Type numbers and names are stored as key-value pairs in the - * Hashtable 'archTypeNumbers'. - */ - public void loadTypeNumbers() { - archTypeNumbers = new HashMap<Integer,String>(); - - try { - // open reading stream to the spells xml file - final String baseDir = IGUIConstants.CONFIG_DIR; - final BufferedReader reader = IOUtils.createReader(baseDir, IGUIConstants.TYPENR_FILE); - try { - - // parse xml document - final SAXBuilder builder = new SAXBuilder(); - builder.setValidation(true); - final Document doc = builder.build(reader); - - // retrieve the spell data from the xml - final Element root = doc.getRootElement(); - if (root == null || !"typenumbers".equalsIgnoreCase(root.getName())) { - log.warn("File '" + IGUIConstants.TYPENR_FILE + "' lacks root element 'typenumbers'."); - } else { - final List types = root.getChildren("type"); - if (types == null || types.size() == 0) { - log.warn("File '" + IGUIConstants.TYPENR_FILE + "' has no content."); - } else { - // process all 'type' elements from the xml file - int i; - for (i = 0; i < types.size(); i++) { - final Element typeElem = (Element) types.get(i); - - if (typeElem.getAttribute("number") == null) { - log.warn("In File '" + IGUIConstants.TYPENR_FILE + "': Found 'type' element without 'number'"); - } else if (typeElem.getAttribute("name") == null) { - log.warn("In File '" + IGUIConstants.TYPENR_FILE + "': Found 'type' element without 'name'"); - } else { - try { - // parse type number and -name, then add it to the table 'archTypeNumbers' - archTypeNumbers.put(typeElem.getAttribute("number").getIntValue(), typeElem.getAttribute("name").getValue()); - } catch (final DataConversionException de) { - log.error("In '" + IGUIConstants.TYPENR_FILE + "':\n type number '" + typeElem.getAttribute("number").getValue() + "' is not an integer."); - } - } - } - - // loading successful - if (log.isInfoEnabled()) { - log.info("" + i + " typenumbers loaded."); - } - } - } - } finally { - reader.close(); - } - } catch (final JDOMException e) { - log.error("Parsing error in '" + IGUIConstants.TYPENR_FILE + "'", e); - } catch (final FileNotFoundException e) { - log.error("Cannot read file '" + IGUIConstants.TYPENR_FILE + "'!", e); - } catch (final IOException e) { - log.error("Error while reading file '" + IGUIConstants.TYPENR_FILE + "'!", e); - } - } - - /** - * Lookup the name of an archtype. - * @param index type number - * @return name of this type, as defined in "typenumbers.xml" - */ - public String getArchTypeName(final int index) { - if (archTypeNumbers != null && archTypeNumbers.containsKey(index)) { - return archTypeNumbers.get(index); - } - return "*UNKNOWN" + index + "*"; // this type is unknown - } - - /** {@inheritDoc} */ - public void parseArchetype(final String fname, final int index) { - //Open the file for reading - try { - final BufferedReader in = new BufferedReader(new FileReader(fname)); - try { - parseArchetypeFromStream(in, index, fname); - } finally { - in.close(); - } - } catch (final FileNotFoundException e) { - log.error("Archfile " + fname + " could not be found"); - } catch (final IOException e) { - log.error("IOException in parseDefArch!"); - } - } - - /** {@inheritDoc} */ - public void parseArchetypeFromStream(final BufferedReader in, final int index, final String fname) { - parseArchetypeFromStream(in, null, null, null, index, fname); - } - - /** {@inheritDoc} */ - @Nullable - public GameObject parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject archetype, final String line, final String archName, int index, final String fname) { - - //Open the file for reading - try { - - // start with new clean GameObject instance - GameObject arch; - GameObject archlast = null; - if (archetype == null) { - arch = new GameObject(); - } else { - arch = archetype.createClone(0, 0); - } - arch.resetObjectText(); - - String thisLine2; - if (line == null) { - thisLine2 = in.readLine(); - } else { - thisLine2 = line; // pre read "Object" from artifacts file loader - } - - boolean msgflag = false; - boolean loreflag = false; - boolean animflag = false; - boolean parsearch = false; - boolean archmore = false; - String oldCat = "<xxx>"; - boolean isNewCategory = true; - GameObject firstArch = null; - String newCat = "no category info"; - int archmoreCount = 0; - while (thisLine2 != null) { - final String thisLine = thisLine2.trim(); - - if (thisLine.startsWith("#")) { - // skip comments - thisLine2 = in.readLine(); - continue; - } - - if (!parsearch) { - - if (thisLine.startsWith("More")) { - if (firstArch == null) { - firstArch = archlast; - } - archmore = true; - } else if (thisLine.startsWith("Object")) { - if (arch == null) { - arch = new GameObject(); - } - - parsearch = true; - if (!archmore) { - firstArch = null; - } - - if (archName == null) { - arch.setArchetypeName(thisLine.substring(7)); - } else { - arch.setArchetypeName(archName); - } - } - } else { - if (msgflag) { - if (thisLine.startsWith("endmsg")) { - msgflag = false; - } else { - arch.addMsgText(thisLine2 + "\n"); // thisLine2 allows leading whitespaces - } - } else if (animflag) { - if (thisLine.startsWith("mina")) { - mainControl.getAnimationObject().addAnimObject(arch.getArchetypeName(), arch.getAnimText()); - - arch.addObjectText("animation " + arch.getArchetypeName() + "\n"); - // here we must add this to AnimationObject - // and add Animation cmd here! - animflag = false; - } else { - arch.addAnimText(thisLine + "\n"); - } - } else if (loreflag) { - if (thisLine.startsWith("endlore")) { - loreflag = false; - } else { - arch.addLoreText(thisLine + "\n"); - } - } else if (thisLine.startsWith("Object")) { - log.error("Find inventory Object in def arch: " + thisLine); - } else if (thisLine.startsWith("end")) { - //if (arch.getArchTypNr() == 0) { - if (log.isDebugEnabled()) { - log.debug("Arch " + arch.getArchetypeName() + " has no type info!"); - } - //} - // we got full arch - parsearch = false; // we write this sucker - - if (firstArch != null) { - // add to head our x/y position so he can setup refmax - firstArch.addTailPart(arch); - } else { - // add arch to the archpanel - only if it is not the map arch - if (!arch.getArchetypeName().equals(STARTARCH_NAME)) { - if (!mainControl.getArchetypeSet().isLoadedFromArchive() || archName != null) { - // loading from individual files, so we simply add it to list - // ArchetypeSet.loadArchFromFiles() takes care of the panels - mainControl.addArchPanelArch(arch.getArchetypeName(), index); - } else { - // loading from collected files, so we need process panels here - if (isNewCategory) { - String folder = newCat; // main folder of new category - if (newCat.indexOf("/") > 0) { - folder = newCat.substring(0, newCat.indexOf("/")); - } - - if (!oldCat.startsWith(folder)) { - // an entire new panel must be opened - mainControl.addArchPanel(folder); - mainControl.addArchPanelCombo("show all"); - mainControl.addArchPanelCombo(folder); - index = 1; - } - - if (newCat.indexOf("/") > 0) { - folder = newCat.substring(newCat.indexOf("/") + 1); - if (newCat.startsWith(folder)) { - index = 1; // add to the base folder - } else if (!oldCat.endsWith(folder)) { - // a new JComboBox must be added - index = mainControl.addArchPanelCombo(folder); - } - } else { - index = 1; // add to the base folder - } - - isNewCategory = false; - oldCat = newCat; - } - mainControl.addArchPanelArch(arch.getArchetypeName(), index); - } - } - } - postParseDefArch(arch); - mainControl.getArchetypeSet().addArchetype(arch); - - archmore = false; // we assume this is last... but perhaps.. - - // if this arch was from Artifacts file - return here: - if (archName != null) { - arch.setArtifact(true); - // here we add all unchanged arch text lines from defArch back to arch - arch.addObjectText(arch.diffArchText(archetype.getObjectText(), true)); - return arch; - } - archlast = arch; - arch = null; - } else { - if (thisLine.startsWith("msg")) { - msgflag = true; - } else if (thisLine.startsWith("animation")) { - arch.addObjectText(thisLine + "\n"); - } else if (thisLine.startsWith("anim_speed")) { - arch.addObjectText(thisLine + "\n"); - } else if (thisLine.startsWith("anim")) { - animflag = true; - } else if (thisLine.equals("lore")) { - loreflag = true; - } else if (thisLine.startsWith("visibility ")) { - if (log.isDebugEnabled()) { - log.debug("Remove visibility: " + arch.getArchetypeName()); - } - } else if (thisLine.startsWith("magicmap ")) { - if (log.isDebugEnabled()) { - log.debug("Remove magicmap: " + arch.getArchetypeName()); - } - } else if (thisLine.startsWith("color_fg ")) { - if (log.isDebugEnabled()) { - log.debug("Remove color_fg: " + arch.getArchetypeName()); - } - } else if (thisLine.startsWith("color_bg ")) { - if (log.isDebugEnabled()) { - log.debug("Remove color_bg: " + arch.getArchetypeName()); - } - } else if (thisLine.startsWith("x ")) { - if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { - log.warn("Find x cmd in single tile or head (add it to arch text): " + arch.getArchetypeName()); - arch.addObjectText(thisLine + "\n"); - } - arch.setMultiX(Integer.parseInt(thisLine.substring(2))); - } else if (thisLine.startsWith("y ")) { - if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { - log.warn("Find y cmd in single tile or head (add it to arch text): " + arch.getArchetypeName()); - arch.addObjectText(thisLine + "\n"); - } - arch.setMultiY(Integer.parseInt(thisLine.substring(2))); - } else if (thisLine.startsWith("type ")) { - try { - final int i = Integer.parseInt(thisLine.substring(5)); - arch.setArchTypNr(i); - if (i == 0) { - log.warn("Arch " + arch.getArchetypeName() + " type number is zero. (" + thisLine.substring(5) + ")"); - } - } catch (final Exception e) { - log.warn("Arch " + arch.getArchetypeName() + " has a invalid type nr. (" + thisLine.substring(5) + ")"); - arch.addObjectText(thisLine + "\n"); - } - } else if (thisLine.startsWith("face ")) { - int x; - for (x = 4; x < thisLine.length(); x++) { - if (thisLine.charAt(x) != ' ') { - break; - } - } - arch.setFaceFlag(false); // we HAVE a face - arch.setFaceName(thisLine.substring(x, thisLine.length())); - } else if (thisLine.startsWith("editor_folder ")) { - // the display category (= "folder" the arch belongs to) - newCat = thisLine.substring(14).trim(); - if (!newCat.equals(oldCat)) { - isNewCategory = true; // this arch has a new category - } - } - arch.addObjectText(thisLine + "\n"); - if (log.isDebugEnabled()) { - log.debug("add String: " + thisLine); - } - } - } - thisLine2 = in.readLine(); - } // while loop ends here - } catch (final IOException e) { - log.error("Error: ", e); - } - return null; - } - - /** {@inheritDoc} */ - public void postParseDefArch(final GameObject arch) { - final String text = arch.getObjectText(); - arch.resetObjectText(); - final int len = text.length(); - - // if no type was set, zero is taken - if (arch.getArchTypNr() == GameObject.TYPE_UNSET) { - arch.setArchTypNr(0); - } - - boolean scriptflag = false; - for (int i = 0, s = 0; i < len; i++) { - - if (text.charAt(i) == '\n') { - if (i - s > 0) { - if (scriptflag) { - arch.addObjectText(text.substring(s, i) + "\n"); - if (text.regionMatches(s, "end_script_", 0, 11)) { - scriptflag = false; - } - } else if (text.regionMatches(s, "start_script_", 0, 13)) { - arch.addObjectText(text.substring(s, i) + "\n"); - scriptflag = true; - } else if (text.regionMatches(s, "editable ", 0, 9)) { - arch.setEditType(Integer.parseInt(text.substring(s + 9, i))); - } else if (text.regionMatches(s, "name ", 0, 5)) { - arch.setObjName(text.substring(s + 5, i)); - } else { - arch.addObjectText(text.substring(s, i) + "\n"); - } - - } - s = i + 1; - } - } - - // default arches don't get an editType (not worth the time) - // they get one assigned as soon as put on a map though. - arch.setEditType(IGUIConstants.TILE_EDIT_NONE); - } - - /** {@inheritDoc} */ - public void postParseMapArch(final GameObject gameObject, final int editType) { - if (gameObject.getArchetypeName() == null) { - return; - } - - final String text = gameObject.getObjectText(); - final int len = text.length(); - final GameObject archetype = mainControl.getArchetype(gameObject.getArchetypeName()); - - gameObject.resetObjectText(); - for (int i = 0, s = 0; i < len; i++) { - - if (text.charAt(i) == '\n') { - if (i - s > 0) { - if (text.regionMatches(s, "name ", 0, 5)) { - gameObject.setObjName(text.substring(s + 5, i)); - } else { - // this is an unparsed arch attribute, it has to stay in the archtext - gameObject.addObjectText(text.substring(s, i) + "\n"); - } - } - s = i + 1; - } - } - // so, lets check the stuff a last time - - if (gameObject.getFaceName() == null) { - gameObject.setFaceNr(archetype.getFaceNr()); - gameObject.setFaceFlag(archetype.getFaceFlag()); - } - - // if the type is still unset, then we take the default one - if (gameObject.getArchTypNr() == GameObject.TYPE_UNSET) { - gameObject.setArchTypNr(archetype.getArchTypNr()); - } - - gameObject.setMultiX(archetype.getMultiX()); - gameObject.setMultiY(archetype.getMultiY()); - - // arch.setEditType(defarch.getEditType()); - - // validate the ScriptedEvents - gameObject.validateAllEvents(); - - // we don't handle anim yet, so attach then back to archtext - if (gameObject.getAnimText() != null) { - gameObject.addObjectText("anim\n"); - gameObject.addObjectText(gameObject.getAnimText()); - gameObject.addObjectText("mina\n"); - } - - // Finally, we calculate the desired editType of the arch - if (gameObject.isTail()) { - gameObject.setEditType(gameObject.getHead().getEditType()); // copy from head - } else if (editType != 0) { - gameObject.setEditType(gameObject.calculateEditType(editType)); // calculate new - } - } - - /** {@inheritDoc} */ - public void expandMulti(final GameObject gameObject, final List<GameObject> objects) { - // TODO: Couldn't we simply invoke archetype = gameObject.getArchetype() here? - final GameObject archetype = mainControl.getArchetype(gameObject.getArchetypeName()); - - // is it a multi head? - if (archetype != null && archetype.isMulti() && gameObject.getMultiRefCount() <= 1) { - // we have a multi head and need to insert his tail now - - // do insertion for all non-head parts of the multi - for (GameObject oldPart = archetype.getMultiNext(); oldPart != null; oldPart = oldPart.getMultiNext()) { - final GameObject newarch = oldPart.createArch(); - - gameObject.addTailPart(newarch); - objects.add(newarch); - - // set map position (x, y) - newarch.setMapX(gameObject.getMapX() + newarch.getMultiX()); - newarch.setMapY(gameObject.getMapY() + newarch.getMultiY()); - - // now attach the default arch and stuff - // (don't need edit type as we copy from head) - mainControl.getArchObjectParser().postParseMapArch(newarch, 0); - } - } - } - - /** {@inheritDoc} */ - public void sortTempList(final List<GameObject> objects) { - final Comparator<GameObject> sorter = new Comparator<GameObject>() { - /** {@inheritDoc} */ - public int compare(final GameObject o1, final GameObject o2) { - final boolean b1 = o1.isMulti(); - final boolean b2 = o2.isMulti(); - return b1 == b2 ? 0 : b2 ? -1 : 1; - } - }; - Collections.sort(objects, sorter); - } - -} // class ArchObjectParser Copied: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java (from rev 505, trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java) =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java (rev 0) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2006-10-08 22:58:58 UTC (rev 506) @@ -0,0 +1,558 @@ +/* + * Crossfire Java Editor. + * Copyright (C) 2000 Michael Toennies + * Copyright (C) 2001 Andreas Vogl + * + * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + */ + +package cfeditor.gameobject; + +import cfeditor.CMainControl; +import cfeditor.IGUIConstants; +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import net.sf.gridarta.io.IOUtils; +import org.apache.log4j.Logger; +import org.jdom.DataConversionException; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; +import org.jetbrains.annotations.Nullable; + +/** + * The <code>ArchetypeParser</code> class handles the parsing of arches. It is + * a class separated from ArchetypeSet because it is also involved in + * loading arches in map files. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public final class ArchetypeParser implements net.sf.gridarta.gameobject.ArchetypeParser<GameObject> { + + /** Logger. */ + private static final Logger log = Logger.getLogger(ArchetypeParser.class); + + // name of the system-arch containing path of starting map + public static final String STARTARCH_NAME = "map"; + + // table with type numbers as keys (Integer), and type names as values (String) + private Map<Integer,String> archTypeNumbers; + + private final CMainControl mainControl; + + /** + * Constructor + * @param mainControl main control + */ + public ArchetypeParser(final CMainControl mainControl) { + this.mainControl = mainControl; + archTypeNumbers = null; + } + + /** + * Parse the typenumbers file (associate names with type numbers) + * Type numbers and names are stored as key-value pairs in the + * Hashtable 'archTypeNumbers'. + */ + public void loadTypeNumbers() { + archTypeNumbers = new HashMap<Integer,String>(); + + try { + // open reading stream to the spells xml file + final String baseDir = IGUIConstants.CONFIG_DIR; + final BufferedReader reader = IOUtils.createReader(baseDir, IGUIConstants.TYPENR_FILE); + try { + + // parse xml document + final SAXBuilder builder = new SAXBuilder(); + builder.setValidation(true); + final Document doc = builder.build(reader); + + // retrieve the spell data from the xml + final Element root = doc.getRootElement(); + if (root == null || !"typenumbers".equalsIgnoreCase(root.getName())) { + log.warn("File '" + IGUIConstants.TYPENR_FILE + "' lacks root element 'typenumbers'."); + } else { + final List types = root.getChildren("type"); + if (types == null || types.size() == 0) { + log.warn("File '" + IGUIConstants.TYPENR_FILE + "' has no content."); + } else { + // process all 'type' elements from the xml file + int i; + for (i = 0; i < types.size(); i++) { + final Element typeElem = (Element) types.get(i); + + if (typeElem.getAttribute("number") == null) { + log.warn("In File '" + IGUIConstants.TYPENR_FILE + "': Found 'type' element without 'number'"); + } else if (typeElem.getAttribute("name") == null) { + log.warn("In File '" + IGUIConstants.TYPENR_FILE + "': Found 'type' element without 'name'"); + } else { + try { + // parse type number and -name, then add it to the table 'archTypeNumbers' + archTypeNumbers.put(typeElem.getAttribute("number").getIntValue(), typeElem.getAttribute("name").getValue()); + } catch (final DataConversionException de) { + log.error("In '" + IGUIConstants.TYPENR_FILE + "':\n type number '" + typeElem.getAttribute("number").getValue() + "' is not an integer."); + } + } + } + + // loading successful + if (log.isInfoEnabled()) { + log.info("" + i + " typenumbers loaded."); + } + } + } + } finally { + reader.close(); + } + } catch (final JDOMException e) { + log.error("Parsing error in '" + IGUIConstants.TYPENR_FILE + "'", e); + } catch (final FileNotFoundException e) { + log.error("Cannot read file '" + IGUIConstants.TYPENR_FILE + "'!", e); + } catch (final IOException e) { + log.error("Error while reading file '" + IGUIConstants.TYPENR_FILE + "'!", e); + } + } + + /** + * Lookup the name of an archtype. + * @param index type number + * @return name of this type, as defined in "typenumbers.xml" + */ + public String getArchTypeName(final int index) { + if (archTypeNumbers != null && archTypeNumbers.containsKey(index)) { + return archTypeNumbers.get(index); + } + return "*UNKNOWN" + index + "*"; // this type is unknown + } + + /** {@inheritDoc} */ + public void parseArchetype(final String fname, final int index) { + //Open the file for reading + try { + final BufferedReader in = new BufferedReader(new FileReader(fname)); + try { + parseArchetypeFromStream(in, index, fname); + } finally { + in.close(); + } + } catch (final FileNotFoundException e) { + log.error("Archfile " + fname + " could not be found"); + } catch (final IOException e) { + log.error("IOException in parseDefArch!"); + } + } + + /** {@inheritDoc} */ + public void parseArchetypeFromStream(final BufferedReader in, final int index, final String fname) { + parseArchetypeFromStream(in, null, null, null, index, fname); + } + + /** {@inheritDoc} */ + @Nullable + public GameObject parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject archetype, final String line, final String archName, int index, final String fname) { + + //Open the file for reading + try { + + // start with new clean GameObject instance + GameObject arch; + GameObject archlast = null; + if (archetype == null) { + arch = new GameObject(); + } else { + arch = archetype.createClone(0, 0); + } + arch.resetObjectText(); + + String thisLine2; + if (line == null) { + thisLine2 = in.readLine(); + } else { + thisLine2 = line; // pre read "Object" from artifacts file loader + } + + boolean msgflag = false; + boolean loreflag = false; + boolean animflag = false; + boolean parsearch = false; + boolean archmore = false; + String oldCat = "<xxx>"; + boolean isNewCategory = true; + GameObject firstArch = null; + String newCat = "no category info"; + int archmoreCount = 0; + while (thisLine2 != null) { + final String thisLine = thisLine2.trim(); + + if (thisLine.startsWith("#")) { + // skip comments + thisLine2 = in.readLine(); + continue; + } + + if (!parsearch) { + + if (thisLine.startsWith("More")) { + if (firstArch == null) { + firstArch = archlast; + } + archmore = true; + } else if (thisLine.startsWith("Object")) { + if (arch == null) { + arch = new GameObject(); + } + + parsearch = true; + if (!archmore) { + firstArch = null; + } + + if (archName == null) { + arch.setArchetypeName(thisLine.substring(7)); + } else { + arch.setArchetypeName(archName); + } + } + } else { + if (msgflag) { + if (thisLine.startsWith("endmsg")) { + msgflag = false; + } else { + arch.addMsgText(thisLine2 + "\n"); // thisLine2 allows leading whitespaces + } + } else if (animflag) { + if (thisLine.startsWith("mina")) { + mainControl.getAnimationObject().addAnimObject(arch.getArchetypeName(), arch.getAnimText()); + + arch.addObjectText("animation " + arch.getArchetypeName() + "\n"); + // here we must add this to AnimationObject + // and add Animation cmd here! + animflag = false; + } else { + arch.addAnimText(thisLine + "\n"); + } + } else if (loreflag) { + if (thisLine.startsWith("endlore")) { + loreflag = false; + } else { + arch.addLoreText(thisLine + "\n"); + } + } else if (thisLine.startsWith("Object")) { + log.error("Find inventory Object in def arch: " + thisLine); + } else if (thisLine.startsWith("end")) { + //if (arch.getArchTypNr() == 0) { + if (log.isDebugEnabled()) { + log.debug("Arch " + arch.getArchetypeName() + " has no type info!"); + } + //} + // we got full arch + parsearch = false; // we write this sucker + + if (firstArch != null) { + // add to head our x/y position so he can setup refmax + firstArch.addTailPart(arch); + } else { + // add arch to the archpanel - only if it is not the map arch + if (!arch.getArchetypeName().equals(STARTARCH_NAME)) { + if (!mainControl.getArchetypeSet().isLoadedFromArchive() || archName != null) { + // loading from individual files, so we simply add it to list + // ArchetypeSet.loadArchFromFiles() takes care of the panels + mainControl.addArchPanelArch(arch.getArchetypeName(), index); + } else { + // loading from collected files, so we need process panels here + if (isNewCategory) { + String folder = newCat; // main folder of new category + if (newCat.indexOf("/") > 0) { + folder = newCat.substring(0, newCat.indexOf("/")); + } + + if (!oldCat.startsWith(folder)) { + // an entire new panel must be opened + mainControl.addArchPanel(folder); + mainControl.addArchPanelCombo("show all"); + mainControl.addArchPanelCombo(folder); + index = 1; + } + + if (newCat.indexOf("/") > 0) { + folder = newCat.substring(newCat.indexOf("/") + 1); + if (newCat.startsWith(folder)) { + index = 1; // add to the base folder + } else if (!oldCat.endsWith(folder)) { + // a new JComboBox must be added + index = mainControl.addArchPanelCombo(folder); + } + } else { + index = 1; // add to the base folder + } + + isNewCategory = false; + oldCat = newCat; + } + mainControl.addArchPanelArch(arch.getArchetypeName(), index); + } + } + } + postParseDefArch(arch); + mainControl.getArchetypeSet().addArchetype(arch); + + archmore = false; // we assume this is last... but perhaps.. + + // if this arch was from Artifacts file - return here: + if (archName != null) { + arch.setArtifact(true); + // here we add all unchanged arch text lines from defArch back to arch + arch.addObjectText(arch.diffArchText(archetype.getObjectText(), true)); + return arch; + } + archlast = arch; + arch = null; + } else { + if (thisLine.startsWith("msg")) { + msgflag = true; + } else if (thisLine.startsWith("animation")) { + arch.addObjectText(thisLine + "\n"); + } else if (thisLine.startsWith("anim_speed")) { + arch.addObjectText(thisLine + "\n"); + } else if (thisLine.startsWith("anim")) { + animflag = true; + } else if (thisLine.equals("lore")) { + loreflag = true; + } else if (thisLine.startsWith("visibility ")) { + if (log.isDebugEnabled()) { + log.debug("Remove visibility: " + arch.getArchetypeName()); + } + } else if (thisLine.startsWith("magicmap ")) { + if (log.isDebugEnabled()) { + log.debug("Remove magicmap: " + arch.getArchetypeName()); + } + } else if (thisLine.startsWith("color_fg ")) { + if (log.isDebugEnabled()) { + log.debug("Remove color_fg: " + arch.getArchetypeName()); + } + } else if (thisLine.startsWith("color_bg ")) { + if (log.isDebugEnabled()) { + log.debug("Remove color_bg: " + arch.getArchetypeName()); + } + } else if (thisLine.startsWith("x ")) { + if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { + log.warn("Find x cmd in single tile or head (add it to arch text): " + arch.getArchetypeName()); + arch.addObjectText(thisLine + "\n"); + } + arch.setMultiX(Integer.parseInt(thisLine.substring(2))); + } else if (thisLine.startsWith("y ")) { + if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { + log.warn("Find y cmd in single tile or head (add it to arch text): " + arch.getArchetypeName()); + arch.addObjectText(thisLine + "\n"); + } + arch.setMultiY(Integer.parseInt(thisLine.substring(2))); + } else if (thisLine.startsWith("type ")) { + try { + final int i = Integer.parseInt(thisLine.substring(5)); + arch.setArchTypNr(i); + if (i == 0) { + log.warn("Arch " + arch.getArchetypeName() + " type number is zero. (" + thisLine.substring(5) + ")"); + } + } catch (final Exception e) { + log.warn("Arch " + arch.getArchetypeName() + " has a invalid type nr. (" + thisLine.substring(5) + ")"); + arch.addObjectText(thisLine + "\n"); + } + } else if (thisLine.startsWith("face ")) { + int x; + for (x = 4; x < thisLine.length(); x++) { + if (thisLine.charAt(x) != ' ') { + break; + } + } + arch.setFaceFlag(false); // we HAVE a face + arch.setFaceName(thisLine.substring(x, thisLine.length())); + } else if (thisLine.startsWith("editor_folder ")) { + // the display category (= "folder" the arch belongs to) + newCat = thisLine.substring(14).trim(); + if (!newCat.equals(oldCat)) { + isNewCategory = true; // this arch has a new category + } + } + arch.addObjectText(thisLine + "\n"); + if (log.isDebugEnabled()) { + log.debug("add String: " + thisLine); + } + } + } + thisLine2 = in.readLine(); + } // while loop ends here + } catch (final IOException e) { + log.error("Error: ", e); + } + return null; + } + + /** {@inheritDoc} */ + public void postParseDefArch(final GameObject arch) { + final String text = arch.getObjectText(); + arch.resetObjectText(); + final int len = text.length(); + + // if no type was set, zero is taken + if (arch.getArchTypNr() == GameObject.TYPE_UNSET) { + arch.setArchTypNr(0); + } + + boolean scriptflag = false; + for (int i = 0, s = 0; i < len; i++) { + + if (text.charAt(i) == '\n') { + if (i - s > 0) { + if (scriptflag) { + arch.addObjectText(text.substring(s, i) + "\n"); + if (text.regionMatches(s, "end_script_", 0, 11)) { + scriptflag = false; + } + } else if (text.regionMatches(s, "start_script_", 0, 13)) { + arch.addObjectText(text.substring(s, i) + "\n"); + scriptflag = true; + } else if (text.regionMatches(s, "editable ", 0, 9)) { + arch.setEditType(Integer.parseInt(text.substring(s + 9, i))); + } else if (text.regionMatches(s, "name ", 0, 5)) { + arch.setObjName(text.substring(s + 5, i)); + } else { + arch.addObjectText(text.substring(s, i) + "\n"); + } + + } + s = i + 1; + } + } + + // default arches don't get an editType (not worth the time) + // they get one assigned as soon as put on a map though. + arch.setEditType(IGUIConstants.TILE_EDIT_NONE); + } + + /** {@inheritDoc} */ + public void postParseMapArch(final GameObject gameObject, final int editType) { + if (gameObject.getArchetypeName() == null) { + return; + } + + final String text = gameObject.getObjectText(); + final int len = text.length(); + final GameObject archetype = mainControl.getArchetype(gameObject.getArchetypeName()); + + gameObject.resetObjectText(); + for (int i = 0, s = 0; i < len; i++) { + + if (text.charAt(i) == '\n') { + if (i - s > 0) { + if (text.regionMatches(s, "name ", 0, 5)) { + gameObject.setObjName(text.substring(s + 5, i)); + } else { + // this is an unparsed arch attribute, it has to stay in the archtext + gameObject.addObjectText(text.substring(s, i) + "\n"); + } + } + s = i + 1; + } + } + // so, lets check the stuff a last time + + if (gameObject.getFaceName() == null) { + gameObject.setFaceNr(archetype.getFaceNr()); + gameObject.setFaceFlag(archetype.getFaceFlag()); + } + + // if the type is still unset, then we take the default one + if (gameObject.getArchTypNr() == GameObject.TYPE_UNSET) { + gameObject.setArchTypNr(archetype.getArchTypNr()); + } + + gameObject.setMultiX(archetype.getMultiX()); + gameObject.setMultiY(archetype.getMultiY()); + + // arch.setEditType(defarch.getEditType()); + + // validate the ScriptedEvents + gameObject.validateAllEvents(); + + // we don't handle anim yet, so attach then back to archtext + if (gameObject.getAnimText() != null) { + gameObject.addObjectText("anim\n"); + gameObject.addObjectText(gameObject.getAnimText()); + gameObject.addObjectText("mina\n"); + } + + // Finally, we calculate the desired editType of the arch + if (gameObject.isTail()) { + gameObject.setEditType(gameObject.getHead().getEditType()); // copy from head + } else if (editType != 0) { + gameObject.setEditType(gameObject.calculateEditType(editType)); // calculate new + } + } + + /** {@inheritDoc} */ + public void expandMulti(final GameObject gameObject, final List<GameObject> objects) { + // TODO: Couldn't we simply invoke archetype = gameObject.getArchetype() here? + final GameObject archetype = mainControl.getArchetype(gameObject.getArchetypeName()); + + // is it a multi head? + if (archetype != null && archetype.isMulti() && gameObject.getMultiRefCount() <= 1) { + // we have a multi head and need to insert his tail now + + // do insertion for all non-head parts of the multi + for (GameObject oldPart = archetype.getMultiNext(); oldPart != null; oldPart = oldPart.getMultiNext()) { + final GameObject newarch = oldPart.createArch(); + + gameObject.addTailPart(newarch); + objects.add(newarch); +... [truncated message content] |
From: <chr...@us...> - 2006-10-08 22:53:33
|
Revision: 505 http://svn.sourceforge.net/gridarta/?rev=505&view=rev Author: christianhujer Date: 2006-10-08 15:53:19 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Fixed some documentation bugs. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-08 22:39:14 UTC (rev 504) +++ trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-08 22:53:19 UTC (rev 505) @@ -151,11 +151,7 @@ return "*UNKNOWN" + index + "*"; // this type is unknown } - /** - * Read a default arch from a file. - * @param fname filename of the arch definition file (*.arc) - * @param index current subdirectory-index on the ArchPanel (-> ComboBoxes) - */ + /** {@inheritDoc} */ public void parseArchetype(final String fname, final int index) { //Open the file for reading try { @@ -172,6 +168,7 @@ } } + /** {@inheritDoc} */ public void parseArchetypeFromStream(final BufferedReader in, final int index, final String fname) { parseArchetypeFromStream(in, null, null, null, index, fname); } @@ -416,11 +413,7 @@ return null; } - /** - * I drop this here ... we got 2 functions now but i want the hardcore parsing - * cut off from load parsing - * @param arch default arch to be parsed - */ + /** {@inheritDoc} */ public void postParseDefArch(final GameObject arch) { final String text = arch.getObjectText(); arch.resetObjectText(); Modified: trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java 2006-10-08 22:39:14 UTC (rev 504) +++ trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java 2006-10-08 22:53:19 UTC (rev 505) @@ -68,11 +68,7 @@ this.mainControl = mainControl; } - /** - * Read a default arch from a file. - * @param fname filename of the arch definition file (*.arc) - * @param index current subdirectory-index on the ArchPanel (-> ComboBoxes) - */ + /** {@inheritDoc} */ public void parseArchetype(final String fname, final int index) { //Open the file for reading try { @@ -90,6 +86,7 @@ } } + /** {@inheritDoc} */ public void parseArchetypeFromStream(final BufferedReader in, final int index, final String fname) throws IOException { parseArchetypeFromStream(in, null, null, null, index, fname); } @@ -401,11 +398,7 @@ return null; } - /** - * I drop this here ... we got 2 functions now but i want the hardcore parsing - * cut off from load parsing - * @param arch default arch to be parsed - */ + /** {@inheritDoc} */ public void postParseDefArch(final GameObject arch) { final String text = arch.getObjectText(); arch.resetObjectText(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-08 22:39:40
|
Revision: 504 http://svn.sourceforge.net/gridarta/?rev=504&view=rev Author: christianhujer Date: 2006-10-08 15:39:14 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Captured ArchObjectParser similarities in a common interface. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CPickmapPanel.java trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMapArchPanel.java trunk/daimonin/src/daieditor/CMapFileDecode.java trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/ArchObjectParser.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-08 21:52:21 UTC (rev 503) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-08 22:39:14 UTC (rev 504) @@ -896,7 +896,7 @@ return null; } - ArchObjectParser.sortTempList(objects); // sort the list (put multiparts at the end) + archObjectParser.sortTempList(objects); // sort the list (put multiparts at the end) control = newLevel(objects, maparch, show, initial); // init the map if (show) { Modified: trunk/crossfire/src/cfeditor/CPickmapPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CPickmapPanel.java 2006-10-08 21:52:21 UTC (rev 503) +++ trunk/crossfire/src/cfeditor/CPickmapPanel.java 2006-10-08 22:39:14 UTC (rev 504) @@ -24,7 +24,6 @@ package cfeditor; -import cfeditor.gameobject.ArchObjectParser; import cfeditor.gameobject.GameObject; import cfeditor.map.MapArchObject; import cfeditor.map.MapControl; @@ -146,7 +145,7 @@ if (!mainControl.collectTempList(objects, mapFile)) { // get face names, face id, etc. return false; } - ArchObjectParser.sortTempList(objects); // sort the list (put multiparts at the end) + mainControl.getArchObjectParser().sortTempList(objects); // sort the list (put multiparts at the end) bmapview = newPickmap(objects, maparch, mapFile); // init the map } Modified: trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-08 21:52:21 UTC (rev 503) +++ trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-08 22:39:14 UTC (rev 504) @@ -52,7 +52,7 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public final class ArchObjectParser { +public final class ArchObjectParser implements net.sf.gridarta.gameobject.ArchObjectParser<GameObject> { /** Logger. */ private static final Logger log = Logger.getLogger(ArchObjectParser.class); @@ -156,12 +156,12 @@ * @param fname filename of the arch definition file (*.arc) * @param index current subdirectory-index on the ArchPanel (-> ComboBoxes) */ - public void parseDefArch(final String fname, final int index) { + public void parseArchetype(final String fname, final int index) { //Open the file for reading try { final BufferedReader in = new BufferedReader(new FileReader(fname)); try { - parseDefArchFromStream(in, index); + parseArchetypeFromStream(in, index, fname); } finally { in.close(); } @@ -172,21 +172,13 @@ } } - public void parseDefArchFromStream(final BufferedReader in, final int index) { - parseDefArchFromStream(in, null, null, null, index); + public void parseArchetypeFromStream(final BufferedReader in, final int index, final String fname) { + parseArchetypeFromStream(in, null, null, null, index, fname); } - /** - * Here we take a default arch from a filestream, parses the data and - * put the result on the arch stack in CMainControl. - * @param in <code>BufferedReader</code> file stream of arch data - * @param defArch default arch (only for artifacts) - * @param line first line, pre-parsed (only for artifacts) - * @param archName arch-object name (only for artifacts) - * @param index current index on the ArchPanel - */ + /** {@inheritDoc} */ @Nullable - public GameObject parseDefArchFromStream(final BufferedReader in, final GameObject defArch, final String line, final String archName, int index) { + public GameObject parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject archetype, final String line, final String archName, int index, final String fname) { //Open the file for reading try { @@ -194,10 +186,10 @@ // start with new clean GameObject instance GameObject arch; GameObject archlast = null; - if (defArch == null) { + if (archetype == null) { arch = new GameObject(); } else { - arch = defArch.createClone(0, 0); + arch = archetype.createClone(0, 0); } arch.resetObjectText(); @@ -339,7 +331,7 @@ if (archName != null) { arch.setArtifact(true); // here we add all unchanged arch text lines from defArch back to arch - arch.addObjectText(arch.diffArchText(defArch.getObjectText(), true)); + arch.addObjectText(arch.diffArchText(archetype.getObjectText(), true)); return arch; } archlast = arch; @@ -429,7 +421,7 @@ * cut off from load parsing * @param arch default arch to be parsed */ - public static void postParseDefArch(final GameObject arch) { + public void postParseDefArch(final GameObject arch) { final String text = arch.getObjectText(); arch.resetObjectText(); final int len = text.length(); @@ -470,25 +462,7 @@ arch.setEditType(IGUIConstants.TILE_EDIT_NONE); } - /** - * Here we go... thats the hard one - * we copy the needed values from default arch to map arch - * we setup the panels to show the right values - * <p/> - * first: the anim list... we want handle this later so we ignore this yet - * and let it in the arch text windows for handwork - * <p/> - * 2nd: msg/msgend - * we had in the map a msg/msgend cmd or not - * because we init our msg buffer only when one cmd come in - * we have a null-ptr or a text - * if text, this will overrule ALWAYS the default text - * if null, copy the default text in arch, so the user can see and edit it - * if at save time msg-maparch == msg-default, we ignore it - * in every other case (even "" text) we save - * @param gameObject map arch to be parsed - * @param editType edit type(s) to be calculated for the arch - */ + /** {@inheritDoc} */ public void postParseMapArch(final GameObject gameObject, final int editType) { if (gameObject.getArchetypeName() == null) { return; @@ -548,16 +522,10 @@ } } - /** - * If the given arch is a multipart head, we generate the appropriate - * tail (from the arch stack) and attach it. The new arches get added - * to the temp list, not a map. This method should only be called - * after map-loading. - * The ArchetypeSet should be fully initialized at this point. - * @param gameObject multipart head that needs tail attached - */ + /** {@inheritDoc} */ public void expandMulti(final GameObject gameObject, final List<GameObject> objects) { - final GameObject archetype = mainControl.getArchetype(gameObject.getArchetypeName()); // default arch + // TODO: Couldn't we simply invoke archetype = gameObject.getArchetype() here? + final GameObject archetype = mainControl.getArchetype(gameObject.getArchetypeName()); // is it a multi head? if (archetype != null && archetype.isMulti() && gameObject.getMultiRefCount() <= 1) { @@ -581,15 +549,10 @@ } } - /** - * Sort the temp list of arches, placing all multiparts at the end. - * This is neccessary to assure multiparts are always on top. - * @param objects list of objects - * @note This method assumes that all pieces of one multipart are listed in - * a row, which is okay as long as the loader puts it that way. - */ - public static void sortTempList(final List<GameObject> objects) { + /** {@inheritDoc} */ + public void sortTempList(final List<GameObject> objects) { final Comparator<GameObject> sorter = new Comparator<GameObject>() { + /** {@inheritDoc} */ public int compare(final GameObject o1, final GameObject o2) { final boolean b1 = o1.isMulti(); final boolean b2 = o2.isMulti(); Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-08 21:52:21 UTC (rev 503) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-08 22:39:14 UTC (rev 504) @@ -193,7 +193,7 @@ final BufferedReader stream = IOUtils.createReader(IGUIConstants.CONFIG_DIR, IGUIConstants.ARCH_FILE); try { // load all arches - mainControl.getArchObjectParser().parseDefArchFromStream(stream, 0); + mainControl.getArchObjectParser().parseArchetypeFromStream(stream, 0, null); } finally { // close filestream stream.close(); @@ -251,7 +251,7 @@ if ((len = name.length()) >= 4) { if (name.regionMatches(len - 4, ".arc", 0, 4)) { //CMainStatusbar.getInstance().setText(" Loading Arch: "+name); - mainControl.getArchObjectParser().parseDefArch(f.getAbsolutePath(), index); + mainControl.getArchObjectParser().parseArchetype(f.getAbsolutePath(), index); } else if (name.regionMatches(len - 4, ".png", 0, 4)) { //CMainStatusbar.getInstance().setText(" Loading PNG: "+name); if (mainControl.getImageSet() == null || name.indexOf("." + mainControl.getImageSet() + ".") != -1) { Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-10-08 21:52:21 UTC (rev 503) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-10-08 22:39:14 UTC (rev 504) @@ -1275,7 +1275,7 @@ // Ok, now is attached to default arch and loaded png // NOW we post parse the object... // (We calculate only edit types that are active, to save time) - ArchObjectParser.postParseMapArch(gameObject, tileEdit); + archObjectParser.postParseMapArch(gameObject, tileEdit); // now lets assign the visible face - perhaps we have still a anim gameObject.setObjectFace(); Modified: trunk/daimonin/src/daieditor/CMapArchPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-10-08 21:52:21 UTC (rev 503) +++ trunk/daimonin/src/daieditor/CMapArchPanel.java 2006-10-08 22:39:14 UTC (rev 504) @@ -24,7 +24,6 @@ package daieditor; -import daieditor.gameobject.ArchObjectParser; import daieditor.gameobject.GameObject; import daieditor.gui.ConnectionView; import daieditor.gui.ErrorListView; @@ -303,7 +302,7 @@ } invnew.setDirection(invnew.getArchetype().getDirection()); - ArchObjectParser.postParseMapArch(invnew, 0); + mainControl.getArchObjectParser().postParseMapArch(invnew, 0); inv.addLast(invnew); invnew.setObjectFace(); mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), inv); Modified: trunk/daimonin/src/daieditor/CMapFileDecode.java =================================================================== --- trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-10-08 21:52:21 UTC (rev 503) +++ trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-10-08 22:39:14 UTC (rev 504) @@ -24,7 +24,6 @@ package daieditor; -import daieditor.gameobject.ArchObjectParser; import daieditor.gameobject.GameObject; import daieditor.map.MapArchObject; import java.io.BufferedReader; @@ -97,7 +96,7 @@ readArch(myInput, thisLine); // all these are map arches } CMainControl.getInstance().collectTempList(objects, file); - ArchObjectParser.sortTempList(objects); + CMainControl.getInstance().getArchObjectParser().sortTempList(objects); return objects; // return first arch of the list } finally { objects = null; Modified: trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java 2006-10-08 21:52:21 UTC (rev 503) +++ trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java 2006-10-08 22:39:14 UTC (rev 504) @@ -50,7 +50,7 @@ * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public final class ArchObjectParser { +public final class ArchObjectParser implements net.sf.gridarta.gameobject.ArchObjectParser<GameObject> { /** Logger. */ private static final Logger log = Logger.getLogger("daieditor"); @@ -73,13 +73,13 @@ * @param fname filename of the arch definition file (*.arc) * @param index current subdirectory-index on the ArchPanel (-> ComboBoxes) */ - public void parseDefArch(final String fname, final int index) { + public void parseArchetype(final String fname, final int index) { //Open the file for reading try { final BufferedReader in = new BufferedReader(new FileReader(fname)); try { // do the actual parsing - parseDefArchFromStream(in, index, fname); + parseArchetypeFromStream(in, index, fname); } finally { in.close(); } @@ -90,30 +90,20 @@ } } - public void parseDefArchFromStream(final BufferedReader in, final int index, final String fname) throws IOException { - parseDefArchFromStream(in, null, null, null, index, fname); + public void parseArchetypeFromStream(final BufferedReader in, final int index, final String fname) throws IOException { + parseArchetypeFromStream(in, null, null, null, index, fname); } - /** - * Here we take a default arch from a filestream, parses the data and - * put the result on the arch stack in CMainControl. - * @param in <code>BufferedReader</code> file stream of arch data - * @param defArch default arch (only for artifacts) - * @param line first line, pre-parsed (only for artifacts) - * @param archName arch-object name (only for artifacts) - * @param index current index on the ArchPanel - * @return TODO - * @throws IOException in case of I/O problems - */ + /** {@inheritDoc} */ @Nullable @SuppressWarnings({"StringContatenationInLoop", "ObjectAllocationInLoop"}) - public GameObject parseDefArchFromStream(final BufferedReader in, @Nullable final GameObject defArch, @Nullable final String line, @Nullable final String archName, /* TODO: final*/ int index, final String fname) throws IOException { + public GameObject parseArchetypeFromStream(final BufferedReader in, @Nullable final GameObject archetype, @Nullable final String line, @Nullable final String archName, /* TODO: final*/ int index, final String fname) throws IOException { // start with new clean GameObject instance GameObject arch; GameObject archlast = null; - if (defArch == null) { + if (archetype == null) { arch = new GameObject(); } else { - arch = defArch.createClone(0, 0); + arch = archetype.createClone(0, 0); } String newCat; final boolean isInternPath; @@ -304,8 +294,8 @@ if (archName != null) { arch.setArtifact(true); // here we add all unchanged arch text lines from defArch back to arch - if (defArch != null) { - arch.addObjectText(arch.diffArchText(defArch.getObjectText(), true)); + if (archetype != null) { + arch.addObjectText(arch.diffArchText(archetype.getObjectText(), true)); } return arch; } @@ -416,7 +406,7 @@ * cut off from load parsing * @param arch default arch to be parsed */ - public static void postParseDefArch(final GameObject arch) { + public void postParseDefArch(final GameObject arch) { final String text = arch.getObjectText(); arch.resetObjectText(); final int len = text.length(); @@ -458,119 +448,94 @@ arch.setEditType(IGUIConstants.TILE_EDIT_NONE); } - /** - * Here we go... thats the hard one - * we copy the needed values from default arch to map arch - * we setup the panels to show the right values - * <p/> - * first: the anim list... we want handle this later so we ignore this yet - * and let it in the arch text windows for handwork - * <p/> - * 2nd: msg/msgend - * we had in the map a msg/msgend cmd or not - * because we init our msg buffer only when one cmd come in - * we have a null-ptr or a text - * if text, this will overrule ALWAYS the default text - * if null, copy the default text in arch, so the user can see and edit it - * if at save time msg-maparch == msg-default, we ignore it - * in every other case (even "" text) we save - * @param arch map arch to be parsed - * @param editType edit type(s) to be calculated for the arch - */ - public static void postParseMapArch(final GameObject arch, final int editType) { - if (!arch.hasArchetype()) { + /** {@inheritDoc} */ + public void postParseMapArch(final GameObject gameObject, final int editType) { + if (!gameObject.hasArchetype()) { return; } - final String text = arch.getObjectText(); + final String text = gameObject.getObjectText(); final int len = text.length(); - final GameObject defarch = arch.getArchetype(); + final GameObject defarch = gameObject.getArchetype(); - arch.resetObjectText(); + gameObject.resetObjectText(); // so, lets check the stuff a last time for (int i = 0, s = 0; i < len; i++) { if (text.charAt(i) == '\n') { if (i - s > 0) { if (text.regionMatches(s, "animation ", 0, 9)) { - arch.setAnimName(text.substring(s + 10, i)); - arch.addObjectText(text.substring(s, i) + "\n"); + gameObject.setAnimName(text.substring(s + 10, i)); + gameObject.addObjectText(text.substring(s, i) + "\n"); } else if (text.regionMatches(s, "name ", 0, 5)) { - arch.setObjName(text.substring(s + 5, i)); + gameObject.setObjName(text.substring(s + 5, i)); } else { // this is an unparsed arch attribute, it has to stay in the archtext - arch.addObjectText(text.substring(s, i) + "\n"); + gameObject.addObjectText(text.substring(s, i) + "\n"); } } s = i + 1; } } - if (arch.getDirection() == -1) { // still the invalid direction! - arch.setDirection(defarch.getDirection()); + if (gameObject.getDirection() == -1) { // still the invalid direction! + gameObject.setDirection(defarch.getDirection()); } - arch.setRealFace(arch.getFaceRealName()); + gameObject.setRealFace(gameObject.getFaceRealName()); // if the type is still unset, then we take the default one - if (arch.getArchTypNr() == GameObject.TYPE_UNSET) { - arch.setArchTypNr(defarch.getArchTypNr()); + if (gameObject.getArchTypNr() == GameObject.TYPE_UNSET) { + gameObject.setArchTypNr(defarch.getArchTypNr()); } // if the type is still unset, then we take the default one - if (defarch.getMultiShapeID() > 0 && arch.getMultiShapeID() == 0) { - arch.setMultiShapeID(defarch.getMultiShapeID()); + if (defarch.getMultiShapeID() > 0 && gameObject.getMultiShapeID() == 0) { + gameObject.setMultiShapeID(defarch.getMultiShapeID()); } - if (defarch.getMultiPartNr() > 0 && arch.getMultiPartNr() == 0) { - arch.setMultiPartNr(defarch.getMultiPartNr()); + if (defarch.getMultiPartNr() > 0 && gameObject.getMultiPartNr() == 0) { + gameObject.setMultiPartNr(defarch.getMultiPartNr()); } if (defarch.isLowestPart()) { - arch.setLowestPart(true); + gameObject.setLowestPart(true); } - arch.setMultiX(defarch.getMultiX()); - arch.setMultiY(defarch.getMultiY()); + gameObject.setMultiX(defarch.getMultiX()); + gameObject.setMultiY(defarch.getMultiY()); // arch.setEditType(defarch.getEditType()); // validate the ScriptedEvents - arch.validateAllEvents(); + gameObject.validateAllEvents(); // Finally, we calculate the desired editType of the arch - if (arch.isTail()) { - arch.setEditType(arch.getHead().getEditType()); // copy from head + if (gameObject.isTail()) { + gameObject.setEditType(gameObject.getHead().getEditType()); // copy from head } else if (editType != 0) { - arch.setEditType(arch.calculateEditType(editType)); // calculate new + gameObject.setEditType(gameObject.calculateEditType(editType)); // calculate new } } - /** - * If the given arch is a multipart head, we generate the appropriate - * tail (from the arch stack) and attach it. The new arches get added - * to the temp list, not a map. This method should only be called - * after map-loading. - * The ArchetypeSet should be fully initialized at this point. - * @param arch multipart head that needs tail attached - */ - public void expandMulti(final GameObject arch, final List<GameObject> objects) { + /** {@inheritDoc} */ + public void expandMulti(final GameObject gameObject, final List<GameObject> objects) { - if (arch.isInContainer()) { + if (gameObject.isInContainer()) { return; } - final GameObject defarch = arch.getArchetype(); // default arch + final GameObject archetype = gameObject.getArchetype(); // default arch // is it a multi head? - if (defarch != null && defarch.isMulti() && arch.getMultiRefCount() <= 1) { + if (archetype != null && archetype.isMulti() && gameObject.getMultiRefCount() <= 1) { // we have a multi head and need to insert his tail now // do insertion for all non-head parts of the multi - for (GameObject oldPart = defarch.getMultiNext(); oldPart != null; oldPart = oldPart.getMultiNext()) { + for (GameObject oldPart = archetype.getMultiNext(); oldPart != null; oldPart = oldPart.getMultiNext()) { final GameObject newarch = oldPart.createArch(); - arch.addTailPart(newarch); + gameObject.addTailPart(newarch); objects.add(newarch); // set map position (x, y) - newarch.setMapX(arch.getMapX() + newarch.getMultiX()); - newarch.setMapY(arch.getMapY() + newarch.getMultiY()); + newarch.setMapX(gameObject.getMapX() + newarch.getMultiX()); + newarch.setMapY(gameObject.getMapY() + newarch.getMultiY()); // now attach the default arch and stuff // (don't need edit type as we copy from head) @@ -579,15 +544,10 @@ } } - /** - * Sort the temp list of arches, placing all multiparts at the end. - * This is neccessary to assure multiparts are always on top. - * @param objects list of objects - * @note This method assumes that all pieces of one multipart are listed in - * a row, which is okay as long as the loader puts it that way. - */ - public static void sortTempList(final List<GameObject> objects) { + /** {@inheritDoc} */ + public void sortTempList(final List<GameObject> objects) { final Comparator<GameObject> sorter = new Comparator<GameObject>() { + /** {@inheritDoc} */ public int compare(final GameObject o1, final GameObject o2) { final boolean b1 = o1.isMulti(); final boolean b2 = o2.isMulti(); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-08 21:52:21 UTC (rev 503) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-08 22:39:14 UTC (rev 504) @@ -263,7 +263,7 @@ // now the editor will do the same as the real server: // get the default arch as base and parse the new values over it // the extended functions of the artifacts file can be ignored here. - mainControl.getArchObjectParser().parseDefArchFromStream(myInput, editorCode == 2 ? null : archetype, thisLine, name, 0, fname); + mainControl.getArchObjectParser().parseArchetypeFromStream(myInput, editorCode == 2 ? null : archetype, thisLine, name, 0, fname); // note: in the parser is a small part where we handle the title setting // and the reverse type setting for type == -1 (unique items marker in artifacts file) } else { @@ -300,7 +300,7 @@ final BufferedReader stream = IOUtils.createReader(baseDir, IGUIConstants.ARCH_FILE); try { // load all arches - mainControl.getArchObjectParser().parseDefArchFromStream(stream, 0, IGUIConstants.ARCH_FILE); + mainControl.getArchObjectParser().parseArchetypeFromStream(stream, 0, IGUIConstants.ARCH_FILE); mainControl.getFaceObjects().loadFacesCollection( new File(mainControl.getArchDefaultFolder(), IGUIConstants.PNG_FILE), new File(new File(mainControl.getArchDefaultFolder(), IGUIConstants.CONFIG_DIR), IGUIConstants.FACETREE_FILE) @@ -372,7 +372,7 @@ if (name.endsWith(".arc")) { //CMainStatusbar.getInstance().setText(" Loading Arch: "+ name); currentFile = f; - mainControl.getArchObjectParser().parseDefArch(f.getPath(), index); + mainControl.getArchObjectParser().parseArchetype(f.getPath(), index); } else if (name.endsWith(".png")) { //CMainStatusbar.getInstance().setText(" Loading PNG: "+ name); addPNGFace(f.getAbsolutePath(), name); Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-10-08 21:52:21 UTC (rev 503) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-10-08 22:39:14 UTC (rev 504) @@ -28,7 +28,6 @@ import daieditor.CFArchTypeList; import daieditor.CMainControl; import daieditor.IGUIConstants; -import daieditor.gameobject.ArchObjectParser; import daieditor.gameobject.GameObject; import java.awt.Point; import java.awt.Toolkit; @@ -271,7 +270,7 @@ mapGrid[pos.x][pos.y].addLast(head); } head.setDirection(defaultArch.getDirection()); - ArchObjectParser.postParseMapArch(head, mapControl.getActiveEditType()); + mainControl.getArchObjectParser().postParseMapArch(head, mapControl.getActiveEditType()); head.setObjectFace(); for (GameObject tailArch = defaultArch.getMultiNext(); tailArch != null; tailArch = tailArch.getMultiNext()) { final Point posT = new Point(tailArch.getMultiX(), tailArch.getMultiY()); @@ -287,7 +286,7 @@ mapGrid[posT.x][posT.y].addLast(tail); } tail.setDirection(tailArch.getDirection()); - ArchObjectParser.postParseMapArch(tail, mapControl.getActiveEditType()); + mainControl.getArchObjectParser().postParseMapArch(tail, mapControl.getActiveEditType()); tail.setObjectFace(); } return true; @@ -357,7 +356,7 @@ next.getContainer().addLast(invnew); invnew.setObjectFace(); - ArchObjectParser.postParseMapArch(invnew, mapControl.getActiveEditType()); + mainControl.getArchObjectParser().postParseMapArch(invnew, mapControl.getActiveEditType()); mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), invnew); return true; } Added: trunk/src/app/net/sf/gridarta/gameobject/ArchObjectParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/ArchObjectParser.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/ArchObjectParser.java 2006-10-08 22:39:14 UTC (rev 504) @@ -0,0 +1,95 @@ +package net.sf.gridarta.gameobject; + +import java.util.List; +import java.io.BufferedReader; +import java.io.IOException; +import org.jetbrains.annotations.Nullable; + +/** + * Common interface for ArchObjectParsers. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface ArchObjectParser<G extends GameObject<G>> { + + /** + * If the given arch is a multipart head, we generate the appropriate + * tail (from the arch stack) and attach it. The new arches get added + * to the temp list, not a map. This method should only be called + * after map-loading. + * The ArchetypeSet should be fully initialized at this point. + * @param gameObject multipart head that needs tail attached + * @param objects list with objects that should get the tails attached + * @todo think whether expanding multiparts here is a good idea, maybe MapModel is a better place. + */ + void expandMulti(G gameObject, List<G> objects); + + /** + * Read an Archetype from a file. + * @param fname filename of the arch definition file (*.arc) + * @param index current subdirectory-index on the ArchPanel (-> ComboBoxes) + */ + void parseArchetype(String fname, int index); + + /** + * Here we read an Archetype from a filestream, parse the data and + * put the result in the ArchetypeSet in CMainControl. + * @param in <code>BufferedReader</code> file stream of arch data + * @param archetype Archetype (only for artifacts) + * @param line first line, pre-parsed (only for artifacts) + * @param archName arch-object name (only for artifacts) + * @param index current index on the ArchPanel + * @param fname filename of the Archetype + * @return TODO + * @throws IOException in case of I/O problems + */ + GameObject parseArchetypeFromStream(BufferedReader in, @Nullable G archetype, @Nullable String line, @Nullable String archName, int index, String fname) throws IOException; + + /** + * Short form of {@link #parseArchetypeFromStream(BufferedReader, GameObject, String, String, int, String)}. + * @param in <code>BufferedReader</code> file stream of arch data + * @param index current index on the ArchPanel + * @param fname filename of the Archetype + * @throws IOException in case of I/O problems + */ + void parseArchetypeFromStream(BufferedReader in, int index, String fname) throws IOException; + + /** + * I drop this here ... we got 2 functions now but i want the hardcore parsing + * cut off from load parsing + * @param arch default arch to be parsed + * @todo improve this stupid comment + */ + void postParseDefArch(G arch); + + /** + * Here we go... thats the hard one + * we copy the needed values from default arch to map arch + * we setup the panels to show the right values + * <p/> + * first: the anim list... we want handle this later so we ignore this yet + * and let it in the arch text windows for handwork + * <p/> + * 2nd: msg/msgend + * we had in the map a msg/msgend cmd or not + * because we init our msg buffer only when one cmd come in + * we have a null-ptr or a text + * if text, this will overrule ALWAYS the default text + * if null, copy the default text in arch, so the user can see and edit it + * if at save time msg-maparch == msg-default, we ignore it + * in every other case (even "" text) we save + * @param gameObject map arch to be parsed + * @param editType edit type(s) to be calculated for the arch + * @todo improve this stupid comment + */ + void postParseMapArch(G gameObject, int editType); + + /** + * Sort the temp list of arches, placing all multiparts at the end. + * This is neccessary to assure multiparts are always on top. + * @param objects list of objects + * @note This method assumes that all pieces of one multipart are listed in + * a row, which is okay as long as the loader puts it that way. + */ + void sortTempList(List<G> objects); + +} // interface ArchObjectParser Property changes on: trunk/src/app/net/sf/gridarta/gameobject/ArchObjectParser.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-08 21:52:26
|
Revision: 503 http://svn.sourceforge.net/gridarta/?rev=503&view=rev Author: christianhujer Date: 2006-10-08 14:52:21 -0700 (Sun, 08 Oct 2006) Log Message: ----------- CMainControl extended JFrame for no good - changed. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-08 21:50:03 UTC (rev 502) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-08 21:52:21 UTC (rev 503) @@ -45,7 +45,6 @@ import java.util.Vector; import javax.swing.ImageIcon; import javax.swing.JFileChooser; -import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JViewport; import javax.swing.SwingUtilities; @@ -68,7 +67,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> */ -public final class CMainControl extends JFrame implements MainControl { +public final class CMainControl implements MainControl { /** ActionFactory. */ private static final ActionFactory ACTION_FACTORY = getFactory("cfeditor"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-08 21:50:26
|
Revision: 502 http://svn.sourceforge.net/gridarta/?rev=502&view=rev Author: christianhujer Date: 2006-10-08 14:50:03 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Some MainControl unification regarding arch/gui handling. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CArchPanel.java trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/CArchPanel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/crossfire/src/cfeditor/CArchPanel.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanel.java 2006-10-08 19:45:30 UTC (rev 501) +++ trunk/crossfire/src/cfeditor/CArchPanel.java 2006-10-08 21:50:03 UTC (rev 502) @@ -163,13 +163,13 @@ selectedPanel.addArchPanelArch(archname, index); } - public void disableTabPane() { - tabDesktop.setEnabled(false); - } - - public void enableTabPane() { - tabDesktop.setEnabled(true); - if (selectedPanel != null) { + /** + * Sets the enabled state of the tab pane for Archetypes. + * @param tabPaneEnabled <code>true</code> to enable tab pane, <code>false</code> to disable it. + */ + public void setTabPaneEnabled(final boolean tabPaneEnabled) { + tabDesktop.setEnabled(tabPaneEnabled); + if (tabPaneEnabled && selectedPanel != null) { selectedPanel.showArchList(); } } Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-08 19:45:30 UTC (rev 501) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-10-08 21:50:03 UTC (rev 502) @@ -521,18 +521,17 @@ return mainView; } + /** {@inheritDoc} */ + @Deprecated public void setTabPaneEnabled(final boolean tabPaneEnabled) { + mainView.setTabPaneEnabled(tabPaneEnabled); + } + + /** {@inheritDoc} */ public void addArchPanel(final String name) { mainView.addArchPanel(name); } - public void disableTabPane() { - mainView.disableTabPane(); - } - - public void enableTabPane() { - mainView.enableTabPane(); - } - + /** {@inheritDoc} */ public int addArchPanelCombo(final String name) { return mainView.addArchPanelCombo(name); } Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-10-08 19:45:30 UTC (rev 501) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-10-08 21:50:03 UTC (rev 502) @@ -357,14 +357,14 @@ archPanel.addPanel(name); } - public void disableTabPane() { - archPanel.disableTabPane(); + /** + * Sets the enabled state of the tab pane for Archetypes. + * @param tabPaneEnabled <code>true</code> to enable tab pane, <code>false</code> to disable it. + */ + public void setTabPaneEnabled(final boolean tabPaneEnabled) { + archPanel.setTabPaneEnabled(tabPaneEnabled); } - public void enableTabPane() { - archPanel.enableTabPane(); - } - public int addArchPanelCombo(final String name) { return archPanel.addArchPanelCombo(name); } Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-08 19:45:30 UTC (rev 501) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-08 21:50:03 UTC (rev 502) @@ -137,7 +137,7 @@ // load object from a arch file you found final File f = new File(mainControl.getArchDefaultFolder()); folderLevel = 0; - mainControl.disableTabPane(); + mainControl.setTabPaneEnabled(false); // here we go... if (mainControl.isArchLoadedFromCollection()) { @@ -148,7 +148,7 @@ CMainStatusbar.getInstance().setText(" Sorting..."); connectFaces(); // attach faces to arches - mainControl.enableTabPane(); + mainControl.setTabPaneEnabled(true); mainControl.getMainView().finishArchPanelBuildProccess(); System.gc(); Modified: trunk/daimonin/src/daieditor/CArchPanel.java =================================================================== --- trunk/daimonin/src/daieditor/CArchPanel.java 2006-10-08 19:45:30 UTC (rev 501) +++ trunk/daimonin/src/daieditor/CArchPanel.java 2006-10-08 21:50:03 UTC (rev 502) @@ -148,13 +148,13 @@ selectedPanel.addArchPanelArch(archname, index); } - public void disableTabPane() { - tabDesktop.setEnabled(false); - } - - public void enableTabPane() { - tabDesktop.setEnabled(true); - if (selectedPanel != null) { + /** + * Sets the enabled state of the tab pane for Archetypes. + * @param tabPaneEnabled <code>true</code> to enable tab pane, <code>false</code> to disable it. + */ + public void setTabPaneEnabled(final boolean tabPaneEnabled) { + tabDesktop.setEnabled(tabPaneEnabled); + if (tabPaneEnabled && selectedPanel != null) { selectedPanel.showArchList(); } } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-10-08 19:45:30 UTC (rev 501) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-10-08 21:50:03 UTC (rev 502) @@ -795,18 +795,17 @@ return mainView; } + /** {@inheritDoc} */ + @Deprecated public void setTabPaneEnabled(final boolean tabPaneEnabled) { + mainView.setTabPaneEnabled(tabPaneEnabled); + } + + /** {@inheritDoc} */ public void addArchPanel(final String name) { mainView.addArchPanel(name); } - public void disableTabPane() { - mainView.disableTabPane(); - } - - public void enableTabPane() { - mainView.enableTabPane(); - } - + /** {@inheritDoc} */ public int addArchPanelCombo(final String name) { return mainView.addArchPanelCombo(name); } Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-10-08 19:45:30 UTC (rev 501) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-10-08 21:50:03 UTC (rev 502) @@ -363,14 +363,14 @@ archPanel.addPanel(name); } - public void disableTabPane() { - archPanel.disableTabPane(); + /** + * Sets the enabled state of the tab pane for Archetypes. + * @param tabPaneEnabled <code>true</code> to enable tab pane, <code>false</code> to disable it. + */ + public void setTabPaneEnabled(final boolean tabPaneEnabled) { + archPanel.setTabPaneEnabled(tabPaneEnabled); } - public void enableTabPane() { - archPanel.enableTabPane(); - } - public int addArchPanelCombo(final String name) { return archPanel.addArchPanelCombo(name); } Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-08 19:45:30 UTC (rev 501) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-08 21:50:03 UTC (rev 502) @@ -138,7 +138,7 @@ // browse arch archive // load object from a arch file you found folderLevel = 0; - mainControl.disableTabPane(); + mainControl.setTabPaneEnabled(false); // here we go... if (mainControl.isArchLoadedFromCollection()) { @@ -156,7 +156,7 @@ loadArchesFromArtifacts(mainControl.getArchDefaultFolder() + File.separator + IGUIConstants.ARTIFACTS_FILE); loadArchesFromArtifacts(mainControl.getMapDefaultFolder()); - mainControl.enableTabPane(); + mainControl.setTabPaneEnabled(true); mainControl.setStatusText(" Sorting..."); connectFaces(); // attach faces to arches Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2006-10-08 19:45:30 UTC (rev 501) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2006-10-08 21:50:03 UTC (rev 502) @@ -2,6 +2,7 @@ import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gameobject.ArchetypeSet; +import org.jetbrains.annotations.NotNull; /** * This interface is only for unification. @@ -43,4 +44,38 @@ */ ArchetypeSet getArchetypeSet(); + /** + * Get the ArchObjectParser that parsers Archetypes. + * @return ArchObjectParser + */ + Object getArchObjectParser(); + + /** + * Returns the MainView of this MainControl. + * @return The MainView of this MainControl. + */ + Object getMainView(); + + /** + * Sets the enabled state of the tab pane for Archetypes. + * @param tabPaneEnabled <code>true</code> to enable tab pane, <code>false</code> to disable it. + * @deprecated this should be done via MVC instead. + */ + @Deprecated void setTabPaneEnabled(boolean tabPaneEnabled); + + /** + * Add a new ArchPanel. + * @param name Name of the new ArchPanel. + * @deprecated this has nothing to do with MainControl and should be refactored + */ + @Deprecated void addArchPanel(@NotNull String name); + + /** + * Add a new ArchPanelCombo. + * @param name Name of the new Combo. + * @return some index TODO document this + * @deprecated this has nothing to do with MainControl and should be refactored + */ + @Deprecated int addArchPanelCombo(@NotNull String name); + } // interface MainControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-08 19:45:39
|
Revision: 501 http://svn.sourceforge.net/gridarta/?rev=501&view=rev Author: christianhujer Date: 2006-10-08 12:45:30 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Cosmetic. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainView.java trunk/daimonin/src/daieditor/CMainView.java Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-10-08 19:40:41 UTC (rev 500) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-10-08 19:45:30 UTC (rev 501) @@ -359,7 +359,6 @@ public void disableTabPane() { archPanel.disableTabPane(); - } public void enableTabPane() { Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-10-08 19:40:41 UTC (rev 500) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-10-08 19:45:30 UTC (rev 501) @@ -24,7 +24,6 @@ package daieditor; -import daieditor.gameobject.ArchetypeSet; import daieditor.gameobject.GameObject; import daieditor.gui.AboutDialog; import daieditor.map.MapControl; @@ -366,7 +365,6 @@ public void disableTabPane() { archPanel.disableTabPane(); - } public void enableTabPane() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-08 19:40:46
|
Revision: 500 http://svn.sourceforge.net/gridarta/?rev=500&view=rev Author: christianhujer Date: 2006-10-08 12:40:41 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Fixed return type of MainControl.getArchetypeSet now that we have that interface. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/MainControl.java Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2006-10-08 19:26:22 UTC (rev 499) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2006-10-08 19:40:41 UTC (rev 500) @@ -1,6 +1,7 @@ package net.sf.gridarta; import javax.swing.filechooser.FileFilter; +import net.sf.gridarta.gameobject.ArchetypeSet; /** * This interface is only for unification. @@ -40,6 +41,6 @@ * Get the ArchetypeSet for the available Archetypes. * @return ArchetypeSet */ - Object getArchetypeSet(); + ArchetypeSet getArchetypeSet(); } // interface MainControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-08 19:26:32
|
Revision: 499 http://svn.sourceforge.net/gridarta/?rev=499&view=rev Author: christianhujer Date: 2006-10-08 12:26:22 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Minor improvements on ArchetypeSet implementations: No need to redirect Archetype queries to CMainControl - we ARE the ArchetypeSet. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-08 19:04:27 UTC (rev 498) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-08 19:26:22 UTC (rev 499) @@ -534,7 +534,7 @@ CMainStatusbar.getInstance().setText("Collect Archfile: write archetypes"); // open the process bar - final CollectProgressBar pbar = new CollectProgressBar(mainControl.getArchetypeSet().getArchetypeCount(), + final CollectProgressBar pbar = new CollectProgressBar(getArchetypeCount(), "Collecting Archetypes..."); File dfile; @@ -570,7 +570,7 @@ // process every arch in this panel for (int i = 0; i < numList.length; i++) { - archetype = mainControl.getArchetype(numList[i]); + archetype = getArchetype(numList[i]); if (archetype.isTail()) { log.error("Collect Error: Multipart Tail in Panel found!"); @@ -648,7 +648,7 @@ } // finally we need to get the "map"-arch, which is not in the panels - final GameObject maparch = mainControl.getArchetype(ArchObjectParser.STARTARCH_NAME); + final GameObject maparch = getArchetype(ArchObjectParser.STARTARCH_NAME); if (maparch != null) { count++; Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-08 19:04:27 UTC (rev 498) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2006-10-08 19:26:22 UTC (rev 499) @@ -473,7 +473,7 @@ */ /** {@inheritDoc} */ public void run() { - final Progress pbar = new ProgressDisplay(mainControl.getMainView(), ""/*FIXME*/, mainControl.getArchetypeSet().getArchetypeCount(), ACTION_FACTORY.getString("archCollectArches")); + final Progress pbar = new ProgressDisplay(mainControl.getMainView(), ""/*FIXME*/, getArchetypeCount(), ACTION_FACTORY.getString("archCollectArches")); collectDaimoninArchetypes(pbar); collectDaimoninAnimations(pbar); collectDaimoninAnimationTree(pbar); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-08 19:04:35
|
Revision: 498 http://svn.sourceforge.net/gridarta/?rev=498&view=rev Author: christianhujer Date: 2006-10-08 12:04:27 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Fixed missing exception message. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gameobject/NotArchetypeException.java Modified: trunk/src/app/net/sf/gridarta/gameobject/NotArchetypeException.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/NotArchetypeException.java 2006-10-08 19:03:50 UTC (rev 497) +++ trunk/src/app/net/sf/gridarta/gameobject/NotArchetypeException.java 2006-10-08 19:04:27 UTC (rev 498) @@ -16,6 +16,7 @@ * @param gameObject The GameObject that was not an Archetype. */ public NotArchetypeException(final GameObject gameObject) { + super(gameObject.toString()); this.gameObject = gameObject; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-08 19:03:57
|
Revision: 497 http://svn.sourceforge.net/gridarta/?rev=497&view=rev Author: christianhujer Date: 2006-10-08 12:03:50 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Specialized IllegalArgumentException at ArchetypeSet for adding non-Archetype objects. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/NotArchetypeException.java Modified: trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java 2006-10-08 18:27:07 UTC (rev 496) +++ trunk/src/app/net/sf/gridarta/gameobject/AbstractArchetypeSet.java 2006-10-08 19:03:50 UTC (rev 497) @@ -55,7 +55,7 @@ /** {@inheritDoc} */ public final void addArchetype(@NotNull final T archetype) { if (!archetype.isArchetype()) { - throw new IllegalArgumentException("Supplied GameObject " + archetype + " is not an Archetype."); + throw new NotArchetypeException(archetype); } final String name = archetype.getArchetypeName(); if (archetypeMap.containsKey(name)) { Added: trunk/src/app/net/sf/gridarta/gameobject/NotArchetypeException.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/NotArchetypeException.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/NotArchetypeException.java 2006-10-08 19:03:50 UTC (rev 497) @@ -0,0 +1,30 @@ +package net.sf.gridarta.gameobject; + +/** + * This exception is thrown in case a method of or on a {@link GameObject} was invoked that must only be used for GameObjects which are Archetypes. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class NotArchetypeException extends IllegalArgumentException { + + /** + * The GameObject that was not an Archetype. + */ + private final GameObject gameObject; + + /** + * Create a NotArchetypeException. + * @param gameObject The GameObject that was not an Archetype. + */ + public NotArchetypeException(final GameObject gameObject) { + this.gameObject = gameObject; + } + + /** + * Returns the GameObject that was not an Archetype. + * @return The GameObject that was not an Archetype. + */ + public GameObject getGameObject() { + return gameObject; + } + +} // class NotArchetypeException Property changes on: trunk/src/app/net/sf/gridarta/gameobject/NotArchetypeException.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2006-10-08 18:27:13
|
Revision: 496 http://svn.sourceforge.net/gridarta/?rev=496&view=rev Author: akirschbaum Date: 2006-10-08 11:27:07 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Fix #1573023 (Arch browser's filter broken). Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CArchPanelPan.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-10-08 17:33:54 UTC (rev 495) +++ trunk/crossfire/ChangeLog 2006-10-08 18:27:07 UTC (rev 496) @@ -1,3 +1,7 @@ +2006-10-08 Andreas Kirschbaum + + * Fix #1573023 (Arch browser's filter broken). + 2006-10-03 Andreas Kirschbaum * Do not crash when a map resize cuts off only a parts of a Modified: trunk/crossfire/src/cfeditor/CArchPanelPan.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-10-08 17:33:54 UTC (rev 495) +++ trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-10-08 18:27:07 UTC (rev 496) @@ -242,7 +242,7 @@ } else { final String strIndex = list.substring(offset + 45, offset + 50).trim(); if (index == Integer.parseInt(strIndex)) { - model.addElement(strIndex); + model.addElement(list.substring(offset, offset + 45).trim()); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-08 17:33:59
|
Revision: 495 http://svn.sourceforge.net/gridarta/?rev=495&view=rev Author: christianhujer Date: 2006-10-08 10:33:54 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Fixed NumberFormatException, added some debug code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CArchPanelPan.java Modified: trunk/crossfire/src/cfeditor/CArchPanelPan.java =================================================================== --- trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-10-08 15:22:05 UTC (rev 494) +++ trunk/crossfire/src/cfeditor/CArchPanelPan.java 2006-10-08 17:33:54 UTC (rev 495) @@ -240,8 +240,9 @@ // this.model.addElement(this.list.substring(offset, offset+5)+" I:"+this.list.substring(offset+45, offset+50)); model.addElement(list.substring(offset, offset + 45).trim()); } else { - if (index == Integer.parseInt(list.substring(offset + 45, offset + 50))) { - model.addElement(list.substring(offset, offset + 45).trim()); + final String strIndex = list.substring(offset + 45, offset + 50).trim(); + if (index == Integer.parseInt(strIndex)) { + model.addElement(strIndex); } } } @@ -274,6 +275,7 @@ archPanel.setPanelArch(value.toString()); mainControl.setStatusText(" " + value + " "); } + assert archetype != null : "Archetype not found: " + value.toString(); setText(archetype.getArchetypeName()); if (archetype.getFaceFlag()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-08 15:22:27
|
Revision: 494 http://svn.sourceforge.net/gridarta/?rev=494&view=rev Author: christianhujer Date: 2006-10-08 08:22:05 -0700 (Sun, 08 Oct 2006) Log Message: ----------- Unified GameObject regarding attribute cache, multiX and multiY. Added exceptions that are thrown in case of wrong GameObject usage. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/IsArchetypeException.java trunk/src/app/net/sf/gridarta/gameobject/NotInsideContainerException.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-07 18:58:03 UTC (rev 493) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-08 15:22:05 UTC (rev 494) @@ -35,7 +35,6 @@ import java.io.IOException; import java.io.StringReader; import java.util.Collections; -import java.util.HashMap; import java.util.List; import javax.swing.JList; import org.apache.log4j.Logger; @@ -88,18 +87,6 @@ @Nullable private MultiArchData multi = null; /** - * The x-distance of this part to the head part. Set to zero for - * single-part objects. - */ - private int multiX = 0; - - /** - * The y-distance of this part to the head part. Set to zero for - * single-part objects. - */ - private int multiY = 0; - - /** * Data for scripted events. * Stays null if no events defined. */ @@ -124,8 +111,6 @@ private AutojoinList join; // if nonzero, pointing to the list of autojoining archetypes - private final HashMap<String, String> cachedAttribute = new HashMap<String, String>(); - /** Create an GameObject. */ public GameObject() { setArchetype(this); @@ -235,133 +220,6 @@ return editType; } - /** {@inheritDoc} */ - @NotNull public String getAttributeString(@NotNull String attributeName, final boolean queryArchetype) { - String aText = getObjectText(); - int j; - attributeName = attributeName.trim() + " "; // attributeName must be followed by space - String result = ""; - if (queryArchetype) { - result = getCachedAttributeValue(attributeName); - if (result != null) { - return result; - } - result = ""; - } - // Add all attributes from archetype that don't already exist in aText - if (queryArchetype && hasArchetype()) { - aText = aText + diffArchText(getArchetype().getObjectText(), true); - } - - if (!aText.endsWith("\n")) { - aText = aText.concat("\n"); // string should end with '\n', see below - } - - // Check line by line for the string 'attributeName' - int i; - for (i = 0, j = 0; i < aText.length(); i++) { - if (aText.charAt(i) == '\n') { - final String line = aText.substring(j, i).trim(); - - // take the String behind 'attributeName' - if (line.startsWith(attributeName)) { - result = line.substring(attributeName.length()).trim(); - } - - j = i + 1; - } - } - if (queryArchetype) { - setCachedAttributeValue(attributeName, result); - } - - return result; - } - - /** {@inheritDoc} */ - @NotNull public String getAttributeString(@NotNull final String attributeName) { - return getAttributeString(attributeName, true); - } - - /** {@inheritDoc} */ - public int getAttributeInt(@NotNull final String attributeName, final boolean queryArchetype) { - String aText = getObjectText(); - // Add all attributes from archetype that don't already exist in aText - if (queryArchetype && hasArchetype()) { - aText += diffArchText(getArchetype().getObjectText(), true); - } - assert aText.endsWith("\n"); - final String attr2 = attributeName.trim() + ' '; - int result = 0; - for (final String line : aText.split("\\s*\n")) { - if (line.startsWith(attr2)) { - try { - result = Integer.parseInt(line.substring(attr2.length()).trim()); - } catch (final NumberFormatException e) { - result = 0; - } - } - } - return result; - } - - /** {@inheritDoc} */ - public int getAttributeInt(@NotNull final String attributeName) { - return getAttributeInt(attributeName, true); - } - - /** {@inheritDoc} */ - public long getAttributeLong(@NotNull final String attributeName, final boolean queryArchetype) { - String aText = getObjectText(); - // Add all attributes from archetype that don't already exist in aText - if (queryArchetype && hasArchetype()) { - aText += diffArchText(getArchetype().getObjectText(), true); - } - final String attr2 = attributeName.trim() + ' '; - long result = 0; - for (final String line : aText.split("\\s*\n")) { - if (line.startsWith(attr2)) { - try { - result = Long.parseLong(line.substring(attr2.length())); - } catch (final NumberFormatException e) { - result = 0; - } - } - } - return result; - } - - /** {@inheritDoc} */ - public long getAttributeLong(@NotNull final String attributeName) { - return getAttributeLong(attributeName, true); - } - - /** {@inheritDoc} */ - public double getAttributeDouble(@NotNull final String attributeName, final boolean queryArchetype) { - String aText = getObjectText(); - // Add all attributes from archetype that don't already exist in aText - if (queryArchetype && hasArchetype()) { - aText += diffArchText(getArchetype().getObjectText(), true); - } - final String attr2 = attributeName.trim() + ' '; - double result = 0; - for (String line : aText.split("\\s*\n")) { - if (line.startsWith(attr2)) { - try { - result = Double.parseDouble(line.substring(attr2.length())); - } catch (final NumberFormatException e) { - result = 0; - } - } - } - return result; - } - - /** {@inheritDoc} */ - public double getAttributeDouble(@NotNull final String attributeName) { - return getAttributeDouble(attributeName, true); - } - /** * Set the String of an arch attribute in the objectText. * @param attributeName search for "attributeName <string>" @@ -584,46 +442,6 @@ } /** - * Set the x-position of this part of a multi-part object. The x-position - * is relative to the head part. - * - * @param multiX the x-distance of this part to the head part - */ - public void setMultiX(final int multiX) { - this.multiX = multiX; - } - - /** - * Set the y-position of this part of a multi-part object. The y-position - * is relative to the head part. - * - * @param multiY the y-distance of this part to the head part - */ - public void setMultiY(final int multiY) { - this.multiY = multiY; - } - - /** - * Get the x-distance of this part to the head part. For single-part - * objects this is always zero. - * - * @return the x-distance of this part to the head part - */ - public int getMultiX() { - return multiX; - } - - /** - * Get the y-distance of this part to the head part. For single-part - * objects this is always zero. - * - * @return the y-distance of this part to the head part - */ - public int getMultiY() { - return multiY; - } - - /** * Returns number of parts for multipart heads. (*.getMultiRefCount() > 0) * is often used as way to find multi-heads. * @return number of parts @@ -727,22 +545,11 @@ return faceName; } - /** {@inheritDoc} */ - public void setObjectText(final String objectText) { - super.setObjectText(objectText); - clearCachedAttributeValue(); - } - /** - * Get all entries from the given archtext 'atxt' that don't exist in - * 'this' archtext. - * @param atxt archtext to compare 'this'-arch with - * @param ignoreValues if true: the values in the archtext-entries are - * ignored at the comparison - * @return all lines from 'atxt' that don't occur in 'this' arch + * {@inheritDoc} * @todo this method is too slow - find a faster way */ - public String diffArchText(String atxt, final boolean ignoreValues) { + @NotNull public String diffArchText(@NotNull String atxt, final boolean ignoreValues) { int j; if (!atxt.endsWith("\n")) { @@ -1207,20 +1014,4 @@ return arch; } - private void setCachedAttributeValue(final String name, final String value) { - cachedAttribute.put(name, value); - } - - private void unSetCachedAttributeValue(final String name) { - cachedAttribute.remove(name); - } - - private void clearCachedAttributeValue() { - cachedAttribute.clear(); - } - - private String getCachedAttributeValue(final String name) { - return cachedAttribute.get(name); - } - } // class GameObject Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-07 18:58:03 UTC (rev 493) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-08 15:22:05 UTC (rev 494) @@ -91,18 +91,6 @@ */ @Nullable private MultiArchData multi = null; - /** - * The x-distance of this part to the head part. Set to zero for - * single-part objects. - */ - private int multiX = 0; - - /** - * The y-distance of this part to the head part. Set to zero for - * single-part objects. - */ - private int multiY = 0; - private int multiPartNr = 0; /** @@ -239,107 +227,6 @@ return editType; } - /** {@inheritDoc} */ - @NotNull public String getAttributeString(@NotNull final String attributeName, final boolean queryArchetype) { - String aText = getObjectText(); // The "real" Archtext from arch & archetype - // Add all attributes from archetype that don't already exist in aText - if (queryArchetype && hasArchetype()) { - aText += diffArchText(getArchetype().getObjectText(), true); - } - final String attr2 = attributeName.trim() + ' '; // attributeName must be followed by space - String result = ""; // returned String - for (final String line : aText.split("\\s*\n")) { - if (line.startsWith(attr2)) { - result = line.substring(attr2.length()); - } - } - return result; - } - - /** {@inheritDoc} */ - @NotNull public String getAttributeString(@NotNull final String attributeName) { - return getAttributeString(attributeName, true); - } - - /** {@inheritDoc} */ - public int getAttributeInt(@NotNull final String attributeName, final boolean queryArchetype) { - String aText = getObjectText(); // The "real" Archtext from arch & archetype - // Add all attributes from archetype that don't already exist in aText - if (queryArchetype && hasArchetype()) { - aText += diffArchText(getArchetype().getObjectText(), true); - } - assert aText.endsWith("\n"); - final String attr2 = attributeName.trim() + ' '; - int result = 0; - for (final String line : aText.split("\\s*\n")) { - if (line.startsWith(attr2)) { - try { - result = Integer.parseInt(line.substring(attr2.length()).trim()); - } catch (final NumberFormatException e) { - result = 0; - } - } - } - return result; - } - - /** {@inheritDoc} */ - public int getAttributeInt(@NotNull final String attributeName) { - return getAttributeInt(attributeName, true); - } - - /** {@inheritDoc} */ - public long getAttributeLong(@NotNull final String attributeName, final boolean queryArchetype) { - String aText = getObjectText(); - // Add all attributes from archetype that don't already exist in aText - if (queryArchetype && hasArchetype()) { - aText += diffArchText(getArchetype().getObjectText(), true); - } - final String attr2 = attributeName.trim() + ' '; - long result = 0; - for (final String line : aText.split("\\s*\n")) { - if (line.startsWith(attr2)) { - try { - result = Long.parseLong(line.substring(attr2.length())); - } catch (final NumberFormatException e) { - result = 0; - } - } - } - return result; - } - - /** {@inheritDoc} */ - public long getAttributeLong(@NotNull final String attributeName) { - return getAttributeLong(attributeName, true); - } - - /** {@inheritDoc} */ - public double getAttributeDouble(@NotNull final String attributeName, final boolean queryArchetype) { - String aText = getObjectText(); - // Add all attributes from archetype that don't already exist in aText - if (queryArchetype && hasArchetype()) { - aText += diffArchText(getArchetype().getObjectText(), true); - } - final String attr2 = attributeName.trim() + ' '; - double result = 0; - for (String line : aText.split("\\s*\n")) { - if (line.startsWith(attr2)) { - try { - result = Double.parseDouble(line.substring(attr2.length())); - } catch (final NumberFormatException e) { - result = 0; - } - } - } - return result; - } - - /** {@inheritDoc} */ - public double getAttributeDouble(@NotNull final String attributeName) { - return getAttributeDouble(attributeName, true); - } - /** * Insert a GameObject before this GameObject. * @param node GameObject to append @@ -456,26 +343,6 @@ return multi != null ? multi.getNext(this) : null; } - /** - * Set the x-position of this part of a multi-part object. The x-position - * is relative to the head part. - * - * @param multiX the x-distance of this part to the head part - */ - public void setMultiX(final int multiX) { - this.multiX = multiX; - } - - /** - * Set the y-position of this part of a multi-part object. The y-position - * is relative to the head part. - * - * @param multiY the y-distance of this part to the head part - */ - public void setMultiY(final int multiY) { - this.multiY = multiY; - } - public int getMultiShapeID() { return multi != null ? multi.getMultiShapeID() : 0; } @@ -502,26 +369,6 @@ } /** - * Get the x-distance of this part to the head part. For single-part - * objects this is always zero. - * - * @return the x-distance of this part to the head part - */ - public int getMultiX() { - return multiX; - } - - /** - * Get the y-distance of this part to the head part. For single-part - * objects this is always zero. - * - * @return the y-distance of this part to the head part - */ - public int getMultiY() { - return multiY; - } - - /** * Returns number of parts for multipart heads. (*.getMultiRefCount() > 0) * is often used as way to find multi-heads. * @return number of parts @@ -657,15 +504,10 @@ } /** - * Get all entries from the given archtext 'atxt' that don't exist in - * 'this' archtext. - * @param atxt archtext to compare 'this'-arch with - * @param ignoreValues if true: the values in the archtext-entries are - * ignored at the comparison - * @return all lines from 'atxt' that don't occur in 'this' arch + * {@inheritDoc} * @todo this method is too slow - find a faster way */ - public String diffArchText(final String atxt, final boolean ignoreValues) { + @NotNull public String diffArchText(@NotNull final String atxt, final boolean ignoreValues) { final StringBuilder result = new StringBuilder(); for (final String line : atxt.split("\\s*\n")) { if (ignoreValues) { @@ -1076,11 +918,11 @@ final GameObject arch = new GameObject(); arch.setArchetypeName(archetypeName); arch.setArchetype(this); - arch.setObjectFace(); arch.setMultiX(multiX); arch.setMultiY(multiY); - arch.setMultiPartNr(multiPartNr); arch.setLowestPart(isLowestPart); + arch.setMultiPartNr(multiPartNr); + arch.setObjectFace(); return arch; } Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-07 18:58:03 UTC (rev 493) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-08 15:22:05 UTC (rev 494) @@ -3,6 +3,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import net.sf.gridarta.map.MapSquare; +import java.util.HashMap; +import java.util.Map; /** * A GameObject instance reflects a GameObject (object on a map) or an Archetype. @@ -13,7 +15,7 @@ @SuppressWarnings({"ClassReferencesSubclass"}) public abstract class GameObject<G extends GameObject<G>> extends GameObjectContainer<G> { - /** Special constant that's used if an arch has no arch type set. */ + /** Special constant that's used if a GameObject has no arch type set. */ public static final int TYPE_UNSET = -666; /** @@ -49,6 +51,25 @@ private int mapy; /** + * Map which caches attributes for faster access. + * Key: attribute name + * value: attribute value + */ + protected Map<String, String> attributeCache = new HashMap<String, String>(); + + /** + * The x-distance of this part to the head part. Set to zero for + * single-part objects. + */ + protected int multiX = 0; + + /** + * The y-distance of this part to the head part. Set to zero for + * single-part objects. + */ + protected int multiY = 0; + + /** * Constructor. */ protected GameObject() { @@ -61,14 +82,55 @@ */ public int countInvObjects() { int count = 0; - for (final GameObject arch : this) { + for (final GameObject gameObject : this) { count++; - count += arch.countInvObjects(); + count += gameObject.countInvObjects(); } return count; } /** + * Get the requested attribute value from the cache. + * @param attributeName Name of the attribute to search. + * @return cached attribute value from the cache or <code>null</code> if not found + */ + @Nullable private String getCachedAttributeValue(@NotNull final String attributeName) { + return attributeCache.get(attributeName); + } + + /** + * Puts an attribute name / value pair in the cache. + * @param attributeName Name of the attribute to cache. + * @param value Value of the attribute to cache + */ + private void cacheAttributeValue(@NotNull final String attributeName, @NotNull final String value) { + attributeCache.put(attributeName, value); + } + + /** + * Clears the attribute cache. + */ + private void clearAttributeCache() { + attributeCache.clear(); + } + + /** + * Get the requested attribute value from the objectText. + * @param attributeName Name of the attribute to search. + * @return attribute value from the objectText or <code>null</code> if not found + */ + @Nullable private String getAttributeValue(@NotNull final String attributeName) { + final String attr2 = attributeName.trim() + ' '; + String result = null; + for (final String line : getObjectText().split("\\s*\n")) { + if (line.startsWith(attr2)) { + result = line.substring(attr2.length()); + break; + } + } + return result; + } + /** * Get the requested attribute value of this GameObject as {@link String}. * The attribute value is first searched in this GameObject. * If <code>queryArchetype == true</code>, additional search is done: @@ -83,7 +145,22 @@ * @return Attribute value or empty String ("") if no such attribute * @see #getAttributeString(String) */ - @NotNull public abstract String getAttributeString(@NotNull String attributeName, boolean queryArchetype); + @NotNull public String getAttributeString(@NotNull final String attributeName, final boolean queryArchetype) { + String result = getCachedAttributeValue(attributeName); + if (result == null) { + result = getAttributeValue(attributeName); + } + if (result == null) { + if (!queryArchetype || isArchetype() || !hasArchetype()) { + result = ""; + } else { + result = getArchetype().getAttributeString(attributeName); + } + } else { + cacheAttributeValue(attributeName, result); + } + return result; + } /** * Get the requested attribute value of this GameObject as {@link String}. @@ -96,7 +173,9 @@ * @return Attribute value or empty String ("") if no such attribute * @see #getAttributeString(String, boolean) */ - @NotNull public abstract String getAttributeString(@NotNull String attributeName); + @NotNull public String getAttributeString(@NotNull final String attributeName) { + return getAttributeString(attributeName, true); + } /** * Get the requested attribute value of this GameObject as <code>int</code>. @@ -106,7 +185,15 @@ * @see #getAttributeInt(String) * @see #getAttributeString(String, boolean) */ - public abstract int getAttributeInt(@NotNull String attributeName, boolean queryArchetype); + public int getAttributeInt(@NotNull final String attributeName, final boolean queryArchetype) { + int result = 0; + try { + result = Integer.parseInt(getAttributeString(attributeName, queryArchetype)); + } catch (final NumberFormatException ignore) { + // ignore + } + return result; + } /** * Get the requested attribute value of this GameObject as <code>int</code>. @@ -115,7 +202,9 @@ * @see #getAttributeInt(String, boolean) * @see #getAttributeString(String) */ - public abstract int getAttributeInt(@NotNull String attributeName); + public int getAttributeInt(@NotNull final String attributeName) { + return getAttributeInt(attributeName, true); + } /** * Get the requested attribute value of this GameObject as <code>long</code>. @@ -125,7 +214,15 @@ * @see #getAttributeLong(String) * @see #getAttributeString(String, boolean) */ - public abstract long getAttributeLong(@NotNull String attributeName, boolean queryArchetype); + public long getAttributeLong(@NotNull final String attributeName, final boolean queryArchetype) { + long result = 0; + try { + result = Long.parseLong(getAttributeString(attributeName, queryArchetype)); + } catch (final NumberFormatException ignore) { + // ignore + } + return result; + } /** * Get the requested attribute value of this GameObject as <code>long</code>. @@ -134,7 +231,9 @@ * @see #getAttributeLong(String, boolean) * @see #getAttributeString(String) */ - public abstract long getAttributeLong(@NotNull String attributeName); + public long getAttributeLong(@NotNull final String attributeName) { + return getAttributeLong(attributeName, true); + } /** * Get the requested attribute value of this GameObject as <code>double</code>. @@ -144,7 +243,15 @@ * @see #getAttributeDouble(String) * @see #getAttributeString(String, boolean) */ - public abstract double getAttributeDouble(@NotNull String attributeName, boolean queryArchetype); + public double getAttributeDouble(@NotNull final String attributeName, final boolean queryArchetype) { + double result = 0; + try { + result = Double.parseDouble(getAttributeString(attributeName, queryArchetype)); + } catch (final NumberFormatException ignore) { + // ignore + } + return result; + } /** * Get the requested attribute value of this GameObject as <code>double</code>. @@ -153,9 +260,21 @@ * @see #getAttributeDouble(String, boolean) * @see #getAttributeString(String) */ - public abstract double getAttributeDouble(@NotNull String attributeName); + public double getAttributeDouble(@NotNull final String attributeName) { + return getAttributeDouble(attributeName, true); + } /** + * Get all entries from the given archtext 'atxt' that don't exist in + * 'this' archtext. + * @param atxt archtext to compare 'this'-arch with + * @param ignoreValues if true: the values in the archtext-entries are + * ignored at the comparison + * @return all lines from 'atxt' that don't occur in 'this' arch + */ + @NotNull public abstract String diffArchText(@NotNull String atxt, boolean ignoreValues); + + /** * Returns container of this GameObject. * There are two possibilities for the container: * <ul> @@ -213,41 +332,88 @@ return container != null ? container.getMapSquare() : null; } - /** Move this GameObject top. */ + // TODO: For the following set of methods add logging that it was tried to move a GameObject without container. + // TODO (continued): Eventually think about using an Exception for that case. + // TODO (continued): Or two: + // TODO (continued): * One in case a non-Archetype method was invoked on an Archetype. + // TODO (continued): * The other in case a method that requires a container was invoked on a GameObject without container. + + /** + * Move this GameObject top. + * Does nothing if the object has no container. + */ public void moveTop() { + if (isArchetype()) { + throw new IsArchetypeException(this); + } + if (container == null) { + throw new NotInsideContainerException(this); + } container.moveTop((G) this); } - /** Move this GameObject up. */ + /** + * Move this GameObject up. + * Does nothing if the object has no container. + */ public void moveUp() { + if (isArchetype()) { + throw new IsArchetypeException(this); + } + if (container == null) { + throw new NotInsideContainerException(this); + } container.moveUp((G) this); } - /** Move this GameObject down. */ + /** + * Move this GameObject down. + * Does nothing if the object has no container. + */ public void moveDown() { + if (isArchetype()) { + throw new IsArchetypeException(this); + } + if (container == null) { + throw new NotInsideContainerException(this); + } container.moveDown((G) this); } - /** Move this GameObject bottom. */ + /** + * Move this GameObject bottom. + * Does nothing if the object has no container. + */ public void moveBottom() { + if (isArchetype()) { + throw new IsArchetypeException(this); + } + if (container == null) { + throw new NotInsideContainerException(this); + } container.moveBottom((G) this); } /** - * Remove this GameObject from its container. Do nothing if the object is - * not inside a container. - * This method also takes perfectly well care of multihead arches. + * Remove this GameObject from its container. + * Does nothing if the object has no container. + * This method also takes perfectly well care of multihead GameObjects. */ public void remove() { + if (isArchetype()) { + throw new IsArchetypeException(this); + } final G head = getHead(); for (G tail = head.getMultiNext(); tail != null; tail = tail.getMultiNext()) { - if (tail.container != null) { - tail.container.remove(tail); + if (tail.container == null) { + throw new NotInsideContainerException(this); } + tail.container.remove(tail); } - if (head.container != null) { - head.container.remove(head); + if (head.container == null) { + throw new NotInsideContainerException(this); } + head.container.remove(head); } /** @@ -276,8 +442,8 @@ /** * Check whether this GameObject has an Archetype. - * @return <code>true</code> when this GameObject has a default arch or is - * a default arch itself, otherwise <code>false</code> + * @return <code>true</code> when this GameObject has an Archetype or is + * an Archetype itself, otherwise <code>false</code> */ public boolean hasArchetype() { return archetype != null; @@ -301,10 +467,10 @@ } /** - * Check whether this GameObject has the same default arch as another + * Check whether this GameObject has the same Archetype as another * GameObject. * @param other other GameObject - * @return <code>true</code> when this GameObject has the same default arch + * @return <code>true</code> when this GameObject has the same Archetype * as the other GameObject, otherwise <code>false</code> */ public boolean hasSameArchetype(final G other) { @@ -424,11 +590,17 @@ @Nullable public abstract G getMultiNext(); - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * Implementations must not provide substitute clones of a different class. + * I.e. implementations MUST return an object created by super.clone() or their own constructor. + * Implementations MUST NOT return an object created from a different class. + */ @Override @NotNull protected GameObject<G> clone() throws CloneNotSupportedException { try { final GameObject<G> clone = (GameObject<G>) super.clone(); clone.objectText = new StringBuffer(getObjectText()); + clone.attributeCache = new HashMap<String, String>(attributeCache); return clone; } catch (final CloneNotSupportedException e) { assert false; @@ -472,6 +644,47 @@ public void setObjectText(final String objectText) { resetObjectText(); this.objectText.append(objectText); + clearAttributeCache(); } + /** + * Set the x-position of this part of a multi-part object. The x-position + * is relative to the head part. + * + * @param multiX the x-distance of this part to the head part + */ + public void setMultiX(final int multiX) { + this.multiX = multiX; + } + + /** + * Set the y-position of this part of a multi-part object. The y-position + * is relative to the head part. + * + * @param multiY the y-distance of this part to the head part + */ + public void setMultiY(final int multiY) { + this.multiY = multiY; + } + + /** + * Get the x-distance of this part to the head part. For single-part + * objects this is always zero. + * + * @return the x-distance of this part to the head part + */ + public int getMultiX() { + return multiX; + } + + /** + * Get the y-distance of this part to the head part. For single-part + * objects this is always zero. + * + * @return the y-distance of this part to the head part + */ + public int getMultiY() { + return multiY; + } + } // interface GameObject Added: trunk/src/app/net/sf/gridarta/gameobject/IsArchetypeException.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/IsArchetypeException.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/IsArchetypeException.java 2006-10-08 15:22:05 UTC (rev 494) @@ -0,0 +1,33 @@ +package net.sf.gridarta.gameobject; + +import org.jetbrains.annotations.NotNull; + +/** + * This exception is thrown in case a method of {@link GameObject} was invoked that must not be used for GameObjects which are Archetypes. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class IsArchetypeException extends IllegalStateException { + + /** + * The GameObject that is an Archetype. + */ + @NotNull private final GameObject archetype; + + /** + * Create an IsArchetypeException. + * @param archetype The GameObject that is an Archetype. + */ + public IsArchetypeException(@NotNull final GameObject archetype) { + super(archetype.toString()); + this.archetype = archetype; + } + + /** + * Returns the GameObject that is an Archetype. + * @return The GameObject that is an Archetype. + */ + @NotNull public GameObject getArchetype() { + return archetype; + } + +} // class IsArchetypeException Property changes on: trunk/src/app/net/sf/gridarta/gameobject/IsArchetypeException.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/gameobject/NotInsideContainerException.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/NotInsideContainerException.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/NotInsideContainerException.java 2006-10-08 15:22:05 UTC (rev 494) @@ -0,0 +1,33 @@ +package net.sf.gridarta.gameobject; + +import org.jetbrains.annotations.NotNull; + +/** + * This exception is thrown in case a method of a {@link GameObject} without a container was invoked when a GameObject requires a container. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class NotInsideContainerException extends IllegalStateException { + + /** + * The GameObject that was not inside a container but should have been. + */ + @NotNull private final GameObject gameObject; + + /** + * Create a NotInsideContainerException. + * @param gameObject GameObject that was not inside a container but should have been. + */ + public NotInsideContainerException(@NotNull final GameObject gameObject) { + super(gameObject.toString()); + this.gameObject = gameObject; + } + + /** + * Returns the GameObject that was not inside a container but should have been. + * @return The GameObject that was not inside a container but should have been. + */ + @NotNull public GameObject getGameObject() { + return gameObject; + } + +} // class NotInsideContainerException Property changes on: trunk/src/app/net/sf/gridarta/gameobject/NotInsideContainerException.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-07 18:58:33
|
Revision: 493 http://svn.sourceforge.net/gridarta/?rev=493&view=rev Author: christianhujer Date: 2006-10-07 11:58:03 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Merged objectext, mapx and mapy of GameObject. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CAttribDialog.java trunk/crossfire/src/cfeditor/CMapFileDecode.java trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/CAttribDialog.java trunk/daimonin/src/daieditor/CMapFileDecode.java trunk/daimonin/src/daieditor/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroError.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java trunk/src/app/net/sf/gridarta/map/MapModel.java trunk/src/app/net/sf/gridarta/map/MapSquare.java Modified: trunk/crossfire/src/cfeditor/CAttribDialog.java =================================================================== --- trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-10-07 17:25:26 UTC (rev 492) +++ trunk/crossfire/src/cfeditor/CAttribDialog.java 2006-10-07 18:58:03 UTC (rev 493) @@ -1402,7 +1402,7 @@ if (typeStruct == typelist.getHead().getNext()) { // for generic (misc) type, all errors are automatically kept. // "misc" is no real type - it is more a default mask for unknown types - gameObject.addArchText(errors.trim() + "\n"); + gameObject.addObjectText(errors.trim() + "\n"); } else { // open a popup dialog and ask user to decide what to do with his errors askConfirmErrors(errors); @@ -1707,7 +1707,7 @@ // the user pressed "keep", so we append the contents // of the textfield to the archtext if (text.getText() != null && text.getText().trim().length() > 0) { - arch.addArchText(text.getText().trim() + "\n"); + arch.addObjectText(text.getText().trim() + "\n"); } } @@ -1722,7 +1722,7 @@ * be assumed that the user did not properly think about them yet. */ public void windowClosing(final WindowEvent e) { - arch.addArchText(allErrors.trim() + "\n"); + arch.addObjectText(allErrors.trim() + "\n"); // nuke the popup dialog dialog.dispose(); Modified: trunk/crossfire/src/cfeditor/CMapFileDecode.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-10-07 17:25:26 UTC (rev 492) +++ trunk/crossfire/src/cfeditor/CMapFileDecode.java 2006-10-07 18:58:03 UTC (rev 493) @@ -212,9 +212,9 @@ msgflag = true; // this is a MUST, because we overrule "anim" test } else if (thisLine.regionMatches(0, "animation", 0, 9)) { - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } else if (thisLine.regionMatches(0, "anim_speed", 0, 10)) { - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } else if (thisLine.regionMatches(0, "anim", 0, 4)) { //arch.addArchText(thisLine + "\n"); animflag = true; @@ -242,7 +242,7 @@ } } else { log.warn("Arch " + arch.getArchetypeName() + " has incorrect event code '" + thisLine + "'"); - arch.addArchText(thisLine + "\n"); // keep line, it might have a meaning after all + arch.addObjectText(thisLine + "\n"); // keep line, it might have a meaning after all } } else if (thisLine.regionMatches(0, "x ", 0, 2)) { final int temp = Integer.parseInt(thisLine.substring(2)); @@ -270,7 +270,7 @@ arch.setFaceFlag(false); arch.setFaceName(thisLine.substring(x, thisLine.length())); } else { - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } } else { // We are in a multipart tail arch ("more"), so we skip it: Modified: trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-07 17:25:26 UTC (rev 492) +++ trunk/crossfire/src/cfeditor/gameobject/ArchObjectParser.java 2006-10-07 18:58:03 UTC (rev 493) @@ -199,7 +199,7 @@ } else { arch = defArch.createClone(0, 0); } - arch.resetArchText(); + arch.resetObjectText(); String thisLine2; if (line == null) { @@ -261,7 +261,7 @@ if (thisLine.startsWith("mina")) { mainControl.getAnimationObject().addAnimObject(arch.getArchetypeName(), arch.getAnimText()); - arch.addArchText("animation " + arch.getArchetypeName() + "\n"); + arch.addObjectText("animation " + arch.getArchetypeName() + "\n"); // here we must add this to AnimationObject // and add Animation cmd here! animflag = false; @@ -339,7 +339,7 @@ if (archName != null) { arch.setArtifact(true); // here we add all unchanged arch text lines from defArch back to arch - arch.addArchText(arch.diffArchText(defArch.getObjectText(), true)); + arch.addObjectText(arch.diffArchText(defArch.getObjectText(), true)); return arch; } archlast = arch; @@ -348,9 +348,9 @@ if (thisLine.startsWith("msg")) { msgflag = true; } else if (thisLine.startsWith("animation")) { - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } else if (thisLine.startsWith("anim_speed")) { - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } else if (thisLine.startsWith("anim")) { animflag = true; } else if (thisLine.equals("lore")) { @@ -374,13 +374,13 @@ } else if (thisLine.startsWith("x ")) { if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { log.warn("Find x cmd in single tile or head (add it to arch text): " + arch.getArchetypeName()); - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } arch.setMultiX(Integer.parseInt(thisLine.substring(2))); } else if (thisLine.startsWith("y ")) { if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { log.warn("Find y cmd in single tile or head (add it to arch text): " + arch.getArchetypeName()); - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } arch.setMultiY(Integer.parseInt(thisLine.substring(2))); } else if (thisLine.startsWith("type ")) { @@ -392,7 +392,7 @@ } } catch (final Exception e) { log.warn("Arch " + arch.getArchetypeName() + " has a invalid type nr. (" + thisLine.substring(5) + ")"); - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } } else if (thisLine.startsWith("face ")) { int x; @@ -410,7 +410,7 @@ isNewCategory = true; // this arch has a new category } } - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); if (log.isDebugEnabled()) { log.debug("add String: " + thisLine); } @@ -431,7 +431,7 @@ */ public static void postParseDefArch(final GameObject arch) { final String text = arch.getObjectText(); - arch.resetArchText(); + arch.resetObjectText(); final int len = text.length(); // if no type was set, zero is taken @@ -445,19 +445,19 @@ if (text.charAt(i) == '\n') { if (i - s > 0) { if (scriptflag) { - arch.addArchText(text.substring(s, i) + "\n"); + arch.addObjectText(text.substring(s, i) + "\n"); if (text.regionMatches(s, "end_script_", 0, 11)) { scriptflag = false; } } else if (text.regionMatches(s, "start_script_", 0, 13)) { - arch.addArchText(text.substring(s, i) + "\n"); + arch.addObjectText(text.substring(s, i) + "\n"); scriptflag = true; } else if (text.regionMatches(s, "editable ", 0, 9)) { arch.setEditType(Integer.parseInt(text.substring(s + 9, i))); } else if (text.regionMatches(s, "name ", 0, 5)) { arch.setObjName(text.substring(s + 5, i)); } else { - arch.addArchText(text.substring(s, i) + "\n"); + arch.addObjectText(text.substring(s, i) + "\n"); } } @@ -498,7 +498,7 @@ final int len = text.length(); final GameObject archetype = mainControl.getArchetype(gameObject.getArchetypeName()); - gameObject.resetArchText(); + gameObject.resetObjectText(); for (int i = 0, s = 0; i < len; i++) { if (text.charAt(i) == '\n') { @@ -507,7 +507,7 @@ gameObject.setObjName(text.substring(s + 5, i)); } else { // this is an unparsed arch attribute, it has to stay in the archtext - gameObject.addArchText(text.substring(s, i) + "\n"); + gameObject.addObjectText(text.substring(s, i) + "\n"); } } s = i + 1; @@ -535,9 +535,9 @@ // we don't handle anim yet, so attach then back to archtext if (gameObject.getAnimText() != null) { - gameObject.addArchText("anim\n"); - gameObject.addArchText(gameObject.getAnimText()); - gameObject.addArchText("mina\n"); + gameObject.addObjectText("anim\n"); + gameObject.addObjectText(gameObject.getAnimText()); + gameObject.addObjectText("mina\n"); } // Finally, we calculate the desired editType of the arch Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-07 17:25:26 UTC (rev 492) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-07 18:58:03 UTC (rev 493) @@ -51,9 +51,6 @@ private static final Logger log = Logger.getLogger(GameObject.class); - /** Special constant that's used if an arch has no arch type set. */ - public static final int TYPE_UNSET = -666; - /** Static reference to the typeList (find syntax errors). */ private static CFArchTypeList typeList; @@ -71,12 +68,6 @@ private String objName; /** - * The objectText with the differences from the Archetype. - * @note Every line in the objectText must end on '\n', including the last line. - */ - @NotNull private StringBuffer objectText; - - /** * The msgText. * @note Every line in msgText must end on '\n', including the last line. * @note If the value is <code>null</code>, the arch has no message text, @@ -90,12 +81,6 @@ private int archTextCount; // lines inserted in ArchText - /** Map x position if on map. */ - private int mapx; - - /** Map y position if on map. */ - private int mapy; - /** * Data for multitile-arches. * Stays null for singlesquare-arches. @@ -148,7 +133,6 @@ myId = myIdCounter++; // increase ID counter for every new arch created - objectText = new StringBuffer(""); msgText = animText = loreText = null; archTextCount = 0; // lines inserted in objectText @@ -163,8 +147,6 @@ editflag = false; join = null; // no autojoin list per default archType = TYPE_UNSET; // type must be set - mapx = 0; - mapy = 0; editType = 0; } @@ -255,7 +237,7 @@ /** {@inheritDoc} */ @NotNull public String getAttributeString(@NotNull String attributeName, final boolean queryArchetype) { - String aText = objectText.toString(); // The "real" Archtext from arch & archetype + String aText = getObjectText(); int j; attributeName = attributeName.trim() + " "; // attributeName must be followed by space String result = ""; @@ -303,7 +285,7 @@ /** {@inheritDoc} */ public int getAttributeInt(@NotNull final String attributeName, final boolean queryArchetype) { - String aText = objectText.toString(); // The "real" Archtext from arch & archetype + String aText = getObjectText(); // Add all attributes from archetype that don't already exist in aText if (queryArchetype && hasArchetype()) { aText += diffArchText(getArchetype().getObjectText(), true); @@ -330,7 +312,7 @@ /** {@inheritDoc} */ public long getAttributeLong(@NotNull final String attributeName, final boolean queryArchetype) { - String aText = objectText.toString(); + String aText = getObjectText(); // Add all attributes from archetype that don't already exist in aText if (queryArchetype && hasArchetype()) { aText += diffArchText(getArchetype().getObjectText(), true); @@ -356,7 +338,7 @@ /** {@inheritDoc} */ public double getAttributeDouble(@NotNull final String attributeName, final boolean queryArchetype) { - String aText = objectText.toString(); + String aText = getObjectText(); // Add all attributes from archetype that don't already exist in aText if (queryArchetype && hasArchetype()) { aText += diffArchText(getArchetype().getObjectText(), true); @@ -386,7 +368,7 @@ * @param value value to set */ public void setAttributeString(String attributeName, final String value) { - String aText = objectText.toString(); // The "real" Archtext from arch + String aText = getObjectText(); // The "real" Archtext from arch int j; attributeName = attributeName.trim() + " "; // attributeName must be followed by space @@ -430,7 +412,7 @@ * @param attributeName search for "attributeName <string>" */ public void removeAttribute(String attributeName) { - String aText = objectText.toString(); // The "real" Archtext from arch + String aText = getObjectText(); int j; attributeName = attributeName.trim() + " "; // attributeName must be followed by space @@ -669,42 +651,6 @@ archType = type; } - public void setMapX(final int mapx) { - this.mapx = mapx; - } - - public void setMapY(final int mapy) { - this.mapy = mapy; - } - - /** {@inheritDoc} */ - public int getMapX() { - return mapx; - } - - /** {@inheritDoc} */ - public int getMapY() { - return mapy; - } - - /** {@inheritDoc} */ - @Override public void addLast(final GameObject arch) { - super.addLast(arch); - // force type change when a MONSTER is put in a spawn point - if (typeList.getTypeOfArch(this) != null && typeList.getTypeOfArch(this).getTypeNr() == 81 && typeList.getTypeOfArch(arch).getTypeNr() == 80) { - arch.archType = 83; // change to SPAWN_POINT_MOB - } - } - - /** {@inheritDoc} */ - @Override public void addFirst(final GameObject arch) { - super.addFirst(arch); - // force type change when a MONSTER is put in a spawn point - if (typeList.getTypeOfArch(this).getTypeNr() == 81 && typeList.getTypeOfArch(arch).getTypeNr() == 80) { - arch.archType = 83; // change to SPAWN_POINT_MOB - } - } - /* Set the default face. Number is index of face list */ public void setFaceNr(final int nr) { facenr = nr; @@ -781,34 +727,12 @@ return faceName; } - /** - * Append <var>text</var> to the arch text of this arch. - * @param text text to add - */ - public void addArchText(final String text) { - objectText.append(text); - } - - /** - * Set <var>text</var> as arch text of this arch. - * @param objectText text to set as arch text - */ + /** {@inheritDoc} */ public void setObjectText(final String objectText) { - this.objectText.delete(0, this.objectText.length()); - this.objectText.append(objectText); + super.setObjectText(objectText); clearCachedAttributeValue(); } - /** {@inheritDoc} */ - @NotNull public String getObjectText() { - return objectText.toString(); - } - - /** Clears the arch text of this arch. */ - public void resetArchText() { - objectText.delete(0, objectText.length()); - } - /** * Get all entries from the given archtext 'atxt' that don't exist in * 'this' archtext. @@ -1009,11 +933,7 @@ clone.objName = objName; // the arch text (contains only the differences from default arch) - if (objectText != null) { - clone.objectText = new StringBuffer(objectText.toString()); - } else { - clone.objectText = null; - } + clone.objectText = new StringBuffer(getObjectText()); clone.archTextCount = archTextCount; // lines of text in objectText // msg text buffer @@ -1050,8 +970,8 @@ clone.archType = archType; // type attribute of the arch // set coords: - clone.mapx = posx; - clone.mapy = posy; + clone.setMapX(posx); + clone.setMapY(posy); // If 'this' arch is a container, we have to create clones // of the whole inventory (recursively) and link them in: @@ -1186,11 +1106,11 @@ */ @Nullable public String getSyntaxErrors(CFArchType type) { - if (typeList != null && objectText != null && objectText.length() > 0) { + if (typeList != null && hasObjectText()) { String errors = ""; // return value: all error lines // open a reading stream for the objectText - final StringReader sread = new StringReader(objectText.toString()); + final StringReader sread = new StringReader(getObjectText()); final BufferedReader sstream = new BufferedReader(sread); try { Modified: trunk/daimonin/src/daieditor/CAttribDialog.java =================================================================== --- trunk/daimonin/src/daieditor/CAttribDialog.java 2006-10-07 17:25:26 UTC (rev 492) +++ trunk/daimonin/src/daieditor/CAttribDialog.java 2006-10-07 18:58:03 UTC (rev 493) @@ -1268,7 +1268,7 @@ if (typeStruct == typelist.getArchType(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.addArchText(errors.trim() + '\n'); + gameObject.addObjectText(errors.trim() + '\n'); } else { // open a popup dialog and ask user to decide what to do with his errors askConfirmErrors(errors); @@ -1555,7 +1555,7 @@ // the user pressed "keep", so we append the contents // of the textfield to the archtext if (text.getText() != null && text.getText().trim().length() > 0) { - arch.addArchText(text.getText().trim() + '\n'); + arch.addObjectText(text.getText().trim() + '\n'); } } @@ -1566,7 +1566,7 @@ /** {@inheritDoc} */ @Override public void windowClosing(final WindowEvent e) { - arch.addArchText(allErrors.trim() + '\n'); + arch.addObjectText(allErrors.trim() + '\n'); // nuke the popup dialog dialog.dispose(); Modified: trunk/daimonin/src/daieditor/CMapFileDecode.java =================================================================== --- trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-10-07 17:25:26 UTC (rev 492) +++ trunk/daimonin/src/daieditor/CMapFileDecode.java 2006-10-07 18:58:03 UTC (rev 493) @@ -172,12 +172,12 @@ // don't load it into the archtext! (why?) } else if (thisLine.startsWith("direction ")) { arch.setDirection(Integer.parseInt(thisLine.substring(10))); - arch.addArchText(thisLine + '\n'); + arch.addObjectText(thisLine + '\n'); } else if (thisLine.startsWith("face ")) { arch.setFaceRealName(thisLine.substring("face ".length()).trim()); - arch.addArchText(thisLine + '\n'); + arch.addObjectText(thisLine + '\n'); } else { - arch.addArchText(thisLine + '\n'); + arch.addObjectText(thisLine + '\n'); } } } while ((thisLine = myInput.readLine()) != null); Modified: trunk/daimonin/src/daieditor/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/ScriptArchData.java 2006-10-07 17:25:26 UTC (rev 492) +++ trunk/daimonin/src/daieditor/ScriptArchData.java 2006-10-07 18:58:03 UTC (rev 493) @@ -778,17 +778,17 @@ } private void setEventData(final int eventType, final String pluginName, final String filePath, final String options) { - event.resetArchText(); + event.resetObjectText(); if (pluginName != null && pluginName.length() > 0) { event.setObjName(pluginName); } if (filePath != null && filePath.length() > 0) { - event.addArchText("race " + filePath + '\n'); + event.addObjectText("race " + filePath + '\n'); } if (options != null && options.length() > 0) { - event.addArchText("slaying " + options + '\n'); + event.addObjectText("slaying " + options + '\n'); } - event.addArchText("sub_type " + eventType + '\n'); + event.addObjectText("sub_type " + eventType + '\n'); } } // class ScriptedEvent Modified: trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java 2006-10-07 17:25:26 UTC (rev 492) +++ trunk/daimonin/src/daieditor/gameobject/ArchObjectParser.java 2006-10-07 18:58:03 UTC (rev 493) @@ -135,7 +135,7 @@ path = null; newCat = null; } - arch.resetArchText(); + arch.resetObjectText(); String thisLine2; if (line == null) { @@ -207,7 +207,7 @@ log.log(Level.WARNING, "duplicateAnimation", e); } - arch.addArchText("animation " + arch.getArchetypeName() + "\n"); + arch.addObjectText("animation " + arch.getArchetypeName() + "\n"); arch.setAnimName(arch.getArchetypeName()); // here we must add this to AnimationObject @@ -305,7 +305,7 @@ arch.setArtifact(true); // here we add all unchanged arch text lines from defArch back to arch if (defArch != null) { - arch.addArchText(arch.diffArchText(defArch.getObjectText(), true)); + arch.addObjectText(arch.diffArchText(defArch.getObjectText(), true)); } return arch; } @@ -315,12 +315,12 @@ if (thisLine.startsWith("msg")) { msgflag = true; } else if (thisLine.startsWith("animation ")) { - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); final String animName = thisLine.substring(10).trim(); arch.setAnimName(animName); //arch.setAnimNr(mainControl.animationObjects.findAnimObject(animName)); // probably not needed, but better not delete it yet } else if (thisLine.startsWith("anim_speed ")) { - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } else if (thisLine.startsWith("anim")) { animflag = true; animText = new StringBuilder(); @@ -335,14 +335,14 @@ } else if (thisLine.startsWith("x ")) { if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { log.log(Level.WARNING, "foundCoordInDefArchSingleTileOrHead", new Object[]{"x", arch.getArchetypeName()}); - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } else { arch.setMultiX(Integer.parseInt(thisLine.substring(2))); } } else if (thisLine.startsWith("y ")) { if (!archmore && !arch.getArchetypeName().equals(STARTARCH_NAME)) { log.log(Level.WARNING, "foundCoordInDefArchSingleTileOrHead", new Object[]{"y", arch.getArchetypeName()}); - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } else { arch.setMultiY(Integer.parseInt(thisLine.substring(2))); } @@ -355,7 +355,7 @@ } } catch (final NumberFormatException e) { log.log(Level.WARNING, "defArchWithInvalidTypeNr", new Object[]{arch.getArchetypeName(), thisLine.substring(5)}); - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } } else if (thisLine.startsWith("direction ")) { try { @@ -363,7 +363,7 @@ } catch (final NumberFormatException e) { log.log(Level.WARNING, "defArchWithInvalidDirection", new Object[]{arch.getArchetypeName(), thisLine.substring(10)}); } - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } else if (thisLine.startsWith("face ")) { int x; for (x = 4; x < thisLine.length(); x++) { @@ -372,7 +372,7 @@ } } arch.setFaceRealName(thisLine.substring(x, thisLine.length())); - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } else if (thisLine.startsWith("editor_folder ")) { // the display category (= "folder" the arch belongs to) newCat = thisLine.substring(14).trim(); @@ -389,7 +389,7 @@ } } catch (final NumberFormatException e) { System.err.println("WARNING: Arch " + arch.getArchetypeName() + " has a invalid mpart_id (" + thisLine.substring(9) + ')'); - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } } else if (thisLine.startsWith("mpart_nr ")) { // part nr for multiparts @@ -398,10 +398,10 @@ arch.setMultiPartNr(i); } catch (final NumberFormatException e) { System.err.println("WARNING: Arch " + arch.getArchetypeName() + " has a invalid mpart_nr (" + thisLine.substring(9) + ')'); - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } } else { - arch.addArchText(thisLine + "\n"); + arch.addObjectText(thisLine + "\n"); } //System.err.println("add String: "+thisLine); } @@ -418,7 +418,7 @@ */ public static void postParseDefArch(final GameObject arch) { final String text = arch.getObjectText(); - arch.resetArchText(); + arch.resetObjectText(); final int len = text.length(); // if no type was set, zero is taken @@ -432,19 +432,19 @@ if (text.charAt(i) == '\n') { if (i - s > 0) { if (scriptflag) { - arch.addArchText(text.substring(s, i) + "\n"); + arch.addObjectText(text.substring(s, i) + "\n"); if (text.regionMatches(s, "end_script_", 0, 11)) { scriptflag = false; } } else if (text.regionMatches(s, "start_script_", 0, 13)) { - arch.addArchText(text.substring(s, i) + "\n"); + arch.addObjectText(text.substring(s, i) + "\n"); scriptflag = true; } else if (text.regionMatches(s, "editable ", 0, 9)) { arch.setEditType(Integer.parseInt(text.substring(s + 9, i))); } else if (text.regionMatches(s, "name ", 0, 5)) { arch.setObjName(text.substring(s + 5, i)); } else { - arch.addArchText(text.substring(s, i) + "\n"); + arch.addObjectText(text.substring(s, i) + "\n"); } } @@ -486,7 +486,7 @@ final int len = text.length(); final GameObject defarch = arch.getArchetype(); - arch.resetArchText(); + arch.resetObjectText(); // so, lets check the stuff a last time for (int i = 0, s = 0; i < len; i++) { @@ -494,12 +494,12 @@ if (i - s > 0) { if (text.regionMatches(s, "animation ", 0, 9)) { arch.setAnimName(text.substring(s + 10, i)); - arch.addArchText(text.substring(s, i) + "\n"); + arch.addObjectText(text.substring(s, i) + "\n"); } else if (text.regionMatches(s, "name ", 0, 5)) { arch.setObjName(text.substring(s + 5, i)); } else { // this is an unparsed arch attribute, it has to stay in the archtext - arch.addArchText(text.substring(s, i) + "\n"); + arch.addObjectText(text.substring(s, i) + "\n"); } } s = i + 1; Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-07 17:25:26 UTC (rev 492) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-07 18:58:03 UTC (rev 493) @@ -59,9 +59,6 @@ /** Serial Version. */ private static final long serialVersionUID = 1L; - /** Special constant that's used if an arch has no arch type set. */ - public static final int TYPE_UNSET = -666; - /** Static reference to the typeList (find syntax errors). */ private static CFArchTypeList typeList; @@ -81,12 +78,6 @@ private String animName; /** - * The objectText with the differences from the Archetype. - * @note Every line in the objectText must end on '\n', including the last line. - */ - @NotNull private StringBuffer objectText; - - /** * The msgText. * @note Every line in msgText must end on '\n', including the last line. * @note If the value is <code>null</code>, the arch has no message text, @@ -94,12 +85,6 @@ */ @Nullable private StringBuffer msgText; - /** Map x position if on map. */ - private int mapx; - - /** Map y position if on map. */ - private int mapy; - /** * Data for multitile-arches. * Stays null for singlesquare-arches. @@ -162,7 +147,6 @@ /** Create an GameObject. */ public GameObject() { - objectText = new StringBuffer(); faceobjdesc = FaceDesc.FACE_NOT_FOUND; archType = TYPE_UNSET; // type must be set script = new ScriptArchData(this); @@ -257,7 +241,7 @@ /** {@inheritDoc} */ @NotNull public String getAttributeString(@NotNull final String attributeName, final boolean queryArchetype) { - String aText = objectText.toString(); // The "real" Archtext from arch & archetype + String aText = getObjectText(); // The "real" Archtext from arch & archetype // Add all attributes from archetype that don't already exist in aText if (queryArchetype && hasArchetype()) { aText += diffArchText(getArchetype().getObjectText(), true); @@ -279,7 +263,7 @@ /** {@inheritDoc} */ public int getAttributeInt(@NotNull final String attributeName, final boolean queryArchetype) { - String aText = objectText.toString(); // The "real" Archtext from arch & archetype + String aText = getObjectText(); // The "real" Archtext from arch & archetype // Add all attributes from archetype that don't already exist in aText if (queryArchetype && hasArchetype()) { aText += diffArchText(getArchetype().getObjectText(), true); @@ -306,7 +290,7 @@ /** {@inheritDoc} */ public long getAttributeLong(@NotNull final String attributeName, final boolean queryArchetype) { - String aText = objectText.toString(); + String aText = getObjectText(); // Add all attributes from archetype that don't already exist in aText if (queryArchetype && hasArchetype()) { aText += diffArchText(getArchetype().getObjectText(), true); @@ -332,7 +316,7 @@ /** {@inheritDoc} */ public double getAttributeDouble(@NotNull final String attributeName, final boolean queryArchetype) { - String aText = objectText.toString(); + String aText = getObjectText(); // Add all attributes from archetype that don't already exist in aText if (queryArchetype && hasArchetype()) { aText += diffArchText(getArchetype().getObjectText(), true); @@ -567,39 +551,21 @@ archType = type; } - public void setMapX(final int mapx) { - this.mapx = mapx; - } - - public void setMapY(final int mapy) { - this.mapy = mapy; - } - /** {@inheritDoc} */ - @Override public int getMapX() { - return mapx; - } - - /** {@inheritDoc} */ - @Override public int getMapY() { - return mapy; - } - - /** {@inheritDoc} */ - @Override public void addLast(final GameObject arch) { - super.addLast(arch); + @Override public void addLast(@NotNull final GameObject gameObject) { + super.addLast(gameObject); // force type change when a MONSTER is put in a spawn point - if (typeList.getTypeOfArch(this) != null && typeList.getTypeOfArch(this).getTypeNr() == 81 && typeList.getTypeOfArch(arch).getTypeNr() == 80) { - arch.archType = 83; // change to SPAWN_POINT_MOB + if (typeList.getTypeOfArch(this) != null && typeList.getTypeOfArch(this).getTypeNr() == 81 && typeList.getTypeOfArch(gameObject).getTypeNr() == 80) { + gameObject.archType = 83; // change to SPAWN_POINT_MOB } } /** {@inheritDoc} */ - @Override public void addFirst(final GameObject arch) { - super.addFirst(arch); + @Override public void addFirst(@NotNull final GameObject gameObject) { + super.addFirst(gameObject); // force type change when a MONSTER is put in a spawn point - if (typeList.getTypeOfArch(this).getTypeNr() == 81 && typeList.getTypeOfArch(arch).getTypeNr() == 80) { - arch.archType = 83; // change to SPAWN_POINT_MOB + if (typeList.getTypeOfArch(this).getTypeNr() == 81 && typeList.getTypeOfArch(gameObject).getTypeNr() == 80) { + gameObject.archType = 83; // change to SPAWN_POINT_MOB } } @@ -691,33 +657,6 @@ } /** - * Append <var>text</var> to the arch text of this arch. - * @param text text to add - */ - public void addArchText(final String text) { - objectText.append(text); - } - - /** - * Set <var>text</var> as arch text of this arch. - * @param objectText text to set as arch text - */ - public void setObjectText(final String objectText) { - resetArchText(); - this.objectText.append(objectText); - } - - /** {@inheritDoc} */ - @NotNull public String getObjectText() { - return objectText.toString(); - } - - /** Clears the arch text of this arch. */ - public void resetArchText() { - objectText.delete(0, objectText.length()); - } - - /** * Get all entries from the given archtext 'atxt' that don't exist in * 'this' archtext. * @param atxt archtext to compare 'this'-arch with @@ -728,7 +667,7 @@ */ public String diffArchText(final String atxt, final boolean ignoreValues) { final StringBuilder result = new StringBuilder(); - for (String line : atxt.split("\\s*\n")) { + for (final String line : atxt.split("\\s*\n")) { if (ignoreValues) { final int spaceIndex = line.indexOf(" "); if (line.length() > 0 && spaceIndex > 0 && diffTextString(getObjectText(), line.substring(0, spaceIndex + 1), ignoreValues) == null) { @@ -943,11 +882,12 @@ } /** {@inheritDoc} */ - @Override protected GameObject clone() { + @Override @NotNull protected GameObject clone() { try { final GameObject clone = (GameObject) super.clone(); - clone.mapx = -1; - clone.mapy = -1; + clone.objectText = new StringBuffer(getObjectText()); + clone.setMapX(-1); + clone.setMapY(-1); clone.multi = null; clone.setContainer(null); return clone; @@ -969,9 +909,6 @@ final GameObject clone = clone(); // The clone is a new object! // Clone Recursion for complex types - if (objectText != null) { // Arch Text differences - clone.objectText = new StringBuffer(objectText); - } if (msgText != null) { // Message text clone.msgText = new StringBuffer(msgText); } @@ -983,8 +920,8 @@ clone.multiY = multiY; clone.script = new ScriptArchData(clone); // Script data - clone.mapx = posx; - clone.mapy = posy; + clone.setMapX(posx); + clone.setMapY(posy); for (final GameObject tmp : this) { // Inventory clone.addLast(tmp.createClone(-1, -1)); } @@ -1083,9 +1020,9 @@ final CFArchType type = archType != null ? archType : typeList.getTypeOfArch(this); - if (typeList != null && objectText != null && objectText.length() > 0) { + if (typeList != null && hasObjectText()) { final StringBuilder errors = new StringBuilder(); // return value: all error lines - for (String rawLine : objectText.toString().split("\n")) { + for (String rawLine : getObjectText().split("\n")) { final String line = rawLine.trim(); // get only the key-part of the attribute. final String attrKey = line.contains(" ") ? line.substring(0, line.indexOf(" ")) : line; Modified: trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroError.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroError.java 2006-10-07 17:25:26 UTC (rev 492) +++ trunk/daimonin/src/daieditor/map/validation/checks/SysObjectOnLayerZeroError.java 2006-10-07 18:58:03 UTC (rev 493) @@ -43,7 +43,7 @@ /** {@inheritDoc} */ public void correct(final Component parentComponent) { // TODO: Ask user - getGameObject().addArchText("layer 0"); + getGameObject().addObjectText("layer 0"); } } // class SysObjectOnLayerZeroError Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-07 17:25:26 UTC (rev 492) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-07 18:58:03 UTC (rev 493) @@ -11,8 +11,11 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ @SuppressWarnings({"ClassReferencesSubclass"}) -public abstract class GameObject<G extends GameObject> extends GameObjectContainer<G> { +public abstract class GameObject<G extends GameObject<G>> extends GameObjectContainer<G> { + /** Special constant that's used if an arch has no arch type set. */ + public static final int TYPE_UNSET = -666; + /** * If this flag is set, this Archetype is not a "real" Archetype but comes from the artifacts file. * Such Archetypes instances are not included in the Archetype collection process, since the artifacts file is the same for editor and server. @@ -30,9 +33,28 @@ @Nullable private GameObjectContainer<G> container; /** The Archetype of this GameObject. */ - @NotNull protected G archetype; + @NotNull private G archetype; /** + * The objectText with the differences from the Archetype. + * @note Every line in the objectText must end on '\n', including the last line. + * @note This field only is protected until the subclasses do not need it in createClone() any longer. + */ + @NotNull protected StringBuffer objectText = new StringBuffer(); + + /** Map x position if on map. */ + private int mapx; + + /** Map y position if on map. */ + private int mapy; + + /** + * Constructor. + */ + protected GameObject() { + } + + /** * Count the number of all inventory items (recursively). * The returned value does not include this GameObject. * @return number of objects in the inventory (recursively) @@ -47,12 +69,6 @@ } /** - * Returns the object text of this game object as String. - * @return the object text - */ - @NotNull public abstract String getObjectText(); - - /** * Get the requested attribute value of this GameObject as {@link String}. * The attribute value is first searched in this GameObject. * If <code>queryArchetype == true</code>, additional search is done: @@ -172,8 +188,12 @@ * <li>A MapSquare, which means that this GameObject is top level on that MapSquare.</li> * </ul> * @param container container of this GameObject. + * @throws IllegalStateException in case this GameObject is an Archetype (Archetypes must not be added to a map). */ public void setContainer(@Nullable final GameObjectContainer<G> container) { + if (isArchetype()) { + throw new IllegalStateException("Trying to set the container of an Archetype!"); + } this.container = container; } @@ -219,8 +239,8 @@ * This method also takes perfectly well care of multihead arches. */ public void remove() { - final GameObject head = getHead(); - for (GameObject tail = head.getMultiNext(); tail != null; tail = tail.getMultiNext()) { + final G head = getHead(); + for (G tail = head.getMultiNext(); tail != null; tail = tail.getMultiNext()) { if (tail.container != null) { tail.container.remove(tail); } @@ -352,7 +372,9 @@ * @return X coordinate on map * @see #getMapY() */ - public abstract int getMapX(); + public int getMapX() { + return mapx; + } /** * Get the Y coordinate of this GameObject on its map. @@ -361,9 +383,29 @@ * @return Y coordinate on map * @see #getMapX() */ - public abstract int getMapY(); + public int getMapY() { + return mapy; + } /** + * Set the X coordinate of this GameObject on its map. + * @warning Only use this method during the load process. + * @param mapx x coordinate + */ + public void setMapX(final int mapx) { + this.mapx = mapx; + } + + /** + * Set the Y coordinate of this GameObject on its map. + * @warning Only use this method during the load process. + * @param mapy y coordinate + */ + public void setMapY(final int mapy) { + this.mapy = mapy; + } + + /** * Create a new GameObject from this Archetype. * If this GameObject is not an Archetype, this method recursively forwards to its Archetype. * This means that the newly created GameObject will not reflect any differences / attributes specific to this GameObject. @@ -382,4 +424,54 @@ @Nullable public abstract G getMultiNext(); + /** {@inheritDoc} */ + @Override @NotNull protected GameObject<G> clone() throws CloneNotSupportedException { + try { + final GameObject<G> clone = (GameObject<G>) super.clone(); + clone.objectText = new StringBuffer(getObjectText()); + return clone; + } catch (final CloneNotSupportedException e) { + assert false; + throw new AssertionError(); + } + } + + /** + * Returns the object text of this GameObject as String. + * @return the object text + */ + @NotNull public String getObjectText() { + return objectText.toString(); + } + + /** + * Returns whether this GameObject has a set object text. + * @return <code>true</code> if this GameObject has a set object text, otherwise <code>false</code>. + */ + public boolean hasObjectText() { + return objectText.length() > 0; + } + + /** + * Append <var>text</var> to the object text of this GameObject. + * @param text text to add + */ + public void addObjectText(final String text) { + objectText.append(text); + } + + /** Clears the object text of this GameObject. */ + public void resetObjectText() { + objectText.delete(0, objectText.length()); + } + + /** + * Set <var>objectText</var> as object text of this GameObject. + * @param objectText text to set as object text + */ + public void setObjectText(final String objectText) { + resetObjectText(); + this.objectText.append(objectText); + } + } // interface GameObject Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java 2006-10-07 17:25:26 UTC (rev 492) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java 2006-10-07 18:58:03 UTC (rev 493) @@ -43,7 +43,7 @@ * @todo: In case of MapSquares, this class is most likely bogus regarding multipart objects. This needs to be fixed. */ @SuppressWarnings({"ClassReferencesSubclass"}) -public abstract class GameObjectContainer<G extends GameObject> implements Iterable<G>, Serializable { +public abstract class GameObjectContainer<G extends GameObject<G>> implements Iterable<G>, Serializable { /** Serial Version. */ private static final long serialVersionUID = 1L; Modified: trunk/src/app/net/sf/gridarta/map/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapModel.java 2006-10-07 17:25:26 UTC (rev 492) +++ trunk/src/app/net/sf/gridarta/map/MapModel.java 2006-10-07 18:58:03 UTC (rev 493) @@ -10,7 +10,7 @@ * A MapModel reflects the data of a map. * This MapModel interface covers the similarities between the current CFEditor and DaiEditor implementations. */ -public interface MapModel<G extends GameObject> extends Iterable<MapSquare<G>> { +public interface MapModel<G extends GameObject<G>> extends Iterable<MapSquare<G>> { /** * Return the map size of this level. Modified: trunk/src/app/net/sf/gridarta/map/MapSquare.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapSquare.java 2006-10-07 17:25:26 UTC (rev 492) +++ trunk/src/app/net/sf/gridarta/map/MapSquare.java 2006-10-07 18:58:03 UTC (rev 493) @@ -40,7 +40,7 @@ * * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class MapSquare<G extends GameObject> extends GameObjectContainer<G> { +public class MapSquare<G extends GameObject<G>> extends GameObjectContainer<G> { /** The MaoModel this square is associated with. */ @NotNull private final MapModel model; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-07 17:25:32
|
Revision: 492 http://svn.sourceforge.net/gridarta/?rev=492&view=rev Author: christianhujer Date: 2006-10-07 10:25:26 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Updated INSTALL. Modified Paths: -------------- trunk/INSTALL Modified: trunk/INSTALL =================================================================== --- trunk/INSTALL 2006-10-07 17:16:18 UTC (rev 491) +++ trunk/INSTALL 2006-10-07 17:25:26 UTC (rev 492) @@ -8,13 +8,13 @@ Build Requirements ------------------ -* Java 5.0 or newer +* Java Software Development Kit 5.0 or newer * Ant 1.6.5 or newer Runtime Requirements -------------------- -* Java 5.0 or newer +* Java Runtime Environment 5.0 or newer Howto Build This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-07 17:16:27
|
Revision: 491 http://svn.sourceforge.net/gridarta/?rev=491&view=rev Author: christianhujer Date: 2006-10-07 10:16:18 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Updated README. Modified Paths: -------------- trunk/README Modified: trunk/README =================================================================== --- trunk/README 2006-10-07 15:37:20 UTC (rev 490) +++ trunk/README 2006-10-07 17:16:18 UTC (rev 491) @@ -22,22 +22,26 @@ ------------------- Gridarta is a map editor for 2D MMORPGs. The current target applications are: -* Angelion http://angelion.sric.com/ * Crossfire http://crossfire.real-time.com/ * Daimonin http://www.daimonin.net/ +Additionally the following applications are planned targets: +* Angelion http://angelion.sric.com/ + PROJECT WEBSITE --------------- -Project homepage: http://gridarta.sourceforge.net/ -Project website: http://sourceforge.net/projects/gridarta/ +Project homepage: http://gridarta.sourceforge.net/ +Project website: http://sourceforge.net/projects/gridarta/ +Project statistics: http://cia.navi.cx/stats/project/gridarta SYSTEM REQUIREMENTS ------------------- Java 5.0 Previous versions of Java will not work. Gridarta uses Generics, autoboxing, - static imports, foreach loops, assertions and varargs quite a lot. + static imports, foreach loops, assertions, covariant return types and varargs + quite a lot. Ant 1.6.5 Previous versions of Ant might work but are not tested. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-07 15:37:36
|
Revision: 490 http://svn.sourceforge.net/gridarta/?rev=490&view=rev Author: christianhujer Date: 2006-10-07 08:37:20 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Merged Archetype related code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-07 14:41:30 UTC (rev 489) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-07 15:37:20 UTC (rev 490) @@ -90,9 +90,6 @@ private int archTextCount; // lines inserted in ArchText - /** The Archetype of this GameObject. */ - @NotNull private GameObject archetype = this; - /** Map x position if on map. */ private int mapx; @@ -146,6 +143,7 @@ /** Create an GameObject. */ public GameObject() { + setArchetype(this); script = null; // this object stays 'null' unless there are events defined myId = myIdCounter++; // increase ID counter for every new arch created @@ -175,23 +173,6 @@ } /** {@inheritDoc} */ - public GameObject getArchetype() { - return archetype; - } - - /** {@inheritDoc} - * @note DO NOT INVOKE DIRECTLY YET! - */ - public void setArchetype(final GameObject archetype) { - this.archetype = archetype; - } - - /** {@inheritDoc} */ - public boolean isArchetype() { - return archetype == this; - } - - /** {@inheritDoc} */ public int getEditType() { return editType; } @@ -278,7 +259,7 @@ int j; attributeName = attributeName.trim() + " "; // attributeName must be followed by space String result = ""; - if (archetype == getArchetype()) { + if (queryArchetype) { result = getCachedAttributeValue(attributeName); if (result != null) { return result; @@ -286,8 +267,8 @@ result = ""; } // Add all attributes from archetype that don't already exist in aText - if (archetype != null) { - aText = aText + diffArchText(archetype.getObjectText(), true); + if (queryArchetype && hasArchetype()) { + aText = aText + diffArchText(getArchetype().getObjectText(), true); } if (!aText.endsWith("\n")) { @@ -308,7 +289,7 @@ j = i + 1; } } - if (archetype == getArchetype()) { + if (queryArchetype) { setCachedAttributeValue(attributeName, result); } @@ -324,8 +305,8 @@ public int getAttributeInt(@NotNull final String attributeName, final boolean queryArchetype) { String aText = objectText.toString(); // The "real" Archtext from arch & archetype // Add all attributes from archetype that don't already exist in aText - if (archetype != null) { - aText += diffArchText(archetype.getObjectText(), true); + if (queryArchetype && hasArchetype()) { + aText += diffArchText(getArchetype().getObjectText(), true); } assert aText.endsWith("\n"); final String attr2 = attributeName.trim() + ' '; @@ -351,8 +332,8 @@ public long getAttributeLong(@NotNull final String attributeName, final boolean queryArchetype) { String aText = objectText.toString(); // Add all attributes from archetype that don't already exist in aText - if (archetype != null) { - aText += diffArchText(archetype.getObjectText(), true); + if (queryArchetype && hasArchetype()) { + aText += diffArchText(getArchetype().getObjectText(), true); } final String attr2 = attributeName.trim() + ' '; long result = 0; @@ -377,8 +358,8 @@ public double getAttributeDouble(@NotNull final String attributeName, final boolean queryArchetype) { String aText = objectText.toString(); // Add all attributes from archetype that don't already exist in aText - if (archetype != null) { - aText += diffArchText(archetype.getObjectText(), true); + if (queryArchetype && hasArchetype()) { + aText += diffArchText(getArchetype().getObjectText(), true); } final String attr2 = attributeName.trim() + ' '; double result = 0; @@ -761,6 +742,7 @@ * @return best suitable descriptive name */ public String getBestName() { + final GameObject archetype = getArchetype(); if (objName != null && objName.length() > 0) { return objName; } else if (archetype != null && archetype.objName != null && archetype.objName.length() > 0) { @@ -1058,7 +1040,7 @@ clone.script = script.getClone(); // clone scripting data } - clone.archetype = archetype; // default arch + clone.setArchetype(getArchetype()); // default arch clone.noface = noface; // if true, arch has no face as default clone.facenr = facenr; // the index of faceImages[] @@ -1292,7 +1274,7 @@ /** {@inheritDoc} */ public GameObject createArch() { if (!isArchetype()) { - return archetype.createArch(); + return getArchetype().createArch(); } final GameObject arch = new GameObject(); arch.setArchetypeName(archetypeName); Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-07 14:41:30 UTC (rev 489) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-07 15:37:20 UTC (rev 490) @@ -94,9 +94,6 @@ */ @Nullable private StringBuffer msgText; - /** The Archetype of this GameObject. */ - @NotNull private GameObject archetype; - /** Map x position if on map. */ private int mapx; @@ -176,46 +173,6 @@ } /** {@inheritDoc} */ - public GameObject getArchetype() { - return archetype; - } - - /** {@inheritDoc} */ - public void setArchetype(final GameObject archetype) { - this.archetype = archetype; - } - - /** Set this to default arch. */ - public void setIsArchetype() { - this.archetype = this; - } - - /** {@inheritDoc} */ - public boolean isArchetype() { - return archetype == this; - } - - /** - * Check whether this GameObject has an Archetype. - * @return <code>true</code> when this GameObject has a default arch or is - * a default arch itself, otherwise <code>false</code> - */ - public boolean hasArchetype() { - return getArchetype() != null; - } - - /** - * Check whether this GameObject has the same default arch as another - * GameObject. - * @param other other GameObject - * @return <code>true</code> when this GameObject has the same default arch - * as the other GameObject, otherwise <code>false</code> - */ - public boolean hasSameArchetype(final GameObject other) { - return getArchetype() == other.getArchetype(); - } - - /** {@inheritDoc} */ public int getEditType() { return editType; } @@ -302,8 +259,8 @@ @NotNull public String getAttributeString(@NotNull final String attributeName, final boolean queryArchetype) { String aText = objectText.toString(); // The "real" Archtext from arch & archetype // Add all attributes from archetype that don't already exist in aText - if (queryArchetype) { - aText += diffArchText(archetype.getObjectText(), true); + if (queryArchetype && hasArchetype()) { + aText += diffArchText(getArchetype().getObjectText(), true); } final String attr2 = attributeName.trim() + ' '; // attributeName must be followed by space String result = ""; // returned String @@ -324,8 +281,8 @@ public int getAttributeInt(@NotNull final String attributeName, final boolean queryArchetype) { String aText = objectText.toString(); // The "real" Archtext from arch & archetype // Add all attributes from archetype that don't already exist in aText - if (archetype != null) { - aText += diffArchText(archetype.getObjectText(), true); + if (queryArchetype && hasArchetype()) { + aText += diffArchText(getArchetype().getObjectText(), true); } assert aText.endsWith("\n"); final String attr2 = attributeName.trim() + ' '; @@ -351,8 +308,8 @@ public long getAttributeLong(@NotNull final String attributeName, final boolean queryArchetype) { String aText = objectText.toString(); // Add all attributes from archetype that don't already exist in aText - if (archetype != null) { - aText += diffArchText(archetype.getObjectText(), true); + if (queryArchetype && hasArchetype()) { + aText += diffArchText(getArchetype().getObjectText(), true); } final String attr2 = attributeName.trim() + ' '; long result = 0; @@ -377,8 +334,8 @@ public double getAttributeDouble(@NotNull final String attributeName, final boolean queryArchetype) { String aText = objectText.toString(); // Add all attributes from archetype that don't already exist in aText - if (archetype != null) { - aText += diffArchText(archetype.getObjectText(), true); + if (queryArchetype && hasArchetype()) { + aText += diffArchText(getArchetype().getObjectText(), true); } final String attr2 = attributeName.trim() + ' '; double result = 0; @@ -681,6 +638,7 @@ * @return best suitable descriptive name */ public String getBestName() { + final GameObject archetype = getArchetype(); if (objName != null && objName.length() > 0) { return objName; } else if (archetype != null && archetype.objName != null && archetype.objName.length() > 0) { @@ -799,7 +757,7 @@ * @param name */ public boolean setRealFace(final String name) { - final String face = archetype.faceRealName; + final String face = getArchetype().faceRealName; /* no name? we always use def arch face */ if (name == null || name.trim().length() == 0) { @@ -826,8 +784,8 @@ // lets check we have in this object or the default arch of it an animation if (effectiveAnimName == null) { faceobjdesc = FaceDesc.DEFARCH_ANIM; - if (archetype != null) { - effectiveAnimName = archetype.animName; + if (hasArchetype()) { + effectiveAnimName = getArchetype().animName; } } @@ -858,8 +816,8 @@ faceobjdesc = FaceDesc.FACE; if (effectiveFaceObjName == null) { faceobjdesc = FaceDesc.DEFARCH_FACE; - if (archetype != null) { - effectiveFaceObjName = archetype.faceRealName; + if (hasArchetype()) { + effectiveFaceObjName = getArchetype().faceRealName; } } } @@ -875,7 +833,7 @@ } else { faceobjdesc = FaceDesc.FACE_NOT_FOUND; } - if (archetype != this) { + if (!isArchetype()) { setFace(); } } @@ -885,7 +843,7 @@ * This method is for speeding up rendering. */ private void setFace() { - if (archetype == null) { + if (!hasArchetype()) { normalFace = CMainControl.noarchTileIcon; transFace = normalFace; } else if (hasFaceObject()) { @@ -1176,7 +1134,7 @@ /** {@inheritDoc} */ public GameObject createArch() { if (!isArchetype()) { - return archetype.createArch(); + return getArchetype().createArch(); } final GameObject arch = new GameObject(); arch.setArchetypeName(archetypeName); Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-07 14:41:30 UTC (rev 489) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-07 15:37:20 UTC (rev 490) @@ -29,6 +29,9 @@ */ @Nullable private GameObjectContainer<G> container; + /** The Archetype of this GameObject. */ + @NotNull protected G archetype; + /** * Count the number of all inventory items (recursively). * The returned value does not include this GameObject. @@ -236,25 +239,31 @@ * @see #isArchetype() * @see #setArchetype(GameObject) */ - @NotNull public abstract G getArchetype(); + @NotNull public G getArchetype() { + return archetype; + } /** - * Get the name of the Archetype this GameObject is based on. - * For an Archetype this method simply returns its name. - * @return the name of the Archetype this GameObject is based on - */ - @NotNull public abstract String getArchetypeName(); - - /** * Returns whether this GameObject is an Archetype. * @return <code>true</code> if this GameObject is an Archetype, otherwise <code>false</code> * @see #getArchetype() * @see #setArchetype(GameObject) * @see #isArtifact() */ - public abstract boolean isArchetype(); + public boolean isArchetype() { + return archetype == this; + } /** + * Check whether this GameObject has an Archetype. + * @return <code>true</code> when this GameObject has a default arch or is + * a default arch itself, otherwise <code>false</code> + */ + public boolean hasArchetype() { + return archetype != null; + } + + /** * Set the Archetype of this GameObject. * @param archetype new Archetype of this GameObject. * @note currently this method takes a GameObject that reflects the Archetype data because there is no separate Archetype class. @@ -262,9 +271,34 @@ * @see #getArchetype() * @see #isArchetype() */ - public abstract void setArchetype(@NotNull final G archetype); + public void setArchetype(@NotNull final G archetype) { + this.archetype = archetype; + } + /** Set that this GameObject is an Archetype. */ + public void setIsArchetype() { + setArchetype((G) this); + } + /** + * Check whether this GameObject has the same default arch as another + * GameObject. + * @param other other GameObject + * @return <code>true</code> when this GameObject has the same default arch + * as the other GameObject, otherwise <code>false</code> + */ + public boolean hasSameArchetype(final G other) { + return archetype == other.archetype; + } + + /** + * Get the name of the Archetype this GameObject is based on. + * For an Archetype this method simply returns its name. + * @return the name of the Archetype this GameObject is based on + */ + @NotNull public abstract String getArchetypeName(); + + /** * Returns whether this GameObject is an Artifact. * Artifacts are special forms of Archetypes, and they are excluded from Archetypes collection. * @return <code>true</code> if this GameObject is an Artifact, otherwise <code>false</code>. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-07 14:41:48
|
Revision: 489 http://svn.sourceforge.net/gridarta/?rev=489&view=rev Author: christianhujer Date: 2006-10-07 07:41:30 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Merged container related GameObject features. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-07 14:24:41 UTC (rev 488) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-07 14:41:30 UTC (rev 489) @@ -38,8 +38,6 @@ import java.util.HashMap; import java.util.List; import javax.swing.JList; -import net.sf.gridarta.gameobject.GameObjectContainer; -import net.sf.gridarta.map.MapSquare; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -132,16 +130,6 @@ private boolean editflag; // if true, object is in a editor /** - * Container of this GameObject. - * There are two possibilities for the container: - * <ul> - * <li>Another GameObject, which means this object is in the inventory of that GameObject.</li> - * <li>A MapSquare, which means that this GameObject is top level on that MapSquare.</li> - * </ul> - */ - private GameObjectContainer<GameObject> container; - - /** * All inventory objects. Set to {@link Collections#EMPTY_LIST} * (to save space) if the object has no inventory. */ @@ -411,69 +399,7 @@ return getAttributeDouble(attributeName, true); } - /** {@inheritDoc} */ - @NotNull public GameObjectContainer<GameObject> getContainer() { - return container; - } - - /** {@inheritDoc} */ - @NotNull public GameObject getTopContainer() { - return isInContainer() ? ((GameObject) container).getTopContainer() : this; - } - - /** {@inheritDoc} */ - public void setContainer(final GameObjectContainer<GameObject> container) { - this.container = container; - } - - /** {@inheritDoc} */ - public boolean isInContainer() { - return container != null && container instanceof GameObject; - } - - /** {@inheritDoc} */ - @Override public MapSquare<GameObject> getMapSquare() { - return container != null ? container.getMapSquare() : null; - } - - /** Move this GameObject top. */ - public void moveTop() { - container.moveTop(this); - } - - /** Move this GameObject up. */ - public void moveUp() { - container.moveUp(this); - } - - /** Move this GameObject down. */ - public void moveDown() { - container.moveDown(this); - } - - /** Move this GameObject bottom. */ - public void moveBottom() { - container.moveBottom(this); - } - /** - * Remove this GameObject from its container. Do nothing if the object is - * not inside a container. - * This method also takes perfectly well care of multihead arches. - */ - public void remove() { - final GameObject head = getHead(); - for (GameObject tail = head.getMultiNext(); tail != null; tail = tail.getMultiNext()) { - if (tail.container != null) { - tail.container.remove(tail); - } - } - if (head.container != null) { - head.container.remove(head); - } - } - - /** * Set the String of an arch attribute in the objectText. * @param attributeName search for "attributeName <string>" * @param value value to set Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-07 14:24:41 UTC (rev 488) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-07 14:41:30 UTC (rev 489) @@ -37,10 +37,9 @@ import java.io.Serializable; import javax.swing.ImageIcon; import javax.swing.JList; +import net.sf.gridarta.gameobject.GameObjectContainer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import net.sf.gridarta.gameobject.GameObjectContainer; -import net.sf.gridarta.map.MapSquare; /** * The <code>GameObject</code> class handles the Daimonin GameObjects. @@ -150,16 +149,6 @@ private int direction; - /** - * Container of this GameObject. - * There are two possibilities for the container: - * <ul> - * <li>Another GameObject, which means this object is in the inventory of that GameObject.</li> - * <li>A MapSquare, which means that this GameObject is top level on that MapSquare.</li> - * </ul> - */ - private GameObjectContainer<GameObject> container; - private int archType; // CF object type of the arch /** Edit Type. */ @@ -410,69 +399,7 @@ return getAttributeDouble(attributeName, true); } - /** {@inheritDoc} */ - @NotNull public GameObjectContainer<GameObject> getContainer() { - return container; - } - - /** {@inheritDoc} */ - @NotNull public GameObject getTopContainer() { - return isInContainer() ? ((GameObject) container).getTopContainer() : this; - } - - /** {@inheritDoc} */ - public void setContainer(final GameObjectContainer<GameObject> container) { - this.container = container; - } - - /** {@inheritDoc} */ - public boolean isInContainer() { - return container != null && container instanceof GameObject; - } - - /** {@inheritDoc} */ - @Override public MapSquare<GameObject> getMapSquare() { - return container != null ? container.getMapSquare() : null; - } - - /** Move this GameObject top. */ - public void moveTop() { - container.moveTop(this); - } - - /** Move this GameObject up. */ - public void moveUp() { - container.moveUp(this); - } - - /** Move this GameObject down. */ - public void moveDown() { - container.moveDown(this); - } - - /** Move this GameObject bottom. */ - public void moveBottom() { - container.moveBottom(this); - } - /** - * Remove this GameObject from its container. Do nothing if the object is - * not inside a container. - * This method also takes perfectly well care of multihead arches. - */ - public void remove() { - final GameObject head = getHead(); - for (GameObject tail = head.getMultiNext(); tail != null; tail = tail.getMultiNext()) { - if (tail.container != null) { - tail.container.remove(tail); - } - } - if (head.container != null) { - head.container.remove(head); - } - } - - /** * Insert a GameObject before this GameObject. * @param node GameObject to append */ @@ -1064,7 +991,7 @@ clone.mapx = -1; clone.mapy = -1; clone.multi = null; - clone.container = null; + clone.setContainer(null); return clone; } catch (final CloneNotSupportedException e) { assert false; @@ -1267,7 +1194,7 @@ * @param other GameObject that is to replace this one */ public void replace(final GameObject other) { - container.replace(this, other); + getContainer().replace(this, other); } /** Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-07 14:24:41 UTC (rev 488) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-07 14:41:30 UTC (rev 489) @@ -2,6 +2,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import net.sf.gridarta.map.MapSquare; /** * A GameObject instance reflects a GameObject (object on a map) or an Archetype. @@ -19,6 +20,16 @@ private boolean artifact; /** + * Container of this GameObject. + * There are two possibilities for the container: + * <ul> + * <li>Another GameObject, which means this object is in the inventory of that GameObject.</li> + * <li>A MapSquare, which means that this GameObject is top level on that MapSquare.</li> + * </ul> + */ + @Nullable private GameObjectContainer<G> container; + + /** * Count the number of all inventory items (recursively). * The returned value does not include this GameObject. * @return number of objects in the inventory (recursively) @@ -135,7 +146,9 @@ * @return container of this GameObject. * @see #getTopContainer() */ - @Nullable public abstract GameObjectContainer<G> getContainer(); // todo: change return type to something more specific. + @Nullable public GameObjectContainer<G> getContainer() { + return container; + } /** * Get the topmost container of this GameObject (in Game sense, which @@ -144,7 +157,9 @@ * If this object is topmost itself, it returns itself. * @see #getContainer() */ - @NotNull public abstract G getTopContainer(); + @NotNull public G getTopContainer() { + return (G) (isInContainer() ? ((G) container).getTopContainer() : this); + } /** * Sets container of this GameObject. @@ -155,7 +170,9 @@ * </ul> * @param container container of this GameObject. */ - public abstract void setContainer(final GameObjectContainer<G> container); + public void setContainer(@Nullable final GameObjectContainer<G> container) { + this.container = container; + } /** * Check whether this GameObject is in a Container (in Daimonin sense, @@ -164,9 +181,53 @@ * Container is an GameObject, otherwise (no Container or Container is not * an GameObject) false */ - public abstract boolean isInContainer(); + public boolean isInContainer() { + return container != null && container instanceof GameObject; + } + /** {@inheritDoc} */ + @Override public MapSquare<G> getMapSquare() { + return container != null ? container.getMapSquare() : null; + } + + /** Move this GameObject top. */ + public void moveTop() { + container.moveTop((G) this); + } + + /** Move this GameObject up. */ + public void moveUp() { + container.moveUp((G) this); + } + + /** Move this GameObject down. */ + public void moveDown() { + container.moveDown((G) this); + } + + /** Move this GameObject bottom. */ + public void moveBottom() { + container.moveBottom((G) this); + } + /** + * Remove this GameObject from its container. Do nothing if the object is + * not inside a container. + * This method also takes perfectly well care of multihead arches. + */ + public void remove() { + final GameObject head = getHead(); + for (GameObject tail = head.getMultiNext(); tail != null; tail = tail.getMultiNext()) { + if (tail.container != null) { + tail.container.remove(tail); + } + } + if (head.container != null) { + head.container.remove(head); + } + } + + /** * Get the Archetype this GameObject is based on. * @return Archetype this GameObject is based on. * @note For Archetypes, this method returns <code>thus</code>. @@ -277,4 +338,14 @@ */ public abstract G createArch(); + /** + * Return the head part of a multi-part object. For single-part objects it + * is the object itself. + * + * @return the head of the object + */ + public abstract G getHead(); + + @Nullable public abstract G getMultiNext(); + } // interface GameObject This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-07 14:24:55
|
Revision: 488 http://svn.sourceforge.net/gridarta/?rev=488&view=rev Author: christianhujer Date: 2006-10-07 07:24:41 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Fixed unspecified return type. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-07 14:21:57 UTC (rev 487) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-07 14:24:41 UTC (rev 488) @@ -412,7 +412,7 @@ } /** {@inheritDoc} */ - @NotNull public GameObjectContainer getContainer() { + @NotNull public GameObjectContainer<GameObject> getContainer() { return container; } Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-07 14:21:57 UTC (rev 487) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-07 14:24:41 UTC (rev 488) @@ -411,7 +411,7 @@ } /** {@inheritDoc} */ - @NotNull public GameObjectContainer getContainer() { + @NotNull public GameObjectContainer<GameObject> getContainer() { return container; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-07 14:22:02
|
Revision: 487 http://svn.sourceforge.net/gridarta/?rev=487&view=rev Author: christianhujer Date: 2006-10-07 07:21:57 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Removed unused next and prev fields. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-07 14:12:12 UTC (rev 486) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-07 14:21:57 UTC (rev 487) @@ -131,10 +131,6 @@ private boolean editflag; // if true, object is in a editor - private GameObject next; // to chain ArchObjects in maps - - private GameObject prev; // same - /** * Container of this GameObject. * There are two possibilities for the container: @@ -181,8 +177,6 @@ editflag = false; join = null; // no autojoin list per default archType = TYPE_UNSET; // type must be set - next = null; - prev = null; mapx = 0; mapy = 0; editType = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-07 14:12:28
|
Revision: 486 http://svn.sourceforge.net/gridarta/?rev=486&view=rev Author: christianhujer Date: 2006-10-07 07:12:12 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Some GameObject unification. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-07 14:01:36 UTC (rev 485) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2006-10-07 14:12:12 UTC (rev 486) @@ -91,7 +91,6 @@ public ArchetypeSet(final CMainControl mainControl) { this.mainControl = mainControl; faceListCount = 0; - GameObject.setArchetypeSet(this); // add static reference to GameObject } /** Returns the index of a face in the face map or -1. Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-07 14:01:36 UTC (rev 485) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2006-10-07 14:12:12 UTC (rev 486) @@ -56,9 +56,6 @@ /** Special constant that's used if an arch has no arch type set. */ public static final int TYPE_UNSET = -666; - /** Static reference to the ArchetypeSet (Archetypes). */ - private static ArchetypeSet archetypeSet; - /** Static reference to the typeList (find syntax errors). */ private static CFArchTypeList typeList; @@ -130,13 +127,6 @@ private boolean noface; // if true, arch has no face as default - /** - * If this flag is set, the arch is not a "real" arch but comes from the - * artifacts file. Such GameObject instances are not included in the arch - * collection, since the artifacts file is the same for editor and server. - */ - private boolean artifact; - private int facenr; // the index of faceImages[] private boolean editflag; // if true, object is in a editor @@ -183,7 +173,6 @@ objName = null; noface = true; // this sucker has no face - artifact = false; // will be true for arches from the artifacts file faceName = null; // if there is a face cmd, this is the face name facenr = -1; // if we have a face AND we have loaded the face, this is his number. // if faceName != null and facenr == -1, we haven't loaded the face @@ -199,14 +188,6 @@ editType = 0; } - /** - * Set the ArchetypeSet to get information on Archetypes. - * @param archetypeSet ArchetypeSet - */ - public static void setArchetypeSet(final ArchetypeSet archetypeSet) { - GameObject.archetypeSet = archetypeSet; - } - public static void setTypeList(final CFArchTypeList tlist) { typeList = tlist; } @@ -603,16 +584,6 @@ myId = num; } - /** {@inheritDoc} */ - public void setArtifact(final boolean artifact) { - this.artifact = artifact; - } - - /** {@inheritDoc} */ - public boolean isArtifact() { - return artifact; - } - /** * Insert an GameObject before this GameObject. * @param node GameObject to append @@ -629,16 +600,6 @@ getContainer().insertAfter(this, node); } - /** {@inheritDoc} */ - public int countInvObjects() { - int count = 0; - for (final GameObject arch : this) { - count++; - count += arch.countInvObjects(); - } - return count; - } - /** * Determine the horizontal extent in tiles. For single-part objects 1 is * returned. Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-07 14:01:36 UTC (rev 485) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2006-10-07 14:12:12 UTC (rev 486) @@ -139,13 +139,6 @@ private boolean noface; - /** - * If this flag is set, the arch is not a "real" arch but comes from the - * artifacts file. Such GameObject instances are not included in the arch - * collection, since the artifacts file is the same for editor and server. - */ - private boolean artifact; - /** State where the face comes from. */ private FaceDesc faceobjdesc; @@ -219,7 +212,7 @@ * a default arch itself, otherwise <code>false</code> */ public boolean hasArchetype() { - return archetype != null; + return getArchetype() != null; } /** @@ -230,7 +223,7 @@ * as the other GameObject, otherwise <code>false</code> */ public boolean hasSameArchetype(final GameObject other) { - return archetype == other.archetype; + return getArchetype() == other.getArchetype(); } /** {@inheritDoc} */ @@ -442,16 +435,6 @@ return container != null ? container.getMapSquare() : null; } - /** {@inheritDoc} */ - public void setArtifact(final boolean artifact) { - this.artifact = artifact; - } - - /** {@inheritDoc} */ - public boolean isArtifact() { - return artifact; - } - /** Move this GameObject top. */ public void moveTop() { container.moveTop(this); @@ -505,16 +488,6 @@ getContainer().insertAfter(this, node); } - /** {@inheritDoc} */ - public int countInvObjects() { - int count = 0; - for (final GameObject arch : this) { - count++; - count += arch.countInvObjects(); - } - return count; - } - /** * Determine the horizontal extent in tiles. For single-part objects 1 is * returned. Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-07 14:01:36 UTC (rev 485) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2006-10-07 14:12:12 UTC (rev 486) @@ -4,7 +4,8 @@ import org.jetbrains.annotations.Nullable; /** - * This interface serves as a common interface for GameObjects for Daimonin and Crossfire to allow classes that use GameObjects being reused and moved to Gridarta. + * A GameObject instance reflects a GameObject (object on a map) or an Archetype. + * This abstract class serves as a common base for GameObjects for Daimonin and Crossfire to allow classes that use GameObjects being reused and moved to Gridarta. * * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ @@ -12,11 +13,24 @@ public abstract class GameObject<G extends GameObject> extends GameObjectContainer<G> { /** + * If this flag is set, this Archetype is not a "real" Archetype but comes from the artifacts file. + * Such Archetypes instances are not included in the Archetype collection process, since the artifacts file is the same for editor and server. + */ + private boolean artifact; + + /** * Count the number of all inventory items (recursively). * The returned value does not include this GameObject. * @return number of objects in the inventory (recursively) */ - public abstract int countInvObjects(); + public int countInvObjects() { + int count = 0; + for (final GameObject arch : this) { + count++; + count += arch.countInvObjects(); + } + return count; + } /** * Returns the object text of this game object as String. @@ -197,14 +211,18 @@ * @see #setArtifact(boolean) * @see #isArchetype() */ - public abstract boolean isArtifact(); + public boolean isArtifact() { + return artifact; + } /** * Sets whether this GameObject is an Artifact. * @param artifact <code>true</code> if this GameObject is an Artifact, otherwise <code>false</code>. * @see #isArtifact() */ - public abstract void setArtifact(boolean artifact); + public void setArtifact(final boolean artifact) { + this.artifact = artifact; + } /** * Get the EditType of an GameObject (e.g. floor, monster, etc). These are This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2006-10-07 14:01:52
|
Revision: 485 http://svn.sourceforge.net/gridarta/?rev=485&view=rev Author: christianhujer Date: 2006-10-07 07:01:36 -0700 (Sat, 07 Oct 2006) Log Message: ----------- Some MapModel unification and cleanup. Modified Paths: -------------- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapModel.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/MapModel.java trunk/src/app/net/sf/gridarta/map/MapModel.java Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-10-07 13:41:41 UTC (rev 484) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-10-07 14:01:36 UTC (rev 485) @@ -213,8 +213,8 @@ } /** {@inheritDoc} */ - public MapSquare<GameObject> getMapSquare(final Point p) throws ArrayIndexOutOfBoundsException { - return mapGrid[p.x][p.y]; + public MapSquare<GameObject> getMapSquare(@NotNull final Point pos) throws ArrayIndexOutOfBoundsException { + return mapGrid[pos.x][pos.y]; } /** Modified: trunk/crossfire/src/cfeditor/map/MapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapModel.java 2006-10-07 13:41:41 UTC (rev 484) +++ trunk/crossfire/src/cfeditor/map/MapModel.java 2006-10-07 14:01:36 UTC (rev 485) @@ -2,10 +2,9 @@ import cfeditor.gameobject.GameObject; import java.awt.Point; -import java.util.Iterator; +import net.sf.gridarta.map.MapSquare; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import net.sf.gridarta.map.MapSquare; /** * Interface for MapModels. @@ -19,17 +18,6 @@ /** Disable autojoin when inserting objects. */ boolean JOIN_DISABLE = false; - /** {@inheritDoc} */ - Iterator<MapSquare<GameObject>> iterator(); - - /** - * Get the square at a specified location. - * @param p location to get square at - * @return square at <var>p</var> - * @throws ArrayIndexOutOfBoundsException in case p specifies a location that's not valid within this map model - */ - MapSquare<GameObject> getMapSquare(Point p) throws ArrayIndexOutOfBoundsException; - @Nullable Point getMouseRightPos(); @Deprecated boolean addArchToMap(String archname, int xx, int yy, int intern, boolean join, boolean insertBelow); Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-10-07 13:41:41 UTC (rev 484) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-10-07 14:01:36 UTC (rev 485) @@ -185,8 +185,8 @@ } /** {@inheritDoc} */ - public MapSquare<GameObject> getMapSquare(final Point p) throws ArrayIndexOutOfBoundsException { - return mapGrid[p.x][p.y]; + public MapSquare<GameObject> getMapSquare(@NotNull final Point pos) throws ArrayIndexOutOfBoundsException { + return mapGrid[pos.x][pos.y]; } /** Modified: trunk/daimonin/src/daieditor/map/MapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapModel.java 2006-10-07 13:41:41 UTC (rev 484) +++ trunk/daimonin/src/daieditor/map/MapModel.java 2006-10-07 14:01:36 UTC (rev 485) @@ -3,10 +3,9 @@ import daieditor.gameobject.GameObject; import java.awt.Point; import java.io.Serializable; -import java.util.Iterator; +import net.sf.gridarta.map.MapSquare; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import net.sf.gridarta.map.MapSquare; /** * Interface for MapModels. @@ -19,20 +18,9 @@ * And there is no rollback. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public interface MapModel extends Iterable<MapSquare<GameObject>>, net.sf.gridarta.map.MapModel<GameObject>, Serializable { +public interface MapModel extends net.sf.gridarta.map.MapModel<GameObject>, Serializable { - /** {@inheritDoc} */ - Iterator<MapSquare<GameObject>> iterator(); - /** - * Get the square at a specified location. - * @param p location to get square at - * @return square at <var>p</var> - * @throws ArrayIndexOutOfBoundsException in case p specifies a location that's not valid within this map model - */ - MapSquare<GameObject> getMapSquare(Point p) throws ArrayIndexOutOfBoundsException; - - /** * Get the currently selected map square. * @return currently selected map square * @deprecated this method requires MapModel implementations to know their views Modified: trunk/src/app/net/sf/gridarta/map/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapModel.java 2006-10-07 13:41:41 UTC (rev 484) +++ trunk/src/app/net/sf/gridarta/map/MapModel.java 2006-10-07 14:01:36 UTC (rev 485) @@ -10,7 +10,7 @@ * A MapModel reflects the data of a map. * This MapModel interface covers the similarities between the current CFEditor and DaiEditor implementations. */ -public interface MapModel<G extends GameObject> { +public interface MapModel<G extends GameObject> extends Iterable<MapSquare<G>> { /** * Return the map size of this level. @@ -55,4 +55,12 @@ */ void squareChanged(@NotNull final MapSquare<G> square); + /** + * Get the square at a specified location. + * @param pos location to get square at + * @return square at <var>p</var> + * @throws ArrayIndexOutOfBoundsException in case p specifies a location that's not valid within this map model + */ + MapSquare<G> getMapSquare(@NotNull Point pos) throws ArrayIndexOutOfBoundsException; + } // interface MapModel This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |