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

View File

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

View File

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