From 958cb213d53557bf092947b3330b7ffbd02601fe Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 19 Feb 2002 07:41:36 +0000 Subject: [PATCH] Blarg. Have to tell the sprite manager about the viewport offset when we're using it to render sprites into a view that is being displayed in a viewport that is smaller than the actual size of the view. Oh the jockeying. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1041 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../media/sprite/SpriteManager.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/media/sprite/SpriteManager.java b/src/java/com/threerings/media/sprite/SpriteManager.java index 70d348b58..dde2507f0 100644 --- a/src/java/com/threerings/media/sprite/SpriteManager.java +++ b/src/java/com/threerings/media/sprite/SpriteManager.java @@ -1,5 +1,5 @@ // -// $Id: SpriteManager.java,v 1.22 2002/02/19 03:58:37 mdb Exp $ +// $Id: SpriteManager.java,v 1.23 2002/02/19 07:41:36 mdb Exp $ package com.threerings.media.sprite; @@ -35,6 +35,21 @@ public class SpriteManager _dirty = new ArrayList(); } + /** + * Specifies the viewport offset of the view into which the sprites + * are being rendered. This is an annoying hack, but the sprite + * manager needs to create dirty rectangles and communicate them to + * the animation manager who deals in untranslated coordinates, + * whereas the sprites remain in translated coordinates; but only the + * view itself knows what the translation should be, so it has to tell + * the sprite manager about it using this method. + */ + public void setViewportOffset (int tx, int ty) + { + _tx = tx; + _ty = ty; + } + /** * Add a rectangle to the dirty rectangle list. * @@ -42,6 +57,8 @@ public class SpriteManager */ public void addDirtyRect (Rectangle rect) { + // translate the rectangle according to our viewport offset + rect.translate(-_tx, -_ty); _dirty.add(rect); } @@ -309,6 +326,9 @@ public class SpriteManager /** The list of pending sprite notifications. */ protected ArrayList _notify; + /** Our viewport offset. */ + protected int _tx, _ty; + protected static class SpriteComparator implements Comparator { public int compare (Object o1, Object o2)