Rejigger component rendering order a bit so that individual components can have their own
priority overrides, since unfortunately, not all male/familiars are created equal. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@693 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -60,6 +60,16 @@ public class CharacterComponent implements Serializable
|
|||||||
_frameProvider = fprov;
|
_frameProvider = fprov;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the render priority appropriate for this component at the specified action and
|
||||||
|
* orientation.
|
||||||
|
*/
|
||||||
|
public int getRenderPriority (String action, int orientation)
|
||||||
|
{
|
||||||
|
return componentClass.getRenderPriority(action, name, orientation);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the image frames for the specified action animation or null if
|
* Returns the image frames for the specified action animation or null if
|
||||||
* no animation for the specified action is available for this component.
|
* no animation for the specified action is available for this component.
|
||||||
@@ -78,7 +88,7 @@ public class CharacterComponent implements Serializable
|
|||||||
*
|
*
|
||||||
* @param type null for the normal action frames or one of the custom
|
* @param type null for the normal action frames or one of the custom
|
||||||
* action sub-types: {@link StandardActions#SHADOW_TYPE}, etc.
|
* action sub-types: {@link StandardActions#SHADOW_TYPE}, etc.
|
||||||
*
|
*
|
||||||
* @param existentPaths the set of all paths for which there are valid frames.
|
* @param existentPaths the set of all paths for which there are valid frames.
|
||||||
*/
|
*/
|
||||||
public String getFramePath (String action, String type, Set<String> existentPaths)
|
public String getFramePath (String action, String type, Set<String> existentPaths)
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ import com.samskivert.util.StringUtil;
|
|||||||
*/
|
*/
|
||||||
public class ComponentClass implements Serializable
|
public class ComponentClass implements Serializable
|
||||||
{
|
{
|
||||||
/** Used to effect custom render orders for particular actions,
|
/** Used to effect custom render orders for particular actions, orientations, etc. */
|
||||||
* orientations, etc. */
|
|
||||||
public static class PriorityOverride
|
public static class PriorityOverride
|
||||||
implements Comparable<PriorityOverride>, Serializable
|
implements Comparable<PriorityOverride>, Serializable
|
||||||
{
|
{
|
||||||
@@ -54,25 +53,27 @@ public class ComponentClass implements Serializable
|
|||||||
/** The action, if any, for which this override is appropriate. */
|
/** The action, if any, for which this override is appropriate. */
|
||||||
public String action;
|
public String action;
|
||||||
|
|
||||||
/** The orientations, if any, for which this override is
|
/** The component, if any, for which this override is appropriate. */
|
||||||
* appropriate. */
|
public String component;
|
||||||
|
|
||||||
|
/** The orientations, if any, for which this override is appropriate. */
|
||||||
public ArrayIntSet orients;
|
public ArrayIntSet orients;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether this priority override matches the specified
|
* Determines whether this priority override matches the specified
|
||||||
* action and orientation combination.
|
* action, orientation ant component combination.
|
||||||
*/
|
*/
|
||||||
public boolean matches (String action, int orient)
|
public boolean matches (String action, String component, int orient)
|
||||||
{
|
{
|
||||||
return (((orients == null) || orients.contains(orient)) &&
|
return (((orients == null) || orients.contains(orient)) &&
|
||||||
|
((this.component == null) || this.component.equals(component)) &&
|
||||||
((this.action == null) || this.action.equals(action)));
|
((this.action == null) || this.action.equals(action)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public int compareTo (PriorityOverride po)
|
public int compareTo (PriorityOverride po)
|
||||||
{
|
{
|
||||||
// overrides with both an action and an orientation should
|
// overrides with both an action and an orientation should come first in the list
|
||||||
// come first in the list
|
|
||||||
int pri = priority(), opri = po.priority();
|
int pri = priority(), opri = po.priority();
|
||||||
if (pri == opri) {
|
if (pri == opri) {
|
||||||
return hashCode() - po.hashCode();
|
return hashCode() - po.hashCode();
|
||||||
@@ -84,6 +85,9 @@ public class ComponentClass implements Serializable
|
|||||||
protected int priority ()
|
protected int priority ()
|
||||||
{
|
{
|
||||||
int priority = 0;
|
int priority = 0;
|
||||||
|
if (component != null) {
|
||||||
|
priority += 3; // Extra priority to things that are for specific components
|
||||||
|
}
|
||||||
if (action != null) {
|
if (action != null) {
|
||||||
priority++;
|
priority++;
|
||||||
}
|
}
|
||||||
@@ -96,8 +100,8 @@ public class ComponentClass implements Serializable
|
|||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString ()
|
||||||
{
|
{
|
||||||
return "[pri=" + renderPriority + ", action=" + action +
|
return "[pri=" + renderPriority + ", action=" + action + ", component=" + component +
|
||||||
", orients=" + orients + "]";
|
", orients=" + orients + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Increase this value when object's serialized state is impacted
|
/** Increase this value when object's serialized state is impacted
|
||||||
@@ -139,20 +143,31 @@ public class ComponentClass implements Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the render priority appropriate for the specified action
|
* Returns the render priority appropriate for the specified action and orientation.
|
||||||
* and orientation.
|
*
|
||||||
|
* This is deprecated; you should really use {@link #getRenderPriority(String, String, int)}
|
||||||
|
* to handle potential per-component priority overrides.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public int getRenderPriority (String action, int orientation)
|
public int getRenderPriority (String action, int orientation)
|
||||||
{
|
{
|
||||||
// because we expect there to be relatively few priority
|
return getRenderPriority(action, null, orientation);
|
||||||
// overrides, we simply search linearly through the list for the
|
}
|
||||||
// closest match
|
|
||||||
|
/**
|
||||||
|
* Returns the render priority appropriate for the specified action, orientation and
|
||||||
|
* component.
|
||||||
|
*/
|
||||||
|
public int getRenderPriority (String action, String component, int orientation)
|
||||||
|
{
|
||||||
|
// because we expect there to be relatively few priority overrides, we simply search
|
||||||
|
// linearly through the list for the closest match
|
||||||
int ocount = (_overrides != null) ? _overrides.size() : 0;
|
int ocount = (_overrides != null) ? _overrides.size() : 0;
|
||||||
for (int ii = 0; ii < ocount; ii++) {
|
for (int ii = 0; ii < ocount; ii++) {
|
||||||
PriorityOverride over = _overrides.get(ii);
|
PriorityOverride over = _overrides.get(ii);
|
||||||
// based on the way the overrides are sorted, the first match
|
// based on the way the overrides are sorted, the first match
|
||||||
// is the most specific and the one we want
|
// is the most specific and the one we want
|
||||||
if (over.matches(action, orientation)) {
|
if (over.matches(action, component, orientation)) {
|
||||||
return over.renderPriority;
|
return over.renderPriority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,8 +176,7 @@ public class ComponentClass implements Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the supplied render priority override record to this component
|
* Adds the supplied render priority override record to this component class.
|
||||||
* class.
|
|
||||||
*/
|
*/
|
||||||
public void addPriorityOverride (PriorityOverride override)
|
public void addPriorityOverride (PriorityOverride override)
|
||||||
{
|
{
|
||||||
@@ -183,8 +197,7 @@ public class ComponentClass implements Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if this component class is a shadow layer rather than a
|
* Returns true if this component class is a shadow layer rather than a normal component class.
|
||||||
* normal component class.
|
|
||||||
*/
|
*/
|
||||||
public boolean isShadow ()
|
public boolean isShadow ()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class CompositedMultiFrameImage
|
|||||||
_images[ii] = createCompositedMirage(ii);
|
_images[ii] = createCompositedMirage(ii);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public int getFrameCount () {
|
public int getFrameCount () {
|
||||||
return _images.length;
|
return _images.length;
|
||||||
@@ -107,8 +107,8 @@ public class CompositedMultiFrameImage
|
|||||||
public long getEstimatedMemoryUsage ()
|
public long getEstimatedMemoryUsage ()
|
||||||
{
|
{
|
||||||
long size = 0;
|
long size = 0;
|
||||||
for (int ii = 0; ii < _images.length; ii++) {
|
for (CompositedMirage element : _images) {
|
||||||
size += _images[ii].getEstimatedMemoryUsage();
|
size += element.getEstimatedMemoryUsage();
|
||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ public class CompositedMultiFrameImage
|
|||||||
}
|
}
|
||||||
return new CompositedVolatileMirage(index);
|
return new CompositedVolatileMirage(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A CompositedMirage that forwards all of its Mirage calls to a delegate Mirage.
|
* A CompositedMirage that forwards all of its Mirage calls to a delegate Mirage.
|
||||||
*/
|
*/
|
||||||
@@ -149,7 +149,7 @@ public class CompositedMultiFrameImage
|
|||||||
{
|
{
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getEstimatedMemoryUsage ()
|
public long getEstimatedMemoryUsage ()
|
||||||
{
|
{
|
||||||
return delegate.getEstimatedMemoryUsage();
|
return delegate.getEstimatedMemoryUsage();
|
||||||
@@ -179,12 +179,12 @@ public class CompositedMultiFrameImage
|
|||||||
{
|
{
|
||||||
delegate.paint(gfx, x, y);
|
delegate.paint(gfx, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int x, y;
|
protected int x, y;
|
||||||
|
|
||||||
protected Mirage delegate;
|
protected Mirage delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
protected Mirage getFrame (int orient, int index)
|
protected Mirage getFrame (int orient, int index)
|
||||||
{
|
{
|
||||||
@@ -247,7 +247,7 @@ public class CompositedMultiFrameImage
|
|||||||
// render our volatile image for the first time
|
// render our volatile image for the first time
|
||||||
createVolatileImage();
|
createVolatileImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getXOrigin ()
|
public int getXOrigin ()
|
||||||
{
|
{
|
||||||
return _origin.x;
|
return _origin.x;
|
||||||
@@ -261,8 +261,8 @@ public class CompositedMultiFrameImage
|
|||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public int compare (ComponentFrames cf1, ComponentFrames cf2)
|
public int compare (ComponentFrames cf1, ComponentFrames cf2)
|
||||||
{
|
{
|
||||||
return (cf1.ccomp.componentClass.getRenderPriority(_action, _orient) -
|
return (cf1.ccomp.getRenderPriority(_action, _orient) -
|
||||||
cf2.ccomp.componentClass.getRenderPriority(_action, _orient));
|
cf2.ccomp.getRenderPriority(_action, _orient));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -278,7 +278,7 @@ public class CompositedMultiFrameImage
|
|||||||
}
|
}
|
||||||
return bounds;
|
return bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getTransparency ()
|
protected int getTransparency ()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -242,8 +242,8 @@ public class BundledComponentRepository
|
|||||||
// look up the component class information
|
// look up the component class information
|
||||||
ComponentClass clazz = _classes.get(cclass);
|
ComponentClass clazz = _classes.get(cclass);
|
||||||
if (clazz == null) {
|
if (clazz == null) {
|
||||||
log.warning("Non-existent component class [class=" + cclass + ", name=" + cname +
|
log.warning("Non-existent component class",
|
||||||
", id=" + componentId + "].");
|
"class", cclass, "name", cname, "id", componentId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,7 +262,7 @@ public class BundledComponentRepository
|
|||||||
if (!comps.contains(component)) {
|
if (!comps.contains(component)) {
|
||||||
comps.add(component);
|
comps.add(component);
|
||||||
} else {
|
} else {
|
||||||
log.info("Requested to register the same component twice? [comp=" + component + "].");
|
log.info("Requested to register the same component twice?", "comp", component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user