@umicat/phaser-sdk 1.0.20 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor/EditorOverlayScene.js +42 -3
- package/dist/protocol.d.ts +12 -1
- package/package.json +1 -1
|
@@ -42,6 +42,11 @@ const CAMERA_VIEWPORT_LINE_WIDTH = 2;
|
|
|
42
42
|
// Brighter/distinct from the world-camera rect: it's the fixed boundary HUD
|
|
43
43
|
// widgets anchor to (Godot's UI viewport rect), not the movable camera view.
|
|
44
44
|
const HUD_SCREEN_COLOR = 0x5bc0ff;
|
|
45
|
+
// World-origin axes (Godot convention): red = X axis (world y=0), green = Y
|
|
46
|
+
// axis (world x=0). Semi-transparent so they read as reference, not content.
|
|
47
|
+
const AXIS_X_COLOR = 0xff5566;
|
|
48
|
+
const AXIS_Y_COLOR = 0x55dd66;
|
|
49
|
+
const AXIS_ALPHA = 0.5;
|
|
45
50
|
// FB.10 polish — CSS cursor name per tilemap resize handle. Corner handles
|
|
46
51
|
// get the diagonal arrows (`nwse-resize` ↖↘ for NW/SE, `nesw-resize` ↗↙ for
|
|
47
52
|
// NE/SW). Edge handles get the axis arrows (ns / ew). Same conventions as
|
|
@@ -349,6 +354,14 @@ export class EditorOverlayScene extends Phaser.Scene {
|
|
|
349
354
|
// a tilemap resize handle. Done first so cursor reflects the immediate
|
|
350
355
|
// visual state regardless of which branch we hit below.
|
|
351
356
|
this.updateResizeCursor(pointer);
|
|
357
|
+
// Coordinate readout — post the cursor's WORLD position so the host can
|
|
358
|
+
// show it in the ruler corner. Cheap; pointermove is frame-throttled.
|
|
359
|
+
{
|
|
360
|
+
const wc = this.pointerCoords(pointer);
|
|
361
|
+
if (typeof window !== 'undefined' && window.parent) {
|
|
362
|
+
window.parent.postMessage({ type: 'umicat:editor:cursorWorld', x: Math.round(wc.x), y: Math.round(wc.y) }, '*');
|
|
363
|
+
}
|
|
364
|
+
}
|
|
352
365
|
// P1 infinite canvas — pan in progress: translate screen delta into
|
|
353
366
|
// world delta via the current zoom, set scroll absolute (relative-mode
|
|
354
367
|
// would accumulate floating-point drift over many move events).
|
|
@@ -1745,6 +1758,20 @@ export class EditorOverlayScene extends Phaser.Scene {
|
|
|
1745
1758
|
// layers (or the resize-rebuilt layers don't track post-resize
|
|
1746
1759
|
// container.x/y changes).
|
|
1747
1760
|
this.syncTilemapLayersFromContainers();
|
|
1761
|
+
// World coordinate-system axes (Godot-style): red X line through world
|
|
1762
|
+
// y=0, green Y line through world x=0 — so the user can see where the
|
|
1763
|
+
// origin (0,0) is and place entities relative to it. Drawn in world space
|
|
1764
|
+
// (pan/zoom with the view); width counter-scaled by zoom so the lines stay
|
|
1765
|
+
// ~1.5px on screen at any zoom. Drawn first so bounds/selection paint over.
|
|
1766
|
+
{
|
|
1767
|
+
const z = this.cameras.main?.zoom || 1;
|
|
1768
|
+
const w = 1.5 / z;
|
|
1769
|
+
const EXT = 100000;
|
|
1770
|
+
this.graphics.lineStyle(w, AXIS_X_COLOR, AXIS_ALPHA);
|
|
1771
|
+
this.graphics.lineBetween(-EXT, 0, EXT, 0);
|
|
1772
|
+
this.graphics.lineStyle(w, AXIS_Y_COLOR, AXIS_ALPHA);
|
|
1773
|
+
this.graphics.lineBetween(0, -EXT, 0, EXT);
|
|
1774
|
+
}
|
|
1748
1775
|
if (this.worldBounds) {
|
|
1749
1776
|
// World bounds outline (the visible game frame). Outside-fill grey
|
|
1750
1777
|
// strips moved to a separate Graphics in the WORLD scene at very
|
|
@@ -1795,10 +1822,22 @@ export class EditorOverlayScene extends Phaser.Scene {
|
|
|
1795
1822
|
// World mode → the camera viewport rect: where the runtime camera
|
|
1796
1823
|
// looks + how much it sees (intrinsic/zoom). Small inside a larger
|
|
1797
1824
|
// world for farming/RPG; coincides with world bounds for Tetris etc.
|
|
1798
|
-
const
|
|
1799
|
-
const
|
|
1825
|
+
const z = worldSceneCam.zoom;
|
|
1826
|
+
const camW = intrinsicW / z;
|
|
1827
|
+
const camH = intrinsicH / z;
|
|
1828
|
+
// Phaser zooms around the camera's viewport CENTRE (default origin
|
|
1829
|
+
// 0.5), so the world coord at the camera's top-left is
|
|
1830
|
+
// `scrollX + (intrinsicW/2)(1 - 1/z)`, NOT scrollX. At z=1 the term is
|
|
1831
|
+
// 0 (unchanged — Tetris/Space-Invaders etc. are unaffected); at any
|
|
1832
|
+
// other zoom this keeps the rect aligned with what cameras.main really
|
|
1833
|
+
// frames — and with the editor rulers/axes, which apply the same
|
|
1834
|
+
// correction. Computed manually rather than reading
|
|
1835
|
+
// `worldSceneCam.worldView` because the runtime cam is hidden in edit
|
|
1836
|
+
// mode and may not preRender, so its worldView can be stale.
|
|
1837
|
+
const viewX = camX + (intrinsicW / 2) * (1 - 1 / z);
|
|
1838
|
+
const viewY = camY + (intrinsicH / 2) * (1 - 1 / z);
|
|
1800
1839
|
this.graphics.lineStyle(CAMERA_VIEWPORT_LINE_WIDTH, CAMERA_VIEWPORT_COLOR, CAMERA_VIEWPORT_ALPHA);
|
|
1801
|
-
this.graphics.strokeRect(
|
|
1840
|
+
this.graphics.strokeRect(viewX, viewY, camW, camH);
|
|
1802
1841
|
}
|
|
1803
1842
|
}
|
|
1804
1843
|
const selectedId = getSelection(this.game);
|
package/dist/protocol.d.ts
CHANGED
|
@@ -867,7 +867,18 @@ export interface EditorTilemapTilePickedMessage {
|
|
|
867
867
|
layerId: string;
|
|
868
868
|
tileIndex: number | null;
|
|
869
869
|
}
|
|
870
|
-
|
|
870
|
+
/**
|
|
871
|
+
* Cursor world position (editor coordinate readout). Posted on pointer-move
|
|
872
|
+
* while editing so the host can show the cursor's WORLD (x, y) — e.g. in the
|
|
873
|
+
* corner of the rulers. Integers (rounded). Cheap; pointermove is
|
|
874
|
+
* frame-throttled by the browser.
|
|
875
|
+
*/
|
|
876
|
+
export interface EditorCursorWorldMessage {
|
|
877
|
+
type: 'umicat:editor:cursorWorld';
|
|
878
|
+
x: number;
|
|
879
|
+
y: number;
|
|
880
|
+
}
|
|
881
|
+
export type EditorSdkToHostMessage = EditorSceneLoadedMessage | EditorSelectionPickedMessage | EditorDragEndMessage | EditorEntityResizedMessage | EditorShortcutMessage | EditorSelectionRectMessage | EditorRulesLoadedMessage | EditorCameraStateMessage | EditorCursorWorldMessage | EditorTilemapEditedMessage | EditorTilemapTilePickedMessage;
|
|
871
882
|
export type RpcMethod = 'saves.get' | 'saves.set' | 'saves.delete' | 'saves.list' | 'gameData.get' | 'gameData.set' | 'gameData.delete' | 'gameData.list' | 'realtime.getToken' | 'ai.act';
|
|
872
883
|
export interface SavesGetParams {
|
|
873
884
|
key: string;
|