diff --git a/html/js/invScript.js b/html/js/invScript.js
index 85f3f4e2..38f3e25c 100644
--- a/html/js/invScript.js
+++ b/html/js/invScript.js
@@ -1,5 +1,35 @@
let imageCache = {};
+const HUD_POS_KEY = "vorp_inventory_hud_pos";
+
+function saveHudPos() {
+ const hud = document.getElementById("inventoryHud");
+ if (!hud) return;
+
+ const pos = {
+ left: hud.style.left || "",
+ top: hud.style.top || ""
+ };
+
+ localStorage.setItem(HUD_POS_KEY, JSON.stringify(pos));
+}
+
+function applyHudPos() {
+ const hud = document.getElementById("inventoryHud");
+ if (!hud) return;
+
+ const raw = localStorage.getItem(HUD_POS_KEY);
+ if (!raw) return;
+
+ try {
+ const pos = JSON.parse(raw);
+ if (pos.left) hud.style.left = pos.left;
+ if (pos.top) hud.style.top = pos.top;
+ } catch (e) {
+ console.warn("Invalid HUD pos in storage:", e);
+ }
+}
+
/**
* Preload images
* @param {Array} images - The array of images to preload so we can choose to display placeholder or not
@@ -7,6 +37,10 @@ let imageCache = {};
function preloadImages(images) {
$.each(images, function (_, image) {
+ if (typeof image === "string" && (image.startsWith("http://") || image.startsWith("https://"))) {
+ imageCache[image] = `url("${image}");`;
+ return;
+ }
const img = new Image();
img.onload = () => {
imageCache[image] = `url("img/items/${image}.png");`;
@@ -16,17 +50,16 @@ function preloadImages(images) {
};
img.src = `img/items/${image}.png`;
});
-
}
-/* DROP DOWN BUTTONS MAIN AND SECONDARY INVENTORY */
document.addEventListener('DOMContentLoaded', () => {
+ applyHudPos();
+
document.querySelectorAll('.dropdownButton[data-type="clothing"], .dropdownButton1[data-type="clothing"]').forEach(button => {
button.classList.add('active');
});
});
-
function bindButtonEventListeners() {
document.querySelectorAll('.dropdownButton[data-type="itemtype"]').forEach(button => {
button.addEventListener('mouseenter', function () {
@@ -277,7 +310,11 @@ $(document).ready(function () {
});
function moveInventory(inv) {
+ if (localStorage.getItem(HUD_POS_KEY)) return;
+
const inventoryHud = document.getElementById('inventoryHud');
+ if (!inventoryHud) return;
+
if (inv === 'main') {
inventoryHud.style.left = '25%';
} else if (inv === 'second') {
@@ -285,8 +322,6 @@ function moveInventory(inv) {
}
}
-
-
function addData(index, item) {
$("#item-" + index).data("item", item);
@@ -457,8 +492,8 @@ function getDegradationMain(item) {
const degradationPercentage = getItemDegradationPercentage(item);
const color = getColorForDegradation(degradationPercentage);
- return `
${LANGUAGE.labels.decay}${degradationPercentage.toFixed(0)}%`;
-
+ const decayLabel = (LANGUAGE?.labels?.decay) ?? "Verfall ";
+ return `
${decayLabel}${degradationPercentage.toFixed(0)}%`;
}
/**
@@ -497,17 +532,23 @@ function loadInventoryItems(item, index, group, count, limit) {
function loadInventoryWeapons(item, index, group) {
if (item.type != "item_weapon") return;
- const weight = getItemWeight(item.weight, 1);
- const info = item.serial_number ? "
" + (LANGUAGE.labels?.ammo ?? "Ammo") + item.count + "
" + (LANGUAGE.labels?.serial ?? "Serial") + item.serial_number : "";
- const url = imageCache[item.name]
+ // NEU: Wir entfernen das störende "
" am Anfang mit .replace()
+ let weight = getItemWeight(item.weight, 1).replace('
', '');
+
+ const info = item.serial_number ? "
" + (LANGUAGE.labels?.ammo ?? "Ammo") + " " + item.count + "
" + (LANGUAGE.labels?.serial ?? "Serial") + " " + item.serial_number : "";
+ const url = imageCache[item.name];
const label = item.custom_label ? item.custom_label : item.label;
- $("#inventoryElement").append(`