Make UI text translatable in MagicCardChoice.
parent
5c46a64395
commit
cd7352497d
|
@ -1,39 +1,37 @@
|
|||
package magic.model.choice;
|
||||
|
||||
import magic.model.MagicCard;
|
||||
import magic.model.MagicCardList;
|
||||
import magic.model.MagicGame;
|
||||
import magic.model.MagicPlayer;
|
||||
import magic.model.MagicSource;
|
||||
import magic.model.event.MagicEvent;
|
||||
import magic.exception.UndoClickedException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import magic.exception.UndoClickedException;
|
||||
import magic.model.IUIGameController;
|
||||
import magic.model.MagicCard;
|
||||
import magic.model.MagicCardList;
|
||||
import magic.model.MagicGame;
|
||||
import magic.model.MagicPlayer;
|
||||
import magic.model.MagicSource;
|
||||
import magic.model.event.MagicEvent;
|
||||
import magic.translate.MText;
|
||||
|
||||
public class MagicCardChoice extends MagicChoice {
|
||||
|
||||
private static final String MESSAGE="Choose a card from your hand.";
|
||||
// translatable UI text (prefix with _S).
|
||||
private static final String _S1 = "Choose a card from your hand.";
|
||||
private static final String _S2 = "Choose %d cards from your hand.";
|
||||
|
||||
private final int amount;
|
||||
|
||||
public MagicCardChoice(final int amount) {
|
||||
|
||||
super(genDescription(amount));
|
||||
this.amount=amount;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
private static final String genDescription(final int amount) {
|
||||
if (amount==1) {
|
||||
return "Choose a card from your hand.";
|
||||
} else {
|
||||
return "Choose " + amount + " cards from your hand.";
|
||||
}
|
||||
private static String genDescription(final int amount) {
|
||||
return amount == 1 ? _S1 : MText.get(_S2, amount);
|
||||
}
|
||||
|
||||
private void createOptions(
|
||||
|
@ -55,9 +53,9 @@ public class MagicCardChoice extends MagicChoice {
|
|||
return;
|
||||
}
|
||||
|
||||
cards[count]=hand.get(index);
|
||||
createOptions(options,hand,cards,count+1,aAmount,index+1);
|
||||
createOptions(options,hand,cards,count,aAmount,index+1);
|
||||
cards[count] = hand.get(index);
|
||||
createOptions(options, hand, cards, count + 1, aAmount, index + 1);
|
||||
createOptions(options, hand, cards, count, aAmount, index + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,9 +67,9 @@ public class MagicCardChoice extends MagicChoice {
|
|||
final MagicCardList hand = new MagicCardList(player.getHand());
|
||||
hand.remove(source);
|
||||
Collections.sort(hand);
|
||||
final int actualAmount = Math.min(amount,hand.size());
|
||||
final int actualAmount = Math.min(amount, hand.size());
|
||||
if (actualAmount > 0) {
|
||||
createOptions(options,hand,new MagicCard[actualAmount],0,actualAmount,0);
|
||||
createOptions(options, hand, new MagicCard[actualAmount], 0, actualAmount, 0);
|
||||
} else {
|
||||
options.add(new MagicCardChoiceResult());
|
||||
}
|
||||
|
@ -83,16 +81,16 @@ public class MagicCardChoice extends MagicChoice {
|
|||
final MagicPlayer player = event.getPlayer();
|
||||
final MagicSource source = event.getSource();
|
||||
|
||||
final MagicCardChoiceResult result=new MagicCardChoiceResult();
|
||||
final Set<Object> validCards=new HashSet<Object>(player.getHand());
|
||||
final MagicCardChoiceResult result = new MagicCardChoiceResult();
|
||||
final Set<Object> validCards = new HashSet<Object>(player.getHand());
|
||||
validCards.remove(source);
|
||||
int actualAmount=Math.min(amount,validCards.size());
|
||||
for (;actualAmount>0;actualAmount--) {
|
||||
final String message=result.size()>0?result.toString()+"|"+MESSAGE:MESSAGE;
|
||||
int actualAmount = Math.min(amount, validCards.size());
|
||||
for (; actualAmount > 0; actualAmount--) {
|
||||
final String message = result.size() > 0 ? result.toString() + "|" + _S1 : _S1;
|
||||
controller.focusViewers(0);
|
||||
controller.disableActionButton(false);
|
||||
controller.setValidChoices(validCards,false);
|
||||
controller.showMessage(source,message);
|
||||
controller.setValidChoices(validCards, false);
|
||||
controller.showMessage(source, message);
|
||||
controller.waitForInput();
|
||||
final MagicCard card = controller.getChoiceClicked();
|
||||
validCards.remove(card);
|
||||
|
|
Loading…
Reference in New Issue