This commit is contained in:
magenoxx 2010-10-22 11:54:23 +00:00
parent 6abd8230a7
commit 5392b92c38
12 changed files with 220 additions and 68 deletions

View file

@ -1,63 +1,71 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>0.3</version>
</parent>
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>0.3</version>
</parent>
<groupId>org.mage</groupId>
<artifactId>mage-client</artifactId>
<packaging>jar</packaging>
<version>0.3</version>
<name>Mage Client</name>
<url>http://maven.apache.org</url>
<artifactId>mage-client</artifactId>
<packaging>jar</packaging>
<version>0.3</version>
<name>Mage Client</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.mage</groupId>
<artifactId>mage</artifactId>
<version>${mage-version}</version>
<groupId>org.mage</groupId>
<artifactId>mage</artifactId>
<version>${mage-version}</version>
</dependency>
<dependency>
<groupId>org.mage</groupId>
<artifactId>mage-common</artifactId>
<version>${mage-version}</version>
<groupId>org.mage</groupId>
<artifactId>mage-common</artifactId>
<version>${mage-version}</version>
</dependency>
<dependency>
<groupId>org.mage</groupId>
<artifactId>mage-sets</artifactId>
<version>${mage-version}</version>
<groupId>org.mage</groupId>
<artifactId>mage-sets</artifactId>
<version>${mage-version}</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<resources>
<resource>
<directory>resources</directory>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</plugins>
<finalName>mage-client</finalName>
</build>
<properties>
<mage-version>0.3</mage-version>
</properties>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View file

@ -77,9 +77,9 @@ import mage.Constants.CardType;
import mage.client.MageFrame;
import mage.client.game.PlayAreaPanel;
import mage.client.remote.Session;
import mage.client.util.ArrowBuilder;
import mage.client.util.Config;
import mage.client.util.ImageHelper;
import mage.client.util.gui.ArrowBuilder;
import mage.sets.Sets;
import mage.view.AbilityView;
import mage.view.CardView;

View file

@ -56,6 +56,10 @@ public class Cards extends javax.swing.JPanel {
/** Creates new form Cards */
public Cards() {
initComponents();
setOpaque(false);
jScrollPane1.setOpaque(false);
jScrollPane1.getViewport().setOpaque(false);
cardArea.setOpaque(false);
}
public boolean loadCards(CardsView cardsView, BigCard bigCard, UUID gameId) {

View file

@ -58,6 +58,8 @@ public class ChatPanel extends javax.swing.JPanel {
/** Creates new form ChatPanel */
public ChatPanel() {
initComponents();
jScrollPane1.setOpaque(false);
jScrollPane1.getViewport().setOpaque(false);
}
public void connect(UUID chatId) {

View file

@ -39,14 +39,20 @@ import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.Map.Entry;
import javax.imageio.ImageIO;
import mage.client.cards.BigCard;
import mage.client.cards.Permanent;
import mage.client.util.Config;
import mage.client.util.gui.ImagePanel;
import mage.view.PermanentView;
/**
@ -101,7 +107,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane implements Compon
moveToFront(perm);
perm.update(permanent);
}
private void groupAttachments(PermanentView permanent) {
Permanent perm = permanents.get(permanent.getId());
int position = getPosition(perm);

View file

@ -38,6 +38,9 @@ import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@ -54,8 +57,11 @@ import mage.client.dialog.PickChoiceDialog;
import mage.client.dialog.ShowCardsDialog;
import mage.client.game.FeedbackPanel.FeedbackMode;
import mage.client.remote.Session;
import mage.client.util.ArrowBuilder;
import mage.client.util.Config;
import mage.client.util.Constants;
import mage.client.util.ImageHelper;
import mage.client.util.gui.ArrowBuilder;
import mage.client.util.gui.ImagePanel;
import mage.util.Logging;
import mage.view.AbilityPickerView;
import mage.view.CardsView;
@ -72,7 +78,6 @@ public class GamePanel extends javax.swing.JPanel {
private final static Logger logger = Logging.getLogger(GamePanel.class.getName());
private Map<UUID, PlayAreaPanel> players = new HashMap<UUID, PlayAreaPanel>();
//private Map<UUID, PlayAreaPanel> players = new HashMap<UUID, PlayAreaPanel>();
private Map<UUID, ExileZoneDialog> exiles = new HashMap<UUID, ExileZoneDialog>();
private UUID gameId;
private UUID playerId;
@ -82,28 +87,45 @@ public class GamePanel extends javax.swing.JPanel {
public GamePanel() {
initComponents();
// Override layout (I can't edit generated code)
this.setLayout(new BorderLayout());
final JLayeredPane j = new JLayeredPane();
j.add(ArrowBuilder.getArrowsPanel(), JLayeredPane.MODAL_LAYER);
j.setSize(1024,768);
//j.setBorder(BorderFactory.createLineBorder(Color.green));
j.add(jSplitPane1, JLayeredPane.DEFAULT_LAYER);
this.add(j);
// Enlarge jlayeredpane on resize
addComponentListener(new ComponentAdapter(){
@Override
public void componentResized(ComponentEvent e) {
int width = ((JComponent)e.getSource()).getWidth();
int height = ((JComponent)e.getSource()).getHeight();
j.setSize(width, height);
JPanel arrowsPanel = ArrowBuilder.getArrowsPanelRef();
if (arrowsPanel != null) arrowsPanel.setSize(width, height);
jSplitPane1.setSize(width, height);
}
});
//FIXME: remove from here
try {
BufferedImage background = ImageHelper.loadImage("/dk_gray.jpg");
ImagePanel bgPanel = new ImagePanel(background, ImagePanel.TILED);
// Override layout (I can't edit generated code)
this.setLayout(new BorderLayout());
final JLayeredPane j = new JLayeredPane();
j.add(ArrowBuilder.getArrowsPanel(), JLayeredPane.MODAL_LAYER);
j.setSize(1024,768);
//j.setBorder(BorderFactory.createLineBorder(Color.green));
//this.add(j);
j.add(jSplitPane1, JLayeredPane.DEFAULT_LAYER);
jSplitPane1.setOpaque(false);
pnlBattlefield.setOpaque(false);
jPanel3.setOpaque(false);
hand.setOpaque(false);
chatPanel.setOpaque(false);
bgPanel.add(j);
this.add(bgPanel);
// Enlarge jlayeredpane on resize
addComponentListener(new ComponentAdapter(){
@Override
public void componentResized(ComponentEvent e) {
int width = ((JComponent)e.getSource()).getWidth();
int height = ((JComponent)e.getSource()).getHeight();
j.setSize(width, height);
JPanel arrowsPanel = ArrowBuilder.getArrowsPanelRef();
if (arrowsPanel != null) arrowsPanel.setSize(width, height);
jSplitPane1.setSize(width, height);
}
});
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
public void cleanUp() {

View file

@ -56,6 +56,10 @@ public class PlayAreaPanel extends javax.swing.JPanel {
/** Creates new form PlayAreaPanel */
public PlayAreaPanel() {
initComponents();
setOpaque(false);
jScrollPane1.setOpaque(false);
jScrollPane1.getViewport().setOpaque(false);
battlefieldPanel.setOpaque(false);
}
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId) {

View file

@ -28,6 +28,8 @@
package mage.client.util;
import java.io.File;
/**
*
* @author BetaSteward_at_googlemail.com
@ -66,5 +68,4 @@ public final class Constants {
public static final int DAMAGE_MAX_LEFT = 180;
public static final double SCALE_FACTOR = 0.5;
}

View file

@ -1,4 +1,4 @@
package mage.client.util;
package mage.client.util.gui;
import java.awt.AlphaComposite;
import java.awt.BorderLayout;

View file

@ -1,4 +1,4 @@
package mage.client.util;
package mage.client.util.gui;
import java.awt.BorderLayout;
import java.awt.Color;

View file

@ -0,0 +1,105 @@
package mage.client.util.gui;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
@SuppressWarnings("serial")
public class ImagePanel extends JPanel {
public static final int TILED = 0;
public static final int SCALED = 1;
public static final int ACTUAL = 2;
private BufferedImage image;
private int style;
private float alignmentX = 0.5f;
private float alignmentY = 0.5f;
public ImagePanel(BufferedImage image) {
this(image, TILED);
}
public ImagePanel(BufferedImage image, int style) {
this.image = image;
this.style = style;
setLayout(new BorderLayout());
}
public void setImageAlignmentX(float alignmentX) {
this.alignmentX = alignmentX > 1.0f ? 1.0f : alignmentX < 0.0f ? 0.0f : alignmentX;
}
public void setImageAlignmentY(float alignmentY) {
this.alignmentY = alignmentY > 1.0f ? 1.0f : alignmentY < 0.0f ? 0.0f : alignmentY;
}
public void add(JComponent component) {
add(component, null);
}
public void add(JComponent component, Object constraints) {
component.setOpaque(false);
if (component instanceof JScrollPane) {
JScrollPane scrollPane = (JScrollPane) component;
JViewport viewport = scrollPane.getViewport();
viewport.setOpaque(false);
Component c = viewport.getView();
if (c instanceof JComponent) {
((JComponent) c).setOpaque(false);
}
}
super.add(component, constraints);
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (image == null)
return;
switch (style) {
case TILED:
drawTiled(g);
break;
case SCALED:
Dimension d = getSize();
g.drawImage(image, 0, 0, d.width, d.height, null);
break;
case ACTUAL:
drawActual(g);
break;
}
}
private void drawTiled(Graphics g) {
Dimension d = getSize();
int width = image.getWidth(null);
int height = image.getHeight(null);
for (int x = 0; x < d.width; x += width) {
for (int y = 0; y < d.height; y += height) {
g.drawImage(image, x, y, null, null);
}
}
}
private void drawActual(Graphics g) {
Dimension d = getSize();
float x = (d.width - image.getWidth()) * alignmentX;
float y = (d.height - image.getHeight()) * alignmentY;
g.drawImage(image, (int) x, (int) y, this);
}
}