mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-20 19:49:47 +07:00
Added per-component alpha support
Added per-component alpha support Added support for drawing equipped ethereal items as partly transparent Cleaned up Animation.Layer API a bit
This commit is contained in:
parent
747b877980
commit
174c1cbb53
@ -545,26 +545,34 @@ public class Animation extends BaseDrawable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setBlendMode(int blendMode) {
|
||||
setBlendMode(blendMode, Color.WHITE);
|
||||
public Layer setBlendMode(int blendMode) {
|
||||
return setBlendMode(blendMode, Color.WHITE);
|
||||
}
|
||||
|
||||
public void setBlendMode(int blendMode, Color tint) {
|
||||
public Layer setBlendMode(int blendMode, Color tint) {
|
||||
this.blendMode = blendMode;
|
||||
this.tint = tint;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setTransform(Index colormap, int id) {
|
||||
public Layer setAlpha(float a) {
|
||||
if (tint == Color.WHITE) tint = tint.cpy();
|
||||
tint.a = a;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Layer setTransform(Index colormap, int id) {
|
||||
transform = colormap;
|
||||
transformColor = colormap == null ? 0 : id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setTransform(byte packedTransform) {
|
||||
public Layer setTransform(byte packedTransform) {
|
||||
int transform = packedTransform & 0xFF;
|
||||
if (transform == 0xFF) {
|
||||
setTransform(null, 0);
|
||||
return setTransform(null, 0);
|
||||
} else {
|
||||
setTransform(Riiablo.colormaps.get(transform >>> 5), transform & 0x1F);
|
||||
return setTransform(Riiablo.colormaps.get(transform >>> 5), transform & 0x1F);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,6 +211,11 @@ public abstract class Entity implements Animation.AnimationListener {
|
||||
DEFAULT_TRANS = new byte[COF.Component.NUM_COMPONENTS];
|
||||
Arrays.fill(DEFAULT_TRANS, (byte) 0xFF);
|
||||
}
|
||||
private static final float[] DEFAULT_ALPHA;
|
||||
static {
|
||||
DEFAULT_ALPHA = new float[COF.Component.NUM_COMPONENTS];
|
||||
Arrays.fill(DEFAULT_ALPHA, 1.0f);
|
||||
}
|
||||
|
||||
String classname;
|
||||
Type type;
|
||||
@ -223,6 +228,7 @@ public abstract class Entity implements Animation.AnimationListener {
|
||||
String cof;
|
||||
byte comp[];
|
||||
byte trans[]; // TODO: Could also assign DEFAULT_TRANS and lazy change
|
||||
float alpha[];
|
||||
float angle = DEFAULT_ANGLE;
|
||||
Vector2 position = new Vector2();
|
||||
|
||||
@ -272,6 +278,7 @@ public abstract class Entity implements Animation.AnimationListener {
|
||||
wclass = WEAPON_HTH;
|
||||
comp = components;
|
||||
trans = transforms;
|
||||
alpha = DEFAULT_ALPHA.clone();
|
||||
invalidate();
|
||||
|
||||
// TODO: lazy init
|
||||
@ -329,6 +336,14 @@ public abstract class Entity implements Animation.AnimationListener {
|
||||
}
|
||||
}
|
||||
|
||||
public void setAlpha(byte component, float a) {
|
||||
if (alpha[component] != a) {
|
||||
if (DEBUG_STATE) Gdx.app.debug(TAG, classname + " alpha: " + alpha[component] + " -> " + a);
|
||||
alpha[component] = a;
|
||||
if (animation != null) animation.getLayer(component).setAlpha(a);
|
||||
}
|
||||
}
|
||||
|
||||
public final void invalidate() {
|
||||
dirty = Dirty.ALL;
|
||||
}
|
||||
@ -383,6 +398,7 @@ public abstract class Entity implements Animation.AnimationListener {
|
||||
DCC dcc = Riiablo.assets.get(descriptor);
|
||||
animation.setLayer(layer, dcc, false)
|
||||
.setTransform(trans[layer.component])
|
||||
.setAlpha(alpha[layer.component])
|
||||
;
|
||||
// FIXME: colors don't look right for sorc Tirant circlet changing hair color
|
||||
// putting a ruby in a white circlet not change color on item or character
|
||||
|
@ -322,6 +322,10 @@ public class Player extends Entity {
|
||||
setComponent(COF.Component.RH, RH != null ? (byte) Type.PLR.getComponent(RH.base.alternateGfx) : 0);
|
||||
setComponent(COF.Component.LH, LH != null ? (byte) Type.PLR.getComponent(LH.base.alternateGfx) : 0);
|
||||
setComponent(COF.Component.SH, SH != null ? (byte) Type.PLR.getComponent(SH.base.alternateGfx) : 0);
|
||||
|
||||
setAlpha(COF.Component.RH, RH != null && RH.isEthereal() ? Item.ETHEREAL_ALPHA : 1.0f);
|
||||
setAlpha(COF.Component.LH, LH != null && LH.isEthereal() ? Item.ETHEREAL_ALPHA : 1.0f);
|
||||
setAlpha(COF.Component.SH, SH != null && SH.isEthereal() ? Item.ETHEREAL_ALPHA : 1.0f);
|
||||
}
|
||||
|
||||
public Item getSlot(Slot slot) {
|
||||
|
Loading…
Reference in New Issue
Block a user