The topbar is icons only: the leading Project dropdown, the Scene picker and the labelled Play/Pause buttons are gone and in their place stand five icon buttons - menu, undo, redo on the left, play and pause in the middle - while Notice, the save state, fps and the Account menu keep the right side; the Play button swaps its icon for a stop square while the project runs and Pause swaps for a second play sign while it is held (Button.setIcon()), and iconSpace() drops the gap between icon and label when a button has no label, which is what kept a 24 px icon button 3 px off its own centre; the menu carries New project, Open project..., a separator and Project settings..., where the picker (src/editor/OpenProjectDialog.ts) preselects the open project and marks it "open", opens on a double click and puts Delete on the left of Cancel and Open - it closes itself before it asks whether to delete, because two modals on top of each other would have left the question standing over a list it no longer speaks about - and the settings dialog (src/editor/ProjectSettingsDialog.ts) holds the name, the "Play starts" switch (Start scene / Active scene, a preference of this browser and so no command) and the collision layers from #152, which retires CollisionLayersDialog.ts and the "Collision layers..." entry; what Apply actually writes is the pure function settingsChanges(), so renaming and the layers are each their own undo step and each drop out when nothing differs; the Scene dropdown falls away without replacement, the active scene is switched by double clicking it in the Assets panel, which is the way that was there anyway; new module 46 runs last with 9 checks (no label left in the bar, the run buttons in edit mode, the four menu entries, the picker with the open project preselected, Cancel leaving the project standing, the settings dialog on the state of the project, renaming with undo and redo through the icon buttons) and it neither opens nor deletes a project, because that would pull the project out from under every earlier module; modules 8, 18 and 35 and the harness follow the new bar, 6 unit tests cover settingsChanges and 3 the icons (#183)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
defd4a86d2
commit
60d0146bde
24 files changed
+751
-284
No files matched your search
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* What "Apply" in the Project settings dialog (#183) actually carries out. The dialog itself is a
|
||||
* widget and needs a canvas; the rule behind it is a pure function and is tested here.
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { settingsChanges, type ProjectSettings } from '../../src/editor/ProjectSettingsDialog';
|
||||
|
||||
const before: ProjectSettings = {
|
||||
name: 'Demo project',
|
||||
playFrom: 'start',
|
||||
collisionLayers: ['Default', 'Enemies'],
|
||||
};
|
||||
|
||||
describe('project settings', () => {
|
||||
it('reports nothing to do when nothing was touched', () => {
|
||||
expect(settingsChanges(before, { ...before, collisionLayers: ['Default', 'Enemies'] })).toEqual({
|
||||
playFrom: 'start',
|
||||
});
|
||||
});
|
||||
|
||||
it('renames only when the name really differs', () => {
|
||||
expect(settingsChanges(before, { ...before, name: 'Tetris' }).name).toBe('Tetris');
|
||||
expect(settingsChanges(before, { ...before, name: 'Demo project' }).name).toBeUndefined();
|
||||
});
|
||||
|
||||
it('trims the name and keeps the old one when only blanks are left', () => {
|
||||
expect(settingsChanges(before, { ...before, name: ' Tetris ' }).name).toBe('Tetris');
|
||||
expect(settingsChanges(before, { ...before, name: ' ' }).name).toBeUndefined();
|
||||
});
|
||||
|
||||
it('writes the layers when one was added, renamed or dropped', () => {
|
||||
const changed = (layers: string[]) => settingsChanges(before, { ...before, collisionLayers: layers });
|
||||
expect(changed(['Default', 'Enemies', 'Pickups']).collisionLayers).toEqual([
|
||||
'Default',
|
||||
'Enemies',
|
||||
'Pickups',
|
||||
]);
|
||||
expect(changed(['Default', 'Foes']).collisionLayers).toEqual(['Default', 'Foes']);
|
||||
expect(changed(['Default']).collisionLayers).toEqual(['Default']);
|
||||
});
|
||||
|
||||
it('hands back a copy of the layers, not the array the dialog goes on editing', () => {
|
||||
const edited = ['Default', 'Foes'];
|
||||
const change = settingsChanges(before, { ...before, collisionLayers: edited });
|
||||
edited.push('Later');
|
||||
expect(change.collisionLayers).toEqual(['Default', 'Foes']);
|
||||
});
|
||||
|
||||
it('always reports the start-scene switch – it is a preference, not an undo step', () => {
|
||||
expect(settingsChanges(before, { ...before, playFrom: 'active' }).playFrom).toBe('active');
|
||||
expect(settingsChanges(before, { ...before, playFrom: 'start' }).playFrom).toBe('start');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user