This commit is contained in:
magenoxx 2011-09-20 21:06:24 +04:00
commit 0324ad59ed
8 changed files with 1012 additions and 127 deletions

View file

@ -291,6 +291,9 @@ public class ConnectDialog extends MageDialog {
} }
} }
// Avatar
int avatarId = PreferencesDialog.getSelectedAvatar();
connection.setAvatarId(avatarId);
logger.debug("connecting: " + connection.getProxyType() + " " + connection.getProxyHost() + " " + connection.getProxyPort()); logger.debug("connecting: " + connection.getProxyType() + " " + connection.getProxyHost() + " " + connection.getProxyPort());
task = new ConnectTask(); task = new ConnectTask();

View file

@ -741,6 +741,434 @@
</Container> </Container>
</SubComponents> </SubComponents>
</Container> </Container>
<Container class="javax.swing.JPanel" name="jPanel8">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Avatars">
<Property name="tabTitle" type="java.lang.String" value="Avatars"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="434" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="264" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel9">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel12" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="30" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jPanel12" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jPanel10" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jPanel19" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="33" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel13" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jPanel14" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jPanel20" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
<Component id="jPanel16" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="33" max="-2" attributes="0"/>
<Component id="jPanel17" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jLabel13" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace min="-2" pref="32" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel18" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jPanel21" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jPanel15" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jPanel11" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace pref="29" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel12" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel11" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jPanel13" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jPanel10" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel15" min="-2" max="-2" attributes="0"/>
<Component id="jPanel12" min="-2" max="-2" attributes="0"/>
<Component id="jPanel14" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="23" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jPanel19" min="-2" max="-2" attributes="0"/>
<Component id="jPanel20" min="-2" max="-2" attributes="0"/>
<Component id="jPanel21" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel13" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jPanel16" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jPanel17" min="-2" max="-2" attributes="0"/>
<Component id="jPanel18" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel10">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder roundedCorners="true">
<Color PropertyName="color" blue="cc" green="cc" red="cc" type="rgb"/>
</LineBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Container class="javax.swing.JPanel" name="jPanel13">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder roundedCorners="true">
<Color PropertyName="color" blue="cc" green="cc" red="cc" type="rgb"/>
</LineBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Container class="javax.swing.JPanel" name="jPanel11">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder roundedCorners="true">
<Color PropertyName="color" blue="cc" green="cc" red="cc" type="rgb"/>
</LineBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Component class="javax.swing.JLabel" name="jLabel12">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="11" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Choose your avatar:"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel12">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder roundedCorners="true">
<Color PropertyName="color" blue="cc" green="cc" red="cc" type="rgb"/>
</LineBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Container class="javax.swing.JPanel" name="jPanel14">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder roundedCorners="true">
<Color PropertyName="color" blue="cc" green="cc" red="cc" type="rgb"/>
</LineBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Container class="javax.swing.JPanel" name="jPanel15">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder roundedCorners="true">
<Color PropertyName="color" blue="cc" green="cc" red="cc" type="rgb"/>
</LineBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Component class="javax.swing.JLabel" name="jLabel13">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="11" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Locked avatars:"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel16">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder roundedCorners="true">
<Color PropertyName="color" blue="cc" green="cc" red="cc" type="rgb"/>
</LineBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Container class="javax.swing.JPanel" name="jPanel17">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder roundedCorners="true">
<Color PropertyName="color" blue="cc" green="cc" red="cc" type="rgb"/>
</LineBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Container class="javax.swing.JPanel" name="jPanel18">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder roundedCorners="true">
<Color PropertyName="color" blue="cc" green="cc" red="cc" type="rgb"/>
</LineBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Container class="javax.swing.JPanel" name="jPanel19">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder roundedCorners="true">
<Color PropertyName="color" blue="cc" green="cc" red="cc" type="rgb"/>
</LineBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Container class="javax.swing.JPanel" name="jPanel20">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder roundedCorners="true">
<Color PropertyName="color" blue="cc" green="cc" red="cc" type="rgb"/>
</LineBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
<Container class="javax.swing.JPanel" name="jPanel21">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder roundedCorners="true">
<Color PropertyName="color" blue="cc" green="cc" red="cc" type="rgb"/>
</LineBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="100" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents> </SubComponents>
</Container> </Container>
<Component class="javax.swing.JButton" name="saveButton"> <Component class="javax.swing.JButton" name="saveButton">

View file

@ -35,12 +35,22 @@ package mage.client.dialog;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.util.Config; import mage.client.util.Config;
import mage.client.util.ImageHelper;
import mage.client.util.gui.BufferedImageBuilder;
import mage.remote.Connection; import mage.remote.Connection;
import org.apache.log4j.Logger;
import javax.swing.*; import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.prefs.BackingStoreException; import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
@ -67,11 +77,36 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_PROXY_TYPE = "proxyType"; public static final String KEY_PROXY_TYPE = "proxyType";
public static final String KEY_PROXY_PSWD = "proxyPassword"; public static final String KEY_PROXY_PSWD = "proxyPassword";
public static final String KEY_AVATAR = "selectedId";
private static Map<String, String> cache = new HashMap<String, String>(); private static Map<String, String> cache = new HashMap<String, String>();
private static final Boolean UPDATE_CACHE_POLICY = Boolean.TRUE; private static final Boolean UPDATE_CACHE_POLICY = Boolean.TRUE;
public static final String OPEN_CONNECTION_TAB = "Open-Connection-Tab"; public static final String OPEN_CONNECTION_TAB = "Open-Connection-Tab";
private static final transient Logger log = Logger.getLogger(PreferencesDialog.class);
public static final int DEFAULT_AVATAR_ID = 51;
private static int selectedId = DEFAULT_AVATAR_ID;
private static Set<Integer> availableAvatars = new HashSet<Integer>();
private static Map<Integer, JPanel> panels = new HashMap<Integer, JPanel>();
private static final Border GREEN_BORDER = BorderFactory.createLineBorder(Color.GREEN, 3);
private static final Border BLACK_BORDER = BorderFactory.createLineBorder(Color.BLACK, 3);
static {
availableAvatars.add(51);
availableAvatars.add(13);
availableAvatars.add(9);
availableAvatars.add(53);
availableAvatars.add(10);
availableAvatars.add(39);
availableAvatars.add(19);
availableAvatars.add(30);
availableAvatars.add(25);
}
private final JFileChooser fc = new JFileChooser(); private final JFileChooser fc = new JFileChooser();
{ {
@ -84,6 +119,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
initComponents(); initComponents();
imageFolderPath.setEditable(false); imageFolderPath.setEditable(false);
cbProxyType.setModel(new DefaultComboBoxModel(Connection.ProxyType.values())); cbProxyType.setModel(new DefaultComboBoxModel(Connection.ProxyType.values()));
addAvatars();
} }
/** This method is called from within the constructor to /** This method is called from within the constructor to
@ -148,6 +184,23 @@ public class PreferencesDialog extends javax.swing.JDialog {
txtPasswordField = new javax.swing.JPasswordField(); txtPasswordField = new javax.swing.JPasswordField();
rememberPswd = new javax.swing.JCheckBox(); rememberPswd = new javax.swing.JCheckBox();
jLabel11 = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel();
jPanel8 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jPanel9 = new javax.swing.JPanel();
jPanel10 = new javax.swing.JPanel();
jPanel13 = new javax.swing.JPanel();
jPanel11 = new javax.swing.JPanel();
jLabel12 = new javax.swing.JLabel();
jPanel12 = new javax.swing.JPanel();
jPanel14 = new javax.swing.JPanel();
jPanel15 = new javax.swing.JPanel();
jLabel13 = new javax.swing.JLabel();
jPanel16 = new javax.swing.JPanel();
jPanel17 = new javax.swing.JPanel();
jPanel18 = new javax.swing.JPanel();
jPanel19 = new javax.swing.JPanel();
jPanel20 = new javax.swing.JPanel();
jPanel21 = new javax.swing.JPanel();
saveButton = new javax.swing.JButton(); saveButton = new javax.swing.JButton();
exitButton = new javax.swing.JButton(); exitButton = new javax.swing.JButton();
@ -240,8 +293,6 @@ public class PreferencesDialog extends javax.swing.JDialog {
.addContainerGap(84, Short.MAX_VALUE)) .addContainerGap(84, Short.MAX_VALUE))
); );
jPanel7.getAccessibleContext().setAccessibleName("Battlefield");
jTabbedPane1.addTab("Main", jPanel1); jTabbedPane1.addTab("Main", jPanel1);
jLabel1.setText("Choose phases MAGE will stop on:"); jLabel1.setText("Choose phases MAGE will stop on:");
@ -582,6 +633,253 @@ public class PreferencesDialog extends javax.swing.JDialog {
jTabbedPane1.addTab("Connection", jPanel6); jTabbedPane1.addTab("Connection", jPanel6);
jPanel10.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
jPanel10.setLayout(jPanel10Layout);
jPanel10Layout.setHorizontalGroup(
jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel10Layout.setVerticalGroup(
jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel13.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
jPanel13.setLayout(jPanel13Layout);
jPanel13Layout.setHorizontalGroup(
jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel13Layout.setVerticalGroup(
jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel11.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
jPanel11.setLayout(jPanel11Layout);
jPanel11Layout.setHorizontalGroup(
jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel11Layout.setVerticalGroup(
jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jLabel12.setFont(new java.awt.Font("Tahoma", 1, 11));
jLabel12.setText("Choose your avatar:");
jPanel12.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
jPanel12.setLayout(jPanel12Layout);
jPanel12Layout.setHorizontalGroup(
jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel12Layout.setVerticalGroup(
jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel14.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
jPanel14.setLayout(jPanel14Layout);
jPanel14Layout.setHorizontalGroup(
jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel14Layout.setVerticalGroup(
jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel15.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
jPanel15.setLayout(jPanel15Layout);
jPanel15Layout.setHorizontalGroup(
jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel15Layout.setVerticalGroup(
jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jLabel13.setFont(new java.awt.Font("Tahoma", 1, 11));
jLabel13.setText("Locked avatars:");
jPanel16.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
jPanel16.setLayout(jPanel16Layout);
jPanel16Layout.setHorizontalGroup(
jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel16Layout.setVerticalGroup(
jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel17.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17);
jPanel17.setLayout(jPanel17Layout);
jPanel17Layout.setHorizontalGroup(
jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel17Layout.setVerticalGroup(
jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel18.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18);
jPanel18.setLayout(jPanel18Layout);
jPanel18Layout.setHorizontalGroup(
jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel18Layout.setVerticalGroup(
jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel19.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
javax.swing.GroupLayout jPanel19Layout = new javax.swing.GroupLayout(jPanel19);
jPanel19.setLayout(jPanel19Layout);
jPanel19Layout.setHorizontalGroup(
jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel19Layout.setVerticalGroup(
jPanel19Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel20.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
javax.swing.GroupLayout jPanel20Layout = new javax.swing.GroupLayout(jPanel20);
jPanel20.setLayout(jPanel20Layout);
jPanel20Layout.setHorizontalGroup(
jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel20Layout.setVerticalGroup(
jPanel20Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel21.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 204), 1, true));
javax.swing.GroupLayout jPanel21Layout = new javax.swing.GroupLayout(jPanel21);
jPanel21.setLayout(jPanel21Layout);
jPanel21Layout.setHorizontalGroup(
jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel21Layout.setVerticalGroup(
jPanel21Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
jPanel9.setLayout(jPanel9Layout);
jPanel9Layout.setHorizontalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel12))
.addGroup(jPanel9Layout.createSequentialGroup()
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addGap(30, 30, 30)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel19, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(33, 33, 33)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel9Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(33, 33, 33)
.addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel13))))
.addGap(32, 32, 32)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(29, Short.MAX_VALUE))
);
jPanel9Layout.setVerticalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(26, 26, 26)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel19, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel20, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel21, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addComponent(jLabel13)
.addGap(18, 18, 18)
.addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(25, 25, 25))
);
jScrollPane1.setViewportView(jPanel9);
javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
jPanel8.setLayout(jPanel8Layout);
jPanel8Layout.setHorizontalGroup(
jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 434, Short.MAX_VALUE)
);
jPanel8Layout.setVerticalGroup(
jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE)
);
jTabbedPane1.addTab("Avatars", jPanel8);
saveButton.setLabel("Save"); saveButton.setLabel("Save");
saveButton.addActionListener(new java.awt.event.ActionListener() { saveButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -654,6 +952,11 @@ public class PreferencesDialog extends javax.swing.JDialog {
prefs.put(KEY_PROXY_PSWD, new String(input)); prefs.put(KEY_PROXY_PSWD, new String(input));
} }
if (availableAvatars.contains(selectedId)) {
prefs.put(KEY_AVATAR, String.valueOf(selectedId));
updateCache(KEY_AVATAR, String.valueOf(selectedId));
}
// images // images
saveImagesPath(prefs); saveImagesPath(prefs);
@ -756,6 +1059,34 @@ public class PreferencesDialog extends javax.swing.JDialog {
public void run() { public void run() {
if (!dialog.isVisible()) { if (!dialog.isVisible()) {
Preferences prefs = MageFrame.getPreferences(); Preferences prefs = MageFrame.getPreferences();
// Phases
loadPhases(prefs);
// Connection
loadProxySettings(prefs);
// Selected avatar
loadSelectedAvatar(prefs);
// Images
loadImagesPath(prefs);
// open specified tab before displaying
openTab(openedTab);
dialog.setLocation(300, 200);
dialog.reset();
dialog.setVisible(true);
} else {
dialog.requestFocus();
}
}
});
}
private static void loadPhases(Preferences prefs) {
load(prefs, dialog.checkBoxUpkeepYou, UPKEEP_YOU); load(prefs, dialog.checkBoxUpkeepYou, UPKEEP_YOU);
load(prefs, dialog.checkBoxDrawYou, DRAW_YOU); load(prefs, dialog.checkBoxDrawYou, DRAW_YOU);
load(prefs, dialog.checkBoxMainYou, MAIN_YOU); load(prefs, dialog.checkBoxMainYou, MAIN_YOU);
@ -774,8 +1105,9 @@ public class PreferencesDialog extends javax.swing.JDialog {
load(prefs, dialog.displayBigCardsInHand, KEY_HAND_USE_BIG_CARDS, "true"); load(prefs, dialog.displayBigCardsInHand, KEY_HAND_USE_BIG_CARDS, "true");
load(prefs, dialog.showToolTipsInHand, KEY_HAND_SHOW_TOOLTIPS, "true"); load(prefs, dialog.showToolTipsInHand, KEY_HAND_SHOW_TOOLTIPS, "true");
load(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true"); load(prefs, dialog.nonLandPermanentsInOnePile, KEY_PERMANENTS_IN_ONE_PILE, "true");
}
// connection private static void loadProxySettings(Preferences prefs) {
dialog.cbProxyType.setSelectedItem(Connection.ProxyType.valueOf(MageFrame.getPreferences().get(KEY_PROXY_TYPE, "NONE").toUpperCase())); dialog.cbProxyType.setSelectedItem(Connection.ProxyType.valueOf(MageFrame.getPreferences().get(KEY_PROXY_TYPE, "NONE").toUpperCase()));
load(prefs, dialog.txtProxyServer, KEY_PROXY_ADDRESS, Config.serverName); load(prefs, dialog.txtProxyServer, KEY_PROXY_ADDRESS, Config.serverName);
@ -785,27 +1117,34 @@ public class PreferencesDialog extends javax.swing.JDialog {
if (dialog.rememberPswd.isSelected()) { if (dialog.rememberPswd.isSelected()) {
load(prefs, dialog.txtPasswordField, KEY_PROXY_PSWD, ""); load(prefs, dialog.txtPasswordField, KEY_PROXY_PSWD, "");
} }
}
// images private static void loadSelectedAvatar(Preferences prefs) {
loadImagesPath(prefs); getSelectedAvatar();
dialog.setSelectedId(selectedId);
dialog.setLocation(300, 200); }
dialog.reset();
public static int getSelectedAvatar() {
try { try {
if (openedTab > 0) { selectedId = Integer.valueOf(MageFrame.getPreferences().get(KEY_AVATAR, String.valueOf(DEFAULT_AVATAR_ID)));
} catch (NumberFormatException n) {
selectedId = DEFAULT_AVATAR_ID;
} finally {
if (!availableAvatars.contains(selectedId)) {
selectedId = DEFAULT_AVATAR_ID;
}
}
return selectedId;
}
private static void openTab(int index) {
try {
if (index > 0) {
dialog.jTabbedPane1.setSelectedIndex(3); dialog.jTabbedPane1.setSelectedIndex(3);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
dialog.setVisible(true);
} else {
dialog.requestFocus();
}
}
});
} }
private static void loadImagesPath(Preferences prefs) { private static void loadImagesPath(Preferences prefs) {
@ -904,6 +1243,70 @@ public class PreferencesDialog extends javax.swing.JDialog {
cache.put(key, value); cache.put(key, value);
} }
private void addAvatars() {
try {
addAvatar(jPanel10, 51, true, false);
addAvatar(jPanel13, 13, false, false);
addAvatar(jPanel11, 9, false, false);
addAvatar(jPanel12, 53, false, false);
addAvatar(jPanel14, 10, false, false);
addAvatar(jPanel15, 39, false, false);
addAvatar(jPanel19, 19, false, false);
addAvatar(jPanel20, 30, false, false);
addAvatar(jPanel21, 25, false, false);
addAvatar(jPanel16, 22, false, true);
addAvatar(jPanel17, 77, false, true);
addAvatar(jPanel18, 62, false, true);
} catch (Exception e) {
log.error(e, e);
}
}
public void setSelectedId(int id) {
if (availableAvatars.contains(id)) {
for (JPanel panel : panels.values()) {
panel.setBorder(BLACK_BORDER);
}
this.selectedId = id;
panels.get(this.selectedId).setBorder(GREEN_BORDER);
}
}
private void addAvatar(JPanel jPanel, final int id, boolean selected, boolean locked) {
String path = "/avatars/" + String.valueOf(id) + ".jpg";
panels.put(id, jPanel);
Image image = ImageHelper.getImageFromResources(path);
Rectangle r = new Rectangle(90, 90);
BufferedImage bufferedImage;
if (!locked) {
bufferedImage = BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB);
} else {
bufferedImage = BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB, new Color(150, 150, 150, 170));
}
BufferedImage resized = ImageHelper.getResizedImage(bufferedImage, r);
final JLabel jLabel = new JLabel();
jLabel.setIcon(new ImageIcon(resized));
if (selected) {
jPanel.setBorder(GREEN_BORDER);
} else {
jPanel.setBorder(BLACK_BORDER);
}
jPanel.setLayout(new BorderLayout());
jPanel.add(jLabel);
if (!locked) {
jLabel.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
if (selectedId != id) {
setSelectedId(id);
MageFrame.getSession().updateAvatar(id);
}
}
});
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton browseButton; private javax.swing.JButton browseButton;
private javax.swing.JComboBox cbProxyType; private javax.swing.JComboBox cbProxyType;
@ -928,6 +1331,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel4;
@ -937,12 +1342,27 @@ public class PreferencesDialog extends javax.swing.JDialog {
private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9; private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel10;
private javax.swing.JPanel jPanel11;
private javax.swing.JPanel jPanel12;
private javax.swing.JPanel jPanel13;
private javax.swing.JPanel jPanel14;
private javax.swing.JPanel jPanel15;
private javax.swing.JPanel jPanel16;
private javax.swing.JPanel jPanel17;
private javax.swing.JPanel jPanel18;
private javax.swing.JPanel jPanel19;
private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel20;
private javax.swing.JPanel jPanel21;
private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel5;
private javax.swing.JPanel jPanel6; private javax.swing.JPanel jPanel6;
private javax.swing.JPanel jPanel7; private javax.swing.JPanel jPanel7;
private javax.swing.JPanel jPanel8;
private javax.swing.JPanel jPanel9;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTabbedPane jTabbedPane1; private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JLabel lblProxyPassword; private javax.swing.JLabel lblProxyPassword;
private javax.swing.JLabel lblProxyPort; private javax.swing.JLabel lblProxyPort;

View file

@ -43,12 +43,12 @@ import mage.client.components.MageRoundPane;
import mage.client.dialog.ShowCardsDialog; import mage.client.dialog.ShowCardsDialog;
import mage.client.plugins.adapters.MageActionCallback; import mage.client.plugins.adapters.MageActionCallback;
import mage.client.plugins.impl.Plugins; import mage.client.plugins.impl.Plugins;
import mage.remote.Session;
import mage.client.util.Command; import mage.client.util.Command;
import mage.client.util.Config; import mage.client.util.Config;
import mage.client.util.ImageHelper; import mage.client.util.ImageHelper;
import mage.client.util.gui.BufferedImageBuilder; import mage.client.util.gui.BufferedImageBuilder;
import mage.components.ImagePanel; import mage.components.ImagePanel;
import mage.remote.Session;
import mage.sets.Sets; import mage.sets.Sets;
import mage.view.CardView; import mage.view.CardView;
import mage.view.ManaPoolView; import mage.view.ManaPoolView;
@ -66,7 +66,6 @@ import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Random;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -88,7 +87,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
private static final int AVATAR_COUNT = 77; private static final int AVATAR_COUNT = 77;
private static final Border greenBorder = new LineBorder(Color.green, 4); private static final Border greenBorder = new LineBorder(Color.red, 3);
private static final Border redBorder = new LineBorder(Color.red, 2); private static final Border redBorder = new LineBorder(Color.red, 2);
private static final Border emptyBorder = BorderFactory.createEmptyBorder(0,0,0,0); private static final Border emptyBorder = BorderFactory.createEmptyBorder(0,0,0,0);
@ -117,14 +116,14 @@ public class PlayerPanelExt extends javax.swing.JPanel {
libraryLabel.setText(Integer.toString(player.getLibraryCount())); libraryLabel.setText(Integer.toString(player.getLibraryCount()));
graveLabel.setText(Integer.toString(player.getGraveyard().size())); graveLabel.setText(Integer.toString(player.getGraveyard().size()));
if (avatarId == -1) { int id = player.getUserData().getAvatarId();
avatarId = player.getUserData().getAvatarId(); if (id > 0 && id != avatarId) {
if (avatarId > 0) { avatarId = id;
String path = "/avatars/" + String.valueOf(avatarId) + ".jpg"; String path = "/avatars/" + String.valueOf(avatarId) + ".jpg";
if (avatarId == 64) { if (avatarId == 64) {
path = "/avatars/i64.jpg"; path = "/avatars/i64.jpg";
} else if (avatarId >= 1000) { } else if (avatarId >= 1000) {
avatarId = avatarId-1000; avatarId = avatarId - 1000;
path = "/avatars/special/" + String.valueOf(avatarId) + ".gif"; path = "/avatars/special/" + String.valueOf(avatarId) + ".gif";
} }
Image image = ImageHelper.getImageFromResources(path); Image image = ImageHelper.getImageFromResources(path);
@ -132,7 +131,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
this.avatar.update("player", resized, resized, resized, resized, r); this.avatar.update("player", resized, resized, resized, resized, r);
} }
}
this.avatar.setText(player.getName()); this.avatar.setText(player.getName());
if (player.isActive()) { if (player.isActive()) {
@ -194,7 +192,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
add(panelBackground); add(panelBackground);
Rectangle r = new Rectangle(80, 80); Rectangle r = new Rectangle(80, 80);
Image image = ImageHelper.getImageFromResources("/avatars/51.jpg"); Image image = ImageHelper.getImageFromResources("/avatars/unknown.jpg");
topCardPanel = Plugins.getInstance().getMageCard(new CardView(Sets.findCard("Forest")), bigCard, topCardDimension, gameId, true); topCardPanel = Plugins.getInstance().getMageCard(new CardView(Sets.findCard("Forest")), bigCard, topCardDimension, gameId, true);
topCardPanel.setVisible(false); topCardPanel.setVisible(false);

View file

@ -1,7 +1,6 @@
package mage.client.util.gui; package mage.client.util.gui;
import java.awt.Graphics2D; import java.awt.*;
import java.awt.Image;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver; import java.awt.image.ImageObserver;
@ -36,6 +35,18 @@ public class BufferedImageBuilder {
return bufferedImage; return bufferedImage;
} }
public static BufferedImage bufferImage(Image image, int type, Color color) {
if (image == null) {
return null;
}
BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), type);
Graphics2D g = bufferedImage.createGraphics();
g.drawImage(image, null, null);
g.setColor(color);
g.fillRect(0, 0, image.getWidth(null), image.getHeight(null));
return bufferedImage;
}
private void waitForImage(BufferedImage bufferedImage) { private void waitForImage(BufferedImage bufferedImage) {
final ImageLoadStatus imageLoadStatus = new ImageLoadStatus(); final ImageLoadStatus imageLoadStatus = new ImageLoadStatus();
bufferedImage.getHeight(new ImageObserver() { bufferedImage.getHeight(new ImageObserver() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

View file

@ -48,6 +48,8 @@ public class Connection {
private String proxyUsername; private String proxyUsername;
private String proxyPassword; private String proxyPassword;
private int avatarId;
private static final String serialization = "?serializationtype=jboss"; private static final String serialization = "?serializationtype=jboss";
private static final String transport = "bisocket"; private static final String transport = "bisocket";
@ -195,4 +197,12 @@ public class Connection {
return null; return null;
} }
public int getAvatarId() {
return avatarId;
}
public void setAvatarId(int avatarId) {
this.avatarId = avatarId;
}
} }

View file

@ -151,7 +151,7 @@ public class Session {
this.sessionId = callbackClient.getSessionId(); this.sessionId = callbackClient.getSessionId();
boolean registerResult = false; boolean registerResult = false;
if (connection.getPassword() == null) { if (connection.getPassword() == null) {
UserDataView userDataView = new UserDataView(0); UserDataView userDataView = new UserDataView(connection.getAvatarId());
// for backward compatibility. don't remove twice call - first one does nothing but for version checking // for backward compatibility. don't remove twice call - first one does nothing but for version checking
registerResult = server.registerClient(connection.getUsername(), sessionId, client.getVersion()); registerResult = server.registerClient(connection.getUsername(), sessionId, client.getVersion());
server.setUserData(connection.getUsername(), sessionId, userDataView); server.setUserData(connection.getUsername(), sessionId, userDataView);
@ -931,6 +931,21 @@ public class Session {
return connection.getUsername(); return connection.getUsername();
} }
public boolean updateAvatar(int avatarId) {
try {
if (isConnected()) {
UserDataView userDataView = new UserDataView(avatarId);
server.setUserData(connection.getUsername(), sessionId, userDataView);
}
return true;
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
}
return false;
}
} }
class MageAuthenticator extends Authenticator { class MageAuthenticator extends Authenticator {