mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +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);
|
||||
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();
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
addTooltipContainer();
|
||||
setBackground();
|
||||
addMageLabel();
|
||||
setAppIcon();
|
||||
|
||||
desktopPane.add(ArrowBuilder.getArrowsPanel(), JLayeredPane.DRAG_LAYER);
|
||||
|
||||
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) {
|
||||
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
|
||||
Session session = MageFrame.getSession();
|
||||
try {
|
||||
PhaseManager.getInstance().setName(this.newPlayerPanel.getPlayerName());
|
||||
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), Sets.loadDeck(this.newPlayerPanel.getDeckFile()));
|
||||
} catch (Exception ex) {
|
||||
handleError(ex);
|
||||
|
|
|
@ -36,6 +36,7 @@ import javax.swing.JOptionPane;
|
|||
import mage.client.MageFrame;
|
||||
import mage.client.chat.ChatPanel;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.GameManager;
|
||||
import mage.interfaces.callback.CallbackClient;
|
||||
import mage.interfaces.callback.ClientCallback;
|
||||
import mage.util.Logging;
|
||||
|
@ -73,6 +74,7 @@ public class Client implements CallbackClient {
|
|||
try {
|
||||
if (callback.getMethod().equals("startGame")) {
|
||||
UUID[] data = (UUID[]) callback.getData();
|
||||
GameManager.getInstance().setCurrentPlayerUUID(data[1]);
|
||||
gameStarted(data[0], data[1]);
|
||||
}
|
||||
else if (callback.getMethod().equals("replayGame")) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package mage.client.util;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Controls game state on client side.
|
||||
*
|
||||
|
@ -7,15 +9,27 @@ package mage.client.util;
|
|||
*/
|
||||
public class GameManager {
|
||||
private static GameManager fInstance = new GameManager();
|
||||
|
||||
public static GameManager getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
public void setStackSize(int stackSize) {
|
||||
this.stackSize = stackSize;
|
||||
}
|
||||
|
||||
public int getStackSize() {
|
||||
return stackSize;
|
||||
}
|
||||
|
||||
public UUID getCurrentPlayerUUID() {
|
||||
return currentPlayerUUID;
|
||||
}
|
||||
|
||||
public void setCurrentPlayerUUID(UUID currentPlayerUUID) {
|
||||
this.currentPlayerUUID = currentPlayerUUID;
|
||||
}
|
||||
|
||||
private int stackSize;
|
||||
private UUID currentPlayerUUID;
|
||||
}
|
||||
|
|
|
@ -2,9 +2,11 @@ package mage.client.util;
|
|||
|
||||
import mage.client.MageFrame;
|
||||
import mage.view.GameView;
|
||||
import mage.view.PlayerView;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
public class PhaseManager {
|
||||
|
@ -51,21 +53,27 @@ public class PhaseManager {
|
|||
put("End Turn - play instants and activated abilities.", END_OF_TURN_OTHERS);
|
||||
}};
|
||||
|
||||
private String yourName;
|
||||
|
||||
public static PhaseManager getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
public void setName(String yourName) {
|
||||
this.yourName = yourName;
|
||||
}
|
||||
|
||||
public boolean isSkip(GameView gameView, String message) {
|
||||
if (GameManager.getInstance().getStackSize() > 0) {
|
||||
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()) {
|
||||
if (message.equals(entry.getKey())) {
|
||||
Preferences prefs = MageFrame.getPreferences();
|
||||
|
|
Loading…
Reference in a new issue