added sort + fixed cost display

This commit is contained in:
MasterGordon 2018-04-02 22:52:35 +02:00
parent e4bfee1ede
commit dd850119de
3 changed files with 25 additions and 5 deletions

View File

@ -311,7 +311,7 @@ function drawInfoBar() {
} else {
$('#infoDesc p').css("height", 166)
}
if (mode == "selectbuilding" || mode == "building") {
if (mode == "selectbuilding" || mode == "build") {
if (selectedTile != 0) {
infoCtx.textAlign = "center"
infoCtx.font = "18px Electrolize"

View File

@ -374,6 +374,25 @@ function closeUi() {
}
}
function sort() {
if (itemId.length > 1) {
var swapped = true
while (swapped) {
swapped = false
for (var i = 0; i < itemId.length - 1; i++) {
if (itemId[i] > itemId[i + 1]) {
var id = itemId[i]
var count = itemCount[i]
itemId[i] = itemId[i + 1]
itemCount[i] = itemCount[i + 1]
itemCount[i + 1] = count
itemId[i + 1] = id
swapped = true
}
}
}
}
}
function drawInventory(inventory, title) {
if (!(inventory instanceof Inventory))
@ -391,6 +410,7 @@ function drawInventory(inventory, title) {
itemCount[index]++
}
}
sort()
inventoryCtx.clearRect(0, 0, innerWidth, innerHeight)
inventoryCtx.font = "20px Electrolize"
@ -445,7 +465,7 @@ function drawBigInventory(inventory) {
itemCount[index]++
}
}
//var swapped =
sort()
for (var i = 0; i < items.length; i++) {
$('#itemBig_' + i)[0].getContext("2d").clearRect(0, 0, 72, 72)
}

View File

@ -1,6 +1,6 @@
none
selectbuilding
building
build
rotate
delete
showmore