Inventory filters: segregate jewelry from armor; and potions from food

This commit is contained in:
Nathan Watson
2021-01-09 20:00:45 -08:00
parent d5f00b25d6
commit f9a08dcf16
4 changed files with 57 additions and 19 deletions

View File

@@ -23,7 +23,9 @@
<item>@string/inventory_category_all</item>
<item>@string/inventory_category_weapons</item>
<item>@string/inventory_category_armor</item>
<item>@string/inventory_category_usable</item>
<item>@string/inventory_category_jewelry</item>
<item>@string/inventory_category_potion</item>
<item>@string/inventory_category_food</item>
<item>@string/inventory_category_quest</item>
<item>@string/inventory_category_other</item>
</string-array>

View File

@@ -710,7 +710,9 @@ Items made of cloth are not considered as being armor." </string>
<string name="inventory_category_favorites">Favorites</string>
<string name="inventory_category_weapons">Weapon</string>
<string name="inventory_category_armor">Armor</string>
<string name="inventory_category_usable">Consumable</string>
<string name="inventory_category_jewelry">Jewelry</string>
<string name="inventory_category_potion">Potion</string>
<string name="inventory_category_food">Food</string>
<string name="inventory_category_quest">Quest Item</string>
<string name="inventory_category_other">Other</string>

View File

@@ -52,7 +52,9 @@ public final class HeroinfoActivity_Inventory extends Fragment implements Custom
private ItemContainerAdapter inventoryListAdapter;
private ItemContainerAdapter inventoryWeaponsListAdapter;
private ItemContainerAdapter inventoryArmorListAdapter;
private ItemContainerAdapter inventoryUsableListAdapter;
private ItemContainerAdapter inventoryJewelryListAdapter;
private ItemContainerAdapter inventoryPotionListAdapter;
private ItemContainerAdapter inventoryFoodListAdapter;
private ItemContainerAdapter inventoryQuestListAdapter;
private ItemContainerAdapter inventoryOtherListAdapter;
@@ -306,11 +308,15 @@ public final class HeroinfoActivity_Inventory extends Fragment implements Custom
return inventoryWeaponsListAdapter.getItem(position).itemType;
} else if (v == 2) { //Armor items
return inventoryArmorListAdapter.getItem(position).itemType;
} else if (v == 3) { //Usable items
return inventoryUsableListAdapter.getItem(position).itemType;
} else if (v == 4) { //Quest items
} else if (v == 3) { //Jewelry items
return inventoryJewelryListAdapter.getItem(position).itemType;
} else if (v == 4) { //Potion items
return inventoryPotionListAdapter.getItem(position).itemType;
} else if (v == 5) { //Food items
return inventoryFoodListAdapter.getItem(position).itemType;
} else if (v == 6) { //Quest items
return inventoryQuestListAdapter.getItem(position).itemType;
} else if (v == 5) { //Other items
} else if (v == 7) { //Other items
return inventoryOtherListAdapter.getItem(position).itemType;
}
@@ -445,15 +451,23 @@ public final class HeroinfoActivity_Inventory extends Fragment implements Custom
inventoryArmorListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildArmorItems(), player, wornTiles);
inventoryList.setAdapter(inventoryArmorListAdapter);
inventoryArmorListAdapter.notifyDataSetChanged();
} else if (v == 3) { //Usable items
inventoryUsableListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildUsableItems(), player, wornTiles);
inventoryList.setAdapter(inventoryUsableListAdapter);
inventoryUsableListAdapter.notifyDataSetChanged();
} else if (v == 4) { //Quest items
} else if (v == 3) { //Jewelry items
inventoryJewelryListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildJewelryItems(), player, wornTiles);
inventoryList.setAdapter(inventoryJewelryListAdapter);
inventoryJewelryListAdapter.notifyDataSetChanged();
} else if (v == 4) { //Potion items
inventoryPotionListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildPotionItems(), player, wornTiles);
inventoryList.setAdapter(inventoryPotionListAdapter);
inventoryPotionListAdapter.notifyDataSetChanged();
} else if (v == 5) { //Food items
inventoryFoodListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildFoodItems(), player, wornTiles);
inventoryList.setAdapter(inventoryFoodListAdapter);
inventoryFoodListAdapter.notifyDataSetChanged();
} else if (v == 6) { //Quest items
inventoryQuestListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildQuestItems(), player, wornTiles);
inventoryList.setAdapter(inventoryQuestListAdapter);
inventoryQuestListAdapter.notifyDataSetChanged();
} else if (v == 5) { //Other items
} else if (v == 7) { //Other items
inventoryOtherListAdapter = new ItemContainerAdapter(getActivity(), world.tileManager, player.inventory.buildOtherItems(), player, wornTiles);
inventoryList.setAdapter(inventoryOtherListAdapter);
inventoryOtherListAdapter.notifyDataSetChanged();

View File

@@ -89,14 +89,34 @@ public final class Inventory extends ItemContainer {
return questItems;
}
// Move to item container?
public Inventory buildUsableItems() {
Inventory usableItems = new Inventory();
public Inventory buildJewelryItems() {
Inventory jewelryItems = new Inventory();
for (ItemEntry i : this.items) {
if (i == null) break;
if (i.itemType.isUsable())
usableItems.items.add(i);
if (i.itemType.isEquippable() && !i.itemType.isWeapon() && !i.itemType.isArmor() && !i.itemType.isShield())
jewelryItems.items.add(i);
}
return usableItems;
return jewelryItems;
}
// Move to item container?
public Inventory buildPotionItems() {
Inventory potionItems = new Inventory();
for (ItemEntry i : this.items) {
if (i == null) break;
if (i.itemType.isUsable() && ("pot".equals(i.itemType.category.id) || "healing".equals(i.itemType.category.id)))
potionItems.items.add(i);
}
return potionItems;
}
// Move to item container?
public Inventory buildFoodItems() {
Inventory foodItems = new Inventory();
for (ItemEntry i : this.items) {
if (i == null) break;
if (i.itemType.isUsable() && !("pot".equals(i.itemType.category.id) || "healing".equals(i.itemType.category.id)))
foodItems.items.add(i);
}
return foodItems;
}
// Move to item container?
public Inventory buildWeaponItems() {
@@ -113,7 +133,7 @@ public final class Inventory extends ItemContainer {
Inventory armorItems = new Inventory();
for (ItemEntry i : this.items) {
if (i == null) break;
if (i.itemType.isEquippable() && !i.itemType.isWeapon())
if (i.itemType.isArmor() || i.itemType.isShield())
armorItems.items.add(i);
}
return armorItems;