mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Merge
This commit is contained in:
commit
c57cf32496
5 changed files with 107 additions and 71 deletions
|
@ -138,71 +138,13 @@ public class MageFrame extends javax.swing.JFrame {
|
||||||
desktopPane.add(pickNumber, JLayeredPane.POPUP_LAYER);
|
desktopPane.add(pickNumber, JLayeredPane.POPUP_LAYER);
|
||||||
session.getUI().addComponent(MageComponents.DESKTOP_PANE, desktopPane);
|
session.getUI().addComponent(MageComponents.DESKTOP_PANE, desktopPane);
|
||||||
|
|
||||||
final JEditorPane cardInfoPane = (JEditorPane) Plugins.getInstance().getCardInfoPane();
|
|
||||||
cardInfoPane.setSize(320, 201);
|
|
||||||
cardInfoPane.setLocation(40, 40);
|
|
||||||
cardInfoPane.setBackground(new Color(0,0,0,0));
|
|
||||||
|
|
||||||
MageRoundPane popupContainer = new MageRoundPane();
|
|
||||||
popupContainer.setLayout(null);
|
|
||||||
|
|
||||||
popupContainer.add(cardInfoPane);
|
|
||||||
popupContainer.setVisible(false);
|
|
||||||
popupContainer.setBounds(0, 0, 320 + 80, 201 + 80);
|
|
||||||
|
|
||||||
desktopPane.add(popupContainer, JLayeredPane.POPUP_LAYER);
|
|
||||||
|
|
||||||
session.getUI().addComponent(MageComponents.CARD_INFO_PANE, cardInfoPane);
|
|
||||||
session.getUI().addComponent(MageComponents.POPUP_CONTAINER, popupContainer);
|
|
||||||
|
|
||||||
ManaSymbols.loadImages();
|
ManaSymbols.loadImages();
|
||||||
|
|
||||||
String filename = "/background.jpg";
|
addTooltipContainer();
|
||||||
try {
|
setBackground();
|
||||||
if (Plugins.getInstance().isThemePluginLoaded()) {
|
addMageLabel();
|
||||||
Map<String, JComponent> ui = new HashMap<String, JComponent>();
|
setAppIcon();
|
||||||
backgroundPane = (ImagePanel) Plugins.getInstance().updateTablePanel(ui);
|
|
||||||
} else {
|
|
||||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
|
||||||
BufferedImage background = ImageIO.read(is);
|
|
||||||
backgroundPane = new ImagePanel(background, ImagePanel.SCALED);
|
|
||||||
}
|
|
||||||
backgroundPane.setSize(1024, 768);
|
|
||||||
desktopPane.add(backgroundPane, JLayeredPane.DEFAULT_LAYER);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
filename = "/label-mage.png";
|
|
||||||
try {
|
|
||||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
|
||||||
|
|
||||||
float ratio = 1179.0f / 678.0f;
|
|
||||||
titleRectangle = new Rectangle(640, (int)(640 / ratio));
|
|
||||||
if (is != null) {
|
|
||||||
BufferedImage image = ImageIO.read(is);
|
|
||||||
//ImageIcon resized = new ImageIcon(image.getScaledInstance(titleRectangle.width, titleRectangle.height, java.awt.Image.SCALE_SMOOTH));
|
|
||||||
title = new JLabel();
|
|
||||||
title.setIcon(new ImageIcon(image));
|
|
||||||
backgroundPane.setLayout(null);
|
|
||||||
backgroundPane.add(title);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
filename = "/icon-mage.png";
|
|
||||||
try {
|
|
||||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
|
||||||
|
|
||||||
if (is != null) {
|
|
||||||
BufferedImage image = ImageIO.read(is);
|
|
||||||
setIconImage(image);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
desktopPane.add(ArrowBuilder.getArrowsPanel(), JLayeredPane.DRAG_LAYER);
|
desktopPane.add(ArrowBuilder.getArrowsPanel(), JLayeredPane.DRAG_LAYER);
|
||||||
|
|
||||||
desktopPane.addComponentListener(new ComponentAdapter(){
|
desktopPane.addComponentListener(new ComponentAdapter(){
|
||||||
|
@ -273,6 +215,77 @@ public class MageFrame extends javax.swing.JFrame {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addTooltipContainer() {
|
||||||
|
final JEditorPane cardInfoPane = (JEditorPane) Plugins.getInstance().getCardInfoPane();
|
||||||
|
cardInfoPane.setSize(320, 201);
|
||||||
|
cardInfoPane.setLocation(40, 40);
|
||||||
|
cardInfoPane.setBackground(new Color(0,0,0,0));
|
||||||
|
|
||||||
|
MageRoundPane popupContainer = new MageRoundPane();
|
||||||
|
popupContainer.setLayout(null);
|
||||||
|
|
||||||
|
popupContainer.add(cardInfoPane);
|
||||||
|
popupContainer.setVisible(false);
|
||||||
|
popupContainer.setBounds(0, 0, 320 + 80, 201 + 80);
|
||||||
|
|
||||||
|
desktopPane.add(popupContainer, JLayeredPane.POPUP_LAYER);
|
||||||
|
|
||||||
|
session.getUI().addComponent(MageComponents.CARD_INFO_PANE, cardInfoPane);
|
||||||
|
session.getUI().addComponent(MageComponents.POPUP_CONTAINER, popupContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setBackground() {
|
||||||
|
String filename = "/background.jpg";
|
||||||
|
try {
|
||||||
|
if (Plugins.getInstance().isThemePluginLoaded()) {
|
||||||
|
Map<String, JComponent> ui = new HashMap<String, JComponent>();
|
||||||
|
backgroundPane = (ImagePanel) Plugins.getInstance().updateTablePanel(ui);
|
||||||
|
} else {
|
||||||
|
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||||
|
BufferedImage background = ImageIO.read(is);
|
||||||
|
backgroundPane = new ImagePanel(background, ImagePanel.SCALED);
|
||||||
|
}
|
||||||
|
backgroundPane.setSize(1024, 768);
|
||||||
|
desktopPane.add(backgroundPane, JLayeredPane.DEFAULT_LAYER);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMageLabel() {
|
||||||
|
String filename = "/label-mage.png";
|
||||||
|
try {
|
||||||
|
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||||
|
|
||||||
|
float ratio = 1179.0f / 678.0f;
|
||||||
|
titleRectangle = new Rectangle(640, (int)(640 / ratio));
|
||||||
|
if (is != null) {
|
||||||
|
BufferedImage image = ImageIO.read(is);
|
||||||
|
//ImageIcon resized = new ImageIcon(image.getScaledInstance(titleRectangle.width, titleRectangle.height, java.awt.Image.SCALE_SMOOTH));
|
||||||
|
title = new JLabel();
|
||||||
|
title.setIcon(new ImageIcon(image));
|
||||||
|
backgroundPane.setLayout(null);
|
||||||
|
backgroundPane.add(title);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAppIcon() {
|
||||||
|
String filename = "/icon-mage.png";
|
||||||
|
try {
|
||||||
|
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||||
|
|
||||||
|
if (is != null) {
|
||||||
|
BufferedImage image = ImageIO.read(is);
|
||||||
|
setIconImage(image);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void btnImagesActionPerformed(java.awt.event.ActionEvent evt) {
|
private void btnImagesActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
Plugins.getInstance().downloadImage(CardsStorage.getAllCards());
|
Plugins.getInstance().downloadImage(CardsStorage.getAllCards());
|
||||||
|
|
|
@ -138,7 +138,6 @@ public class JoinTableDialog extends MageDialog {
|
||||||
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
||||||
Session session = MageFrame.getSession();
|
Session session = MageFrame.getSession();
|
||||||
try {
|
try {
|
||||||
PhaseManager.getInstance().setName(this.newPlayerPanel.getPlayerName());
|
|
||||||
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), Sets.loadDeck(this.newPlayerPanel.getDeckFile()));
|
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), Sets.loadDeck(this.newPlayerPanel.getDeckFile()));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleError(ex);
|
handleError(ex);
|
||||||
|
|
|
@ -36,6 +36,7 @@ import javax.swing.JOptionPane;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.chat.ChatPanel;
|
import mage.client.chat.ChatPanel;
|
||||||
import mage.client.plugins.impl.Plugins;
|
import mage.client.plugins.impl.Plugins;
|
||||||
|
import mage.client.util.GameManager;
|
||||||
import mage.interfaces.callback.CallbackClient;
|
import mage.interfaces.callback.CallbackClient;
|
||||||
import mage.interfaces.callback.ClientCallback;
|
import mage.interfaces.callback.ClientCallback;
|
||||||
import mage.util.Logging;
|
import mage.util.Logging;
|
||||||
|
@ -73,6 +74,7 @@ public class Client implements CallbackClient {
|
||||||
try {
|
try {
|
||||||
if (callback.getMethod().equals("startGame")) {
|
if (callback.getMethod().equals("startGame")) {
|
||||||
UUID[] data = (UUID[]) callback.getData();
|
UUID[] data = (UUID[]) callback.getData();
|
||||||
|
GameManager.getInstance().setCurrentPlayerUUID(data[1]);
|
||||||
gameStarted(data[0], data[1]);
|
gameStarted(data[0], data[1]);
|
||||||
}
|
}
|
||||||
else if (callback.getMethod().equals("replayGame")) {
|
else if (callback.getMethod().equals("replayGame")) {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package mage.client.util;
|
package mage.client.util;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controls game state on client side.
|
* Controls game state on client side.
|
||||||
*
|
*
|
||||||
|
@ -7,15 +9,27 @@ package mage.client.util;
|
||||||
*/
|
*/
|
||||||
public class GameManager {
|
public class GameManager {
|
||||||
private static GameManager fInstance = new GameManager();
|
private static GameManager fInstance = new GameManager();
|
||||||
|
|
||||||
public static GameManager getInstance() {
|
public static GameManager getInstance() {
|
||||||
return fInstance;
|
return fInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStackSize(int stackSize) {
|
public void setStackSize(int stackSize) {
|
||||||
this.stackSize = stackSize;
|
this.stackSize = stackSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStackSize() {
|
public int getStackSize() {
|
||||||
return stackSize;
|
return stackSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UUID getCurrentPlayerUUID() {
|
||||||
|
return currentPlayerUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentPlayerUUID(UUID currentPlayerUUID) {
|
||||||
|
this.currentPlayerUUID = currentPlayerUUID;
|
||||||
|
}
|
||||||
|
|
||||||
private int stackSize;
|
private int stackSize;
|
||||||
|
private UUID currentPlayerUUID;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,11 @@ package mage.client.util;
|
||||||
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.view.GameView;
|
import mage.view.GameView;
|
||||||
|
import mage.view.PlayerView;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
|
|
||||||
public class PhaseManager {
|
public class PhaseManager {
|
||||||
|
@ -51,21 +53,27 @@ public class PhaseManager {
|
||||||
put("End Turn - play instants and activated abilities.", END_OF_TURN_OTHERS);
|
put("End Turn - play instants and activated abilities.", END_OF_TURN_OTHERS);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
private String yourName;
|
|
||||||
|
|
||||||
public static PhaseManager getInstance() {
|
public static PhaseManager getInstance() {
|
||||||
return fInstance;
|
return fInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String yourName) {
|
|
||||||
this.yourName = yourName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isSkip(GameView gameView, String message) {
|
public boolean isSkip(GameView gameView, String message) {
|
||||||
if (GameManager.getInstance().getStackSize() > 0) {
|
if (GameManager.getInstance().getStackSize() > 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Map<String, String> map = gameView.getActivePlayerName().equals(DEFAULT_PLAYER_NAME) ? mapYou : mapOthers;
|
UUID activePlayer = null;
|
||||||
|
Map<String, String> map = mapOthers;
|
||||||
|
for (PlayerView playerView : gameView.getPlayers()) {
|
||||||
|
if (playerView.isActive()) {
|
||||||
|
activePlayer = playerView.getPlayerId();
|
||||||
|
if (activePlayer.equals(GameManager.getInstance().getCurrentPlayerUUID())) {
|
||||||
|
map = mapYou;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (activePlayer == null) {
|
||||||
|
throw new IllegalStateException("No active player found.");
|
||||||
|
}
|
||||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||||
if (message.equals(entry.getKey())) {
|
if (message.equals(entry.getKey())) {
|
||||||
Preferences prefs = MageFrame.getPreferences();
|
Preferences prefs = MageFrame.getPreferences();
|
||||||
|
|
Loading…
Reference in a new issue