|
From: <cro...@li...> - 2003-05-12 21:18:01
|
Module Name: CFJavaEditor
Committed By: avogl
Date: Mon May 12 21:18:00 UTC 2003
Modified Files:
CFJavaEditor/src/cfeditor: CFJavaEditor.java CMainControl.java
CMapModel.java CMapViewIFrame.java JFontChooser.java
Log Message:
Two patches submitted by Bernd Edler:
1. "Enter Exit" now also works for pits and trapdoors
2. For exits without x/y dest. coordinations set,
"Enter Exit" takes the EnterX/Y values from map header
(As the CF server does.)
Apart from that I've (hopefully) improved the behaviour
for the "Enter North/East/West/South" command with map tiles.
Instead of always opening the top-left part of the map the
editor tries to do something smarter... hard to explain,
just try it out.
--AndreasV
Start of context diffs
Index: CFJavaEditor/src/cfeditor/CFJavaEditor.java
diff -c CFJavaEditor/src/cfeditor/CFJavaEditor.java:1.11 CFJavaEditor/src/cfeditor/CFJavaEditor.java:1.12
*** CFJavaEditor/src/cfeditor/CFJavaEditor.java:1.11 Mon May 5 16:19:15 2003
--- CFJavaEditor/src/cfeditor/CFJavaEditor.java Mon May 12 14:17:59 2003
***************
*** 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 {
/**
--- 31,37 ----
* The launcher that launches the whole level editor application.
*
* @author <a href="mailto:mic...@no...">Michael Toennies</a>
! * @version $Revision: 1.12 $
*/
public class CFJavaEditor {
/**
Index: CFJavaEditor/src/cfeditor/CMainControl.java
diff -c CFJavaEditor/src/cfeditor/CMainControl.java:1.13 CFJavaEditor/src/cfeditor/CMainControl.java:1.14
*** CFJavaEditor/src/cfeditor/CMainControl.java:1.13 Mon May 5 16:19:15 2003
--- CFJavaEditor/src/cfeditor/CMainControl.java Mon May 12 14:17:59 2003
***************
*** 1211,1216 ****
--- 1211,1222 ----
oldmap = m_currentMap; // store old map control
openFile(newfile); // open the new map
+
+ if (dx==0 && dy==0) {
+ // use the entry point defined by the map header
+ dx=m_currentMap.m_model.getMapArchObject().getEnterX();
+ dy=m_currentMap.m_model.getMapArchObject().getEnterY();
+ }
m_currentMap.m_view.setHotspot(dx, dy); // set hotspot
// Update the main view so the new map instantly pops up.
***************
*** 1257,1262 ****
--- 1263,1303 ----
oldmap = m_currentMap; // store old map control
openFile(newfile); // open the new map
+
+ // set viewport view on the new map
+ if (!IGUIConstants.isoView) {
+ Rectangle scrollto = null; // new vieport rect
+ JViewport newViewPort = m_currentMap.m_view.getViewPort();
+ JViewport oldViewPort = oldmap.m_view.getViewPort();
+
+ if (direction == IGUIConstants.SOUTH) {
+ scrollto = new Rectangle(oldViewPort.getViewRect().x, 0,
+ oldViewPort.getViewRect().width, oldViewPort.getViewRect().height);
+ }
+ else if (direction == IGUIConstants.NORTH) {
+ scrollto = new Rectangle(oldViewPort.getViewRect().x, newViewPort.getViewSize().height-oldViewPort.getViewRect().height,
+ oldViewPort.getViewRect().width, oldViewPort.getViewRect().height);
+ }
+ else if (direction == IGUIConstants.EAST) {
+ scrollto = new Rectangle(0, oldViewPort.getViewRect().y,
+ oldViewPort.getViewRect().width, oldViewPort.getViewRect().height);
+ }
+ else if (direction == IGUIConstants.WEST) {
+ scrollto = new Rectangle(newViewPort.getViewSize().width-oldViewPort.getViewRect().width, oldViewPort.getViewRect().y,
+ oldViewPort.getViewRect().width, oldViewPort.getViewRect().height);
+ }
+
+ if (scrollto.x+scrollto.width > newViewPort.getViewSize().width)
+ scrollto.x = newViewPort.getViewSize().width - scrollto.width;
+ if (scrollto.x < 0 )
+ scrollto.x = 0;
+ if (scrollto.y+scrollto.height > newViewPort.getViewSize().height)
+ scrollto.y = newViewPort.getViewSize().height - scrollto.height;
+ if (scrollto.y < 0 )
+ scrollto.y = 0;
+ newViewPort.setViewPosition( scrollto.getLocation() );
+ //getViewport().scrollRectToVisible(scrollto);
+ }
// Update the main view so the new map instantly pops up.
m_view.update(m_view.getGraphics());
Index: CFJavaEditor/src/cfeditor/CMapModel.java
diff -c CFJavaEditor/src/cfeditor/CMapModel.java:1.8 CFJavaEditor/src/cfeditor/CMapModel.java:1.9
*** CFJavaEditor/src/cfeditor/CMapModel.java:1.8 Sat May 3 11:23:07 2003
--- CFJavaEditor/src/cfeditor/CMapModel.java Mon May 12 14:17:59 2003
***************
*** 39,44 ****
--- 39,47 ----
public static final boolean JOIN_ENABLE = true;
public static final boolean JOIN_DISABLE = false;
+ // list of exit types (Integer values)
+ private static Set exitTypes = new HashSet();
+
/** Level grid data. */
MapArchObject m_mapArch=null; // the MapArchObject
ArchObject[][] m_mapGrid = null; // containing all arches grid-wise
***************
*** 46,55 ****
private int m_mapWidth = 8;
/** The height of the level (in tiles). */
private int m_mapHeight = 8;
! /** The controller of this model. */
! /** The level file or null if none exists. */
! /** The name of the level. */
! //private String m_strMapName = "";
/** Flag that indicates if the level has been changed since last save. */
private boolean m_fLevelChanged = false;
--- 49,55 ----
private int m_mapWidth = 8;
/** The height of the level (in tiles). */
private int m_mapHeight = 8;
!
/** Flag that indicates if the level has been changed since last save. */
private boolean m_fLevelChanged = false;
***************
*** 66,92 ****
* @param start first element in the <code>ArchObject</code> list of this map
* @param map the map header (<code>MapArchObject</code>)
*/
-
CMapModel (CMainControl mc, CMapControl control, ArchObject start,
MapArchObject map) {
main_control = mc;
m_control = control;
m_mapWidth = map.getWidth();
m_mapHeight = map.getHeight();
- //m_strMapName = map.getName();
m_fLevelChanged = false;
isoView = IGUIConstants.isoView; // is ISO view applied?
m_mapGrid = new ArchObject[m_mapWidth][m_mapHeight];
initMap(m_mapWidth, m_mapHeight);
- // if a new map, we generate the starting map arch
- /*if(start == null)
- start = new ArchObject();*/
-
addArchListToMap(start, map); // init mapArchObject and (when not new map) the arch list
setMapX(m_mapWidth);
setMapY(m_mapHeight);
}
ArchObject getMouseRightPosObject() {
--- 66,104 ----
* @param start first element in the <code>ArchObject</code> list of this map
* @param map the map header (<code>MapArchObject</code>)
*/
CMapModel (CMainControl mc, CMapControl control, ArchObject start,
MapArchObject map) {
main_control = mc;
m_control = control;
m_mapWidth = map.getWidth();
m_mapHeight = map.getHeight();
m_fLevelChanged = false;
isoView = IGUIConstants.isoView; // is ISO view applied?
m_mapGrid = new ArchObject[m_mapWidth][m_mapHeight];
initMap(m_mapWidth, m_mapHeight);
addArchListToMap(start, map); // init mapArchObject and (when not new map) the arch list
setMapX(m_mapWidth);
setMapY(m_mapHeight);
+
+ // init static component
+ if (exitTypes.isEmpty())
+ init();
+ }
+
+ /**
+ * Initialize static components
+ */
+ private static void init() {
+ synchronized(exitTypes) {
+ if (exitTypes.isEmpty()) {
+ exitTypes.add(new Integer(41)); // teleporter
+ exitTypes.add(new Integer(66)); // exit
+ exitTypes.add(new Integer(94)); // pit
+ exitTypes.add(new Integer(95)); // trapdoor
+ }
+ }
}
ArchObject getMouseRightPosObject() {
***************
*** 830,837 ****
/**
* Searching for a valid exit at the highlighted map-spot.
! * (This can be either a teleporter (41), or exit (66))
! * If
*
* @return: ArchObject exit-arch if existent, otherwise null
*/
--- 842,848 ----
/**
* Searching for a valid exit at the highlighted map-spot.
! * (This can be a teleporter, exit, pit etc.)
*
* @return: ArchObject exit-arch if existent, otherwise null
*/
***************
*** 844,859 ****
// first, check if the selected arch is a valid exit
exit = main_control.getMainView().getMapTileSelection();
! if (exit == null || (exit.getArchTypNr() != 41 &&
! exit.getArchTypNr() != 66)) {
// if not, we check the whole selected spot for an exit
! for (exit = m_mapGrid[hspot.x][hspot.y];
! exit != null && exit.getArchTypNr() != 41 &&
! exit.getArchTypNr() != 66; exit = exit.getNextArch());
}
! if (exit == null || (exit.getArchTypNr() != 41 &&
! exit.getArchTypNr() != 66))
exit = null; // make sure it's either an exit, or null
// if we have a multipart exit, return the head
--- 855,867 ----
// first, check if the selected arch is a valid exit
exit = main_control.getMainView().getMapTileSelection();
! if (exit == null || !exitTypes.contains(new Integer(exit.getArchTypNr()))) {
// if not, we check the whole selected spot for an exit
! for (exit = m_mapGrid[hspot.x][hspot.y]; exit != null &&
! !exitTypes.contains(new Integer(exit.getArchTypNr())); exit = exit.getNextArch());
}
! if (exit == null || !exitTypes.contains(new Integer(exit.getArchTypNr())))
exit = null; // make sure it's either an exit, or null
// if we have a multipart exit, return the head
Index: CFJavaEditor/src/cfeditor/CMapViewIFrame.java
diff -c CFJavaEditor/src/cfeditor/CMapViewIFrame.java:1.4 CFJavaEditor/src/cfeditor/CMapViewIFrame.java:1.5
*** CFJavaEditor/src/cfeditor/CMapViewIFrame.java:1.4 Sat May 3 11:23:07 2003
--- CFJavaEditor/src/cfeditor/CMapViewIFrame.java Mon May 12 14:17:59 2003
***************
*** 102,107 ****
--- 102,109 ----
// following a bunch of wrapper methods which just pass access
// to the basic mapview object 'view':
public Point getMapMouseRightPos() {return view.getMapMouseRightPos();}
+ public JViewport getViewPort() {return view.getViewport();}
+ public Dimension getSize() {return view.getSize();}
public boolean isGridVisible() {return view.isGridVisible();}
public void updateLookAndFeel() {view.updateLookAndFeel();}
public boolean isHighlight() {return view.isHighlight();}
Index: CFJavaEditor/src/cfeditor/JFontChooser.java
diff -c CFJavaEditor/src/cfeditor/JFontChooser.java:1.7 CFJavaEditor/src/cfeditor/JFontChooser.java:1.8
*** CFJavaEditor/src/cfeditor/JFontChooser.java:1.7 Mon May 5 16:19:15 2003
--- CFJavaEditor/src/cfeditor/JFontChooser.java Mon May 12 14:17:59 2003
***************
*** 10,16 ****
*
* Valentin Tablan 06/04/2001
*
! * $Id: JFontChooser.java,v 1.7 2003/05/05 23:19:15 avogl Exp $
*
*/
package cfeditor;
--- 10,16 ----
*
* Valentin Tablan 06/04/2001
*
! * $Id: JFontChooser.java,v 1.8 2003/05/12 21:17:59 avogl Exp $
*
*/
package cfeditor;
|