v1.4.0: various code improvements relating to finding doc pages
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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)){
|
||||
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user