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