v0.6.1: renamed journal class to notes

This commit is contained in:
Evan Debenham 2017-07-09 14:42:30 -04:00
parent 3c5a8c9ca4
commit 1a22c5334e
14 changed files with 176 additions and 51 deletions

View File

@ -160,7 +160,7 @@ public class Dungeon {
Random.seed();
Statistics.reset();
Journal.reset();
Notes.reset();
quickslot.reset();
QuickSlotButton.reset();
@ -482,7 +482,7 @@ public class Dungeon {
SpecialRoom.storeRoomsInBundle( bundle );
Statistics.storeInBundle( bundle );
Journal.storeInBundle( bundle );
Notes.storeInBundle( bundle );
Generator.storeInBundle( bundle );
Scroll.save( bundle );
@ -608,7 +608,7 @@ public class Dungeon {
depth = bundle.getInt( DEPTH );
Statistics.restoreFromBundle( bundle );
Journal.restoreFromBundle( bundle );
Notes.restoreFromBundle( bundle );
Generator.restoreFromBundle( bundle );
droppedItems = new SparseArray<ArrayList<Item>>();

View File

@ -0,0 +1,125 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2017 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.utils.Bundlable;
import com.watabou.utils.Bundle;
import java.util.ArrayList;
public class Notes {
public enum Feature {
WELL_OF_HEALTH,
WELL_OF_AWARENESS,
WELL_OF_TRANSMUTATION,
ALCHEMY,
GARDEN,
STATUE,
GHOST,
WANDMAKER,
TROLL,
IMP;
public String desc() {
return Messages.get(this, name());
}
};
public static class Record implements Comparable<Record>, Bundlable {
private static final String FEATURE = "feature";
private static final String DEPTH = "depth";
public Feature feature;
public int depth;
public Record() {
}
public Record( Feature feature, int depth ) {
this.feature = feature;
this.depth = depth;
}
@Override
public int compareTo( Record another ) {
return another.depth - depth;
}
@Override
public void restoreFromBundle( Bundle bundle ) {
feature = Feature.valueOf( bundle.getString( FEATURE ) );
depth = bundle.getInt( DEPTH );
}
@Override
public void storeInBundle( Bundle bundle ) {
bundle.put( FEATURE, feature.toString() );
bundle.put( DEPTH, depth );
}
}
public static ArrayList<Record> records;
public static void reset() {
records = new ArrayList<Notes.Record>();
}
private static final String JOURNAL = "journal";
public static void storeInBundle( Bundle bundle ) {
bundle.put( JOURNAL, records );
}
public static void restoreFromBundle( Bundle bundle ) {
records = new ArrayList<Record>();
for (Bundlable rec : bundle.getCollection( JOURNAL ) ) {
records.add( (Record) rec );
}
}
public static void add( Feature feature ) {
int size = records.size();
for (int i=0; i < size; i++) {
Record rec = records.get( i );
if (rec.feature == feature && rec.depth == Dungeon.depth) {
return;
}
}
records.add( new Record( feature, Dungeon.depth ) );
}
public static void remove( Feature feature ) {
int size = records.size();
for (int i=0; i < size; i++) {
Record rec = records.get( i );
if (rec.feature == feature && rec.depth == Dungeon.depth) {
records.remove( i );
return;
}
}
}
}

View File

@ -22,7 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Journal;
import com.shatteredpixel.shatteredpixeldungeon.Notes;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
@ -53,7 +53,7 @@ public class Alchemy extends Blob {
area.union(pos%Dungeon.level.width(), pos/Dungeon.level.width());
if (Dungeon.visible[pos]) {
Journal.add( Journal.Feature.ALCHEMY );
Notes.add( Notes.Feature.ALCHEMY );
}
}

View File

@ -22,7 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Journal;
import com.shatteredpixel.shatteredpixeldungeon.Notes;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Shadows;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
@ -69,7 +69,7 @@ public class Foliage extends Blob {
}
if (visible) {
Journal.add( Journal.Feature.GARDEN );
Notes.add( Notes.Feature.GARDEN );
}
}

View File

@ -24,9 +24,8 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.Journal;
import com.shatteredpixel.shatteredpixeldungeon.Journal.Feature;
import com.shatteredpixel.shatteredpixeldungeon.Notes;
import com.shatteredpixel.shatteredpixeldungeon.Notes.Feature;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Awareness;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
@ -37,6 +36,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.audio.Sample;
@ -70,7 +70,7 @@ public class WaterOfAwareness extends WellWater {
GLog.p( Messages.get(this, "procced") );
Journal.remove( Feature.WELL_OF_AWARENESS );
Notes.remove( Feature.WELL_OF_AWARENESS );
return true;
}
@ -85,7 +85,7 @@ public class WaterOfAwareness extends WellWater {
emitter.parent.add( new Identification( DungeonTilemap.tileCenterToWorld( pos ) ) );
Journal.remove( Feature.WELL_OF_AWARENESS );
Notes.remove( Feature.WELL_OF_AWARENESS );
return item;
}

View File

@ -23,8 +23,8 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Journal;
import com.shatteredpixel.shatteredpixeldungeon.Journal.Feature;
import com.shatteredpixel.shatteredpixeldungeon.Notes;
import com.shatteredpixel.shatteredpixeldungeon.Notes.Feature;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Hunger;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
@ -55,7 +55,7 @@ public class WaterOfHealth extends WellWater {
GLog.p( Messages.get(this, "procced") );
Journal.remove( Feature.WELL_OF_HEALTH );
Notes.remove( Feature.WELL_OF_HEALTH );
return true;
}
@ -64,7 +64,7 @@ public class WaterOfHealth extends WellWater {
protected Item affectItem( Item item ) {
if (item instanceof DewVial && !((DewVial)item).isFull()) {
((DewVial)item).fill();
Journal.remove( Feature.WELL_OF_HEALTH );
Notes.remove( Feature.WELL_OF_HEALTH );
return item;
}

View File

@ -21,8 +21,8 @@
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Journal;
import com.shatteredpixel.shatteredpixeldungeon.Journal.Feature;
import com.shatteredpixel.shatteredpixeldungeon.Notes;
import com.shatteredpixel.shatteredpixeldungeon.Notes.Feature;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
@ -71,7 +71,7 @@ public class WaterOfTransmutation extends WellWater {
}
if (item != null) {
Journal.remove( Feature.WELL_OF_TRANSMUTATION );
Notes.remove( Feature.WELL_OF_TRANSMUTATION );
}
return item;

View File

@ -22,8 +22,8 @@
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Journal;
import com.shatteredpixel.shatteredpixeldungeon.Journal.Feature;
import com.shatteredpixel.shatteredpixeldungeon.Notes;
import com.shatteredpixel.shatteredpixeldungeon.Notes.Feature;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
@ -58,11 +58,11 @@ public class WellWater extends Blob {
if (Dungeon.visible[pos]) {
if (this instanceof WaterOfAwareness) {
Journal.add( Feature.WELL_OF_AWARENESS );
Notes.add( Feature.WELL_OF_AWARENESS );
} else if (this instanceof WaterOfHealth) {
Journal.add( Feature.WELL_OF_HEALTH );
Notes.add( Feature.WELL_OF_HEALTH );
} else if (this instanceof WaterOfTransmutation) {
Journal.add( Feature.WELL_OF_TRANSMUTATION );
Notes.add( Feature.WELL_OF_TRANSMUTATION );
}
}
}

View File

@ -22,7 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Journal;
import com.shatteredpixel.shatteredpixeldungeon.Notes;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Poison;
@ -80,7 +80,7 @@ public class Statue extends Mob {
@Override
protected boolean act() {
if (Dungeon.visible[pos]) {
Journal.add( Journal.Feature.STATUE );
Notes.add( Notes.Feature.STATUE );
}
return super.act();
}
@ -139,7 +139,7 @@ public class Statue extends Mob {
@Override
public void destroy() {
Journal.remove( Journal.Feature.STATUE );
Notes.remove( Notes.Feature.STATUE );
super.destroy();
}

View File

@ -24,7 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Journal;
import com.shatteredpixel.shatteredpixeldungeon.Notes;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem;
@ -86,7 +86,7 @@ public class Blacksmith extends NPC {
}
} );
Journal.add( Journal.Feature.TROLL );
Notes.add( Notes.Feature.TROLL );
} else if (!Quest.completed) {
if (Quest.alternative) {
@ -203,7 +203,7 @@ public class Blacksmith extends NPC {
Quest.reforged = true;
Journal.remove( Journal.Feature.TROLL );
Notes.remove( Notes.Feature.TROLL );
}
@Override

View File

@ -23,7 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Journal;
import com.shatteredpixel.shatteredpixeldungeon.Notes;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
@ -170,7 +170,7 @@ public class Ghost extends NPC {
GameScene.add(questBoss);
GameScene.show( new WndQuest( this, txt_quest ) );
Quest.given = true;
Journal.add( Journal.Feature.GHOST );
Notes.add( Notes.Feature.GHOST );
}
}
@ -342,7 +342,7 @@ public class Ghost extends NPC {
weapon = null;
armor = null;
Journal.remove( Journal.Feature.GHOST );
Notes.remove( Notes.Feature.GHOST );
}
public static boolean completed(){

View File

@ -22,7 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Journal;
import com.shatteredpixel.shatteredpixeldungeon.Notes;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Golem;
@ -105,7 +105,7 @@ public class Imp extends NPC {
Quest.given = true;
Quest.completed = false;
Journal.add( Journal.Feature.IMP );
Notes.add( Notes.Feature.IMP );
}
return false;
@ -214,7 +214,7 @@ public class Imp extends NPC {
reward = null;
completed = true;
Journal.remove( Journal.Feature.IMP );
Notes.remove( Notes.Feature.IMP );
}
public static boolean isCompleted() {

View File

@ -23,7 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs;
import com.shatteredpixel.shatteredpixeldungeon.Challenges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Journal;
import com.shatteredpixel.shatteredpixeldungeon.Notes;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
@ -163,7 +163,7 @@ public class Wandmaker extends NPC {
}
});
Journal.add( Journal.Feature.WANDMAKER );
Notes.add( Notes.Feature.WANDMAKER );
Quest.given = true;
}
@ -307,7 +307,7 @@ public class Wandmaker extends NPC {
wand1 = null;
wand2 = null;
Journal.remove( Journal.Feature.WANDMAKER );
Notes.remove( Notes.Feature.WANDMAKER );
}
}
}

View File

@ -22,7 +22,7 @@
package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Journal;
import com.shatteredpixel.shatteredpixeldungeon.Notes;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey;
@ -62,7 +62,7 @@ public class WndJournal extends WndTabbed {
private static final int ITEM_HEIGHT = 18;
private Notes notes;
private NotesTab notesTab;
private CatalogTab catalogTab;
public static int last_index = 0;
@ -74,10 +74,10 @@ public class WndJournal extends WndTabbed {
resize(width, height);
notes = new Notes();
add(notes);
notes.setRect(0, 0, width, height);
notes.updateList();
notesTab = new NotesTab();
add(notesTab);
notesTab.setRect(0, 0, width, height);
notesTab.updateList();
catalogTab = new CatalogTab();
add(catalogTab);
@ -94,7 +94,7 @@ public class WndJournal extends WndTabbed {
new LabeledTab( "Notes" ) {
protected void select( boolean value ) {
super.select( value );
notes.active = notes.visible = value;
notesTab.active = notesTab.visible = value;
if (value) last_index = 1;
};
},
@ -181,11 +181,11 @@ public class WndJournal extends WndTabbed {
}
}
private static class Notes extends Component {
private static class NotesTab extends Component {
private ScrollPane list;
public Notes(){
public NotesTab(){
list = new ScrollPane( new Component() );
add( list );
}
@ -199,7 +199,7 @@ public class WndJournal extends WndTabbed {
private void updateList(){
Component content = list.content();
Collections.sort( Journal.records );
Collections.sort( Notes.records );
float pos = 0;
@ -237,8 +237,8 @@ public class WndJournal extends WndTabbed {
}
//Journal entries
for (Journal.Record rec : Journal.records) {
//Notes entries
for (Notes.Record rec : Notes.records) {
ListItem item = new ListItem( Icons.get(Icons.DEPTH), rec.feature.desc(), rec.depth );
item.setRect( 0, pos, width(), ITEM_HEIGHT );
content.add( item );