Minor tweak in InputSelectTargets and some string refactoring

This commit is contained in:
kevlahnota
2017-09-05 20:53:54 +00:00
parent 5c18270826
commit 00cbfa45d7
17 changed files with 174 additions and 154 deletions

View File

@@ -50,6 +50,7 @@ import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import forge.util.TextUtil;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.StringUtils;
@@ -479,7 +480,7 @@ public class ImportDialog {
selectedOptions.add(entry.getKey());
}
cb.setText(String.format("%s (%d)", cb.getName(), selection.getRight().size()));
cb.setText(TextUtil.concatWithSpace(cb.getName(), TextUtil.enclosedParen(String.valueOf(selection.getRight().size()))));
}
// asynchronously update the text in the op log, which may be many tens of thousands of lines long

View File

@@ -19,6 +19,7 @@ package forge.itemmanager.views;
import forge.card.CardEdition;
import forge.model.FModel;
import forge.util.TextUtil;
/**
* A wrapper to show explanatory tooltips for edition set abbreviations.
@@ -41,6 +42,6 @@ public class SetCodeRenderer extends ItemCellRenderer {
setFullName = editions.get(setAbbrev).getName();
}
return String.format("%s (%s)", setFullName, setAbbrev);
return TextUtil.concatWithSpace(setFullName, TextUtil.enclosedParen(setAbbrev));
}
}

View File

@@ -5,6 +5,7 @@ import forge.card.CardEdition;
import forge.gui.SOverlayUtils;
import forge.model.FModel;
import forge.toolbox.*;
import forge.util.TextUtil;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
@@ -43,7 +44,7 @@ public class DialogChooseSets {
for (CardEdition ce : editions) {
String code = ce.getCode();
FCheckBox box = new FCheckBox(String.format("%s (%s)", ce.getName(), code));
FCheckBox box = new FCheckBox(TextUtil.concatWithSpace(ce.getName(), TextUtil.enclosedParen(code)));
box.setName(code);
box.setSelected(null != preselectedSets && preselectedSets.contains(code));

View File

@@ -32,6 +32,7 @@ import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.border.Border;
import forge.util.TextUtil;
import net.miginfocom.swing.MigLayout;
import com.google.common.collect.Lists;
@@ -409,7 +410,7 @@ public class VAssignDamage {
dt.label.setText(sb.toString());
}
lblTotalDamage.setText(String.format("Available damage points: %d (of %d)", damageLeft, totalDamageToAssign));
lblTotalDamage.setText(TextUtil.concatNoSpace("Available damage points: ", String.valueOf(damageLeft), " (of ", String.valueOf(totalDamageToAssign), ")"));
btnOK.setEnabled(damageLeft == 0);
lblAssignRemaining.setVisible(allHaveLethal && damageLeft > 0);
}

View File

@@ -12,6 +12,7 @@ import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import forge.util.TextUtil;
import net.miginfocom.swing.MigLayout;
import org.apache.commons.lang3.StringUtils;
@@ -216,9 +217,9 @@ public class ViewWinLose implements IWinLoseView<FButton> {
if (winner == null || winner.isEmpty()) {
return "It's a draw!";
} else if (winningTeam != -1) {
return String.format("Team %d won!", Integer.valueOf(winningTeam));
return TextUtil.concatNoSpace("Team ", String.valueOf(winningTeam), " won!");
} else {
return String.format("%s won!", winner);
return TextUtil.concatNoSpace(winner, " won!");
}
}

View File

@@ -29,6 +29,7 @@ import forge.screens.workshop.views.VCardDesigner;
import forge.screens.workshop.views.VCardScript;
import forge.screens.workshop.views.VWorkshopCatalog;
import forge.toolbox.FOptionPane;
import forge.util.TextUtil;
/**
* Controls the "card script" panel in the workshop UI.
@@ -127,7 +128,7 @@ public enum CCardScript implements ICDoc {
switchInProgress = true;
Singletons.getControl().ensureScreenActive(FScreen.WORKSHOP_SCREEN); //ensure Workshop is active before showing dialog
final int choice = FOptionPane.showOptionDialog(
String.format("Save changes to %s?", currentCard),
TextUtil.concatNoSpace("Save changes to ", currentCard.toString(), "?"),
"Save Changes?",
FOptionPane.QUESTION_ICON,
switchAwayOptions);

View File

@@ -8,6 +8,7 @@ import forge.LobbyPlayer;
import forge.deck.DeckGroup;
import forge.properties.ForgeConstants;
import forge.tournament.system.*;
import forge.util.TextUtil;
import forge.util.storage.IStorage;
import org.apache.commons.lang3.text.WordUtils;
import org.apache.commons.lang3.time.StopWatch;
@@ -102,13 +103,13 @@ public class SimulateMatch {
for(String deck : params.get("d")) {
Deck d = deckFromCommandLineParameter(deck, type);
if (d == null) {
System.out.println(String.format("Could not load deck - %s, match cannot start", deck));
System.out.println(TextUtil.concatNoSpace("Could not load deck - ", deck, ", match cannot start"));
return;
}
if (i > 1) {
sb.append(" vs ");
}
String name = String.format("Ai(%s)-%s", i, d.getName());
String name = TextUtil.concatNoSpace("Ai(", String.valueOf(i), ")-", d.getName());
sb.append(name);
RegisteredPlayer rp;
@@ -195,7 +196,7 @@ public class SimulateMatch {
for(String deck : params.get("d")) {
Deck d = deckFromCommandLineParameter(deck, rules.getGameType());
if (d == null) {
System.out.println(String.format("Could not load deck - %s, match cannot start", deck));
System.out.println(TextUtil.concatNoSpace("Could not load deck - ", deck, ", match cannot start"));
return;
}
@@ -220,7 +221,7 @@ public class SimulateMatch {
})) {
Deck d = DeckSerializer.fromFile(deck);
if (d == null) {
System.out.println(String.format("Could not load deck - %s, match cannot start", deck.getName()));
System.out.println(TextUtil.concatNoSpace("Could not load deck - ", deck.getName(), ", match cannot start"));
return;
}
deckGroup.addAiDeck(d);
@@ -251,16 +252,17 @@ public class SimulateMatch {
String lastWinner = "";
int curRound = 0;
System.out.println(String.format("Starting a %s tournament with %d players over %d rounds", tournament,
numPlayers, tourney.getTotalRounds()));
System.out.println(TextUtil.concatNoSpace("Starting a ", tournament, " tournament with ",
String.valueOf(numPlayers), " players over ",
String.valueOf(tourney.getTotalRounds()), " rounds"));
while(!tourney.isTournamentOver()) {
if (tourney.getActiveRound() != curRound) {
if (curRound != 0) {
System.out.println(String.format("End Round - %d", curRound));
System.out.println(TextUtil.concatNoSpace("End Round - ", String.valueOf(curRound)));
}
curRound = tourney.getActiveRound();
System.out.println("");
System.out.println(String.format("Round %d Pairings:", curRound));
System.out.println(TextUtil.concatNoSpace("Round ", String.valueOf(curRound) ," Pairings:"));
for(TournamentPairing pairing : tourney.getActivePairings()) {
System.out.println(pairing.outputHeader());
@@ -303,7 +305,7 @@ public class SimulateMatch {
if (winner.equals(tp.getPlayer())) {
pairing.setWinner(tp);
lastWinner = winner.getName();
System.out.println(String.format("Match Winner - %s!", lastWinner));
System.out.println(TextUtil.concatNoSpace("Match Winner - ", lastWinner, "!"));
System.out.println("");
break;
}

View File

@@ -36,6 +36,7 @@ import forge.screens.match.CMatchUI;
import forge.toolbox.CardFaceSymbols;
import forge.toolbox.FSkin.SkinnedPanel;
import forge.toolbox.IDisposable;
import forge.util.TextUtil;
import forge.view.arcane.util.OutlinedLabel;
import javax.swing.*;
@@ -682,13 +683,14 @@ public class CardPanel extends SkinnedPanel implements CardContainer, IDisposabl
final CardStateView state = card.getCurrentState();
String sPt = "";
if (state.isCreature() && state.isPlaneswalker()) {
sPt = String.format("%d/%d (%d)", state.getPower(), state.getToughness(), state.getLoyalty());
sPt = TextUtil.concatWithSpace(TextUtil.transformPT(state.getPower(), state.getToughness()),
TextUtil.enclosedParen( String.valueOf(state.getLoyalty())));
}
else if (state.isCreature()) {
sPt = String.format("%d/%d", state.getPower(), state.getToughness());
sPt = TextUtil.transformPT(state.getPower(), state.getToughness());
}
else if (state.getType().hasSubtype("Vehicle")) {
sPt = String.format("[%d/%d]", state.getPower(), state.getToughness());
sPt = TextUtil.enclosedBracket(TextUtil.transformPT(state.getPower(), state.getToughness()));
}
else if (state.isPlaneswalker()) {
sPt = String.valueOf(state.getLoyalty());