Fixing Room Templates

This commit is contained in:
dingo
2026-01-10 09:22:14 -05:00
parent 8c756cc191
commit b987015e67
4 changed files with 44 additions and 9 deletions
@@ -361,8 +361,10 @@ function loadData() {
function buildGrid() {
const g = document.getElementById('editorGrid');
const cellW = sheet?.tw || 16;
const cellH = sheet?.th || 16;
// Scale factor for grid display (2x for better visibility)
const scale = 2;
const cellW = (sheet?.tw || 16) * scale;
const cellH = (sheet?.th || 16) * scale;
g.style.gridTemplateColumns = `repeat(${gw}, ${cellW}px)`;
g.innerHTML = '';
for (let y = 0; y < gh; y++) {
@@ -390,6 +392,9 @@ function render(x, y) {
if (!c) return;
const k = `${x},${y}`;
// Scale factor for display
const scale = 2;
// Check for floor or wall tile
const floor = floorData[k];
const wall = wallData[k];
@@ -397,8 +402,8 @@ function render(x, y) {
if (tile && sheet && tile.sheetId == sheet.id) {
const col = tile.frameIndex % sheet.cols, row = Math.floor(tile.frameIndex / sheet.cols);
c.style.background = `url('${cdnBase}/${sheet.cdn}') ${-col*sheet.tw}px ${-row*sheet.th}px no-repeat`;
c.style.backgroundSize = `${sheet.sw}px ${sheet.sh}px`;
c.style.background = `url('${cdnBase}/${sheet.cdn}') ${-col*sheet.tw*scale}px ${-row*sheet.th*scale}px no-repeat`;
c.style.backgroundSize = `${sheet.sw*scale}px ${sheet.sh*scale}px`;
} else if (tile) {
c.style.background = wall ? '#4a1a1a' : '#2d3748';
} else {
@@ -549,6 +554,11 @@ function setLayer(l) {
document.querySelectorAll('.mob-select-item').forEach(i => i.classList.remove('selected'));
document.getElementById('selectionInfo').textContent = 'Nothing';
document.getElementById('selectionDetails').textContent = '';
// Refresh templates when switching between floor/wall layers
if (l === 'floor' || l === 'wall') {
renderTemplates();
}
}
function loadTileTemplates() {
@@ -648,6 +658,11 @@ function renderTemplates(filterTags = []) {
return;
}
// Scale factor for palette display (2x for better visibility)
const scale = 2;
const displayW = sheet.tw * scale;
const displayH = sheet.th * scale;
let html = '';
filtered.forEach(t => {
// frameIndex is pre-extracted by the server
@@ -665,12 +680,12 @@ function renderTemplates(filterTags = []) {
data-name="${t.name}"
data-tags="${t.tags || ''}"
title="${t.name}${t.tags ? ' [' + t.tags + ']' : ''}"
style="width:${sheet.tw + 8}px; padding:4px;"
style="width:${displayW + 12}px; padding:6px;"
onclick="selectPaletteItem(this)">
<div style="width:${sheet.tw}px; height:${sheet.th}px; background:url('${cdnBase}/${sheet.cdn}') ${-col*sheet.tw}px ${-row*sheet.th}px no-repeat; background-size:${sheet.sw}px ${sheet.sh}px; position:relative;">
<div style="width:${displayW}px; height:${displayH}px; background:url('${cdnBase}/${sheet.cdn}') ${-col*sheet.tw*scale}px ${-row*sheet.th*scale}px no-repeat; background-size:${sheet.sw*scale}px ${sheet.sh*scale}px; position:relative;">
<div class="walkable-badge ${t.isWalkable ? 'floor' : 'wall'}"></div>
</div>
<div class="template-info mt-1" style="width:${sheet.tw}px;">${t.name}</div>
<div class="template-info mt-1" style="width:${displayW}px;">${t.name}</div>
</div>`;
});