Let's not make things that actually compose stuff hop about the screen by using their VolatileMirage offset in the place of their origin offset.
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@296 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -66,20 +66,18 @@ public class CompositedMaskedImage extends CompositedMultiFrameImage
|
||||
|
||||
// documentation inherited from interface
|
||||
public void paintFrame (Graphics2D g, int index, int x, int y) {
|
||||
_images[index].paint(g, x + _images[index].getX(),
|
||||
y + _images[index].getY());
|
||||
_images[index].paint(g, x + getX(index), y + getY(index));
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public boolean hitTest (int index, int x, int y) {
|
||||
return _images[index].hitTest(x + _images[index].getX(),
|
||||
y + _images[index].getY());
|
||||
return _images[index].hitTest(x + getX(index), y + getY(index));
|
||||
}
|
||||
|
||||
// documentation inherited from interface TrimmedMultiFrameImage
|
||||
public void getTrimmedBounds (int index, Rectangle bounds) {
|
||||
bounds.setBounds(_images[index].getX(), _images[index].getY(),
|
||||
_images[index].getWidth(), _images[index].getHeight());
|
||||
bounds.setBounds(getX(index), getY(index), _images[index].getWidth(),
|
||||
_images[index].getHeight());
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
@@ -129,4 +127,18 @@ public class CompositedMaskedImage extends CompositedMultiFrameImage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the x offset into the source image for the image at index
|
||||
*/
|
||||
protected int getX (int index) {
|
||||
return ((VolatileMirage)_images[index]).getX();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the y offset into the source image for the image at index
|
||||
*/
|
||||
protected int getY (int index) {
|
||||
return ((VolatileMirage)_images[index]).getY();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,16 +6,16 @@ import com.threerings.cast.CompositedActionFrames.ComponentFrames;
|
||||
import com.threerings.media.image.Mirage;
|
||||
|
||||
public interface CompositedMirage
|
||||
extends Mirage, Comparator<ComponentFrames>
|
||||
extends Mirage
|
||||
{
|
||||
/**
|
||||
* Returns the x offset into our image.
|
||||
*/
|
||||
public int getX ();
|
||||
public int getXOrigin ();
|
||||
|
||||
/**
|
||||
* Returns the y offset into our image.
|
||||
*/
|
||||
public int getY ();
|
||||
public int getYOrigin ();
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.awt.Rectangle;
|
||||
import java.awt.Transparency;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
import com.threerings.cast.CompositedActionFrames.ComponentFrames;
|
||||
import com.threerings.cast.bundle.BundledComponentRepository.TileSetFrameImage;
|
||||
@@ -75,12 +76,12 @@ public class CompositedMultiFrameImage
|
||||
|
||||
public int getXOrigin (int index)
|
||||
{
|
||||
return _images[index].getX();
|
||||
return _images[index].getXOrigin();
|
||||
}
|
||||
|
||||
public int getYOrigin (int index)
|
||||
{
|
||||
return _images[index].getY();
|
||||
return _images[index].getYOrigin();
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
@@ -137,23 +138,16 @@ public class CompositedMultiFrameImage
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public int getX ()
|
||||
public int getXOrigin ()
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY ()
|
||||
public int getYOrigin ()
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public int compare (ComponentFrames cf1, ComponentFrames cf2)
|
||||
{
|
||||
return (cf1.ccomp.componentClass.getRenderPriority(_action, _orient) -
|
||||
cf2.ccomp.componentClass.getRenderPriority(_action, _orient));
|
||||
}
|
||||
|
||||
public long getEstimatedMemoryUsage ()
|
||||
{
|
||||
return delegate.getEstimatedMemoryUsage();
|
||||
@@ -214,7 +208,7 @@ public class CompositedMultiFrameImage
|
||||
* Used to create our mirage using the source action frame images.
|
||||
*/
|
||||
protected class CompositedVolatileMirage extends VolatileMirage
|
||||
implements CompositedMirage
|
||||
implements CompositedMirage, Comparator<ComponentFrames>
|
||||
{
|
||||
public CompositedVolatileMirage (int index)
|
||||
{
|
||||
|
||||
@@ -66,25 +66,43 @@ public class CompositedShadowImage extends CompositedMultiFrameImage
|
||||
return _sources[0].frames.getYOrigin(_orient, index);
|
||||
}
|
||||
|
||||
@Override // documentation inherited
|
||||
protected CompositedMirage createCompositedMirage (int index) {
|
||||
// Always use a CompositedVolatileMirage for ShadowImage since we need to draw into it.
|
||||
return new CompositedVolatileMirage(index);
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public void paintFrame (Graphics2D g, int index, int x, int y) {
|
||||
Composite ocomp = g.getComposite();
|
||||
g.setComposite(_shadowAlpha);
|
||||
_images[index].paint(g, x + _images[index].getX(),
|
||||
y + _images[index].getY());
|
||||
_images[index].paint(g, x + getX(index), y + getY(index));
|
||||
g.setComposite(ocomp);
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
public boolean hitTest (int index, int x, int y) {
|
||||
return _images[index].hitTest(x + _images[index].getX(),
|
||||
y + _images[index].getY());
|
||||
return _images[index].hitTest(x + getX(index), y + getY(index));
|
||||
}
|
||||
|
||||
// documentation inherited from interface TrimmedMultiFrameImage
|
||||
public void getTrimmedBounds (int index, Rectangle bounds) {
|
||||
bounds.setBounds(_images[index].getX(), _images[index].getY(),
|
||||
_images[index].getWidth(), _images[index].getHeight());
|
||||
bounds.setBounds(getX(index), getY(index), _images[index].getWidth(),
|
||||
_images[index].getHeight());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the x offset into the source image for the image at index
|
||||
*/
|
||||
protected int getX (int index) {
|
||||
return ((VolatileMirage)_images[index]).getX();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the y offset into the source image for the image at index
|
||||
*/
|
||||
protected int getY (int index) {
|
||||
return ((VolatileMirage)_images[index]).getY();
|
||||
}
|
||||
|
||||
/** The alpha value at which we render our shadow. */
|
||||
|
||||
Reference in New Issue
Block a user