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
feat(editor): calmer play-mode chrome + non-intrusive selection
yhh283ab453ab74
diff --git a/desktop/src/App.tsx b/desktop/src/App.tsxindex 1419dde77..e4a6e6c09 100644--- a/desktop/src/App.tsx+++ b/desktop/src/App.tsx@@ -1,6 +1,6 @@// SPDX-License-Identifier: Apache-2.0// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team-import { useEffect, useSyncExternalStore } from 'react';+import { useEffect, useRef, useSyncExternalStore } from 'react';import { MenuBar } from '@/layout/MenuBar';import { Toolbar } from '@/layout/Toolbar';import { StatusBar } from '@/layout/StatusBar';@@ -109,21 +109,17 @@ export function App() {});}, []);- // Reveal a mode's companion panels when the selection enters that mode (only on the- // transition INTO one, so moving within a mode doesn't keep yanking focus). This- // generalizes the old tilemap-painter auto-open: "select a tilemap → here's how you- // paint it" is now one instance of "enter a mode → here are its panels". A selection- // that implies a new mode also drops a stale explicit pin.+ // A plain selection switches the editing mode (its tools + viewport overlays are+ // derived live from activeMode()) but must NOT restructure the workspace — clicking+ // to inspect a node should never fling docked panels open over what you were doing.+ // Opening a mode's companion panels (the Tilemap painter, UI widgets…) is an+ // EXPLICIT gesture now: click the mode chip in the viewport, the activity-bar mode+ // button, or run the mode command. Entering a new mode still drops a stale pin.useEffect(() => {let prevMode: EditorModeId | null = null;return useSelection.subscribe(() => {const mode = suggestedMode();- if (mode.id !== prevMode) {- useEditorMode.getState().clearPin();- for (const p of mode.panels ?? []) {- dockApi.openSidePanel(p.id, p.component, p.title, p.side ?? 'left', p.width ?? 300);- }- }+ if (mode.id !== prevMode) useEditorMode.getState().clearPin();prevMode = mode.id;});}, []);@@ -192,6 +188,9 @@ export function App() {// EditorControlSurface.setRunMode + step for deterministic capture.)const isPlaying = useEditorStore((s) => s.isPlaying);const isPaused = useEditorStore((s) => s.isPaused);+ // Tracks a maximize we triggered from "Maximize On Play" so Stop only restores the+ // layout WE collapsed — a manual F11 focus the user chose is left as they left it.+ const autoMaximized = useRef(false);useEffect(() => {if (isPlaying) {// Prefab Mode holds a prefab tree, not a playable scene (no camera → a black@@ -215,10 +214,22 @@ export function App() {if (useEditorStore.getState().playTarget === 'window') dockApi.openGame();// Client players each get their own Game tab beside player 1.if (players > 1) dockApi.openGameClients(PlayRealms.clients.map((c) => c.id));+ // Maximize On Play: give the game the whole workspace (the Game tab lives in+ // the viewport group, so maximizing it covers both targets). Deferred a frame+ // so the just-added Game panel is settled. Native maximize only hides the+ // siblings — the viewport's live canvas is never remounted.+ if (useEditorStore.getState().maximizeOnPlay) {+ autoMaximized.current = true;+ requestAnimationFrame(() => dockApi.maximizePanel('viewport'));+ }} else {PlayRealms.stopSession();PlayInspect.stop();useEditorStore.getState().setInspectWorld('editor');+ if (autoMaximized.current) {+ dockApi.exitMaximized();+ autoMaximized.current = false;+ }dockApi.closeGame();dockApi.closeGameClients();// Not on mount/launcher — there is no project to stage yet.diff --git a/desktop/src/commands/editorCommands.ts b/desktop/src/commands/editorCommands.tsindex 1e7783e83..5ec91e432 100644--- a/desktop/src/commands/editorCommands.ts+++ b/desktop/src/commands/editorCommands.ts@@ -324,6 +324,18 @@ commands.register({if (ids.length > 0) ViewportController.frameSelection(ids);},});+commands.register({+ id: 'view.focusViewport',+ label: t('cmd.view.focusViewport'),+ category: t('cat.view'),+ // Maximize the viewport/game group to fill the workspace (hiding the surrounding+ // docks), or restore — a focus toggle usable any time, and the manual counterpart+ // to "Maximize On Play". Native dockview maximize: the viewport canvas is only+ // hidden-behind, never remounted, so the engine keeps running.+ keybinding: 'f11',+ isChecked: () => dockApi.isMaximized(),+ run: () => dockApi.toggleMaximizePanel('viewport'),+});commands.register({id: 'view.toggleGrid',label: t('cmd.view.toggleGrid'),@@ -434,6 +446,10 @@ commands.register({label: t('cmd.play.toggle'),category: t('cat.play'),keybinding: 'f5',+ // A prefab has no scene to run — disable Play (F5 / palette / menu) in Prefab Mode+ // so it can't flip on for a frame and immediately self-revert. Stopping is always+ // allowed (isPlaying), so a stuck session can never be trapped.+ isEnabled: () => editor().isPlaying || !ProjectStore.getSnapshot()?.prefabEdit,run: () => editor().togglePlay(),});commands.register({diff --git a/desktop/src/i18n/messages/commands.ts b/desktop/src/i18n/messages/commands.tsindex 2170c103e..ee6b115bf 100644--- a/desktop/src/i18n/messages/commands.ts+++ b/desktop/src/i18n/messages/commands.ts@@ -46,6 +46,7 @@ export const commandMessages = defineMessages({// — View —'cmd.view.frameSelected': { en: 'Frame Selected', zh: '聚焦所选' },+ 'cmd.view.focusViewport': { en: 'Maximize Viewport', zh: '最大化视口' },'cmd.view.toggleGrid': { en: 'Show Grid', zh: '显示网格' },'cmd.view.toggleGizmos': { en: 'Show Gizmos', zh: '显示 Gizmo' },'cmd.view.togglePreviewFx': { en: 'Preview FX', zh: '预览特效' },diff --git a/desktop/src/i18n/messages/layout.ts b/desktop/src/i18n/messages/layout.tsindex 67a580da1..4c8dd64b7 100644--- a/desktop/src/i18n/messages/layout.ts+++ b/desktop/src/i18n/messages/layout.ts@@ -43,6 +43,8 @@ export const layoutMessages = defineMessages({'layout.tool.scale': { en: 'Scale', zh: '缩放' },'layout.restart': { en: 'Restart', zh: '重新运行' },'layout.pause': { en: 'Pause', zh: '暂停' },+ 'layout.resume': { en: 'Resume', zh: '继续' },+ 'layout.maximizeOnPlay': { en: 'Maximize Viewport on Play', zh: '运行时最大化视口' },'layout.playInViewportTooltip': { en: 'Play in Viewport', zh: '在视口中运行' },'layout.playInWindowTooltip': { en: 'Play in New Window', zh: '在新窗口中运行' },'layout.playInViewport': { en: 'Play In Viewport', zh: '在视口中运行' },@@ -55,6 +57,7 @@ export const layoutMessages = defineMessages({// — Status bar —'layout.contentDrawer': { en: 'Content Drawer', zh: '内容抽屉' },'layout.status.running': { en: 'Running', zh: '运行中' },+ 'layout.status.paused': { en: 'Paused', zh: '已暂停' },'layout.status.editMode': { en: 'Edit Mode', zh: '编辑模式' },'layout.status.selected': { en: '{count} selected', zh: '已选中 {count} 个' },'layout.status.noSelection': { en: 'No selection', zh: '未选中' },diff --git a/desktop/src/i18n/messages/viewport.ts b/desktop/src/i18n/messages/viewport.tsindex 41d2c321d..c5019204e 100644--- a/desktop/src/i18n/messages/viewport.ts+++ b/desktop/src/i18n/messages/viewport.ts@@ -120,8 +120,8 @@ export const viewportMessages = defineMessages({// — Play chrome (Play-in-viewport + Game panel) —'vp.playFailed': { en: 'Play failed: {error}', zh: '运行失败:{error}' },'vp.startingGame': { en: 'Starting game…', zh: '正在启动游戏…' },- 'vp.playFlag': { en: '● PLAY', zh: '● 运行中' },- 'vp.pausedFlag': { en: '● PAUSED', zh: '● 已暂停' },+ 'vp.pausedFlag': { en: '⏸ PAUSED', zh: '⏸ 已暂停' },+ 'vp.openModePanels': { en: 'Open {mode} panels', zh: '打开{mode}面板' },'vp.pressPlay': { en: 'Press Play to run the game.', zh: '点击“运行”启动游戏。' },'vp.starting': { en: 'Starting…', zh: '正在启动…' },'vp.noMpSession': { en: 'No multiplayer session.', zh: '没有多人会话。' },diff --git a/desktop/src/layout/DockLayout.tsx b/desktop/src/layout/DockLayout.tsxindex b9ec85587..44ceb7a46 100644--- a/desktop/src/layout/DockLayout.tsx+++ b/desktop/src/layout/DockLayout.tsx@@ -335,8 +335,15 @@ export function DockLayout() {ensureBottomTabs(api);api.getPanel('content')?.api.setActive();+ // Never restore into a maximized state — "Maximize On Play" / F11 focus is a+ // transient view, so a reload always lands on the real editing layout.+ if (api.hasMaximizedGroup()) api.exitMaximizedGroup();+// Persist the dock arrangement so it survives reloads — a real editor habit.+ // Skip while maximized (play/focus): that view is transient and must not+ // overwrite the user's real dock arrangement.api.onDidLayoutChange(() => {+ if (api.hasMaximizedGroup()) return;localStorage.setItem(LAYOUT_KEY, JSON.stringify(api.toJSON()));});};diff --git a/desktop/src/layout/StatusBar.tsx b/desktop/src/layout/StatusBar.tsxindex 89135c18c..5adba1e9d 100644--- a/desktop/src/layout/StatusBar.tsx+++ b/desktop/src/layout/StatusBar.tsx@@ -61,6 +61,7 @@ function CursorReadout() {// world position) reads in the mono face. Anchors the Content Drawer.export function StatusBar() {const isPlaying = useEditorStore((s) => s.isPlaying);+ const isPaused = useEditorStore((s) => s.isPaused);const contentDrawer = useEditorStore((s) => s.contentDrawer);const toggleContentDrawer = useEditorStore((s) => s.toggleContentDrawer);const selectedIds = useSelection((s) => s.selectedIds);@@ -78,8 +79,8 @@ export function StatusBar() {{t('layout.contentDrawer')}</button><span className="sitem">- <span className={`sdot${isPlaying ? ' live' : ''}`} />- {isPlaying ? t('layout.status.running') : t('layout.status.editMode')}+ <span className={`sdot${isPlaying ? (isPaused ? ' paused' : ' live') : ''}`} />+ {isPlaying ? (isPaused ? t('layout.status.paused') : t('layout.status.running')) : t('layout.status.editMode')}</span><Perf id="statusbar.mods"><SubsystemIndicator /></Perf><span className="sitem">diff --git a/desktop/src/layout/Toolbar.tsx b/desktop/src/layout/Toolbar.tsxindex 603f950b7..2ab9fd23a 100644--- a/desktop/src/layout/Toolbar.tsx+++ b/desktop/src/layout/Toolbar.tsx@@ -8,6 +8,7 @@ import {Play,Pause,Square as Stop,+ RotateCcw,Hammer,Monitor,AppWindow,@@ -61,8 +62,10 @@ export function Toolbar() {const setPlayTarget = useEditorStore((s) => s.setPlayTarget);const playPlayers = useEditorStore((s) => s.playPlayers);const setPlayPlayers = useEditorStore((s) => s.setPlayPlayers);+ const maximizeOnPlay = useEditorStore((s) => s.maximizeOnPlay);+ const setMaximizeOnPlay = useEditorStore((s) => s.setMaximizeOnPlay);const [modeMenu, setModeMenu] = useState<{ x: number; y: number } | null>(null);- const { isPlaying, isPaused, togglePause, stop } = useEditorStore();+ const { isPlaying, isPaused, togglePause } = useEditorStore();// Play is unavailable in Prefab Mode — a prefab has no scene to run.const inPrefabMode = useSyncExternalStore(@@ -104,7 +107,9 @@ export function Toolbar() {<span className="tspacer" />- {/* Play controls sit dead-center — the focal action. */}+ {/* Play controls sit dead-center — the focal action. The primary button is a+ Play↔Stop toggle (the muscle-memory action), so hitting it while playing+ stops — never a surprise cold Restart. Restart + Pause are side buttons. */}<div className={`play-wrap${isPlaying ? ' playing' : ''}${isPaused ? ' paused' : ''}`}><buttontype="button"@@ -114,19 +119,31 @@ export function Toolbar() {inPrefabMode? t('layout.toast.noPlayInPrefab'): isPlaying- ? `${t('layout.restart')}${hint('play.restart')}`+ ? `${t('cmd.play.stop')}${hint('play.stop')}`: `${t('cmd.play.toggle')}${hint('play.toggle')}`}- onClick={() => commands.run(isPlaying ? 'play.restart' : 'play.toggle')}+ onClick={() => commands.run(isPlaying ? 'play.stop' : 'play.toggle')}>- <Play size={15} strokeWidth={1.9} fill="currentColor" />- {isPlaying ? t('layout.restart') : t('cmd.play.toggle')}+ {isPlaying ? <Stop size={13} strokeWidth={1.9} fill="currentColor" /> : <Play size={15} strokeWidth={1.9} fill="currentColor" />}+ {isPlaying ? t('cmd.play.stop') : t('cmd.play.toggle')}</button>- <button type="button" className="play-side" title={t('layout.pause')} disabled={!isPlaying} onClick={togglePause}>- <Pause size={14} strokeWidth={1.9} fill="currentColor" />+ <button+ type="button"+ className="play-side"+ title={isPaused ? `${t('layout.resume')}${hint('play.pause')}` : `${t('layout.pause')}${hint('play.pause')}`}+ disabled={!isPlaying}+ onClick={togglePause}+ >+ {isPaused ? <Play size={13} strokeWidth={1.9} fill="currentColor" /> : <Pause size={14} strokeWidth={1.9} fill="currentColor" />}</button>- <button type="button" className="play-side" title={t('cmd.play.stop')} disabled={!isPlaying} onClick={stop}>- <Stop size={12} strokeWidth={1.9} fill="currentColor" />+ <button+ type="button"+ className="play-side"+ title={`${t('layout.restart')}${hint('play.restart')}`}+ disabled={!isPlaying}+ onClick={() => commands.run('play.restart')}+ >+ <RotateCcw size={13} strokeWidth={2} /></button><buttontype="button"@@ -151,6 +168,10 @@ export function Toolbar() {{ label: t('layout.playInViewport'), checked: playTarget === 'viewport', onClick: () => setPlayTarget('viewport') },{ label: t('layout.playInWindow'), checked: playTarget === 'window', onClick: () => setPlayTarget('window') },{ sep: true },+ // Unity-style "Maximize On Play": hand the whole workspace to the game+ // while it runs, restoring the docks on Stop.+ { label: t('layout.maximizeOnPlay'), checked: maximizeOnPlay, onClick: () => setMaximizeOnPlay(!maximizeOnPlay) },+ { sep: true },// Multiplayer preview: 1 = plain play; N>1 boots a listen-server realm// (player 1) + N-1 client realms wired by in-editor replication.{ label: t('layout.singlePlayer'), checked: playPlayers <= 1, onClick: () => setPlayPlayers(1) },diff --git a/desktop/src/layout/dockApi.ts b/desktop/src/layout/dockApi.tsindex 61e189c13..1af8b69c3 100644--- a/desktop/src/layout/dockApi.ts+++ b/desktop/src/layout/dockApi.ts@@ -177,6 +177,31 @@ export const dockApi = {p.api.close();}},++ /** True while some dock group is maximized (the whole stage fills the workspace). */+ isMaximized(): boolean {+ return !!api?.hasMaximizedGroup();+ },+ /**+ * Maximize a panel's group to fill the workspace — dockview's native maximize,+ * which only HIDES the sibling groups (it does not remove/recreate any panel),+ * so the Viewport's live WebGL canvas survives untouched. Powers "Maximize On+ * Play" and the F11 focus toggle. No-op if the panel is popped out (a separate+ * OS window owns its own size). */+ maximizePanel(id: string) {+ const panel = api?.getPanel(id);+ if (api && panel && panel.api.location.type === 'grid') api.maximizeGroup(panel);+ },+ /** Restore from any maximized group (Stop / exit focus). */+ exitMaximized() {+ if (api?.hasMaximizedGroup()) api.exitMaximizedGroup();+ },+ /** Toggle a panel's group maximized/restored — the F11 focus command. */+ toggleMaximizePanel(id: string) {+ if (!api) return;+ if (api.hasMaximizedGroup()) api.exitMaximizedGroup();+ else this.maximizePanel(id);+ },/** Collapse a panel's group to its header / expand it back (click-to-toggle). */toggleCollapse(id: string, axis: 'width' | 'height') {const panel = api?.getPanel(id);diff --git a/desktop/src/panels/Viewport.tsx b/desktop/src/panels/Viewport.tsxindex b05bc158e..7ca6d990c 100644--- a/desktop/src/panels/Viewport.tsx+++ b/desktop/src/panels/Viewport.tsx@@ -1940,7 +1940,7 @@ export function Viewport() {};return (- <div className={`viewport${isPlaying ? ' viewport--play' : ''}`}>+ <div className={`viewport${playInViewport ? ' viewport--play' : ''}${playInViewport && isPaused ? ' viewport--paused' : ''}`}>{/* Docked scene toolbar under the panel tabs — view menus + display controlson the left, quick display toggles pinned right. Tool selection lives in thefloating palette over the canvas (.ov-left). */}@@ -2457,16 +2457,22 @@ export function Viewport() {{engine.status === 'ready' && showMinimap && <ViewportMinimap data={minimap} />}{perfVisible && <Perf id="viewport.perfhud"><PerfOverlay /></Perf>}- {mode.id !== 'scene' && (- <div className="viewport__tileflag">+ {mode.id !== 'scene' && !isPlaying && (+ <button+ type="button"+ className="viewport__tileflag"+ title={t('vp.openModePanels', { mode: mode.label })}+ onClick={() => commands.run(`mode.${mode.id}`)}+ >◧ {mode.label}{inTilePaint && paintTool ? ` · ${TILE_TOOL_LABEL[paintTool]}` : ''}- </div>+ </button>)}- {isPlaying && (- <div className={`viewport__playflag${isPaused ? ' paused' : ''}`}>- {isPaused ? t('vp.pausedFlag') : t('vp.playFlag')}- </div>+ {/* Playing-in-viewport is shown by the accent ring around the frame (see+ .viewport--play in CSS) — no pill over the game. A PAUSED game is the one+ state that needs a label: a frozen frame must not read as a hang. */}+ {playInViewport && isPaused && (+ <div className="viewport__playflag paused">{t('vp.pausedFlag')}</div>)}</div>);diff --git a/desktop/src/store/editorStore.ts b/desktop/src/store/editorStore.tsindex eafba949e..bd5b1bee1 100644--- a/desktop/src/store/editorStore.ts+++ b/desktop/src/store/editorStore.ts@@ -26,6 +26,11 @@ interface EditorState {// single realm; N>1 = a listen-server realm + N-1 client realms, replicated).playPlayers: number;setPlayPlayers: (n: number) => void;+ // Maximize the viewport/game group when Play starts (Unity's "Maximize On Play"),+ // restored on Stop. Off by default so the live-inspect-while-playing workflow+ // (tweaking entities in the Outliner/Details) keeps its panels. Persisted.+ maximizeOnPlay: boolean;+ setMaximizeOnPlay: (v: boolean) => void;// Which world the Outliner/Details inspect: the edit scene or the live game// (UE5 world picker). Auto-flips to 'game' on Play, 'editor' on Stop.inspectWorld: 'editor' | 'game';@@ -146,6 +151,12 @@ export const useEditorStore = create<EditorState>((set) => ({if (typeof localStorage !== 'undefined') localStorage.setItem('estella.playPlayers', String(playPlayers));set({ playPlayers });},+ maximizeOnPlay:+ typeof localStorage !== 'undefined' && localStorage.getItem('estella.maximizeOnPlay') === '1',+ setMaximizeOnPlay: (maximizeOnPlay) => {+ if (typeof localStorage !== 'undefined') localStorage.setItem('estella.maximizeOnPlay', maximizeOnPlay ? '1' : '0');+ set({ maximizeOnPlay });+ },inspectWorld: 'editor',setInspectWorld: (inspectWorld) => set({ inspectWorld }),diff --git a/desktop/src/theme/app.css b/desktop/src/theme/app.cssindex 82d0dd77b..985f380a8 100644--- a/desktop/src/theme/app.css+++ b/desktop/src/theme/app.css@@ -766,7 +766,15 @@ body.thumb-capture .viewport > :not(.viewport__stage):not(.viewport__play) {border: 1px solid color-mix(in srgb, var(--gizmo-tile) 50%, transparent);padding: 4px 12px;border-radius: 999px;- pointer-events: none;+ /* A button now: click the chip to open the mode's companion panels (the Tilemap+ painter / UI widgets) — the contextual counterpart to the activity-bar mode+ buttons, so a plain selection never has to fling those panels open itself. */+ cursor: pointer;+ transition: background var(--t-fast), border-color var(--t-fast);+}+.viewport__tileflag:hover {+ background: color-mix(in srgb, var(--gizmo-tile) 22%, rgba(var(--glass-rgb), 0.85));+ border-color: color-mix(in srgb, var(--gizmo-tile) 75%, transparent);}/* Squeezed viewport: the centered flags would slide under the top toolbars —diff --git a/desktop/src/theme/chrome.css b/desktop/src/theme/chrome.cssindex c10bb7359..749a313b7 100644--- a/desktop/src/theme/chrome.css+++ b/desktop/src/theme/chrome.css@@ -147,6 +147,7 @@.sitem.mono { font-family: var(--mono); }.sdot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-mute); }.sdot.live { background: var(--play); }+.sdot.paused { background: var(--warn); }.smute { color: var(--text-mute); }/* Keep the status strip (with the Content-Drawer toggle) above the drawer/scrim. */.status { position: relative; z-index: calc(var(--z-drawer) + 3); }diff --git a/desktop/src/theme/viewport.css b/desktop/src/theme/viewport.cssindex d788ee3d1..bfb5b9424 100644--- a/desktop/src/theme/viewport.css+++ b/desktop/src/theme/viewport.css@@ -309,6 +309,32 @@display: none;}+/* "This viewport is live" reads as a soft accent ring around the frame — not a+ pill over the game. Non-interactive, above the play iframe (z 7, matching the old+ pill) so it frames the running game without eating clicks. */+.viewport--play::after {+ content: '';+ position: absolute;+ inset: 0;+ z-index: 7;+ pointer-events: none;+ border-radius: inherit;+ box-shadow:+ inset 0 0 0 2px var(--run),+ inset 0 0 22px -2px color-mix(in srgb, var(--run) 45%, transparent);+}+/* Paused: the ring turns amber and the frozen game dims, so a still frame reads as+ deliberately paused (the centered PAUSED chip carries the word) — never a hang. */+.viewport--paused::after {+ box-shadow:+ inset 0 0 0 2px #e0a83e,+ inset 0 0 22px -2px rgba(224, 168, 62, 0.4);+}+.viewport--paused .viewport__play-host {+ filter: brightness(0.55) saturate(0.85);+ transition: filter var(--t-fast);+}+/* Game view (isolated play realm iframe) — REARCH_EDITOR_REALM Phase R. */.game-panel { position: relative; width: 100%; height: 100%; background: var(--srf-1); overflow: hidden; }.game-panel__host { position: absolute; inset: 0; }