Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for card counts in image mode.

  • Loading branch information...
commit fc5dfba85c00b598da5b6b327d65733eb71b6056 1 parent f7effb0
@drheld authored
Showing with 152 additions and 18 deletions.
  1. +52 −10 card_counts.js
  2. +10 −6 dominion.js
  3. +90 −2 styles.css
View
62 card_counts.js
@@ -3,6 +3,35 @@ function cardId(player_id, card_name) {
return player_id + "_" + card_name.replace(/[^a-zA-Z]/gi, "").toLowerCase();
}
+// Sets up the per player card count layout.
+// Returns true if this call set it up, or false if it was already setup.
+function setupPerPlayerCardCounts() {
+ if (!getOption("show_card_counts")) {
+ return true;
+ }
+
+ // Make sure things aren't already setup.
+ if ($('#player1_copper').length != 0) return false;
+
+ if ($('#chat ~ a[href^="/mode/"]').text() == "images") {
+ setupPerPlayerTextCardCounts();
+ } else {
+ setupPerPlayerImageCardCounts('kingdom');
+ setupPerPlayerImageCardCounts('basic');
+ }
+ return true;
+}
+
+// Creates an appropriately IDd table cell for a card/player.
+function createPlayerCardCountCell(player, card) {
+ var id = cardId(player.id, card);
+ var count = player.card_counts[card];
+ if (count == undefined) count = '-';
+ var cell = $('<td id="' + id + '">' + count + '</td>');
+ cell.addClass("playerCardCountCol").addClass(player.id);
+ return cell;
+}
+
//
// TEXT MODE
@@ -26,9 +55,6 @@ function growHeaderColumns() {
// Set up the card count cells for all players in text mode.
function setupPerPlayerTextCardCounts() {
- // Make sure things aren't already setup.
- if ($('#player1_copper').length != 0) return false;
-
// For each row in the supply table, add a column count cell for each player.
$(".txcardname").each(function() {
var $this = $(this);
@@ -37,17 +63,33 @@ function setupPerPlayerTextCardCounts() {
// Insert new cells after this one.
var insertAfter = $this.next();
for (var p in players) {
- var player = players[p];
- var id = cardId(player.id, cardName);
- var count = player.card_counts[cardName];
- if (count == undefined) count = '-';
- var cell = $('<td id="' + id + '">' + count + '</td>');
- cell.addClass("playerCardCountCol").addClass(player.id);
+ var cell = createPlayerCardCountCell(players[p], cardName);
insertAfter.after(cell);
insertAfter = cell;
}
insertAfter.after($('<td class="availPadding"></td>'));
});
growHeaderColumns();
- return true;
+}
+
+
+//
+// GRAPHIC MODE
+//
+
+// Set up the per-player card counts in image mode for a given column.
+function setupPerPlayerImageCardCounts(region) {
+ var selector = '.' + region + '-column';
+
+ // make "hr" rows span all columns
+ var numPlayers = 1 + player_count;
+ $(selector + ' .hr:empty').append('<td colspan="' + numPlayers + '"></td>');
+
+ $(selector + ' .supplycard').each(function() {
+ var $this = $(this);
+ var cardName = $this.attr('cardname');
+ for (var p in players) {
+ $this.append(createPlayerCardCountCell(players[p], cardName));
+ }
+ });
}
View
16 dominion.js
@@ -308,10 +308,11 @@ function Player(name) {
this.recordSpecialCounts(singular_card_name, card, count);
this.recordCards(singular_card_name, count);
- // FIXME(drheld): Handle graphical mode.
- if (!setupPerPlayerTextCardCounts()) {
- var id = '#' + cardId(this.id, singular_card_name);
- $(id).text(this.card_counts[singular_card_name]);
+ if (getOption('show_card_counts')) {
+ if (!setupPerPlayerCardCounts()) {
+ var id = '#' + cardId(this.id, singular_card_name);
+ $(id).text(this.card_counts[singular_card_name]);
+ }
}
}
}
@@ -848,8 +849,11 @@ function initialize(doc) {
setTimeout("maybeIntroducePlugin()", wait_time);
}
- // FIXME(drheld): Handle graphical mode.
- setupPerPlayerTextCardCounts();
+ if (getOption('show_card_counts')) {
+ setupPerPlayerCardCounts();
+ }
+
+ $('#full_log').append('<div style="height: 60em"></div>');
}
function maybeRewriteName(doc) {
View
92 styles.css
@@ -13,7 +13,7 @@
font-style: italic;
}
#optionPanel > label {
- display: block;
+ display: block;
}
@@ -45,8 +45,96 @@
}
.avail {
- padding-right: 1ex !important;
+ padding-right: 0.5ex !important;
}
.availPadding {
padding-right: 3ex;
}
+
+
+/*
+ * Styles for showing card counts in image mode.
+ */
+
+td.kingdom-column, td.basic-column {
+ width: auto !important;
+}
+
+.kingdom-column > *, .basic-column > * {
+ display: table-row;
+}
+
+.kingdom-column > * > *, .basic-column > * > * {
+ display: table-cell;
+}
+
+/* Cause the prices + count display for basic cards to be vertical just like for kingdom cards */
+.imbasic > .imprice {
+ display: inline-block;
+}
+
+.imbasic {
+ width: 10px !important;
+}
+.imverticle {
+ width: 10px !important;
+}
+
+.imageMode #game, .imageMode {
+ display: table-row !important;
+}
+
+.imageMode #optionPanel {
+ display: table-cell;
+ width: 100%;
+}
+
+.imageMode #supply {
+ position: static !important;
+ display: table-cell !important;
+ width: auto !important;
+ left: inherit !important;
+ bottom: inherit !important;
+ vertical-align: bottom;
+}
+
+.imageMode #supply > table {
+ bottom: inherit !important;
+ position: static !important;
+}
+
+.imageMode #playerData {
+ border-bottom: black 1px groove;
+}
+
+.playing #right {
+ padding-left: 1em;
+ margin-left: auto !important;
+ vertical-align: bottom;
+ width: 100%;
+ display: table-cell;
+}
+
+.playing #full_log {
+ height: auto !important;
+ overflow-y: auto;
+ margin-left: 2em;
+}
+
+.playing #full_log > .logline > div[style] {
+ height: 0 !important;
+}
+
+
+
+#game .right {
+ margin-left: 400px !important;
+}
+#game .supply {
+ width: 400px !important
+}
+div.vertical {
+ margin-left: 0px !important;
+ margin-right: 0px !important;
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.