|
From: <cro...@li...> - 2002-12-18 22:33:34
|
Module Name: CFJavaEditor
Committed By: avogl
Date: Wed Dec 18 22:33:32 UTC 2002
Modified Files:
CFJavaEditor: CFJavaEditor.jar
CFJavaEditor/resource/conf: archetypes crossfire.0 types.txt
CFJavaEditor/src/cfeditor: ArchObject.java ArchObjectParser.java
ArchObjectStack.java CAttribBitmask.java CAttribDialog.java
CFArchAttrib.java CFArchType.java CFArchTypeList.java
CFJavaEditor.java CFTreasureListTree.java CFileReader.java
CMainControl.java CMainView.java CMapControl.java CMapModel.java
CMapPropertiesDialog.java CMapTileList.java CMapViewBasic.java
CNewMapDialog.java IGUIConstants.java MapArchObject.java
Log Message:
CFJavaEditor update:
o Bitmasks and Lists (for the arch syntax) can now be
defined directly in "types.txt", rather than in the code.
This means it is now completely trivial to support new
bitmask or list fields on editor-side: Just add them in
"types.txt" and there you go...
o I've updated the "types.txt" file to take advantage of
the described new feature.
o All multipart-specific data has been removed from the
general ArchObject class and seperated to MultiArchData.
This data-"encapsulation" can save some memory, as most of the
objects are *not* multiparts and hence don't need those
extra-variables.
o Arches have been recollected so the editor has now all
new arches/images included.
--AndreasV
The following files had too many changes to show the context diffs here:
cvs rdiff -r1.6 -r1.7 CFJavaEditor/resource/conf/archetypes
cvs rdiff -r1.4 -r1.5 CFJavaEditor/resource/conf/types.txt
cvs rdiff -r1.4 -r1.5 CFJavaEditor/src/cfeditor/ArchObject.java
cvs rdiff -r1.5 -r1.6 CFJavaEditor/src/cfeditor/CAttribDialog.java
cvs rdiff -r1.3 -r1.4 CFJavaEditor/src/cfeditor/CFArchAttrib.java
Start of context diffs
Index: CFJavaEditor/CFJavaEditor.jar
Index: CFJavaEditor/src/cfeditor/ArchObjectParser.java
diff -c CFJavaEditor/src/cfeditor/ArchObjectParser.java:1.2 CFJavaEditor/src/cfeditor/ArchObjectParser.java:1.3
*** CFJavaEditor/src/cfeditor/ArchObjectParser.java:1.2 Mon Sep 9 10:49:29 2002
--- CFJavaEditor/src/cfeditor/ArchObjectParser.java Wed Dec 18 14:33:32 2002
***************
*** 235,244 ****
//System.out.println("Arch "+ arch.getArchName()+" has no type info!");
// we got full arch
parsearch = false; // we write this sucker
- archmore = false; // we assume this is last... but perhaps..
- // add arch here (ommiting the map arch)
- //if (!arch.getArchName().equals(STARTARCH_NAME)) {
arch.setRefNr(first_arch);
if(first_arch != -1) {
// add to head our x/y position so he can setup refmax
--- 235,241 ----
***************
*** 291,297 ****
}
postParseDefArch(arch);
m_control.addArchToList(arch);
! //}
arch = null;
} else {
if(thisLine.regionMatches(0,"msg", 0, 3)) {
--- 288,298 ----
}
postParseDefArch(arch);
m_control.addArchToList(arch);
!
! if (IGUIConstants.isoView && archmore)
! calcLowestMulti(arch);
! archmore = false; // we assume this is last... but perhaps..
!
arch = null;
} else {
if(thisLine.regionMatches(0,"msg", 0, 3)) {
***************
*** 347,352 ****
--- 348,374 ----
newCath = thisLine.substring(14).trim();
if (!newCath.equals(oldCath))
isNewCathegory = true; // this arch has a new cathegory
+ } else if (IGUIConstants.isoView && thisLine.startsWith("mpart_id ")) {
+ // shape ID for multiparts
+ try {
+ int i = Integer.parseInt(thisLine.substring(9).trim());
+ arch.setMultiShapeID(i);
+
+ if(i <= 0 || i >= MultiPositionData.Y_DIM)
+ System.out.println("WARNING: Arch "+ arch.getArchName()+" mpart_id number is '"+thisLine.substring(9)+"'");
+ } catch (Exception e) {
+ System.out.println("WARNING: Arch "+ arch.getArchName()+" has a invalid mpart_id ("+thisLine.substring(9)+")");
+ arch.addArchText(thisLine+"\n");
+ }
+ } else if (IGUIConstants.isoView && thisLine.startsWith("mpart_nr ")) {
+ // part nr for multiparts
+ try {
+ int i = Integer.parseInt(thisLine.substring(9).trim());
+ arch.setMultiPartNr(i);
+ } catch (Exception e) {
+ System.out.println("WARNING: Arch "+ arch.getArchName()+" has a invalid mpart_nr ("+thisLine.substring(9)+")");
+ arch.addArchText(thisLine+"\n");
+ }
} else
arch.addArchText(thisLine+"\n");
// System.out.println("add String: "+thisLine);
***************
*** 466,479 ****
if (arch.getArchTypNr() == ArchObject.TYPE_UNSET)
arch.setArchTypNr(defarch.getArchTypNr());
! arch.setRefCount(defarch.getRefCount());
! arch.setRefFlag(defarch.getRefFlag());
! arch.setRefMaxX(defarch.getRefMaxX());
! arch.setRefMaxY(defarch.getRefMaxY());
! arch.setRefMaxMX(defarch.getRefMaxMX());
! arch.setRefMaxMY(defarch.getRefMaxMY());
! arch.setRefX(defarch.getRefX());
! arch.setRefY(defarch.getRefY());
// arch.setEditType(defarch.getEditType());
// we don't handle anim yet, so attach then back to archtext
--- 488,515 ----
if (arch.getArchTypNr() == ArchObject.TYPE_UNSET)
arch.setArchTypNr(defarch.getArchTypNr());
! // if the type is still unset, then we take the default one
! if (IGUIConstants.isoView) {
! if (defarch.getMultiShapeID() > 0 && arch.getMultiShapeID() == 0)
! arch.setMultiShapeID(defarch.getMultiShapeID());
! if (defarch.getMultiPartNr() > 0 && arch.getMultiPartNr() == 0)
! arch.setMultiPartNr(defarch.getMultiPartNr());
! if (defarch.isLowestPart())
! arch.setLowestPart(true);
! }
!
! if (arch.isMulti() || defarch.isMulti()) {
! if (!arch.isMD()) arch.initMultiData(); // make sure the MultiArchData is initialized
!
! arch.setRefCount(defarch.getRefCount());
! arch.setRefFlag(defarch.getRefFlag());
! arch.setRefMaxX(defarch.getRefMaxX());
! arch.setRefMaxY(defarch.getRefMaxY());
! arch.setRefMaxMX(defarch.getRefMaxMX());
! arch.setRefMaxMY(defarch.getRefMaxMY());
! arch.setRefX(defarch.getRefX());
! arch.setRefY(defarch.getRefY());
! }
// arch.setEditType(defarch.getEditType());
// we don't handle anim yet, so attach then back to archtext
***************
*** 615,618 ****
--- 651,694 ----
return start;
}
+ /**
+ * Calculate the lowest part of this multi-arch. This lowest part is needed
+ * because in ISO view, the big image is drawn for it's lowest part, in order
+ * to get the overlappings correct.
+ *
+ * (TODO: This method is called repeatedly for each multipart. It would be
+ * better if it was called only once per multipart.)
+ *
+ * @param arch last tail part of this multi
+ */
+ private void calcLowestMulti(ArchObject arch) {
+ ArchObject tmp = arch;
+ int minYOffset = 10000; // minimal offset
+ int count = 0; // count number of tiles
+ int t; // tmp. storage
+
+ // 1.step: find the maximal y-offest
+ while (tmp.getRefCount() <= 0 && tmp.getNodeNr() > 0) {
+ t = MultiPositionData.getYOffset(tmp.getMultiShapeID(), tmp.getMultiPartNr());
+ if (t < minYOffset) minYOffset = t;
+
+ // get next multipart piece
+ tmp = m_control.getArch(tmp.getNodeNr()-1);
+ count++;
+ }
+ t = MultiPositionData.getYOffset(tmp.getMultiShapeID(), tmp.getMultiPartNr());
+ if (t < minYOffset) minYOffset = t;
+
+ // 2.step: set 'lowestPart' flag for all tiles with maximum offset
+ for (int i=0; count >= 0; count--, i++) {
+ t = MultiPositionData.getYOffset(tmp.getMultiShapeID(), tmp.getMultiPartNr());
+ if (t <= minYOffset) {
+ tmp.setLowestPart(true);
+ }
+ else
+ tmp.setLowestPart(false);
+ tmp = m_control.getArch(tmp.getNodeNr()+1);
+ }
+
+ }
};
Index: CFJavaEditor/src/cfeditor/ArchObjectStack.java
diff -c CFJavaEditor/src/cfeditor/ArchObjectStack.java:1.7 CFJavaEditor/src/cfeditor/ArchObjectStack.java:1.8
*** CFJavaEditor/src/cfeditor/ArchObjectStack.java:1.7 Sun Nov 3 08:43:18 2002
--- CFJavaEditor/src/cfeditor/ArchObjectStack.java Wed Dec 18 14:33:32 2002
***************
*** 1160,1165 ****
--- 1160,1169 ----
binFile.writeBytes("face "+arch.getFaceName()+"\n");
if(arch.getArchTypNr()>0)
binFile.writeBytes("type "+arch.getArchTypNr()+"\n");
+ if(arch.getMultiShapeID()>0)
+ binFile.writeBytes("mpart_id "+arch.getMultiShapeID()+"\n");
+ if(arch.getMultiPartNr()>0)
+ binFile.writeBytes("mpart_nr "+arch.getMultiPartNr()+"\n");
if(arch.getMsgText() != null) {
binFile.writeBytes("msg\n");
***************
*** 1203,1208 ****
--- 1207,1216 ----
binFile.writeBytes("face "+arch.getFaceName()+"\n");
if(arch.getArchTypNr()>0)
binFile.writeBytes("type "+arch.getArchTypNr()+"\n");
+ if(arch.getMultiShapeID()>0)
+ binFile.writeBytes("mpart_id "+arch.getMultiShapeID()+"\n");
+ if(arch.getMultiPartNr()>0)
+ binFile.writeBytes("mpart_nr "+arch.getMultiPartNr()+"\n");
if(arch.getMsgText() != null) {
binFile.writeBytes("msg\n");
Index: CFJavaEditor/src/cfeditor/CFileReader.java
diff -c CFJavaEditor/src/cfeditor/CFileReader.java:1.1 CFJavaEditor/src/cfeditor/CFileReader.java:1.2
*** CFJavaEditor/src/cfeditor/CFileReader.java:1.1 Fri Aug 16 11:48:35 2002
--- CFJavaEditor/src/cfeditor/CFileReader.java Wed Dec 18 14:33:32 2002
***************
*** 176,181 ****
--- 176,184 ----
int c; // character value, read from the stream
int t=0; // index
+ long count = 0; // counter (to realize when shooting past EOF)
+ long maxCount = 10000; // bail out when counter exceeds this value
+
do {
c = stream.read(); // read one character
r = r + String.valueOf((char)c); // add character 'c' to the string
***************
*** 183,192 ****
t++;
else
t=0;
! } while (t < tag.length() && c != -1);
// if we did not find the tag, an EOFException is thrown
! if (c == -1)
throw new EOFException();
else {
// cut 'tag' off, at the end of the string
--- 186,195 ----
t++;
else
t=0;
! } while (t < tag.length() && c != -1 && count++ < maxCount);
// if we did not find the tag, an EOFException is thrown
! if (c == -1 || count++ >= maxCount)
throw new EOFException();
else {
// cut 'tag' off, at the end of the string
Index: CFJavaEditor/src/cfeditor/CMainControl.java
diff -c CFJavaEditor/src/cfeditor/CMainControl.java:1.8 CFJavaEditor/src/cfeditor/CMainControl.java:1.9
*** CFJavaEditor/src/cfeditor/CMainControl.java:1.8 Sun Nov 3 08:43:19 2002
--- CFJavaEditor/src/cfeditor/CMainControl.java Wed Dec 18 14:33:32 2002
***************
*** 185,190 ****
--- 185,194 ----
if (getPlainFont() != null)
JFontChooser.setUIFont(getPlainFont());
+ // initialize & load
+ if (IGUIConstants.isoView)
+ MultiPositionData.init();
+
// Initialise the main view
m_view.init();
loadDefTiles();
***************
*** 741,747 ****
if (askConfirm(
"Do You Want To Save Changes?",
"Do you want to save changes to map "+
! level.getMapName()+"?" )) {
if (level.isPlainSaveEnabled()) {
level.save();
--- 745,751 ----
if (askConfirm(
"Do You Want To Save Changes?",
"Do you want to save changes to map "+
! level.getMapNameWithoutMusic()+"?" )) {
if (level.isPlainSaveEnabled()) {
level.save();
***************
*** 831,841 ****
try {
start = mapFileDecoder.decodeMapFile(file, this); // parse mapfile
maparch = mapFileDecoder.getMapArch(); // get map arch
! } catch (CGridderException e) {
// popup display
showMessage("Couldn't load Map", e.getMessage());
return;
}
// ok, we have it all!!
--- 835,854 ----
try {
start = mapFileDecoder.decodeMapFile(file, this); // parse mapfile
maparch = mapFileDecoder.getMapArch(); // get map arch
! }
! catch (CGridderException e) {
// popup display
showMessage("Couldn't load Map", e.getMessage());
return;
}
+ catch (OutOfMemoryError e) {
+ // out of memory!! - display error
+ showMessage("Out of Memory", "Not enough memory available to open more maps!\n"+
+ "You can increase the memory limit by using the '-mx' runtime flag.\n"+
+ "For example: 'java -mx128m -jar "+IGUIConstants.APP_NAME+".jar'",
+ JOptionPane.WARNING_MESSAGE);
+ return;
+ }
// ok, we have it all!!
***************
*** 1564,1574 ****
/**
* Shows the given message in the UI.
! *@param strTitle The title of the message.
! *@param strMessage The message to be shown.
*/
! public void showMessage( String strTitle, String strMessage ) {
! m_view.showMessage( strTitle, strMessage );
}
/**
--- 1577,1597 ----
/**
* Shows the given message in the UI.
! * @param strTitle The title of the message.
! * @param strMessage The message to be shown.
! */
! public void showMessage(String strTitle, String strMessage ) {
! m_view.showMessage(strTitle, strMessage );
! }
!
! /**
! * Shows the given message in the UI.
! * @param strTitle The title of the message.
! * @param strMessage The message to be shown.
! * @param messageType Type of message (see JOptionPane constants)
*/
! public void showMessage(String strTitle, String strMessage, int messageType) {
! m_view.showMessage(strTitle, strMessage, messageType);
}
/**
Index: CFJavaEditor/src/cfeditor/CMainView.java
diff -c CFJavaEditor/src/cfeditor/CMainView.java:1.6 CFJavaEditor/src/cfeditor/CMainView.java:1.7
*** CFJavaEditor/src/cfeditor/CMainView.java:1.6 Sun Nov 3 08:43:19 2002
--- CFJavaEditor/src/cfeditor/CMainView.java Wed Dec 18 14:33:32 2002
***************
*** 522,536 ****
/**
* Shows the given message in the UI.
! *@param strTitle The title of the message.
! *@param strMessage The message to be shown.
*/
! public void showMessage( String strTitle, String strMessage ) {
! JOptionPane.showMessageDialog(
! this,
! strMessage,
! strTitle,
! JOptionPane.INFORMATION_MESSAGE );
}
/**
--- 522,537 ----
/**
* Shows the given message in the UI.
! * @param strTitle The title of the message.
! * @param strMessage The message to be shown.
! * @param messageType Type of message (see JOptionPane constants), defines icon used
*/
! public void showMessage(String strTitle, String strMessage, int messageType) {
! JOptionPane.showMessageDialog(this, strMessage, strTitle, messageType);
! }
!
! public void showMessage(String strTitle, String strMessage) {
! JOptionPane.showMessageDialog(this, strMessage, strTitle, JOptionPane.INFORMATION_MESSAGE);
}
/**
|