Skip to content

Commit

Permalink
added images on empty slots (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhnb committed Jan 20, 2020
1 parent 3167269 commit 2a03935
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions srcjs/stendhal/ui/itemcontainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ stendhal.ui = stendhal.ui || {};
*
* @constructor
*/
stendhal.ui.ItemContainerWindow = function(slot, size, object, suffix, quickPickup) {
stendhal.ui.ItemContainerWindow = function(slot, size, object, suffix, quickPickup, defaultImage) {
this.update = function() {
render();
};
Expand All @@ -42,7 +42,11 @@ stendhal.ui.ItemContainerWindow = function(slot, size, object, suffix, quickPick
}
for (var i = cnt; i < size; i++) {
var e = document.getElementById(slot + suffix + i);
e.style.backgroundImage = "none";
if (defaultImage) {
e.style.backgroundImage = "url(data/gui/" + defaultImage + ")";
} else {
e.style.backgroundImage = "none";
}
e.textContent = "";
e.dataItem = null;
}
Expand Down Expand Up @@ -153,14 +157,16 @@ stendhal.ui.ItemContainerWindow = function(slot, size, object, suffix, quickPick
stendhal.ui.equip = {
slotNames: ["head", "lhand", "rhand", "finger", "armor", "cloak", "legs", "feet", "bag", "keyring", "portfolio"],
slotSizes: [ 1, 1, 1, 1, 1, 1, 1, 1, 12, 8, 9 ],
slotImages: ["slot-helmet.png", "slot-shield.png", "slot-weapon.png", "slot-ring.png", "slot-armor.png", "slot-cloak.png",
"slot-legs.png", "slot-boots.png", null, "slot-key.png", "slot-portfolio.png"],
counter: 0,

init: function() {
stendhal.ui.equip.inventory = [];
for (var i in this.slotNames) {
stendhal.ui.equip.inventory.push(
new stendhal.ui.ItemContainerWindow(
this.slotNames[i], this.slotSizes[i], null, "", false));
this.slotNames[i], this.slotSizes[i], null, "", false, this.slotImages[i]));
}
},

Expand All @@ -184,7 +190,7 @@ stendhal.ui.equip = {
html += "</div>";

var popup = new stendhal.ui.Popup(title, html, 160, 370);
var itemContainer = new stendhal.ui.ItemContainerWindow(slot, sizeX * sizeY, object, suffix, quickPickup);
var itemContainer = new stendhal.ui.ItemContainerWindow(slot, sizeX * sizeY, object, suffix, quickPickup, null);
stendhal.ui.equip.inventory.push(itemContainer);
itemContainer.update();
popup.onClose = function() {
Expand Down

0 comments on commit 2a03935

Please sign in to comment.