diff --git a/Mage.Client/pom.xml b/Mage.Client/pom.xml index fdcb8d17360..1d66bf123db 100644 --- a/Mage.Client/pom.xml +++ b/Mage.Client/pom.xml @@ -102,6 +102,11 @@ beansbinding 1.2.1 + + org.swinglabs + swing-layout + 1.0.3 + diff --git a/Mage.Client/src/main/java/mage/client/MageFrame.java b/Mage.Client/src/main/java/mage/client/MageFrame.java index 45447490b8c..58f4cc17179 100644 --- a/Mage.Client/src/main/java/mage/client/MageFrame.java +++ b/Mage.Client/src/main/java/mage/client/MageFrame.java @@ -47,6 +47,7 @@ import mage.client.deckeditor.collection.viewer.CollectionViewerPane; import mage.client.dialog.*; import mage.client.plugins.impl.Plugins; import mage.client.util.EDTExceptionHandler; +import mage.client.util.SettingsManager; import mage.client.util.gui.ArrowBuilder; import mage.components.ImagePanel; @@ -173,6 +174,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { initComponents(); setSize(1024, 768); + SettingsManager.getInstance().setScreenWidthAndHeight(1024, 768); this.setExtendedState(JFrame.MAXIMIZED_BOTH); session = new Session(this); @@ -199,11 +201,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { addMageLabel(); setAppIcon(); - //PlayerPanelNew n = new PlayerPanelNew(); - //n.setBounds(100,100,100,300); - //n.setVisible(true); - //backgroundPane.add(n); - desktopPane.add(ArrowBuilder.getArrowsPanel(), JLayeredPane.DRAG_LAYER); desktopPane.addComponentListener(new ComponentAdapter() { @@ -211,12 +208,13 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { public void componentResized(ComponentEvent e) { int width = ((JComponent) e.getSource()).getWidth(); int height = ((JComponent) e.getSource()).getHeight(); - if (!liteMode) + SettingsManager.getInstance().setScreenWidthAndHeight(width, height); + if (!liteMode) { backgroundPane.setSize(width, height); + } JPanel arrowsPanel = ArrowBuilder.getArrowsPanelRef(); if (arrowsPanel != null) arrowsPanel.setSize(width, height); if (title != null) { - //title.setBorder(BorderFactory.createLineBorder(Color.red)); title.setBounds((int) (width - titleRectangle.getWidth()) / 2, (int) (height - titleRectangle.getHeight()) / 2, titleRectangle.width, titleRectangle.height); } } diff --git a/Mage.Client/src/main/java/mage/client/components/ability/AbilityPicker.java b/Mage.Client/src/main/java/mage/client/components/ability/AbilityPicker.java new file mode 100644 index 00000000000..5166c3088f8 --- /dev/null +++ b/Mage.Client/src/main/java/mage/client/components/ability/AbilityPicker.java @@ -0,0 +1,296 @@ +package mage.client.components.ability; + +import com.sun.deploy.util.ArrayUtil; +import mage.client.MageFrame; +import mage.client.util.ImageHelper; +import mage.client.util.SettingsManager; +import mage.client.util.gui.GuiDisplayUtil; +import mage.remote.Session; +import mage.view.AbilityPickerView; +import org.jdesktop.layout.GroupLayout; +import org.jdesktop.layout.LayoutStyle; +import org.jdesktop.swingx.JXPanel; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; +import java.awt.image.BufferedImage; +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +/** + * Dialog for choosing abilities. + * + * @author nantuko + */ +public class AbilityPicker extends JXPanel implements MouseWheelListener { + + private static final String DEFAULT_MESSAGE = "Choose spell or ability to play (double-click)";; + private static final int DIALOG_WIDTH = 320; + private static final int DIALOG_HEIGHT = 240; + + private JList rows; + private List choices; + private String message = DEFAULT_MESSAGE; + + private Session session; + private UUID gameId; + + private BackgroundPainter mwPanelPainter; + private JScrollPane jScrollPane2; + private JTextField title; + + private Image rightImage; + private Image rightImageHovered; + + private static final String IMAGE_RIGHT_PATH = "/game/right.png"; + private static final String IMAGE_RIGHT_HOVERED_PATH = "/game/right_hovered.png"; + + private static Color SELECTED_COLOR = new Color(64,147,208); + private static Color BORDER_COLOR = new Color(0,0,0,50); + + public AbilityPicker() { + initComponents(); + addMouseWheelListener(this); + setSize(320, 240); + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + jScrollPane2.setOpaque(false); + jScrollPane2.getViewport().setOpaque(false); + //jScrollPane2.getHorizontalScrollBar().setUI(new MageScrollbarUI()); + //jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI()); + } + }); + } + + public AbilityPicker(List choices, String message) { + this.choices = choices; + if (message!= null) { + this.message = message + " (double-click)"; + } + initComponents(); + jScrollPane2.setOpaque(false); + jScrollPane2.getViewport().setOpaque(false); + jScrollPane2.getHorizontalScrollBar().setUI(new MageScrollbarUI()); + jScrollPane2.getVerticalScrollBar().setUI(new MageScrollbarUI()); + + addMouseWheelListener(this); + } + + public void init(Session session, UUID gameId) { + this.session = session; + this.gameId = gameId; + } + + public void show(AbilityPickerView choices, Point p) { + if (p == null) return; + this.choices = new ArrayList(); + + for (Map.Entry choice: choices.getChoices().entrySet()) { + this.choices.add(new AbilityPickerAction(choice.getKey(), choice.getValue())); + } + this.choices.add(new AbilityPickerAction(null, "Cancel")); + + Point centered = SettingsManager.getInstance().getComponentPosition(320, 240); + this.setLocation(centered.x, centered.y); + GuiDisplayUtil.keepComponentInsideScreen(centered.x, centered.y, this); + } + + public void initComponents() { + JLabel jLabel1; + JLabel jLabel3; + + Color textColor = Color.white; + + mwPanelPainter = new BackgroundPainter(); + jLabel1 = new JLabel(); + jLabel3 = new JLabel(); + + title = new JTextField(); + jScrollPane2 = new JScrollPane(); + + setBackground(textColor); + setBackgroundPainter(mwPanelPainter); + jLabel1.setFont(new Font("Times New Roman", 1, 18)); + jLabel1.setForeground(textColor); + jLabel1.setText(message); + + jLabel3.setForeground(textColor); + jLabel3.setHorizontalAlignment(SwingConstants.TRAILING); + jLabel3.setText("Selected:"); + + title.setFont(new Font("Tahoma", 1, 11)); + title.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); + + jScrollPane2.setBorder(null); + jScrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + jScrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); + + rightImage = ImageHelper.loadImage(IMAGE_RIGHT_PATH); + rightImageHovered = ImageHelper.loadImage(IMAGE_RIGHT_HOVERED_PATH); + + //BufferedImage[] images = new BufferedImage[choices.size()]; + //rows = new JList(images); + rows = new JList(); + rows.setModel ( + new AbstractListModel() { + public int getSize() { + if (AbilityPicker.this.choices == null) { + return 0; + } + return AbilityPicker.this.choices.size(); + } + public Object getElementAt(int i) { return AbilityPicker.this.choices.get(i); } + } + ); + + rows.setBackground(textColor); + rows.setCellRenderer(new ImageRenderer()); + rows.ensureIndexIsVisible(rows.getModel().getSize()); + rows.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + rows.setLayoutOrientation(JList.VERTICAL); + rows.setMaximumSize(new Dimension(32767, 32767)); + rows.setMinimumSize(new Dimension(67, 16)); + rows.setOpaque(false); + rows.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent evt) { + if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() > 1) { + objectMouseClicked(evt); + } + } + }); + rows.setSelectedIndex(0); + rows.setFont(new Font("Times New Roman", 1, 17)); + + rows.addMouseWheelListener(this); + + jScrollPane2.setViewportView(rows); + + GroupLayout layout = new GroupLayout(this); + this.setLayout(layout); + + layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.LEADING).add( + GroupLayout.TRAILING, + layout.createSequentialGroup().addContainerGap().add( + layout.createParallelGroup(GroupLayout.TRAILING).add(GroupLayout.LEADING, jScrollPane2, GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE).add(GroupLayout.LEADING, + layout.createSequentialGroup().add(jLabel1).addPreferredGap(LayoutStyle.RELATED, 175, Short.MAX_VALUE).add(1, 1, 1)).add( + GroupLayout.LEADING, + layout.createSequentialGroup().add(layout.createParallelGroup(GroupLayout.LEADING) + ) + .addPreferredGap(LayoutStyle.RELATED) + .add( + layout.createParallelGroup(GroupLayout.TRAILING) + .add( + GroupLayout.LEADING, layout.createParallelGroup(GroupLayout.LEADING))))).add(10, 10, 10))); + + layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.LEADING).add( + layout.createSequentialGroup().add( + layout.createParallelGroup(GroupLayout.LEADING).add( + layout.createSequentialGroup().add(jLabel1, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE) + .add(5, 5, 5) + .add( + layout.createParallelGroup(GroupLayout.BASELINE) + ) + ).add(layout.createSequentialGroup().add(8, 8, 8))) + .addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add( + layout.createParallelGroup(GroupLayout.BASELINE)).addPreferredGap(LayoutStyle.RELATED).add(layout.createParallelGroup(GroupLayout.LEADING)).addPreferredGap( + LayoutStyle.RELATED).add(jScrollPane2, GroupLayout.PREFERRED_SIZE, 180, GroupLayout.PREFERRED_SIZE).addContainerGap(23, Short.MAX_VALUE))); + } + + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + int notches = e.getWheelRotation(); + int index = rows.getSelectedIndex(); + + if (notches < 0) { + if (index > 0) { + rows.setSelectedIndex(index-1); + rows.repaint(); + } + } else { + if (index < choices.size() - 1) { + rows.setSelectedIndex(index+1); + rows.repaint(); + } + } + } + + private void objectMouseClicked(MouseEvent event) { + AbilityPickerAction action = (AbilityPickerAction)choices.get(rows.getSelectedIndex()); + action.actionPerformed(null); + } + + class ImageRenderer extends DefaultListCellRenderer { + + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + + JLabel label = ((JLabel) c); + label.setOpaque(false); + label.setForeground(Color.white); + + if (choices.size() <= index) return label; + + Object object = choices.get(index); + String name = object.toString(); + label.setText(name); + + if (isSelected) { + label.setIcon(new ImageIcon(rightImageHovered)); + label.setForeground(SELECTED_COLOR); + label.setBorder(BorderFactory.createLineBorder(BORDER_COLOR)); + } else { + label.setIcon(new ImageIcon(rightImage)); + } + + return label; + } + + private static final long serialVersionUID = 7689696087189956997L; + } + + public static void main(String[] argv) { + JFrame jframe = new JFrame("Test"); + + List objectList = new ArrayList(); + objectList.add("T: add {R} to your mana pool"); + objectList.add("T: add {B} to your mana pool"); + objectList.add("Cancel"); + AbilityPicker panel = new AbilityPicker(objectList, "Choose ability"); + jframe.add(panel); + jframe.setSize(640, 480); + jframe.setVisible(true); + } + + public class AbilityPickerAction extends AbstractAction { + + private UUID id; + + public AbilityPickerAction(UUID id, String choice) { + this.id = id; + putValue(Action.NAME, choice); + } + + @Override + public void actionPerformed(ActionEvent e) { + // cancel + if (id == null) { + session.sendPlayerBoolean(gameId, false); + } else { + session.sendPlayerUUID(gameId, id); + } + setVisible(false); + } + + @Override + public String toString() { + return (String)getValue(Action.NAME); + } + + } +} diff --git a/Mage.Client/src/main/java/mage/client/components/ability/BackgroundPainter.java b/Mage.Client/src/main/java/mage/client/components/ability/BackgroundPainter.java new file mode 100644 index 00000000000..c91d5ab87da --- /dev/null +++ b/Mage.Client/src/main/java/mage/client/components/ability/BackgroundPainter.java @@ -0,0 +1,60 @@ +package mage.client.components.ability; + +import org.jdesktop.swingx.painter.AbstractPainter; +import sun.swing.CachedPainter; + +import javax.swing.*; +import java.awt.*; +import java.awt.geom.Area; +import java.awt.geom.Ellipse2D; +import java.awt.geom.RoundRectangle2D; + +/** + * Background painter. + * + * @author nantuko + */ +public class BackgroundPainter extends AbstractPainter { + + private Color bgColor = Color.black; + + float bgalpha = 0.8f; + + public BackgroundPainter() { + super(); + setAntialiasing(true); + } + + @Override + protected void doPaint(Graphics2D g2, Object o, int i, int i1) { + float alpha = bgalpha; + Component c = (Component)o; + Composite composite = g2.getComposite(); + if (composite instanceof AlphaComposite) { + alpha *= ((AlphaComposite) composite).getAlpha(); + } + + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); + g2.setColor(bgColor); + + RoundRectangle2D rect = new RoundRectangle2D.Double(0, 0, c.getWidth() - 1, c.getHeight() - 1, 24, 24); + g2.fill(rect); + + Ellipse2D ellipse = new Ellipse2D.Double(-c.getWidth(), + c.getHeight() / 3.0, c.getWidth() * 3.0, + c.getHeight() * 2.0); + + Area area = new Area(new Rectangle(0, 0, c.getWidth(), c.getHeight())); + area.subtract(new Area(ellipse)); + area.intersect(new Area(rect)); + + alpha = 0.1f; + if (composite instanceof AlphaComposite) { + alpha *= ((AlphaComposite) composite).getAlpha(); + } + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); + g2.setColor(new Color(1.0f, 1.0f, 1.0f)); + g2.fill(area); + g2.setComposite(composite); + } +} \ No newline at end of file diff --git a/Mage.Client/src/main/java/mage/client/components/ability/MageScrollButton.java b/Mage.Client/src/main/java/mage/client/components/ability/MageScrollButton.java new file mode 100644 index 00000000000..c64c643ab01 --- /dev/null +++ b/Mage.Client/src/main/java/mage/client/components/ability/MageScrollButton.java @@ -0,0 +1,75 @@ +package mage.client.components.ability; + +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Image; +import java.io.File; + +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.plaf.basic.BasicArrowButton; +import javax.swing.plaf.metal.MetalScrollButton; + + +/** + * Buttons for scroll bar. + * + * @author nantuko + */ +public class MageScrollButton extends MetalScrollButton { + + private static Icon buttonLeft; + private static Icon buttonRight; + private static ImageIcon buttonUp; + private static ImageIcon buttonDown; + + private int width; + + static { + buttonLeft = new ImageIcon(MageScrollButton.class.getResource("/buttons/left.png")); + buttonRight = new ImageIcon(MageScrollButton.class.getResource("/buttons/right.png")); + buttonUp = new ImageIcon(MageScrollButton.class.getResource("/buttons/up.png")); + buttonDown = new ImageIcon(MageScrollButton.class.getResource("/buttons/down.png")); + } + + public MageScrollButton(int direction, int width, boolean freeStanding) { + super(direction, width, freeStanding); + setOpaque(false); + this.width = width; + buttonUp.setImage(buttonUp.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH)); + buttonDown.setImage(buttonDown.getImage().getScaledInstance(width, width, Image.SCALE_SMOOTH)); + } + + @Override + public Dimension getMaximumSize() { + return this.getPreferredSize(); + } + + @Override + public Dimension getMinimumSize() { + return this.getPreferredSize(); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(width, width); + } + + @Override + public void paint(Graphics g) { + switch (getDirection()) { + case BasicArrowButton.WEST: + buttonLeft.paintIcon(null, g, 0, 0); + break; + case BasicArrowButton.EAST: + buttonRight.paintIcon(null, g, 0, 0); + break; + case BasicArrowButton.NORTH: + buttonUp.paintIcon(null, g, 0, 0); + break; + case BasicArrowButton.SOUTH: + buttonDown.paintIcon(null, g, 0, 0); + break; + } + } +} diff --git a/Mage.Client/src/main/java/mage/client/components/ability/MageScrollbarUI.java b/Mage.Client/src/main/java/mage/client/components/ability/MageScrollbarUI.java new file mode 100644 index 00000000000..658017a1720 --- /dev/null +++ b/Mage.Client/src/main/java/mage/client/components/ability/MageScrollbarUI.java @@ -0,0 +1,165 @@ +package mage.client.components.ability; + +import java.awt.AlphaComposite; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Composite; +import java.awt.GradientPaint; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Rectangle; +import java.awt.RenderingHints; +import java.awt.Stroke; +import java.awt.geom.Area; +import java.awt.geom.Rectangle2D; +import java.awt.geom.RoundRectangle2D; + +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JScrollBar; +import javax.swing.plaf.metal.MetalScrollBarUI; + +/** + * Custom scroll bar. + * + * @author nantuko + */ +public class MageScrollbarUI extends MetalScrollBarUI { + + private static int ANTI_WIDTH = -3; + + @Override + public void installUI(JComponent c) { + super.installUI(c); + c.setOpaque(false); + } + + @Override + protected JButton createDecreaseButton(int orientation) { + decreaseButton = new MageScrollButton(orientation, scrollBarWidth + ANTI_WIDTH, isFreeStanding); + return decreaseButton; + } + + @Override + protected JButton createIncreaseButton(int orientation) { + increaseButton = new MageScrollButton(orientation, scrollBarWidth + ANTI_WIDTH, isFreeStanding); + return increaseButton; + } + + @Override + protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) { + Graphics2D g2 = (Graphics2D) g; + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + if (scrollbar.getOrientation() == JScrollBar.VERTICAL) { + int width = trackBounds.width - 4 + ANTI_WIDTH; + int height = trackBounds.height; + + g2.translate(trackBounds.x + 2, trackBounds.y); + + Rectangle2D casing = new Rectangle2D.Double(0, 0, width, height); + g2.setColor(Color.BLACK); + + float alpha = 0.5f; + Composite composite = g2.getComposite(); + if (composite instanceof AlphaComposite) { + alpha *= ((AlphaComposite) composite).getAlpha(); + } + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); + g2.fill(casing); + g2.setComposite(composite); + + g2.drawLine(-1, 0, -1, height); + g2.drawLine(-2, 0, -2, height); + + g2.drawLine(width, 0, width, height); + g2.drawLine(width + 1, 0, width + 1, height); + + RoundRectangle2D roundCasing = new RoundRectangle2D.Double(0, 2, width, height - 4, width, width); + Area area = new Area(casing); + area.subtract(new Area(roundCasing)); + g2.fill(area); + + g2.translate(-trackBounds.x - 2, -trackBounds.y); + } else { + int width = trackBounds.width; + int height = trackBounds.height - 4; + + g2.translate(trackBounds.x, trackBounds.y + 2); + + Rectangle2D casing = new Rectangle2D.Double(0, 0, width, height); + g2.setColor(Color.BLACK); + + float alpha = 0.5f; + Composite composite = g2.getComposite(); + if (composite instanceof AlphaComposite) { + alpha *= ((AlphaComposite) composite).getAlpha(); + } + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); + g2.fill(casing); + g2.setComposite(composite); + + g2.drawLine(0, -1, width, -1); + g2.drawLine(0, -2, width, -2); + + g2.drawLine(0, height, width, height); + g2.drawLine(0, height + 1, width, height + 1); + + RoundRectangle2D roundCasing = new RoundRectangle2D.Double(2, 0, width - 4, height, height, height); + Area area = new Area(casing); + area.subtract(new Area(roundCasing)); + g2.fill(area); + + g2.translate(-trackBounds.x, -trackBounds.y - 2); + } + + } + + @Override + protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) { + Graphics2D g2 = (Graphics2D) g; + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + if (scrollbar.getOrientation() == JScrollBar.VERTICAL) { + g2.translate(thumbBounds.x + 1, thumbBounds.y + 2); + + int width = thumbBounds.width - 3 + ANTI_WIDTH; + int height = thumbBounds.height - 4; + + RoundRectangle2D casing = new RoundRectangle2D.Double(0, 0, width, height, width, width); + g2.setColor(Color.BLACK); + Paint paint = g2.getPaint(); + g2.setPaint(new GradientPaint(0, 0, new Color(0x818a9b), 0, height, new Color(0x3a4252))); + g2.fill(casing); + g2.setPaint(paint); + + Stroke stroke = g2.getStroke(); + g2.setStroke(new BasicStroke(2.0f)); + g2.draw(casing); + g2.setStroke(stroke); + + g2.translate(-thumbBounds.x - 1, -thumbBounds.y - 2); + } else { + g2.translate(thumbBounds.x + 2, thumbBounds.y + 1); + + int width = thumbBounds.width - 4; + int height = thumbBounds.height - 3; + + RoundRectangle2D casing = new RoundRectangle2D.Double(0, 0, width, height, height, height); + g2.setColor(Color.BLACK); + + Paint paint = g2.getPaint(); + g2.setPaint(new GradientPaint(0, 0, new Color(0x818a9b), 0, height, new Color(0x3a4252))); + g2.fill(casing); + g2.setPaint(paint); + + Stroke stroke = g2.getStroke(); + g2.setStroke(new BasicStroke(2.0f)); + g2.draw(casing); + g2.setStroke(stroke); + + g2.translate(-thumbBounds.x - 2, -thumbBounds.y - 1); + } + } +} diff --git a/Mage.Client/src/main/java/mage/client/game/AbilityPicker.java b/Mage.Client/src/main/java/mage/client/game/AbilityPicker.java index b521cb0c92d..890e9b8bc90 100644 --- a/Mage.Client/src/main/java/mage/client/game/AbilityPicker.java +++ b/Mage.Client/src/main/java/mage/client/game/AbilityPicker.java @@ -28,19 +28,18 @@ package mage.client.game; -import java.awt.Point; +import mage.client.MageFrame; +import mage.client.util.gui.GuiDisplayUtil; +import mage.remote.Session; +import mage.view.AbilityPickerView; + +import javax.swing.*; +import javax.swing.event.PopupMenuEvent; +import javax.swing.event.PopupMenuListener; +import java.awt.*; import java.awt.event.ActionEvent; import java.util.Map.Entry; import java.util.UUID; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JPopupMenu; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; -import mage.client.MageFrame; -import mage.remote.Session; -import mage.client.util.gui.GuiDisplayUtil; -import mage.view.AbilityPickerView; /** * diff --git a/Mage.Client/src/main/java/mage/client/game/GamePane.java b/Mage.Client/src/main/java/mage/client/game/GamePane.java index 37c4344a9be..a6b8b6d3bd4 100644 --- a/Mage.Client/src/main/java/mage/client/game/GamePane.java +++ b/Mage.Client/src/main/java/mage/client/game/GamePane.java @@ -35,6 +35,8 @@ package mage.client.game; import mage.client.*; + +import javax.swing.*; import java.util.UUID; /** diff --git a/Mage.Client/src/main/java/mage/client/util/SettingsManager.java b/Mage.Client/src/main/java/mage/client/util/SettingsManager.java new file mode 100644 index 00000000000..a0629bd2cf6 --- /dev/null +++ b/Mage.Client/src/main/java/mage/client/util/SettingsManager.java @@ -0,0 +1,68 @@ +package mage.client.util; + +import com.sun.org.apache.xerces.internal.impl.dv.xs.YearMonthDV; + +import java.awt.*; +import java.util.UUID; + +/** + * Contains dynamic settings for client. + * + * @author nantuko + */ +public class SettingsManager { + private static SettingsManager fInstance = new SettingsManager(); + + public static SettingsManager getInstance() { + return fInstance; + } + + public int getScreenWidth() { + return screenWidth; + } + + public void setScreenWidth(int screenWidth) { + this.screenWidth = screenWidth; + } + + public int getScreenHeight() { + return screenHeight; + } + + public void setScreenHeight(int screenHeight) { + this.screenHeight = screenHeight; + } + + public void setScreenWidthAndHeight(int screenWidth, int screenHeight) { + this.screenWidth = screenWidth; + this.screenHeight = screenHeight; + } + + /** + * Get centered component position. Depends on screen width and height. + * + * @param dialogWidth + * @param dialogHeight + * @return + */ + public Point getComponentPosition(int dialogWidth, int dialogHeight) { + if (dialogWidth == 0) { + throw new IllegalArgumentException("dialogWidth can't be 0"); + } + if (dialogHeight == 0) { + throw new IllegalArgumentException("dialogHeight can't be 0"); + } + + int width = Math.max(screenWidth, dialogWidth); + int height = Math.max(screenHeight, dialogHeight); + + int x = ((width - dialogWidth) / 2); + int y = ((height - dialogHeight) / 2); + + return new Point(x, y); + } + + private int screenWidth; + private int screenHeight; + +} diff --git a/Mage.Client/src/main/resources/buttons/down.png b/Mage.Client/src/main/resources/buttons/down.png new file mode 100644 index 00000000000..e5f3f8cf216 Binary files /dev/null and b/Mage.Client/src/main/resources/buttons/down.png differ diff --git a/Mage.Client/src/main/resources/buttons/left.png b/Mage.Client/src/main/resources/buttons/left.png new file mode 100644 index 00000000000..846b6566992 Binary files /dev/null and b/Mage.Client/src/main/resources/buttons/left.png differ diff --git a/Mage.Client/src/main/resources/buttons/right.png b/Mage.Client/src/main/resources/buttons/right.png new file mode 100644 index 00000000000..e4f033131db Binary files /dev/null and b/Mage.Client/src/main/resources/buttons/right.png differ diff --git a/Mage.Client/src/main/resources/buttons/up.png b/Mage.Client/src/main/resources/buttons/up.png new file mode 100644 index 00000000000..7537b523d18 Binary files /dev/null and b/Mage.Client/src/main/resources/buttons/up.png differ diff --git a/Mage.Client/src/main/resources/game/right.png b/Mage.Client/src/main/resources/game/right.png new file mode 100644 index 00000000000..b38267d3df8 Binary files /dev/null and b/Mage.Client/src/main/resources/game/right.png differ diff --git a/Mage.Client/src/main/resources/game/right_hovered.png b/Mage.Client/src/main/resources/game/right_hovered.png new file mode 100644 index 00000000000..000cbec5ad9 Binary files /dev/null and b/Mage.Client/src/main/resources/game/right_hovered.png differ