diff --git a/SPD-classes/src/main/java/com/watabou/glwrap/Uniform.java b/SPD-classes/src/main/java/com/watabou/glwrap/Uniform.java index 3bf666acc..adcd54a37 100644 --- a/SPD-classes/src/main/java/com/watabou/glwrap/Uniform.java +++ b/SPD-classes/src/main/java/com/watabou/glwrap/Uniform.java @@ -29,9 +29,9 @@ public class Uniform { private int location; - private float[] recentValue; + private float[] prevVal = new float[4]; - public Uniform( int location ) { + public Uniform(int location) { this.location = location; } @@ -40,43 +40,44 @@ public class Uniform { } public void enable() { - GLES20.glEnableVertexAttribArray( location ); + GLES20.glEnableVertexAttribArray(location); } public void disable() { - GLES20.glDisableVertexAttribArray( location ); + GLES20.glDisableVertexAttribArray(location); } - public void value1f( float value ) { - if (sameFloat(new float[]{value})) return; - GLES20.glUniform1f( location, value ); + public void value1f(float value) { + GLES20.glUniform1f(location, value); } - public void value2f( float v1, float v2 ) { - if (sameFloat(new float[]{v1, v2})) return; - GLES20.glUniform2f( location, v1, v2 ); + public void value2f(float v1, float v2) { + GLES20.glUniform2f(location, v1, v2); } - public void value4f( float v1, float v2, float v3, float v4 ) { - if (sameFloat(new float[]{v1, v2, v3, v4})) return; - GLES20.glUniform4f( location, v1, v2, v3, v4 ); - } - - public void valueM3( float[] value ) { - if (sameFloat(value)) return; - GLES20.glUniformMatrix3fv( location, 1, false, value, 0 ); - } - - public void valueM4( float[] value ) { - if (sameFloat(value)) return; - GLES20.glUniformMatrix4fv( location, 1, false, value, 0 ); - } + public void value4f(float v1, float v2, float v3, float v4) { + if (v1 == prevVal[0] && + v2 == prevVal[1] && + v3 == prevVal[2] && + v4 == prevVal[3]) + return; - private boolean sameFloat(float[] newValue){ - if (Arrays.equals(recentValue, newValue)) - return true; - - recentValue = newValue; - return false; + prevVal[0] = v1; + prevVal[1] = v2; + prevVal[2] = v3; + prevVal[3] = v4; + GLES20.glUniform4f(location, v1, v2, v3, v4); } -} + + public void valueM3(float[] value) { + GLES20.glUniformMatrix3fv(location, 1, false, value, 0); + } + + public void valueM4(float[] value) { + if (Arrays.equals(prevVal, value)) + return; + + System.arraycopy(value, 0, prevVal, 0, 4); + GLES20.glUniformMatrix4fv(location, 1, false, value, 0); + } +} \ No newline at end of file diff --git a/SPD-classes/src/main/java/com/watabou/utils/PointF.java b/SPD-classes/src/main/java/com/watabou/utils/PointF.java index 058113816..b5f3809e5 100644 --- a/SPD-classes/src/main/java/com/watabou/utils/PointF.java +++ b/SPD-classes/src/main/java/com/watabou/utils/PointF.java @@ -151,4 +151,11 @@ public class PointF { public String toString() { return "" + x + ", " + y; } + + @Override + public boolean equals(Object o) { + if (super.equals(o)) + return true; + return o instanceof PointF && (((PointF)o).x == x && ((PointF)o).y == y); + } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 1d06b6c04..656575b41 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -100,6 +100,7 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton; +import com.shatteredpixel.shatteredpixeldungeon.ui.StatusPane; import com.shatteredpixel.shatteredpixeldungeon.utils.BArray; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage; @@ -1406,6 +1407,7 @@ public class Hero extends Char { belongings.specialKeys[Dungeon.depth]--; Level.set( doorCell, Terrain.UNLOCKED_EXIT ); } + StatusPane.needsKeyUpdate = true; Level.set( doorCell, door == Terrain.LOCKED_DOOR ? Terrain.DOOR : Terrain.UNLOCKED_EXIT ); GameScene.updateMap( doorCell ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/keys/Key.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/keys/Key.java index ce1a3e315..8390ba650 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/keys/Key.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/keys/Key.java @@ -24,6 +24,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; +import com.shatteredpixel.shatteredpixeldungeon.ui.StatusPane; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Bundle; @@ -48,6 +49,7 @@ public abstract class Key extends Item { GameScene.pickUpJournal(this); Sample.INSTANCE.play( Assets.SND_ITEM ); hero.spendAndNext( TIME_TO_PICK_UP ); + StatusPane.needsKeyUpdate = true; return true; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java index d81ce6111..e865f8ea6 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java @@ -231,6 +231,8 @@ public class StatusPane extends Component { true ); } + public static boolean needsKeyUpdate = false; + private static class JournalButton extends Button { private Image bg; @@ -253,6 +255,7 @@ public class StatusPane extends Component { icon = new Image( Assets.MENU, 31, 0, 11, 7); add( icon ); + needsKeyUpdate = true; } @Override @@ -270,10 +273,13 @@ public class StatusPane extends Component { @Override public void update() { super.update(); - updateKeyDisplay(); + if (needsKeyUpdate) + updateKeyDisplay(); } public void updateKeyDisplay() { + needsKeyUpdate = false; + boolean foundKeys = false; boolean blackKey = false; boolean specialKey = false;