mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
small changes: FControl has getPlayer(), CMatchUI has iteration over list, return types of label getters improved
This commit is contained in:
@@ -34,6 +34,7 @@ import javax.swing.WindowConstants;
|
||||
import forge.AllZone;
|
||||
import forge.Singletons;
|
||||
import forge.control.KeyboardShortcuts.Shortcut;
|
||||
import forge.game.player.Player;
|
||||
import forge.gui.deckeditor.CDeckEditorUI;
|
||||
import forge.gui.deckeditor.VDeckEditorUI;
|
||||
import forge.gui.framework.SOverflowUtil;
|
||||
@@ -269,4 +270,8 @@ public enum FControl {
|
||||
children = display.getComponentsInLayer(JLayeredPane.MODAL_LAYER);
|
||||
if (children.length != 0) { children[0].setSize(display.getSize()); }
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return AllZone.getHumanPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,8 +70,8 @@ public enum CMatchUI implements CardContainer {
|
||||
|
||||
// Update avatars
|
||||
final String[] indices = Singletons.getModel().getPreferences().getPref(FPref.UI_AVATARS).split(",");
|
||||
final Object[] views = VMatchUI.SINGLETON_INSTANCE.getFieldViews().toArray();
|
||||
for (int i = 0; i < views.length; i++) {
|
||||
int i = 0;
|
||||
for (VField view : VMatchUI.SINGLETON_INSTANCE.getFieldViews()) {
|
||||
final Image img;
|
||||
// Update AI quest icon
|
||||
if (i != 1 && Singletons.getModel().getMatchState().getGameType() == GameType.Quest) {
|
||||
@@ -91,9 +91,10 @@ public enum CMatchUI implements CardContainer {
|
||||
else {
|
||||
img = FSkin.getAvatars().get(Integer.parseInt(indices[i]));
|
||||
}
|
||||
i++;
|
||||
|
||||
((VField) views[i]).getLblAvatar().setIcon(new ImageIcon(img));
|
||||
((FLabel) ((VField) views[i]).getLblAvatar()).getResizeTimer().start();
|
||||
view.getLblAvatar().setIcon(new ImageIcon(img));
|
||||
view.getLblAvatar().getResizeTimer().start();
|
||||
}
|
||||
|
||||
// Update observers
|
||||
|
||||
@@ -19,14 +19,11 @@ package forge.gui.match.controllers;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SwingWorker;
|
||||
@@ -43,7 +40,6 @@ import forge.game.phase.PhaseHandler;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.ForgeAction;
|
||||
import forge.gui.SOverlayUtils;
|
||||
import forge.gui.framework.ICDoc;
|
||||
import forge.gui.framework.SLayoutIO;
|
||||
@@ -55,7 +51,6 @@ import forge.gui.toolbox.SaveOpenDialog.Filetypes;
|
||||
import forge.item.CardPrinted;
|
||||
import forge.model.FModel;
|
||||
import forge.properties.ForgePreferences.FPref;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.view.FView;
|
||||
|
||||
/**
|
||||
@@ -142,7 +137,7 @@ public enum CDock implements ICDoc {
|
||||
* View deck list.
|
||||
*/
|
||||
private void viewDeckList() {
|
||||
new DeckListAction(NewConstants.Lang.GuiDisplay.HUMAN_DECKLIST).actionPerformed(null);
|
||||
showDeck(AllZone.getHumanPlayer().getDeck());
|
||||
}
|
||||
|
||||
/** Attack with everyone. */
|
||||
@@ -182,26 +177,12 @@ public enum CDock implements ICDoc {
|
||||
* (typically used in dev mode). Allows copy of the cardlist to clipboard.
|
||||
*
|
||||
*/
|
||||
private class DeckListAction extends ForgeAction {
|
||||
public DeckListAction(final String property) {
|
||||
super(property);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 9874492387239847L;
|
||||
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
Deck targetDeck;
|
||||
|
||||
if (!AllZone.getHumanPlayer().getDeck().getMain().isEmpty()) {
|
||||
targetDeck = AllZone.getHumanPlayer().getDeck();
|
||||
} else if (!AllZone.getComputerPlayer().getDeck().getMain().isEmpty()) {
|
||||
targetDeck = AllZone.getComputerPlayer().getDeck();
|
||||
} else {
|
||||
private final void showDeck(Deck targetDeck) {
|
||||
if ( null == targetDeck ) {
|
||||
return;
|
||||
}
|
||||
|
||||
final HashMap<String, Integer> deckMap = new HashMap<String, Integer>();
|
||||
final TreeMap<String, Integer> deckMap = new TreeMap<String, Integer>();
|
||||
|
||||
for (final Entry<CardPrinted, Integer> s : targetDeck.getMain()) {
|
||||
deckMap.put(s.getKey().getName(), s.getValue());
|
||||
@@ -211,26 +192,17 @@ public enum CDock implements ICDoc {
|
||||
final StringBuilder deckList = new StringBuilder();
|
||||
String dName = targetDeck.getName();
|
||||
|
||||
if (dName == null) {
|
||||
dName = "";
|
||||
} else {
|
||||
if (dName != null) {
|
||||
deckList.append(dName + nl);
|
||||
}
|
||||
|
||||
final ArrayList<String> dmKeys = new ArrayList<String>();
|
||||
for (final String s : deckMap.keySet()) {
|
||||
dmKeys.add(s);
|
||||
}
|
||||
|
||||
Collections.sort(dmKeys);
|
||||
|
||||
for (final String s : dmKeys) {
|
||||
deckList.append(deckMap.get(s) + " x " + s + nl);
|
||||
for (final Entry<String, Integer> s : deckMap.entrySet()) {
|
||||
deckList.append(s.getValue() + " x " + s.getKey() + nl);
|
||||
}
|
||||
|
||||
int rcMsg = -1138;
|
||||
String ttl = "Human's Decklist";
|
||||
if (!dName.equals("")) {
|
||||
if (dName != null) {
|
||||
ttl += " - " + dName;
|
||||
}
|
||||
|
||||
@@ -250,7 +222,7 @@ public enum CDock implements ICDoc {
|
||||
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
|
||||
}
|
||||
}
|
||||
} // End DeckListAction
|
||||
// End DeckListAction
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see forge.gui.framework.ICDoc#getCommandOnSelect()
|
||||
|
||||
@@ -72,9 +72,9 @@ public class VField implements IVDoc {
|
||||
private final JPanel pnlDetails = new JPanel();
|
||||
|
||||
// Avatar area
|
||||
private final JLabel lblAvatar = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
|
||||
private final FLabel lblAvatar = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
|
||||
.iconScaleFactor(1.0f).build();
|
||||
private final JLabel lblLife = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
|
||||
private final FLabel lblLife = new FLabel.Builder().fontAlign(SwingConstants.CENTER)
|
||||
.fontStyle(Font.BOLD).build();
|
||||
|
||||
// Info labels
|
||||
@@ -408,12 +408,12 @@ public class VField implements IVDoc {
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JLabel} */
|
||||
public JLabel getLblAvatar() {
|
||||
public FLabel getLblAvatar() {
|
||||
return this.lblAvatar;
|
||||
}
|
||||
|
||||
/** @return {@link javax.swing.JLabel} */
|
||||
public JLabel getLblLife() {
|
||||
public FLabel getLblLife() {
|
||||
return this.lblLife;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user