From 915e13ca12a584ddfd3a8c8833738467da771ab8 Mon Sep 17 00:00:00 2001 From: Walter Korman Date: Thu, 11 Oct 2001 16:21:09 +0000 Subject: [PATCH] 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 --- .../threerings/miso/client/IsoSceneView.java | 16 +++--------- .../miso/client/IsoSceneViewModel.java | 26 ++++++++++++++++++- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/java/com/threerings/miso/client/IsoSceneView.java b/src/java/com/threerings/miso/client/IsoSceneView.java index bdc57770a..b105ea582 100644 --- a/src/java/com/threerings/miso/client/IsoSceneView.java +++ b/src/java/com/threerings/miso/client/IsoSceneView.java @@ -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; @@ -64,12 +64,7 @@ public class IsoSceneView implements SceneView _scene = scene; } - /** - * Paint the scene view and any highlighted tiles to the given - * graphics context. - * - * @param g the graphics context. - */ + // documentation inherited public void paint (Graphics g) { if (_scene == null) { @@ -375,11 +370,7 @@ public class IsoSceneView implements SceneView } } - /** - * Invalidate a list of rectangles in the view for later repainting. - * - * @param rects the list of Rectangle objects. - */ + // documentation inherited public void invalidateRects (DirtyRectList rects) { // we specifically need to allow the dirty rects list to grow @@ -530,6 +521,7 @@ public class IsoSceneView implements SceneView _model.precalculate(); } + // documentation inherited public Path getPath (AmbulatorySprite sprite, int x, int y) { // make sure the destination point is within our bounds diff --git a/src/java/com/threerings/miso/client/IsoSceneViewModel.java b/src/java/com/threerings/miso/client/IsoSceneViewModel.java index 742def75a..d0a5d36d4 100644 --- a/src/java/com/threerings/miso/client/IsoSceneViewModel.java +++ b/src/java/com/threerings/miso/client/IsoSceneViewModel.java @@ -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; @@ -8,6 +8,7 @@ import java.awt.Point; import com.samskivert.util.Config; import com.threerings.miso.Log; +import com.threerings.miso.scene.util.IsoUtil; import com.threerings.miso.util.MisoUtil; /** @@ -107,6 +108,29 @@ public class IsoSceneViewModel 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. */