From b9b02fdef823f51f78b5e6462a2b5ae8561cb042 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sat, 10 Sep 2022 12:37:33 -0400 Subject: [PATCH] v1.4.0: made various improvements to the short tutorial --- .../assets/messages/scenes/scenes.properties | 4 +- .../actors/buffs/Hunger.java | 2 + .../actors/hero/Hero.java | 3 +- .../items/journal/Guidebook.java | 5 ++ .../scenes/GameScene.java | 59 ++++++++++--------- .../shatteredpixeldungeon/ui/ItemSlot.java | 8 +++ .../ui/QuickSlotButton.java | 4 ++ .../shatteredpixeldungeon/ui/StatusPane.java | 17 ++++++ .../shatteredpixeldungeon/ui/Toolbar.java | 34 ++++++++++- .../windows/WndGame.java | 25 ++++---- 10 files changed, 117 insertions(+), 44 deletions(-) diff --git a/core/src/main/assets/messages/scenes/scenes.properties b/core/src/main/assets/messages/scenes/scenes.properties index 267d80325..97d1310ec 100644 --- a/core/src/main/assets/messages/scenes/scenes.properties +++ b/core/src/main/assets/messages/scenes/scenes.properties @@ -52,8 +52,8 @@ scenes.gamescene.tutorial_move_mobile=Tap a location to to move and interact. scenes.gamescene.tutorial_move_desktop=Use the mouse or arrow keys to move and interact. scenes.gamescene.tutorial_move_controller=Select a location or use the left stick to move or interact. scenes.gamescene.tutorial_guidebook=Select the blinking journal button to read the book you just picked up. -scenes.gamescene.tutorial_ui_mobile=Hero info is on the top left, and your inventory and game actions are below, good luck! -scenes.gamescene.tutorial_ui_desktop=Hero info is below, and your inventory and game actions are to the right, good luck! +scenes.gamescene.tutorial_ui_mobile=Hero info is on the top left. Inventory, quickslots, and game actions are below. Good luck! +scenes.gamescene.tutorial_ui_desktop=Hero info is below. Inventory, quickslots, and game actions are to the right. Good luck! scenes.heroselectscene.title=Choose Your Hero scenes.heroselectscene.options=Game Options diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java index 3b1272a76..accf44325 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Hunger.java @@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty; @@ -67,6 +68,7 @@ public class Hunger extends Buff implements Hero.Doom { if (Dungeon.level.locked || target.buff(WellFed.class) != null + || SPDSettings.intro() || target.buff(ScrollOfChallenge.ChallengeArena.class) != null){ spend(STEP); return true; 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 a99744f58..918feddeb 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 @@ -871,7 +871,8 @@ public class Hero extends Char { if (item instanceof Dewdrop || item instanceof TimekeepersHourglass.sandBag || item instanceof DriedRose.Petal - || item instanceof Key) { + || item instanceof Key + || item instanceof Guidebook) { //Do Nothing } else { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/journal/Guidebook.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/journal/Guidebook.java index 728a1a270..ae5d1299c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/journal/Guidebook.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/journal/Guidebook.java @@ -25,9 +25,11 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.journal.Document; +import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.ui.GameLog; +import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.noosa.audio.Sample; public class Guidebook extends Item { @@ -39,6 +41,9 @@ public class Guidebook extends Item { @Override public final boolean doPickUp(Hero hero, int pos) { GameScene.pickUpJournal(this, pos); + //we do this here so it appears before the tutorial text + GLog.i( Messages.capitalize(Messages.get(Hero.class, "you_now_have", name())) ); + GLog.p(Messages.get(GameScene.class, "tutorial_guidebook")); GameScene.flashForDocument(Document.ADVENTURERS_GUIDE, Document.GUIDE_INTRO); Sample.INSTANCE.play( Assets.Sounds.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 3c726b7c5..cce30a2f2 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -129,6 +129,7 @@ import com.watabou.noosa.Visual; import com.watabou.noosa.audio.Music; import com.watabou.noosa.audio.Sample; import com.watabou.noosa.particles.Emitter; +import com.watabou.noosa.tweeners.Tweener; import com.watabou.utils.Callback; import com.watabou.utils.DeviceCompat; import com.watabou.utils.GameMath; @@ -482,21 +483,6 @@ public class GameScene extends PixelScene { && (InterlevelScene.mode == InterlevelScene.Mode.DESCEND || InterlevelScene.mode == InterlevelScene.Mode.FALL)) { GLog.h(Messages.get(this, "descend"), Dungeon.depth); Sample.INSTANCE.play(Assets.Sounds.DESCEND); - - //Tutorial - if (SPDSettings.intro()){ - - if (ControllerHandler.isControllerConnected()){ - GLog.p(Messages.get(GameScene.class, "tutorial_move_controller")); - } else if (SPDSettings.interfaceSize() == 0){ - GLog.p(Messages.get(GameScene.class, "tutorial_move_mobile")); - } else { - GLog.p(Messages.get(GameScene.class, "tutorial_move_desktop")); - } - toolbar.visible = false; - status.visible = false; - if (inventory != null) inventory.visible = false; - } for (Char ch : Actor.chars()){ if (ch instanceof DriedRose.GhostHero){ @@ -585,6 +571,21 @@ public class GameScene extends PixelScene { } + //Tutorial + if (SPDSettings.intro()){ + + if (ControllerHandler.isControllerConnected()){ + GLog.p(Messages.get(GameScene.class, "tutorial_move_controller")); + } else if (SPDSettings.interfaceSize() == 0){ + GLog.p(Messages.get(GameScene.class, "tutorial_move_mobile")); + } else { + GLog.p(Messages.get(GameScene.class, "tutorial_move_desktop")); + } + toolbar.visible = false; + status.visible = false; + if (inventory != null) inventory.visible = false; + } + if (Rankings.INSTANCE.totalNumber > 0 && !Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_DIEING)){ GLog.p(Messages.get(Guidebook.class, "hint")); GameScene.flashForDocument(Document.ADVENTURERS_GUIDE, Document.GUIDE_DIEING); @@ -1046,24 +1047,27 @@ public class GameScene extends PixelScene { public static void flashForDocument( Document doc, String page ){ if (scene != null) { scene.menu.flashForPage( doc, page ); - //we use a callback here so that regular pickup text appears first - if (SPDSettings.intro()) { - Game.runOnRenderThread(new Callback() { - @Override - public void call() { - GLog.p(Messages.get(GameScene.class, "tutorial_guidebook")); - } - }); - } } } public static void endIntro(){ if (scene != null){ SPDSettings.intro(false); - //TODO this is very sudden, should have UI and doors fade in - scene.status.visible = true; - scene.toolbar.visible = true; + scene.add(new Tweener(scene, 2f){ + @Override + protected void updateValues(float progress) { + if (progress <= 0.5f) { + scene.status.alpha(2*progress); + scene.status.visible = true; + scene.toolbar.visible = false; + } else { + scene.status.alpha(1f); + scene.status.visible = true; + scene.toolbar.alpha((progress - 0.5f)*2); + scene.toolbar.visible = true; + } + } + }); if (scene.inventory != null) scene.inventory.visible = true; GameLog.wipe(); if (SPDSettings.interfaceSize() == 0){ @@ -1076,6 +1080,7 @@ public class GameScene extends PixelScene { for (int i = 0; i < Dungeon.level.length(); i++){ if (Dungeon.level.map[i] == Terrain.SECRET_DOOR){ Dungeon.level.discover(i); + discoverTile(i, Terrain.SECRET_DOOR); } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java index daf0a9561..dd21b2fb0 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java @@ -166,6 +166,14 @@ public class ItemSlot extends Button { } + public void alpha( float value ){ + if (sprite != null) sprite.alpha(value); + if (extra != null) extra.alpha(value); + if (status != null) status.alpha(value); + if (itemIcon != null) itemIcon.alpha(value); + if (level != null) level.alpha(value); + } + public void clear(){ item(null); enable(true); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java index da397facd..8846bce8c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/QuickSlotButton.java @@ -166,6 +166,10 @@ public class QuickSlotButton extends Button { PixelScene.align(crossB); } + public void alpha( float value ){ + slot.alpha(value); + } + @Override public void update() { super.update(); 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 80c548bbd..c2a44cf99 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StatusPane.java @@ -44,6 +44,7 @@ import com.watabou.noosa.NinePatch; import com.watabou.noosa.particles.Emitter; import com.watabou.noosa.ui.Component; import com.watabou.utils.ColorMath; +import com.watabou.utils.GameMath; import java.util.ArrayList; @@ -318,6 +319,22 @@ public class StatusPane extends Component { counter.setSweep((1f - Actor.now()%1f)%1f); } + public void alpha( float value ){ + value = GameMath.gate(0, value, 1f); + bg.alpha(value); + avatar.alpha(value); + rawShielding.alpha(0.5f*value); + shieldedHP.alpha(value); + hp.alpha(value); + hpText.alpha(0.6f*value); + exp.alpha(value); + if (expText != null) expText.alpha(0.6f*value); + level.alpha(value); + compass.alpha(value); + busy.alpha(value); + counter.alpha(value); + } + public void showStarParticles(){ Emitter emitter = (Emitter)recycle( Emitter.class ); emitter.revive(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java index cfecb39de..1203d9efc 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java @@ -638,7 +638,17 @@ public class Toolbar extends Component { btnInventory.enable(true); } } - + + public void alpha( float value ){ + btnWait.alpha( value ); + btnSearch.alpha( value ); + btnInventory.alpha( value ); + for (QuickslotTool tool : btnQuick){ + tool.alpha(value); + } + btnSwap.alpha( value ); + } + public void pickup( Item item, int cell ) { pickedUp.reset( item, cell, @@ -695,7 +705,11 @@ public class Toolbar extends Component { base.x = x; base.y = y; } - + + public void alpha( float value ){ + base.alpha(value); + } + @Override protected void onPointerDown() { base.brightness( 1.4f ); @@ -747,7 +761,13 @@ public class Toolbar extends Component { slot.setRect( x, y, width, height ); slot.slotMargins(borderLeft, 2, borderRight, 2); } - + + @Override + public void alpha(float value) { + super.alpha(value); + slot.alpha(value); + } + @Override public void enable( boolean value ) { super.enable( value && visible ); @@ -849,6 +869,14 @@ public class Toolbar extends Component { updateVisuals(); } + @Override + public void alpha(float value) { + super.alpha(value); + for (Image im : icons){ + if (im != null) im.alpha(value); + } + } + @Override public void enable(boolean value) { super.enable(value); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java index 51d19d243..732d0fe37 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndGame.java @@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress; +import com.shatteredpixel.shatteredpixeldungeon.SPDSettings; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; @@ -110,18 +111,20 @@ public class WndGame extends Window { } // Main menu - addButton(curBtn = new RedButton( Messages.get(this, "menu") ) { - @Override - protected void onClick() { - try { - Dungeon.saveAll(); - } catch (IOException e) { - ShatteredPixelDungeon.reportException(e); + if (!SPDSettings.intro()) { + addButton(curBtn = new RedButton(Messages.get(this, "menu")) { + @Override + protected void onClick() { + try { + Dungeon.saveAll(); + } catch (IOException e) { + ShatteredPixelDungeon.reportException(e); + } + Game.switchScene(TitleScene.class); } - Game.switchScene(TitleScene.class); - } - } ); - curBtn.icon(Icons.get(Icons.DISPLAY)); + }); + curBtn.icon(Icons.get(Icons.DISPLAY)); + } resize( WIDTH, pos ); }