mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
GUI, preferences: reworked size settings:
- added size settings for player's panel size (closes #12455, closes #12451, closes #5605); - size settings can be edit by slider or by text edit; - size settings for fonts has preview button with real text sample; - improved some tabs and hints for better UX; - improved GUI rendering performance;
This commit is contained in:
parent
921e656e3c
commit
1f3fad6594
15 changed files with 3224 additions and 5913 deletions
|
|
@ -37,11 +37,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void activated() {
|
public void activated() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deactivated() {
|
public void deactivated() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleEvent(AWTEvent event) {
|
public void handleEvent(AWTEvent event) {
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,7 @@ public class HoverButton extends JPanel implements MouseListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintComponent(Graphics g) {
|
public void paintComponent(Graphics g) {
|
||||||
|
// must ignore look and fill, so no calls of super.paintComponent(g);
|
||||||
Graphics2D g2d = (Graphics2D) g;
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
if (isEnabled()) {
|
if (isEnabled()) {
|
||||||
if (isHovered || textAlwaysVisible) {
|
if (isHovered || textAlwaysVisible) {
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ public class KeyboundButton extends JButton {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent(Graphics g) {
|
protected void paintComponent(Graphics g) {
|
||||||
|
// must ignore look and fill, so no calls of super.paintComponent(g);
|
||||||
if (ui != null && g != null) {
|
if (ui != null && g != null) {
|
||||||
Graphics sg = g.create();
|
Graphics sg = g.create();
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ public final class Constants {
|
||||||
public static final int POWBOX_TEXT_MAX_LEFT = 212;
|
public static final int POWBOX_TEXT_MAX_LEFT = 212;
|
||||||
public static final int DAMAGE_MAX_LEFT = 180;
|
public static final int DAMAGE_MAX_LEFT = 180;
|
||||||
|
|
||||||
// tooltip hints delay in ms (need more time to display long hints withour hiding)
|
// tooltip hints delay in ms (need more time to display long hints without hiding)
|
||||||
public static final int TOOLTIPS_DELAY_MS = 60 * 1000;
|
public static final int TOOLTIPS_DELAY_MS = 60 * 1000;
|
||||||
|
|
||||||
public static final Border EMPTY_BORDER = BorderFactory.createEmptyBorder(2, 2, 2, 2);
|
public static final Border EMPTY_BORDER = BorderFactory.createEmptyBorder(2, 2, 2, 2);
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,17 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
||||||
|
|
||||||
protected boolean modal = false;
|
protected boolean modal = false;
|
||||||
|
|
||||||
/**
|
// GUI performance and bugs issues:
|
||||||
* Creates new form MageDialog
|
// TODO: swing components should override paintComponent() instead paint()
|
||||||
*/
|
// TODO: swing components should use this.revalidate() instead parent.validate()
|
||||||
|
// TODO: swing components in paintComponent() must call super or paint full rect on opaque = true
|
||||||
|
|
||||||
public MageDialog() {
|
public MageDialog() {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
|
// paint calls optimization - no needs in transparent
|
||||||
|
setOpaque(true);
|
||||||
|
|
||||||
// enable a minimizing window on double clicks
|
// enable a minimizing window on double clicks
|
||||||
if (this instanceof MageDesktopIconifySupport) {
|
if (this instanceof MageDesktopIconifySupport) {
|
||||||
BasicInternalFrameUI ui = (BasicInternalFrameUI) this.getUI();
|
BasicInternalFrameUI ui = (BasicInternalFrameUI) this.getUI();
|
||||||
|
|
@ -54,6 +59,12 @@ public class MageDialog extends javax.swing.JInternalFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValidateRoot() {
|
||||||
|
// paint calls optimization - no frame auto-size on child changes
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void changeGUISize() {
|
public void changeGUISize() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -332,14 +332,18 @@ public class TestCardRenderDialog extends MageDialog {
|
||||||
possibleTargets.add(playerYou.getId());
|
possibleTargets.add(playerYou.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// need re-create panel, because it can't change size in real time
|
// player's panel
|
||||||
this.playerPanel.removeAll();
|
if (this.player == null) {
|
||||||
|
// create new panel
|
||||||
|
this.playerPanel.setLayout(new BorderLayout(5, 5));
|
||||||
|
this.player = new PlayerPanelExt(this.playerSizeMod);
|
||||||
|
this.playerPanel.add(player, BorderLayout.CENTER);
|
||||||
|
} else {
|
||||||
|
// update existing panel (recreate all inner components)
|
||||||
|
this.player.fullRefresh(this.playerSizeMod);
|
||||||
|
}
|
||||||
this.playerPanel.setPreferredSize(new java.awt.Dimension(Math.round(100 * this.playerSizeMod), 10));
|
this.playerPanel.setPreferredSize(new java.awt.Dimension(Math.round(100 * this.playerSizeMod), 10));
|
||||||
this.playerPanel.setLayout(new BorderLayout(5, 5));
|
// update data in player's panel
|
||||||
this.player = new PlayerPanelExt(this.playerSizeMod);
|
|
||||||
this.playerPanel.add(player, BorderLayout.CENTER);
|
|
||||||
//this.player.cleanUp();
|
|
||||||
//this.player.changeGUISize();
|
|
||||||
GameView gameView = new GameView(this.game.getState(), this.game, controlledId, null);
|
GameView gameView = new GameView(this.game.getState(), this.game, controlledId, null);
|
||||||
PlayerView currentPlayerView = gameView.getPlayers()
|
PlayerView currentPlayerView = gameView.getPlayers()
|
||||||
.stream()
|
.stream()
|
||||||
|
|
@ -348,7 +352,7 @@ public class TestCardRenderDialog extends MageDialog {
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
this.player.init(this.game.getId(), playerYou.getId(), isMe, this.bigCard, 0);
|
this.player.init(this.game.getId(), playerYou.getId(), isMe, this.bigCard, 0);
|
||||||
this.player.update(gameView, currentPlayerView, possibleTargets);
|
this.player.update(gameView, currentPlayerView, possibleTargets);
|
||||||
PlayAreaPanel.sizePlayerPanel(this.player, isMe, smallMode);
|
this.player.sizePlayerPanel(smallMode);
|
||||||
|
|
||||||
// update CARDS
|
// update CARDS
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -248,12 +248,14 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
resizeTimer = new Timer(1000, evt -> SwingUtilities.invokeLater(() -> {
|
resizeTimer = new Timer(1000, evt -> SwingUtilities.invokeLater(() -> {
|
||||||
resizeTimer.stop();
|
resizeTimer.stop();
|
||||||
setGUISize();
|
setGUISize(false);
|
||||||
feedbackPanel.changeGUISize();
|
feedbackPanel.changeGUISize();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
pnlHelperHandButtonsStackArea.addComponentListener(componentAdapterPlayField);
|
pnlHelperHandButtonsStackArea.addComponentListener(componentAdapterPlayField);
|
||||||
initComponents = false;
|
initComponents = false;
|
||||||
|
|
||||||
|
setGUISize(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, JComponent> getUIComponents(JLayeredPane jLayeredPane) {
|
private Map<String, JComponent> getUIComponents(JLayeredPane jLayeredPane) {
|
||||||
|
|
@ -377,7 +379,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
public void changeGUISize() {
|
public void changeGUISize() {
|
||||||
initComponents = true;
|
initComponents = true;
|
||||||
setGUISize();
|
setGUISize(true);
|
||||||
stackObjects.changeGUISize();
|
stackObjects.changeGUISize();
|
||||||
feedbackPanel.changeGUISize();
|
feedbackPanel.changeGUISize();
|
||||||
handContainer.changeGUISize();
|
handContainer.changeGUISize();
|
||||||
|
|
@ -418,7 +420,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
initComponents = false;
|
initComponents = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setGUISize() {
|
private void setGUISize(boolean themeReload) {
|
||||||
jSplitPane0.setDividerSize(GUISizeHelper.dividerBarSize);
|
jSplitPane0.setDividerSize(GUISizeHelper.dividerBarSize);
|
||||||
jSplitPane1.setDividerSize(GUISizeHelper.dividerBarSize);
|
jSplitPane1.setDividerSize(GUISizeHelper.dividerBarSize);
|
||||||
jSplitPane2.setDividerSize(GUISizeHelper.dividerBarSize);
|
jSplitPane2.setDividerSize(GUISizeHelper.dividerBarSize);
|
||||||
|
|
@ -453,7 +455,9 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
pnlShortCuts.setMinimumSize(newDimension);
|
pnlShortCuts.setMinimumSize(newDimension);
|
||||||
pnlShortCuts.setMaximumSize(newDimension);
|
pnlShortCuts.setMaximumSize(newDimension);
|
||||||
|
|
||||||
reloadThemeRelatedGraphic();
|
if (themeReload) {
|
||||||
|
reloadThemeRelatedGraphic();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reloadThemeRelatedGraphic() {
|
private void reloadThemeRelatedGraphic() {
|
||||||
|
|
@ -485,6 +489,20 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
phaseButtons.forEach((phaseName, phaseButton) -> {
|
phaseButtons.forEach((phaseName, phaseButton) -> {
|
||||||
phaseButton.update(phaseButton.getText(), ImageManagerImpl.instance.getPhaseImage(phaseName));
|
phaseButton.update(phaseButton.getText(), ImageManagerImpl.instance.getPhaseImage(phaseName));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// player panels
|
||||||
|
if (lastGameData.game != null) {
|
||||||
|
lastGameData.game.getPlayers().forEach(player -> {
|
||||||
|
PlayAreaPanel playPanel = this.players.getOrDefault(player.getPlayerId(), null);
|
||||||
|
if (playPanel != null) {
|
||||||
|
// see test render dialog for refresh commands order
|
||||||
|
playPanel.getPlayerPanel().fullRefresh(GUISizeHelper.playerPanelGuiScale);
|
||||||
|
playPanel.init(player, bigCard, gameId, player.getPriorityTimeLeftSecs());
|
||||||
|
playPanel.update(lastGameData.game, player, lastGameData.targets);
|
||||||
|
playPanel.getPlayerPanel().sizePlayerPanel(isSmallMode());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveDividerLocations() {
|
private void saveDividerLocations() {
|
||||||
|
|
@ -521,7 +539,13 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isSmallMode() {
|
||||||
|
// TODO: no needs on gui scale?
|
||||||
|
return this.getBounds().height < 770;
|
||||||
|
}
|
||||||
|
|
||||||
private void sizeToScreen() {
|
private void sizeToScreen() {
|
||||||
|
// on resize frame
|
||||||
Rectangle rect = this.getBounds();
|
Rectangle rect = this.getBounds();
|
||||||
|
|
||||||
if (rect.height < 770) {
|
if (rect.height < 770) {
|
||||||
|
|
@ -534,7 +558,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
pnlShortCuts.revalidate();
|
pnlShortCuts.revalidate();
|
||||||
pnlShortCuts.repaint();
|
pnlShortCuts.repaint();
|
||||||
for (PlayAreaPanel p : players.values()) {
|
for (PlayAreaPanel p : players.values()) {
|
||||||
p.setSizeMode(smallMode);
|
p.getPlayerPanel().sizePlayerPanel(smallMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (smallMode) {
|
} else if (smallMode) {
|
||||||
|
|
@ -546,7 +570,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
pnlShortCuts.revalidate();
|
pnlShortCuts.revalidate();
|
||||||
pnlShortCuts.repaint();
|
pnlShortCuts.repaint();
|
||||||
for (PlayAreaPanel p : players.values()) {
|
for (PlayAreaPanel p : players.values()) {
|
||||||
p.setSizeMode(smallMode);
|
p.getPlayerPanel().sizePlayerPanel(smallMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -667,6 +691,7 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
public synchronized void init(int messageId, GameView game, boolean callGameUpdateAfterInit) {
|
public synchronized void init(int messageId, GameView game, boolean callGameUpdateAfterInit) {
|
||||||
addPlayers(game);
|
addPlayers(game);
|
||||||
|
|
||||||
// default menu states
|
// default menu states
|
||||||
setMenuStates(
|
setMenuStates(
|
||||||
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
|
PreferencesDialog.getCachedValue(KEY_GAME_MANA_AUTOPAYMENT, "true").equals("true"),
|
||||||
|
|
@ -772,8 +797,10 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set init sizes
|
||||||
for (PlayAreaPanel p : players.values()) {
|
for (PlayAreaPanel p : players.values()) {
|
||||||
p.setSizeMode(smallMode);
|
p.getPlayerPanel().sizePlayerPanel(isSmallMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
GridBagConstraints panelC = new GridBagConstraints();
|
GridBagConstraints panelC = new GridBagConstraints();
|
||||||
|
|
@ -785,21 +812,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
this.pnlBattlefield.add(topPanel, panelC);
|
this.pnlBattlefield.add(topPanel, panelC);
|
||||||
panelC.gridy = 1;
|
panelC.gridy = 1;
|
||||||
this.pnlBattlefield.add(bottomPanel, panelC);
|
this.pnlBattlefield.add(bottomPanel, panelC);
|
||||||
|
|
||||||
// TODO: combat arrows aren't visible on re-connect, must click on avatar to update correctrly
|
|
||||||
// reason: panels aren't visible/located here, so battlefieldpanel see wrong sizes
|
|
||||||
// recalc all component sizes and update permanents/arrows positions
|
|
||||||
// if you don't do it here then will catch wrong arrows drawing on re-connect (no sortLayout calls)
|
|
||||||
/*
|
|
||||||
this.validate();
|
|
||||||
for (Map.Entry<UUID, PlayAreaPanel> p : players.entrySet()) {
|
|
||||||
PlayerView playerView = game.getPlayers().stream().filter(view -> view.getPlayerId().equals(p.getKey())).findFirst().orElse(null);
|
|
||||||
if (playerView != null) {
|
|
||||||
p.getValue().getBattlefieldPanel().updateSize();
|
|
||||||
p.getValue().update(null, playerView, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void updateGame(int messageId, GameView game) {
|
public synchronized void updateGame(int messageId, GameView game) {
|
||||||
|
|
@ -2423,8 +2435,6 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
initPopupMenuTriggerOrder();
|
initPopupMenuTriggerOrder();
|
||||||
|
|
||||||
setGUISize();
|
|
||||||
|
|
||||||
// Replay panel to control replay of games
|
// Replay panel to control replay of games
|
||||||
javax.swing.GroupLayout gl_pnlReplay = new javax.swing.GroupLayout(pnlReplay);
|
javax.swing.GroupLayout gl_pnlReplay = new javax.swing.GroupLayout(pnlReplay);
|
||||||
pnlReplay.setLayout(gl_pnlReplay);
|
pnlReplay.setLayout(gl_pnlReplay);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import static mage.client.dialog.PreferencesDialog.*;
|
||||||
/**
|
/**
|
||||||
* GUI: play area panel (player with avatar/mana panel + battlefield panel)
|
* GUI: play area panel (player with avatar/mana panel + battlefield panel)
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com, JayDi85
|
||||||
*/
|
*/
|
||||||
public class PlayAreaPanel extends javax.swing.JPanel {
|
public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
|
|
@ -49,16 +49,6 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
public static final int PANEL_HEIGHT_SMALL = 220;
|
public static final int PANEL_HEIGHT_SMALL = 220;
|
||||||
private static final int PANEL_HEIGHT_EXTRA_FOR_ME = 25;
|
private static final int PANEL_HEIGHT_EXTRA_FOR_ME = 25;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates new form PlayAreaPanel
|
|
||||||
*
|
|
||||||
* @param player
|
|
||||||
* @param bigCard
|
|
||||||
* @param gameId
|
|
||||||
* @param priorityTime
|
|
||||||
* @param gamePanel
|
|
||||||
* @param options
|
|
||||||
*/
|
|
||||||
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, int priorityTime, GamePanel gamePanel,
|
public PlayAreaPanel(PlayerView player, BigCard bigCard, UUID gameId, int priorityTime, GamePanel gamePanel,
|
||||||
PlayAreaPanelOptions options) {
|
PlayAreaPanelOptions options) {
|
||||||
this.gamePanel = gamePanel;
|
this.gamePanel = gamePanel;
|
||||||
|
|
@ -70,6 +60,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
// data init
|
// data init
|
||||||
init(player, bigCard, gameId, priorityTime);
|
init(player, bigCard, gameId, priorityTime);
|
||||||
update(null, player, null);
|
update(null, player, null);
|
||||||
|
playerPanel.sizePlayerPanel(isSmallMode());
|
||||||
|
|
||||||
// init popup menu (must run after data init)
|
// init popup menu (must run after data init)
|
||||||
popupMenu = new JPopupMenu();
|
popupMenu = new JPopupMenu();
|
||||||
|
|
@ -78,7 +69,6 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
} else {
|
} else {
|
||||||
addPopupMenuWatcher();
|
addPopupMenuWatcher();
|
||||||
}
|
}
|
||||||
this.add(popupMenu);
|
|
||||||
|
|
||||||
setGUISize();
|
setGUISize();
|
||||||
}
|
}
|
||||||
|
|
@ -545,52 +535,18 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0, 0)));
|
setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0, 0)));
|
||||||
playerPanel = new PlayerPanelExt();
|
playerPanel = new PlayerPanelExt(GUISizeHelper.playerPanelGuiScale);
|
||||||
btnCheat = new javax.swing.JButton();
|
btnCheat = new javax.swing.JButton(); // TODO: not used? Delete
|
||||||
battlefieldPanel = new mage.client.game.BattlefieldPanel();
|
battlefieldPanel = new mage.client.game.BattlefieldPanel();
|
||||||
battlefieldPanel.setTopPanelBattlefield(options.topRow);
|
battlefieldPanel.setTopPanelBattlefield(options.topRow);
|
||||||
|
battlefieldPanel.setPreferredSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
|
||||||
|
|
||||||
btnCheat.setText("Cheat");
|
btnCheat.setText("Cheat");
|
||||||
btnCheat.addActionListener(evt -> btnCheatActionPerformed(evt));
|
btnCheat.addActionListener(evt -> btnCheatActionPerformed(evt));
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
this.setLayout(new BorderLayout());
|
||||||
layout.setHorizontalGroup(
|
this.add(playerPanel, BorderLayout.WEST);
|
||||||
layout.createSequentialGroup()
|
this.add(battlefieldPanel, BorderLayout.CENTER);
|
||||||
.addComponent(playerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addPreferredGap(ComponentPlacement.RELATED)
|
|
||||||
.addComponent(battlefieldPanel, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
||||||
);
|
|
||||||
layout.setVerticalGroup(
|
|
||||||
layout.createParallelGroup(Alignment.LEADING)
|
|
||||||
.addComponent(playerPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addComponent(battlefieldPanel, GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
|
|
||||||
);
|
|
||||||
this.setLayout(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSizeMode(boolean smallMode) {
|
|
||||||
this.smallMode = smallMode;
|
|
||||||
sizePlayerPanel(this.playerPanel, this.isMe, this.smallMode);
|
|
||||||
sizeBattlefieldPanel(this.battlefieldPanel, this.isMe, this.smallMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sizePlayerPanel(PlayerPanelExt playerPanel, boolean isMe, boolean smallMode) {
|
|
||||||
playerPanel.sizePlayerPanel(smallMode);
|
|
||||||
int extraForMe = isMe ? PANEL_HEIGHT_EXTRA_FOR_ME : 0;
|
|
||||||
if (smallMode) {
|
|
||||||
playerPanel.setPreferredSize(new Dimension(92, PANEL_HEIGHT_SMALL + extraForMe));
|
|
||||||
} else {
|
|
||||||
playerPanel.setPreferredSize(new Dimension(92, PANEL_HEIGHT + extraForMe));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sizeBattlefieldPanel(BattlefieldPanel battlefieldPanel, boolean isMe, boolean smallMode) {
|
|
||||||
int extraForMe = isMe ? PANEL_HEIGHT_EXTRA_FOR_ME : 0;
|
|
||||||
if (smallMode) {
|
|
||||||
battlefieldPanel.setPreferredSize(new Dimension(160, PANEL_HEIGHT_SMALL + extraForMe));
|
|
||||||
} else {
|
|
||||||
battlefieldPanel.setPreferredSize(new Dimension(160, PANEL_HEIGHT + extraForMe));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {
|
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
|
|
||||||
|
|
@ -64,35 +64,49 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
private static final int PANEL_HEIGHT_SMALL = 218; // small mode (with avatar button) // TODO: no need in small mode after GUI scale added
|
private static final int PANEL_HEIGHT_SMALL = 218; // small mode (with avatar button) // TODO: no need in small mode after GUI scale added
|
||||||
private static final int PANEL_HEIGHT_EXTRA_FOR_ME = 25; // hints button
|
private static final int PANEL_HEIGHT_EXTRA_FOR_ME = 25; // hints button
|
||||||
|
|
||||||
private final Border GREEN_BORDER;
|
private Border GREEN_BORDER;
|
||||||
private final Border RED_BORDER;
|
private Border RED_BORDER;
|
||||||
private final Border YELLOW_BORDER;
|
private Border YELLOW_BORDER;
|
||||||
private final Border EMPTY_BORDER;
|
private Border EMPTY_BORDER;
|
||||||
|
|
||||||
float guiScaleMod = 1.0f;
|
float guiScaleMod = 1.0f;
|
||||||
|
|
||||||
private final Color activeValueColor = new Color(244, 9, 47);
|
private Color activeValueColor = new Color(244, 9, 47);
|
||||||
private final Font fontValuesZero;
|
private Font fontValuesZero;
|
||||||
private final Font fontValuesNonZero;
|
private Font fontValuesNonZero;
|
||||||
|
|
||||||
private int avatarId = -1;
|
private int avatarId = -1;
|
||||||
private String flagName;
|
private String flagName;
|
||||||
private String basicTooltipText;
|
private String basicTooltipText;
|
||||||
private static final Map<UUID, Integer> playerLives = new HashMap<>();
|
private static final Map<UUID, Integer> playerLives = new HashMap<>();
|
||||||
|
|
||||||
|
private Font defaultFont = null;
|
||||||
|
|
||||||
private PriorityTimer timer;
|
private PriorityTimer timer;
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates new form PlayerPanel
|
|
||||||
*/
|
|
||||||
public PlayerPanelExt() {
|
public PlayerPanelExt() {
|
||||||
this(1.0f);
|
this(1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerPanelExt(float guiScaleMod) {
|
public PlayerPanelExt(float guiScaleMod) {
|
||||||
// gui scale
|
// save default font cause panel can be recreated manually
|
||||||
|
this.defaultFont = this.getFont();
|
||||||
|
|
||||||
|
createAllComponents(guiScaleMod);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refresh full panel's components due actual GUI settings
|
||||||
|
*/
|
||||||
|
public void fullRefresh(float guiScaleMod) {
|
||||||
|
this.cleanUp();
|
||||||
|
this.removeAll();
|
||||||
|
this.createAllComponents(guiScaleMod);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createAllComponents(float guiScaleMod) {
|
||||||
this.guiScaleMod = guiScaleMod;
|
this.guiScaleMod = guiScaleMod;
|
||||||
this.setFont(this.getFont().deriveFont(sizeMod(this.getFont().getSize2D())));
|
this.setFont(this.defaultFont.deriveFont(sizeMod(this.defaultFont.getSize2D())));
|
||||||
this.fontValuesZero = this.getFont().deriveFont(Font.PLAIN);
|
this.fontValuesZero = this.getFont().deriveFont(Font.PLAIN);
|
||||||
this.fontValuesNonZero = this.getFont().deriveFont(Font.BOLD);
|
this.fontValuesNonZero = this.getFont().deriveFont(Font.BOLD);
|
||||||
this.GREEN_BORDER = new LineBorder(Color.green, sizeMod(3));
|
this.GREEN_BORDER = new LineBorder(Color.green, sizeMod(3));
|
||||||
|
|
@ -123,7 +137,8 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
toolHintsHelper.setVisible(this.isMe);
|
toolHintsHelper.setVisible(this.isMe);
|
||||||
toolHintsHelper.setFocusable(false);
|
toolHintsHelper.setFocusable(false);
|
||||||
flagName = null;
|
flagName = null;
|
||||||
if (priorityTime > 0) {
|
avatarId = -1;
|
||||||
|
if (priorityTime > 0 && priorityTime != Integer.MAX_VALUE) {
|
||||||
long delay = 1000L;
|
long delay = 1000L;
|
||||||
|
|
||||||
timer = new PriorityTimer(priorityTime, delay, () -> {
|
timer = new PriorityTimer(priorityTime, delay, () -> {
|
||||||
|
|
@ -360,9 +375,9 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.timer != null) {
|
if (this.timer != null) {
|
||||||
if (player.getPriorityTimeLeft() != Integer.MAX_VALUE) {
|
if (player.getPriorityTimeLeftSecs() != Integer.MAX_VALUE) {
|
||||||
String priorityTimeValue = getPriorityTimeLeftString(player);
|
String priorityTimeValue = getPriorityTimeLeftString(player);
|
||||||
this.timer.setCount(player.getPriorityTimeLeft());
|
this.timer.setCount(player.getPriorityTimeLeftSecs());
|
||||||
this.timer.setBufferCount(player.getBufferTimeLeft());
|
this.timer.setBufferCount(player.getBufferTimeLeft());
|
||||||
this.avatar.setTopText(priorityTimeValue);
|
this.avatar.setTopText(priorityTimeValue);
|
||||||
this.timerLabel.setText(priorityTimeValue);
|
this.timerLabel.setText(priorityTimeValue);
|
||||||
|
|
@ -372,7 +387,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
if (player.getBufferTimeLeft() > 0) {
|
if (player.getBufferTimeLeft() > 0) {
|
||||||
textColor = Color.GREEN;
|
textColor = Color.GREEN;
|
||||||
foregroundColor = Color.GREEN.darker().darker();
|
foregroundColor = Color.GREEN.darker().darker();
|
||||||
} else if (player.getPriorityTimeLeft() < 300) { // visual indication for under 5 minutes
|
} else if (player.getPriorityTimeLeftSecs() < 300) { // visual indication for under 5 minutes
|
||||||
textColor = Color.RED;
|
textColor = Color.RED;
|
||||||
foregroundColor = Color.RED.darker().darker();
|
foregroundColor = Color.RED.darker().darker();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -476,7 +491,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPriorityTimeLeftString(PlayerView player) {
|
private String getPriorityTimeLeftString(PlayerView player) {
|
||||||
int priorityTimeLeft = player.getPriorityTimeLeft() + player.getBufferTimeLeft();
|
int priorityTimeLeft = player.getPriorityTimeLeftSecs() + player.getBufferTimeLeft();
|
||||||
return getPriorityTimeLeftString(priorityTimeLeft);
|
return getPriorityTimeLeftString(priorityTimeLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -975,7 +990,7 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
|
|
||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
protected void sizePlayerPanel(boolean smallMode) {
|
public void sizePlayerPanel(boolean smallMode) {
|
||||||
int extraForMe = this.isMe ? PANEL_HEIGHT_EXTRA_FOR_ME : 0;
|
int extraForMe = this.isMe ? PANEL_HEIGHT_EXTRA_FOR_ME : 0;
|
||||||
if (smallMode) {
|
if (smallMode) {
|
||||||
avatar.setVisible(false);
|
avatar.setVisible(false);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import org.mage.card.arcane.CardRenderer;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -62,6 +63,8 @@ public final class GUISizeHelper {
|
||||||
public static Dimension handCardDimension;
|
public static Dimension handCardDimension;
|
||||||
public static int stackWidth; // percent
|
public static int stackWidth; // percent
|
||||||
|
|
||||||
|
public static float playerPanelGuiScale;
|
||||||
|
|
||||||
public static Dimension otherZonesCardDimension;
|
public static Dimension otherZonesCardDimension;
|
||||||
public static int otherZonesCardVerticalOffset;
|
public static int otherZonesCardVerticalOffset;
|
||||||
|
|
||||||
|
|
@ -126,7 +129,7 @@ public final class GUISizeHelper {
|
||||||
gameRequestsFont = new Font("Arial", 0, dialogFontSize);
|
gameRequestsFont = new Font("Arial", 0, dialogFontSize);
|
||||||
|
|
||||||
// used in the feedback area of the game panel
|
// used in the feedback area of the game panel
|
||||||
int feedbackFontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_FEEDBACK_AREA_SIZE, 14);
|
int feedbackFontSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_FEEDBACK_FONT_SIZE, 14);
|
||||||
gameDialogAreaFontSizeBig = feedbackFontSize;
|
gameDialogAreaFontSizeBig = feedbackFontSize;
|
||||||
gameDialogAreaFontSizeTooltip = feedbackFontSize - 2;
|
gameDialogAreaFontSizeTooltip = feedbackFontSize - 2;
|
||||||
gameDialogAreaFontSizeSmall = (feedbackFontSize / 2) + 2;
|
gameDialogAreaFontSizeSmall = (feedbackFontSize / 2) + 2;
|
||||||
|
|
@ -149,6 +152,8 @@ public final class GUISizeHelper {
|
||||||
handCardDimension = new Dimension(CARD_IMAGE_WIDTH * handCardSize / 42, CARD_IMAGE_HEIGHT * handCardSize / 42);
|
handCardDimension = new Dimension(CARD_IMAGE_WIDTH * handCardSize / 42, CARD_IMAGE_HEIGHT * handCardSize / 42);
|
||||||
stackWidth = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_STACK_WIDTH, 30);
|
stackWidth = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_STACK_WIDTH, 30);
|
||||||
|
|
||||||
|
playerPanelGuiScale = (float) (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_PLAYER_PANEL_SIZE, 14) / 14.0);
|
||||||
|
|
||||||
int otherZonesCardSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_OTHER_ZONES_SIZE, 14);
|
int otherZonesCardSize = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_GUI_CARD_OTHER_ZONES_SIZE, 14);
|
||||||
otherZonesCardDimension = new Dimension(CARD_IMAGE_WIDTH * otherZonesCardSize / 42, CARD_IMAGE_HEIGHT * otherZonesCardSize / 42);
|
otherZonesCardDimension = new Dimension(CARD_IMAGE_WIDTH * otherZonesCardSize / 42, CARD_IMAGE_HEIGHT * otherZonesCardSize / 42);
|
||||||
if (PreferencesDialog.getRenderMode() == 0) {
|
if (PreferencesDialog.getRenderMode() == 0) {
|
||||||
|
|
@ -234,4 +239,22 @@ public final class GUISizeHelper {
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Swing don't store name in the component, so it allow to find component by field's name instead
|
||||||
|
*/
|
||||||
|
static public <T extends Component> T getComponentByFieldName(Window dialog, String name) {
|
||||||
|
for (Field field : dialog.getClass().getDeclaredFields()) {
|
||||||
|
try {
|
||||||
|
field.setAccessible(true);
|
||||||
|
if (name.equals(field.getName())) {
|
||||||
|
final Object potentialMatch = field.get(dialog);
|
||||||
|
return (T) potentialMatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SecurityException | IllegalArgumentException | IllegalAccessException ignore) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,7 @@ public class ThemePluginImpl implements ThemePlugin {
|
||||||
if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) {
|
if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) {
|
||||||
ImagePanel bgPanel = new ImagePanel(backgroundImage, ImagePanelStyle.TILED);
|
ImagePanel bgPanel = new ImagePanel(backgroundImage, ImagePanelStyle.TILED);
|
||||||
|
|
||||||
|
// TODO: research - is all components used? And why it make transparent?
|
||||||
unsetOpaque(ui.get("jSplitPane1"));
|
unsetOpaque(ui.get("jSplitPane1"));
|
||||||
unsetOpaque(ui.get("pnlBattlefield"));
|
unsetOpaque(ui.get("pnlBattlefield"));
|
||||||
unsetOpaque(ui.get("pnlHelperHandButtonsStackArea"));
|
unsetOpaque(ui.get("pnlHelperHandButtonsStackArea"));
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@ import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JViewport;
|
import javax.swing.JViewport;
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
/**
|
||||||
|
* GUI component: JPanel with background image
|
||||||
|
*/
|
||||||
public class ImagePanel extends JPanel {
|
public class ImagePanel extends JPanel {
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -24,6 +26,8 @@ public class ImagePanel extends JPanel {
|
||||||
this.image = image;
|
this.image = image;
|
||||||
this.style = style;
|
this.style = style;
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
|
|
||||||
|
setOpaque(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setImageAlignmentX(float alignmentX) {
|
public void setImageAlignmentX(float alignmentX) {
|
||||||
|
|
@ -56,7 +60,6 @@ public class ImagePanel extends JPanel {
|
||||||
super.add(component, constraints);
|
super.add(component, constraints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent(Graphics g) {
|
protected void paintComponent(Graphics g) {
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,8 @@ public class PlayerView implements Serializable {
|
||||||
private final List<CommandObjectView> commandList = new ArrayList<>();
|
private final List<CommandObjectView> commandList = new ArrayList<>();
|
||||||
private final List<UUID> attachments = new ArrayList<>();
|
private final List<UUID> attachments = new ArrayList<>();
|
||||||
private final int statesSavedSize;
|
private final int statesSavedSize;
|
||||||
private final int priorityTimeLeft;
|
private final long priorityTimeSavedTimeMs;
|
||||||
|
private final int priorityTimeLeftSecs;
|
||||||
private final int bufferTimeLeft;
|
private final int bufferTimeLeft;
|
||||||
private final boolean passedTurn; // F4
|
private final boolean passedTurn; // F4
|
||||||
private final boolean passedUntilEndOfTurn; // F5
|
private final boolean passedUntilEndOfTurn; // F5
|
||||||
|
|
@ -71,7 +72,8 @@ public class PlayerView implements Serializable {
|
||||||
this.manaPool = new ManaPoolView(player.getManaPool());
|
this.manaPool = new ManaPoolView(player.getManaPool());
|
||||||
this.isActive = (player.getId().equals(state.getActivePlayerId()));
|
this.isActive = (player.getId().equals(state.getActivePlayerId()));
|
||||||
this.hasPriority = player.getId().equals(state.getPriorityPlayerId());
|
this.hasPriority = player.getId().equals(state.getPriorityPlayerId());
|
||||||
this.priorityTimeLeft = player.getPriorityTimeLeft();
|
this.priorityTimeLeftSecs = player.getPriorityTimeLeft();
|
||||||
|
this.priorityTimeSavedTimeMs = System.currentTimeMillis();
|
||||||
this.bufferTimeLeft = player.getBufferTimeLeft();
|
this.bufferTimeLeft = player.getBufferTimeLeft();
|
||||||
this.timerActive = (this.hasPriority && player.isGameUnderControl())
|
this.timerActive = (this.hasPriority && player.isGameUnderControl())
|
||||||
|| (player.getPlayersUnderYourControl().contains(state.getPriorityPlayerId()))
|
|| (player.getPlayersUnderYourControl().contains(state.getPriorityPlayerId()))
|
||||||
|
|
@ -270,8 +272,10 @@ public class PlayerView implements Serializable {
|
||||||
return statesSavedSize;
|
return statesSavedSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPriorityTimeLeft() {
|
public int getPriorityTimeLeftSecs() {
|
||||||
return priorityTimeLeft;
|
// workaround to find real time
|
||||||
|
int secsAfterUpdate = (int) ((System.currentTimeMillis() - this.priorityTimeSavedTimeMs) / 1000);
|
||||||
|
return Math.max(0, this.priorityTimeLeftSecs - secsAfterUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBufferTimeLeft() {
|
public int getBufferTimeLeft() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue