Changed the way shadow layers will be handled because we only have a list of

components when creating our character and we need to be able to determine
which shadow layers are needed from the set of active components.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3739 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2005-10-20 18:10:03 +00:00
parent 18833d7eb7
commit 882868abb4
3 changed files with 37 additions and 31 deletions
@@ -251,6 +251,9 @@ public class CharacterManager
Log.debug("Compositing action [action=" + action + Log.debug("Compositing action [action=" + action +
", descrip=" + descrip + "]."); ", descrip=" + descrip + "].");
// this will be used to construct any shadow layers
HashMap shadows = null;
// create colorized versions of all of the source action frames // create colorized versions of all of the source action frames
ComponentFrames[] sources = new ComponentFrames[ccount]; ComponentFrames[] sources = new ComponentFrames[ccount];
for (int ii = 0; ii < ccount; ii++) { for (int ii = 0; ii < ccount; ii++) {
@@ -268,16 +271,16 @@ public class CharacterManager
sources[ii].frames = (zations == null || zations[ii] == null) ? sources[ii].frames = (zations == null || zations[ii] == null) ?
source : source.cloneColorized(zations[ii]); source : source.cloneColorized(zations[ii]);
// load up the shadow images if they are needed // // load up the shadow images if they are needed
if (sources[ii].ccomp.componentClass.shadowed) { // if (sources[ii].ccomp.componentClass.isShadowed()) {
sources[ii].shadowFrames = sources[ii].ccomp.getFrames( // sources[ii].shadowFrames = sources[ii].ccomp.getFrames(
action + StandardActions.SHADOW_SUFFIX); // action + StandardActions.SHADOW_SUFFIX);
if (sources[ii].shadowFrames == null) { // if (sources[ii].shadowFrames == null) {
Log.warning("Missing shadow frames for action " + // Log.warning("Missing shadow frames for action " +
"[action=" + action + // "[action=" + action +
", comp=" + sources[ii].ccomp + "]."); // ", comp=" + sources[ii].ccomp + "].");
} // }
} // }
} }
// use those to create an entity that will lazily composite things // use those to create an entity that will lazily composite things
@@ -117,24 +117,14 @@ public class ComponentClass implements Serializable
* be null if a system does not use recolorable components. */ * be null if a system does not use recolorable components. */
public String[] colors; public String[] colors;
/** Indicates whether or not components in this class have an associated /** Indicates the class name of the shadow layer to which this component
* shadow image. */ * class contributes a shadow. */
public boolean shadowed; public String shadow;
/** Null for a normal component, the color of the pre-composited shadow for /** Null for a normal component, the color of the pre-composited shadow for
* the special "shadow" component class. */ * the special "shadow" component class. */
public Color shadowColor; public Color shadowColor;
/** Zero for a normal component, defines the (inclusive) lower bound of the
* range of components whose shadow will be included in this pre-composited
* shadow layer for a shadow component. */
public int minShadowPri;
/** Zero for a normal component, defines the (inclusive) upper bound of the
* range of components whose shadow will be included in this pre-composited
* shadow layer for a shadow component. */
public int maxShadowPri;
/** /**
* Creates an uninitialized instance suitable for unserialization or * Creates an uninitialized instance suitable for unserialization or
* population during XML parsing. * population during XML parsing.
@@ -177,6 +167,25 @@ public class ComponentClass implements Serializable
_overrides.insertSorted(override); _overrides.insertSorted(override);
} }
/**
* Returns true if this component class contributes a shadow to a
* particular shadow layer. Note: this is different from <em>being</em> a
* shadow layer which is determined by calling {@link #isShadow}.
*/
public boolean isShadowed ()
{
return (shadow != null);
}
/**
* Returns true if this component class is a shadow layer rather than a
* normal component class.
*/
public boolean isShadow ()
{
return (shadowColor != null);
}
/** /**
* Classes with the same name are the same. * Classes with the same name are the same.
*/ */
@@ -211,10 +220,8 @@ public class ComponentClass implements Serializable
if (shadowColor != null) { if (shadowColor != null) {
buf.append(", shadow="); buf.append(", shadow=");
buf.append(StringUtil.toString(shadowColor.getComponents(null))); buf.append(StringUtil.toString(shadowColor.getComponents(null)));
buf.append(" (").append(minShadowPri).append("-"); } else if (shadow != null) {
buf.append(maxShadowPri).append(")"); buf.append(", shadow=").append(shadow);
} else {
buf.append(", shadowed=").append(shadowed);
} }
return buf.append("]").toString(); return buf.append("]").toString();
} }
@@ -46,10 +46,6 @@ public class CompositedActionFrames
public ActionFrames frames; public ActionFrames frames;
public ActionFrames shadowFrames;
public ActionFrames cropFrames;
public String toString () { public String toString () {
return ccomp + ":" + frames; return ccomp + ":" + frames;
} }