diff --git a/src/haven/CFG.java b/src/haven/CFG.java index 4d3f5c2f31..7d41312aa0 100644 --- a/src/haven/CFG.java +++ b/src/haven/CFG.java @@ -56,6 +56,7 @@ public class CFG { public static final CFG MMAP_SHOW_BIOMES = new CFG<>("ui.mmap_biomes", true); public static final CFG MMAP_SHOW_PATH = new CFG<>("ui.mmap_path", false); public static final CFG MMAP_SHOW_MARKER_NAMES = new CFG<>("ui.mmap_mnames", false); + public static final CFG UI_ALWAYS_SHOW_LONG_TOOLTIPS = new CFG<>("ui.items_long_tooltips", false); public static final CFG MENU_SINGLE_CTRL_CLICK = new CFG<>("ui.menu_single_ctrl_click", true); public static final CFG MENU_SKIP_AUTO_CHOOSE = new CFG<>("ui.menu_skip_auto_choose", UI.KeyMod.SHIFT); public static final CFG MENU_ADD_PICK_ALL = new CFG<>("ui.menu_add_pick_all", false); diff --git a/src/haven/ExtInventory.java b/src/haven/ExtInventory.java index a85b911188..35135995ac 100644 --- a/src/haven/ExtInventory.java +++ b/src/haven/ExtInventory.java @@ -292,6 +292,23 @@ private static Double quality(WItem item, Grouping g) { QualityList q = item.itemq.get(); return (q == null || q.isEmpty()) ? null : quantifyQ(q.single().value, g); } + private static int curiosityMentalWeight(ItemsGroup item){ + Curiosity curioInfo = item.sample.curio.get(); + if(curioInfo != null) { + return curioInfo.mw; + } else { + return 0; + } + } + + private static int curiosityLPH(ItemsGroup item){ + Curiosity curioInfo = item.sample.curio.get(); + if(curioInfo != null) { + return curioInfo.lph(curioInfo.lph); + } else { + return 0; + } + } private static Double quantifyQ(Double q, Grouping g) { if(q == null) {return null;} @@ -375,26 +392,47 @@ public ItemsGroup(ExtInventory extInventory, ItemType type, List items, U this.ui = ui; this.type = type; this.items = items; - items.sort(ExtInventory::byQuality); this.sample = items.get(0); - double quality; - if(type.quality == null) { - quality = items.stream().map(ExtInventory::quality).filter(Objects::nonNull).reduce(0.0, Double::sum) - / items.stream().map(ExtInventory::quality).filter(Objects::nonNull).count(); - } else { - quality = type.quality; - } - String quantity = Utils.f2s(items.stream().map(wItem -> wItem.quantity.get()).reduce(0f, Float::sum)); - this.text[1] = fnd.render(String.format("×%s %s", quantity, type.name)).tex(); - if(!Double.isNaN(quality)) { - String avg = type.quality != null ? "" : "~"; - String sign = (g == Grouping.NONE || g == Grouping.Q) ? "" : "+"; - String q = String.format("%sq%s%s", avg, Utils.f2s(quality, 1), sign); - this.text[0] = fnd.render(String.format("×%s %s", quantity, q)).tex(); + + // Grouping + if(g == Grouping.Curios){ + Curiosity curioInfo = this.sample.curio.get(); + if(curioInfo != null) { + this.text[0] = fnd.render(String.format("mw: %s - %s", curioInfo.mw, type.name)).tex(); + }else{ + this.text[0] = fnd.render(String.format("%s", type.name)).tex(); + } + } else if (g == Grouping.CuriosLPH) { + Curiosity curioInfo = this.sample.curio.get(); + if(curioInfo != null) { + this.text[0] = fnd.render(String.format("lph: %s - %s", curioInfo.lph(curioInfo.lph), type.name)).tex(); + }else{ + this.text[0] = fnd.render(String.format("%s", type.name)).tex(); + } } else { - this.text[0] = text[1]; + items.sort(ExtInventory::byQuality); + double quality; + if(type.quality == null) { + quality = items.stream().map(ExtInventory::quality).filter(Objects::nonNull).reduce(0.0, Double::sum) + / items.stream().map(ExtInventory::quality).filter(Objects::nonNull).count(); + } else { + quality = type.quality; + } + String quantity = Utils.f2s(items.stream().map(wItem -> wItem.quantity.get()).reduce(0f, Float::sum)); + this.text[1] = fnd.render(String.format("×%s %s", quantity, type.name)).tex(); + if(!Double.isNaN(quality)) { + String avg = type.quality != null ? "" : "~"; + String sign = (g == Grouping.NONE || g == Grouping.Q) ? "" : "+"; + String q = String.format("%sq%s%s", avg, Utils.f2s(quality, 1), sign); + + this.text[0] = fnd.render(String.format("×%s %s", quantity, q)).tex(); + } else { + this.text[0] = text[1]; + } + + this.text[2] = info(sample, quantity, text[1]); } - this.text[2] = info(sample, quantity, text[1]); + flowerSubscription = Reactor.FLOWER_CHOICE.subscribe(this::flowerChoice); } @@ -526,6 +564,18 @@ private static int byQuality(WItem a, WItem b) { return Double.compare(qb, qa); } + private static int byCuriosMentalWeight(ItemsGroup a, ItemsGroup b){ + int qa = curiosityMentalWeight(a); + int qb = curiosityMentalWeight(b); + return Integer.compare(qb, qa); + } + + private static int byCuriosLPH(ItemsGroup a, ItemsGroup b){ + int qa = curiosityLPH(a); + int qb = curiosityLPH(b); + return Integer.compare(qb, qa); + } + public static boolean needDisableExtraInventory(String title) { return EXCLUDES.contains(title); } @@ -592,6 +642,15 @@ public void tick(double dt) { } else { groups = ExtInventory.this.groups.entrySet().stream() .map(v -> new ItemsGroup(ExtInventory.this, v.getKey(), v.getValue(), ui, grouping.sel)).collect(Collectors.toList()); + + if(grouping.sel == Grouping.Curios) { + groups.sort(ExtInventory::byCuriosMentalWeight); + } + if(grouping.sel == Grouping.CuriosLPH){ + groups.sort(ExtInventory::byCuriosLPH); + } + + } } needsUpdate = false; @@ -628,7 +687,10 @@ enum Grouping { Q("Quality"), Q1("Quality 1"), Q5("Quality 5"), - Q10("Quality 10"); + Q10("Quality 10"), + Curios("Curiosities MentalWeight"), + CuriosLPH("Curiosities LPH"); + private final String name; diff --git a/src/haven/OptWnd.java b/src/haven/OptWnd.java index 68185ab445..76bb225715 100644 --- a/src/haven/OptWnd.java +++ b/src/haven/OptWnd.java @@ -1075,6 +1075,10 @@ public void set(boolean a) { y += STEP; panel.add(new CFGBox("Show queued path on minimap", CFG.MMAP_SHOW_PATH), x, y); + + //custom options + y += STEP; + panel.add(new CFGBox("Always show long tooltips", CFG.UI_ALWAYS_SHOW_LONG_TOOLTIPS), x, y); //second row my = Math.max(my, y); diff --git a/src/haven/WItem.java b/src/haven/WItem.java index bc73502884..4926dd7540 100644 --- a/src/haven/WItem.java +++ b/src/haven/WItem.java @@ -134,14 +134,21 @@ public Object tooltip(Coord c, Widget prev) { shorttip = longtip = null; ttinfo = info; } - if(now - hoverstart < 1.0) { - if(shorttip == null) - shorttip = new ShortTip(info); - return(shorttip); - } else { + + if(CFG.UI_ALWAYS_SHOW_LONG_TOOLTIPS.get()){ if(longtip == null) longtip = new LongTip(info); return(longtip); + } else { /* normal behaviour */ + if(now - hoverstart < 1.0) { + if(shorttip == null) + shorttip = new ShortTip(info); + return(shorttip); + } else { + if(longtip == null) + longtip = new LongTip(info); + return(longtip); + } } } catch(Loading e) { return("...");