mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-12 08:21:02 +02:00
Add nickname editing to the save editor's mon inspector
The mon inspector now has a NICKNAME section: a text field with Set / Clear, commit-on-Enter and discard-on-Escape. Input is gated at the field instead of refused at commit. Only glyphs the game font can actually draw AND that round-trip through a .sav are accepted, capped at the naming screen's 10 glyphs, so a bad keystroke or paste never appears and Set always succeeds. Chars like "@" (the Gen1 string terminator), "#" and the dakuten kana have codec entries but no font tile so they are blocked rather than silently mangled.
This commit is contained in:
@@ -426,7 +426,12 @@ end
|
||||
-- state because Kit had no input widget; this replaces that hack, and App
|
||||
-- routes love.textinput / love.keypressed in through Kit.textinput /
|
||||
-- Kit.keypressed. Returns the (possibly edited) value; the caller stores it.
|
||||
function Kit.textfield(id, x, y, w, h, value, placeholder)
|
||||
--
|
||||
-- `opts.sanitize(value)` (optional) is a post-filter run on the merged text
|
||||
-- right after this frame's edits and BEFORE it draws, so a keystroke or paste
|
||||
-- the filter rejects never even flashes on screen. It gets the whole value
|
||||
-- because a paste arrives as one textinput chunk alongside existing text.
|
||||
function Kit.textfield(id, x, y, w, h, value, placeholder, opts)
|
||||
audit("control", x, y, w, h, id)
|
||||
value = tostring(value or "")
|
||||
if Kit.press(x, y, w, h) then Kit.focus = id end
|
||||
@@ -444,6 +449,9 @@ function Kit.textfield(id, x, y, w, h, value, placeholder)
|
||||
value = value .. e
|
||||
end
|
||||
end
|
||||
if opts and opts.sanitize then
|
||||
value = opts.sanitize(value)
|
||||
end
|
||||
end
|
||||
if G then
|
||||
local r = 8 * Kit.scale
|
||||
|
||||
Reference in New Issue
Block a user