Skip to content

Commit

Permalink
Look I maded a new label
Browse files Browse the repository at this point in the history
  • Loading branch information
par13002 committed Dec 9, 2015
1 parent 38f9f34 commit 1b9f46f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
1 change: 1 addition & 0 deletions MegaMek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2118,6 +2118,7 @@ MegaMek.serverPassL=Server Password:
MegaMek.metaserverL=Serverbrowser URL:
MegaMek.registerC=Register Game
MegaMek.serverAddrL=Server Address:
MegaMek.ConnectAsInvis=Connect as invisible?
MegaMek.welcome.message=MegaMek is a complex application -- if you ever need any help you\r\nshould start by reading the documentation, accessible through the\r\nHelp menu.\n\ \nWould you like to view the documentation now?\n
MegaMek.hostNewGame.label=Start a New Game...
MegaMek.hostScenario.label=Start a Scenario...
Expand Down
14 changes: 8 additions & 6 deletions MegaMek/mmconf/clientsettings.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
<?xml version="1.0"?>
<MegaMekSettings>
<store name="ClientSettings">
<preference name="LastPlayerCamoName" value="Blue"/>
<preference name="LastPlayerCamoName" value="Red"/>
<preference name="LastPlayerCategory" value="-- No Camo --"/>
<preference name="LastPlayerColor" value="0"/>
<preference name="LastPlayerName" value="test"/>
<preference name="LastPlayerColor" value="1"/>
<preference name="LastPlayerName" value="Patryk"/>
<preference name="megamek.megamek.metaservername" value="http://stormy-light-2818.herokuapp.com/announce"/>
<preference name="LastConnectAddr" value="localhost"/>
<preference name="LastServerPass" value="test"/>
</store>
<store name="megamek.client.ui.swing.ButtonOrderPreferences">
</store>
<store name="megamek.client.ui.swing.GUIPreferences">
<preference name="WindowSizeHeight" value="876"/>
<preference name="WindowPosY" value="-8"/>
<preference name="WindowPosX" value="-8"/>
<preference name="WindowSizeWidth" value="1616"/>
<preference name="WindowPosY" value="0"/>
<preference name="WindowPosX" value="0"/>
<preference name="WindowSizeWidth" value="1600"/>
<preference name="NagForReadme" value="false"/>
</store>
</MegaMekSettings>
21 changes: 20 additions & 1 deletion MegaMek/src/megamek/client/ui/swing/ConnectDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ public class ConnectDialog extends JDialog implements ActionListener {
private static final long serialVersionUID = 5895056240077042429L;
public String playerName;
public String serverAddr;
public String spectateValue;
public int port;
private JLabel yourNameL;
private JLabel serverAddrL;
private JLabel portL;
private JLabel SpectateConnectL;
private JTextField yourNameF;
private JTextField serverAddrF;
private JTextField portF;
private JTextField SpectateConnectF;
private JButton okayB;
private JButton cancelB;

Expand All @@ -44,6 +47,8 @@ public ConnectDialog(JFrame frame) {
Messages.getString("MegaMek.serverAddrL"), SwingConstants.RIGHT); //$NON-NLS-1$
portL = new JLabel(
Messages.getString("MegaMek.portL"), SwingConstants.RIGHT); //$NON-NLS-1$
SpectateConnectL = new JLabel(
Messages.getString("MegaMek.ConnectAsInvis"), SwingConstants.RIGHT); //$NON-NLS-1$
yourNameF = new JTextField(PreferenceManager.getClientPreferences()
.getLastPlayerName(), 16);
yourNameF.addActionListener(this);
Expand All @@ -54,6 +59,9 @@ public ConnectDialog(JFrame frame) {
.getLastConnectPort()
+ "", 4); //$NON-NLS-1$
portF.addActionListener(this);
SpectateConnectF = new JTextField(PreferenceManager.getClientPreferences()
.getSpectateConnect(), 16);
SpectateConnectF.addActionListener(this);
okayB = new JButton(Messages.getString("Okay")); //$NON-NLS-1$
okayB.setActionCommand("done"); //$NON-NLS-1$
okayB.addActionListener(this);
Expand All @@ -68,7 +76,7 @@ public ConnectDialog(JFrame frame) {
c.fill = GridBagConstraints.NONE;
c.weightx = 0.0;
c.weighty = 0.0;
c.insets = new Insets(5, 5, 5, 5);
c.insets = new Insets(6, 6, 6, 6);
c.gridwidth = 1;
c.anchor = GridBagConstraints.EAST;
gridbag.setConstraints(yourNameL, c);
Expand All @@ -93,6 +101,14 @@ public ConnectDialog(JFrame frame) {
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(portF, c);
getContentPane().add(portF);
c.gridwidth = 1;
c.anchor = GridBagConstraints.EAST;
gridbag.setConstraints(SpectateConnectL, c);
getContentPane().add(SpectateConnectL);
c.gridwidth = GridBagConstraints.REMAINDER;
c.anchor = GridBagConstraints.WEST;
gridbag.setConstraints(SpectateConnectF, c);
getContentPane().add(SpectateConnectF);
c.ipadx = 20;
c.ipady = 5;
c.gridwidth = 1;
Expand All @@ -114,6 +130,7 @@ public void actionPerformed(ActionEvent e) {
try {
playerName = yourNameF.getText();
serverAddr = serverAddrF.getText();
spectateValue = SpectateConnectF.getText();
port = Integer.decode(portF.getText().trim()).intValue();
} catch (NumberFormatException ex) {
System.err.println(ex.getMessage());
Expand All @@ -125,6 +142,8 @@ public void actionPerformed(ActionEvent e) {
PreferenceManager.getClientPreferences().setLastConnectAddr(
serverAddr);
PreferenceManager.getClientPreferences().setLastConnectPort(port);

PreferenceManager.getClientPreferences().setSpectateConnect(spectateValue);
}
setVisible(false);
}
Expand Down
9 changes: 9 additions & 0 deletions MegaMek/src/megamek/common/preference/ClientPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ClientPreferences extends PreferenceStoreProxy implements
store.setDefault(MAX_PATHFINDER_TIME,
MovePath.DEFAULT_PATHFINDER_TIME_LIMIT);
store.setDefault(DATA_DIRECTORY, "data");
store.setDefault(SPECTATE_CONNECT, "No");
store.setDefault(LOG_DIRECTORY, "logs");
store.setDefault(MECH_DIRECTORY, store.getDefaultString(DATA_DIRECTORY)
+ File.separator + "mechfiles");
Expand Down Expand Up @@ -90,6 +91,10 @@ public int getLastConnectPort() {
public String getLastPlayerName() {
return store.getString(LAST_PLAYER_NAME);
}

public String getSpectateConnect() {
return store.getString(SPECTATE_CONNECT);
}

public String getLastServerPass() {
return store.getString(LAST_SERVER_PASS);
Expand Down Expand Up @@ -218,6 +223,10 @@ public void setLastPlayerColor(int colorIndex) {
public void setLastPlayerName(String name) {
store.setValue(LAST_PLAYER_NAME, name);
}

public void setSpectateConnect(String Value) {
store.setValue(SPECTATE_CONNECT, Value);
}

public void setLastServerPass(String serverPass) {
store.setValue(LAST_SERVER_PASS, serverPass);
Expand Down
5 changes: 5 additions & 0 deletions MegaMek/src/megamek/common/preference/IClientPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public interface IClientPreferences extends IPreferenceStore {
public static final String LAST_PLAYER_CATEGORY = "LastPlayerCategory";
public static final String LAST_PLAYER_COLOR = "LastPlayerColor";
public static final String LAST_PLAYER_NAME = "LastPlayerName";
public static final String SPECTATE_CONNECT = "SpectateConnect";
public static final String LAST_SERVER_PASS = "LastServerPass";
public static final String LAST_SERVER_PORT = "LastServerPort";
public static final String LOCALE = "Locale";
Expand Down Expand Up @@ -72,6 +73,8 @@ public interface IClientPreferences extends IPreferenceStore {

String getLastPlayerName();

String getSpectateConnect();

String getLastServerPass();

int getLastServerPort();
Expand Down Expand Up @@ -138,6 +141,8 @@ public interface IClientPreferences extends IPreferenceStore {

void setLastPlayerName(String name);

void setSpectateConnect(String Value);

void setLastServerPass(String serverPass);

void setLastServerPort(int port);
Expand Down

0 comments on commit 1b9f46f

Please sign in to comment.