mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
* Client memory - Some more changes to maximize objects for gc.
This commit is contained in:
parent
b10ad8e663
commit
f2cf060b21
4 changed files with 41 additions and 10 deletions
|
|
@ -47,12 +47,13 @@ import mage.view.AbilityView;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
import mage.view.CardsView;
|
import mage.view.CardsView;
|
||||||
import mage.view.SimpleCardsView;
|
import mage.view.SimpleCardsView;
|
||||||
|
import org.mage.card.arcane.CardPanel;
|
||||||
|
|
||||||
public class CardArea extends JPanel {
|
public class CardArea extends JPanel {
|
||||||
|
|
||||||
private boolean reloaded = false;
|
private boolean reloaded = false;
|
||||||
private javax.swing.JLayeredPane cardArea;
|
private final javax.swing.JLayeredPane cardArea;
|
||||||
private javax.swing.JScrollPane scrollPane;
|
private final javax.swing.JScrollPane scrollPane;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the panel.
|
* Create the panel.
|
||||||
|
|
@ -68,6 +69,15 @@ public class CardArea extends JPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cleanUp() {
|
||||||
|
for(Component comp: cardArea.getComponents()) {
|
||||||
|
if (comp instanceof CardPanel) {
|
||||||
|
((CardPanel) comp).cleanUp();
|
||||||
|
cardArea.remove(comp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void loadCards(SimpleCardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, MouseListener listener) {
|
public void loadCards(SimpleCardsView showCards, BigCard bigCard, CardDimensions dimension, UUID gameId, MouseListener listener) {
|
||||||
loadCards(CardsViewUtil.convertSimple(showCards), bigCard, dimension, gameId, listener);
|
loadCards(CardsViewUtil.convertSimple(showCards), bigCard, dimension, gameId, listener);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import org.mage.card.arcane.CardPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -48,8 +49,8 @@ import java.util.UUID;
|
||||||
*/
|
*/
|
||||||
public class PickPileDialog extends MageDialog {
|
public class PickPileDialog extends MageDialog {
|
||||||
|
|
||||||
private CardArea pile1;
|
private final CardArea pile1;
|
||||||
private CardArea pile2;
|
private final CardArea pile2;
|
||||||
|
|
||||||
private boolean pickedPile1 = false;
|
private boolean pickedPile1 = false;
|
||||||
|
|
||||||
|
|
@ -68,6 +69,7 @@ public class PickPileDialog extends MageDialog {
|
||||||
|
|
||||||
JButton btnChoosePile1 = new JButton("Pile 1");
|
JButton btnChoosePile1 = new JButton("Pile 1");
|
||||||
btnChoosePile1.addActionListener(new ActionListener() {
|
btnChoosePile1.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
btnPile1ActionPerformed(e);
|
btnPile1ActionPerformed(e);
|
||||||
}
|
}
|
||||||
|
|
@ -83,6 +85,7 @@ public class PickPileDialog extends MageDialog {
|
||||||
|
|
||||||
JButton btnChoosePile2 = new JButton("Pile 2");
|
JButton btnChoosePile2 = new JButton("Pile 2");
|
||||||
btnChoosePile2.addActionListener(new ActionListener() {
|
btnChoosePile2.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
btnPile2ActionPerformed(e);
|
btnPile2ActionPerformed(e);
|
||||||
}
|
}
|
||||||
|
|
@ -90,6 +93,21 @@ public class PickPileDialog extends MageDialog {
|
||||||
panel_1.add(btnChoosePile2, BorderLayout.NORTH);
|
panel_1.add(btnChoosePile2, BorderLayout.NORTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cleanUp() {
|
||||||
|
for(Component comp: pile1.getComponents()) {
|
||||||
|
if (comp instanceof CardPanel) {
|
||||||
|
((CardPanel) comp).cleanUp();
|
||||||
|
pile1.remove(comp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(Component comp: pile2.getComponents()) {
|
||||||
|
if (comp instanceof CardPanel) {
|
||||||
|
((CardPanel) comp).cleanUp();
|
||||||
|
pile2.remove(comp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void loadCards(String name, CardsView pile1, CardsView pile2, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
public void loadCards(String name, CardsView pile1, CardsView pile2, BigCard bigCard, CardDimensions dimension, UUID gameId) {
|
||||||
this.title = name;
|
this.title = name;
|
||||||
this.pile1.loadCardsNarrow(pile1, bigCard, dimension, gameId, null);
|
this.pile1.loadCardsNarrow(pile1, bigCard, dimension, gameId, null);
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ public class ShowCardsDialog extends MageDialog implements MouseListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanUp() {
|
public void cleanUp() {
|
||||||
|
cardArea.cleanUp();
|
||||||
for (Component comp : cardArea.getComponents()) {
|
for (Component comp : cardArea.getComponents()) {
|
||||||
if (comp instanceof CardPanel) {
|
if (comp instanceof CardPanel) {
|
||||||
((CardPanel) comp).cleanUp();
|
((CardPanel) comp).cleanUp();
|
||||||
|
|
|
||||||
|
|
@ -764,6 +764,8 @@ public final class GamePanel extends javax.swing.JPanel {
|
||||||
PickPileDialog pickPileDialog = new PickPileDialog();
|
PickPileDialog pickPileDialog = new PickPileDialog();
|
||||||
pickPileDialog.loadCards(message, pile1, pile2, bigCard, Config.dimensions, gameId);
|
pickPileDialog.loadCards(message, pile1, pile2, bigCard, Config.dimensions, gameId);
|
||||||
session.sendPlayerBoolean(gameId, pickPileDialog.isPickedPile1());
|
session.sendPlayerBoolean(gameId, pickPileDialog.isPickedPile1());
|
||||||
|
pickPileDialog.cleanUp();
|
||||||
|
pickPileDialog.removeDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<UUID, PlayAreaPanel> getPlayers() {
|
public Map<UUID, PlayAreaPanel> getPlayers() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue