mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Code cleanup
This commit is contained in:
@@ -228,23 +228,23 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addPlayer() {
|
private void addPlayer() {
|
||||||
if (activePlayersNum >= MAX_PLAYERS)
|
if (activePlayersNum >= MAX_PLAYERS) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int freeIndex = -1;
|
int freeIndex = -1;
|
||||||
for(int i = 0; i < MAX_PLAYERS; i++)
|
for (int i = 0; i < MAX_PLAYERS; i++) {
|
||||||
if (!playerPanels.get(i).isVisible()) {
|
if (!playerPanels.get(i).isVisible()) {
|
||||||
freeIndex = i;
|
freeIndex = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
playerPanels.get(freeIndex).setVisible(true);
|
playerPanels.get(freeIndex).setVisible(true);
|
||||||
|
|
||||||
activePlayersNum++;
|
activePlayersNum++;
|
||||||
addPlayerBtn.setEnabled(activePlayersNum < MAX_PLAYERS);
|
addPlayerBtn.setEnabled(activePlayersNum < MAX_PLAYERS);
|
||||||
|
|
||||||
|
|
||||||
playerPanels.get(freeIndex).setVisible(true);
|
playerPanels.get(freeIndex).setVisible(true);
|
||||||
playerPanels.get(freeIndex).focusOnAvatar();
|
playerPanels.get(freeIndex).focusOnAvatar();
|
||||||
}
|
}
|
||||||
@@ -341,9 +341,11 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
decksFrame.add(cbSingletons, strCheckboxConstraints);
|
decksFrame.add(cbSingletons, strCheckboxConstraints);
|
||||||
decksFrame.add(cbArtifacts, strCheckboxConstraints);
|
decksFrame.add(cbArtifacts, strCheckboxConstraints);
|
||||||
}
|
}
|
||||||
} else if (GameType.Planechase == forGameType) {
|
}
|
||||||
|
else if (GameType.Planechase == forGameType) {
|
||||||
decksFrame.add(planarDeckPanels.get(playerWithFocus), "grow, push");
|
decksFrame.add(planarDeckPanels.get(playerWithFocus), "grow, push");
|
||||||
} else if (GameType.Vanguard == forGameType) {
|
}
|
||||||
|
else if (GameType.Vanguard == forGameType) {
|
||||||
updateVanguardList(playerWithFocus);
|
updateVanguardList(playerWithFocus);
|
||||||
decksFrame.add(vgdPanels.get(playerWithFocus), "grow, push");
|
decksFrame.add(vgdPanels.get(playerWithFocus), "grow, push");
|
||||||
}
|
}
|
||||||
@@ -362,7 +364,6 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
return deckChoosers.get(playernum);
|
return deckChoosers.get(playernum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see forge.gui.home.IVSubmenu#getMenuTitle()
|
* @see forge.gui.home.IVSubmenu#getMenuTitle()
|
||||||
*/
|
*/
|
||||||
@@ -433,9 +434,10 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
public final List<Integer> getParticipants() {
|
public final List<Integer> getParticipants() {
|
||||||
final List<Integer> participants = new ArrayList<Integer>(activePlayersNum);
|
final List<Integer> participants = new ArrayList<Integer>(activePlayersNum);
|
||||||
for (final PlayerPanel panel : playerPanels) {
|
for (final PlayerPanel panel : playerPanels) {
|
||||||
if(panel.isVisible())
|
if (panel.isVisible()) {
|
||||||
participants.add(playerPanels.indexOf(panel));
|
participants.add(playerPanels.indexOf(panel));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return participants;
|
return participants;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,7 +465,6 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
private FRadioButton radioHuman;
|
private FRadioButton radioHuman;
|
||||||
private FRadioButton radioAi;
|
private FRadioButton radioAi;
|
||||||
|
|
||||||
|
|
||||||
private final FLabel deckBtn = new FLabel.ButtonBuilder().text("Select a deck").build();
|
private final FLabel deckBtn = new FLabel.ButtonBuilder().text("Select a deck").build();
|
||||||
|
|
||||||
private final String variantBtnConstraints = "height 30px, hidemode 3";
|
private final String variantBtnConstraints = "height 30px, hidemode 3";
|
||||||
@@ -475,8 +476,6 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
private final FLabel vgdSelectorBtn = new FLabel.ButtonBuilder().text("Select a Vanguard avatar").build();
|
private final FLabel vgdSelectorBtn = new FLabel.ButtonBuilder().text("Select a Vanguard avatar").build();
|
||||||
private final FLabel vgdLabel = newLabel("Vanguard:");
|
private final FLabel vgdLabel = newLabel("Vanguard:");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public PlayerPanel(final int index) {
|
public PlayerPanel(final int index) {
|
||||||
super();
|
super();
|
||||||
this.index = index;
|
this.index = index;
|
||||||
@@ -527,7 +526,6 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** Listens to name text fields and gives the appropriate player focus.
|
/** Listens to name text fields and gives the appropriate player focus.
|
||||||
* Also saves the name preference when leaving player one's text field. */
|
* Also saves the name preference when leaving player one's text field. */
|
||||||
private FocusAdapter nameFocusListener = new FocusAdapter() {
|
private FocusAdapter nameFocusListener = new FocusAdapter() {
|
||||||
@@ -559,7 +557,6 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private FMouseAdapter avatarMouseListener = new FMouseAdapter() {
|
private FMouseAdapter avatarMouseListener = new FMouseAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void onLeftClick(MouseEvent e) {
|
public void onLeftClick(MouseEvent e) {
|
||||||
@@ -582,9 +579,10 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
aSel.setVisible(true);
|
aSel.setVisible(true);
|
||||||
aSel.dispose();
|
aSel.dispose();
|
||||||
|
|
||||||
if (index < 2)
|
if (index < 2) {
|
||||||
updateAvatarPrefs();
|
updateAvatarPrefs();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onRightClick(MouseEvent e) {
|
public void onRightClick(MouseEvent e) {
|
||||||
changePlayerFocus(index);
|
changePlayerFocus(index);
|
||||||
@@ -592,12 +590,12 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
|
|
||||||
setRandomAvatar();
|
setRandomAvatar();
|
||||||
|
|
||||||
if (index < 2)
|
if (index < 2) {
|
||||||
updateAvatarPrefs();
|
updateAvatarPrefs();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public void updateVariantControlsVisibility() {
|
public void updateVariantControlsVisibility() {
|
||||||
pchDeckSelectorBtn.setVisible(appliedVariants.contains(GameType.Planechase));
|
pchDeckSelectorBtn.setVisible(appliedVariants.contains(GameType.Planechase));
|
||||||
pchDeckEditor.setVisible(appliedVariants.contains(GameType.Planechase));
|
pchDeckEditor.setVisible(appliedVariants.contains(GameType.Planechase));
|
||||||
@@ -628,10 +626,8 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
deckBtn.setText(text);
|
deckBtn.setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void focusOnAvatar() {
|
public void focusOnAvatar() {
|
||||||
avatarLabel.requestFocusInWindow();
|
avatarLabel.requestFocusInWindow();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -717,9 +713,9 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String newName = getNewName();
|
String newName = getNewName();
|
||||||
if ( null == newName )
|
if (null == newName) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
txtPlayerName.setText(newName);
|
txtPlayerName.setText(newName);
|
||||||
|
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
@@ -745,7 +741,8 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
name = "Human";
|
name = "Human";
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
name = NameGenerator.getRandomName("Any", "Any", getPlayerNames());
|
name = NameGenerator.getRandomName("Any", "Any", getPlayerNames());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -769,13 +766,13 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
return closeBtn;
|
return closeBtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void createAvatar() {
|
private void createAvatar() {
|
||||||
String[] currentPrefs = Singletons.getModel().getPreferences().getPref(FPref.UI_AVATARS).split(",");
|
String[] currentPrefs = Singletons.getModel().getPreferences().getPref(FPref.UI_AVATARS).split(",");
|
||||||
if (index < currentPrefs.length) {
|
if (index < currentPrefs.length) {
|
||||||
avatarIndex = Integer.parseInt(currentPrefs[index]);
|
avatarIndex = Integer.parseInt(currentPrefs[index]);
|
||||||
avatarLabel.setIcon(FSkin.getAvatars().get(avatarIndex));
|
avatarLabel.setIcon(FSkin.getAvatars().get(avatarIndex));
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
setRandomAvatar();
|
setRandomAvatar();
|
||||||
}
|
}
|
||||||
this.addMouseListener(new FMouseAdapter() {
|
this.addMouseListener(new FMouseAdapter() {
|
||||||
@@ -828,7 +825,6 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
public String getPlayerName() {
|
public String getPlayerName() {
|
||||||
return txtPlayerName.getText();
|
return txtPlayerName.getText();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changePlayerFocus(int newFocusOwner) {
|
private void changePlayerFocus(int newFocusOwner) {
|
||||||
@@ -901,17 +897,18 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
final String[] typeOptions = new String[]{ "Fantasy", "Generic", "Any" };
|
final String[] typeOptions = new String[]{ "Fantasy", "Generic", "Any" };
|
||||||
|
|
||||||
final int genderIndex = FOptionPane.showOptionDialog(message, title, icon, genderOptions, 2);
|
final int genderIndex = FOptionPane.showOptionDialog(message, title, icon, genderOptions, 2);
|
||||||
if ( genderIndex < 0 )
|
if (genderIndex < 0) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
final int typeIndex = FOptionPane.showOptionDialog(message, title, icon, typeOptions, 2);
|
final int typeIndex = FOptionPane.showOptionDialog(message, title, icon, typeOptions, 2);
|
||||||
if ( typeIndex < 0 )
|
if (typeIndex < 0) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
final String gender = genderOptions[genderIndex];
|
final String gender = genderOptions[genderIndex];
|
||||||
final String type = typeOptions[typeIndex];
|
final String type = typeOptions[typeIndex];
|
||||||
|
|
||||||
String confirmMsg;
|
String confirmMsg, newName;
|
||||||
String newName;
|
|
||||||
|
|
||||||
List<String> usedNames = getPlayerNames();
|
List<String> usedNames = getPlayerNames();
|
||||||
do {
|
do {
|
||||||
newName = NameGenerator.getRandomName(gender, type, usedNames);
|
newName = NameGenerator.getRandomName(gender, type, usedNames);
|
||||||
@@ -940,12 +937,15 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
FCheckBox cb = (FCheckBox) arg0.getSource();
|
FCheckBox cb = (FCheckBox) arg0.getSource();
|
||||||
GameType variantType = null;
|
GameType variantType = null;
|
||||||
|
|
||||||
if (cb == vntVanguard)
|
if (cb == vntVanguard) {
|
||||||
variantType = GameType.Vanguard;
|
variantType = GameType.Vanguard;
|
||||||
else if (cb == vntCommander)
|
}
|
||||||
|
else if (cb == vntCommander) {
|
||||||
variantType = GameType.Commander;
|
variantType = GameType.Commander;
|
||||||
else if (cb == vntPlanechase)
|
}
|
||||||
|
else if (cb == vntPlanechase) {
|
||||||
variantType = GameType.Planechase;
|
variantType = GameType.Planechase;
|
||||||
|
}
|
||||||
else if (cb == vntArchenemy) {
|
else if (cb == vntArchenemy) {
|
||||||
variantType = archenemyType.contains("Classic") ? GameType.Archenemy : GameType.ArchenemyRumble;
|
variantType = archenemyType.contains("Classic") ? GameType.Archenemy : GameType.ArchenemyRumble;
|
||||||
comboArchenemy.setEnabled(vntArchenemy.isSelected());
|
comboArchenemy.setEnabled(vntArchenemy.isSelected());
|
||||||
@@ -959,7 +959,8 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
if (arg0.getStateChange() == ItemEvent.SELECTED) {
|
if (arg0.getStateChange() == ItemEvent.SELECTED) {
|
||||||
appliedVariants.add(variantType);
|
appliedVariants.add(variantType);
|
||||||
currentGameMode = variantType;
|
currentGameMode = variantType;
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
appliedVariants.remove(variantType);
|
appliedVariants.remove(variantType);
|
||||||
if (currentGameMode == variantType) {
|
if (currentGameMode == variantType) {
|
||||||
currentGameMode = GameType.Constructed;
|
currentGameMode = GameType.Constructed;
|
||||||
@@ -988,7 +989,6 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private ActionListener nameListener = new ActionListener() {
|
private ActionListener nameListener = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
@@ -1013,7 +1013,8 @@ public enum VSubmenuConstructed implements IVSubmenu<CSubmenuConstructed> {
|
|||||||
cdp.setCard(Card.getCardForUi((PaperCard) obj));
|
cdp.setCard(Card.getCardForUi((PaperCard) obj));
|
||||||
cdp.setVisible(true);
|
cdp.setVisible(true);
|
||||||
refreshPanels(false, true);
|
refreshPanels(false, true);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
pp.setVanguardButtonText((String) obj);
|
pp.setVanguardButtonText((String) obj);
|
||||||
cdp.setVisible(false);
|
cdp.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user