mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
handle smaller screen sizes
This commit is contained in:
parent
b5db562450
commit
afef9c06fe
5 changed files with 83 additions and 120 deletions
|
|
@ -624,7 +624,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
|||
lblStatus = new javax.swing.JLabel();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
setMinimumSize(new Dimension(800, 600));
|
||||
setMinimumSize(new Dimension(600, 400));
|
||||
|
||||
desktopPane.setBackground(new java.awt.Color(204, 204, 204));
|
||||
|
||||
|
|
|
|||
|
|
@ -262,21 +262,8 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
return permanents;
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
//setBackground(java.awt.Color.gray);
|
||||
//setForeground(java.awt.Color.gray);
|
||||
setOpaque(true);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
pnlGameInfo.repaint();
|
||||
this.handContainer.sizeHand(0.8, smallMode);
|
||||
for (PlayAreaPanel p: players.values()) {
|
||||
p.sizePlayer();
|
||||
p.sizePlayer(smallMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -199,7 +199,7 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
pnlGameInfo.repaint();
|
||||
this.handContainer.sizeHand(1, smallMode);
|
||||
for (PlayAreaPanel p: players.values()) {
|
||||
p.sizePlayer();
|
||||
p.sizePlayer(smallMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -840,21 +840,24 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
.addComponent(pnlGameInfo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0)
|
||||
.addGroup(gl_jPanel3.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(handContainer, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||
.addComponent(jPhases, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(gl_jPanel3.createSequentialGroup()
|
||||
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
|
||||
.addGap(49))))
|
||||
);
|
||||
gl_jPanel3.setVerticalGroup(
|
||||
gl_jPanel3.createParallelGroup(Alignment.TRAILING)
|
||||
.addGroup(gl_jPanel3.createSequentialGroup()
|
||||
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 545, Short.MAX_VALUE)
|
||||
.addComponent(pnlBattlefield, GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(handContainer, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPhases, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(pnlGameInfo, GroupLayout.DEFAULT_SIZE, 568, Short.MAX_VALUE)
|
||||
.addComponent(pnlGameInfo, GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
|
||||
);
|
||||
jPanel3.setLayout(gl_jPanel3);
|
||||
|
||||
jPanel3.setMinimumSize(new Dimension(600, 400));
|
||||
// jPanel3.setMinimumSize(new Dimension(400, 400));
|
||||
jSplitPane1.setLeftComponent(jPanel3);
|
||||
|
||||
gameChatPanel.setMinimumSize(new java.awt.Dimension(100, 48));
|
||||
|
|
@ -872,11 +875,11 @@ public class GamePanel extends javax.swing.JPanel {
|
|||
);
|
||||
}
|
||||
|
||||
private void btnConcedeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConcedeActionPerformed
|
||||
private void btnConcedeActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
if (modalQuestion("Are you sure you want to concede?", "Confirm concede") == JOptionPane.YES_OPTION) {
|
||||
session.concedeGame(gameId);
|
||||
}
|
||||
}//GEN-LAST:event_btnConcedeActionPerformed
|
||||
}
|
||||
|
||||
private void btnSwitchHandActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
String[] choices = handCards.keySet().toArray(new String[0]);
|
||||
|
|
|
|||
|
|
@ -58,14 +58,13 @@ import javax.swing.LayoutStyle.ComponentPlacement;
|
|||
*/
|
||||
public class PlayAreaPanel extends javax.swing.JPanel {
|
||||
|
||||
UUID playerId;
|
||||
UUID gameId;
|
||||
private UUID playerId;
|
||||
private UUID gameId;
|
||||
|
||||
/** Creates new form PlayAreaPanel */
|
||||
public PlayAreaPanel() {
|
||||
initComponents();
|
||||
setOpaque(false);
|
||||
jPanel1.setOpaque(false);
|
||||
jScrollPane1.setOpaque(false);
|
||||
jScrollPane1.getViewport().setOpaque(false);
|
||||
battlefieldPanel.setOpaque(false);
|
||||
|
|
@ -99,12 +98,9 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
return battlefieldPanel;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void initComponents() {
|
||||
setBorder(BorderFactory.createLineBorder(new Color(0,0,0,0)));
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
playerPanel = new PlayerPanelExt();
|
||||
playerPanel.setPreferredSize(new Dimension(92, 212));
|
||||
btnCheat = new javax.swing.JButton();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
battlefieldPanel = new mage.client.game.BattlefieldPanel(jScrollPane1);
|
||||
|
|
@ -116,19 +112,6 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout gl_jPanel1 = new javax.swing.GroupLayout(jPanel1);
|
||||
gl_jPanel1.setHorizontalGroup(
|
||||
gl_jPanel1.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(playerPanel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
);
|
||||
gl_jPanel1.setVerticalGroup(
|
||||
gl_jPanel1.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_jPanel1.createSequentialGroup()
|
||||
.addComponent(playerPanel, GroupLayout.PREFERRED_SIZE, 212, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanel1.setLayout(gl_jPanel1);
|
||||
|
||||
jScrollPane1.setViewportView(battlefieldPanel);
|
||||
Border empty = new EmptyBorder(0,0,0,0);
|
||||
jScrollPane1.setBorder(empty);
|
||||
|
|
@ -136,29 +119,32 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jPanel1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 366, Short.MAX_VALUE)
|
||||
.addGap(0))
|
||||
layout.createSequentialGroup()
|
||||
.addComponent(playerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(jScrollPane1, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(Alignment.TRAILING)
|
||||
.addGroup(Alignment.LEADING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(Alignment.TRAILING)
|
||||
.addComponent(jScrollPane1)
|
||||
.addComponent(jPanel1, Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 213, GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(0))
|
||||
layout.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(playerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
|
||||
);
|
||||
this.setLayout(layout);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
}
|
||||
|
||||
public void sizePlayer() {
|
||||
this.playerPanel.sizePlayerPanel();
|
||||
public void sizePlayer(boolean smallMode) {
|
||||
this.playerPanel.sizePlayerPanel(smallMode);
|
||||
if (smallMode) {
|
||||
this.playerPanel.setPreferredSize(new Dimension(92, 160));
|
||||
this.jScrollPane1.setPreferredSize(new Dimension(160, 160));
|
||||
}
|
||||
else {
|
||||
this.playerPanel.setPreferredSize(new Dimension(92, 212));
|
||||
this.jScrollPane1.setPreferredSize(new Dimension(160, 212));
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheatActionPerformed
|
||||
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
try {
|
||||
MageFrame.getSession().cheat(gameId, playerId, Sets.loadDeck("cheat.dck"));
|
||||
} catch (FileNotFoundException ex) {
|
||||
|
|
@ -166,15 +152,12 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
|||
} catch (IOException ex) {
|
||||
Logger.getLogger(PlayAreaPanel.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}//GEN-LAST:event_btnCheatActionPerformed
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
||||
private mage.client.game.BattlefieldPanel battlefieldPanel;
|
||||
private javax.swing.JButton btnCheat;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
//private mage.client.game.ManaPool manaPool;
|
||||
private PlayerPanelExt playerPanel;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ import java.util.UUID;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.GroupLayout.Alignment;
|
||||
import javax.swing.LayoutStyle.ComponentPlacement;
|
||||
|
||||
/**
|
||||
* Enhanced player pane.
|
||||
|
|
@ -98,6 +99,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
|
||||
/** Creates new form PlayerPanel */
|
||||
public PlayerPanelExt() {
|
||||
setPreferredSize(new Dimension(94, 212));
|
||||
initComponents();
|
||||
}
|
||||
|
||||
|
|
@ -135,12 +137,16 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
}
|
||||
}
|
||||
this.avatar.setText(player.getName());
|
||||
this.btnPlayer.setText(player.getName());
|
||||
if (player.isActive()) {
|
||||
this.avatar.setBorder(greenBorder);
|
||||
this.btnPlayer.setBorder(greenBorder);
|
||||
} else if (player.hasLeft()) {
|
||||
this.avatar.setBorder(redBorder);
|
||||
this.btnPlayer.setBorder(redBorder);
|
||||
} else {
|
||||
this.avatar.setBorder(emptyBorder);
|
||||
this.btnPlayer.setBorder(emptyBorder);
|
||||
}
|
||||
|
||||
synchronized (this) {
|
||||
|
|
@ -183,6 +189,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
private void initComponents() {
|
||||
|
||||
panelBackground = new MageRoundPane();
|
||||
panelBackground.setPreferredSize(new Dimension(92, 212));
|
||||
Rectangle r = new Rectangle(80, 80);
|
||||
lifeLabel = new JLabel();
|
||||
handLabel = new JLabel();
|
||||
|
|
@ -266,6 +273,18 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
}
|
||||
});
|
||||
|
||||
btnPlayer = new JButton();
|
||||
btnPlayer.setText("Player");
|
||||
btnPlayer.setVisible(false);
|
||||
btnPlayer.setToolTipText("Player");
|
||||
btnPlayer.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
session.sendPlayerUUID(gameId, playerId);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Add mana symbols
|
||||
BufferedImage imageManaW = ManaSymbols.getManaSymbolImageSmall("W");
|
||||
ImagePanel manaW = new ImagePanel(imageManaW, ImagePanel.ACTUAL);
|
||||
|
|
@ -311,9 +330,6 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
GroupLayout gl_panelBackground = new GroupLayout(panelBackground);
|
||||
gl_panelBackground.setHorizontalGroup(
|
||||
gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(6)
|
||||
.addComponent(avatar, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(9)
|
||||
.addComponent(life, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)
|
||||
|
|
@ -383,13 +399,21 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(1)
|
||||
.addComponent(manaCountLabelU, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))))
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(6)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(btnPlayer, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(avatar, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
|
||||
.addGap(14))
|
||||
);
|
||||
gl_panelBackground.setVerticalGroup(
|
||||
gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(6)
|
||||
.addComponent(avatar, GroupLayout.PREFERRED_SIZE, 80, GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(3)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addComponent(btnPlayer)
|
||||
.addPreferredGap(ComponentPlacement.RELATED)
|
||||
.addGroup(gl_panelBackground.createParallelGroup(Alignment.LEADING)
|
||||
.addGroup(gl_panelBackground.createSequentialGroup()
|
||||
.addGap(1)
|
||||
|
|
@ -456,67 +480,32 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
GroupLayout groupLayout = new GroupLayout(this);
|
||||
groupLayout.setHorizontalGroup(
|
||||
groupLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, 92, GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(groupLayout.createSequentialGroup()
|
||||
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||
);
|
||||
groupLayout.setVerticalGroup(
|
||||
groupLayout.createParallelGroup(Alignment.LEADING)
|
||||
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, 212, GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(groupLayout.createSequentialGroup()
|
||||
.addComponent(panelBackground, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
|
||||
);
|
||||
setLayout(groupLayout);
|
||||
|
||||
}
|
||||
|
||||
public void sizePlayerPanel() {
|
||||
Dimension r = new Dimension(60, 60);
|
||||
this.avatar.setSize(r);
|
||||
this.avatar.setPreferredSize(r);
|
||||
public void sizePlayerPanel(boolean smallMode) {
|
||||
if (smallMode) {
|
||||
avatar.setVisible(false);
|
||||
btnPlayer.setVisible(true);
|
||||
panelBackground.setPreferredSize(new Dimension(92, 160));
|
||||
panelBackground.setBounds(0, 0, 92, 160);
|
||||
}
|
||||
else {
|
||||
avatar.setVisible(true);
|
||||
btnPlayer.setVisible(false);
|
||||
panelBackground.setPreferredSize(new Dimension(92, 212));
|
||||
panelBackground.setBounds(0, 0, 92, 212);
|
||||
}
|
||||
}
|
||||
|
||||
// private void addManaImagePanel(String mana, Rectangle rect, JPanel container) {
|
||||
// BufferedImage imageMana = ManaSymbols.getManaSymbolImageSmall(mana);
|
||||
// if (imageMana != null) {
|
||||
// ImagePanel manaB = new ImagePanel(imageMana, ImagePanel.ACTUAL);
|
||||
// manaB.setBounds(rect.x, rect.y, rect.width, rect.height);
|
||||
// manaB.setOpaque(false);
|
||||
// container.add(manaB);
|
||||
// }
|
||||
// JLabel manaCountLabel = new JLabel();
|
||||
// manaCountLabel.setText("0");
|
||||
// manaCountLabel.setBounds(rect.x + rect.width + 5, rect.y - 8, 30, 30);
|
||||
// container.add(manaCountLabel);
|
||||
// manaLabels.put(mana, manaCountLabel);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Adds image panel and label to the container panel.
|
||||
*
|
||||
* @param containerPanel
|
||||
* @param text
|
||||
* @param r
|
||||
* @param imagePath
|
||||
* @return
|
||||
*/
|
||||
// private JComponent addParam(JPanel containerPanel, String tooltip, JLabel text, Rectangle r, String imagePath, boolean isButton) {
|
||||
// if (text != null) {
|
||||
// text.setForeground(Color.black);
|
||||
// containerPanel.add(text);
|
||||
// text.setToolTipText(tooltip);
|
||||
// }
|
||||
//
|
||||
// Image image = ImageHelper.getImageFromResources(imagePath);
|
||||
// BufferedImage resized = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r);
|
||||
// JComponent component = null;
|
||||
// if (isButton) {
|
||||
// component = new HoverButton(null, resized, resized, resized, r);
|
||||
// } else {
|
||||
// component = new ImagePanel(resized, ImagePanel.ACTUAL);
|
||||
// }
|
||||
// component.setToolTipText(tooltip);
|
||||
// component.setOpaque(false);
|
||||
// containerPanel.add(component);
|
||||
//
|
||||
// return component;
|
||||
// }
|
||||
|
||||
private void btnGraveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGraveActionPerformed
|
||||
if (graveyard == null) {
|
||||
|
|
@ -536,6 +525,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
}
|
||||
|
||||
private HoverButton avatar;
|
||||
private JButton btnPlayer;
|
||||
private ImagePanel life;
|
||||
private ImagePanel poison;
|
||||
private ImagePanel hand;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue