popup13
This commit is contained in:
parent
84d43f0f1e
commit
f733a213b7
@ -286,3 +286,50 @@ body {
|
|||||||
color: white;
|
color: white;
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#character-ui {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 40px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.equip-left,
|
||||||
|
.equip-right {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.equip-slot {
|
||||||
|
width: 64px;
|
||||||
|
height: 64px;
|
||||||
|
border: 2px solid #8b6f3d;
|
||||||
|
background: #111;
|
||||||
|
}
|
||||||
|
|
||||||
|
.equip-slot img {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.character img {
|
||||||
|
height: 260px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#inventory-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(8, 64px);
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inventory-slot {
|
||||||
|
width: 64px;
|
||||||
|
height: 64px;
|
||||||
|
border: 1px solid #555;
|
||||||
|
background: #1b1b1b;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inventory-slot img {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|||||||
@ -1,16 +1,35 @@
|
|||||||
export async function loadWohnhaus(data) {
|
export async function loadWohnhaus() {
|
||||||
const ui = document.querySelector(".building-ui");
|
const ui = document.querySelector(".building-ui");
|
||||||
|
|
||||||
ui.innerHTML = `
|
ui.innerHTML = `
|
||||||
<div id="wohnhaus-ui">
|
|
||||||
|
<div id="character-ui">
|
||||||
|
|
||||||
|
<div class="equip-left">
|
||||||
|
<div class="equip-slot" data-slot="helmet"></div>
|
||||||
|
<div class="equip-slot" data-slot="shoulder"></div>
|
||||||
|
<div class="equip-slot" data-slot="gloves"></div>
|
||||||
|
<div class="equip-slot" data-slot="belt"></div>
|
||||||
|
<div class="equip-slot" data-slot="boots"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="character">
|
||||||
|
<img src="/images/avatar.png">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="equip-right">
|
||||||
|
<div class="equip-slot" data-slot="amulet"></div>
|
||||||
|
<div class="equip-slot" data-slot="weapon"></div>
|
||||||
|
<div class="equip-slot" data-slot="shield"></div>
|
||||||
|
<div class="equip-slot" data-slot="ring"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<h3>Inventar</h3>
|
<h3>Inventar</h3>
|
||||||
|
|
||||||
<div id="inventory-grid"></div>
|
<div id="inventory-grid"></div>
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="item-tooltip"></div>
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
loadInventory();
|
loadInventory();
|
||||||
@ -24,48 +43,34 @@ async function loadInventory() {
|
|||||||
|
|
||||||
let html = "";
|
let html = "";
|
||||||
|
|
||||||
for (let i = 0; i < 30; i++) {
|
items.forEach((item) => {
|
||||||
const item = items[i];
|
const icon = item.icon || "/images/items/default.png";
|
||||||
|
|
||||||
if (item) {
|
html += `
|
||||||
const icon = item.icon || "/images/items/default.png";
|
<div class="inventory-slot"
|
||||||
|
data-slot="${item.equip_slot || ""}">
|
||||||
html += `
|
|
||||||
<div class="inventory-slot" data-name="${item.name}">
|
|
||||||
<img src="${icon}">
|
<img src="${icon}">
|
||||||
<div class="item-amount">${item.amount || ""}</div>
|
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
} else {
|
});
|
||||||
html += `<div class="inventory-slot"></div>`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
grid.innerHTML = html;
|
grid.innerHTML = html;
|
||||||
|
|
||||||
initTooltips();
|
initEquip();
|
||||||
}
|
}
|
||||||
|
|
||||||
function initTooltips() {
|
function initEquip() {
|
||||||
const tooltip = document.getElementById("item-tooltip");
|
document.querySelectorAll(".inventory-slot").forEach((item) => {
|
||||||
|
item.addEventListener("click", () => {
|
||||||
|
const slot = item.dataset.slot;
|
||||||
|
|
||||||
document.querySelectorAll(".inventory-slot").forEach((slot) => {
|
const target = document.querySelector(
|
||||||
slot.addEventListener("mouseenter", () => {
|
'.equip-slot[data-slot="' + slot + '"]',
|
||||||
const name = slot.dataset.name;
|
);
|
||||||
|
|
||||||
if (!name) return;
|
if (!target) return;
|
||||||
|
|
||||||
tooltip.innerHTML = `<strong>${name}</strong>`;
|
target.innerHTML = item.innerHTML;
|
||||||
tooltip.style.display = "block";
|
|
||||||
});
|
|
||||||
|
|
||||||
slot.addEventListener("mousemove", (e) => {
|
|
||||||
tooltip.style.left = e.pageX + 10 + "px";
|
|
||||||
tooltip.style.top = e.pageY + 10 + "px";
|
|
||||||
});
|
|
||||||
|
|
||||||
slot.addEventListener("mouseleave", () => {
|
|
||||||
tooltip.style.display = "none";
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,14 +65,23 @@ document.querySelectorAll(".building").forEach((building) => {
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const actionsTab = document.getElementById("tab-actions");
|
const actionsTab = document.getElementById("tab-actions");
|
||||||
|
const tabs = document.querySelector(".popup-tabs");
|
||||||
|
|
||||||
actionsTab.innerHTML = ` <button>Betreten</button> `;
|
// Standard: Tabs anzeigen
|
||||||
|
tabs.style.display = "flex";
|
||||||
|
|
||||||
// Prüfen ob das Gebäude ein eigenes Modul hat
|
actionsTab.innerHTML = `<button>Betreten</button>`;
|
||||||
|
|
||||||
|
// Prüfen ob Gebäude ein eigenes Modul hat
|
||||||
if (buildingModules[Number(data.type)]) {
|
if (buildingModules[Number(data.type)]) {
|
||||||
|
// NUR beim Wohnhaus Tabs ausblenden
|
||||||
|
if (Number(data.type) === 11) {
|
||||||
|
tabs.style.display = "none";
|
||||||
|
}
|
||||||
|
|
||||||
actionsTab.innerHTML = `
|
actionsTab.innerHTML = `
|
||||||
<div class="building-ui"></div>
|
<div class="building-ui"></div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Modul starten
|
// Modul starten
|
||||||
buildingModules[data.type](data);
|
buildingModules[data.type](data);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user