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 48cb3845e..3b1272a76 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 @@ -102,7 +102,7 @@ public class Hunger extends Buff implements Hero.Doom { if (!Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_FOOD)){ GLog.p(Messages.get(Guidebook.class, "hint")); - GameScene.flashForDocument(Document.GUIDE_FOOD); + GameScene.flashForDocument(Document.ADVENTURERS_GUIDE, Document.GUIDE_FOOD); } } 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 bfc81d42d..199ff44f5 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 @@ -1303,7 +1303,7 @@ public class Hero extends Char { if (m instanceof Snake && Dungeon.level.distance(m.pos, pos) <= 4 && !Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_EXAMINING)){ GLog.p(Messages.get(Guidebook.class, "hint")); - GameScene.flashForDocument(Document.GUIDE_EXAMINING); + GameScene.flashForDocument(Document.ADVENTURERS_GUIDE, Document.GUIDE_EXAMINING); //we set to read here to prevent this message popping up a bunch Document.ADVENTURERS_GUIDE.readPage(Document.GUIDE_EXAMINING); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Snake.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Snake.java index 50243ca83..2d4839cbb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Snake.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Snake.java @@ -63,7 +63,7 @@ public class Snake extends Mob { dodges++; if (dodges >= 2 && !Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_SURPRISE_ATKS)){ GLog.p(Messages.get(Guidebook.class, "hint")); - GameScene.flashForDocument(Document.GUIDE_SURPRISE_ATKS); + GameScene.flashForDocument(Document.ADVENTURERS_GUIDE, Document.GUIDE_SURPRISE_ATKS); dodges = 0; } return super.defenseVerb(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/EquipableItem.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/EquipableItem.java index 409e69a24..817f54361 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/EquipableItem.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/EquipableItem.java @@ -57,7 +57,7 @@ public abstract class EquipableItem extends Item { if (super.doPickUp(hero, pos)){ if (!isIdentified() && !Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_IDING)){ GLog.p(Messages.get(Guidebook.class, "hint")); - GameScene.flashForDocument(Document.GUIDE_IDING); + GameScene.flashForDocument(Document.ADVENTURERS_GUIDE, Document.GUIDE_IDING); } return true; } else { 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 8de50c095..117cc5834 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 @@ -52,7 +52,7 @@ public abstract class DocumentPage extends Item { @Override public final boolean doPickUp(Hero hero, int pos) { GameScene.pickUpJournal(this, pos); - GameScene.flashForDocument(page()); + GameScene.flashForDocument(document(), page()); if (document() == Document.ALCHEMY_GUIDE){ WndJournal.last_index = 1; WndJournal.AlchemyTab.currentPageIdx = document().pageIdx(page()); 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 8b0bed0ec..05e48ed5e 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 @@ -46,7 +46,7 @@ public class Guidebook extends Item { Game.runOnRenderThread(new Callback() { @Override public void call() { - GameScene.show(new WndStory(WndJournal.GuideTab.iconForPage(page), + GameScene.show(new WndStory(Document.ADVENTURERS_GUIDE.pageSprite(page), Document.ADVENTURERS_GUIDE.pageTitle(page), Document.ADVENTURERS_GUIDE.pageBody(page)){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Document.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Document.java index f37461b61..cecc2dc44 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Document.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/journal/Document.java @@ -21,6 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.journal; +import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; @@ -125,10 +126,46 @@ public enum Document { private int pageSprite; private Icons pageIcon; public Image pageSprite(){ - if (pageIcon != null){ - return Icons.get(pageIcon); + return pageSprite(""); + } + + public Image pageSprite(String page){ + if (page.isEmpty() || !isPageFound(page) || this != ADVENTURERS_GUIDE){ + if (pageIcon != null){ + return Icons.get(pageIcon); + } else { + return new ItemSprite(pageSprite); + } } else { - return new ItemSprite(pageSprite); + //special per-page visuals for guidebook + switch (page){ + case Document.GUIDE_INTRO: default: + return new ItemSprite(ItemSpriteSheet.MASTERY); + case "Examining": + return Icons.get(Icons.MAGNIFY); + case "Surprise_Attacks": + return new ItemSprite( ItemSpriteSheet.ASSASSINS_BLADE ); + case "Identifying": + return new ItemSprite( new ScrollOfIdentify() ); + case "Food": + return new ItemSprite( ItemSpriteSheet.PASTY ); + case "Dieing": + return new ItemSprite( ItemSpriteSheet.TOMB ); + case Document.GUIDE_SEARCHING: + return Icons.get(Icons.MAGNIFY); + case "Strength": + return new ItemSprite( ItemSpriteSheet.GREATAXE ); + case "Upgrades": + return new ItemSprite( ItemSpriteSheet.RING_EMERALD ); + case "Looting": + return new ItemSprite( ItemSpriteSheet.CRYSTAL_KEY ); + case "Levelling": + return Icons.get(Icons.TALENT); + case "Positioning": + return new ItemSprite( ItemSpriteSheet.SPIRIT_BOW ); + case "Magic": + return new ItemSprite( ItemSpriteSheet.WAND_FIREBOLT ); + } } } 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 c67b27965..ff7f44ac3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -569,7 +569,7 @@ public class GameScene extends PixelScene { if (Rankings.INSTANCE.totalNumber > 0 && !Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_DIEING)){ GLog.p(Messages.get(Guidebook.class, "hint")); - GameScene.flashForDocument(Document.GUIDE_DIEING); + GameScene.flashForDocument(Document.ADVENTURERS_GUIDE, Document.GUIDE_DIEING); } if (!invVisible) toggleInvPane(); @@ -1022,8 +1022,8 @@ public class GameScene extends PixelScene { } //TODO currently only works with guidebooks - public static void flashForDocument( String page ){ - if (scene != null) scene.menu.flashForPage( page ); + public static void flashForDocument( Document doc, String page ){ + if (scene != null) scene.menu.flashForPage( doc, page ); } public static void updateKeyDisplay(){ @@ -1398,7 +1398,7 @@ public class GameScene extends PixelScene { GameScene.show(new WndInfoMob((Mob) o)); if (o instanceof Snake && !Document.ADVENTURERS_GUIDE.isPageRead(Document.GUIDE_SURPRISE_ATKS)){ GLog.p(Messages.get(Guidebook.class, "hint")); - GameScene.flashForDocument(Document.GUIDE_SURPRISE_ATKS); + GameScene.flashForDocument(Document.ADVENTURERS_GUIDE, Document.GUIDE_SURPRISE_ATKS); } } else if ( o instanceof Heap ){ GameScene.show(new WndInfoItem((Heap)o)); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/MenuPane.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/MenuPane.java index 9436407f9..50a1d5814 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/MenuPane.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/MenuPane.java @@ -44,6 +44,8 @@ import com.watabou.noosa.Image; import com.watabou.noosa.audio.Sample; import com.watabou.noosa.ui.Component; +import javax.print.Doc; + public class MenuPane extends Component { private Image bg; @@ -198,7 +200,8 @@ public class MenuPane extends Component { btnJournal.centerY()); } - public void flashForPage( String page ){ + public void flashForPage( Document doc, String page ){ + btnJournal.flashingDoc = doc; btnJournal.flashingPage = page; } @@ -212,6 +215,7 @@ public class MenuPane extends Component { private Image journalIcon; private KeyDisplay keyIcon; + private Document flashingDoc = null; private String flashingPage = null; public JournalButton() { @@ -306,11 +310,14 @@ public class MenuPane extends Component { time = 0; keyIcon.am = journalIcon.am = 1; if (flashingPage != null){ - if (Document.ADVENTURERS_GUIDE.pageNames().contains(flashingPage)){ - GameScene.show( new WndStory( WndJournal.GuideTab.iconForPage(flashingPage), - Document.ADVENTURERS_GUIDE.pageTitle(flashingPage), - Document.ADVENTURERS_GUIDE.pageBody(flashingPage) )); - Document.ADVENTURERS_GUIDE.readPage(flashingPage); + if (flashingDoc == Document.ALCHEMY_GUIDE){ + WndJournal.last_index = 1; + GameScene.show( new WndJournal() ); + } else if (flashingDoc.pageNames().contains(flashingPage)){ + GameScene.show( new WndStory( flashingDoc.pageSprite(flashingPage), + flashingDoc.pageTitle(flashingPage), + flashingDoc.pageBody(flashingPage) )); + flashingDoc.readPage(flashingPage); } else { GameScene.show( new WndJournal() ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndDocument.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndDocument.java index 6cb246bb5..0b0e54057 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndDocument.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndDocument.java @@ -49,7 +49,7 @@ public class WndDocument extends Window { public boolean onClick(float x, float y) { if (inside( x, y ) && found) { ShatteredPixelDungeon.scene().addToFront( new WndStory( - doc.pageSprite(), + doc.pageSprite(page), doc.pageTitle(page), doc.pageBody(page) )); doc.readPage(page); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java index b6a2e339d..62a4ae42c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java @@ -184,14 +184,14 @@ public class WndJournal extends WndTabbed { for (String page : Document.ADVENTURERS_GUIDE.pageNames()){ boolean found = Document.ADVENTURERS_GUIDE.isPageFound(page); ScrollingListPane.ListItem item = new ScrollingListPane.ListItem( - iconForPage(page), + Document.ADVENTURERS_GUIDE.pageSprite(page), null, found ? Messages.titleCase(Document.ADVENTURERS_GUIDE.pageTitle(page)) : Messages.titleCase(Messages.get( this, "missing" )) ){ @Override public boolean onClick(float x, float y) { if (inside( x, y ) && found) { - GameScene.show( new WndStory( iconForPage(page), + GameScene.show( new WndStory( Document.ADVENTURERS_GUIDE.pageSprite(page), Document.ADVENTURERS_GUIDE.pageTitle(page), Document.ADVENTURERS_GUIDE.pageBody(page) )); Document.ADVENTURERS_GUIDE.readPage(page); @@ -211,41 +211,6 @@ public class WndJournal extends WndTabbed { list.setRect(x, y, width, height); } - //TODO might just want this to be part of the Document class - public static Image iconForPage( String page ){ - if (!Document.ADVENTURERS_GUIDE.isPageFound(page)){ - return new ItemSprite( ItemSpriteSheet.GUIDE_PAGE ); - } - switch (page){ - case Document.GUIDE_INTRO: default: - return new ItemSprite(ItemSpriteSheet.MASTERY); - case "Examining": - return Icons.get(Icons.MAGNIFY); - case "Surprise_Attacks": - return new ItemSprite( ItemSpriteSheet.ASSASSINS_BLADE ); - case "Identifying": - return new ItemSprite( new ScrollOfIdentify() ); - case "Food": - return new ItemSprite( ItemSpriteSheet.PASTY ); - case "Dieing": - return new ItemSprite( ItemSpriteSheet.TOMB ); - case Document.GUIDE_SEARCHING: - return Icons.get(Icons.MAGNIFY); - case "Strength": - return new ItemSprite( ItemSpriteSheet.GREATAXE ); - case "Upgrades": - return new ItemSprite( ItemSpriteSheet.RING_EMERALD ); - case "Looting": - return new ItemSprite( ItemSpriteSheet.CRYSTAL_KEY ); - case "Levelling": - return Icons.get(Icons.TALENT); - case "Positioning": - return new ItemSprite( ItemSpriteSheet.SPIRIT_BOW ); - case "Magic": - return new ItemSprite( ItemSpriteSheet.WAND_FIREBOLT ); - } - } - } public static class AlchemyTab extends Component {