mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
* Saved table spectator setting to preferences.
This commit is contained in:
parent
8bc3efff07
commit
9c0d0a0153
2 changed files with 36 additions and 30 deletions
|
|
@ -27,6 +27,12 @@
|
||||||
*/
|
*/
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import javax.swing.*;
|
||||||
import mage.cards.decks.importer.DeckImporterUtil;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
|
|
@ -45,13 +51,6 @@ import mage.view.GameTypeView;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -623,17 +622,22 @@ public class NewTableDialog extends MageDialog {
|
||||||
* set the table settings from java prefs
|
* set the table settings from java prefs
|
||||||
*/
|
*/
|
||||||
int currentSettingVersion = 0;
|
int currentSettingVersion = 0;
|
||||||
|
|
||||||
private void setGameSettingsFromPrefs(int version) {
|
private void setGameSettingsFromPrefs(int version) {
|
||||||
currentSettingVersion = version;
|
currentSettingVersion = version;
|
||||||
String versionStr = "";
|
String versionStr = "";
|
||||||
if (currentSettingVersion == 1) {
|
switch (currentSettingVersion) {
|
||||||
|
case 1:
|
||||||
versionStr = "1";
|
versionStr = "1";
|
||||||
btnPreviousConfiguration1.requestFocus();
|
btnPreviousConfiguration1.requestFocus();
|
||||||
} else if (currentSettingVersion == 2) {
|
break;
|
||||||
|
case 2:
|
||||||
versionStr = "2";
|
versionStr = "2";
|
||||||
btnPreviousConfiguration2.requestFocus();
|
btnPreviousConfiguration2.requestFocus();
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
btnPreviousConfiguration2.getParent().requestFocus();
|
btnPreviousConfiguration2.getParent().requestFocus();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
txtName.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NAME + versionStr, "Game"));
|
txtName.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NAME + versionStr, "Game"));
|
||||||
txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD + versionStr, ""));
|
txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD + versionStr, ""));
|
||||||
|
|
@ -724,6 +728,7 @@ public class NewTableDialog extends MageDialog {
|
||||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RANGE + versionStr, Integer.toString(options.getRange().getRange()));
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RANGE + versionStr, Integer.toString(options.getRange().getRange()));
|
||||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_ATTACK_OPTION + versionStr, options.getAttackOption().toString());
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_ATTACK_OPTION + versionStr, options.getAttackOption().toString());
|
||||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SKILL_LEVEL + versionStr, options.getSkillLevel().toString());
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SKILL_LEVEL + versionStr, options.getSkillLevel().toString());
|
||||||
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_SPECTATORS_ALLOWED + versionStr, options.isSpectatorsAllowed() ? "Yes" : "No");
|
||||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO + versionStr, Integer.toString(options.getQuitRatio()));
|
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_QUIT_RATIO + versionStr, Integer.toString(options.getQuitRatio()));
|
||||||
StringBuilder playerTypesString = new StringBuilder();
|
StringBuilder playerTypesString = new StringBuilder();
|
||||||
for (Object player : players) {
|
for (Object player : players) {
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,13 @@ package mage.client.dialog;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.cards.decks.importer.DeckImporterUtil;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.cards.repository.ExpansionInfo;
|
import mage.cards.repository.ExpansionInfo;
|
||||||
|
|
@ -589,9 +591,9 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
} else {
|
} else {
|
||||||
for (JPanel panel : packPanels) {
|
for (JPanel panel : packPanels) {
|
||||||
JComboBox combo = findComboInComponent(panel);
|
JComboBox combo = findComboInComponent(panel);
|
||||||
if(combo != null) {
|
if (combo != null) {
|
||||||
tOptions.getLimitedOptions().getSetCodes().add(((ExpansionInfo) combo.getSelectedItem()).getCode());
|
tOptions.getLimitedOptions().getSetCodes().add(((ExpansionInfo) combo.getSelectedItem()).getCode());
|
||||||
}else{
|
} else {
|
||||||
logger.error("Can't find combo component in " + panel.toString());
|
logger.error("Can't find combo component in " + panel.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -764,7 +766,6 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
this.spnNumPlayers.setModel(new SpinnerNumberModel(numPlayers, tournamentType.getMinPlayers(), tournamentType.getMaxPlayers(), 1));
|
this.spnNumPlayers.setModel(new SpinnerNumberModel(numPlayers, tournamentType.getMinPlayers(), tournamentType.getMaxPlayers(), 1));
|
||||||
this.spnNumPlayers.setEnabled(tournamentType.getMinPlayers() != tournamentType.getMaxPlayers());
|
this.spnNumPlayers.setEnabled(tournamentType.getMinPlayers() != tournamentType.getMaxPlayers());
|
||||||
createPlayers((Integer) spnNumPlayers.getValue() - 1);
|
createPlayers((Integer) spnNumPlayers.getValue() - 1);
|
||||||
|
|
||||||
this.spnNumSeats.setModel(new SpinnerNumberModel(2, 2, tournamentType.getMaxPlayers(), 1));
|
this.spnNumSeats.setModel(new SpinnerNumberModel(2, 2, tournamentType.getMaxPlayers(), 1));
|
||||||
|
|
||||||
if (tournamentType.isLimited()) {
|
if (tournamentType.isLimited()) {
|
||||||
|
|
@ -926,7 +927,7 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
|
||||||
// search combo box near button (must be only one combo in panel)
|
// search combo box near button (must be only one combo in panel)
|
||||||
JButton button = (JButton)evt.getSource();
|
JButton button = (JButton) evt.getSource();
|
||||||
JComboBox combo = findComboInComponent(button.getParent());
|
JComboBox combo = findComboInComponent(button.getParent());
|
||||||
|
|
||||||
if (combo != null) {
|
if (combo != null) {
|
||||||
|
|
@ -941,12 +942,12 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
this.repaint();
|
this.repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComboBox findComboInComponent(Container panel){
|
private JComboBox findComboInComponent(Container panel) {
|
||||||
// search combo box near button (must be only one combo in panel)
|
// search combo box near button (must be only one combo in panel)
|
||||||
JComboBox combo = null;
|
JComboBox combo = null;
|
||||||
for(Component comp: panel.getComponents()){
|
for (Component comp : panel.getComponents()) {
|
||||||
if (comp instanceof JComboBox){
|
if (comp instanceof JComboBox) {
|
||||||
combo = (JComboBox)comp;
|
combo = (JComboBox) comp;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -955,21 +956,21 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
|
|
||||||
private void packActionPerformed(java.awt.event.ActionEvent evt) {
|
private void packActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
// fill all bottom combobox with same value
|
// fill all bottom combobox with same value
|
||||||
JComboBox curentCombo = (JComboBox)evt.getSource();
|
JComboBox curentCombo = (JComboBox) evt.getSource();
|
||||||
int newValue = curentCombo.getSelectedIndex();
|
int newValue = curentCombo.getSelectedIndex();
|
||||||
|
|
||||||
// search start index
|
// search start index
|
||||||
int startIndex = 0;
|
int startIndex = 0;
|
||||||
for(int i = 0; i < packPanels.size(); i++){
|
for (int i = 0; i < packPanels.size(); i++) {
|
||||||
JComboBox pack = findComboInComponent(packPanels.get(i));
|
JComboBox pack = findComboInComponent(packPanels.get(i));
|
||||||
if (pack.equals(curentCombo)){
|
if (pack.equals(curentCombo)) {
|
||||||
startIndex = i + 1;
|
startIndex = i + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// change all from start index
|
// change all from start index
|
||||||
for(int i = startIndex; i < packPanels.size(); i++){
|
for (int i = startIndex; i < packPanels.size(); i++) {
|
||||||
JComboBox pack = findComboInComponent(packPanels.get(i));
|
JComboBox pack = findComboInComponent(packPanels.get(i));
|
||||||
pack.setSelectedIndex(newValue);
|
pack.setSelectedIndex(newValue);
|
||||||
}
|
}
|
||||||
|
|
@ -1128,7 +1129,7 @@ public class NewTournamentDialog extends MageDialog {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
logger.error("Can't find combo component in " + panel.toString());
|
logger.error("Can't find combo component in " + panel.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue