Skip to content

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.

feat(editor): PAUSED indicator + Pause/Resume command (F6)

esengine2adeaf0bc77c
diff --git a/desktop/src/commands/editorCommands.ts b/desktop/src/commands/editorCommands.ts
index e9db428b8..526bb0266 100644
--- a/desktop/src/commands/editorCommands.ts
+++ b/desktop/src/commands/editorCommands.ts
@@ -434,6 +434,16 @@ commands.register({
isEnabled: () => editor().isPlaying,
run: () => editor().stop(),
});
+commands.register({
+ id: 'play.pause',
+ label: t('cmd.play.pause'),
+ category: t('cat.play'),
+ keybinding: 'f6',
+ // Only while playing — and as a command it reaches the palette and popped-out
+ // windows, where the toolbar Pause button doesn't exist.
+ isEnabled: () => editor().isPlaying,
+ run: () => editor().togglePause(),
+});
// — Build —
commands.register({
diff --git a/desktop/src/i18n/messages/commands.ts b/desktop/src/i18n/messages/commands.ts
index 93fcfda10..062718144 100644
--- a/desktop/src/i18n/messages/commands.ts
+++ b/desktop/src/i18n/messages/commands.ts
@@ -65,6 +65,7 @@ export const commandMessages = defineMessages({
'palette.noMatch': { en: 'No matching commands', zh: '没有匹配的命令' },
'cmd.play.toggle': { en: 'Play', zh: '运行' },
'cmd.play.stop': { en: 'Stop', zh: '停止' },
+ 'cmd.play.pause': { en: 'Pause / Resume', zh: '暂停 / 继续' },
'cmd.build.scripts': { en: 'Build Project Scripts', zh: '构建项目脚本' },
// — Command categories (menus, shortcuts page grouping) —
diff --git a/desktop/src/i18n/messages/viewport.ts b/desktop/src/i18n/messages/viewport.ts
index f7c27a1fd..41d2c321d 100644
--- a/desktop/src/i18n/messages/viewport.ts
+++ b/desktop/src/i18n/messages/viewport.ts
@@ -121,6 +121,7 @@ export const viewportMessages = defineMessages({
'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.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/panels/Viewport.tsx b/desktop/src/panels/Viewport.tsx
index 1453e7b95..38b27a4f7 100644
--- a/desktop/src/panels/Viewport.tsx
+++ b/desktop/src/panels/Viewport.tsx
@@ -728,6 +728,7 @@ export function Viewport() {
// popped out. Drives resize re-binding and any window-scoped listeners below.
const win = usePanelWindow();
const isPlaying = useEditorStore((s) => s.isPlaying);
+ const isPaused = useEditorStore((s) => s.isPaused);
const playTarget = useEditorStore((s) => s.playTarget);
const tool = useEditorStore((s) => s.tool);
const showGrid = useEditorStore((s) => s.showGrid);
@@ -2462,7 +2463,11 @@ export function Viewport() {
{inTilePaint && paintTool ? ` · ${TILE_TOOL_LABEL[paintTool]}` : ''}
</div>
)}
- {isPlaying && <div className="viewport__playflag">{t('vp.playFlag')}</div>}
+ {isPlaying && (
+ <div className={`viewport__playflag${isPaused ? ' paused' : ''}`}>
+ {isPaused ? t('vp.pausedFlag') : t('vp.playFlag')}
+ </div>
+ )}
</div>
);
}
diff --git a/desktop/src/theme/app.css b/desktop/src/theme/app.css
index 74f019533..1b7e68e38 100644
--- a/desktop/src/theme/app.css
+++ b/desktop/src/theme/app.css
@@ -718,6 +718,13 @@ body.thumb-capture .viewport > :not(.viewport__stage):not(.viewport__play) {
border-radius: 999px;
box-shadow: var(--run-glow);
}
+/* Paused reads amber, not the green "running" accent, so a frozen game doesn't
+ look like a hang. */
+.viewport__playflag.paused {
+ color: #e0a83e;
+ border-color: rgba(224, 168, 62, 0.5);
+ box-shadow: none;
+}
/* Tile-paint mode badge — mirrors the play flag but in the tile-editing accent, so
"you are painting tiles (Q/Esc to leave)" reads at a glance. Edit-mode only, so it