From 0aa620d79b4f344577bd96be13794325ee9f90ca Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Thu, 21 Mar 2019 15:48:05 -0700 Subject: [PATCH] Added item stat list to item details --- core/src/com/riiablo/item/Item.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/src/com/riiablo/item/Item.java b/core/src/com/riiablo/item/Item.java index 9356bad4..a0f89916 100644 --- a/core/src/com/riiablo/item/Item.java +++ b/core/src/com/riiablo/item/Item.java @@ -29,6 +29,7 @@ import com.riiablo.widget.Label; import org.apache.commons.lang3.builder.ToStringBuilder; import java.util.Arrays; +import java.util.Comparator; import java.util.EnumMap; import static com.riiablo.item.Quality.SET; @@ -55,6 +56,8 @@ public class Item extends Actor implements Disposable { private static final int INSCRIBED = 0x01000000; private static final int RUNEWORD = 0x04000000; + private static final EnumMap[] EMPTY_STAT_ARRAY = (EnumMap[]) new EnumMap[0]; + public int flags; public int version; // 0 = pre-1.08; 1 = 1.08/1.09 normal; 2 = 1.10 normal; 100 = 1.08/1.09 expansion; 101 = 1.10 expansion public Location location; @@ -149,6 +152,7 @@ public class Item extends Actor implements Disposable { qualityData = null; runewordData = 0; inscription = null; + stats = EMPTY_STAT_ARRAY; } else { id = bitStream.read32BitsOrLess(Integer.SIZE); level = bitStream.readUnsigned7OrLess(7); @@ -770,6 +774,24 @@ public class Item extends Actor implements Disposable { add(usable).center().space(SPACING).row(); } + for (int i = 0; i < stats.length; i++) { + EnumMap stats = Item.this.stats[i]; + if (stats == null) continue; + Array values = new Array<>(); + for (Stat.Instance stat : stats.values()) values.add(stat); + values.sort(new Comparator() { + @Override + public int compare(Stat.Instance o1, Stat.Instance o2) { + return o1.stat.entry().descpriority - o2.stat.entry().descpriority; + } + }); + + for (Stat.Instance stat : values) { + Label label = new Label(stat.stat + ": " + stat, font); + add(label).center().space(SPACING).row(); + } + } + pack(); } }