v0.6.1: added all identifiable items to items tab, needs improvements

This commit is contained in:
Evan Debenham 2017-07-06 21:54:15 -04:00
parent 2ffbef67fd
commit d975f3c8d5
4 changed files with 293 additions and 55 deletions

View File

@ -155,14 +155,17 @@ public class UnstableSpellbook extends Artifact {
public String desc() {
String desc = super.desc();
if (cursed && isEquipped (Dungeon.hero)){
desc += "\n\n" + Messages.get(this, "desc_cursed");
}
if (level() < levelCap && scrolls.size() > 0) {
desc += "\n\n" + Messages.get(this, "desc_index");
desc += "\n" + "_" + Messages.get(scrolls.get(0), "name") + "_";
if (scrolls.size() > 1) desc += "\n" + "_" + Messages.get(scrolls.get(1), "name") + "_";
if (isEquipped(Dungeon.hero)) {
if (cursed) {
desc += "\n\n" + Messages.get(this, "desc_cursed");
}
if (level() < levelCap && scrolls.size() > 0) {
desc += "\n\n" + Messages.get(this, "desc_index");
desc += "\n" + "_" + Messages.get(scrolls.get(0), "name") + "_";
if (scrolls.size() > 1)
desc += "\n" + "_" + Messages.get(scrolls.get(1), "name") + "_";
}
}
if (level() > 0) {

View File

@ -74,6 +74,11 @@ public class Boomerang extends MissileWeapon {
return true;
}
@Override
public boolean isIdentified() {
return levelKnown && cursedKnown;
}
@Override
public Item upgrade( boolean enchant ) {
super.upgrade( enchant );

View File

@ -0,0 +1,235 @@
/*
* 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.journal;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.ClothArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.HuntressArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.LeatherArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.MageArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.MailArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.PlateArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.RogueArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.ScaleArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.armor.WarriorArmor;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CapeOfThorns;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.ChaliceOfBlood;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.CloakOfShadows;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.EtherealChains;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.HornOfPlenty;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.LloydsBeacon;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.MasterThievesArmband;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.SandalsOfNature;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TalismanOfForesight;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.UnstableSpellbook;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfExperience;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfFrost;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfHealing;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfInvisibility;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLevitation;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMindVision;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfParalyticGas;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfPurity;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfStrength;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfAccuracy;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfElements;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfEvasion;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfForce;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfFuror;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfHaste;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfMight;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfSharpshooting;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfTenacity;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfIdentify;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfLullaby;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicMapping;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMagicalInfusion;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfMirrorImage;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfPsionicBlast;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRage;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRecharging;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfRemoveCurse;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTerror;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfBlastWave;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfCorruption;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfDisintegration;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfFireblast;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfFrost;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfLightning;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfMagicMissile;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfPrismaticLight;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfRegrowth;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfTransfusion;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfVenom;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.AssassinsBlade;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.BattleAxe;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Dagger;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Dirk;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Flail;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Glaive;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Greataxe;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Greatshield;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Greatsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.HandAxe;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Knuckles;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Longsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Mace;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.MagesStaff;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Quarterstaff;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.RoundShield;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.RunicBlade;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Sai;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Scimitar;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Shortsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Spear;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Sword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.WarHammer;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.Whip;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.melee.WornShortsword;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.Boomerang;
public class Catalogs {
public static final Class<?>[] weapons = new Class<?>[]{
WornShortsword.class,
Knuckles.class,
Dagger.class,
MagesStaff.class,
Boomerang.class,
Shortsword.class,
HandAxe.class,
Spear.class,
Quarterstaff.class,
Dirk.class,
Sword.class,
Mace.class,
Scimitar.class,
RoundShield.class,
Sai.class,
Whip.class,
Longsword.class,
BattleAxe.class,
Flail.class,
RunicBlade.class,
AssassinsBlade.class,
Greatsword.class,
WarHammer.class,
Glaive.class,
Greataxe.class,
Greatshield.class
};
public static final Class<?>[] armor = new Class<?>[]{
ClothArmor.class,
LeatherArmor.class,
MailArmor.class,
ScaleArmor.class,
PlateArmor.class,
WarriorArmor.class,
MageArmor.class,
RogueArmor.class,
HuntressArmor.class,
};
public static final Class<?>[] wands = new Class<?>[]{
WandOfMagicMissile.class,
WandOfLightning.class,
WandOfDisintegration.class,
WandOfFireblast.class,
WandOfVenom.class,
WandOfBlastWave.class,
//WandOfLivingEarth.class,
WandOfFrost.class,
WandOfPrismaticLight.class,
//WandOfWarding.class,
WandOfTransfusion.class,
WandOfCorruption.class,
WandOfRegrowth.class
};
public static final Class<?>[] rings = new Class<?>[]{
RingOfAccuracy.class,
RingOfEvasion.class,
RingOfElements.class,
RingOfForce.class,
RingOfFuror.class,
RingOfHaste.class,
//RingOfMagic.class,
RingOfMight.class,
RingOfSharpshooting.class,
RingOfTenacity.class,
RingOfWealth.class
};
public static final Class<?>[] artifacts = new Class<?>[]{
//AlchemistsToolkit.class,
CapeOfThorns.class,
ChaliceOfBlood.class,
CloakOfShadows.class,
DriedRose.class,
EtherealChains.class,
HornOfPlenty.class,
LloydsBeacon.class,
MasterThievesArmband.class,
SandalsOfNature.class,
TalismanOfForesight.class,
TimekeepersHourglass.class,
UnstableSpellbook.class
};
public static final Class<?>[] potions = new Class<?>[]{
PotionOfHealing.class,
PotionOfStrength.class,
PotionOfLiquidFlame.class,
PotionOfFrost.class,
PotionOfToxicGas.class,
PotionOfParalyticGas.class,
PotionOfPurity.class,
PotionOfLevitation.class,
PotionOfMindVision.class,
PotionOfInvisibility.class,
PotionOfExperience.class,
PotionOfMight.class,
};
public static final Class<?>[] scrolls = new Class<?>[]{
ScrollOfIdentify.class,
ScrollOfUpgrade.class,
ScrollOfRemoveCurse.class,
ScrollOfMagicMapping.class,
ScrollOfTeleportation.class,
ScrollOfRecharging.class,
ScrollOfMirrorImage.class,
ScrollOfTerror.class,
ScrollOfLullaby.class,
ScrollOfRage.class,
ScrollOfPsionicBlast.class,
ScrollOfMagicalInfusion.class
};
}

View File

@ -24,7 +24,6 @@ package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.Journal;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey;
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
@ -32,6 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.items.rings.Ring;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
import com.shatteredpixel.shatteredpixeldungeon.journal.Catalogs;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
@ -49,6 +49,7 @@ import com.watabou.noosa.ui.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
//FIXME a lot of cleanup and improvements to do here
public class WndJournal extends WndTabbed {
@ -62,7 +63,7 @@ public class WndJournal extends WndTabbed {
private static final int ITEM_HEIGHT = 18;
private Notes notes;
private Catalog catalog;
private CatalogTab catalogTab;
public static int last_index = 0;
@ -78,10 +79,10 @@ public class WndJournal extends WndTabbed {
notes.setRect(0, 0, width, height);
notes.updateList();
catalog = new Catalog();
add(catalog);
catalog.setRect(0, 0, width, height);
catalog.updateList();
catalogTab = new CatalogTab();
add(catalogTab);
catalogTab.setRect(0, 0, width, height);
catalogTab.updateList();
Tab[] tabs = {
new LabeledTab( "Guide" ) {
@ -100,7 +101,7 @@ public class WndJournal extends WndTabbed {
new LabeledTab( "Items" ) {
protected void select( boolean value ) {
super.select( value );
catalog.active = catalog.visible = value;
catalogTab.active = catalogTab.visible = value;
if (value) last_index = 2;
};
}
@ -250,18 +251,18 @@ public class WndJournal extends WndTabbed {
}
private static class Catalog extends Component{
private static class CatalogTab extends Component{
private RedButton[] itemButtons;
private static final int NUM_BUTTONS = 7;
private static int latestPressedIdx = 0;
private static int currentItemIdx = 0;
private ScrollPane list;
private ArrayList<CatalogItem> items = new ArrayList<>();
public Catalog(){
public CatalogTab(){
super();
@ -271,7 +272,7 @@ public class WndJournal extends WndTabbed {
itemButtons[i] = new RedButton( "" ){
@Override
protected void onClick() {
latestPressedIdx = idx;
currentItemIdx = idx;
updateList();
}
};
@ -317,7 +318,7 @@ public class WndJournal extends WndTabbed {
items.clear();
for (int i = 0; i < NUM_BUTTONS; i++){
if (i == latestPressedIdx){
if (i == currentItemIdx){
itemButtons[i].icon().color(TITLE_COLOR);
} else {
itemButtons[i].icon().resetColor();
@ -329,27 +330,36 @@ public class WndJournal extends WndTabbed {
list.scrollTo( 0, 0 );
ArrayList<Class<?>> itemClasses;
if (latestPressedIdx == 5){
itemClasses = new ArrayList<>(Arrays.asList(Generator.Category.POTION.classes));
for ( Class unknown : Potion.getUnknown()){
if (itemClasses.remove(unknown)) itemClasses.add(unknown);
}
} else if (latestPressedIdx == 6) {
itemClasses = new ArrayList<>(Arrays.asList(Generator.Category.SCROLL.classes));
for ( Class unknown : Scroll.getUnknown()){
if (itemClasses.remove(unknown)) itemClasses.add(unknown);
}
HashMap<Class<?>, Boolean> known = new HashMap<>();
if (currentItemIdx == 0) {
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.weapons));
for (Class<?> cls : itemClasses) known.put(cls, true);
} else if (currentItemIdx == 1){
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.armor));
for (Class<?> cls : itemClasses) known.put(cls, true);
} else if (currentItemIdx == 2){
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.wands));
for (Class<?> cls : itemClasses) known.put(cls, true);
} else if (currentItemIdx == 3){
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.rings));
for (Class<?> cls : itemClasses) known.put(cls, Ring.getKnown().contains(cls));
} else if (currentItemIdx == 4){
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.artifacts));
for (Class<?> cls : itemClasses) known.put(cls, true);
} else if (currentItemIdx == 5){
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.potions));
for (Class<?> cls : itemClasses) known.put(cls, Potion.getKnown().contains(cls));
} else if (currentItemIdx == 6) {
itemClasses = new ArrayList<>(Arrays.asList(Catalogs.scrolls));
for (Class<?> cls : itemClasses) known.put(cls, Scroll.getKnown().contains(cls));
} else {
itemClasses = new ArrayList<>(Arrays.asList(Generator.Category.RING.classes));
for ( Class unknown : Ring.getUnknown()){
if (itemClasses.remove(unknown)) itemClasses.add(unknown);
}
itemClasses = new ArrayList<>();
}
float pos = 0;
for (Class<?> itemClass : itemClasses) {
try{
CatalogItem item = new CatalogItem((Item) itemClass.newInstance());
CatalogItem item = new CatalogItem((Item) itemClass.newInstance(), known.get(itemClass));
item.setRect( 0, pos, width, ITEM_HEIGHT );
content.add( item );
items.add( item );
@ -367,26 +377,14 @@ public class WndJournal extends WndTabbed {
private static class CatalogItem extends ListItem {
private Item item;
private boolean identified;
public CatalogItem(Item item ) {
super( new ItemSprite(item), Messages.titleCase(item.name()));
public CatalogItem(Item item, boolean IDed ) {
super( new ItemSprite(item), Messages.titleCase(item.trueName()));
this.item = item;
if (!(identified = item.isIdentified())) {
ItemSprite placeHolder;
if (item instanceof Potion){
placeHolder = new ItemSprite( ItemSpriteSheet.POTION_HOLDER, null);
} else if (item instanceof Scroll){
placeHolder = new ItemSprite( ItemSpriteSheet.SCROLL_HOLDER, null);
} else if (item instanceof Ring){
placeHolder = new ItemSprite( ItemSpriteSheet.RING_HOLDER, null);
} else {
placeHolder = new ItemSprite( ItemSpriteSheet.SOMETHING, null);
}
icon.copy( placeHolder );
label.text( Messages.titleCase(item.trueName()) );
if (!IDed) {
icon.copy( new ItemSprite( ItemSpriteSheet.WEAPON_HOLDER + currentItemIdx, null) );
label.hardlight( 0xCCCCCC );
}
@ -394,10 +392,7 @@ public class WndJournal extends WndTabbed {
public boolean onClick( float x, float y ) {
if (inside( x, y )) {
if (identified)
GameScene.show( new WndInfoItem( item ) );
else
GameScene.show(new WndTitledMessage( new Image(icon),
GameScene.show(new WndTitledMessage( new Image(icon),
Messages.titleCase(item.trueName()), item.desc() ));
return true;
} else {