mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-06-29 15:52:31 +08:00
Take all, take everything, leave if possible
Multiple fixes: 1. take all of a kind 2. take everything 3. if possible, leave 4. drop menu on hover 5. Same item not shown as drop option
This commit is contained in:
committed by
Blake Grotewold
parent
da0d39b579
commit
7208b845b1
+208
-98
@@ -46,13 +46,6 @@ var Events = {
|
|||||||
Events.activeScene = name;
|
Events.activeScene = name;
|
||||||
var scene = Events.activeEvent().scenes[name];
|
var scene = Events.activeEvent().scenes[name];
|
||||||
|
|
||||||
// Scene reward
|
|
||||||
if(scene.reward) {
|
|
||||||
$SM.addM('stores', scene.reward);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// onLoad
|
// onLoad
|
||||||
if(scene.onLoad) {
|
if(scene.onLoad) {
|
||||||
scene.onLoad();
|
scene.onLoad();
|
||||||
@@ -63,6 +56,11 @@ var Events = {
|
|||||||
Notifications.notify(null, scene.notification);
|
Notifications.notify(null, scene.notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scene reward
|
||||||
|
if(scene.reward) {
|
||||||
|
$SM.addM('stores', scene.reward);
|
||||||
|
}
|
||||||
|
|
||||||
$('#description', Events.eventPanel()).empty();
|
$('#description', Events.eventPanel()).empty();
|
||||||
$('#buttons', Events.eventPanel()).empty();
|
$('#buttons', Events.eventPanel()).empty();
|
||||||
if(scene.combat) {
|
if(scene.combat) {
|
||||||
@@ -221,6 +219,8 @@ var Events = {
|
|||||||
w.data('hp', hp);
|
w.data('hp', hp);
|
||||||
Events.updateFighterDiv(w);
|
Events.updateFighterDiv(w);
|
||||||
Events.drawFloatText('+' + World.meatHeal(), '#wanderer .hp');
|
Events.drawFloatText('+' + World.meatHeal(), '#wanderer .hp');
|
||||||
|
var takeETbutton = Events.setTakeAll();
|
||||||
|
Events.canLeave(takeETbutton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -243,6 +243,8 @@ var Events = {
|
|||||||
w.data('hp', hp);
|
w.data('hp', hp);
|
||||||
Events.updateFighterDiv(w);
|
Events.updateFighterDiv(w);
|
||||||
Events.drawFloatText('+' + World.medsHeal(), '#wanderer .hp');
|
Events.drawFloatText('+' + World.medsHeal(), '#wanderer .hp');
|
||||||
|
var takeETbutton = Events.setTakeAll();
|
||||||
|
Events.canLeave(takeETbutton);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -454,23 +456,23 @@ var Events = {
|
|||||||
Engine.setTimeout(function() {
|
Engine.setTimeout(function() {
|
||||||
try {
|
try {
|
||||||
var scene = Events.activeEvent().scenes[Events.activeScene];
|
var scene = Events.activeEvent().scenes[Events.activeScene];
|
||||||
|
var leaveBtn = false;
|
||||||
var desc = $('#description', Events.eventPanel());
|
var desc = $('#description', Events.eventPanel());
|
||||||
var btns = $('#buttons', Events.eventPanel());
|
var btns = $('#buttons', Events.eventPanel());
|
||||||
desc.empty();
|
desc.empty();
|
||||||
btns.empty();
|
btns.empty();
|
||||||
$('<div>').text(scene.deathMessage).appendTo(desc);
|
$('<div>').text(scene.deathMessage).appendTo(desc);
|
||||||
|
|
||||||
Events.drawLoot(scene.loot);
|
var takeETbtn = Events.drawLoot(scene.loot);
|
||||||
|
|
||||||
if(scene.buttons) {
|
if(scene.buttons) {
|
||||||
// Draw the buttons
|
// Draw the buttons
|
||||||
Events.drawButtons(scene);
|
leaveBtn = Events.drawButtons(scene);
|
||||||
} else {
|
} else {
|
||||||
Button.cooldown(new Button.Button({
|
leaveBtn = new Button.Button({
|
||||||
id: 'leaveBtn',
|
id: 'leaveBtn',
|
||||||
cooldown: Events._LEAVE_COOLDOWN,
|
cooldown: Events._LEAVE_COOLDOWN,
|
||||||
click: function() {
|
click: function() {
|
||||||
var scene = Events.activeEvent().scenes[Events.activeScene];
|
|
||||||
if(scene.nextScene && scene.nextScene != 'end') {
|
if(scene.nextScene && scene.nextScene != 'end') {
|
||||||
Events.loadScene(scene.nextScene);
|
Events.loadScene(scene.nextScene);
|
||||||
} else {
|
} else {
|
||||||
@@ -478,13 +480,15 @@ var Events = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
text: _('leave')
|
text: _('leave')
|
||||||
}).appendTo(btns));
|
});
|
||||||
|
Button.cooldown(leaveBtn.appendTo(btns));
|
||||||
|
|
||||||
Events.createEatMeatButton(0).appendTo(btns);
|
Events.createEatMeatButton(0).appendTo(btns);
|
||||||
if((Path.outfit['medicine'] || 0) !== 0) {
|
if((Path.outfit['medicine'] || 0) !== 0) {
|
||||||
Events.createUseMedsButton(0).appendTo(btns);
|
Events.createUseMedsButton(0).appendTo(btns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Events.allowLeave(takeETbtn, leaveBtn);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
// It is possible to die and win if the timing is perfect. Just let it fail.
|
// It is possible to die and win if the timing is perfect. Just let it fail.
|
||||||
}
|
}
|
||||||
@@ -492,106 +496,212 @@ var Events = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
drawDrop:function(btn) {
|
||||||
|
var name = btn.attr('id').substring(5).replace('-', ' ');
|
||||||
|
var needsAppend = false;
|
||||||
|
var weight = Path.getWeight(name);
|
||||||
|
var freeSpace = Path.getFreeSpace();
|
||||||
|
if(weight > freeSpace) {
|
||||||
|
// Draw the drop menu
|
||||||
|
Engine.log('drop menu');
|
||||||
|
if($('#dropMenu').length){
|
||||||
|
var dropMenu = $('#dropMenu');
|
||||||
|
$('#dropMenu').empty();
|
||||||
|
} else {
|
||||||
|
var dropMenu = $('<div>').attr({'id': 'dropMenu', 'data-legend': _('drop:')});
|
||||||
|
needsAppend = true;
|
||||||
|
}
|
||||||
|
for(var k in Path.outfit) {
|
||||||
|
if(name == k) continue;
|
||||||
|
var itemWeight = Path.getWeight(k);
|
||||||
|
if(itemWeight > 0) {
|
||||||
|
var numToDrop = Math.ceil((weight - freeSpace) / itemWeight);
|
||||||
|
if(numToDrop > Path.outfit[k]) {
|
||||||
|
numToDrop = Path.outfit[k];
|
||||||
|
}
|
||||||
|
if(numToDrop > 0) {
|
||||||
|
var dropRow = $('<div>').attr('id', 'drop_' + k.replace(' ', '-'))
|
||||||
|
.text(_(k) + ' x' + numToDrop)
|
||||||
|
.data('thing', k)
|
||||||
|
.data('num', numToDrop)
|
||||||
|
.click(Events.dropStuff)
|
||||||
|
.mouseenter(function(e){
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
dropRow.appendTo(dropMenu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$('<div>').attr('id','no_drop')
|
||||||
|
.text(_('nothing'))
|
||||||
|
.mouseenter(function(e){
|
||||||
|
e.stopPropagation();
|
||||||
|
})
|
||||||
|
.click(function(e){
|
||||||
|
e.stopPropagation();
|
||||||
|
dropMenu.remove();
|
||||||
|
})
|
||||||
|
.appendTo(dropMenu);
|
||||||
|
if(needsAppend){
|
||||||
|
dropMenu.appendTo(btn);
|
||||||
|
}
|
||||||
|
btn.one("mouseleave", function() {
|
||||||
|
$('#dropMenu').remove();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
drawLootRow: function(name, num){
|
||||||
|
var id = name.replace(' ', '-');
|
||||||
|
var lootRow = $('<div>').attr('id','loot_' + id).data('item', name).addClass('lootRow');
|
||||||
|
var take = new Button.Button({
|
||||||
|
id: 'take_' + id,
|
||||||
|
text: _(name) + ' [' + num + ']',
|
||||||
|
click: Events.getLoot
|
||||||
|
}).addClass('lootTake').data('numLeft', num).appendTo(lootRow);
|
||||||
|
take.mouseenter(function(){
|
||||||
|
Events.drawDrop(take);
|
||||||
|
});
|
||||||
|
var takeall = new Button.Button({
|
||||||
|
id: 'all_take_' + id,
|
||||||
|
text: _('take') + ' ',
|
||||||
|
click: Events.takeAll
|
||||||
|
}).addClass('lootTakeAll').appendTo(lootRow);
|
||||||
|
$('<span>').insertBefore(takeall.children('.cooldown'));
|
||||||
|
$('<div>').addClass('clear').appendTo(lootRow);
|
||||||
|
return lootRow;
|
||||||
|
},
|
||||||
|
|
||||||
drawLoot: function(lootList) {
|
drawLoot: function(lootList) {
|
||||||
var desc = $('#description', Events.eventPanel());
|
var desc = $('#description', Events.eventPanel());
|
||||||
var lootButtons = $('<div>').attr('id', 'lootButtons');
|
var lootButtons = $('<div>').attr({'id': 'lootButtons', 'data-legend': _('take:')});
|
||||||
for(var k in lootList) {
|
for(var k in lootList) {
|
||||||
var loot = lootList[k];
|
var loot = lootList[k];
|
||||||
if(Math.random() < loot.chance) {
|
if(Math.random() < loot.chance) {
|
||||||
var num = Math.floor(Math.random() * (loot.max - loot.min)) + loot.min;
|
var num = Math.floor(Math.random() * (loot.max - loot.min)) + loot.min;
|
||||||
new Button.Button({
|
var lootRow = Events.drawLootRow(k, num);
|
||||||
id: 'loot_' + k.replace(' ', '-'),
|
lootRow.appendTo(lootButtons);
|
||||||
text: _(k) + ' [' + num + ']',
|
|
||||||
click: Events.getLoot
|
|
||||||
}).data('numLeft', num).appendTo(lootButtons);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$('<div>').addClass('clear').appendTo(lootButtons);
|
lootButtons.appendTo(desc);
|
||||||
if(lootButtons.children().length > 1) {
|
if(lootButtons.children().length > 0) {
|
||||||
lootButtons.appendTo(desc);
|
var takeETrow = $('<div>').addClass('takeETrow');
|
||||||
var takeAll = new Button.Button({
|
var takeET = new Button.Button({
|
||||||
id: 'loot_take_all',
|
id: 'loot_takeEverything',
|
||||||
text: _('take all'),
|
text: '',
|
||||||
click: Events.takeAllLoot
|
click: Events.takeEverything
|
||||||
}).addClass('take-all-button').appendTo(lootButtons);
|
}).appendTo(takeETrow);
|
||||||
|
$('<span>').insertBefore(takeET.children('.cooldown'));
|
||||||
|
$('<div>').addClass('clear').appendTo(takeETrow);
|
||||||
|
takeETrow.appendTo(lootButtons);
|
||||||
|
Events.setTakeAll(lootButtons);
|
||||||
|
} else {
|
||||||
|
var noLoot = $('<div>').addClass('noLoot').text( _('nothing to take') );
|
||||||
|
noLoot.appendTo(lootButtons);
|
||||||
|
}
|
||||||
|
return takeET || false;
|
||||||
|
},
|
||||||
|
|
||||||
|
setTakeAll: function(lootButtons){
|
||||||
|
var lootButtons = lootButtons || $('#lootButtons');
|
||||||
|
var canTakeSomething = false;
|
||||||
|
var free = Path.getFreeSpace();
|
||||||
|
var takeETbutton = lootButtons.find('#loot_takeEverything');
|
||||||
|
lootButtons.children('.lootRow').each(function(i){
|
||||||
|
var name = $(this).data('item');
|
||||||
|
var take = $(this).children('.lootTake').first();
|
||||||
|
var takeAll = $(this).children('.lootTakeAll').first();
|
||||||
|
var numLeft = take.data('numLeft');
|
||||||
|
var num = Math.min(Math.floor(Path.getFreeSpace() / Path.getWeight(name)), numLeft);
|
||||||
|
takeAll.data('numLeft', num);
|
||||||
|
free -= numLeft * Path.getWeight(name);
|
||||||
|
if(num > 0){
|
||||||
|
takeAll.removeClass('disabled');
|
||||||
|
canTakeSomething = true;
|
||||||
|
} else {
|
||||||
|
takeAll.addClass('disabled');
|
||||||
|
}
|
||||||
|
if(num < numLeft){
|
||||||
|
takeAll.children('span').first().text(num);
|
||||||
|
} else {
|
||||||
|
takeAll.children('span').first().text(_('all'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(canTakeSomething){
|
||||||
|
takeETbutton.removeClass('disabled');
|
||||||
|
} else {
|
||||||
|
takeETbutton.addClass('disabled');
|
||||||
|
}
|
||||||
|
takeETbutton.data('canTakeEverything', (free >= 0) ? true : false);
|
||||||
|
return takeETbutton;
|
||||||
|
},
|
||||||
|
|
||||||
|
allowLeave: function(takeETbtn, leaveBtn){
|
||||||
|
if(takeETbtn){
|
||||||
|
if(leaveBtn){
|
||||||
|
takeETbtn.data('leaveBtn', leaveBtn);
|
||||||
|
}
|
||||||
|
Events.canLeave(takeETbtn);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
takeAllLoot: function(){
|
canLeave: function(btn){
|
||||||
|
var basetext = _('take everything');
|
||||||
var stoppedEarly = false;
|
var textbox = btn.children('span');
|
||||||
$('#lootButtons')
|
var takeAndLeave = (btn.data('leaveBtn')) ? btn.data('canTakeEverything') : false;
|
||||||
.children('.button')
|
if(takeAndLeave){
|
||||||
.each(function(){
|
textbox.text( basetext + _(' and ') + _('leave') );
|
||||||
if( $(this).hasClass('take-all-button') ) {
|
btn.data('canLeave', true);
|
||||||
return;
|
} else {
|
||||||
}
|
textbox.text( basetext );
|
||||||
|
btn.data('canLeave', false)
|
||||||
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);
|
||||||
|
var target = btn.closest('.button');
|
||||||
var thing = btn.data('thing');
|
var thing = btn.data('thing');
|
||||||
|
var id = 'take_' + thing.replace(' ', '-');
|
||||||
var num = btn.data('num');
|
var num = btn.data('num');
|
||||||
var lootButtons = $('#lootButtons');
|
var lootButtons = $('#lootButtons');
|
||||||
Engine.log('dropping ' + num + ' ' + thing);
|
Engine.log('dropping ' + num + ' ' + thing);
|
||||||
|
|
||||||
var lootBtn = $('#loot_' + thing.replace(' ', '-'), lootButtons);
|
var lootBtn = $('#' + id, lootButtons);
|
||||||
if(lootBtn.length > 0) {
|
if(lootBtn.length > 0) {
|
||||||
var curNum = lootBtn.data('numLeft');
|
var curNum = lootBtn.data('numLeft');
|
||||||
curNum += num;
|
curNum += num;
|
||||||
lootBtn.text(_(thing) + ' [' + curNum + ']').data('numLeft', curNum);
|
lootBtn.text(_(thing) + ' [' + curNum + ']').data('numLeft', curNum);
|
||||||
} else {
|
} else {
|
||||||
new Button.Button({
|
var lootRow = Events.drawLootRow(thing, num);
|
||||||
id: 'loot_' + thing.replace(' ', '-'),
|
lootRow.insertBefore($('.takeETrow', lootButtons));
|
||||||
text: _(thing) + ' [' + num + ']',
|
|
||||||
click: Events.getLoot
|
|
||||||
}).data('numLeft', num).insertBefore($('.clear', lootButtons));
|
|
||||||
}
|
}
|
||||||
Path.outfit[thing] -= num;
|
Path.outfit[thing] -= num;
|
||||||
Events.getLoot(btn.closest('.button'));
|
Events.getLoot(target);
|
||||||
World.updateSupplies();
|
World.updateSupplies();
|
||||||
},
|
},
|
||||||
|
|
||||||
getLoot: function(btn) {
|
getLoot: function(btn, skipButtonSet) {
|
||||||
var name = btn.attr('id').substring(5).replace('-', ' ');
|
var name = btn.attr('id').substring(5).replace('-', ' ');
|
||||||
if(btn.data('numLeft') > 0) {
|
if(btn.data('numLeft') > 0) {
|
||||||
|
var skipButtonSet = skipButtonSet || false;
|
||||||
var weight = Path.getWeight(name);
|
var weight = Path.getWeight(name);
|
||||||
var freeSpace = Path.getFreeSpace();
|
var freeSpace = Path.getFreeSpace();
|
||||||
if(weight <= freeSpace) {
|
if(weight <= freeSpace) {
|
||||||
var num = btn.data('numLeft');
|
var num = btn.data('numLeft');
|
||||||
num--;
|
num--;
|
||||||
btn.data('numLeft', num);
|
btn.data('numLeft', num);
|
||||||
|
// #dropMenu gets removed by this.
|
||||||
|
btn.text(_(name) + ' [' + num + ']');
|
||||||
if(num === 0) {
|
if(num === 0) {
|
||||||
Button.setDisabled(btn);
|
Button.setDisabled(btn);
|
||||||
btn.animate({'opacity':0}, 300, 'linear', function() {
|
btn.animate({'opacity':0}, 300, 'linear', function() {
|
||||||
$(this).remove();
|
$(this).parent().remove();
|
||||||
if($('#lootButtons').children().length == 1) {
|
if($('#lootButtons').children().length == 1) {
|
||||||
$('#lootButtons').remove();
|
$('#lootButtons').remove();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
// #dropMenu gets removed by this.
|
|
||||||
btn.text(_(name) + ' [' + num + ']');
|
|
||||||
}
|
}
|
||||||
var curNum = Path.outfit[name];
|
var curNum = Path.outfit[name];
|
||||||
curNum = typeof curNum == 'number' ? curNum : 0;
|
curNum = typeof curNum == 'number' ? curNum : 0;
|
||||||
@@ -599,39 +709,33 @@ var Events = {
|
|||||||
Path.outfit[name] = curNum;
|
Path.outfit[name] = curNum;
|
||||||
World.updateSupplies();
|
World.updateSupplies();
|
||||||
|
|
||||||
// Update weight and free space variables so we can decide
|
if(!skipButtonSet){
|
||||||
// whether or not to bring up/update the drop menu.
|
Events.setTakeAll();
|
||||||
weight = Path.getWeight(name);
|
|
||||||
freeSpace = Path.getFreeSpace();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(weight > freeSpace && btn.data('numLeft') > 0) {
|
|
||||||
// Draw the drop menu
|
|
||||||
Engine.log('drop menu');
|
|
||||||
$('#dropMenu').remove();
|
|
||||||
var dropMenu = $('<div>').attr('id', 'dropMenu');
|
|
||||||
for(var k in Path.outfit) {
|
|
||||||
var itemWeight = Path.getWeight(k);
|
|
||||||
if(itemWeight > 0) {
|
|
||||||
var numToDrop = Math.ceil((weight - freeSpace) / itemWeight);
|
|
||||||
if(numToDrop > Path.outfit[k]) {
|
|
||||||
numToDrop = Path.outfit[k];
|
|
||||||
}
|
|
||||||
if(numToDrop > 0) {
|
|
||||||
var dropRow = $('<div>').attr('id', 'drop_' + k.replace(' ', '-'))
|
|
||||||
.text(_(k) + ' x' + numToDrop)
|
|
||||||
.data('thing', k)
|
|
||||||
.data('num', numToDrop)
|
|
||||||
.click(Events.dropStuff);
|
|
||||||
dropRow.appendTo(dropMenu);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
dropMenu.appendTo(btn);
|
|
||||||
btn.one("mouseleave", function() {
|
|
||||||
$('#dropMenu').remove();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
if(!skipButtonSet){
|
||||||
|
Events.drawDrop(btn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
takeAll: function(btn){
|
||||||
|
var target = $('#'+ btn.attr('id').substring(4));
|
||||||
|
for(var k = 0; k < btn.data('numLeft'); k++){
|
||||||
|
Events.getLoot(target, true);
|
||||||
|
}
|
||||||
|
Events.setTakeAll();
|
||||||
|
},
|
||||||
|
|
||||||
|
takeEverything: function(btn){
|
||||||
|
$('#lootButtons').children('.lootRow').each(function(i){
|
||||||
|
var target = $(this).children('.lootTakeAll').first();
|
||||||
|
if(!target.hasClass('disabled')){
|
||||||
|
Events.takeAll(target);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(btn.data('canLeave')){
|
||||||
|
btn.data('leaveBtn').click();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -648,6 +752,7 @@ var Events = {
|
|||||||
startStory: function(scene) {
|
startStory: function(scene) {
|
||||||
// Write the text
|
// Write the text
|
||||||
var desc = $('#description', Events.eventPanel());
|
var desc = $('#description', Events.eventPanel());
|
||||||
|
var leaveBtn = false;
|
||||||
for(var i in scene.text) {
|
for(var i in scene.text) {
|
||||||
$('<div>').text(scene.text[i]).appendTo(desc);
|
$('<div>').text(scene.text[i]).appendTo(desc);
|
||||||
}
|
}
|
||||||
@@ -662,15 +767,18 @@ var Events = {
|
|||||||
|
|
||||||
// Draw any loot
|
// Draw any loot
|
||||||
if(scene.loot) {
|
if(scene.loot) {
|
||||||
Events.drawLoot(scene.loot);
|
var takeETbtn = Events.drawLoot(scene.loot);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the buttons
|
// Draw the buttons
|
||||||
Events.drawButtons(scene);
|
leaveBtn = Events.drawButtons(scene);
|
||||||
|
|
||||||
|
Events.allowLeave(takeETbtn, leaveBtn);
|
||||||
},
|
},
|
||||||
|
|
||||||
drawButtons: function(scene) {
|
drawButtons: function(scene) {
|
||||||
var btns = $('#buttons', Events.eventPanel());
|
var btns = $('#buttons', Events.eventPanel());
|
||||||
|
var btnsList = [];
|
||||||
for(var id in scene.buttons) {
|
for(var id in scene.buttons) {
|
||||||
var info = scene.buttons[id];
|
var info = scene.buttons[id];
|
||||||
var b = new Button.Button({
|
var b = new Button.Button({
|
||||||
@@ -686,9 +794,11 @@ var Events = {
|
|||||||
if(typeof info.cooldown == 'number') {
|
if(typeof info.cooldown == 'number') {
|
||||||
Button.cooldown(b);
|
Button.cooldown(b);
|
||||||
}
|
}
|
||||||
|
btnsList.push(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
Events.updateButtons();
|
Events.updateButtons();
|
||||||
|
return (btnsList.length == 1) ? btnsList[0] : false;
|
||||||
},
|
},
|
||||||
|
|
||||||
updateButtons: function() {
|
updateButtons: function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user