Whitespace
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@1031 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -144,8 +144,7 @@ public class ObjectSet
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the index of the object or its insertion index if it is
|
* Returns the index of the object or its insertion index if it is not in the set.
|
||||||
* not in the set.
|
|
||||||
*/
|
*/
|
||||||
protected function indexOf (info :ObjectInfo) :int
|
protected function indexOf (info :ObjectInfo) :int
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,49 +26,44 @@ import com.threerings.util.DirectionCodes;
|
|||||||
import com.threerings.media.image.Colorization;
|
import com.threerings.media.image.Colorization;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates a set of frames in each of {@link
|
* Encapsulates a set of frames in each of {@link DirectionCodes#DIRECTION_COUNT} orientations
|
||||||
* DirectionCodes#DIRECTION_COUNT} orientations that are used to render a
|
* that are used to render a character sprite.
|
||||||
* character sprite.
|
|
||||||
*/
|
*/
|
||||||
public interface ActionFrames
|
public interface ActionFrames
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns the number of orientations available in this set of action
|
* Returns the number of orientations available in this set of action frames.
|
||||||
* frames.
|
|
||||||
*/
|
*/
|
||||||
public int getOrientationCount ();
|
public int getOrientationCount ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the multi-frame image that comprises the frames for the
|
* Returns the multi-frame image that comprises the frames for the specified orientation.
|
||||||
* specified orientation.
|
|
||||||
*/
|
*/
|
||||||
public TrimmedMultiFrameImage getFrames (int orient);
|
public TrimmedMultiFrameImage getFrames (int orient);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the x offset from the upper left of the image to the
|
* Returns the x offset from the upper left of the image to the "origin" for this character
|
||||||
* "origin" for this character frame. A sprite with location (x, y)
|
* frame. A sprite with location (x, y) will be rendered such that its origin is coincident
|
||||||
* will be rendered such that its origin is coincident with that
|
* with that location.
|
||||||
* location.
|
|
||||||
*/
|
*/
|
||||||
public int getXOrigin (int orient, int frameIdx);
|
public int getXOrigin (int orient, int frameIdx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the y offset from the upper left of the image to the
|
* Returns the y offset from the upper left of the image to the "origin" for this character
|
||||||
* "origin" for this character frame. A sprite with location (x, y)
|
* frame. A sprite with location (x, y) will be rendered such that its origin is coincident
|
||||||
* will be rendered such that its origin is coincident with that
|
* with that location.
|
||||||
* location.
|
|
||||||
*/
|
*/
|
||||||
public int getYOrigin (int orient, int frameIdx);
|
public int getYOrigin (int orient, int frameIdx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a clone of these action frames which will have the supplied
|
* Creates a clone of these action frames which will have the supplied colorizations applied
|
||||||
* colorizations applied to the frame images.
|
* to the frame images.
|
||||||
*/
|
*/
|
||||||
public ActionFrames cloneColorized (Colorization[] zations);
|
public ActionFrames cloneColorized (Colorization[] zations);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a clone of these action frames which will have the supplied
|
* Creates a clone of these action frames which will have the supplied translation applied to
|
||||||
* translation applied to the frame images.
|
* the frame images.
|
||||||
*/
|
*/
|
||||||
public ActionFrames cloneTranslated (int dx, int dy);
|
public ActionFrames cloneTranslated (int dx, int dy);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,16 +32,14 @@ import com.threerings.media.sprite.ImageSprite;
|
|||||||
import static com.threerings.cast.Log.log;
|
import static com.threerings.cast.Log.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A character sprite is a sprite that animates itself while walking
|
* A character sprite is a sprite that animates itself while walking about in a scene.
|
||||||
* about in a scene.
|
|
||||||
*/
|
*/
|
||||||
public class CharacterSprite extends ImageSprite
|
public class CharacterSprite extends ImageSprite
|
||||||
implements StandardActions
|
implements StandardActions
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Initializes this character sprite with the specified character
|
* Initializes this character sprite with the specified character descriptor and character
|
||||||
* descriptor and character manager. It will obtain animation data
|
* manager. It will obtain animation data from the supplied character manager.
|
||||||
* from the supplied character manager.
|
|
||||||
*/
|
*/
|
||||||
public void init (CharacterDescriptor descrip, CharacterManager charmgr)
|
public void init (CharacterDescriptor descrip, CharacterManager charmgr)
|
||||||
{
|
{
|
||||||
@@ -60,9 +58,8 @@ public class CharacterSprite extends ImageSprite
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after this sprite has been initialized with its character
|
* Called after this sprite has been initialized with its character descriptor and character
|
||||||
* descriptor and character manager. Derived classes can do post-init
|
* manager. Derived classes can do post-init business here.
|
||||||
* business here.
|
|
||||||
*/
|
*/
|
||||||
protected void didInit ()
|
protected void didInit ()
|
||||||
{
|
{
|
||||||
@@ -84,8 +81,8 @@ public class CharacterSprite extends ImageSprite
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the action to use when the sprite is at rest. The default
|
* Specifies the action to use when the sprite is at rest. The default is
|
||||||
* is <code>STANDING</code>.
|
* <code>STANDING</code>.
|
||||||
*/
|
*/
|
||||||
public void setRestingAction (String action)
|
public void setRestingAction (String action)
|
||||||
{
|
{
|
||||||
@@ -93,9 +90,8 @@ public class CharacterSprite extends ImageSprite
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the action to be used when the sprite is at rest. Derived
|
* Returns the action to be used when the sprite is at rest. Derived classes may wish to
|
||||||
* classes may wish to override this method and vary the action based
|
* override this method and vary the action based on external parameters (or randomly).
|
||||||
* on external parameters (or randomly).
|
|
||||||
*/
|
*/
|
||||||
public String getRestingAction ()
|
public String getRestingAction ()
|
||||||
{
|
{
|
||||||
@@ -103,8 +99,8 @@ public class CharacterSprite extends ImageSprite
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies the action to use when the sprite is following a path.
|
* Specifies the action to use when the sprite is following a path. The default is
|
||||||
* The default is <code>WALKING</code>.
|
* <code>WALKING</code>.
|
||||||
*/
|
*/
|
||||||
public void setFollowingPathAction (String action)
|
public void setFollowingPathAction (String action)
|
||||||
{
|
{
|
||||||
@@ -112,9 +108,8 @@ public class CharacterSprite extends ImageSprite
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the action to be used when the sprite is following a path.
|
* Returns the action to be used when the sprite is following a path. Derived classes may wish
|
||||||
* Derived classes may wish to override this method and vary the
|
* to override this method and vary the action based on external parameters (or randomly).
|
||||||
* action based on external parameters (or randomly).
|
|
||||||
*/
|
*/
|
||||||
public String getFollowingPathAction ()
|
public String getFollowingPathAction ()
|
||||||
{
|
{
|
||||||
@@ -122,8 +117,8 @@ public class CharacterSprite extends ImageSprite
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the action sequence used when rendering the character, from
|
* Sets the action sequence used when rendering the character, from the set of available
|
||||||
* the set of available sequences.
|
* sequences.
|
||||||
*/
|
*/
|
||||||
public void setActionSequence (String action)
|
public void setActionSequence (String action)
|
||||||
{
|
{
|
||||||
@@ -145,8 +140,8 @@ public class CharacterSprite extends ImageSprite
|
|||||||
public void setOrientation (int orient)
|
public void setOrientation (int orient)
|
||||||
{
|
{
|
||||||
if (orient < 0 || orient >= FINE_DIRECTION_COUNT) {
|
if (orient < 0 || orient >= FINE_DIRECTION_COUNT) {
|
||||||
log.info("Refusing to set invalid orientation [sprite=" + this +
|
log.info("Refusing to set invalid orientation",
|
||||||
", orient=" + orient + "].", new Exception());
|
"sprite", this, "orient", orient, new Exception());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,8 +167,7 @@ public class CharacterSprite extends ImageSprite
|
|||||||
// tick caused them to become invalid
|
// tick caused them to become invalid
|
||||||
compositeActionFrames();
|
compositeActionFrames();
|
||||||
super.tick(tickStamp);
|
super.tick(tickStamp);
|
||||||
// composite our action frames if something during tick() caused
|
// composite our action frames if something during tick() caused them to become invalid
|
||||||
// them to become invalid
|
|
||||||
compositeActionFrames();
|
compositeActionFrames();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,25 +211,22 @@ public class CharacterSprite extends ImageSprite
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to paint any decorations that should appear behind the
|
* Called to paint any decorations that should appear behind the character sprite image.
|
||||||
* character sprite image.
|
|
||||||
*/
|
*/
|
||||||
protected void decorateBehind (Graphics2D gfx)
|
protected void decorateBehind (Graphics2D gfx)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to paint any decorations that should appear in front of the
|
* Called to paint any decorations that should appear in front of the character sprite image.
|
||||||
* character sprite image.
|
|
||||||
*/
|
*/
|
||||||
protected void decorateInFront (Graphics2D gfx)
|
protected void decorateInFront (Graphics2D gfx)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rebuilds our action frames given our current character descriptor
|
* Rebuilds our action frames given our current character descriptor and action sequence. This
|
||||||
* and action sequence. This is called when either of those two things
|
* is called when either of those two things changes.
|
||||||
* changes.
|
|
||||||
*/
|
*/
|
||||||
protected void updateActionFrames ()
|
protected void updateActionFrames ()
|
||||||
{
|
{
|
||||||
@@ -258,12 +249,12 @@ public class CharacterSprite extends ImageSprite
|
|||||||
setFrameRate(actseq.framesPerSecond);
|
setFrameRate(actseq.framesPerSecond);
|
||||||
|
|
||||||
} catch (NoSuchComponentException nsce) {
|
} catch (NoSuchComponentException nsce) {
|
||||||
log.warning("Character sprite references non-existent " +
|
log.warning("Character sprite references non-existent component",
|
||||||
"component [sprite=" + this + ", err=" + nsce + "].");
|
"sprite", this, "err", nsce);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("Failed to obtain action frames [sprite=" + this +
|
log.warning("Failed to obtain action frames",
|
||||||
", descrip=" + _descrip + ", action=" + _action + "].", e);
|
"sprite", this, "descrip", _descrip, "action", _action, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,8 +282,7 @@ public class CharacterSprite extends ImageSprite
|
|||||||
protected boolean tickPath (long tickStamp)
|
protected boolean tickPath (long tickStamp)
|
||||||
{
|
{
|
||||||
boolean moved = super.tickPath(tickStamp);
|
boolean moved = super.tickPath(tickStamp);
|
||||||
// composite our action frames if our path caused them to become
|
// composite our action frames if our path caused them to become invalid
|
||||||
// invalid
|
|
||||||
compositeActionFrames();
|
compositeActionFrames();
|
||||||
return moved;
|
return moved;
|
||||||
}
|
}
|
||||||
@@ -341,22 +331,21 @@ public class CharacterSprite extends ImageSprite
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by {@link #accomodateFrame} to give derived classes an
|
* Called by {@link #accomodateFrame} to give derived classes an opportunity to incorporate
|
||||||
* opportunity to incorporate the bounds of any decorations that will
|
* the bounds of any decorations that will be drawn along with this sprite. The
|
||||||
* be drawn along with this sprite. The {@link #_ibounds} rectangle
|
* {@link #_ibounds} rectangle will contain the bounds of the image that comprises the
|
||||||
* will contain the bounds of the image that comprises the undecorated
|
* undecorated sprite. From that the position and size of decorations can be computed and
|
||||||
* sprite. From that the position and size of decorations can be
|
* unioned with the supplied bounds rectangle (most likely by using
|
||||||
* computed and unioned with the supplied bounds rectangle (most
|
* {@link SwingUtilities#computeUnion} which applies the union in place rather than creating a
|
||||||
* likely by using {@link SwingUtilities#computeUnion} which applies
|
* new rectangle).
|
||||||
* the union in place rather than creating a new rectangle).
|
|
||||||
*/
|
*/
|
||||||
protected void unionDecorationBounds (Rectangle bounds)
|
protected void unionDecorationBounds (Rectangle bounds)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the sprite animation frame to reflect the cessation of
|
* Updates the sprite animation frame to reflect the cessation of movement and disables any
|
||||||
* movement and disables any further animation.
|
* further animation.
|
||||||
*/
|
*/
|
||||||
protected void halt ()
|
protected void halt ()
|
||||||
{
|
{
|
||||||
@@ -378,8 +367,7 @@ public class CharacterSprite extends ImageSprite
|
|||||||
/** The action to use when following a path. */
|
/** The action to use when following a path. */
|
||||||
protected String _followingPathAction = WALKING;
|
protected String _followingPathAction = WALKING;
|
||||||
|
|
||||||
/** A reference to the descriptor for the character that we're
|
/** A reference to the descriptor for the character that we're visualizing. */
|
||||||
* visualizing. */
|
|
||||||
protected CharacterDescriptor _descrip;
|
protected CharacterDescriptor _descrip;
|
||||||
|
|
||||||
/** A reference to the character manager that created us. */
|
/** A reference to the character manager that created us. */
|
||||||
@@ -388,12 +376,11 @@ public class CharacterSprite extends ImageSprite
|
|||||||
/** The action we are currently displaying. */
|
/** The action we are currently displaying. */
|
||||||
protected String _action;
|
protected String _action;
|
||||||
|
|
||||||
/** The animation frames for the active action sequence in each
|
/** The animation frames for the active action sequence in each orientation. */
|
||||||
* orientation. */
|
|
||||||
protected ActionFrames _aframes;
|
protected ActionFrames _aframes;
|
||||||
|
|
||||||
/** The offset from the upper-left of the total sprite bounds to the
|
/** The offset from the upper-left of the total sprite bounds to the upper-left of the image
|
||||||
* upper-left of the image within those bounds. */
|
* within those bounds. */
|
||||||
protected Point _ioff = new Point();
|
protected Point _ioff = new Point();
|
||||||
|
|
||||||
/** The bounds of the current sprite image. */
|
/** The bounds of the current sprite image. */
|
||||||
|
|||||||
@@ -108,12 +108,11 @@ public class ActiveRepaintManager extends RepaintManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure that the component is actually in a window or applet
|
// make sure that the component is actually in a window or applet that is showing
|
||||||
// that is showing
|
|
||||||
if (getRoot(vroot) == null) {
|
if (getRoot(vroot) == null) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
log.info("Skipping rootless component [comp=" + toString(comp) +
|
log.info("Skipping rootless component",
|
||||||
", vroot=" + toString(vroot) + "].");
|
"comp", toString(comp), "vroot", toString(vroot));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -154,8 +153,7 @@ public class ActiveRepaintManager extends RepaintManager
|
|||||||
|
|
||||||
drect = new Rectangle(x, y, width, height);
|
drect = new Rectangle(x, y, width, height);
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
log.info("Dirtying component [comp=" + toString(comp) +
|
log.info("Dirtying component", "comp", toString(comp), "drect", drect);
|
||||||
", drect=" + StringUtil.toString(drect) + "]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we made it this far, we can queue up a dirty region for this component to be
|
// if we made it this far, we can queue up a dirty region for this component to be
|
||||||
@@ -278,10 +276,9 @@ public class ActiveRepaintManager extends RepaintManager
|
|||||||
drect.y = y;
|
drect.y = y;
|
||||||
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
log.info("Found dirty parent [comp=" + toString(comp) +
|
log.info("Found dirty parent",
|
||||||
", drect=" + StringUtil.toString(drect) +
|
"comp", toString(comp), "drect", StringUtil.toString(drect),
|
||||||
", pcomp=" + toString(c) +
|
"pcomp", toString(c), "prect", StringUtil.toString(prect));
|
||||||
", prect=" + StringUtil.toString(prect) + "].");
|
|
||||||
}
|
}
|
||||||
prect.add(drect);
|
prect.add(drect);
|
||||||
|
|
||||||
@@ -294,8 +291,7 @@ public class ActiveRepaintManager extends RepaintManager
|
|||||||
continue PRUNE;
|
continue PRUNE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// translate the coordinates into this component's
|
// translate the coordinates into this component's coordinate system
|
||||||
// coordinate system
|
|
||||||
x += c.getX();
|
x += c.getX();
|
||||||
y += c.getY();
|
y += c.getY();
|
||||||
}
|
}
|
||||||
@@ -364,9 +360,8 @@ public class ActiveRepaintManager extends RepaintManager
|
|||||||
// instance
|
// instance
|
||||||
if (root == _root) {
|
if (root == _root) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
log.info("Repainting [comp=" + toString(comp) + StringUtil.toString(_cbounds) +
|
log.info("Repainting", "comp", toString(comp) + StringUtil.toString(_cbounds),
|
||||||
", ocomp=" + toString(ocomp) +
|
"ocomp", toString(ocomp), "drect", StringUtil.toString(drect));
|
||||||
", drect=" + StringUtil.toString(drect) + "].");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setClip(drect);
|
g.setClip(drect);
|
||||||
@@ -377,7 +372,7 @@ public class ActiveRepaintManager extends RepaintManager
|
|||||||
ocomp.paint(g);
|
ocomp.paint(g);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("Exception while painting component [comp=" + ocomp + "].", e);
|
log.warning("Exception while painting component", "comp", ocomp, e);
|
||||||
}
|
}
|
||||||
g.translate(-_cbounds.x, -_cbounds.y);
|
g.translate(-_cbounds.x, -_cbounds.y);
|
||||||
|
|
||||||
@@ -387,9 +382,9 @@ public class ActiveRepaintManager extends RepaintManager
|
|||||||
|
|
||||||
} else if (root != null) {
|
} else if (root != null) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
log.info("Repainting old-school [comp=" + toString(comp) +
|
log.info("Repainting old-school",
|
||||||
", ocomp=" + toString(ocomp) + ", root=" + toString(root) +
|
"comp", toString(comp), "ocomp", toString(ocomp), "root", toString(root),
|
||||||
", bounds=" + StringUtil.toString(_cbounds) + "].");
|
"bounds", StringUtil.toString(_cbounds));
|
||||||
dumpHierarchy(comp);
|
dumpHierarchy(comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,10 +440,10 @@ public class ActiveRepaintManager extends RepaintManager
|
|||||||
protected Object[] _invalid;
|
protected Object[] _invalid;
|
||||||
|
|
||||||
/** A mapping of invalid rectangles for each widget that is dirty. */
|
/** A mapping of invalid rectangles for each widget that is dirty. */
|
||||||
protected Map<JComponent,Rectangle> _dirty = Maps.newHashMap();
|
protected Map<JComponent, Rectangle> _dirty = Maps.newHashMap();
|
||||||
|
|
||||||
/** A spare hashmap that we swap in while repainting dirty components in the old hashmap. */
|
/** A spare hashmap that we swap in while repainting dirty components in the old hashmap. */
|
||||||
protected Map<JComponent,Rectangle> _spare = Maps.newHashMap();
|
protected Map<JComponent, Rectangle> _spare = Maps.newHashMap();
|
||||||
|
|
||||||
/** Used to compute dirty components' bounds. */
|
/** Used to compute dirty components' bounds. */
|
||||||
protected Rectangle _cbounds = new Rectangle();
|
protected Rectangle _cbounds = new Rectangle();
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ import java.awt.image.VolatileImage;
|
|||||||
import static com.threerings.media.Log.log;
|
import static com.threerings.media.Log.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link FrameManager} extension that uses a volatile off-screen image
|
* A {@link FrameManager} extension that uses a volatile off-screen image to do its rendering.
|
||||||
* to do its rendering.
|
|
||||||
*/
|
*/
|
||||||
public class BackFrameManager extends FrameManager
|
public class BackFrameManager extends FrameManager
|
||||||
{
|
{
|
||||||
@@ -92,8 +91,7 @@ public class BackFrameManager extends FrameManager
|
|||||||
}
|
}
|
||||||
_fgfx.drawImage(_backimg, 0, 0, null);
|
_fgfx.drawImage(_backimg, 0, 0, null);
|
||||||
|
|
||||||
// if we loop through a second time, we'll need to rerender
|
// if we loop through a second time, we'll need to rerender everything
|
||||||
// everything
|
|
||||||
incremental = false;
|
incremental = false;
|
||||||
|
|
||||||
} while (_backimg.contentsLost());
|
} while (_backimg.contentsLost());
|
||||||
@@ -118,8 +116,8 @@ public class BackFrameManager extends FrameManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the off-screen buffer used to perform double buffered
|
* Creates the off-screen buffer used to perform double buffered rendering of the animated
|
||||||
* rendering of the animated panel.
|
* panel.
|
||||||
*/
|
*/
|
||||||
protected void createBackBuffer (GraphicsConfiguration gc)
|
protected void createBackBuffer (GraphicsConfiguration gc)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ import java.awt.image.BufferStrategy;
|
|||||||
import static com.threerings.media.Log.log;
|
import static com.threerings.media.Log.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link FrameManager} extension that uses a flip-buffer (via {@link
|
* A {@link FrameManager} extension that uses a flip-buffer (via {@link BufferStrategy} to do its
|
||||||
* BufferStrategy} to do its rendering.
|
* rendering.
|
||||||
*/
|
*/
|
||||||
public class FlipFrameManager extends FrameManager
|
public class FlipFrameManager extends FrameManager
|
||||||
{
|
{
|
||||||
@@ -64,15 +64,13 @@ public class FlipFrameManager extends FrameManager
|
|||||||
|
|
||||||
// dirty everything if we're not incrementally rendering
|
// dirty everything if we're not incrementally rendering
|
||||||
if (!incremental) {
|
if (!incremental) {
|
||||||
log.info("Doing non-incremental render; contents lost " +
|
log.info("Doing non-incremental render; contents lost",
|
||||||
"[lost=" + _bufstrat.contentsLost() +
|
"lost", _bufstrat.contentsLost(), "rest", _bufstrat.contentsRestored());
|
||||||
", rest=" + _bufstrat.contentsRestored() + "].");
|
|
||||||
_root.getRootPane().revalidate();
|
_root.getRootPane().revalidate();
|
||||||
_root.getRootPane().repaint();
|
_root.getRootPane().repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
// request to paint our participants and components and bail
|
// request to paint our participants and components and bail if they paint nothing
|
||||||
// if they paint nothing
|
|
||||||
if (!paint(gfx)) {
|
if (!paint(gfx)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -80,8 +78,7 @@ public class FlipFrameManager extends FrameManager
|
|||||||
// flip our buffer to visible
|
// flip our buffer to visible
|
||||||
_bufstrat.show();
|
_bufstrat.show();
|
||||||
|
|
||||||
// if we loop through a second time, we'll need to rerender
|
// if we loop through a second time, we'll need to rerender everything
|
||||||
// everything
|
|
||||||
incremental = false;
|
incremental = false;
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ public abstract class FrameManager
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a millisecond granularity time stamp using the {@link MediaTimer} with which this
|
* Returns a millisecond granularity time stamp using the {@link MediaTimer} with which this
|
||||||
* frame manager was configured. <em>Note:</em> this should only be called from the AWT
|
* frame manager was configured. <em>Note:</em> this should only be called from the AWT
|
||||||
* thread.
|
* thread.
|
||||||
*/
|
*/
|
||||||
public long getTimeStamp ()
|
public long getTimeStamp ()
|
||||||
@@ -220,8 +220,8 @@ public abstract class FrameManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the highest drift ratio our timer has seen. 1.0 means no drift (and is what we return
|
* Returns the highest drift ratio our timer has seen. 1.0 means no drift (and is what we
|
||||||
* if we're not using a CalibratingTimer)
|
* return if we're not using a CalibratingTimer)
|
||||||
*/
|
*/
|
||||||
public float getMaxTimerDriftRatio ()
|
public float getMaxTimerDriftRatio ()
|
||||||
{
|
{
|
||||||
@@ -245,9 +245,9 @@ public abstract class FrameManager
|
|||||||
/**
|
/**
|
||||||
* Returns an overlay that can be used to render sprites and animations on top of the entire
|
* Returns an overlay that can be used to render sprites and animations on top of the entire
|
||||||
* frame. This is lazily created the first time this method is called and the overlay will
|
* frame. This is lazily created the first time this method is called and the overlay will
|
||||||
* remain a frame participant until {@link #clearMediaOverlay} is called. Be sure to coordinate
|
* remain a frame participant until {@link #clearMediaOverlay} is called. Be sure to
|
||||||
* access to the overlay in your application as there is only one overlay in existence at any
|
* coordinate access to the overlay in your application as there is only one overlay in
|
||||||
* time, and attempts to use an overlay after it has been cleared will fail.
|
* existence at any time, and attempts to use an overlay after it has been cleared will fail.
|
||||||
*/
|
*/
|
||||||
public MediaOverlay getMediaOverlay ()
|
public MediaOverlay getMediaOverlay ()
|
||||||
{
|
{
|
||||||
@@ -439,14 +439,14 @@ public abstract class FrameManager
|
|||||||
if (HANG_DEBUG) {
|
if (HANG_DEBUG) {
|
||||||
long delay = (System.currentTimeMillis() - start);
|
long delay = (System.currentTimeMillis() - start);
|
||||||
if (delay > HANG_GAP) {
|
if (delay > HANG_GAP) {
|
||||||
log.info("Whoa nelly! Ticker took a long time " +
|
log.info("Whoa nelly! Ticker took a long time",
|
||||||
"[part=" + part + ", time=" + delay + "ms].");
|
"part", part, "time", delay + "ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
log.warning("Frame participant choked during tick " +
|
log.warning("Frame participant choked during tick",
|
||||||
"[part=" + StringUtil.safeToString(part) + "].", t);
|
"part", StringUtil.safeToString(part), t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -529,8 +529,8 @@ public abstract class FrameManager
|
|||||||
if (HANG_DEBUG) {
|
if (HANG_DEBUG) {
|
||||||
long delay = (System.currentTimeMillis() - start);
|
long delay = (System.currentTimeMillis() - start);
|
||||||
if (delay > HANG_GAP) {
|
if (delay > HANG_GAP) {
|
||||||
log.warning("Whoa nelly! Painter took a long time " +
|
log.warning("Whoa nelly! Painter took a long time",
|
||||||
"[part=" + part + ", time=" + delay + "ms].");
|
"part", part, "time", delay + "ms");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -630,16 +630,13 @@ public abstract class FrameManager
|
|||||||
/** Used to effect periodic calls to {@link FrameManager#tick}. */
|
/** Used to effect periodic calls to {@link FrameManager#tick}. */
|
||||||
protected class Ticker extends Thread
|
protected class Ticker extends Thread
|
||||||
{
|
{
|
||||||
public Ticker ()
|
public Ticker () {
|
||||||
{
|
|
||||||
super("FrameManagerTicker");
|
super("FrameManagerTicker");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run ()
|
public void run () {
|
||||||
{
|
log.info("Frame manager ticker running", "sleepGran", _sleepGranularity.getValue());
|
||||||
log.info("Frame manager ticker running " +
|
|
||||||
"[sleepGran=" + _sleepGranularity.getValue() + "].");
|
|
||||||
while (_running) {
|
while (_running) {
|
||||||
long start = 0L;
|
long start = 0L;
|
||||||
if (_perfDebug.getValue()) {
|
if (_perfDebug.getValue()) {
|
||||||
@@ -652,15 +649,15 @@ public abstract class FrameManager
|
|||||||
getPerfMetrics()[0].record((int)(woke-start)/100);
|
getPerfMetrics()[0].record((int)(woke-start)/100);
|
||||||
int elapsed = (int)(woke-start);
|
int elapsed = (int)(woke-start);
|
||||||
if (elapsed > _sleepGranularity.getValue()*1500) {
|
if (elapsed > _sleepGranularity.getValue()*1500) {
|
||||||
log.warning("Long tick [elapsed=" + elapsed + "us].");
|
log.warning("Long tick", "elapsed", elapsed + "us");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// work around sketchy bug on WinXP that causes the clock to leap into the past
|
// work around sketchy bug on WinXP that causes the clock to leap into the past
|
||||||
// from time to time
|
// from time to time
|
||||||
if (woke < _lastAttempt) {
|
if (woke < _lastAttempt) {
|
||||||
log.warning("Zoiks! We've leapt into the past, coping as best we can " +
|
log.warning("Zoiks! We've leapt into the past, coping as best we can",
|
||||||
"[dt=" + (woke - _lastAttempt) + "].");
|
"dt", (woke - _lastAttempt));
|
||||||
_lastAttempt = woke;
|
_lastAttempt = woke;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -674,13 +671,11 @@ public abstract class FrameManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancel ()
|
public void cancel () {
|
||||||
{
|
|
||||||
_running = false;
|
_running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final synchronized boolean testAndSet ()
|
protected final synchronized boolean testAndSet () {
|
||||||
{
|
|
||||||
_tries++;
|
_tries++;
|
||||||
if (!_ticking) {
|
if (!_ticking) {
|
||||||
_ticking = true;
|
_ticking = true;
|
||||||
@@ -689,8 +684,7 @@ public abstract class FrameManager
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final synchronized void clearTicking (long elapsed)
|
protected final synchronized void clearTicking (long elapsed) {
|
||||||
{
|
|
||||||
if (++_ticks == 100) {
|
if (++_ticks == 100) {
|
||||||
long time = (elapsed - _lastTick);
|
long time = (elapsed - _lastTick);
|
||||||
_fps[0] = _tries * 1000f / time;
|
_fps[0] = _tries * 1000f / time;
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ import java.awt.Window;
|
|||||||
import javax.swing.JApplet;
|
import javax.swing.JApplet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When using the {@link FrameManager} in an Applet, one must use this
|
* When using the {@link FrameManager} in an Applet, one must use this top-level class.
|
||||||
* top-level class.
|
|
||||||
*/
|
*/
|
||||||
public class ManagedJApplet extends JApplet
|
public class ManagedJApplet extends JApplet
|
||||||
implements FrameManager.ManagedRoot
|
implements FrameManager.ManagedRoot
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ import java.awt.Window;
|
|||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When using the {@link FrameManager}, one must use this top-level frame
|
* When using the {@link FrameManager}, one must use this top-level frame class.
|
||||||
* class.
|
|
||||||
*/
|
*/
|
||||||
public class ManagedJFrame extends JFrame
|
public class ManagedJFrame extends JFrame
|
||||||
implements FrameManager.ManagedRoot
|
implements FrameManager.ManagedRoot
|
||||||
@@ -82,8 +81,7 @@ public class ManagedJFrame extends JFrame
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We catch paint requests and forward them on to the repaint
|
* We catch paint requests and forward them on to the repaint infrastructure.
|
||||||
* infrastructure.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void paint (Graphics g)
|
public void paint (Graphics g)
|
||||||
@@ -92,8 +90,7 @@ public class ManagedJFrame extends JFrame
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* We catch update requests and forward them on to the repaint
|
* We catch update requests and forward them on to the repaint infrastructure.
|
||||||
* infrastructure.
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void update (Graphics g)
|
public void update (Graphics g)
|
||||||
|
|||||||
@@ -216,8 +216,7 @@ public class MediaPanel extends JComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an animation to this panel. Animations are automatically
|
* Adds an animation to this panel. Animations are automatically removed when they finish.
|
||||||
* removed when they finish.
|
|
||||||
*/
|
*/
|
||||||
public void addAnimation (Animation anim)
|
public void addAnimation (Animation anim)
|
||||||
{
|
{
|
||||||
@@ -233,9 +232,8 @@ public class MediaPanel extends JComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Aborts a currently running animation and removes it from this
|
* Aborts a currently running animation and removes it from this panel. Animations are
|
||||||
* panel. Animations are normally automatically removed when they
|
* normally automatically removed when they finish.
|
||||||
* finish.
|
|
||||||
*/
|
*/
|
||||||
public void abortAnimation (Animation anim)
|
public void abortAnimation (Animation anim)
|
||||||
{
|
{
|
||||||
@@ -566,8 +564,7 @@ public class MediaPanel extends JComponent
|
|||||||
protected class ActionSpriteHandler extends MouseInputAdapter
|
protected class ActionSpriteHandler extends MouseInputAdapter
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed (MouseEvent me)
|
public void mousePressed (MouseEvent me) {
|
||||||
{
|
|
||||||
if (_activeSprite == null) {
|
if (_activeSprite == null) {
|
||||||
// see if we can find one
|
// see if we can find one
|
||||||
Sprite s = getHit(me);
|
Sprite s = getHit(me);
|
||||||
@@ -582,8 +579,7 @@ public class MediaPanel extends JComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased (MouseEvent me)
|
public void mouseReleased (MouseEvent me) {
|
||||||
{
|
|
||||||
if (_activeSprite instanceof ArmingSprite) {
|
if (_activeSprite instanceof ArmingSprite) {
|
||||||
((ArmingSprite)_activeSprite).setArmed(false);
|
((ArmingSprite)_activeSprite).setArmed(false);
|
||||||
}
|
}
|
||||||
@@ -615,8 +611,7 @@ public class MediaPanel extends JComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseDragged (MouseEvent me)
|
public void mouseDragged (MouseEvent me) {
|
||||||
{
|
|
||||||
if (_activeSprite instanceof ArmingSprite) {
|
if (_activeSprite instanceof ArmingSprite) {
|
||||||
((ArmingSprite) _activeSprite).setArmed(
|
((ArmingSprite) _activeSprite).setArmed(
|
||||||
_activeSprite.hitTest(me.getX(), me.getY()));
|
_activeSprite.hitTest(me.getX(), me.getY()));
|
||||||
@@ -624,8 +619,7 @@ public class MediaPanel extends JComponent
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseMoved (MouseEvent me)
|
public void mouseMoved (MouseEvent me) {
|
||||||
{
|
|
||||||
Sprite s = getHit(me);
|
Sprite s = getHit(me);
|
||||||
if (_activeSprite == s) {
|
if (_activeSprite == s) {
|
||||||
return;
|
return;
|
||||||
@@ -642,8 +636,7 @@ public class MediaPanel extends JComponent
|
|||||||
/**
|
/**
|
||||||
* Utility method, get the highest non-disabled action/hover sprite.
|
* Utility method, get the highest non-disabled action/hover sprite.
|
||||||
*/
|
*/
|
||||||
protected Sprite getHit (MouseEvent me)
|
protected Sprite getHit (MouseEvent me) {
|
||||||
{
|
|
||||||
ArrayList<Sprite> list = Lists.newArrayList();
|
ArrayList<Sprite> list = Lists.newArrayList();
|
||||||
getSpriteManager().getHitSprites(list, me.getX(), me.getY());
|
getSpriteManager().getHitSprites(list, me.getX(), me.getY());
|
||||||
for (int ii = 0, nn = list.size(); ii < nn; ii++) {
|
for (int ii = 0, nn = list.size(); ii < nn; ii++) {
|
||||||
|
|||||||
@@ -345,8 +345,7 @@ public class VirtualMediaPanel extends MediaPanel
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log.warning("Eh? Set to invalid pathable mode " +
|
log.warning("Eh? Set to invalid pathable mode", "mode", _fmode);
|
||||||
"[mode=" + _fmode + "].");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,11 +28,10 @@ import com.threerings.media.MediaPanel;
|
|||||||
import com.threerings.media.sprite.Sprite;
|
import com.threerings.media.sprite.Sprite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Sprite that wraps an animation so that a sequence of frames can be easily
|
* A Sprite that wraps an animation so that a sequence of frames can be easily moved around the
|
||||||
* moved around the screen. Animations embedded here should not be added
|
* screen. Animations embedded here should not be added directly to a media panel as this sprite
|
||||||
* directly to a media panel as this sprite will manage them. If the enclosed
|
* will manage them. If the enclosed animation completes, we remove the sprite from the media
|
||||||
* animation completes, we remove the sprite from the media panel, since the
|
* panel, since the animation would normally do that itself.
|
||||||
* animation would normally do that itself.
|
|
||||||
*/
|
*/
|
||||||
public class AnimationSprite extends Sprite
|
public class AnimationSprite extends Sprite
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -411,16 +411,14 @@ public abstract class Sprite extends AbstractMedia
|
|||||||
protected long _when;
|
protected long _when;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The location of the sprite's origin in pixel coordinates. If the
|
/** The location of the sprite's origin in pixel coordinates. If the sprite positions itself
|
||||||
* sprite positions itself via a hotspot that is not the upper left
|
* via a hotspot that is not the upper left coordinate of the sprite's bounds, the offset to
|
||||||
* coordinate of the sprite's bounds, the offset to the hotspot should
|
* the hotspot should be maintained in {@link #_oxoff} and {@link #_oyoff}. */
|
||||||
* be maintained in {@link #_oxoff} and {@link #_oyoff}. */
|
|
||||||
protected int _ox = Integer.MIN_VALUE, _oy = Integer.MIN_VALUE;
|
protected int _ox = Integer.MIN_VALUE, _oy = Integer.MIN_VALUE;
|
||||||
|
|
||||||
/** The offsets from our upper left coordinate to our origin (or hot
|
/** The offsets from our upper left coordinate to our origin (or hot spot). Derived classes
|
||||||
* spot). Derived classes will need to update these values if the
|
* will need to update these values if the sprite's origin is not coincident with the upper
|
||||||
* sprite's origin is not coincident with the upper left coordinate of
|
* left coordinate of its bounds. */
|
||||||
* its bounds. */
|
|
||||||
protected int _oxoff, _oyoff;
|
protected int _oxoff, _oyoff;
|
||||||
|
|
||||||
/** The orientation of this sprite. */
|
/** The orientation of this sprite. */
|
||||||
|
|||||||
@@ -22,8 +22,7 @@
|
|||||||
package com.threerings.media.sprite.action;
|
package com.threerings.media.sprite.action;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An ActionSprite that wishes to be notified of events when it is armed
|
* An ActionSprite that wishes to be notified of events when it is armed or not.
|
||||||
* or not.
|
|
||||||
*/
|
*/
|
||||||
public interface ArmingSprite extends ActionSprite
|
public interface ArmingSprite extends ActionSprite
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,8 +22,7 @@
|
|||||||
package com.threerings.media.sprite.action;
|
package com.threerings.media.sprite.action;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface indicating that a sprite wishes to be notified when
|
* An interface indicating that a sprite wishes to be notified when the mouse hovers over it.
|
||||||
* the mouse hovers over it.
|
|
||||||
*/
|
*/
|
||||||
public interface HoverSprite
|
public interface HoverSprite
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -280,8 +280,7 @@ public class TileSetBundler
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure this tileset's image file exists and check
|
// make sure this tileset's image file exists and check its last modified date
|
||||||
// its last modified date
|
|
||||||
File tsfile = new File(bundleDesc.getParent(),
|
File tsfile = new File(bundleDesc.getParent(),
|
||||||
set.getImagePath());
|
set.getImagePath());
|
||||||
if (!tsfile.exists()) {
|
if (!tsfile.exists()) {
|
||||||
|
|||||||
@@ -39,11 +39,10 @@ import com.threerings.util.DirectionUtil;
|
|||||||
import static com.threerings.media.Log.log;
|
import static com.threerings.media.Log.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The line segment path is used to cause a pathable to follow a path that
|
* The line segment path is used to cause a pathable to follow a path that is made up of a
|
||||||
* is made up of a sequence of line segments. There must be at least two
|
* sequence of line segments. There must be at least two nodes in any worthwhile path. The
|
||||||
* nodes in any worthwhile path. The direction of the first node in the
|
* direction of the first node in the path is meaningless since the pathable begins at that node
|
||||||
* path is meaningless since the pathable begins at that node and will
|
* and will therefore never be heading towards it.
|
||||||
* therefore never be heading towards it.
|
|
||||||
*/
|
*/
|
||||||
public class LineSegmentPath
|
public class LineSegmentPath
|
||||||
implements DirectionCodes, Path
|
implements DirectionCodes, Path
|
||||||
@@ -56,11 +55,10 @@ public class LineSegmentPath
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a line segment path that consists of a single segment
|
* Constructs a line segment path that consists of a single segment connecting the point
|
||||||
* connecting the point <code>(x1, y1)</code> with <code>(x2,
|
* <code>(x1, y1)</code> with <code>(x2, y2)</code>. The orientation for the first node is set
|
||||||
* y2)</code>. The orientation for the first node is set arbitrarily
|
* arbitrarily and the second node is oriented based on the vector between the two nodes (in
|
||||||
* and the second node is oriented based on the vector between the two
|
* top-down coordinates).
|
||||||
* nodes (in top-down coordinates).
|
|
||||||
*/
|
*/
|
||||||
public LineSegmentPath (int x1, int y1, int x2, int y2)
|
public LineSegmentPath (int x1, int y1, int x2, int y2)
|
||||||
{
|
{
|
||||||
@@ -71,8 +69,7 @@ public class LineSegmentPath
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a line segment path between the two nodes with the
|
* Construct a line segment path between the two nodes with the specified direction.
|
||||||
* specified direction.
|
|
||||||
*/
|
*/
|
||||||
public LineSegmentPath (Point p1, Point p2, int dir)
|
public LineSegmentPath (Point p1, Point p2, int dir)
|
||||||
{
|
{
|
||||||
@@ -81,8 +78,8 @@ public class LineSegmentPath
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a line segment path with the specified list of points.
|
* Constructs a line segment path with the specified list of points. An arbitrary direction
|
||||||
* An arbitrary direction will be assigned to the starting node.
|
* will be assigned to the starting node.
|
||||||
*/
|
*/
|
||||||
public LineSegmentPath (List<Point> points)
|
public LineSegmentPath (List<Point> points)
|
||||||
{
|
{
|
||||||
@@ -90,8 +87,7 @@ public class LineSegmentPath
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the orientation the sprite will face at the end of the
|
* Returns the orientation the sprite will face at the end of the path.
|
||||||
* path.
|
|
||||||
*/
|
*/
|
||||||
public int getFinalOrientation ()
|
public int getFinalOrientation ()
|
||||||
{
|
{
|
||||||
@@ -99,8 +95,7 @@ public class LineSegmentPath
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a node to the path with the specified destination point and
|
* Add a node to the path with the specified destination point and facing direction.
|
||||||
* facing direction.
|
|
||||||
*
|
*
|
||||||
* @param x the x-position.
|
* @param x the x-position.
|
||||||
* @param y the y-position.
|
* @param y the y-position.
|
||||||
@@ -112,8 +107,7 @@ public class LineSegmentPath
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the requested node index in the path, or null if no such
|
* Return the requested node index in the path, or null if no such index exists.
|
||||||
* index exists.
|
|
||||||
*
|
*
|
||||||
* @param idx the node index.
|
* @param idx the node index.
|
||||||
*
|
*
|
||||||
@@ -133,12 +127,10 @@ public class LineSegmentPath
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the velocity of this pathable in pixels per millisecond. The
|
* Sets the velocity of this pathable in pixels per millisecond. The velocity is measured as
|
||||||
* velocity is measured as pixels traversed along the path that the
|
* pixels traversed along the path that the pathable is traveling rather than in the x or y
|
||||||
* pathable is traveling rather than in the x or y directions
|
* directions individually. Note that the pathable velocity should not be changed while a path
|
||||||
* individually. Note that the pathable velocity should not be
|
* is being traversed; doing so may result in the pathable position changing unexpectedly.
|
||||||
* changed while a path is being traversed; doing so may result in the
|
|
||||||
* pathable position changing unexpectedly.
|
|
||||||
*
|
*
|
||||||
* @param velocity the pathable velocity in pixels per millisecond.
|
* @param velocity the pathable velocity in pixels per millisecond.
|
||||||
*/
|
*/
|
||||||
@@ -148,12 +140,10 @@ public class LineSegmentPath
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the velocity at which the pathable will need to travel
|
* Computes the velocity at which the pathable will need to travel along this path such that
|
||||||
* along this path such that it will arrive at the destination in
|
* it will arrive at the destination in approximately the specified number of milliseconds.
|
||||||
* approximately the specified number of milliseconds. Efforts are
|
* Efforts are taken to get the pathable there as close to the desired time as possible, but
|
||||||
* taken to get the pathable there as close to the desired time as
|
* framerate variation may prevent it from arriving exactly on time.
|
||||||
* possible, but framerate variation may prevent it from arriving
|
|
||||||
* exactly on time.
|
|
||||||
*/
|
*/
|
||||||
public void setDuration (long millis)
|
public void setDuration (long millis)
|
||||||
{
|
{
|
||||||
@@ -161,8 +151,8 @@ public class LineSegmentPath
|
|||||||
// information to compute our velocity
|
// information to compute our velocity
|
||||||
int ncount = _nodes.size();
|
int ncount = _nodes.size();
|
||||||
if (ncount < 2) {
|
if (ncount < 2) {
|
||||||
log.warning("Requested to set duration of bogus path " +
|
log.warning("Requested to set duration of bogus path",
|
||||||
"[path=" + this + ", duration=" + millis + "].");
|
"path", this, "duration", millis);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,8 +175,7 @@ public class LineSegmentPath
|
|||||||
// give the pathable a chance to perform any starting antics
|
// give the pathable a chance to perform any starting antics
|
||||||
pable.pathBeginning();
|
pable.pathBeginning();
|
||||||
|
|
||||||
// if we have only one node then let the pathable know that we're
|
// if we have only one node then let the pathable know that we're done straight away
|
||||||
// done straight away
|
|
||||||
if (size() < 2) {
|
if (size() < 2) {
|
||||||
// move the pathable to the location specified by the first
|
// move the pathable to the location specified by the first
|
||||||
// node (assuming we have a first node)
|
// node (assuming we have a first node)
|
||||||
@@ -257,16 +246,14 @@ public class LineSegmentPath
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Place the pathable moving along the path at the end of the previous
|
* Place the pathable moving along the path at the end of the previous path node, face it
|
||||||
* path node, face it appropriately for the next node, and start it on
|
* appropriately for the next node, and start it on its way. Returns whether the pathable
|
||||||
* its way. Returns whether the pathable position moved.
|
* position moved.
|
||||||
*/
|
*/
|
||||||
protected boolean headToNextNode (
|
protected boolean headToNextNode (Pathable pable, long startstamp, long now)
|
||||||
Pathable pable, long startstamp, long now)
|
|
||||||
{
|
{
|
||||||
if (_niter == null) {
|
if (_niter == null) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException("headToNextNode() called before init()");
|
||||||
"headToNextNode() called before init()");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check to see if we've completed our path
|
// check to see if we've completed our path
|
||||||
@@ -327,9 +314,8 @@ public class LineSegmentPath
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the path with the path nodes that lead the pathable from
|
* Populate the path with the path nodes that lead the pathable from its starting position to
|
||||||
* its starting position to the given destination coordinates
|
* the given destination coordinates following the given list of screen coordinates.
|
||||||
* following the given list of screen coordinates.
|
|
||||||
*/
|
*/
|
||||||
protected void createPath (List<Point> points)
|
protected void createPath (List<Point> points)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -57,9 +57,9 @@ public class PathNode
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This should be overridden by derived classes (which should be sure
|
* This should be overridden by derived classes (which should be sure to call
|
||||||
* to call <code>super.toString()</code>) to append the derived class
|
* <code>super.toString()</code>) to append the derived class specific path node information
|
||||||
* specific path node information to the string buffer.
|
* to the string buffer.
|
||||||
*/
|
*/
|
||||||
public void toString (StringBuilder buf)
|
public void toString (StringBuilder buf)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,17 +51,16 @@ public interface Pathable
|
|||||||
public void setLocation (int x, int y);
|
public void setLocation (int x, int y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will be called by a path when it moves the pathable in the
|
* Will be called by a path when it moves the pathable in the specified direction. Pathables
|
||||||
* specified direction. Pathables that wish to face in the direction
|
* that wish to face in the direction they are moving can take advantage of this callback.
|
||||||
* they are moving can take advantage of this callback.
|
|
||||||
*
|
*
|
||||||
* @see DirectionCodes
|
* @see DirectionCodes
|
||||||
*/
|
*/
|
||||||
public void setOrientation (int orient);
|
public void setOrientation (int orient);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should return the orientation of the pathable, or {@link
|
* Should return the orientation of the pathable, or {@link DirectionCodes#NONE} if the
|
||||||
* DirectionCodes#NONE} if the pathable does not support orientation.
|
* pathable does not support orientation.
|
||||||
*/
|
*/
|
||||||
public int getOrientation ();
|
public int getOrientation ();
|
||||||
|
|
||||||
|
|||||||
@@ -146,8 +146,7 @@ public class ObjectSet
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the index of the object or its insertion index if it is
|
* Returns the index of the object or its insertion index if it is not in the set.
|
||||||
* not in the set.
|
|
||||||
*/
|
*/
|
||||||
protected final int indexOf (ObjectInfo info)
|
protected final int indexOf (ObjectInfo info)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -77,7 +77,7 @@ for ($i = 0; $i < @ARGV; $i++) {
|
|||||||
if ($arg eq "-p") {
|
if ($arg eq "-p") {
|
||||||
$pid_file = $ARGV[$i+1];
|
$pid_file = $ARGV[$i+1];
|
||||||
splice(@ARGV, $i, 2);
|
splice(@ARGV, $i, 2);
|
||||||
$i -= 1; # decrement i so that things stay in sync
|
$i -= 1; # decrement i so that things stay in sync
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class TestFrame extends JFrame
|
|||||||
{
|
{
|
||||||
public TestFrame ()
|
public TestFrame ()
|
||||||
{
|
{
|
||||||
super("Character Builder");
|
super("Character Builder");
|
||||||
|
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
setDefaultCloseOperation(EXIT_ON_CLOSE);
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ import com.threerings.media.MediaPanel;
|
|||||||
import com.threerings.media.sprite.Sprite;
|
import com.threerings.media.sprite.Sprite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A test app that is useful for visualizing paths during their
|
* A test app that is useful for visualizing paths during their development.
|
||||||
* development.
|
|
||||||
*/
|
*/
|
||||||
public class PathViz extends MediaPanel
|
public class PathViz extends MediaPanel
|
||||||
{
|
{
|
||||||
@@ -87,8 +86,7 @@ public class PathViz extends MediaPanel
|
|||||||
|
|
||||||
protected static class HappySprite extends Sprite
|
protected static class HappySprite extends Sprite
|
||||||
{
|
{
|
||||||
public HappySprite ()
|
public HappySprite () {
|
||||||
{
|
|
||||||
_bounds.width = 32;
|
_bounds.width = 32;
|
||||||
_bounds.height = 32;
|
_bounds.height = 32;
|
||||||
_oxoff = 16;
|
_oxoff = 16;
|
||||||
@@ -96,16 +94,14 @@ public class PathViz extends MediaPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint (Graphics2D gfx)
|
public void paint (Graphics2D gfx) {
|
||||||
{
|
|
||||||
gfx.setColor(Color.blue);
|
gfx.setColor(Color.blue);
|
||||||
int hx = _bounds.x + _bounds.width/2;
|
int hx = _bounds.x + _bounds.width/2;
|
||||||
int hy = _bounds.y + _bounds.height/2;
|
int hy = _bounds.y + _bounds.height/2;
|
||||||
gfx.drawLine(hx, _bounds.y, hx, _bounds.y + _bounds.height-1);
|
gfx.drawLine(hx, _bounds.y, hx, _bounds.y + _bounds.height-1);
|
||||||
gfx.drawLine(_bounds.x, hy, _bounds.x+_bounds.width-1, hy);
|
gfx.drawLine(_bounds.x, hy, _bounds.x+_bounds.width-1, hy);
|
||||||
gfx.setColor(Color.black);
|
gfx.setColor(Color.black);
|
||||||
gfx.drawRect(_bounds.x, _bounds.y,
|
gfx.drawRect(_bounds.x, _bounds.y, _bounds.width-1, _bounds.height-1);
|
||||||
_bounds.width-1, _bounds.height-1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class ScrollingFrame extends ManagedJFrame
|
|||||||
*/
|
*/
|
||||||
public ScrollingFrame (GraphicsConfiguration gc)
|
public ScrollingFrame (GraphicsConfiguration gc)
|
||||||
{
|
{
|
||||||
super(gc);
|
super(gc);
|
||||||
|
|
||||||
// set up the frame options
|
// set up the frame options
|
||||||
setTitle("Scene scrolling test");
|
setTitle("Scene scrolling test");
|
||||||
@@ -64,8 +64,8 @@ public class ScrollingFrame extends ManagedJFrame
|
|||||||
vgl = new VGroupLayout(VGroupLayout.NONE);
|
vgl = new VGroupLayout(VGroupLayout.NONE);
|
||||||
vgl.setOffAxisPolicy(VGroupLayout.STRETCH);
|
vgl.setOffAxisPolicy(VGroupLayout.STRETCH);
|
||||||
JPanel stuff = new JPanel(vgl);
|
JPanel stuff = new JPanel(vgl);
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int ii = 0; ii < 10; ii++) {
|
||||||
stuff.add(new JButton("Button " + i));
|
stuff.add(new JButton("Button " + ii));
|
||||||
}
|
}
|
||||||
getContentPane().add(new SafeScrollPane(stuff));
|
getContentPane().add(new SafeScrollPane(stuff));
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ public class ScrollingFrame extends ManagedJFrame
|
|||||||
|
|
||||||
// now add the new one
|
// now add the new one
|
||||||
_panel = panel;
|
_panel = panel;
|
||||||
getContentPane().add(_panel, 0);
|
getContentPane().add(_panel, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Component _panel;
|
protected Component _panel;
|
||||||
|
|||||||
@@ -67,47 +67,40 @@ public class ScrollingTestApp
|
|||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
// get the graphics environment
|
// get the graphics environment
|
||||||
GraphicsEnvironment env =
|
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||||
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
|
||||||
|
|
||||||
// get the target graphics device
|
// get the target graphics device
|
||||||
GraphicsDevice gd = env.getDefaultScreenDevice();
|
GraphicsDevice gd = env.getDefaultScreenDevice();
|
||||||
log.info("Graphics device [dev=" + gd +
|
log.info("Graphics device", "dev", gd, "mem", gd.getAvailableAcceleratedMemory(),
|
||||||
", mem=" + gd.getAvailableAcceleratedMemory() +
|
"displayChange", gd.isDisplayChangeSupported(), "fullScreen", gd.isFullScreenSupported());
|
||||||
", displayChange=" + gd.isDisplayChangeSupported() +
|
|
||||||
", fullScreen=" + gd.isFullScreenSupported() + "].");
|
|
||||||
|
|
||||||
// get the graphics configuration and display mode information
|
// get the graphics configuration and display mode information
|
||||||
GraphicsConfiguration gc = gd.getDefaultConfiguration();
|
GraphicsConfiguration gc = gd.getDefaultConfiguration();
|
||||||
DisplayMode dm = gd.getDisplayMode();
|
DisplayMode dm = gd.getDisplayMode();
|
||||||
log.info("Display mode [bits=" + dm.getBitDepth() +
|
log.info("Display mode", "bits", dm.getBitDepth(), "wid", dm.getWidth(),
|
||||||
", wid=" + dm.getWidth() + ", hei=" + dm.getHeight() +
|
"hei", dm.getHeight(), "refresh", dm.getRefreshRate());
|
||||||
", refresh=" + dm.getRefreshRate() + "].");
|
|
||||||
|
|
||||||
// create the window
|
// create the window
|
||||||
_frame = new ScrollingFrame(gc);
|
_frame = new ScrollingFrame(gc);
|
||||||
|
|
||||||
// set up our frame manager
|
// set up our frame manager
|
||||||
_framemgr = FrameManager.newInstance(_frame);
|
_framemgr = FrameManager.newInstance(_frame);
|
||||||
|
|
||||||
// we don't need to configure anything
|
// we don't need to configure anything
|
||||||
ResourceManager rmgr = new ResourceManager("rsrc");
|
ResourceManager rmgr = new ResourceManager("rsrc");
|
||||||
rmgr.initBundles(
|
rmgr.initBundles(null, "config/resource/manager.properties", null);
|
||||||
null, "config/resource/manager.properties", null);
|
|
||||||
ClientImageManager imgr = new ClientImageManager(rmgr, _frame);
|
ClientImageManager imgr = new ClientImageManager(rmgr, _frame);
|
||||||
_tilemgr = new MisoTileManager(rmgr, imgr);
|
_tilemgr = new MisoTileManager(rmgr, imgr);
|
||||||
_tilemgr.setTileSetRepository(
|
_tilemgr.setTileSetRepository(new BundledTileSetRepository(rmgr, imgr, "tilesets"));
|
||||||
new BundledTileSetRepository(rmgr, imgr, "tilesets"));
|
|
||||||
|
|
||||||
// hack in some different MisoProperties
|
// hack in some different MisoProperties
|
||||||
MisoConfig.config = new Config("rsrc/config/miso/scrolling");
|
MisoConfig.config = new Config("rsrc/config/miso/scrolling");
|
||||||
|
|
||||||
// create the context object
|
// create the context object
|
||||||
MisoContext ctx = new ContextImpl();
|
MisoContext ctx = new ContextImpl();
|
||||||
|
|
||||||
// create the various managers
|
// create the various managers
|
||||||
BundledComponentRepository crepo =
|
BundledComponentRepository crepo = new BundledComponentRepository(rmgr, imgr, "components");
|
||||||
new BundledComponentRepository(rmgr, imgr, "components");
|
|
||||||
CharacterManager charmgr = new CharacterManager(imgr, crepo);
|
CharacterManager charmgr = new CharacterManager(imgr, crepo);
|
||||||
|
|
||||||
// create our scene view panel
|
// create our scene view panel
|
||||||
@@ -132,8 +125,7 @@ public class ScrollingTestApp
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (NoSuchComponentException nsce) {
|
} catch (NoSuchComponentException nsce) {
|
||||||
log.warning("Can't locate ship component [class=" + scclass +
|
log.warning("Can't locate ship component", "class", scclass, "name", scname);
|
||||||
", name=" + scname + "].");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ship.addSpriteObserver(new PathAdapter() {
|
_ship.addSpriteObserver(new PathAdapter() {
|
||||||
@@ -157,8 +149,7 @@ public class ScrollingTestApp
|
|||||||
int x = _ship.getX(), y = _ship.getY();
|
int x = _ship.getX(), y = _ship.getY();
|
||||||
_ship.move(new LinePath(x, y, x, y + 1000, 3000l));
|
_ship.move(new LinePath(x, y, x, y + 1000, 3000l));
|
||||||
|
|
||||||
// size and position the window, entering full-screen exclusive
|
// size and position the window, entering full-screen exclusive mode if available
|
||||||
// mode if available
|
|
||||||
if (gd.isFullScreenSupported()) {
|
if (gd.isFullScreenSupported()) {
|
||||||
log.info("Entering full-screen exclusive mode.");
|
log.info("Entering full-screen exclusive mode.");
|
||||||
gd.setFullScreenWindow(_frame);
|
gd.setFullScreenWindow(_frame);
|
||||||
@@ -179,18 +170,18 @@ public class ScrollingTestApp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The implementation of the MisoContext interface that provides
|
* The implementation of the MisoContext interface that provides handles to the manager
|
||||||
* handles to the manager objects that offer commonly used services.
|
* objects that offer commonly used services.
|
||||||
*/
|
*/
|
||||||
protected class ContextImpl implements MisoContext
|
protected class ContextImpl implements MisoContext
|
||||||
{
|
{
|
||||||
public MisoTileManager getTileManager () {
|
public MisoTileManager getTileManager () {
|
||||||
return _tilemgr;
|
return _tilemgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FrameManager getFrameManager () {
|
public FrameManager getFrameManager () {
|
||||||
return _framemgr;
|
return _framemgr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ import com.threerings.cast.bundle.BundledComponentRepository;
|
|||||||
import static com.threerings.miso.Log.log;
|
import static com.threerings.miso.Log.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ViewerApp is a scene viewing application that allows for trying
|
* The ViewerApp is a scene viewing application that allows for trying out game scenes in a
|
||||||
* out game scenes in a pseudo-runtime environment.
|
* pseudo-runtime environment.
|
||||||
*/
|
*/
|
||||||
public class ViewerApp
|
public class ViewerApp
|
||||||
{
|
{
|
||||||
@@ -64,38 +64,33 @@ public class ViewerApp
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the graphics environment
|
// get the graphics environment
|
||||||
GraphicsEnvironment env =
|
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||||
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
|
||||||
|
|
||||||
// get the target graphics device
|
// get the target graphics device
|
||||||
GraphicsDevice gd = env.getDefaultScreenDevice();
|
GraphicsDevice gd = env.getDefaultScreenDevice();
|
||||||
log.info("Graphics device [dev=" + gd +
|
log.info("Graphics device", "dev", gd, "mem", gd.getAvailableAcceleratedMemory(),
|
||||||
", mem=" + gd.getAvailableAcceleratedMemory() +
|
"displayChange", gd.isDisplayChangeSupported(),
|
||||||
", displayChange=" + gd.isDisplayChangeSupported() +
|
"fullScreen", gd.isFullScreenSupported());
|
||||||
", fullScreen=" + gd.isFullScreenSupported() + "].");
|
|
||||||
|
|
||||||
// get the graphics configuration and display mode information
|
// get the graphics configuration and display mode information
|
||||||
GraphicsConfiguration gc = gd.getDefaultConfiguration();
|
GraphicsConfiguration gc = gd.getDefaultConfiguration();
|
||||||
DisplayMode dm = gd.getDisplayMode();
|
DisplayMode dm = gd.getDisplayMode();
|
||||||
log.info("Display mode [bits=" + dm.getBitDepth() +
|
log.info("Display mode", "bits", dm.getBitDepth(), "wid", dm.getWidth(),
|
||||||
", wid=" + dm.getWidth() + ", hei=" + dm.getHeight() +
|
"hei", dm.getHeight(), "refresh", dm.getRefreshRate());
|
||||||
", refresh=" + dm.getRefreshRate() + "].");
|
|
||||||
|
|
||||||
// create the window
|
// create the window
|
||||||
_frame = new ViewerFrame(gc);
|
_frame = new ViewerFrame(gc);
|
||||||
_framemgr = FrameManager.newInstance(_frame);
|
_framemgr = FrameManager.newInstance(_frame);
|
||||||
|
|
||||||
// we don't need to configure anything
|
// we don't need to configure anything
|
||||||
ResourceManager rmgr = new ResourceManager("rsrc");
|
ResourceManager rmgr = new ResourceManager("rsrc");
|
||||||
rmgr.initBundles(
|
rmgr.initBundles(null, "config/resource/manager.properties", null);
|
||||||
null, "config/resource/manager.properties", null);
|
|
||||||
ClientImageManager imgr = new ClientImageManager(rmgr, _frame);
|
ClientImageManager imgr = new ClientImageManager(rmgr, _frame);
|
||||||
_tilemgr = new MisoTileManager(rmgr, imgr);
|
_tilemgr = new MisoTileManager(rmgr, imgr);
|
||||||
_tilemgr.setTileSetRepository(
|
_tilemgr.setTileSetRepository(new BundledTileSetRepository(rmgr, imgr, "tilesets"));
|
||||||
new BundledTileSetRepository(rmgr, imgr, "tilesets"));
|
|
||||||
|
|
||||||
// create the context object
|
// create the context object
|
||||||
MisoContext ctx = new ContextImpl();
|
MisoContext ctx = new ContextImpl();
|
||||||
|
|
||||||
// create the various managers
|
// create the various managers
|
||||||
BundledComponentRepository crepo =
|
BundledComponentRepository crepo =
|
||||||
@@ -111,14 +106,13 @@ public class ViewerApp
|
|||||||
SimpleMisoSceneParser parser = new SimpleMisoSceneParser("");
|
SimpleMisoSceneParser parser = new SimpleMisoSceneParser("");
|
||||||
SimpleMisoSceneModel model = parser.parseScene(args[0]);
|
SimpleMisoSceneModel model = parser.parseScene(args[0]);
|
||||||
if (model == null) {
|
if (model == null) {
|
||||||
log.warning("No miso scene found in scene file " +
|
log.warning("No miso scene found in scene file", "path", args[0]);
|
||||||
"[path=" + args[0] + "].");
|
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
_panel.setSceneModel(model);
|
_panel.setSceneModel(model);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("Unable to parse scene [path=" + args[0] + "].", e);
|
log.warning("Unable to parse scene", "path", args[0], e);
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -143,13 +137,11 @@ public class ViewerApp
|
|||||||
*/
|
*/
|
||||||
protected class ContextImpl implements MisoContext
|
protected class ContextImpl implements MisoContext
|
||||||
{
|
{
|
||||||
public MisoTileManager getTileManager ()
|
public MisoTileManager getTileManager () {
|
||||||
{
|
return _tilemgr;
|
||||||
return _tilemgr;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public FrameManager getFrameManager ()
|
public FrameManager getFrameManager () {
|
||||||
{
|
|
||||||
return _framemgr;
|
return _framemgr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class ViewerFrame extends ManagedJFrame
|
|||||||
*/
|
*/
|
||||||
public ViewerFrame (GraphicsConfiguration gc)
|
public ViewerFrame (GraphicsConfiguration gc)
|
||||||
{
|
{
|
||||||
super(gc);
|
super(gc);
|
||||||
|
|
||||||
// set up the frame options
|
// set up the frame options
|
||||||
setTitle("Scene Viewer");
|
setTitle("Scene Viewer");
|
||||||
@@ -57,8 +57,7 @@ public class ViewerFrame extends ManagedJFrame
|
|||||||
|
|
||||||
// create the "Settings" menu
|
// create the "Settings" menu
|
||||||
JMenu menuSettings = new JMenu("Settings");
|
JMenu menuSettings = new JMenu("Settings");
|
||||||
MenuUtil.addMenuItem(
|
MenuUtil.addMenuItem(menuSettings, "Preferences", this, "handlePreferences");
|
||||||
menuSettings, "Preferences", this, "handlePreferences");
|
|
||||||
|
|
||||||
// create the menu bar
|
// create the menu bar
|
||||||
JMenuBar bar = new JMenuBar();
|
JMenuBar bar = new JMenuBar();
|
||||||
@@ -80,7 +79,7 @@ public class ViewerFrame extends ManagedJFrame
|
|||||||
|
|
||||||
// now add the new one
|
// now add the new one
|
||||||
_panel = panel;
|
_panel = panel;
|
||||||
getContentPane().add(_panel, BorderLayout.CENTER);
|
getContentPane().add(_panel, BorderLayout.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class ViewerSceneViewPanel extends MisoScenePanel
|
|||||||
CharacterManager charmgr,
|
CharacterManager charmgr,
|
||||||
ComponentRepository crepo)
|
ComponentRepository crepo)
|
||||||
{
|
{
|
||||||
super(ctx, MisoConfig.getSceneMetrics());
|
super(ctx, MisoConfig.getSceneMetrics());
|
||||||
|
|
||||||
// create the character descriptors
|
// create the character descriptors
|
||||||
_descUser = CastUtil.getRandomDescriptor("female", crepo);
|
_descUser = CastUtil.getRandomDescriptor("female", crepo);
|
||||||
@@ -71,7 +71,7 @@ public class ViewerSceneViewPanel extends MisoScenePanel
|
|||||||
// create the decoy sprites
|
// create the decoy sprites
|
||||||
createDecoys(_spritemgr, charmgr);
|
createDecoys(_spritemgr, charmgr);
|
||||||
|
|
||||||
PerformanceMonitor.register(this, "paint", 1000);
|
PerformanceMonitor.register(this, "paint", 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -137,8 +137,8 @@ public class ViewerSceneViewPanel extends MisoScenePanel
|
|||||||
@Override
|
@Override
|
||||||
public void paint (Graphics g)
|
public void paint (Graphics g)
|
||||||
{
|
{
|
||||||
super.paint(g);
|
super.paint(g);
|
||||||
PerformanceMonitor.tick(this, "paint");
|
PerformanceMonitor.tick(this, "paint");
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
@@ -177,14 +177,14 @@ public class ViewerSceneViewPanel extends MisoScenePanel
|
|||||||
{
|
{
|
||||||
// get the path from here to there
|
// get the path from here to there
|
||||||
LineSegmentPath path = (LineSegmentPath)getPath(s, x, y, true);
|
LineSegmentPath path = (LineSegmentPath)getPath(s, x, y, true);
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
s.cancelMove();
|
s.cancelMove();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// start the sprite moving along the path
|
// start the sprite moving along the path
|
||||||
path.setVelocity(100f/1000f);
|
path.setVelocity(100f/1000f);
|
||||||
s.move(path);
|
s.move(path);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user