Continued work on deck builder.

This commit is contained in:
marcins78@gmail.com
2011-09-04 21:07:11 +00:00
parent 087c2a606f
commit f72c786487
2 changed files with 12 additions and 2 deletions

View File

@@ -25,6 +25,7 @@ var GempLotrDeckBuildingUI = Class.extend({
this.normalCollectionGroup = new NormalCardGroup(null, this.normalCollectionDiv, function(card) {
return true;
});
this.normalCollectionGroup.maxCardHeight = 200;
this.collectionDiv.append(this.normalCollectionDiv);
this.specialCollectionDiv = $("<div></div>");
@@ -32,6 +33,7 @@ var GempLotrDeckBuildingUI = Class.extend({
this.specialCollectionGroup = new NormalCardGroup(null, this.specialCollectionDiv, function(card) {
return true;
});
this.specialCollectionGroup.maxCardHeight = 200;
this.collectionDiv.append(this.specialCollectionDiv);
this.ringBearerDiv = $("<div>Ring Bearer</div>");
@@ -78,6 +80,7 @@ var GempLotrDeckBuildingUI = Class.extend({
this.drawDeckGroup = new NormalCardGroup(null, this.drawDeckDiv, function(card) {
return (card.zone == "deck");
});
this.drawDeckGroup.maxCardHeight = 200;
this.deckDiv.append(this.drawDeckDiv);
this.selectionFunc = this.addCardToDeck;
@@ -208,10 +211,10 @@ var GempLotrDeckBuildingUI = Class.extend({
this.drawDeckDiv.css({ position: "absolute", left: sitesWidth * 2, top: 0, width: this.deckDiv.width() - sitesWidth * 2, height: deckHeight });
this.drawDeckGroup.setBounds(0, 0, this.deckDiv.width() - sitesWidth * 2, deckHeight);
this.normalCollectionDiv.css({ position: "absolute", left: 0, top: 0, width: this.collectionDiv.width(), height: this.collectionDiv.height() })
this.normalCollectionDiv.css({ position: "absolute", left: 0, top: 50, width: this.collectionDiv.width(), height: this.collectionDiv.height() - 50 })
this.specialCollectionDiv.css({ position: "absolute", left: 0, top: 0, width: this.collectionDiv.width(), height: this.collectionDiv.height() })
this.normalCollectionGroup.setBounds(0, 0, this.collectionDiv.width(), this.collectionDiv.height());
this.normalCollectionGroup.setBounds(0, 0, this.collectionDiv.width(), this.collectionDiv.height() - 50);
this.specialCollectionGroup.setBounds(0, 0, this.collectionDiv.width(), this.collectionDiv.height());
},

View File

@@ -7,6 +7,7 @@ var CardGroup = Class.extend({
belongTestFunc: null,
padding: 5,
cardId: null,
maxCardHeight: null,
init: function(container, belongTest) {
this.container = container;
@@ -166,6 +167,8 @@ var NormalCardGroup = CardGroup.extend({
tryIfCanLayoutInRows: function(rowCount, cardsToLayout) {
var rowHeight = (this.height - (this.padding * (rowCount - 1))) / rowCount;
if (this.maxCardHeight != null)
rowHeight = Math.min(this.maxCardHeight, rowHeight);
var totalWidth = 0;
var row = 0;
for (var cardId in cardsToLayout) {
@@ -185,6 +188,8 @@ var NormalCardGroup = CardGroup.extend({
},
layoutInRow: function(cardsToLayout, height) {
if (this.maxCardHeight != null)
height = Math.min(this.maxCardHeight, height);
var x = 0;
var row = 0;
var y = Math.floor((this.height - height) / 2);
@@ -208,6 +213,8 @@ var NormalCardGroup = CardGroup.extend({
layoutInRows: function(rowCount, cardsToLayout) {
var rowHeight = (this.height - ((rowCount - 1) * this.padding)) / rowCount;
if (this.maxCardHeight != null)
rowHeight = Math.min(this.maxCardHeight, rowHeight);
var x = 0;
var row = 0;
var y = 0;