Let the game view show the picture at a chosen scale (#225)
The game view always stretched the camera picture to fit the pane.
Pixel art came out blurred at odd factors, and there was no way to
see the game at its real size. The view now has a header with a
scale drop-down, and 100 % is the default.
- The header of the new GamePane offers Auto, Fit, 25 %, 50 %,
100 %, 200 % and 400 %. Auto and Fit show the factor they land
on, e.g. "Auto · 100%", and follow the pane when it resizes.
- 100 % means one screen pixel per pixel of the camera resolution
(width x height). The camera zoom scales the world on top of
that, so a zoomed camera still fills the same frame.
- Auto takes the largest fixed step that fits the whole picture
and falls back to 25 % when nothing fits. Fit keeps the old
behaviour.
- A picture larger than the pane is cropped around the camera
centre. Fixed steps start on a whole pixel so pixel art stays
sharp at 100 %.
- The choice is kept in the browser like "Play starts". Nothing
is written into the project.
Found on the way: the first draft applied the step to the world
instead of the camera resolution. The camera zoom then had no
effect at 100 %, which the existing check 12c caught (zoom 1.37
measured as scale 1).
The CI smokes were not run locally, because that would reseed
projects the user works in. All three smoke cameras are 640x360
and fit the 670x383 harness view at 100 %.
Tests:
- ./check.sh: 156 files, 2298 tests, CHECK EXIT 0 (before 2290).
- 8 unit tests in tests/viewport/view.test.ts for whole-pixel
steps, cropping, Auto and Fit with fallback, and zoomed cameras.
- 7 e2e checks in 03g. e2e 1-17,28,30,38-40: ALL PASSED, 727
checks.
- Counter-checks: no cropping, no rounding, no factor reported to
the header, and no zoom share each fail their own tests.
- Check total: 1367 (CI at c1a702b) + 7 = 1374, computed only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c1a702bc39
commit
9ef360ba1b
10 files changed
+291
-21
No files matched your search
@@ -28,6 +28,7 @@ import { TabStrip, type TabPlace } from './TabStrip';
|
||||
import type { AssetTabEditor } from './AssetTabEditor';
|
||||
import { closeDocument, type DocumentRow, openDocument, replaceDocument } from './documents';
|
||||
import { ConsolePanel } from './console/ConsolePanel';
|
||||
import { GamePane } from './viewport/GamePane';
|
||||
import { GameViewport } from './viewport/GameViewport';
|
||||
import { SceneViewport } from './viewport/SceneViewport';
|
||||
import { TAB_OF_ASSET } from './assetTabs';
|
||||
@@ -183,6 +184,7 @@ export class Editor implements PlayHost {
|
||||
readonly viewport: SceneViewport;
|
||||
/** Game tab: the running world through its camera. */
|
||||
readonly gameView: GameViewport;
|
||||
readonly gamePane: GamePane;
|
||||
readonly graphEditor: GraphEditor;
|
||||
readonly stateMachineEditor: StateMachineEditor;
|
||||
readonly shaderEditor: ShaderEditor;
|
||||
@@ -258,6 +260,7 @@ export class Editor implements PlayHost {
|
||||
) {
|
||||
this.viewport = new SceneViewport(state);
|
||||
this.gameView = new GameViewport(state);
|
||||
this.gamePane = new GamePane(this.gameView);
|
||||
this.graphEditor = new GraphEditor(state);
|
||||
this.stateMachineEditor = new StateMachineEditor(state);
|
||||
this.shaderEditor = new ShaderEditor(state);
|
||||
@@ -373,7 +376,7 @@ export class Editor implements PlayHost {
|
||||
};
|
||||
this.panes = {
|
||||
scene: this.sceneRow,
|
||||
game: this.gameView,
|
||||
game: this.gamePane,
|
||||
...this.assetEditors,
|
||||
list: this.listEditor,
|
||||
management: this.managementPane,
|
||||
@@ -391,6 +394,7 @@ export class Editor implements PlayHost {
|
||||
this.centre.add(this.panes[tab], 1);
|
||||
this.panes[tab].visible = tab === 'scene';
|
||||
}
|
||||
this.gameView.visible = false;
|
||||
// The console sits below whichever tab is showing, so it is a sibling of the panes, not of
|
||||
// the workspace: switching tabs must not move it.
|
||||
this.centre.add(this.consoleSplitter);
|
||||
@@ -693,9 +697,12 @@ export class Editor implements PlayHost {
|
||||
for (const [key, pane] of this.pluginPanes) pane.visible = key === tab;
|
||||
// The view checks its own flag before it redraws, and the row around it is what switches now.
|
||||
this.viewport.visible = tab === 'scene';
|
||||
this.gameView.visible = tab === 'game';
|
||||
this.syncTilemapPanel();
|
||||
this.tabs.setActive(strip);
|
||||
this.centre.relayout();
|
||||
// Hidden, it skipped every change; its pane may come back at the same size and not relayout.
|
||||
this.gameView.redraw();
|
||||
ui().focus.validate();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user