mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-28 08:11:54 +08:00
Add take all button
This commit is contained in:
committed by
Blake Grotewold
parent
66054c2825
commit
8c368d363a
@@ -508,6 +508,10 @@ body.noMask #description {
|
|||||||
padding-bottom: 20px;
|
padding-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.take-all-button {
|
||||||
|
float: none;
|
||||||
|
}
|
||||||
|
|
||||||
#buttons > .button {
|
#buttons > .button {
|
||||||
margin: 0 5px 5px;
|
margin: 0 5px 5px;
|
||||||
margin-right: 15px;
|
margin-right: 15px;
|
||||||
|
|||||||
@@ -503,9 +503,44 @@ var Events = {
|
|||||||
$('<div>').addClass('clear').appendTo(lootButtons);
|
$('<div>').addClass('clear').appendTo(lootButtons);
|
||||||
if(lootButtons.children().length > 1) {
|
if(lootButtons.children().length > 1) {
|
||||||
lootButtons.appendTo(desc);
|
lootButtons.appendTo(desc);
|
||||||
|
var takeAll = new Button.Button({
|
||||||
|
id: 'loot_take_all',
|
||||||
|
text: _('take all'),
|
||||||
|
click: Events.takeAllLoot
|
||||||
|
}).addClass('take-all-button').appendTo(lootButtons);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
takeAllLoot: function(){
|
||||||
|
|
||||||
|
var stoppedEarly = false;
|
||||||
|
$('#lootButtons')
|
||||||
|
.children('.button')
|
||||||
|
.each(function(){
|
||||||
|
if( $(this).hasClass('take-all-button') ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var weight = $(this).data('numLeft') * Path.getWeight($(this).attr('id').substring(5).replace('-', ' '));
|
||||||
|
while( $(this).data('numLeft') > 0 && weight < Path.getFreeSpace() ){
|
||||||
|
$(this).click();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(weight > Path.getFreeSpace()){
|
||||||
|
stoppedEarly = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if( !stoppedEarly ){
|
||||||
|
|
||||||
|
$('#leave').click();
|
||||||
|
$('#leaveBtn').click();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
dropStuff: function(e) {
|
dropStuff: function(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
var btn = $(this);
|
var btn = $(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user