Fix format tooltip

This commit is contained in:
drdev
2014-04-12 05:07:31 +00:00
parent 8631916993
commit 32c50dec13
3 changed files with 6 additions and 27 deletions

View File

@@ -40,9 +40,7 @@ public abstract class FormatFilter<T extends InventoryItem> extends ListLabelFil
}
//use HTML tooltips so we can insert line breaks
int lastLen = 0;
int lineLen = 0;
StringBuilder tooltip = new StringBuilder("<html>Sets:");
StringBuilder tooltip = new StringBuilder("Sets:");
if (sets.isEmpty()) {
tooltip.append(" All");
}
@@ -50,47 +48,28 @@ public abstract class FormatFilter<T extends InventoryItem> extends ListLabelFil
CardEdition.Collection editions = FModel.getMagicDb().getEditions();
for (String code : sets) {
// don't let a single line get too long
if (50 < lineLen) {
tooltip.append("<br>");
lastLen += lineLen;
lineLen = 0;
}
CardEdition edition = editions.get(code);
tooltip.append(" ").append(edition.getName()).append(" (").append(code).append("),");
lineLen = tooltip.length() - lastLen;
}
// chop off last comma
tooltip.delete(tooltip.length() - 1, tooltip.length());
if (this.allowReprints) {
tooltip.append("<br><br>Allowing identical cards from other sets");
tooltip.append("\n\nAllowing identical cards from other sets.");
}
}
if (!bannedCards.isEmpty()) {
tooltip.append("<br><br>Banned:");
lastLen += lineLen;
lineLen = 0;
tooltip.append("\n\nBanned:");
for (String cardName : bannedCards) {
// don't let a single line get too long
if (50 < lineLen) {
tooltip.append("<br>");
lastLen += lineLen;
lineLen = 0;
}
tooltip.append(" ").append(cardName).append(";");
lineLen = tooltip.length() - lastLen;
}
// chop off last semicolon
tooltip.delete(tooltip.length() - 1, tooltip.length());
}
tooltip.append("</html>");
return tooltip.toString();
}

View File

@@ -54,7 +54,7 @@ public abstract class ListLabelFilter<T extends InventoryItem> extends ItemFilte
@Override
protected void doWidgetLayout(LayoutHelper helper) {
helper.fillLine(label, FTextField.getDefaultHeight());
helper.fillLine(label, helper.getParentHeight());
}
private class ListLabel extends FLabel {
@@ -65,7 +65,7 @@ public abstract class ListLabelFilter<T extends InventoryItem> extends ItemFilte
@Override
public boolean tap(float x, float y, int count) {
FTooltip tooltip = new FTooltip(getTooltip());
tooltip.show(this, x, y);
tooltip.show(this, x, getHeight());
return true;
}
}

View File

@@ -83,7 +83,7 @@ public abstract class ValueRangeFilter<T extends InventoryItem> extends ItemFilt
@Override
protected void doWidgetLayout(LayoutHelper helper) {
float height = lowerBound.getHeight();
float height = helper.getParentHeight();
helper.include(lowerBound, 45, height);
helper.include(label, 125, height);
helper.include(upperBound, 45, height);