From 89e6684288bc5835d19070bfffbef7c05e5c8c0b Mon Sep 17 00:00:00 2001 From: dingo Date: Sun, 4 Jan 2026 14:01:36 -0500 Subject: [PATCH] Dungeon Builder. CONT.. --- .../Pages/DungeonBuilder/RoomEdit.cshtml | 14 ++++++++++---- .../Pages/DungeonBuilder/TileEdit.cshtml | 19 +++++++++---------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Services/Admin/Pages/DungeonBuilder/RoomEdit.cshtml b/Services/Admin/Pages/DungeonBuilder/RoomEdit.cshtml index 46f5df6..8694570 100644 --- a/Services/Admin/Pages/DungeonBuilder/RoomEdit.cshtml +++ b/Services/Admin/Pages/DungeonBuilder/RoomEdit.cshtml @@ -15,8 +15,6 @@ border-radius: 4px; } .editor-cell { - width: 32px; - height: 32px; background: #0f0f1a; cursor: crosshair; position: relative; @@ -274,12 +272,17 @@ function loadData() { function buildGrid() { const g = document.getElementById('editorGrid'); - g.style.gridTemplateColumns = `repeat(${gw}, 32px)`; + // Use sheet tile dimensions if available, fallback to 32px + const cellW = sheet?.tw || 32; + const cellH = sheet?.th || 32; + g.style.gridTemplateColumns = `repeat(${gw}, ${cellW}px)`; g.innerHTML = ''; for (let y = 0; y < gh; y++) { for (let x = 0; x < gw; x++) { const c = document.createElement('div'); c.className = 'editor-cell'; + c.style.width = cellW + 'px'; + c.style.height = cellH + 'px'; c.dataset.x = x; c.dataset.y = y; c.onmousedown = e => { mouseDown = true; paint(x, y); }; c.onmouseenter = () => { document.getElementById('cursorPos').textContent = `(${x}, ${y})`; if (mouseDown) paint(x, y); }; @@ -381,6 +384,10 @@ function loadTilePalette() { const opt = document.getElementById('tileSheetSelect').selectedOptions[0]; if (!opt?.value) { sheet = null; document.getElementById('tilePalette').innerHTML = '
Select a sheet
'; return; } sheet = { id: +opt.value, cdn: opt.dataset.cdn, cols: +opt.dataset.cols, tw: +opt.dataset.tw, th: +opt.dataset.th, sw: +opt.dataset.sw, sh: +opt.dataset.sh }; + + // Rebuild grid with correct tile dimensions + buildGrid(); + const total = sheet.cols * Math.ceil(sheet.sh / sheet.th); let html = ''; for (let i = 0; i < total; i++) { @@ -390,7 +397,6 @@ function loadTilePalette() { onclick="selectPaletteItem(this)">`; } document.getElementById('tilePalette').innerHTML = html; - for (let y = 0; y < gh; y++) for (let x = 0; x < gw; x++) render(x, y); } function selectPaletteItem(el) { diff --git a/Services/Admin/Pages/DungeonBuilder/TileEdit.cshtml b/Services/Admin/Pages/DungeonBuilder/TileEdit.cshtml index a57c59b..68ffa36 100644 --- a/Services/Admin/Pages/DungeonBuilder/TileEdit.cshtml +++ b/Services/Admin/Pages/DungeonBuilder/TileEdit.cshtml @@ -16,8 +16,6 @@ border-radius: 4px; } .tile-cell { - width: 32px; - height: 32px; background: #0f0f1a; cursor: crosshair; position: relative; @@ -307,13 +305,18 @@ function loadExisting() { function buildTemplateGrid() { const grid = document.getElementById('templateGrid'); - grid.style.gridTemplateColumns = `repeat(${tw}, 32px)`; + // Use sheet tile dimensions if available, fallback to 32px + const cellW = sheet?.tw || 32; + const cellH = sheet?.th || 32; + grid.style.gridTemplateColumns = `repeat(${tw}, ${cellW}px)`; grid.innerHTML = ''; for (let y = 0; y < th; y++) { for (let x = 0; x < tw; x++) { const cell = document.createElement('div'); cell.className = 'tile-cell'; + cell.style.width = cellW + 'px'; + cell.style.height = cellH + 'px'; cell.dataset.x = x; cell.dataset.y = y; cell.onclick = () => paintCell(x, y); @@ -374,6 +377,9 @@ function loadSheet() { sh: +opt.dataset.sh }; + // Rebuild template grid with correct tile dimensions + buildTemplateGrid(); + const total = sheet.cols * Math.ceil(sheet.sh / sheet.th); let html = ''; for (let i = 0; i < total; i++) { @@ -385,13 +391,6 @@ function loadSheet() { background-size: ${sheet.sw}px ${sheet.sh}px;">`; } document.getElementById('palette').innerHTML = html; - - // Re-render template with new sheet - for (let y = 0; y < th; y++) { - for (let x = 0; x < tw; x++) { - renderCell(x, y); - } - } } function selectTile(frameIndex) {