mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
* Player types - If you connect to another MAGE server, the available player types are updated now correctly. Removed some redundant update of server information in client.
This commit is contained in:
parent
27d441de0a
commit
c88eb2ead6
6 changed files with 72 additions and 42 deletions
|
@ -246,10 +246,11 @@ public class ConnectDialog extends MageDialog {
|
|||
|
||||
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
|
||||
MageFrame.getPreferences().put("autoConnect", Boolean.toString(chkAutoConnect.isSelected()));
|
||||
if (task != null && !task.isDone())
|
||||
if (task != null && !task.isDone()) {
|
||||
task.cancel(true);
|
||||
else
|
||||
} else {
|
||||
this.hideDialog();
|
||||
}
|
||||
}//GEN-LAST:event_btnCancelActionPerformed
|
||||
|
||||
private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed
|
||||
|
|
|
@ -63,18 +63,22 @@ public class NewTableDialog extends MageDialog {
|
|||
private TableView table;
|
||||
private UUID playerId;
|
||||
private UUID roomId;
|
||||
private Session session;
|
||||
private List<TablePlayerPanel> players = new ArrayList<TablePlayerPanel>();
|
||||
private List<String> prefPlayerTypes = new ArrayList<String>();
|
||||
private final Session session;
|
||||
private String lastSessionId;
|
||||
private final List<TablePlayerPanel> players = new ArrayList<>();
|
||||
private final List<String> prefPlayerTypes = new ArrayList<>();
|
||||
|
||||
private static final String LIMITED = "Limited";
|
||||
|
||||
/** Creates new form NewTableDialog */
|
||||
public NewTableDialog() {
|
||||
session = MageFrame.getSession();
|
||||
lastSessionId = "";
|
||||
initComponents();
|
||||
player1Panel.showLevel(false);
|
||||
this.spnNumWins.setModel(new SpinnerNumberModel(1, 1, 5, 1));
|
||||
this.spnFreeMulligans.setModel(new SpinnerNumberModel(0, 0, 5, 1));
|
||||
MageFrame.getUI().addButton(MageComponents.NEW_TABLE_OK_BUTTON, btnOK);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
|
@ -391,6 +395,7 @@ public class NewTableDialog extends MageDialog {
|
|||
}
|
||||
|
||||
private void createPlayers(int numPlayers) {
|
||||
// add missing player panels
|
||||
if (numPlayers > players.size()) {
|
||||
while (players.size() != numPlayers) {
|
||||
TablePlayerPanel playerPanel = new TablePlayerPanel();
|
||||
|
@ -409,7 +414,9 @@ public class NewTableDialog extends MageDialog {
|
|||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// remove player panels no longer needed
|
||||
else if (numPlayers < players.size()) {
|
||||
while (players.size() != numPlayers) {
|
||||
players.remove(players.size() - 1);
|
||||
|
@ -435,22 +442,26 @@ public class NewTableDialog extends MageDialog {
|
|||
}
|
||||
|
||||
public void showDialog(UUID roomId) {
|
||||
session = MageFrame.getSession();
|
||||
MageFrame.getUI().addButton(MageComponents.NEW_TABLE_OK_BUTTON, btnOK);
|
||||
this.player1Panel.setPlayerName(session.getUserName());
|
||||
cbGameType.setModel(new DefaultComboBoxModel(session.getGameTypes().toArray()));
|
||||
cbDeckType.setModel(new DefaultComboBoxModel(session.getDeckTypes()));
|
||||
selectLimitedByDefault();
|
||||
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
|
||||
cbRange.setModel(new DefaultComboBoxModel(RangeOfInfluence.values()));
|
||||
cbAttackOption.setModel(new DefaultComboBoxModel(MultiplayerAttackOption.values()));
|
||||
|
||||
setGameSettingsFromPrefs();
|
||||
|
||||
this.roomId = roomId;
|
||||
this.setModal(true);
|
||||
setGameOptions();
|
||||
this.setLocation(150, 100);
|
||||
this.roomId = roomId;
|
||||
if (!lastSessionId.equals(MageFrame.getSession().getSessionId())) {
|
||||
lastSessionId = session.getSessionId();
|
||||
this.player1Panel.setPlayerName(session.getUserName());
|
||||
cbGameType.setModel(new DefaultComboBoxModel(session.getGameTypes().toArray()));
|
||||
cbDeckType.setModel(new DefaultComboBoxModel(session.getDeckTypes()));
|
||||
selectLimitedByDefault();
|
||||
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
|
||||
cbRange.setModel(new DefaultComboBoxModel(RangeOfInfluence.values()));
|
||||
cbAttackOption.setModel(new DefaultComboBoxModel(MultiplayerAttackOption.values()));
|
||||
// Update the existing player panels (neccessary if server was changes = new session)
|
||||
int i=2;
|
||||
for (TablePlayerPanel tablePlayerPanel :players) {
|
||||
tablePlayerPanel.init(i++, tablePlayerPanel.getPlayerType());
|
||||
}
|
||||
setGameSettingsFromPrefs();
|
||||
this.setModal(true);
|
||||
setGameOptions();
|
||||
this.setLocation(150, 100);
|
||||
}
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ import javax.swing.SpinnerNumberModel;
|
|||
import mage.cards.repository.ExpansionInfo;
|
||||
import mage.cards.repository.ExpansionRepository;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.table.TablePlayerPanel;
|
||||
import mage.client.table.TournamentPlayerPanel;
|
||||
import mage.constants.MatchTimeLimit;
|
||||
import mage.constants.MultiplayerAttackOption;
|
||||
|
@ -71,12 +72,15 @@ public class NewTournamentDialog extends MageDialog {
|
|||
private UUID playerId;
|
||||
private UUID roomId;
|
||||
private Session session;
|
||||
private String lastSessionId;
|
||||
private final List<TournamentPlayerPanel> players = new ArrayList<>();
|
||||
private final List<JComboBox> packs = new ArrayList<>();
|
||||
|
||||
/** Creates new form NewTournamentDialog */
|
||||
public NewTournamentDialog() {
|
||||
initComponents();
|
||||
session = MageFrame.getSession();
|
||||
lastSessionId = "";
|
||||
txtName.setText("Tournament");
|
||||
this.spnNumWins.setModel(new SpinnerNumberModel(2, 1, 5, 1));
|
||||
this.spnFreeMulligans.setModel(new SpinnerNumberModel(0, 0, 5, 1));
|
||||
|
@ -86,18 +90,23 @@ public class NewTournamentDialog extends MageDialog {
|
|||
|
||||
public void showDialog(UUID roomId) {
|
||||
this.roomId = roomId;
|
||||
session = MageFrame.getSession();
|
||||
this.txtPlayer1Name.setText(session.getUserName());
|
||||
cbTournamentType.setModel(new DefaultComboBoxModel(session.getTournamentTypes().toArray()));
|
||||
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
|
||||
cbDraftCube.setModel(new DefaultComboBoxModel(session.getDraftCubes()));
|
||||
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values()));
|
||||
cbAllowSpectators.setSelected(true);
|
||||
|
||||
setTournamentSettingsFromPrefs();
|
||||
|
||||
this.setModal(true);
|
||||
this.setLocation(150, 100);
|
||||
if (!lastSessionId.equals(MageFrame.getSession().getSessionId())) {
|
||||
lastSessionId = session.getSessionId();
|
||||
this.txtPlayer1Name.setText(session.getUserName());
|
||||
cbTournamentType.setModel(new DefaultComboBoxModel(session.getTournamentTypes().toArray()));
|
||||
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
|
||||
cbDraftCube.setModel(new DefaultComboBoxModel(session.getDraftCubes()));
|
||||
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values()));
|
||||
// update player types
|
||||
int i=2;
|
||||
for (TournamentPlayerPanel tournamentPlayerPanel :players) {
|
||||
tournamentPlayerPanel.init(i++);
|
||||
}
|
||||
cbAllowSpectators.setSelected(true);
|
||||
setTournamentSettingsFromPrefs();
|
||||
this.setModal(true);
|
||||
this.setLocation(150, 100);
|
||||
}
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
|
@ -574,6 +583,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
}
|
||||
|
||||
private void createPlayers(int numPlayers) {
|
||||
// add/remove player panels
|
||||
if (numPlayers > players.size()) {
|
||||
while (players.size() != numPlayers) {
|
||||
TournamentPlayerPanel playerPanel = new TournamentPlayerPanel();
|
||||
|
|
|
@ -109,6 +109,11 @@ public class SessionImpl implements Session {
|
|||
this.client = client;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean connect(Connection connection) {
|
||||
if (isConnected()) {
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.remote.interfaces;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.remote.Connection;
|
||||
|
||||
/**
|
||||
|
@ -47,4 +48,6 @@ public interface Connect {
|
|||
boolean isConnected();
|
||||
|
||||
boolean disconnectUser(String userSessionId);
|
||||
|
||||
String getSessionId();
|
||||
}
|
||||
|
|
|
@ -35,16 +35,16 @@ import mage.game.match.MatchType;
|
|||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class GameTypeView implements Serializable {
|
||||
public class GameTypeView extends Object implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String name;
|
||||
private int minPlayers;
|
||||
private int maxPlayers;
|
||||
private int numTeams;
|
||||
private int playersPerTeam;
|
||||
private boolean useRange;
|
||||
private boolean useAttackOption;
|
||||
private final String name;
|
||||
private final int minPlayers;
|
||||
private final int maxPlayers;
|
||||
private final int numTeams;
|
||||
private final int playersPerTeam;
|
||||
private final boolean useRange;
|
||||
private final boolean useAttackOption;
|
||||
|
||||
public GameTypeView(MatchType gameType) {
|
||||
this.name = gameType.getName();
|
||||
|
|
Loading…
Reference in a new issue