Rebuild level editor sidebar with a fixed virtual-space layout

Replace the fraction-of-window positioning (which overlapped and didn't
scale) with a small layout system: the sidebar is authored in one fixed
virtual coordinate space and rendered at native panel resolution, so
element sizes stay constant relative to the panel at any window size and
fonts scale with it.

- level_editor/layout.lua: sections, scrolling list (with clip + hit-test
  by point), scrollbar. Clip rects are scaled to real canvas pixels.
- Room view split into non-overlapping divs: search/back header, a
  scrollable asset list (replaces the old row-paging + forward buttons),
  a status strip, and a compact bottom control cluster.
- Mouse wheel scrolls the list; clicks map from window coords into the
  virtual space via the same transform used to render.
- Sidebar canvas is panel-sized and blitted 1:1 (nearest filter, never
  averaged) to stay crisp; editorDraw runs under a scale transform.
- Center text-only fields (level name) in their rect.

Also carried in main.lua (share the file, can't split cleanly here):
narrator require path fixed via love.filesystem.setRequirePath; sfxr
static uses waveform=NOISE again after the field rename; low-pass +
lower volume on the static loop.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Your Name 2026-08-11 12:24:54 -04:00
parent 03532d29e4
commit 5b7ea9ec20
4 changed files with 336 additions and 144 deletions

View file

@ -26,7 +26,7 @@ function GUI:initialize(t)
if t.sprite then
print(self.name)
self.scale = t.scale or drawScale * 2 / 3
self.scale = t.scale or editorScale * 2 / 3
self.w = t.sprite:getWidth() * self.scale
self.h = t.sprite:getHeight() * self.scale
self.sprite = t.sprite
@ -41,22 +41,22 @@ function GUI:initialize(t)
h = sprite:getHeight()
end
if w > h then
self.scale = (drawScale * (2 / 3)) / (w / 16)
self.scale = (editorScale * (2 / 3)) / (w / 16)
elseif w < h then
self.scale = (drawScale * (2 / 3)) / (h / 16)
self.scale = (editorScale * (2 / 3)) / (h / 16)
else
self.scale = (drawScale * (2 / 3)) / (w / 16)
self.scale = (editorScale * (2 / 3)) / (w / 16)
end
self.w = sideBarBox.w - (self.x * 2)
self.w = sb.w - (self.x * 2)
self.h = h * self.scale
else
-- this is text
self.x, self.y = t.x, t.y
self.w, self.h = sideBarBox.w - self.x * 2, 50
self.w, self.h = sb.w - self.x * 2, 50
end
if self.name == "folder" then
self.w = sideBarBox.w - self.x * 2
self.w = sb.w - self.x * 2
end
end
@ -106,9 +106,14 @@ function GUI:draw()
if self.text then
love.graphics.setColor(gColor.white:set())
if not self.sprites and not self.sprite then
-- text-only element (e.g. the level-name field): center in its rect
love.graphics.rectangle("line", box.x, box.y, box.w, box.h)
local th = love.graphics.getFont():getHeight()
love.graphics.printf(self.text, box.x, box.y + (box.h - th) / 2, box.w, "center")
else
-- label sitting to the right of an icon
love.graphics.print(self.text, box.x + 50, box.y + 15)
end
love.graphics.print(self.text, box.x + 50, box.y + 15)
end
end