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): shared EmptyState — one empty-panel look
yhhb7ad7af83432
diff --git a/desktop/src/components/EmptyState.tsx b/desktop/src/components/EmptyState.tsxnew file mode 100644index 000000000..49cf45d2f--- /dev/null+++ b/desktop/src/components/EmptyState.tsx@@ -0,0 +1,36 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file EmptyState.tsx+ * @brief The shared "nothing here yet" panel state — a dashed-chip icon, a title,+ * an optional hint, and optional actions/children. One look everywhere a+ * panel has no content to show (no selection, no project, empty list), so+ * empty panels read consistently instead of each rolling its own.+ */+import type { LucideIcon } from 'lucide-react';+import type { ReactNode } from 'react';++export function EmptyState({+ icon: Icon,+ title,+ hint,+ children,+}: {+ icon: LucideIcon;+ title: string;+ /** A short line under the title saying what to do next. */+ hint?: ReactNode;+ /** Optional trailing content — a primary action, onboarding steps, etc. */+ children?: ReactNode;+}) {+ return (+ <div className="empty-state">+ <div className="empty-state__icon">+ <Icon size={22} strokeWidth={1.4} />+ </div>+ <div className="empty-state__title">{title}</div>+ {hint && <div className="empty-state__hint">{hint}</div>}+ {children}+ </div>+ );+}diff --git a/desktop/src/i18n/messages/controllers.ts b/desktop/src/i18n/messages/controllers.tsindex 749e9d302..8f7b60734 100644--- a/desktop/src/i18n/messages/controllers.ts+++ b/desktop/src/i18n/messages/controllers.ts@@ -14,10 +14,12 @@ export const controllerMessages = defineMessages({en: 'Record: edits write into the active controller’s current page (un-geared fields gear themselves)',zh: '录制:编辑写入活动控制器的当前页(未绑定的字段会自动绑定)',},+ 'ctrl.emptyNoSelTitle': { en: 'No UI selected', zh: '未选择 UI' },'ctrl.emptyNoSelection': {en: 'Select a UI entity to author its controllers.',zh: '选择一个 UI 实体来编辑它的控制器。',},+ 'ctrl.emptyNotUiTitle': { en: 'Not a UI element', zh: '非 UI 元素' },'ctrl.emptyNotUi': {en: 'The selected entity is not a UI element (no Canvas / UINode).',zh: '所选实体不是 UI 元素(没有 Canvas / UINode)。',diff --git a/desktop/src/i18n/messages/mixer.ts b/desktop/src/i18n/messages/mixer.tsindex efc119d7f..92673873e 100644--- a/desktop/src/i18n/messages/mixer.ts+++ b/desktop/src/i18n/messages/mixer.ts@@ -7,6 +7,7 @@ import { defineMessages } from './types';export const mixerMessages = defineMessages({'mix.panelTitle': { en: 'Audio Mixer', zh: '音频混音器' },+ 'mix.noProjectTitle': { en: 'No project open', zh: '未打开项目' },'mix.noProject': { en: 'Open a project to edit its mixer.', zh: '打开项目后编辑其混音器。' },'mix.mute': { en: 'Mute', zh: '静音' },'mix.addBus': { en: 'Add Bus', zh: '添加总线' },diff --git a/desktop/src/panels/AudioMixerPanel.tsx b/desktop/src/panels/AudioMixerPanel.tsxindex 8731eacbd..97e79cf76 100644--- a/desktop/src/panels/AudioMixerPanel.tsx+++ b/desktop/src/panels/AudioMixerPanel.tsx@@ -19,6 +19,7 @@ import {import { ProjectStore } from '@/project/ProjectStore';import { EngineHost } from '@/engine/EngineHost';import { Select } from '@/components/Select';+import { EmptyState } from '@/components/EmptyState';import { t } from '@/i18n';/** The always-present mixer tree; custom buses append after these. */@@ -209,7 +210,7 @@ function BusStrip(props: { strip: StripModel; all: StripModel[]; config: AudioPrexport function AudioMixerPanel() {const project = useSyncExternalStore(ProjectStore.subscribe, ProjectStore.getSnapshot);if (!project) {- return <div className="mix-empty">{t('mix.noProject')}</div>;+ return <EmptyState icon={Volume2} title={t('mix.noProjectTitle')} hint={t('mix.noProject')} />;}const config = ProjectStore.audioFeature();const strips = stripsOf(config);diff --git a/desktop/src/panels/ControllersPanel.tsx b/desktop/src/panels/ControllersPanel.tsxindex 4096a7bce..3e2f6877c 100644--- a/desktop/src/panels/ControllersPanel.tsx+++ b/desktop/src/panels/ControllersPanel.tsx@@ -20,6 +20,7 @@ import { useControllerStore } from '@/store/controllerStore';import { SceneStore } from '@/engine/SceneStore';import { SceneModel } from '@/engine/SceneModel';import { SceneCommands } from '@/engine/SceneCommands';+import { EmptyState } from '@/components/EmptyState';import { resolveControllers, readGearBindings, type ResolvedController } from '@/controller/controllerModel';import { t } from '@/i18n';import type { EntityId } from '@/types';@@ -47,10 +48,10 @@ export function ControllersPanel() {}, [controllers, activeController, setActiveController]);if (selectedId == null || !entity) {- return <div className="ctrl-empty">{t('ctrl.emptyNoSelection')}</div>;+ return <EmptyState icon={MousePointerClick} title={t('ctrl.emptyNoSelTitle')} hint={t('ctrl.emptyNoSelection')} />;}if (!isUi) {- return <div className="ctrl-empty">{t('ctrl.emptyNotUi')}</div>;+ return <EmptyState icon={MousePointerClick} title={t('ctrl.emptyNotUiTitle')} hint={t('ctrl.emptyNotUi')} />;}const addController = () => {diff --git a/desktop/src/panels/Details.tsx b/desktop/src/panels/Details.tsxindex a3c534d52..b80421e70 100644--- a/desktop/src/panels/Details.tsx+++ b/desktop/src/panels/Details.tsx@@ -81,6 +81,7 @@ import { AnimClipDocument } from '@/flipbook/AnimClipDocument';import { buildAnimClipComponents, makeAnimClipWrite } from '@/flipbook/animClipInspectorModel';import { ColorControl, rgbaToHex8 } from '@/components/ColorControl';import { IconButton } from '@/components/IconButton';+import { EmptyState } from '@/components/EmptyState';import { ContextMenu } from '@/components/Menu';import { NumField, useScrub, fmt, type ControlGesture } from '@/components/NumField';import { Popover, usePopover } from '@/components/Popover';@@ -2941,13 +2942,7 @@ function EditorDetails() {if (!entity || selectedId == null) {return (<div className="insp">- <div className="insp-empty">- <div className="ei">- <Box size={22} strokeWidth={1.4} />- </div>- <div className="et">{t('det.noSelection')}</div>- <div className="es">{t('det.noSelectionHint')}</div>- </div>+ <EmptyState icon={Box} title={t('det.noSelection')} hint={t('det.noSelectionHint')} /></div>);}diff --git a/desktop/src/theme/app.css b/desktop/src/theme/app.cssindex 158955a36..74f019533 100644--- a/desktop/src/theme/app.css+++ b/desktop/src/theme/app.css@@ -162,6 +162,33 @@max-width: 220px;}+/* The shared panel empty state (see components/EmptyState.tsx): a dashed-chip icon,+ a title, an optional hint. Used wherever a panel has no content — no selection,+ no project, an empty list — so every empty panel reads the same. */+.empty-state {+ flex: 1;+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ gap: 10px;+ height: 100%;+ padding: 40px 24px;+ text-align: center;+ color: var(--text-mute);+}+.empty-state__icon {+ width: 46px;+ height: 46px;+ display: grid;+ place-items: center;+ color: var(--text-mute);+ border: 1px dashed var(--border-line);+ border-radius: var(--r-lg);+}+.empty-state__title { font-size: var(--fs-md); color: var(--text-dim); font-weight: 600; }+.empty-state__hint { font-size: var(--fs-sm); line-height: 1.5; max-width: 260px; }+/* -------------------------------------------------------------- viewport --- */.viewport {position: relative;diff --git a/desktop/src/theme/controllers.css b/desktop/src/theme/controllers.cssindex c09efe5c9..fde3e8b21 100644--- a/desktop/src/theme/controllers.css+++ b/desktop/src/theme/controllers.css@@ -3,7 +3,6 @@/* Controllers panel (ControllersPanel): author UIController pages + record mode. */.ctrl-panel { padding: 8px; display: flex; flex-direction: column; gap: 8px; height: 100%; overflow-y: auto; }-.ctrl-empty { padding: 16px 12px; font-size: var(--fs-2xs); color: var(--text-dim); line-height: 1.5; text-align: center; }.ctrl-hint { font-size: var(--fs-2xs); color: var(--text-dim); line-height: 1.4; padding: 0 2px; }.ctrl-head { display: flex; align-items: center; justify-content: space-between; }diff --git a/desktop/src/theme/settings.css b/desktop/src/theme/settings.cssindex 5a308489c..12a481917 100644--- a/desktop/src/theme/settings.css+++ b/desktop/src/theme/settings.css@@ -213,10 +213,6 @@color: var(--text);font-size: var(--fs-sm);}-.mix-empty {- display: flex; align-items: center; justify-content: center;- height: 100%; color: var(--text-dim);-}.mix-strips {display: flex;align-items: flex-start;