From: Elias Fleckenstein Date: Tue, 29 Jun 2021 14:49:01 +0000 (+0200) Subject: Make dragonblocks.getTexture() return value contain background-size: cover X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=647040aa14a0ada7430ad4df56ef3e8323c14033;p=dragonblocks.git Make dragonblocks.getTexture() return value contain background-size: cover --- diff --git a/engine/assets.js b/engine/assets.js index aef2340..1e8c291 100644 --- a/engine/assets.js +++ b/engine/assets.js @@ -41,7 +41,7 @@ dragonblocks.getTexture = name => { let path = dragonblocks.textures[name]; - return path ? "url(" + path + ")" : name; + return path ? "left top/cover url(" + path + ")" : name; }; dragonblocks.resolveTextures = elem => { @@ -55,7 +55,7 @@ dragonblocks.resolveTextures = elem => { }; dragonblocks.getSound = name => { - if(! name) + if (! name) return ""; return dragonblocks.sounds[name] || name; diff --git a/engine/creative_inventory.js b/engine/creative_inventory.js index b85331f..e94490d 100644 --- a/engine/creative_inventory.js +++ b/engine/creative_inventory.js @@ -89,7 +89,6 @@ dragonblocks.CreativeInventory = class extends dragonblocks.Inventory arrow.style.height = dragonblocks.settings.inventory.scale + "px"; arrow.style[dir] = "0px"; arrow.style.background = dragonblocks.getTexture("arrow.png"); - arrow.style.backgroundSize = "cover"; arrow.style.cursor = "pointer"; if (dir == "right") diff --git a/engine/gui.js b/engine/gui.js index 3d6eea9..5567e34 100644 --- a/engine/gui.js +++ b/engine/gui.js @@ -96,7 +96,6 @@ dragonblocks.gui.Box = class extends EventTarget moveField.style.width = this.big ? "50px": "30px"; moveField.style.height = this.big ? "50px": "30px"; moveField.style.background = dragonblocks.getTexture("move.png"); - moveField.style.backgroundSize = "cover" moveField.style.cursor = "move"; let self = this; @@ -136,7 +135,6 @@ dragonblocks.gui.Box = class extends EventTarget closeField.style.width = this.big ? "50px": "30px"; closeField.style.height = this.big ? "50px": "30px"; closeField.style.background = dragonblocks.getTexture("close.png"); - closeField.style.backgroundSize = "cover"; closeField.style.cursor = "pointer"; let self = this; diff --git a/engine/hotbar.js b/engine/hotbar.js index 755e03a..62f8309 100644 --- a/engine/hotbar.js +++ b/engine/hotbar.js @@ -105,7 +105,6 @@ dragonblocks.Hotbar = class slotDisplay.style.background = itemstack.item && dragonblocks.getTexture(itemstack.toItem().texture); if (! slotDisplay.style.backgroundColor || slotDisplay.style.backgroundColor == "initial") slotDisplay.style.backgroundColor = "rgba(0, 0, 0, 0.3)"; - slotDisplay.style.backgroundSize = "cover"; slotCountDisplay.innerHTML = (itemstack.count <= 1) ? "" : itemstack.count; diff --git a/engine/item_stack.js b/engine/item_stack.js index cee5ee6..2345446 100644 --- a/engine/item_stack.js +++ b/engine/item_stack.js @@ -227,7 +227,6 @@ dragonblocks.ItemStack = class extends EventTarget display.title = item.desc; display.style.background = dragonblocks.getTexture(item.texture); - display.style.backgroundSize = "cover"; if (this.count > 1) countDisplay.innerHTML = this.count; diff --git a/engine/mainmenu.js b/engine/mainmenu.js index a4ba2f0..a525c0a 100644 --- a/engine/mainmenu.js +++ b/engine/mainmenu.js @@ -300,7 +300,6 @@ arrow.style.position = "absolute"; arrow.style[dir] = "3px"; arrow.style.background = dragonblocks.getTexture("arrow.png"); - arrow.style.backgroundSize = "cover"; arrow.style.cursor = "pointer"; if (dir == "right") diff --git a/engine/map_display.js b/engine/map_display.js index 474cb8a..58c64ff 100644 --- a/engine/map_display.js +++ b/engine/map_display.js @@ -136,7 +136,6 @@ dragonblocks.MapDisplay = class if (mapNodeDef) { node.style.background = dragonblocks.getTexture(mapNodeDef.texture); - node.style.backgroundSize = "cover"; node.style.zIndex = mapNodeDef.zIndex || "1"; } else { node.style.background = "black"; diff --git a/engine/map_interaction.js b/engine/map_interaction.js index 6220a4e..2345f66 100644 --- a/engine/map_interaction.js +++ b/engine/map_interaction.js @@ -27,7 +27,6 @@ dragonblocks.MapInteraction = { this.tmp.crackDisplay = this.map.entityContainer.appendChild(document.createElement("div")); this.tmp.crackDisplay.style.position = "absolute"; this.tmp.crackDisplay.style.visibility = "hidden"; - this.tmp.crackDisplay.style.backgroundSize = "cover"; this.tmp.crackDisplay.style.height = dragonblocks.settings.mapDisplay.scale + "px"; this.tmp.crackDisplay.style.width = dragonblocks.settings.mapDisplay.scale + "px"; this.tmp.crackDisplay.style.boxShadow = "0 0 0 1px black inset"; @@ -115,7 +114,6 @@ dragonblocks.MapInteraction = { nodeDef.playSound("dig"); this.tmp.crackDisplay.style.background = dragonblocks.getTexture("crack" + Math.floor(node.meta.causedDamage / nodeDef.hardness * 5) + ".png"); - this.tmp.crackDisplay.style.backgroundSize = "cover"; this.tmp.crackDisplay.style.zIndex = nodeDef.zIndex || "1"; this.tmp.digTimeout = setTimeout(_ => { diff --git a/engine/skin.js b/engine/skin.js index ea1e1f7..d9c4555 100644 --- a/engine/skin.js +++ b/engine/skin.js @@ -70,7 +70,6 @@ dragonblocks.registerSkin = def => { skinDisplay.style.width = parseInt(dragonblocks.settings.map.scale) + "px"; skinDisplay.style.height = parseInt(dragonblocks.settings.map.scale * 2) + "px"; skinDisplay.style.background = dragonblocks.getTexture(def.texture); - skinDisplay.style.backgroundSize = "cover"; skinDisplay.title = def.name + (def.desc ? "\n" + def.desc : ""); if (dragonblocks.player.skin == def.name) diff --git a/engine/spawned_entity.js b/engine/spawned_entity.js index 5bbb96e..f2c0635 100644 --- a/engine/spawned_entity.js +++ b/engine/spawned_entity.js @@ -246,7 +246,6 @@ dragonblocks.SpawnedEntity = class updateTexture() { this.tmp.display.style.background = dragonblocks.getTexture(this.texture); - this.tmp.display.style.backgroundSize = "cover"; } teleport(x, y)