translate some text

This commit is contained in:
CCTV-1
2020-02-24 20:05:44 +08:00
parent f4dfa6038c
commit cc5d2c47ee
5 changed files with 140 additions and 134 deletions

View File

@@ -23,6 +23,7 @@ import forge.deck.io.DeckPreferences;
import forge.item.InventoryItem; import forge.item.InventoryItem;
import forge.toolbox.FSkin; import forge.toolbox.FSkin;
import forge.toolbox.FSkin.SkinImage; import forge.toolbox.FSkin.SkinImage;
import forge.util.Localizer;
import javax.swing.*; import javax.swing.*;
@@ -76,16 +77,17 @@ public class DeckStarRenderer extends ItemCellRenderer {
} }
private void update() { private void update() {
final Localizer localizer = Localizer.getInstance();
if (deck == null) { if (deck == null) {
this.setToolTipText(null); this.setToolTipText(null);
skinImage = null; skinImage = null;
} }
else if (DeckPreferences.getPrefs(deck).getStarCount() == 0) { else if (DeckPreferences.getPrefs(deck).getStarCount() == 0) {
this.setToolTipText("Click to add " + deck.getName() + " to your favorites"); this.setToolTipText(localizer.getMessage("lblClickToAddTargetToFavorites", deck.getName()));
skinImage = FSkin.getImage(FSkinProp.IMG_STAR_OUTINE); skinImage = FSkin.getImage(FSkinProp.IMG_STAR_OUTINE);
} }
else { //TODO: consider supporting more than 1 star else { //TODO: consider supporting more than 1 star
this.setToolTipText("Click to remove " + deck.getName() + " from your favorites"); this.setToolTipText(localizer.getMessage("lblClickToRemoveTargetToFavorites", deck.getName()));
skinImage = FSkin.getImage(FSkinProp.IMG_STAR_FILLED); skinImage = FSkin.getImage(FSkinProp.IMG_STAR_FILLED);
} }
} }

View File

@@ -23,6 +23,8 @@ import forge.item.IPaperCard;
import forge.item.InventoryItem; import forge.item.InventoryItem;
import forge.toolbox.FSkin; import forge.toolbox.FSkin;
import forge.toolbox.FSkin.SkinImage; import forge.toolbox.FSkin.SkinImage;
import forge.util.CardTranslation;
import forge.util.Localizer;
import javax.swing.*; import javax.swing.*;
@@ -77,16 +79,17 @@ public class StarRenderer extends ItemCellRenderer {
} }
private void update() { private void update() {
final Localizer localizer = Localizer.getInstance();
if (card == null) { if (card == null) {
this.setToolTipText(null); this.setToolTipText(null);
skinImage = null; skinImage = null;
} }
else if (CardPreferences.getPrefs(card).getStarCount() == 0) { else if (CardPreferences.getPrefs(card).getStarCount() == 0) {
this.setToolTipText("Click to add " + card.getName() + " to your favorites"); this.setToolTipText(localizer.getMessage("lblClickToAddTargetToFavorites", CardTranslation.getTranslatedName(card.getName())));
skinImage = FSkin.getImage(FSkinProp.IMG_STAR_OUTINE); skinImage = FSkin.getImage(FSkinProp.IMG_STAR_OUTINE);
} }
else { //TODO: consider supporting more than 1 star else { //TODO: consider supporting more than 1 star
this.setToolTipText("Click to remove " + card.getName() + " from your favorites"); this.setToolTipText(localizer.getMessage("lblClickToRemoveTargetToFavorites", CardTranslation.getTranslatedName(card.getName())));
skinImage = FSkin.getImage(FSkinProp.IMG_STAR_FILLED); skinImage = FSkin.getImage(FSkinProp.IMG_STAR_FILLED);
} }
} }

View File

@@ -11,6 +11,7 @@ import forge.model.FModel;
import forge.screens.deckeditor.views.*; import forge.screens.deckeditor.views.*;
import forge.screens.home.quest.CSubmenuQuestDecks; import forge.screens.home.quest.CSubmenuQuestDecks;
import forge.screens.match.controllers.CDetailPicture; import forge.screens.match.controllers.CDetailPicture;
import forge.util.Localizer;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -44,7 +45,7 @@ public class CEditorTokenViewer extends ACEditorBase<PaperToken, DeckBase> {
final TokenManager catalogManager = new TokenManager(cDetailPicture0, false); final TokenManager catalogManager = new TokenManager(cDetailPicture0, false);
final TokenManager deckManager = new TokenManager(cDetailPicture0, false); final TokenManager deckManager = new TokenManager(cDetailPicture0, false);
catalogManager.setCaption("All Tokens"); catalogManager.setCaption(Localizer.getInstance().getMessage("lblAllTokens"));
catalogManager.setAlwaysNonUnique(true); catalogManager.setAlwaysNonUnique(true);
this.setCatalogManager(catalogManager); this.setCatalogManager(catalogManager);
this.setDeckManager(deckManager); this.setDeckManager(deckManager);
@@ -103,7 +104,7 @@ public class CEditorTokenViewer extends ACEditorBase<PaperToken, DeckBase> {
resetUI(); resetUI();
CCTabLabel = VCardCatalog.SINGLETON_INSTANCE.getTabLabel().getText(); CCTabLabel = VCardCatalog.SINGLETON_INSTANCE.getTabLabel().getText();
VCardCatalog.SINGLETON_INSTANCE.getTabLabel().setText("All tokens"); VCardCatalog.SINGLETON_INSTANCE.getTabLabel().setText(Localizer.getInstance().getMessage("lblAllTokens"));
this.getBtnAdd().setVisible(false); this.getBtnAdd().setVisible(false);
this.getBtnAdd4().setVisible(false); this.getBtnAdd4().setVisible(false);

View File

@@ -412,7 +412,7 @@ public class VAssignDamage {
dt.label.setText(sb.toString()); dt.label.setText(sb.toString());
} }
lblTotalDamage.setText(TextUtil.concatNoSpace("Available damage points: ", String.valueOf(damageLeft), " (of ", String.valueOf(totalDamageToAssign), ")")); lblTotalDamage.setText(TextUtil.concatNoSpace(localizer.getMessage("lblAvailableDamagePoints"), ": " , String.valueOf(damageLeft), " (of ", String.valueOf(totalDamageToAssign), ")"));
btnOK.setEnabled(damageLeft == 0); btnOK.setEnabled(damageLeft == 0);
lblAssignRemaining.setVisible(allHaveLethal && damageLeft > 0); lblAssignRemaining.setVisible(allHaveLethal && damageLeft > 0);
} }

View File

@@ -30,6 +30,7 @@ import forge.screens.match.CMatchUI;
import forge.view.arcane.util.CardPanelMouseAdapter; import forge.view.arcane.util.CardPanelMouseAdapter;
import forge.toolbox.FButton; import forge.toolbox.FButton;
import forge.util.Localizer;
// Show a list of cards in a new window, containing the moveable cards // Show a list of cards in a new window, containing the moveable cards
// Allow moves of the moveable cards to top, to bottom, or anywhere // Allow moves of the moveable cards to top, to bottom, or anywhere
@@ -46,63 +47,63 @@ public class ListCardArea extends FloatingCardArea {
private boolean toTop, toBottom, toAnywhere; private boolean toTop, toBottom, toAnywhere;
private ListCardArea(final CMatchUI matchUI) { private ListCardArea(final CMatchUI matchUI) {
super(matchUI); super(matchUI);
window.add(getScrollPane(),"grow, push"); window.add(getScrollPane(),"grow, push");
window.setModal(true); window.setModal(true);
getScrollPane().setViewportView(this); getScrollPane().setViewportView(this);
doneButton = new FButton("Done"); doneButton = new FButton(Localizer.getInstance().getMessage("lblDone"));
doneButton.addActionListener(new ActionListener() { doneButton.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent e) { window.setVisible(false); } @Override public void actionPerformed(ActionEvent e) { window.setVisible(false); }
}); });
window.add(doneButton,BorderLayout.SOUTH); window.add(doneButton,BorderLayout.SOUTH);
setOpaque(false); setOpaque(false);
} }
public static ListCardArea show(final CMatchUI matchUI, final String title0, final Iterable<CardView> cardList0, final Iterable<CardView> moveableCards0, final boolean toTop0, final boolean toBottom0, final boolean toAnywhere0) { public static ListCardArea show(final CMatchUI matchUI, final String title0, final Iterable<CardView> cardList0, final Iterable<CardView> moveableCards0, final boolean toTop0, final boolean toBottom0, final boolean toAnywhere0) {
if (storedArea==null) { if (storedArea==null) {
storedArea = new ListCardArea(matchUI); storedArea = new ListCardArea(matchUI);
} }
cardList = new ArrayList<>(); cardList = new ArrayList<>();
for ( CardView cv : cardList0 ) { cardList.add(cv) ; } for ( CardView cv : cardList0 ) { cardList.add(cv) ; }
moveableCards = new ArrayList<>(); // make sure moveable cards are in cardlist moveableCards = new ArrayList<>(); // make sure moveable cards are in cardlist
for ( CardView card : moveableCards0 ) { for ( CardView card : moveableCards0 ) {
if ( cardList.contains(card) ) { if ( cardList.contains(card) ) {
moveableCards.add(card); moveableCards.add(card);
} }
} }
storedArea.title = title0; storedArea.title = title0;
storedArea.toTop = toTop0; storedArea.toTop = toTop0;
storedArea.toBottom = toBottom0; storedArea.toBottom = toBottom0;
storedArea.toAnywhere = toAnywhere0; storedArea.toAnywhere = toAnywhere0;
storedArea.setDragEnabled(true); storedArea.setDragEnabled(true);
storedArea.setVertical(true); storedArea.setVertical(true);
storedArea.showWindow(); storedArea.showWindow();
return storedArea; return storedArea;
} }
public ListCardArea(final CMatchUI matchUI, final String title0, final List<CardView> cardList0, final List<CardView> moveableCards0, final boolean toTop0, final boolean toBottom0, final boolean toAnywhere0) { public ListCardArea(final CMatchUI matchUI, final String title0, final List<CardView> cardList0, final List<CardView> moveableCards0, final boolean toTop0, final boolean toBottom0, final boolean toAnywhere0) {
super(matchUI); super(matchUI);
window.add(getScrollPane(),"grow, push"); window.add(getScrollPane(),"grow, push");
getScrollPane().setViewportView(this); getScrollPane().setViewportView(this);
setOpaque(false); setOpaque(false);
doneButton = new FButton("Done"); doneButton = new FButton(Localizer.getInstance().getMessage("lblDone"));
doneButton.addActionListener(new ActionListener() { doneButton.addActionListener(new ActionListener() {
@Override public void actionPerformed(ActionEvent e) { window.setVisible(false); } @Override public void actionPerformed(ActionEvent e) { window.setVisible(false); }
}); });
window.add(doneButton,BorderLayout.SOUTH); window.add(doneButton,BorderLayout.SOUTH);
cardList = new ArrayList<>(cardList0); // this is modified - pfps - is there a better way? cardList = new ArrayList<>(cardList0); // this is modified - pfps - is there a better way?
moveableCards = new ArrayList<>(moveableCards0); moveableCards = new ArrayList<>(moveableCards0);
title = title0; title = title0;
toTop = toTop0; toTop = toTop0;
toBottom = toBottom0; toBottom = toBottom0;
toAnywhere = toAnywhere0; toAnywhere = toAnywhere0;
this.setDragEnabled(true); this.setDragEnabled(true);
this.setVertical(true); this.setVertical(true);
storedArea = this; storedArea = this;
} }
public List<CardView> getCards() { public List<CardView> getCards() {
return cardList; return cardList;
} }
@Override @Override
@@ -114,110 +115,109 @@ public class ListCardArea extends FloatingCardArea {
@Override @Override
protected void onShow() { protected void onShow() {
super.onShow(); super.onShow();
if (!hasBeenShown) { if (!hasBeenShown) {
this.addCardPanelMouseListener(new CardPanelMouseAdapter() { this.addCardPanelMouseListener(new CardPanelMouseAdapter() {
@Override @Override
public void mouseDragEnd(final CardPanel dragPanel, final MouseEvent evt) { public void mouseDragEnd(final CardPanel dragPanel, final MouseEvent evt) {
dragEnd(dragPanel); dragEnd(dragPanel);
} }
}); });
this.addKeyListener(new KeyAdapter() { this.addKeyListener(new KeyAdapter() {
@Override @Override
public void keyPressed(final KeyEvent e) { public void keyPressed(final KeyEvent e) {
switch (e.getKeyCode()) { switch (e.getKeyCode()) {
case KeyEvent.VK_ENTER: case KeyEvent.VK_ENTER:
doneButton.doClick(); doneButton.doClick();
break; break;
default: default:
break; break;
} }
} }
}); });
} }
} }
// is this a valid place to move the card? // is this a valid place to move the card?
private boolean validIndex(final CardView card, final int index) { private boolean validIndex(final CardView card, final int index) {
if (toAnywhere) { return true; } if (toAnywhere) { return true; }
int oldIndex = cardList.indexOf(card); int oldIndex = cardList.indexOf(card);
boolean topMove = true; boolean topMove = true;
for(int i=0; i<index+(oldIndex<index?1:0); i++) { for(int i=0; i<index+(oldIndex<index?1:0); i++) {
if (!moveableCards.contains(cardList.get(i))) { topMove=false; break; } if (!moveableCards.contains(cardList.get(i))) { topMove=false; break; }
} }
if (toTop && topMove) { return true; } if (toTop && topMove) { return true; }
boolean bottomMove = true; boolean bottomMove = true;
for(int i=index+1-(oldIndex>index?1:0); i<cardList.size(); i++) { for(int i=index+1-(oldIndex>index?1:0); i<cardList.size(); i++) {
if (!moveableCards.contains(cardList.get(i))) { bottomMove=false; break; } if (!moveableCards.contains(cardList.get(i))) { bottomMove=false; break; }
} }
return toBottom && bottomMove; return toBottom && bottomMove;
} }
@Override @Override
protected boolean cardPanelDraggable(final CardPanel panel) { protected boolean cardPanelDraggable(final CardPanel panel) {
return moveableCards.contains(panel.getCard()); return moveableCards.contains(panel.getCard());
} }
private void dragEnd(final CardPanel dragPanel) { private void dragEnd(final CardPanel dragPanel) {
// if drag is not allowed, don't move anything // if drag is not allowed, don't move anything
final CardView dragCard = dragPanel.getCard(); final CardView dragCard = dragPanel.getCard();
if (moveableCards.contains(dragCard)) { if (moveableCards.contains(dragCard)) {
//update index of dragged card in hand zone to match new index within hand area //update index of dragged card in hand zone to match new index within hand area
final int index = getCardPanels().indexOf(dragPanel); final int index = getCardPanels().indexOf(dragPanel);
if (validIndex(dragCard,index)) { if (validIndex(dragCard,index)) {
synchronized (cardList) { synchronized (cardList) {
cardList.remove(dragCard); cardList.remove(dragCard);
cardList.add(index, dragCard); cardList.add(index, dragCard);
}
}
} }
} refresh();
}
refresh();
} }
// move to beginning of list if allowable else to beginning of bottom if allowable // move to beginning of list if allowable else to beginning of bottom if allowable
@Override @Override
public final void mouseLeftClicked(final CardPanel panel, final MouseEvent evt) { public final void mouseLeftClicked(final CardPanel panel, final MouseEvent evt) {
final CardView clickCard = panel.getCard(); final CardView clickCard = panel.getCard();
if ( moveableCards.contains(clickCard) ) { if ( moveableCards.contains(clickCard) ) {
if ( toTop || toBottom ) { if ( toTop || toBottom ) {
synchronized (cardList) { synchronized (cardList) {
cardList.remove(clickCard); cardList.remove(clickCard);
int position; int position;
if ( toTop ) { if ( toTop ) {
position = 0 ; position = 0 ;
} else { // to beginning of bottom: warning, untested } else { // to beginning of bottom: warning, untested
for ( position = cardList.size() ; for ( position = cardList.size() ;
position>0 && moveableCards.contains(cardList.get(position-1)) ; position>0 && moveableCards.contains(cardList.get(position-1)) ;
position-- ); position-- );
} }
cardList.add(position,clickCard); cardList.add(position,clickCard);
}
refresh();
}
} }
refresh();
}
}
super.mouseLeftClicked(panel, evt); super.mouseLeftClicked(panel, evt);
} }
@Override @Override
public final void mouseRightClicked(final CardPanel panel, final MouseEvent evt) { public final void mouseRightClicked(final CardPanel panel, final MouseEvent evt) {
final CardView clickCard = panel.getCard(); final CardView clickCard = panel.getCard();
if (moveableCards.contains(clickCard)) { if (moveableCards.contains(clickCard)) {
if ( toTop || toBottom ) { if ( toTop || toBottom ) {
synchronized (cardList) { synchronized (cardList) {
cardList.remove(clickCard); cardList.remove(clickCard);
int position; int position;
if ( toBottom ) { if ( toBottom ) {
position = cardList.size() ; position = cardList.size() ;
} else { // to end of top } else { // to end of top
for ( position = 0 ; for ( position = 0 ;
position<cardList.size() && moveableCards.contains(cardList.get(position)) ; position<cardList.size() && moveableCards.contains(cardList.get(position)) ;
position++ ); position++ );
} }
cardList.add(position,clickCard); cardList.add(position,clickCard);
}
refresh();
}
} }
refresh();
}
}
super.mouseRightClicked(panel, evt); super.mouseRightClicked(panel, evt);
} }