Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/haven/CFG.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class CFG<T> {
public static final CFG<Boolean> MMAP_SHOW_BIOMES = new CFG<>("ui.mmap_biomes", true);
public static final CFG<Boolean> MMAP_SHOW_PATH = new CFG<>("ui.mmap_path", false);
public static final CFG<Boolean> MMAP_SHOW_MARKER_NAMES = new CFG<>("ui.mmap_mnames", false);
public static final CFG<Boolean> UI_ALWAYS_SHOW_LONG_TOOLTIPS = new CFG<>("ui.items_long_tooltips", false);
public static final CFG<Boolean> MENU_SINGLE_CTRL_CLICK = new CFG<>("ui.menu_single_ctrl_click", true);
public static final CFG<UI.KeyMod> MENU_SKIP_AUTO_CHOOSE = new CFG<>("ui.menu_skip_auto_choose", UI.KeyMod.SHIFT);
public static final CFG<Boolean> MENU_ADD_PICK_ALL = new CFG<>("ui.menu_add_pick_all", false);
Expand Down
98 changes: 80 additions & 18 deletions src/haven/ExtInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;}
Expand Down Expand Up @@ -375,26 +392,47 @@ public ItemsGroup(ExtInventory extInventory, ItemType type, List<WItem> 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);
}

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 4 additions & 0 deletions src/haven/OptWnd.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 12 additions & 5 deletions src/haven/WItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -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("...");
Expand Down