mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Fixed UI bit with cards z-order
This commit is contained in:
parent
dda36afce4
commit
9a5000616d
2 changed files with 18 additions and 15 deletions
|
|
@ -65,24 +65,27 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
protected Map<UUID, PermanentView> battlefield;
|
||||
private Dimension cardDimension;
|
||||
|
||||
private JPanel jPanel;
|
||||
private JComponent jPanel;
|
||||
private JScrollPane jScrollPane;
|
||||
private int width;
|
||||
|
||||
private static int i = 0;
|
||||
|
||||
/** Creates new form BattlefieldPanel */
|
||||
public BattlefieldPanel() {
|
||||
ui.put("battlefieldPanel", this);
|
||||
initComponents();
|
||||
ui.put("jPanel", jPanel);
|
||||
|
||||
addComponentListener(new ComponentAdapter(){
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
int width = e.getComponent().getWidth();
|
||||
int height = e.getComponent().getHeight();
|
||||
BattlefieldPanel.this.jScrollPane.setSize(width, height);
|
||||
BattlefieldPanel.this.width = width;
|
||||
sortLayout();
|
||||
}
|
||||
sortLayout();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -162,12 +165,13 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
}
|
||||
permanents.put(permanent.getId(), perm);
|
||||
|
||||
//BattlefieldPanel.this.jPanel.add(perm, 10);
|
||||
this.jPanel.add(perm);
|
||||
BattlefieldPanel.this.jPanel.add(perm, 10);
|
||||
//this.jPanel.add(perm);
|
||||
if (!Plugins.getInstance().isCardPluginLoaded()) {
|
||||
moveToFront(perm);
|
||||
perm.update(permanent);
|
||||
} else {
|
||||
moveToFront(jPanel);
|
||||
Plugins.getInstance().onAddCard(perm, 1);
|
||||
/*Thread t = new Thread(new Runnable() {
|
||||
@Override
|
||||
|
|
@ -272,7 +276,7 @@ public class BattlefieldPanel extends javax.swing.JLayeredPane {
|
|||
private void initComponents() {
|
||||
setOpaque(false);
|
||||
|
||||
jPanel = new JPanel();
|
||||
jPanel = new JLayeredPane();
|
||||
jPanel.setLayout(null);
|
||||
jPanel.setOpaque(false);
|
||||
jScrollPane = new JScrollPane(jPanel);
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
|
||||
//JScrollPane jScrollPane = (JScrollPane) component;
|
||||
JLayeredPane battlefieldPanel = (JLayeredPane) component2;
|
||||
JComponent jPanel = ui.get("jPanel");
|
||||
|
||||
Row allLands = new Row();
|
||||
|
||||
|
|
@ -166,7 +167,6 @@ public class CardPluginImpl implements CardPlugin {
|
|||
boolean othersOnTheRight = true;
|
||||
if (options != null && options.containsKey("nonLandPermanentsInOnePile")) {
|
||||
if (options.get("nonLandPermanentsInOnePile").equals("true")) {
|
||||
// System.out.println("in one pile");
|
||||
othersOnTheRight = false;
|
||||
allCreatures.addAll(allOthers);
|
||||
allOthers.clear();
|
||||
|
|
@ -215,7 +215,7 @@ public class CardPluginImpl implements CardPlugin {
|
|||
break;
|
||||
//cardWidth = (int)(cardWidth / 1.2);
|
||||
//FIXME: -1 is too slow. why not binary search?
|
||||
cardWidth--;
|
||||
cardWidth -= 3;
|
||||
}
|
||||
|
||||
// Get size of all the rows.
|
||||
|
|
@ -232,8 +232,6 @@ public class CardPluginImpl implements CardPlugin {
|
|||
y = rowBottom;
|
||||
maxRowWidth = Math.max(maxRowWidth, x);
|
||||
}
|
||||
//setPreferredSize(new Dimension(maxRowWidth - cardSpacingX, y - cardSpacingY));
|
||||
//revalidate();
|
||||
|
||||
// Position all card panels.
|
||||
x = 0;
|
||||
|
|
@ -252,14 +250,15 @@ public class CardPluginImpl implements CardPlugin {
|
|||
for (int panelIndex = 0, panelCount = stack.size(); panelIndex < panelCount; panelIndex++) {
|
||||
MagePermanent panel = stack.get(panelIndex);
|
||||
int stackPosition = panelCount - panelIndex - 1;
|
||||
///setComponentZOrder((Component)panel, panelIndex);
|
||||
if (jPanel != null)
|
||||
jPanel.setComponentZOrder(panel, panelIndex);
|
||||
int panelX = x + (stackPosition * stackSpacingX);
|
||||
int panelY = y + (stackPosition * stackSpacingY);
|
||||
//panel.setLocation(panelX, panelY);
|
||||
try {
|
||||
// may cause:
|
||||
// java.lang.IllegalArgumentException: illegal component position 26 should be less then 26
|
||||
battlefieldPanel.moveToBack(panel);
|
||||
battlefieldPanel.moveToFront(panel);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue