diff --git a/css/main.css b/css/main.css index 9ea256f..7e21aa7 100644 --- a/css/main.css +++ b/css/main.css @@ -194,15 +194,22 @@ div.button div.cooldown { /* Up/Down buttons. They're complicated! */ -.upBtn, .dnBtn { +.upBtn, .dnBtn, .maxBtn, .zeroBtn { position: absolute; width: 14px; height: 15px; - right: 0px; cursor: pointer; } -.upBtn.disabled, .dnBtn.disabled { +.upBtn, .dnBtn { + right: 0px; +} + +.maxBtn, .zeroBtn { + right: -11px; +} + +.upBtn.disabled, .dnBtn.disabled, .maxBtn.disabled, .zeroBtn.disabled { cursor: default; } @@ -210,7 +217,11 @@ div.button div.cooldown { top: -2px; } -.upBtn:after, .upBtn:before { +.maxBtn { + top: -2px; +} + +.upBtn:after, .upBtn:before, .maxBtn:after, .maxBtn:before { position: absolute; border: medium solid transparent; content: " "; @@ -219,15 +230,15 @@ div.button div.cooldown { bottom: 4px; } -.upBtn:after { +.upBtn:after, .maxBtn:after { border-color: transparent transparent white; } -.upBtn:before { +.upBtn:before, .maxBtn:before { border-color: transparent transparent black; } -.upBtn.disabled:before { +.upBtn.disabled:before, .maxBtn.disabled:before { border-color: transparent transparent #999; } @@ -236,7 +247,11 @@ div.button div.cooldown { bottom: -3px; } -.dnBtn:after, .dnBtn:before { +.zeroBtn { + bottom: -3px; +} + +.dnBtn:after, .dnBtn:before, .zeroBtn:after, .zeroBtn:before { position: absolute; border: medium solid transparent; content: " "; @@ -251,21 +266,27 @@ div.button div.cooldown { margin-left: -3px; } -.upBtn:before, .dnBtn:before { +.upBtn:before, .dnBtn:before, .maxBtn:before, .zeroBtn:before { border-width: 5px; left: 50%; margin-left: -5px; } -.dnBtn:after { +.maxBtn:after, .zeroBtn:after { + border-width: 2px; + left: 50%; + margin-left: -2px; +} + +.dnBtn:after, .zeroBtn:after { border-color: white transparent transparent; } -.dnBtn:before { +.dnBtn:before, .zeroBtn:before { border-color: black transparent transparent; } -.dnBtn.disabled:before { +.dnBtn.disabled:before, .zeroBtn.disabled:before { border-color: #999 transparent transparent; } diff --git a/script/outside.js b/script/outside.js index 9a74ca0..79ad486 100644 --- a/script/outside.js +++ b/script/outside.js @@ -296,8 +296,10 @@ var Outside = { numGatherers -= State.outside.workers[k]; if(State.outside.workers[k] == 0) { $('.dnBtn', row).addClass('disabled'); + $('.zeroBtn', row).addClass('disabled'); } else { $('.dnBtn', row).removeClass('disabled'); + $('.zeroBtn', row).removeClass('disabled'); } } @@ -310,8 +312,10 @@ var Outside = { if(numGatherers == 0) { $('.upBtn', '#workers').addClass('disabled'); + $('.maxBtn', '#workers').addClass('disabled'); } else { $('.upBtn', '#workers').removeClass('disabled'); + $('.maxBtn', '#workers').removeClass('disabled'); } @@ -338,8 +342,10 @@ var Outside = { $('').text(num).appendTo(val); if(name != 'gatherer') { + $('
').addClass('maxBtn').appendTo(val).click(Outside.maxWorker); $('
').addClass('upBtn').appendTo(val).click(Outside.increaseWorker); $('
').addClass('dnBtn').appendTo(val).click(Outside.decreaseWorker); + $('
').addClass('zeroBtn').appendTo(val).click(Outside.zeroWorker); } $('
').addClass('clear').appendTo(row); @@ -376,6 +382,26 @@ var Outside = { } }, + maxWorker: function(btn) { + var worker = $(this).closest('.workerRow').children('.row_key').text(); + if(Outside.getNumGatherers() > 0) { + Engine.log('maxing ' + worker); + State.outside.workers[worker] += Outside.getNumGatherers(); + Outside.updateVillageIncome(); + Outside.updateWorkersView(); + } + }, + + zeroWorker: function(btn) { + var worker = $(this).closest('.workerRow').children('.row_key').text(); + if(State.outside.workers[worker] > 0) { + Engine.log('zeroing ' + worker); + State.outside.workers[worker] = 0; + Outside.updateVillageIncome(); + Outside.updateWorkersView(); + } + }, + updateVillageRow: function(name, num, village) { var id = 'building_row_' + name.replace(' ', '-'); var row = $('div#' + id, village); diff --git a/script/path.js b/script/path.js index 762cac5..41c9369 100644 --- a/script/path.js +++ b/script/path.js @@ -194,13 +194,17 @@ var Path = { } if(num == 0) { $('.dnBtn', row).addClass('disabled'); + $('.zeroBtn', row).addClass('disabled'); } else { $('.dnBtn', row).removeClass('disabled'); + $('.zeroBtn', row).removeClass('disabled'); } if(num >= numAvailable || space < Path.getWeight(k)) { $('.upBtn', row).addClass('disabled'); + $('.maxBtn', row).addClass('disabled'); } else if(space >= Path.getWeight(k)) { $('.upBtn', row).removeClass('disabled'); + $('.maxBtn', row).removeClass('disabled'); } } else if(have == 0 && row.length > 0) { row.remove(); @@ -225,6 +229,8 @@ var Path = { $('').text(num).appendTo(val); $('
').addClass('upBtn').appendTo(val).click(Path.increaseSupply); $('
').addClass('dnBtn').appendTo(val).click(Path.decreaseSupply); + $('
').addClass('maxBtn').appendTo(val).click(Path.maxSupply); + $('
').addClass('zeroBtn').appendTo(val).click(Path.zeroSupply); $('
').addClass('clear').appendTo(row); var numAvailable = Engine.getStore(name); @@ -259,6 +265,30 @@ var Path = { } }, + maxSupply: function() { + var supply = $(this).closest('.outfitRow').children('.row_key').text().replace('-', ' '); + Engine.log('maxing ' + supply); + var cur = Path.outfit[supply]; + cur = typeof cur == 'number' ? cur : 0; + if(Path.getFreeSpace() >= Path.getWeight(supply) && cur < Engine.getStore(supply)) { + var maxExtraByWeight = Math.floor(Path.getFreeSpace() / Path.getWeight(supply)); + var maxExtraByStore = Engine.getStore(supply) - cur; + Path.outfit[supply] = cur + Math.min(maxExtraByWeight, maxExtraByStore); + Path.updateOutfitting(); + } + }, + + zeroSupply: function() { + var supply = $(this).closest('.outfitRow').children('.row_key').text().replace('-', ' '); + Engine.log('zeroing ' + supply); + var cur = Path.outfit[supply]; + cur = typeof cur == 'number' ? cur : 0; + if(cur > 0) { + Path.outfit[supply] = 0; + Path.updateOutfitting(); + } + }, + onArrival: function() { Path.setTitle(); Path.updateOutfitting();