图层修改

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-14 16:02:20 +08:00
parent ff1542c24f
commit ae75fce80b
5121 changed files with 17930 additions and 16467861 deletions

View File

@@ -196,9 +196,25 @@ function bindOnce(el, event, handler) {
function normalizeBorder(border) {
const out = {};
for (const [k, v] of Object.entries(border || {})) {
if (v === true || v === 1) out[k] = 'WallBlock';
else if (typeof v === 'string') out[k] = v;
else out[k] = 'WallBlock';
if (v === true || v === 1) {
out[k] = 'WallBlock';
continue;
}
if (typeof v === 'string') {
const s = v.trim();
// 地砖名不得进入 Border
out[k] = (!s || s === 'Baseblock' || s === 'JumpBlock') ? 'WallBlock' : s;
continue;
}
out[k] = 'WallBlock';
}
return out;
}
function normalizeGround(ground) {
const out = {};
for (const [k, v] of Object.entries(ground || {})) {
out[k] = v === 'JumpBlock' ? 'JumpBlock' : 'Baseblock';
}
return out;
}
@@ -504,7 +520,7 @@ exports.ready = function () {
if (this.$.levelId) this.$.levelId.value = String(id);
state.config = levelIdUtil.syncLevelEntry(JSON.parse(JSON.stringify(cfg)), id);
state.selectedSpawn = null;
state.config.ground = state.config.ground || {};
state.config.ground = normalizeGround(state.config.ground || {});
state.config.border = normalizeBorder(state.config.border);
state.config.spawns = Array.isArray(cfg.spawns) ? JSON.parse(JSON.stringify(cfg.spawns)) : [];
spawnTools.ensureSpawns(state);
@@ -1115,20 +1131,27 @@ exports.ready = function () {
}
if (changed) drawGrid.call(this, state);
if (!state.painting && this.$.status && c) {
if (state.editMode === 'spawns') {
const hits = spawnTools.spawnsAt(state, c.x, c.y);
const hitInfo = hits.length
? ` [${hits.map((h) => spawnTools.SPAWN_KIND_LABELS[h.kind] || h.kind).join('+')}]`
: '';
const hint = spawnTools.validationHint(state);
this.$.status.textContent = `[实体] 格子 (${c.x},${c.y})${hitInfo} · ${spawnTools.spawnSummary(state)}${hint ? ` · ${hint}` : ''}`;
} else {
const layer = state.editLayer === 'ground' ? 'Ground' : 'Border';
const v = isInGrid(c) ? tools.getCell(state, c.key) : undefined;
const info = v !== undefined ? ` 当前=${v === true ? '墙' : v}` : ' 空';
const bounds = isInGrid(c) ? '' : ' [超出 60×60]';
this.$.status.textContent = `[${layer}] 格子 (${c.x},${c.y})${info}${bounds} · 缩放 ${Math.round(state.zoom * 100)}% — ${tools.TOOL_LABELS[state.tool]}`;
}
const modeTag = state.editMode === 'spawns'
? '实体'
: (state.editLayer === 'ground' ? 'Ground' : 'Border');
const bounds = isInGrid(c) ? '' : ' [超出 60×60]';
const contents = isInGrid(c)
? tools.describeCellContents(
state,
c.x,
c.y,
spawnTools.spawnsAt(state, c.x, c.y),
spawnTools.SPAWN_KIND_LABELS,
)
: '空';
const hint = state.editMode === 'spawns'
? spawnTools.validationHint(state)
: tools.TOOL_LABELS[state.tool];
const summary = state.editMode === 'spawns' ? ` · ${spawnTools.spawnSummary(state)}` : '';
this.$.status.textContent =
`[${modeTag}] 格子 (${c.x},${c.y}) ${contents}${bounds}`
+ ` · 缩放 ${Math.round(state.zoom * 100)}%`
+ `${summary}${hint ? `${hint}` : ''}`;
}
if (state.painting && state.editMode === 'map' && (state.tool === 'paint' || state.tool === 'eraser') && c && isInGrid(c)) {
if (applyToolAt(c)) drawGrid.call(this, state);