diff --git a/src/editor/Editor.ts b/src/editor/Editor.ts index 9a8a7eab..65bd886a 100644 --- a/src/editor/Editor.ts +++ b/src/editor/Editor.ts @@ -429,7 +429,8 @@ export class Editor implements PlayHost { showBadge: (on) => this.toolbar.showRecording(on), badgeRoom: () => this.toolbar.recordingRoom(), }); - useCursorFiles(app.renderer.events, app.canvas); + // Undone on dispose: the next session's editor shares the renderer and must find Pixi's own styles. + this.cleanups.push(useCursorFiles(app.renderer.events, app.canvas)); this.play = new PlaySession(state, this); this.editorRun = new EditorRun(state, { // The game view is the one place where no key means anything to the editor, so that is where diff --git a/src/editor/editorCursors.ts b/src/editor/editorCursors.ts index 6205d0e1..940accf1 100644 --- a/src/editor/editorCursors.ts +++ b/src/editor/editorCursors.ts @@ -10,15 +10,20 @@ import { generalSettings, onGeneralSettings } from './generalSettings'; export function useCursorFiles(events: EventSystem, canvas: HTMLCanvasElement): () => void { const own = { ...events.cursorStyles }; const files = Object.fromEntries(cursorKeywords().map((keyword) => [keyword, cursorCss(keyword)])); - const apply = (): void => { + const show = (custom: boolean): void => { const styles = events.cursorStyles; for (const keyword of Object.keys(styles)) delete styles[keyword]; - Object.assign(styles, own, generalSettings().customCursor ? files : {}); + Object.assign(styles, own, custom ? files : {}); // Pixi sets a style only when the pointer's mode changes: the one showing now changes here. const keyword = cursorKeyword(canvas.style.cursor); const style = styles[keyword]; canvas.style.cursor = typeof style === 'string' ? style : keyword; }; + const apply = (): void => show(generalSettings().customCursor); apply(); - return onGeneralSettings(apply); + const stopListening = onGeneralSettings(apply); + return () => { + stopListening(); + show(false); + }; } diff --git a/tools/e2e/62-device-pixels.mjs b/tools/e2e/62-device-pixels.mjs index f79f7f26..2f6b9baf 100644 --- a/tools/e2e/62-device-pixels.mjs +++ b/tools/e2e/62-device-pixels.mjs @@ -128,7 +128,7 @@ export async function devicePixels(t) { fixed.shown.w === 960 && fixed.shown.h === 540 && Array.isArray(rows) && - rows.includes('Start recording'), + rows.includes('Start recording…'), JSON.stringify({ fixed, menu, rows }), );