Make sure screen coordinates that are converted to tile and full
coordinates when editing a scene are valid before forging ahead with scene modifications. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@436 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: IsoSceneView.java,v 1.57 2001/10/11 00:41:27 shaper Exp $
|
// $Id: IsoSceneView.java,v 1.58 2001/10/11 16:21:08 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.miso.scene;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
@@ -64,12 +64,7 @@ public class IsoSceneView implements SceneView
|
|||||||
_scene = scene;
|
_scene = scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// documentation inherited
|
||||||
* Paint the scene view and any highlighted tiles to the given
|
|
||||||
* graphics context.
|
|
||||||
*
|
|
||||||
* @param g the graphics context.
|
|
||||||
*/
|
|
||||||
public void paint (Graphics g)
|
public void paint (Graphics g)
|
||||||
{
|
{
|
||||||
if (_scene == null) {
|
if (_scene == null) {
|
||||||
@@ -375,11 +370,7 @@ public class IsoSceneView implements SceneView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// documentation inherited
|
||||||
* Invalidate a list of rectangles in the view for later repainting.
|
|
||||||
*
|
|
||||||
* @param rects the list of Rectangle objects.
|
|
||||||
*/
|
|
||||||
public void invalidateRects (DirtyRectList rects)
|
public void invalidateRects (DirtyRectList rects)
|
||||||
{
|
{
|
||||||
// we specifically need to allow the dirty rects list to grow
|
// we specifically need to allow the dirty rects list to grow
|
||||||
@@ -530,6 +521,7 @@ public class IsoSceneView implements SceneView
|
|||||||
_model.precalculate();
|
_model.precalculate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
public Path getPath (AmbulatorySprite sprite, int x, int y)
|
public Path getPath (AmbulatorySprite sprite, int x, int y)
|
||||||
{
|
{
|
||||||
// make sure the destination point is within our bounds
|
// make sure the destination point is within our bounds
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: IsoSceneViewModel.java,v 1.12 2001/08/29 20:07:54 shaper Exp $
|
// $Id: IsoSceneViewModel.java,v 1.13 2001/10/11 16:21:09 shaper Exp $
|
||||||
|
|
||||||
package com.threerings.miso.scene;
|
package com.threerings.miso.scene;
|
||||||
|
|
||||||
@@ -8,6 +8,7 @@ import java.awt.Point;
|
|||||||
|
|
||||||
import com.samskivert.util.Config;
|
import com.samskivert.util.Config;
|
||||||
import com.threerings.miso.Log;
|
import com.threerings.miso.Log;
|
||||||
|
import com.threerings.miso.scene.util.IsoUtil;
|
||||||
import com.threerings.miso.util.MisoUtil;
|
import com.threerings.miso.util.MisoUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,6 +108,29 @@ public class IsoSceneViewModel
|
|||||||
showPaths = config.getValue(SHOW_PATHS_KEY, DEF_SHOW_PATHS);
|
showPaths = config.getValue(SHOW_PATHS_KEY, DEF_SHOW_PATHS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given tile coordinate is a valid coordinate
|
||||||
|
* within the scene.
|
||||||
|
*/
|
||||||
|
public boolean isValidCoordinate (int x, int y)
|
||||||
|
{
|
||||||
|
return (x >= 0 && x < scenewid &&
|
||||||
|
y >= 0 && y < scenehei);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the given full coordinate is a valid coordinate
|
||||||
|
* within the scene.
|
||||||
|
*/
|
||||||
|
public boolean isValidFullCoordinate (int x, int y)
|
||||||
|
{
|
||||||
|
int tx = IsoUtil.fullToTile(x), ty = IsoUtil.fullToTile(y);
|
||||||
|
int fx = IsoUtil.fullToFine(x), fy = IsoUtil.fullToFine(y);
|
||||||
|
return (isValidCoordinate(tx, ty) &&
|
||||||
|
fx >= 0 && fx < finegran &&
|
||||||
|
fy >= 0 && fy < finegran);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether locations in the scene are currently drawn.
|
* Return whether locations in the scene are currently drawn.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user