From 4890b4f19dc8b32113c2e07c25bf3dfc93c0e218 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 1 Aug 2017 19:59:42 -0400 Subject: [PATCH] v0.6.1: picking up document pages now makes the journal button blink --- .../items/journal/DocumentPage.java | 3 +++ .../shatteredpixeldungeon/items/keys/Key.java | 2 ++ .../shatteredpixeldungeon/scenes/GameScene.java | 4 ++++ .../shatteredpixeldungeon/ui/StatusPane.java | 17 +++++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/journal/DocumentPage.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/journal/DocumentPage.java index fd666f003..b7e1a7c6e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/journal/DocumentPage.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/journal/DocumentPage.java @@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.journal.Document; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Bundle; @@ -51,6 +52,8 @@ public abstract class DocumentPage extends Item { @Override public final boolean doPickUp(Hero hero) { GameScene.pickUpJournal(this); + GameScene.flashJournal(); + WndJournal.last_index = 0; document().addPage(page); Sample.INSTANCE.play( Assets.SND_ITEM ); hero.spendAndNext( TIME_TO_PICK_UP ); 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 1053416ae..028e9a430 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 @@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.journal.Notes; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.ui.StatusPane; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Bundle; @@ -49,6 +50,7 @@ public abstract class Key extends Item { @Override public boolean doPickUp(Hero hero) { GameScene.pickUpJournal(this); + WndJournal.last_index = 1; Notes.add(this); Sample.INSTANCE.play( Assets.SND_ITEM ); hero.spendAndNext( TIME_TO_PICK_UP ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index b15ae6aa4..40c743291 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -727,6 +727,10 @@ public class GameScene extends PixelScene { public static void pickUpJournal( Item item ) { if (scene != null) scene.pane.pickup( item ); } + + public static void flashJournal(){ + if (scene != null) scene.pane.flash(); + } public static void resetMap() { if (scene != null) { 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 5cec478f6..131d9f74a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java @@ -227,6 +227,10 @@ public class StatusPane extends Component { btnJournal.icon.y + btnJournal.icon.height()/2f, true ); } + + public void flash(){ + btnJournal.flashing = true; + } public static boolean needsKeyUpdate = false; @@ -235,6 +239,8 @@ public class StatusPane extends Component { private Image bg; //used to display key state to the player private Image icon; + + private boolean flashing; public JournalButton() { super(); @@ -267,11 +273,20 @@ public class StatusPane extends Component { PixelScene.align(icon); } + private float time; + @Override public void update() { super.update(); if (needsKeyUpdate) updateKeyDisplay(); + + if (flashing){ + icon.am = (float)Math.abs(Math.cos( 3 * (time += Game.elapsed) )); + if (time >= 0.333f*Math.PI) { + time = 0; + } + } } public void updateKeyDisplay() { @@ -327,6 +342,8 @@ public class StatusPane extends Component { @Override protected void onClick() { + flashing = false; + time = 0; GameScene.show( new WndJournal() ); }