Increase stack spacing

This commit is contained in:
drdev
2014-10-14 03:26:07 +00:00
parent 844f765ec6
commit 0804a9b632

View File

@@ -59,9 +59,9 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
/** Constant <code>CARD_SPACING_Y=0.06f</code>. */ /** Constant <code>CARD_SPACING_Y=0.06f</code>. */
private static final float CARD_SPACING_Y = 0.06f; private static final float CARD_SPACING_Y = 0.06f;
/** Constant <code>STACK_SPACING_X=0.07f</code>. */ /** Constant <code>STACK_SPACING_X=0.07f</code>. */
private static final float STACK_SPACING_X = 0.07f; private static final float STACK_SPACING_X = 0.1f;
/** Constant <code>STACK_SPACING_Y=0.07f</code>. */ /** Constant <code>STACK_SPACING_Y=0.07f</code>. */
private static final float STACK_SPACING_Y = 0.07f; private static final float STACK_SPACING_Y = 0.1f;
//private final int creatureStackMax = 4; //private final int creatureStackMax = 4;
private final int landStackMax = 5; private final int landStackMax = 5;
@@ -312,7 +312,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
} }
} }
setCardWidth(lastGoodCardWidth); setCardWidth(lastGoodCardWidth);
if ( null == lastTemplate ) if (null == lastTemplate)
lastTemplate = tryArrangePilesOfWidth(lands, tokens, creatures, others); lastTemplate = tryArrangePilesOfWidth(lands, tokens, creatures, others);
this.rows = lastTemplate; this.rows = lastTemplate;
@@ -341,7 +341,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
int x = 0; int x = 0;
int y = PlayArea.GUTTER_Y; int y = PlayArea.GUTTER_Y;
//System.out.println("-------- " + (mirror ? "^" : "_") + " (Positioning ) Card width = " + cardWidth + ". Playarea = " + playAreaWidth + " x " + playAreaHeight ); //System.out.println("-------- " + (mirror ? "^" : "_") + " (Positioning) Card width = " + cardWidth + ". Playarea = " + playAreaWidth + " x " + playAreaHeight);
for (final CardStackRow row : template) { for (final CardStackRow row : template) {
int rowBottom = 0; int rowBottom = 0;
x = PlayArea.GUTTER_X; x = PlayArea.GUTTER_X;
@@ -361,7 +361,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
this.setComponentZOrder(panel, panelIndex); this.setComponentZOrder(panel, panelIndex);
final int panelX = x + (stackPosition * this.stackSpacingX); final int panelX = x + (stackPosition * this.stackSpacingX);
final int panelY = y + (stackPosition * this.stackSpacingY); final int panelY = y + (stackPosition * this.stackSpacingY);
//System.out.println("... placinng " + panel.getCard() + " @ (" + panelX + ", " + panelY + ")" ); //System.out.println("... placinng " + panel.getCard() + " @ (" + panelX + ", " + panelY + ")");
panel.setCardBounds(panelX, panelY, this.getCardWidth(), this.cardHeight); panel.setCardBounds(panelX, panelY, this.getCardWidth(), this.cardHeight);
} }
rowBottom = Math.max(rowBottom, y + stack.getHeight()); rowBottom = Math.max(rowBottom, y + stack.getHeight());
@@ -376,7 +376,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
int afterFirstRow; int afterFirstRow;
//System.out.println( "======== " + ( mirror ? "^" : "_" ) + " (try arrange) Card width = " + cardWidth + ". PlayArea = " + playAreaWidth + " x " + playAreaHeight + " ========"); //System.out.println("======== " + (mirror ? "^" : "_") + " (try arrange) Card width = " + cardWidth + ". PlayArea = " + playAreaWidth + " x " + playAreaHeight + " ========");
boolean landsFit, tokensFit, creaturesFit; boolean landsFit, tokensFit, creaturesFit;
if (this.mirror) { if (this.mirror) {
// Wrap all creatures and lands. // Wrap all creatures and lands.
@@ -392,9 +392,9 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
landsFit = this.planRow(lands, template, template.size()); landsFit = this.planRow(lands, template, template.size());
} }
if ( !landsFit || !creaturesFit || !tokensFit ) if (!landsFit || !creaturesFit || !tokensFit) {
return null; return null;
}
// Other cards may be stored at end of usual rows or on their own row. // Other cards may be stored at end of usual rows or on their own row.
int cntOthers = others.size(); int cntOthers = others.size();
@@ -408,13 +408,13 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
int nextOther = 0; int nextOther = 0;
for (final CardStackRow row : template) { for (final CardStackRow row : template) {
nextOther = this.planOthersRow(others, nextOther, template, row); nextOther = this.planOthersRow(others, nextOther, template, row);
if ( nextOther == cntOthers ) if (nextOther == cntOthers)
return template; // everything was successfully placed return template; // everything was successfully placed
} }
template = templateCopy; template = templateCopy;
// Try to put others on their own row(s) // Try to put others on their own row(s)
if ( this.planRow(others, template, afterFirstRow) ) if (this.planRow(others, template, afterFirstRow))
return template; return template;
@@ -444,13 +444,13 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
for (final CardStack stack : sourceRow) { for (final CardStack stack : sourceRow) {
final int rowWidth = currentRow.getWidth(); final int rowWidth = currentRow.getWidth();
final int stackWidth = stack.getWidth(); final int stackWidth = stack.getWidth();
//System.out.printf("Adding %s (+%dpx), current row is %dpx and has %s \n", stack, stackWidth, rowWidth, currentRow ); //System.out.printf("Adding %s (+%dpx), current row is %dpx and has %s \n", stack, stackWidth, rowWidth, currentRow);
// If the row is not empty and this stack doesn't fit, add the row. // If the row is not empty and this stack doesn't fit, add the row.
if (rowWidth + stackWidth > this.playAreaWidth && !currentRow.isEmpty()) { if (rowWidth + stackWidth > this.playAreaWidth && !currentRow.isEmpty()) {
// Stop processing if the row is too wide or tall. // Stop processing if the row is too wide or tall.
if (rowWidth > this.playAreaWidth || this.getRowsHeight(template) + sourceRow.getHeight() > this.playAreaHeight) { if (rowWidth > this.playAreaWidth || this.getRowsHeight(template) + sourceRow.getHeight() > this.playAreaHeight) {
if ( !isMinimalSize ) if (!isMinimalSize)
return false; return false;
} }
@@ -468,7 +468,7 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
if (!currentRow.isEmpty()) { if (!currentRow.isEmpty()) {
final int rowWidth = currentRow.getWidth(); final int rowWidth = currentRow.getWidth();
if (isMinimalSize || rowWidth <= this.playAreaWidth && this.getRowsHeight(template) + sourceRow.getHeight() <= this.playAreaHeight) { if (isMinimalSize || rowWidth <= this.playAreaWidth && this.getRowsHeight(template) + sourceRow.getHeight() <= this.playAreaHeight) {
if ( insertIndex == -1) if (insertIndex == -1)
template.add(currentRow); template.add(currentRow);
else else
template.add(insertIndex, currentRow); template.add(insertIndex, currentRow);
@@ -496,8 +496,8 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
private int planOthersRow(final List<CardStack> sourceRow, final int firstPile, final List<CardStackRow> template, final CardStackRow rowToFill) { private int planOthersRow(final List<CardStack> sourceRow, final int firstPile, final List<CardStackRow> template, final CardStackRow rowToFill) {
int rowWidth = rowToFill.getWidth(); int rowWidth = rowToFill.getWidth();
//System.out.println("This row has:" + rowToFill + "; want to add:" + sourceRow ); //System.out.println("This row has:" + rowToFill + "; want to add:" + sourceRow);
for (int i = firstPile; i < sourceRow.size(); i++ ) { for (int i = firstPile; i < sourceRow.size(); i++) {
CardStack stack = sourceRow.get(i); CardStack stack = sourceRow.get(i);
rowWidth += stack.getWidth(); rowWidth += stack.getWidth();
@@ -505,8 +505,9 @@ public class PlayArea extends CardPanelContainer implements CardPanelMouseListen
if (stack.getHeight() > rowToFill.getHeight()) { // if row becomes taller if (stack.getHeight() > rowToFill.getHeight()) { // if row becomes taller
int newAllRowsHeight = this.getRowsHeight(template) - rowToFill.getHeight() + stack.getHeight(); int newAllRowsHeight = this.getRowsHeight(template) - rowToFill.getHeight() + stack.getHeight();
if ( newAllRowsHeight > this.playAreaHeight) if (newAllRowsHeight > this.playAreaHeight) {
return i; // refuse to add here because it won't fit in height return i; // refuse to add here because it won't fit in height
}
} }
rowToFill.add(stack); rowToFill.add(stack);
} }