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