Code cleanup (removed outdated client's config.properties settings)

This commit is contained in:
Oleg Agafonov 2020-01-26 15:19:22 +04:00
parent 3510ac0957
commit b56587a383
22 changed files with 92 additions and 175 deletions

View file

@ -1315,7 +1315,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (startPort > 0) {
instance.currentConnection.setPort(startPort);
} else {
instance.currentConnection.setPort(MagePreferences.getServerPortWithDefault(Config.port));
instance.currentConnection.setPort(MagePreferences.getServerPortWithDefault(ClientDefaultSettings.port));
}
PreferencesDialog.setProxyInformation(instance.currentConnection);
instance.currentConnection.setPassword(startPassword);

View file

@ -7,7 +7,7 @@ import mage.cards.TextPopup;
import mage.cards.action.ActionCallback;
import mage.client.MageFrame;
import mage.client.game.PlayAreaPanel;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.DefaultActionCallback;
import mage.client.util.ImageHelper;
import mage.client.util.gui.ArrowBuilder;
@ -68,7 +68,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
this.gameId = gameId;
this.card = card;
this.bigCard = bigCard;
small = new BufferedImage(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight(), BufferedImage.TYPE_INT_RGB);
small = new BufferedImage(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight(), BufferedImage.TYPE_INT_RGB);
backgroundName = getBackgroundName();
background = ImageHelper.getBackground(card, backgroundName);
@ -120,7 +120,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gSmall.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
gSmall.setColor(Color.BLACK);
gSmall.drawImage(ImageHelper.scaleImage(image, Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight()), 0, 0, this);
gSmall.drawImage(ImageHelper.scaleImage(image, ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight()), 0, 0, this);
gImage.setFont(new Font("Arial", Font.PLAIN, NAME_FONT_MAX_SIZE));
gImage.drawString(card.getName() + "TEST", CONTENT_MAX_XOFFSET, NAME_MAX_YOFFSET);
@ -136,16 +136,16 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
gImage.dispose();
gSmall.setFont(new Font("Arial", Font.PLAIN, Config.dimensions.getNameFontSize()));
gSmall.drawString(card.getName() + "TEST2", Config.dimensions.getContentXOffset(), Config.dimensions.getNameYOffset());
gSmall.setFont(new Font("Arial", Font.PLAIN, ClientDefaultSettings.dimensions.getNameFontSize()));
gSmall.drawString(card.getName() + "TEST2", ClientDefaultSettings.dimensions.getContentXOffset(), ClientDefaultSettings.dimensions.getNameYOffset());
if (card.isCreature()) {
gSmall.drawString(card.getPower() + "/-/" + card.getToughness(), Config.dimensions.getPowBoxTextLeft(), Config.dimensions.getPowBoxTextTop());
gSmall.drawString(card.getPower() + "/-/" + card.getToughness(), ClientDefaultSettings.dimensions.getPowBoxTextLeft(), ClientDefaultSettings.dimensions.getPowBoxTextTop());
} else if (card.isPlanesWalker()) {
gSmall.drawString(card.getLoyalty(), Config.dimensions.getPowBoxTextLeft(), Config.dimensions.getPowBoxTextTop());
gSmall.drawString(card.getLoyalty(), ClientDefaultSettings.dimensions.getPowBoxTextLeft(), ClientDefaultSettings.dimensions.getPowBoxTextTop());
}
if (!card.getCardTypes().isEmpty()) {
gSmall.drawString(cardType, Config.dimensions.getContentXOffset(), Config.dimensions.getTypeYOffset());
gSmall.drawString(cardType, ClientDefaultSettings.dimensions.getContentXOffset(), ClientDefaultSettings.dimensions.getTypeYOffset());
}
drawText();
@ -346,11 +346,11 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
tooltipPopup.hide();
}
PopupFactory factory = PopupFactory.getSharedInstance();
tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + Config.dimensions.getFrameWidth(), (int) this.getLocationOnScreen().getY() + 40);
tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + ClientDefaultSettings.dimensions.getFrameWidth(), (int) this.getLocationOnScreen().getY() + 40);
tooltipPopup.show();
//hack to get tooltipPopup to resize to fit text
tooltipPopup.hide();
tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + Config.dimensions.getFrameWidth(), (int) this.getLocationOnScreen().getY() + 40);
tooltipPopup = factory.getPopup(this, tooltipText, (int) this.getLocationOnScreen().getX() + ClientDefaultSettings.dimensions.getFrameWidth(), (int) this.getLocationOnScreen().getY() + 40);
tooltipPopup.show();
tooltipShowing = true;

View file

@ -11,7 +11,7 @@
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins;
import mage.client.util.CardsViewUtil;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.GUISizeHelper;
import mage.view.*;
import org.apache.log4j.Logger;
@ -212,7 +212,7 @@
private Dimension getCardDimension() {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
}
return cardDimension;
}

View file

@ -11,7 +11,7 @@ package mage.client.cards;
import mage.cards.CardDimensions;
import mage.cards.MagePermanent;
import mage.cards.Sets;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.TransformedImageCache;
import mage.view.CounterView;
import mage.view.PermanentView;
@ -49,7 +49,7 @@ public class Permanent extends Card {
super(permanent, bigCard, dimensions, gameId);
this.setSize(this.getPreferredSize());
this.permanent = permanent;
tappedImage = new BufferedImage(Config.dimensions.getFrameHeight(), Config.dimensions.getFrameWidth(), BufferedImage.TYPE_INT_RGB);
tappedImage = new BufferedImage(ClientDefaultSettings.dimensions.getFrameHeight(), ClientDefaultSettings.dimensions.getFrameWidth(), BufferedImage.TYPE_INT_RGB);
}
public UUID getPermanentId() {
@ -173,10 +173,10 @@ public class Permanent extends Card {
g2.setColor(Color.BLACK);
}
if (permanent.isTapped()) {
g2.drawRect(0, 0, Config.dimensions.getFrameHeight() - 1, Config.dimensions.getFrameWidth() - 1);
g2.drawRect(0, 0, ClientDefaultSettings.dimensions.getFrameHeight() - 1, ClientDefaultSettings.dimensions.getFrameWidth() - 1);
}
else {
g2.drawRect(0, 0, Config.dimensions.getFrameWidth() - 1, Config.dimensions.getFrameHeight() - 1);
g2.drawRect(0, 0, ClientDefaultSettings.dimensions.getFrameWidth() - 1, ClientDefaultSettings.dimensions.getFrameHeight() - 1);
}
}
@ -206,10 +206,10 @@ public class Permanent extends Card {
@Override
public Dimension getPreferredSize() {
if (permanent != null && permanent.isTapped()) {
return new Dimension(Config.dimensions.getFrameHeight(), Config.dimensions.getFrameWidth());
return new Dimension(ClientDefaultSettings.dimensions.getFrameHeight(), ClientDefaultSettings.dimensions.getFrameWidth());
}
else {
return new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
return new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
}
}
@ -229,7 +229,7 @@ public class Permanent extends Card {
tooltipPopup.hide();
}
PopupFactory factory = PopupFactory.getSharedInstance();
int x = (int) this.getLocationOnScreen().getX() + (permanent.isTapped()? Config.dimensions.getFrameHeight() : Config.dimensions.getFrameWidth());
int x = (int) this.getLocationOnScreen().getX() + (permanent.isTapped()? ClientDefaultSettings.dimensions.getFrameHeight() : ClientDefaultSettings.dimensions.getFrameWidth());
int y = (int) this.getLocationOnScreen().getY() + 40;
tooltipPopup = factory.getPopup(this, tooltipText, x, y);
tooltipPopup.show();

View file

@ -1,7 +1,7 @@
package mage.client.components.ext.dlg;
import mage.client.components.ImageButton;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import org.jdesktop.swingx.JXPanel;
import javax.swing.*;
@ -71,7 +71,7 @@ public abstract class IDialogPanel extends JXPanel {
protected Dimension getCardDimension() {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
}
return cardDimension;
}

View file

@ -10,7 +10,7 @@ import mage.client.cards.BigCard;
import mage.client.components.HoverButton;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.ImageHelper;
import mage.client.util.NaturalOrderCardNumberComparator;
import mage.client.util.audio.AudioManager;
@ -405,7 +405,7 @@ public class MageBook extends JComponent {
private void addCard(CardView card, BigCard bigCard, UUID gameId, Rectangle rectangle) {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
}
final MageCard cardImg = Plugins.instance.getMageCard(card, bigCard, cardDimension, gameId, true, true, PreferencesDialog.getRenderMode(), true);
cardImg.setBounds(rectangle);
@ -442,7 +442,7 @@ public class MageBook extends JComponent {
private void addToken(Token token, BigCard bigCard, UUID gameId, Rectangle rectangle) {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
}
PermanentToken newToken = new PermanentToken(token, null, token.getOriginalExpansionSetCode(), null);
newToken.removeSummoningSickness();

View file

@ -7,7 +7,7 @@ import mage.client.cards.ICardGrid;
import mage.client.deckeditor.SortSetting;
import mage.client.plugins.impl.Plugins;
import mage.client.util.ClientEventType;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.Event;
import mage.client.util.Listener;
import mage.client.util.gui.GuiDisplayUtil;
@ -249,8 +249,8 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.getFrameWidth(),
Config.dimensions.getFrameHeight());
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(),
ClientDefaultSettings.dimensions.getFrameHeight());
}
cards.put(card.getId(), card);

View file

@ -6,7 +6,7 @@ import mage.choices.ChoiceImpl;
import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.preference.MagePreferences;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.gui.countryBox.CountryItemEditor;
import mage.client.util.sets.ConstructedFormats;
import mage.remote.Connection;
@ -59,9 +59,9 @@ public class ConnectDialog extends MageDialog {
}
public void showDialog() {
String serverAddress = MagePreferences.getServerAddressWithDefault(Config.serverName);
String serverAddress = MagePreferences.getServerAddressWithDefault(ClientDefaultSettings.serverName);
this.txtServer.setText(serverAddress);
this.txtPort.setText(Integer.toString(MagePreferences.getServerPortWithDefault(Config.port)));
this.txtPort.setText(Integer.toString(MagePreferences.getServerPortWithDefault(ClientDefaultSettings.port)));
this.txtUserName.setText(MagePreferences.getUserName(serverAddress));
this.txtPassword.setText(MagePreferences.getPassword(serverAddress));
this.chkAutoConnect.setSelected(Boolean.parseBoolean(MageFrame.getPreferences().get(KEY_CONNECT_AUTO_CONNECT, "false")));
@ -512,9 +512,9 @@ public class ConnectDialog extends MageDialog {
return;
}
// txtPassword is not checked here, because authentication might be disabled by the server config.
if (Integer.valueOf(txtPort.getText()) < 1 || Integer.valueOf(txtPort.getText()) > 65535) {
if (Integer.parseInt(txtPort.getText()) < 1 || Integer.parseInt(txtPort.getText()) > 65535) {
JOptionPane.showMessageDialog(rootPane, "Invalid port number");
txtPort.setText(Integer.toString(MagePreferences.getServerPortWithDefault(Config.port)));
txtPort.setText(Integer.toString(MagePreferences.getServerPortWithDefault(ClientDefaultSettings.port)));
return;
}
@ -522,7 +522,7 @@ public class ConnectDialog extends MageDialog {
try {
connection = new Connection();
connection.setHost(this.txtServer.getText().trim());
connection.setPort(Integer.valueOf(this.txtPort.getText().trim()));
connection.setPort(Integer.parseInt(this.txtPort.getText().trim()));
connection.setUsername(this.txtUserName.getText().trim());
connection.setPassword(String.valueOf(this.txtPassword.getPassword()).trim());
connection.setForceDBComparison(this.chkForceUpdateDB.isSelected() || RepositoryUtil.isDatabaseEmpty());

View file

@ -4,7 +4,7 @@ import mage.client.MageFrame;
import mage.client.SessionHandler;
import mage.client.components.KeyBindButton;
import mage.client.util.CardLanguage;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.GUISizeHelper;
import mage.client.util.ImageHelper;
import mage.client.util.gui.BufferedImageBuilder;
@ -3475,8 +3475,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
private static void loadProxySettings(Preferences prefs) {
dialog.cbProxyType.setSelectedItem(Connection.ProxyType.valueOf(MageFrame.getPreferences().get(KEY_PROXY_TYPE, "NONE").toUpperCase(Locale.ENGLISH)));
load(prefs, dialog.txtProxyServer, KEY_PROXY_ADDRESS, Config.serverName);
load(prefs, dialog.txtProxyPort, KEY_PROXY_PORT, Integer.toString(Config.port));
load(prefs, dialog.txtProxyServer, KEY_PROXY_ADDRESS, ClientDefaultSettings.serverName);
load(prefs, dialog.txtProxyPort, KEY_PROXY_PORT, Integer.toString(ClientDefaultSettings.port));
load(prefs, dialog.txtProxyUserName, KEY_PROXY_USERNAME, "");
load(prefs, dialog.rememberPswd, KEY_PROXY_REMEMBER, "true", "false");
if (dialog.rememberPswd.isSelected()) {

View file

@ -12,7 +12,7 @@
import mage.client.cards.Permanent;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.impl.Plugins;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.GUISizeHelper;
import mage.client.util.audio.AudioManager;
import mage.client.util.layout.CardLayoutStrategy;
@ -226,7 +226,7 @@
private void addPermanent(PermanentView permanent, final int count) {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.getFrameWidth(), Config.dimensions.getFrameHeight());
cardDimension = new Dimension(ClientDefaultSettings.dimensions.getFrameWidth(), ClientDefaultSettings.dimensions.getFrameHeight());
}
final MagePermanent perm = Plugins.instance.getMagePermanent(permanent, bigCard, cardDimension, gameId, true, PreferencesDialog.getRenderMode(), true);

View file

@ -10,7 +10,7 @@ import mage.client.cards.Permanent;
import mage.client.dialog.PreferencesDialog;
import mage.client.plugins.MagePlugins;
import mage.client.plugins.adapters.MageActionCallback;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.interfaces.PluginException;
import mage.interfaces.plugin.CardPlugin;
import mage.interfaces.plugin.CounterPlugin;
@ -99,7 +99,7 @@ public enum Plugins implements MagePlugins {
mageActionCallback.setCardPreviewComponent(bigCard);
return cardPlugin.getMagePermanent(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage, renderMode, needFullPermanentRender);
} else {
return new Permanent(card, bigCard, Config.dimensions, gameId);
return new Permanent(card, bigCard, ClientDefaultSettings.dimensions, gameId);
}
}
@ -112,7 +112,7 @@ public enum Plugins implements MagePlugins {
}
return cardPlugin.getMageCard(card, dimension, gameId, mageActionCallback, false, !MageFrame.isLite() && loadImage, renderMode, needFullPermanentRender);
} else {
return new Card(card, bigCard, Config.dimensions, gameId);
return new Card(card, bigCard, ClientDefaultSettings.dimensions, gameId);
}
}

View file

@ -2,7 +2,7 @@ package mage.client.preference;
import com.google.common.collect.Sets;
import mage.client.MageFrame;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import java.util.Set;
import java.util.prefs.BackingStoreException;
@ -144,8 +144,8 @@ public final class MagePreferences {
}
public static void saveLastServer() {
lastServerAddress = getServerAddressWithDefault(Config.serverName);
lastServerPort = getServerPortWithDefault(Config.port);
lastServerAddress = getServerAddressWithDefault(ClientDefaultSettings.serverName);
lastServerPort = getServerPortWithDefault(ClientDefaultSettings.port);
lastServerUser = getUserName(lastServerAddress);
lastServerPassword = getPassword(lastServerAddress);
}

View file

@ -9,14 +9,12 @@ package mage.client.table;
import java.io.File;
import java.io.IOException;
import java.util.Locale;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import mage.cards.decks.DeckFileFilter;
import mage.client.MageFrame;
import mage.client.deck.generator.DeckGenerator;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
/**
*
@ -36,14 +34,10 @@ public class NewPlayerPanel extends javax.swing.JPanel {
fcSelectDeck.addChoosableFileFilter(new DeckFileFilter("dck", "XMage's deck files (*.dck)"));
String deckPath = MageFrame.getPreferences().get("defaultDeckPath", "");
if (deckPath.isEmpty()) {
if (Config.defaultDeckPath != null) {
deckPath = Config.defaultDeckPath;
}
deckPath = ClientDefaultSettings.deckPath;
}
this.txtPlayerDeck.setText(deckPath);
if (Config.defaultComputerName != null) {
this.txtPlayerName.setText(Config.defaultComputerName);
}
this.txtPlayerName.setText(ClientDefaultSettings.computerName);
}
public void setPlayerName(String playerName) {

View file

@ -10,7 +10,7 @@ package mage.client.table;
import mage.cards.decks.importer.DeckImporter;
import mage.client.SessionHandler;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.Event;
import mage.client.util.Listener;
import mage.players.PlayerType;
@ -38,11 +38,11 @@ public class TablePlayerPanel extends javax.swing.JPanel {
public void init(int playerNum, PlayerType playerType) {
cbPlayerType.setModel(new DefaultComboBoxModel(SessionHandler.getPlayerTypes()));
this.lblPlayerNum.setText("Player " + playerNum);
if (Config.defaultOtherPlayerIndex != null) {
if (Integer.valueOf(Config.defaultOtherPlayerIndex) >= cbPlayerType.getItemCount()) {
if (ClientDefaultSettings.otherPlayerIndex != null) {
Integer index = Integer.parseInt(ClientDefaultSettings.otherPlayerIndex);
if (index >= cbPlayerType.getItemCount()) {
cbPlayerType.setSelectedIndex(cbPlayerType.getItemCount() - 1);
} else {
Integer index = Integer.parseInt(Config.defaultOtherPlayerIndex);
cbPlayerType.setSelectedIndex(index);
}
}

View file

@ -10,7 +10,7 @@ package mage.client.unusedFiles;
//package mage.client.game;
import java.util.UUID;
import mage.client.cards.BigCard;
import mage.client.util.Config;
import mage.client.util.ClientDefaultSettings;
import mage.client.util.GUISizeHelper;
import mage.view.CombatGroupView;
@ -61,9 +61,9 @@ public class CombatGroup extends javax.swing.JPanel {
attackers = new mage.client.cards.Cards();
lblDefender = new javax.swing.JLabel();
blockers.setPreferredSize(new java.awt.Dimension(Config.dimensions.getFrameWidth() + 8, Config.dimensions.getFrameHeight() + 25));
blockers.setPreferredSize(new java.awt.Dimension(ClientDefaultSettings.dimensions.getFrameWidth() + 8, ClientDefaultSettings.dimensions.getFrameHeight() + 25));
attackers.setPreferredSize(new java.awt.Dimension(Config.dimensions.getFrameWidth() + 8, Config.dimensions.getFrameHeight() + 25));
attackers.setPreferredSize(new java.awt.Dimension(ClientDefaultSettings.dimensions.getFrameWidth() + 8, ClientDefaultSettings.dimensions.getFrameHeight() + 25));
lblDefender.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
lblDefender.setText("Defender");

View file

@ -0,0 +1,35 @@
package mage.client.util;
import mage.cards.CardDimensions;
/**
* @author JayDi85
*/
public final class ClientDefaultSettings {
public static final String serverName;
public static final int port;
public static final double cardScalingFactor;
public static final double cardScalingFactorEnlarged;
public static final double handScalingFactor;
public static final CardDimensions dimensions;
public static final CardDimensions dimensionsEnlarged;
public static final String deckPath;
public static final String otherPlayerIndex;
public static final String computerName;
static {
// default values
serverName = "localhost";
port = 17171;
cardScalingFactor = 0.4;
cardScalingFactorEnlarged = 0.5;
handScalingFactor = 1.3;
deckPath = "";
otherPlayerIndex = "1"; // combobox default, example: 0: Human, 1: Computer - mad, 2: Computer - Draft Bot
computerName = "computer";
dimensions = new CardDimensions(cardScalingFactor);
dimensionsEnlarged = new CardDimensions(cardScalingFactorEnlarged);
}
}

View file

@ -1,73 +0,0 @@
package mage.client.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import mage.cards.CardDimensions;
import org.apache.log4j.Logger;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public final class Config {
// TODO: Remove this class completely
private static final Logger logger = Logger.getLogger(Config.class);
public static final String remoteServer;
public static final String serverName;
public static final int port;
public static final double cardScalingFactor;
public static final double cardScalingFactorEnlarged;
public static final double handScalingFactor;
public static final CardDimensions dimensions;
public static final CardDimensions dimensionsEnlarged;
public static final String defaultGameType;
public static final String defaultDeckPath;
public static final String defaultOtherPlayerIndex;
public static final String defaultComputerName;
static {
Properties p = new Properties();
boolean fileFound = true;
try (FileInputStream fis = new FileInputStream(new File("config/config.properties"))) {
p.load(fis);
} catch (IOException ex) {
fileFound = false;
}
if (fileFound) {
serverName = p.getProperty("server-name");
port = Integer.parseInt(p.getProperty("port"));
remoteServer = p.getProperty("remote-server");
cardScalingFactor = Double.valueOf(p.getProperty("card-scaling-factor"));
cardScalingFactorEnlarged = Double.valueOf(p.getProperty("card-scaling-factor-enlarged"));
handScalingFactor = Double.valueOf(p.getProperty("hand-scaling-factor"));
defaultGameType = p.getProperty("default-game-type", "Human");
defaultDeckPath = p.getProperty("default-deck-path");
defaultOtherPlayerIndex = p.getProperty("default-other-player-index");
defaultComputerName = p.getProperty("default-computer-name");
dimensions = new CardDimensions(cardScalingFactor);
dimensionsEnlarged = new CardDimensions(cardScalingFactorEnlarged);
} else { // Take some default valies for netbeans design view
serverName = "localhost";
port = 17171;
remoteServer = "mage-server";
cardScalingFactor = 0.4;
cardScalingFactorEnlarged = 0.5;
handScalingFactor = 1.3;
defaultGameType = p.getProperty("default-game-type", "Human");
defaultDeckPath = "";
defaultOtherPlayerIndex = "1";
defaultComputerName = "AI Computer";
dimensions = new CardDimensions(cardScalingFactor);
dimensionsEnlarged = new CardDimensions(cardScalingFactorEnlarged);
}
}
}

View file

@ -1,7 +0,0 @@
server-name=localhost
port=17171
remote-server=mage-server
cards-resource-path=resources/images/cards/
symbols-resource-path=resources/images/symbols/
resource-path=resources/images/
card-scaling-factor=0.4