From ee260a2559b738d85ff8eedd4fa0e388c7569717 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 7 Jun 2020 17:34:50 -0400 Subject: [PATCH] v0.8.1: adjusted logic and added alpha settings for buttons --- .../shatteredpixeldungeon/ui/ExitButton.java | 34 ++----------------- .../ui/StyledButton.java | 6 ++++ 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ExitButton.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ExitButton.java index b54f12db6..a99811fcc 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ExitButton.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ExitButton.java @@ -30,45 +30,15 @@ import com.watabou.noosa.Image; import com.watabou.noosa.audio.Sample; import com.watabou.noosa.ui.Button; -public class ExitButton extends Button { - - protected Image image; +public class ExitButton extends IconButton { public ExitButton() { - super(); + super(Icons.EXIT.get()); width = 20; height = 20; } - @Override - protected void createChildren() { - super.createChildren(); - - image = Icons.EXIT.get(); - add( image ); - } - - @Override - protected void layout() { - super.layout(); - - image.x = x + (width - image.width)/2f; - image.y = y + (height - image.height)/2f; - PixelScene.align(image); - } - - @Override - protected void onPointerDown() { - image.brightness( 1.5f ); - Sample.INSTANCE.play( Assets.Sounds.CLICK ); - } - - @Override - protected void onPointerUp() { - image.resetColor(); - } - @Override protected void onClick() { if (Game.scene() instanceof TitleScene) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StyledButton.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StyledButton.java index 33ddd3902..d19cd3693 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StyledButton.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StyledButton.java @@ -123,6 +123,12 @@ public class StyledButton extends Button { public Image icon(){ return icon; } + + public void alpha(float value){ + if (icon != null) icon.alpha(value); + if (bg != null) bg.alpha(value); + if (text != null) text.alpha(value); + } public float reqWidth() { float reqWidth = 0;