A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
refactor(editor): locale-table editor speaks the UE Details grid, not card stacks
yhha2424b93a02b
diff --git a/desktop/src/panels/Details.tsx b/desktop/src/panels/Details.tsxindex 1bb28f214..3a1d7a1b9 100644--- a/desktop/src/panels/Details.tsx+++ b/desktop/src/panels/Details.tsx@@ -1,6 +1,7 @@// SPDX-License-Identifier: Apache-2.0// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Teamimport { useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';+import type { KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react';import {Box,Camera,@@ -1964,9 +1965,9 @@ function LocaleTableAssetInspector({ path }: { path: string }) {if (loadError) {return (- <div className="insp input-map">- <div className="empty-line">{t('det.localeParseError')}</div>- <div className="lt-ref" title={loadError}>{loadError}</div>+ <div className="insp">+ <div className="comp-notice" style={{ margin: 8 }}>{t('det.localeParseError')}</div>+ <div className="lt-error" title={loadError}>{loadError}</div></div>);}@@ -1981,6 +1982,9 @@ function LocaleTableAssetInspector({ path }: { path: string }) {for (let i = 2; table.entries[n] !== undefined; i++) n = `new.key${i}`;return n;};+ const blurOnEnter = (e: ReactKeyboardEvent<HTMLInputElement>) => {+ if (e.key === 'Enter') (e.target as HTMLInputElement).blur();+ };// Reference language for a key: 'en' when this table isn't en, else the// first other locale that carries it.const refFor = (key: string): { tag: string; text: string } | null => {@@ -1994,110 +1998,180 @@ function LocaleTableAssetInspector({ path }: { path: string }) {const missing = siblings ? [...siblings.keys()].filter((k) => table.entries[k] === undefined).sort() : [];const entries = Object.entries(table.entries);+ const textField = (fieldKey: string, value: string, write: (v: string) => void) => (+ <span className="field">+ <input+ key={fieldKey}+ defaultValue={value}+ spellCheck={false}+ onBlur={(e) => write(e.target.value)}+ onKeyDown={blurOnEnter}+ />+ </span>+ );+return (- <div className="insp input-map">- <div className="im-head">- <span>{t('det.localeStrings')}</span>- <button type="button" className="im-add" onClick={() => commit(ldoc.addEntry(table, uniqueKey()))}>{t('det.addKey')}</button>- </div>- <div className="im-action">- <div className="im-action-head">- <span className="lt-form">{t('det.localeTag')}</span>- <input- className="im-name"- key={table.locale}- defaultValue={table.locale}- spellCheck={false}- onBlur={(e) => {- if (e.target.value.trim() && e.target.value !== table.locale) commit(ldoc.setLocaleTag(table, e.target.value));- }}- />- </div>- </div>- {entries.length === 0 && <div className="empty-line">{t('det.noStrings')}</div>}- {entries.map(([key, entry]) => {- const ref = refFor(key);- const plural = typeof entry !== 'string';- return (- <div className="im-action" key={key}>- <div className="im-action-head">+ <div className="insp">+ <div className="insp-body">+ <LocaleSection+ title={t('det.localeStrings')}+ badge={String(entries.length)}+ action={+ <button+ type="button"+ className="comp-menu lt-headbtn"+ title={t('det.addKey')}+ onClick={(e) => {+ e.stopPropagation();+ commit(ldoc.addEntry(table, uniqueKey()));+ }}+ >+ <Plus size={13} strokeWidth={2} />+ </button>+ }+ >+ <div className="prop">+ <span className="prop-label">{t('det.localeTag')}</span>+ <span className="prop-value">{textField(table.locale, table.locale, (v) => {+ if (v.trim() && v !== table.locale) commit(ldoc.setLocaleTag(table, v));+ })}</span>+ <span />+ </div>+ {entries.length === 0 && <div className="empty-line">{t('det.noStrings')}</div>}+ {entries.map(([key, entry]) => {+ const ref = refFor(key);+ const plural = typeof entry !== 'string';+ const keyInput = (<input- className="im-name"+ className="lt-key"key={key}defaultValue={key}spellCheck={false}+ title={key}onBlur={(e) => {if (e.target.value.trim() && e.target.value !== key) commit(ldoc.renameEntry(table, key, e.target.value));}}+ onKeyDown={blurOnEnter}/>+ );+ const pluralToggle = (<buttontype="button"- className="im-x"+ className="lt-act"title={plural ? t('det.toSingle') : t('det.toPlural')}onClick={() => commit(plural ? ldoc.toSingle(table, key) : ldoc.toPlural(table, key))}>{plural ? '1' : 'N'}</button>- <button type="button" className="im-x" title={t('det.removeEntry')} onClick={() => commit(ldoc.removeEntry(table, key))}>×</button>- </div>- {!plural ? (- <input- className="im-in lt-text"- key={`${key}:s`}- defaultValue={entry}- spellCheck={false}- onBlur={(e) => commit(ldoc.setEntryText(table, key, e.target.value))}- />- ) : (- <>- {ldoc.PLURAL_CATEGORIES.filter((c) => entry[c] !== undefined).map((c) => (- <div className="im-binding" key={c}>- <span className="lt-form">{c}</span>- <input- className="im-in lt-text"- key={`${key}:${c}`}- defaultValue={entry[c]}- spellCheck={false}- onBlur={(e) => commit(ldoc.setPluralForm(table, key, c, e.target.value))}- />- {c !== 'other' && (- <button type="button" className="im-x" title={t('det.removeForm')} onClick={() => commit(ldoc.removePluralForm(table, key, c))}>×</button>- )}+ );+ const remove = (+ <button type="button" className="lt-x" title={t('det.removeEntry')} onClick={() => commit(ldoc.removeEntry(table, key))}>+ <X size={12} strokeWidth={2} />+ </button>+ );+ return (+ <div key={key}>+ {!plural ? (+ <div className="prop">+ {keyInput}+ <span className="prop-value">+ {textField(`${key}:s`, entry, (v) => commit(ldoc.setEntryText(table, key, v)))}+ {pluralToggle}+ </span>+ {remove}+ </div>+ ) : (+ <>+ <div className="prop">+ {keyInput}+ <span className="prop-value">+ {ldoc.absentPluralForms(entry).length > 0 && (+ <span className="field dropdown">+ <Select+ variant="field"+ ariaLabel={t('det.pluralFormAria')}+ value=""+ options={[+ { value: '', label: t('det.addForm') },+ ...ldoc.absentPluralForms(entry).map((c) => ({ value: c, label: c })),+ ]}+ onChange={(v) => v && commit(ldoc.setPluralForm(table, key, v as PluralCategory, ''))}+ />+ </span>+ )}+ {pluralToggle}+ </span>+ {remove}+ </div>+ {ldoc.PLURAL_CATEGORIES.filter((c) => entry[c] !== undefined).map((c) => (+ <div className="prop" key={c}>+ <span className="prop-label lt-formlabel">{c}</span>+ <span className="prop-value">+ {textField(`${key}:${c}`, entry[c] ?? '', (v) => commit(ldoc.setPluralForm(table, key, c, v)))}+ </span>+ {c !== 'other' ? (+ <button type="button" className="lt-x" title={t('det.removeForm')} onClick={() => commit(ldoc.removePluralForm(table, key, c))}>+ <X size={12} strokeWidth={2} />+ </button>+ ) : (+ <span />+ )}+ </div>+ ))}+ </>+ )}+ {ref && (+ <div className="lt-refrow">+ <span className="lt-ref" title={`${ref.tag} · ${ref.text}`}>{ref.tag} · {ref.text}</span></div>- ))}- {ldoc.absentPluralForms(entry).length > 0 && (- <Select- className="im-in kind"- ariaLabel={t('det.pluralFormAria')}- value=""- options={[- { value: '', label: t('det.addForm') },- ...ldoc.absentPluralForms(entry).map((c) => ({ value: c, label: c })),- ]}- onChange={(v) => v && commit(ldoc.setPluralForm(table, key, v as PluralCategory, ''))}- />)}- </>- )}- {ref && <div className="lt-ref" title={`${ref.tag} · ${ref.text}`}>{ref.tag} · {ref.text}</div>}- </div>- );- })}- {missing.length > 0 && (- <>- <div className="im-head"><span>{t('det.missingKeys')}</span></div>- {missing.map((k) => {- const ref = refFor(k);- return (- <div className="im-binding" key={k}>- <button type="button" className="im-addb" title={t('det.addMissingKey')} onClick={() => commit(ldoc.addEntry(table, k))}>+</button>- <span className="lt-miss" title={k}>{k}</span>- {ref && <span className="lt-ref" title={ref.text}>{ref.tag} · {ref.text}</span>}</div>);})}- </>- )}+ </LocaleSection>+ {missing.length > 0 && (+ <LocaleSection title={t('det.missingKeys')} badge={String(missing.length)}>+ {missing.map((k) => {+ const ref = refFor(k);+ return (+ <div className="prop" key={k}>+ <span className="lt-miss-key" title={k}>{k}</span>+ <span className="prop-value">+ {ref && <span className="lt-miss-ref" title={ref.text}>{ref.tag} · {ref.text}</span>}+ </span>+ <button type="button" className="lt-addk" title={t('det.addMissingKey')} onClick={() => commit(ldoc.addEntry(table, k))}>+ <Plus size={12} strokeWidth={2} />+ </button>+ </div>+ );+ })}+ </LocaleSection>+ )}+ </div>+ </div>+ );+}++// A collapsible Details section speaking the component-header language — the+// locale editor's structural chrome (title + count badge + an always-visible+// header action), sharing .comp/.prop styling with the entity inspector.+function LocaleSection({ title, badge, action, children }: {+ title: string; badge: string; action?: ReactNode; children: ReactNode;+}) {+ const [open, setOpen] = useState(true);+ return (+ <div className={`comp${open ? ' open' : ''}`}>+ <div className="comp-head" onClick={() => setOpen((o) => !o)}>+ <span className="comp-arrow"><ChevronRight size={13} strokeWidth={2} /></span>+ <span className="comp-name">{title}</span>+ <span className="comp-badge">{badge}</span>+ {action}+ </div>+ <div className="comp-body">+ <div className="cinner">+ <div className="comp-fields">{children}</div>+ </div>+ </div></div>);}diff --git a/desktop/src/theme/inspector.css b/desktop/src/theme/inspector.cssindex 3d9eba9e1..0c84b8195 100644--- a/desktop/src/theme/inspector.css+++ b/desktop/src/theme/inspector.css@@ -271,10 +271,27 @@.im-x:hover { color: var(--error); background: var(--srf-4); }.im-addb { align-self: flex-start; }-/* Locale-table editor (.eslocale) — rides the .im-* frame; these add the- translator-specific bits: the plural-form tag, the dimmed sibling-locale- reference line, and the missing-key backfill rows. */-.lt-form { flex-shrink: 0; width: 42px; font-family: var(--mono); font-size: var(--fs-2xs); color: var(--text-mute); text-align: right; }-.lt-text { flex: 1; min-width: 0; }-.lt-ref { font-size: var(--fs-2xs); color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 2px; }-.lt-miss { flex: 1; min-width: 0; font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+/* Locale-table editor (.eslocale) — speaks the component-inspector language:+ .comp sections + the .prop 38%/1fr/18px grid. Keys are ghost inputs in the+ label column (read as labels until hovered/focused), translations are .field+ inputs in the value column, row actions reveal on hover, and each key carries+ a dimmed sibling-locale reference line under its value. */+.lt-headbtn { opacity: 1 !important; color: var(--acc-hi); }+.lt-headbtn:hover { background: var(--star-dim); }+.lt-key { min-width: 0; background: transparent; border: 1px solid transparent; border-radius: var(--r-xs); padding: 2px 4px; font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-dim); text-overflow: ellipsis; outline: none; transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast); }+.lt-key:hover { border-color: var(--border); color: var(--text); }+.lt-key:focus { background: var(--inset); border-color: var(--acc); color: var(--text); }+.lt-act { width: 16px; height: 16px; display: grid; place-items: center; color: var(--text-mute); border-radius: var(--r-xs); opacity: 0; flex-shrink: 0; font-size: var(--fs-2xs); font-family: var(--mono); font-weight: 600; transition: opacity var(--t-fast), color var(--t-fast), background var(--t-fast); }+.prop:hover .lt-act { opacity: 1; }+.lt-act:hover { color: var(--text); background: var(--srf-4); }+.lt-x { width: 16px; height: 16px; display: grid; place-items: center; color: var(--text-mute); border-radius: var(--r-xs); opacity: 0; flex-shrink: 0; justify-self: center; transition: opacity var(--t-fast), color var(--t-fast), background var(--t-fast); }+.prop:hover .lt-x { opacity: 1; }+.lt-x:hover { color: var(--error); background: var(--srf-4); }+.lt-addk { width: 16px; height: 16px; display: grid; place-items: center; color: var(--acc-hi); border-radius: var(--r-xs); opacity: .8; flex-shrink: 0; justify-self: center; transition: opacity var(--t-fast), background var(--t-fast); }+.lt-addk:hover { opacity: 1; background: var(--star-dim); }+.lt-refrow { display: grid; grid-template-columns: 38% 1fr 18px; gap: 4px; padding: 0 0 4px; }+.lt-refrow .lt-ref { grid-column: 2; font-size: var(--fs-2xs); color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px 0 8px; }+.lt-formlabel { font-family: var(--mono); font-size: var(--fs-2xs); color: var(--text-mute); text-align: right; padding-right: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+.lt-miss-key { font-family: var(--mono); font-size: var(--fs-xs); color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 2px; }+.lt-miss-ref { font-size: var(--fs-2xs); color: var(--text-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }+.lt-error { margin: 8px; padding: 6px 9px; font-size: var(--fs-2xs); line-height: 1.5; font-family: var(--mono); color: var(--text-dim); background: var(--inset); border: 1px solid var(--border); border-radius: var(--r-sm); word-break: break-all; }