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.toolbox.FSkin;
import forge.toolbox.FSkin.SkinImage;
import forge.util.Localizer;
import javax.swing.*;
@@ -76,16 +77,17 @@ public class DeckStarRenderer extends ItemCellRenderer {
}
private void update() {
final Localizer localizer = Localizer.getInstance();
if (deck == null) {
this.setToolTipText(null);
skinImage = null;
}
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);
}
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);
}
}

View File

@@ -23,6 +23,8 @@ import forge.item.IPaperCard;
import forge.item.InventoryItem;
import forge.toolbox.FSkin;
import forge.toolbox.FSkin.SkinImage;
import forge.util.CardTranslation;
import forge.util.Localizer;
import javax.swing.*;
@@ -77,16 +79,17 @@ public class StarRenderer extends ItemCellRenderer {
}
private void update() {
final Localizer localizer = Localizer.getInstance();
if (card == null) {
this.setToolTipText(null);
skinImage = null;
}
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);
}
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);
}
}

View File

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

View File

@@ -412,7 +412,7 @@ public class VAssignDamage {
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);
lblAssignRemaining.setVisible(allHaveLethal && damageLeft > 0);
}

View File

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