|
From: <cro...@li...> - 2003-05-05 23:19:18
|
Module Name: CFJavaEditor
Committed By: avogl
Date: Mon May 5 23:19:16 UTC 2003
Modified Files:
CFJavaEditor/src/cfeditor: CFJavaEditor.java CMainControl.java
CMapViewBasic.java JFontChooser.java
Log Message:
Bernd Edler has written a patch which does the
following:
When a user invokes "Enter Exit", the new opening mapview
is centered on the destination spot.
This makes the whole "Enter Exit" thing a lot
more convenient to use.
Start of context diffs
Index: CFJavaEditor/src/cfeditor/CFJavaEditor.java
diff -c CFJavaEditor/src/cfeditor/CFJavaEditor.java:1.10 CFJavaEditor/src/cfeditor/CFJavaEditor.java:1.11
*** CFJavaEditor/src/cfeditor/CFJavaEditor.java:1.10 Sat May 3 11:23:07 2003
--- CFJavaEditor/src/cfeditor/CFJavaEditor.java Mon May 5 16:19:15 2003
***************
*** 31,37 ****
* The launcher that launches the whole level editor application.
*
* @author <a href="mailto:mic...@no...">Michael Toennies</a>
! * @version $Revision: 1.10 $
*/
public class CFJavaEditor {
/**
--- 31,37 ----
* The launcher that launches the whole level editor application.
*
* @author <a href="mailto:mic...@no...">Michael Toennies</a>
! * @version $Revision: 1.11 $
*/
public class CFJavaEditor {
/**
Index: CFJavaEditor/src/cfeditor/CMainControl.java
diff -c CFJavaEditor/src/cfeditor/CMainControl.java:1.12 CFJavaEditor/src/cfeditor/CMainControl.java:1.13
*** CFJavaEditor/src/cfeditor/CMainControl.java:1.12 Sat May 3 11:23:07 2003
--- CFJavaEditor/src/cfeditor/CMainControl.java Mon May 5 16:19:15 2003
***************
*** 359,433 ****
public ArchObject getArch(int i) {return(archList.getArch(i));}
public CopyBuffer getCopyBuffer() {return copybuffer;}
public Font getPlainFont() {return plainFont;}
public Font getBoldFont() {return boldFont;}
public void newPlainFont(Font newfont) {plainFont = newfont;}
public void newBoldFont(Font newfont) {boldFont = newfont;}
public boolean isBigFont() {return (((getPlainFont()==null)?JFontChooser.default_font.getSize():
getPlainFont().getSize()) > 13);}
- /**
- * Read the typenumbers file (associate names with type numbers)
- *
- private void loadTypeDef() {
- String thisLine, thisLine2;
- int x,y;
- boolean typeflag=false;
-
- try {
- String baseDir = (IGUIConstants.isoView ? CMainControl.getInstance().getArchDefaultFolder()+File.separator+IGUIConstants.CONFIG_DIR : IGUIConstants.CONFIG_DIR);
- CFileReader myInput = new CFileReader(baseDir, IGUIConstants.TYPENR_FILE);
-
- while ((thisLine2 = myInput.getReader().readLine()) != null) {
- // hm, thats ugly, but i need to cut off the damn white spaces for the names
- thisLine = thisLine2;
- if(thisLine2.length()>1) {
- for(x=0;x<thisLine2.length();x++) {
- if(thisLine2.charAt(x) != ' ' && thisLine2.charAt(x) != 0x09)
- break;
- }
- for(y=thisLine2.length()-1;y>=x;y--) {
- if(thisLine2.charAt(y) != ' ')
- break;
- }
- // our clean line
- thisLine = thisLine2.substring(x,y+1);
-
- // we are in space, search for cmd
- if(typeflag == false) {
- if(thisLine.regionMatches(0,"!Type ", 0, 6)) {
- // kill white spaces afer arch...
- // (hm, no command for this in java? )
- for(x=6;x<thisLine.length();x++) {
- if(thisLine.charAt(x) != ' ')
- break;
- }
-
- // we had find our type name
- // System.out.println("Adding type: "+thisLine.substring(x));
- archObjectParser.addObjectTyp(thisLine.substring(x));
- typeflag = true;
- } else
- System.out.println("ERROR Read typedef:Unknown cmd "+thisLine);
- } else {
- if(thisLine.regionMatches(0,"!Tend", 0, 5)) {
- typeflag = false;
- }
- else if(thisLine.regionMatches(0,"field ", 0, 6)) {
- archObjectParser.addObjectForm(thisLine.substring(6));
- }
- }
- }
- }
- myInput.close();
- }
- catch (FileNotFoundException e) {}
- catch (IOException e) {
- System.out.println("Couldn't load \""+IGUIConstants.TYPENR_FILE+"\"");
- }
- }*/
-
void setMapAndArchPosition(int archid, int x, int y) {
m_currentMap.m_view.setMapAndArchPosition(archid, x,y);
}
--- 359,375 ----
public ArchObject getArch(int i) {return(archList.getArch(i));}
public CopyBuffer getCopyBuffer() {return copybuffer;}
+ /** IMPORTANT: plainFont can be null! */
public Font getPlainFont() {return plainFont;}
+ /** IMPORTANT: boldFont can be null! */
public Font getBoldFont() {return boldFont;}
+
public void newPlainFont(Font newfont) {plainFont = newfont;}
public void newBoldFont(Font newfont) {boldFont = newfont;}
public boolean isBigFont() {return (((getPlainFont()==null)?JFontChooser.default_font.getSize():
getPlainFont().getSize()) > 13);}
void setMapAndArchPosition(int archid, int x, int y) {
m_currentMap.m_view.setMapAndArchPosition(archid, x,y);
}
***************
*** 1254,1259 ****
--- 1196,1205 ----
newfile = new File(m_mapDir.getAbsolutePath(), path.substring(1));
} else {
// we have a relative path:
+ if (m_currentMap.mapFile == null) {
+ showMessage("Map not Saved", "Please save this map first.", JOptionPane.ERROR_MESSAGE);
+ return;
+ }
newfile = new File(m_currentMap.mapFile.getParent(), path);
}
Index: CFJavaEditor/src/cfeditor/CMapViewBasic.java
diff -c CFJavaEditor/src/cfeditor/CMapViewBasic.java:1.9 CFJavaEditor/src/cfeditor/CMapViewBasic.java:1.10
*** CFJavaEditor/src/cfeditor/CMapViewBasic.java:1.9 Sat May 3 11:23:07 2003
--- CFJavaEditor/src/cfeditor/CMapViewBasic.java Mon May 5 16:19:15 2003
***************
*** 262,269 ****
}
/**
! * highlight the tile at given koordinates (just as
! * if it had been selected with leftclick)
* @param dx x-coordinate
* @param dy y-coordinate
*/
--- 262,271 ----
}
/**
! * Highlight the tile at given koordinates (just as
! * if it had been selected with leftclick). Besides, the mapview is
! * always centered on the koordinates as far as possible.
! *
* @param dx x-coordinate
* @param dy y-coordinate
*/
***************
*** 273,278 ****
--- 275,299 ----
mapMouseRightPos.y = dy;
mapMouseRightOff.x = 0;
mapMouseRightOff.y = 0;
+
+ // set scroll position accordingly to center on target
+ Rectangle scrollto;
+ if (!IGUIConstants.isoView) {
+ scrollto = new Rectangle ( (dx+1)*32 +16 - getViewport().getViewRect().width/2 ,
+ (dy+1)*32 +16 - getViewport().getViewRect().height/2,
+ getViewport().getViewRect().width,
+ getViewport().getViewRect().height);
+ if (scrollto.x+scrollto.width > getViewport().getViewSize().width)
+ scrollto.x = getViewport().getViewSize().width - scrollto.width;
+ if (scrollto.x < 0 )
+ scrollto.x = 0;
+ if (scrollto.y+scrollto.height > getViewport().getViewSize().height)
+ scrollto.y = getViewport().getViewSize().height - scrollto.height;
+ if (scrollto.y < 0 )
+ scrollto.y = 0;
+ getViewport().setViewPosition( scrollto.getLocation() );
+ //getViewport().scrollRectToVisible(scrollto);
+ }
if (!highlight_on) {
highlight_on = true;
Index: CFJavaEditor/src/cfeditor/JFontChooser.java
diff -c CFJavaEditor/src/cfeditor/JFontChooser.java:1.6 CFJavaEditor/src/cfeditor/JFontChooser.java:1.7
*** CFJavaEditor/src/cfeditor/JFontChooser.java:1.6 Sat May 3 11:23:07 2003
--- CFJavaEditor/src/cfeditor/JFontChooser.java Mon May 5 16:19:15 2003
***************
*** 10,16 ****
*
* Valentin Tablan 06/04/2001
*
! * $Id: JFontChooser.java,v 1.6 2003/05/03 18:23:07 avogl Exp $
*
*/
package cfeditor;
--- 10,16 ----
*
* Valentin Tablan 06/04/2001
*
! * $Id: JFontChooser.java,v 1.7 2003/05/05 23:19:15 avogl Exp $
*
*/
package cfeditor;
|