Skip to content

Commit

Permalink
Merge pull request doublespeakgames#425 from Sebring/master
Browse files Browse the repository at this point in the history
 Showing total in stores tooltip - Issue doublespeakgames#170
  • Loading branch information
Continuities committed Aug 2, 2015
2 parents 95cf44c + 1e37f45 commit 64f6797
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ div.row_val {
float: right;
}

div.total {
font-weight: bold;
}

/* Notifications */

div#notifications {
Expand Down
10 changes: 10 additions & 0 deletions script/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,7 @@ var Room = {

updateIncomeView: function() {
var stores = $('div#resources');
var totalIncome = {};
if(stores.length === 0 || typeof $SM.get('income') == 'undefined') return;
$('div.storeRow', stores).each(function(index, el) {
el = $(el);
Expand All @@ -900,10 +901,19 @@ var Room = {
.addClass('row_val')
.text(Engine.getIncomeMsg(income.stores[store], income.delay))
.appendTo(tt);
if (totalIncome[store] === undefined || totalIncome[store]['income'] === undefined) {
totalIncome[store] = {};
totalIncome[store]['income'] = 0;
}
totalIncome[store]['income'] += Number(income.stores[store]);
totalIncome[store]['delay'] = income.delay;
}
}
}
if(tt.children().length > 0) {
var total = totalIncome[storeName]['income'];
$('<div>').addClass('total row_key').text(_('total')).appendTo(tt);
$('<div>').addClass('total row_val').text(Engine.getIncomeMsg(total, totalIncome[storeName]['delay'])).appendTo(tt);
tt.appendTo(el);
}
});
Expand Down

0 comments on commit 64f6797

Please sign in to comment.