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