v0.9.4: document pages now open directly from the flashing prompt
This commit is contained in:
parent
15862f98e8
commit
8c9012e085
|
@ -52,9 +52,10 @@ public abstract class DocumentPage extends Item {
|
|||
@Override
|
||||
public final boolean doPickUp(Hero hero) {
|
||||
GameScene.pickUpJournal(this, hero.pos);
|
||||
GameScene.flashJournal();
|
||||
GameScene.flashForDocument(page());
|
||||
if (document() == Document.ALCHEMY_GUIDE){
|
||||
WndJournal.last_index = 1;
|
||||
WndJournal.AlchemyTab.currentPageIdx = document().pageIdx(page());
|
||||
} else {
|
||||
WndJournal.last_index = 0;
|
||||
}
|
||||
|
|
|
@ -52,13 +52,8 @@ public enum Document {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean readPage( String page ) {
|
||||
if (pagesStates.containsKey(page) && pagesStates.get(page) == FOUND){
|
||||
pagesStates.put(page, READ);
|
||||
Journal.saveNeeded = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
public boolean findPage( int pageIdx ) {
|
||||
return findPage( pagesStates.keySet().toArray(new String[0])[pageIdx] );
|
||||
}
|
||||
|
||||
public boolean pageFound( String page ){
|
||||
|
@ -69,6 +64,19 @@ public enum Document {
|
|||
return pageFound( pagesStates.keySet().toArray(new String[0])[pageIdx] );
|
||||
}
|
||||
|
||||
public boolean readPage( String page ) {
|
||||
if (pagesStates.containsKey(page) && pagesStates.get(page) == FOUND){
|
||||
pagesStates.put(page, READ);
|
||||
Journal.saveNeeded = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean readPage( int pageIdx ) {
|
||||
return readPage( pagesStates.keySet().toArray(new String[0])[pageIdx] );
|
||||
}
|
||||
|
||||
public boolean pageRead( String page ){
|
||||
return pagesStates.containsKey(page) && pagesStates.get(page) == READ;
|
||||
}
|
||||
|
@ -77,14 +85,21 @@ public enum Document {
|
|||
return pageRead( pagesStates.keySet().toArray(new String[0])[pageIdx] );
|
||||
}
|
||||
|
||||
public void setPageState( String page, int state ){
|
||||
if (pagesStates.containsKey(page)) pagesStates.put(page, state);
|
||||
}
|
||||
|
||||
public Collection<String> pageNames(){
|
||||
return pagesStates.keySet();
|
||||
}
|
||||
|
||||
public int pageIdx(String name){
|
||||
int i = 0;
|
||||
for( String page : pagesStates.keySet()){
|
||||
if (page.equals(name)){
|
||||
return i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int pageSprite;
|
||||
public int pageSprite(){
|
||||
return pageSprite;
|
||||
|
|
|
@ -918,8 +918,9 @@ public class GameScene extends PixelScene {
|
|||
if (scene != null) scene.pane.pickup( item, pos );
|
||||
}
|
||||
|
||||
public static void flashJournal(){
|
||||
if (scene != null) scene.pane.flash();
|
||||
//TODO currently only works with guidebooks
|
||||
public static void flashForDocument( String page ){
|
||||
if (scene != null) scene.pane.flashForPage( page );
|
||||
}
|
||||
|
||||
public static void updateKeyDisplay(){
|
||||
|
|
|
@ -27,12 +27,14 @@ import com.shatteredpixel.shatteredpixeldungeon.SPDAction;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndGame;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndHero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory;
|
||||
import com.watabou.input.GameAction;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Camera;
|
||||
|
@ -265,8 +267,8 @@ public class StatusPane extends Component {
|
|||
btnJournal.journalIcon.y + btnJournal.journalIcon.height()/2f);
|
||||
}
|
||||
|
||||
public void flash(){
|
||||
btnJournal.flashing = true;
|
||||
public void flashForPage( String page ){
|
||||
btnJournal.flashingPage = page;
|
||||
}
|
||||
|
||||
public void updateKeys(){
|
||||
|
@ -279,7 +281,7 @@ public class StatusPane extends Component {
|
|||
private Image journalIcon;
|
||||
private KeyDisplay keyIcon;
|
||||
|
||||
private boolean flashing;
|
||||
private String flashingPage = Document.GUIDE_INTRO_PAGE;
|
||||
|
||||
public JournalButton() {
|
||||
super();
|
||||
|
@ -327,15 +329,16 @@ public class StatusPane extends Component {
|
|||
}
|
||||
|
||||
private float time;
|
||||
private static final float FLASH_RATE = (float)(Math.PI*1.5f); //1.5 blinks per second
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (flashing){
|
||||
journalIcon.am = (float)Math.abs(Math.cos( 3 * (time += Game.elapsed) ));
|
||||
if (flashingPage != null){
|
||||
journalIcon.am = (float)Math.abs(Math.cos( FLASH_RATE * (time += Game.elapsed) ));
|
||||
keyIcon.am = journalIcon.am;
|
||||
if (time >= 0.333f*Math.PI) {
|
||||
if (time >= Math.PI/FLASH_RATE) {
|
||||
time = 0;
|
||||
}
|
||||
}
|
||||
|
@ -369,10 +372,20 @@ public class StatusPane extends Component {
|
|||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
flashing = false;
|
||||
time = 0;
|
||||
keyIcon.am = journalIcon.am = 1;
|
||||
GameScene.show( new WndJournal() );
|
||||
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) ));
|
||||
} else {
|
||||
GameScene.show( new WndJournal() );
|
||||
}
|
||||
flashingPage = null;
|
||||
} else {
|
||||
GameScene.show( new WndJournal() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -200,7 +200,7 @@ public class WndJournal extends WndTabbed {
|
|||
}
|
||||
}
|
||||
|
||||
private static class GuideTab extends Component {
|
||||
public static class GuideTab extends Component {
|
||||
|
||||
private ScrollPane list;
|
||||
private ArrayList<GuideItem> pages = new ArrayList<>();
|
||||
|
@ -283,41 +283,42 @@ public class WndJournal extends WndTabbed {
|
|||
GameScene.show( new WndStory( iconForPage(page),
|
||||
Document.ADVENTURERS_GUIDE.pageTitle(page),
|
||||
Document.ADVENTURERS_GUIDE.pageBody(page) ));
|
||||
Document.ALCHEMY_GUIDE.readPage(page);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO might just want this to be part of the Document class
|
||||
private static Image iconForPage( String page ){
|
||||
if (!Document.ADVENTURERS_GUIDE.pageFound(page)){
|
||||
return new ItemSprite( ItemSpriteSheet.GUIDE_PAGE );
|
||||
}
|
||||
switch (page){
|
||||
case Document.GUIDE_INTRO_PAGE: default:
|
||||
return new ItemSprite(ItemSpriteSheet.MASTERY);
|
||||
case "Identifying":
|
||||
return new ItemSprite( ItemSpriteSheet.SCROLL_ISAZ );
|
||||
case Document.GUIDE_SEARCH_PAGE:
|
||||
return new ItemSprite( ItemSpriteSheet.LOCKED_CHEST );
|
||||
case "Strength":
|
||||
return new ItemSprite( ItemSpriteSheet.ARMOR_SCALE );
|
||||
case "Food":
|
||||
return new ItemSprite( ItemSpriteSheet.PASTY );
|
||||
case "Levelling":
|
||||
return new ItemSprite( ItemSpriteSheet.POTION_MAGENTA );
|
||||
case "Surprise_Attacks":
|
||||
return new ItemSprite( ItemSpriteSheet.ASSASSINS_BLADE );
|
||||
case "Dieing":
|
||||
return new ItemSprite( ItemSpriteSheet.ANKH );
|
||||
case "Looting":
|
||||
return new ItemSprite( ItemSpriteSheet.CRYSTAL_KEY );
|
||||
case "Magic":
|
||||
return new ItemSprite( ItemSpriteSheet.WAND_LIGHTNING );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO might just want this to be part of the Document class
|
||||
public static Image iconForPage( String page ){
|
||||
if (!Document.ADVENTURERS_GUIDE.pageFound(page)){
|
||||
return new ItemSprite( ItemSpriteSheet.GUIDE_PAGE );
|
||||
}
|
||||
switch (page){
|
||||
case Document.GUIDE_INTRO_PAGE: default:
|
||||
return new ItemSprite(ItemSpriteSheet.MASTERY);
|
||||
case "Identifying":
|
||||
return new ItemSprite( ItemSpriteSheet.SCROLL_ISAZ );
|
||||
case Document.GUIDE_SEARCH_PAGE:
|
||||
return new ItemSprite( ItemSpriteSheet.LOCKED_CHEST );
|
||||
case "Strength":
|
||||
return new ItemSprite( ItemSpriteSheet.ARMOR_SCALE );
|
||||
case "Food":
|
||||
return new ItemSprite( ItemSpriteSheet.PASTY );
|
||||
case "Levelling":
|
||||
return new ItemSprite( ItemSpriteSheet.POTION_MAGENTA );
|
||||
case "Surprise_Attacks":
|
||||
return new ItemSprite( ItemSpriteSheet.ASSASSINS_BLADE );
|
||||
case "Dieing":
|
||||
return new ItemSprite( ItemSpriteSheet.ANKH );
|
||||
case "Looting":
|
||||
return new ItemSprite( ItemSpriteSheet.CRYSTAL_KEY );
|
||||
case "Magic":
|
||||
return new ItemSprite( ItemSpriteSheet.WAND_LIGHTNING );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -329,7 +330,7 @@ public class WndJournal extends WndTabbed {
|
|||
|
||||
private static final int[] spriteIndexes = {10, 12, 7, 8, 3, 9, 11, 13, 14, 15};
|
||||
|
||||
private static int currentPageIdx = -1;
|
||||
public static int currentPageIdx = -1;
|
||||
|
||||
private IconTitle title;
|
||||
private RenderedTextBlock body;
|
||||
|
@ -437,6 +438,8 @@ public class WndJournal extends WndTabbed {
|
|||
body.setPos(0, title.bottom());
|
||||
content.add(body);
|
||||
|
||||
Document.ALCHEMY_GUIDE.readPage(currentPageIdx);
|
||||
|
||||
ArrayList<QuickRecipe> toAdd = QuickRecipe.getRecipes(currentPageIdx);
|
||||
|
||||
float left;
|
||||
|
|
Loading…
Reference in New Issue
Block a user