public docPage(Document doc, String page ){ super( new ItemSprite( doc.pageSprite(), null), Messages.titleCase(doc.pageTitle(page)), -1); this.doc = doc; this.page = page; found = doc.hasPage(page); if (!found) { icon.hardlight( 0.5f, 0.5f, 0.5f); label.text( Messages.titleCase(Messages.get( WndDocument.class, "missing" ))); label.hardlight( 0x999999 ); } }
public static void store( Bundle bundle ){ Bundle docBundle = new Bundle(); for ( Document doc : values()){ ArrayList<String> pages = new ArrayList<>(); for (String page : doc.pages()){ if (doc.pages.get(page)){ pages.add(page); } } if (!pages.isEmpty()) { docBundle.put(doc.name(), pages.toArray(new String[0])); } } bundle.put( DOCUMENTS, docBundle ); }
public String pageBody( int pageIdx ){ return pageBody( pages.keySet().toArray(new String[0])[pageIdx] ); }
public static void restore( Bundle bundle ){ if (!bundle.contains( DOCUMENTS )){ return; } Bundle docBundle = bundle.getBundle( DOCUMENTS ); for ( Document doc : values()){ if (docBundle.contains(doc.name())){ List<String> pages = Arrays.asList(docBundle.getStringArray(doc.name())); for (String page : pages){ if (doc.pages.containsKey(page)) { doc.pages.put(page, true); } } } } }
@SuppressWarnings("unchecked") @Override public void restoreFromBundle( Bundle bundle ) { pos = bundle.getInt( POS ); seen = bundle.getBoolean( SEEN ); type = Type.valueOf( bundle.getString( TYPE ) ); items = new LinkedList<Item>( (Collection<Item>) ((Collection<?>) bundle.getCollection( ITEMS )) ); items.removeAll(Collections.singleton(null)); //remove any document pages that either don't exist anymore or that the player already has for (Item item : items.toArray(new Item[0])){ if (item instanceof DocumentPage && ( !((DocumentPage) item).document().pages().contains(((DocumentPage) item).page()) || ((DocumentPage) item).document().hasPage(((DocumentPage) item).page()))){ items.remove(item); } } haunted = bundle.getBoolean( HAUNTED ); }
public GuideItem( String page ){ super( new ItemSprite( ItemSpriteSheet.GUIDE_PAGE, null), Messages.titleCase(Document.ADVENTURERS_GUIDE.pageTitle(page)), -1); this.page = page; found = Document.ADVENTURERS_GUIDE.hasPage(page); if (!found) { icon.hardlight( 0.5f, 0.5f, 0.5f); label.text( Messages.titleCase(Messages.get( this, "missing" ))); label.hardlight( 0x999999 ); } }
public String pageTitle( int pageIdx ){ return pageTitle( pages.keySet().toArray(new String[0])[pageIdx] ); }
public String pageTitle( String page ){ return Messages.get( this, name() + "." + page + ".title"); }
public boolean hasPage( int pageIdx ){ return hasPage( pages.keySet().toArray(new String[0])[pageIdx] ); }
@Override public final boolean doPickUp(Hero hero) { GameScene.pickUpJournal(this, hero.pos); GameScene.flashJournal(); if (document() == Document.ALCHEMY_GUIDE){ WndJournal.last_index = 1; } else { WndJournal.last_index = 0; } document().addPage(page); Sample.INSTANCE.play( Assets.SND_ITEM ); hero.spendAndNext( TIME_TO_PICK_UP ); return true; }
public static void saveGlobal(){ if (!saveNeeded){ return; } Bundle bundle = new Bundle(); Catalog.store(bundle); Document.store(bundle); try { FileUtils.bundleToFile( JOURNAL_FILE, bundle ); saveNeeded = false; } catch (IOException e) { ShatteredPixelDungeon.reportException(e); } }
public static void loadGlobal(){ if (loaded){ return; } Bundle bundle; try { bundle = FileUtils.bundleFromFile( JOURNAL_FILE ); } catch (IOException e){ bundle = new Bundle(); } Catalog.restore( bundle ); Document.restore( bundle ); loaded = true; }
@SuppressWarnings("unchecked") @Override public void restoreFromBundle( Bundle bundle ) { pos = bundle.getInt( POS ); seen = bundle.getBoolean( SEEN ); type = Type.valueOf( bundle.getString( TYPE ) ); items = new LinkedList( bundle.getCollection( ITEMS ) ); items.removeAll(Collections.singleton(null)); //remove any document pages that either don't exist anymore or that the player already has for (Item item : items.toArray(new Item[0])){ if (item instanceof DocumentPage && ( !((DocumentPage) item).document().pages().contains(((DocumentPage) item).page()) || ((DocumentPage) item).document().hasPage(((DocumentPage) item).page()))){ items.remove(item); } } haunted = bundle.getBoolean( HAUNTED ); }
public GuideItem( String page ){ super( new ItemSprite( ItemSpriteSheet.GUIDE_PAGE, null), Messages.titleCase(Document.ADVENTURERS_GUIDE.pageTitle(page)), -1); this.page = page; found = Document.ADVENTURERS_GUIDE.hasPage(page); if (!found) { icon.hardlight( 0.5f, 0.5f, 0.5f); label.text( Messages.titleCase(Messages.get( this, "missing" ))); label.hardlight( 0x999999 ); } }
public static void restore( Bundle bundle ){ if (!bundle.contains( DOCUMENTS )){ return; } Bundle docBundle = bundle.getBundle( DOCUMENTS ); for ( Document doc : values()){ if (docBundle.contains(doc.name())){ List<String> pages = Arrays.asList(docBundle.getStringArray(doc.name())); for (String page : pages){ if (doc.pages.containsKey(page)) { doc.pages.put(page, true); } } } } }
public String pageTitle( int pageIdx ){ return pageTitle( pages.keySet().toArray(new String[0])[pageIdx] ); }