mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 01:02:23 +00:00
The renderer seam: clicks go to the newest tool, recession and display groups through the contract, drawing at parity with Cesium
- Clicks: when two tools want the globe's clicks, the newest takes them and the older is told and turns itself off; a click is decided when it arrives, and ambient selection fires only when no tool holds the pointer. The "map is busy" paths and their strings are removed. - Recession: the limb fade is shared (src/render/recession.js) and reaches icon and model sets through SetSpec.recede; tuning applies on the next frame. - Display panel groups are published through src/ui/displayGroups.js; the Weather group and src/viewWeather.js are removed. - Draw port: a set whose icons only move is moved in place, and models that did not change are not restyled each frame, so moving fleets cost what they did when drawn directly; an untinted, fully opaque model is drawn without a colour. - Conformance: input.lease.lost checks the new lease inside onLost and reports a throwing onLost; draw.sets.recede covers model sets. - QA scripts read the renderer host instead of internals the seam replaced.
This commit is contained in:
1 parent
a0d299523d
commit
0ab31d4fb8
130 files changed
+5438
-1674
No files matched your search
+12
-15
@@ -15,7 +15,8 @@
|
||||
* (`src/data/inputOwnership.js`), and every ambient selection handler yields,
|
||||
* so a vertex clicked on top of an aircraft or a camera is a vertex and
|
||||
* nothing else. It is one claim consulted by all of them, not a list of
|
||||
* exceptions inside each.
|
||||
* exceptions inside each. Turning Draw on takes the pointer from any tool
|
||||
* holding it; a newer tool taking it turns Draw off.
|
||||
* - Cesium's Viewer binds its OWN left click (select the entity under the
|
||||
* pointer) and double click (track it) on the viewer's handler, outside every
|
||||
* layer and therefore outside the shared claim. Both are suppressed for the
|
||||
@@ -37,7 +38,6 @@ import {
|
||||
releasePointer,
|
||||
} from '../data/inputOwnership.js';
|
||||
import { inputFor } from '../input/dispatcher.js';
|
||||
import { pointerOwnerName } from '../data/pointerOwnerNames.js';
|
||||
import {
|
||||
DRAW_SHAPES,
|
||||
MAX_VERTICES,
|
||||
@@ -59,7 +59,7 @@ import {
|
||||
presentDrawMarks,
|
||||
} from './drawMarks.js';
|
||||
|
||||
import { onLocaleChange, t, translateKnown } from '../i18n/index.js';
|
||||
import { onLocaleChange, t } from '../i18n/index.js';
|
||||
import { fromDegrees } from '../geo/index.js';
|
||||
import { cssColor } from '../render/color.js';
|
||||
import {
|
||||
@@ -407,18 +407,15 @@ export function initDrawTool({
|
||||
function setActive(next) {
|
||||
if (destroyed || next === active) return active;
|
||||
if (next) {
|
||||
lease = claimPointer(DRAW_POINTER_OWNER);
|
||||
if (!lease) {
|
||||
// Somebody else is using the pointer — possibly an older instance of
|
||||
// this same tool that has not finished tearing down. Say so instead of
|
||||
// half-starting.
|
||||
setHint(() =>
|
||||
t('{owner} is using the pointer — close it first.', {
|
||||
owner: translateKnown(pointerOwnerName(pointerOwner())),
|
||||
}),
|
||||
);
|
||||
return active;
|
||||
}
|
||||
// The newest claim takes over: a tool holding the pointer is told and
|
||||
// turns itself off, and a newer one turns Draw off as if the person had.
|
||||
const claimed = claimPointer(DRAW_POINTER_OWNER, {
|
||||
onLost: () => {
|
||||
if (lease === claimed) setActive(false);
|
||||
},
|
||||
});
|
||||
if (!claimed) return active;
|
||||
lease = claimed;
|
||||
}
|
||||
active = next;
|
||||
present();
|
||||
|
||||
@@ -296,27 +296,42 @@ test('turning Draw on takes a lease and turning it off gives it back', async ()
|
||||
}
|
||||
});
|
||||
|
||||
test('Draw refuses to start when something else holds the pointer', async () => {
|
||||
test('Draw takes the pointer from another tool, which is told', async () => {
|
||||
const h = harness();
|
||||
try {
|
||||
const other = claimPointer('directions');
|
||||
let lost = 0;
|
||||
claimPointer('directions', { onLost: () => (lost += 1) });
|
||||
h.act('toggleDraw');
|
||||
assert.equal(h.tool.active, false, 'it must not half-start');
|
||||
assert.equal(pointerOwner(), 'directions', 'and must not steal the claim');
|
||||
// Named by its tool, not by the internal owner id.
|
||||
assert.equal(
|
||||
h.shown.view.hint,
|
||||
'Directions is using the pointer — close it first.',
|
||||
);
|
||||
assert.equal(
|
||||
h.tool.diagnostics().sceneHandler,
|
||||
false,
|
||||
'no handler was bound',
|
||||
);
|
||||
assert.equal(h.tool.active, true, 'the newest claim takes over');
|
||||
assert.equal(pointerOwner(), 'draw');
|
||||
assert.equal(lost, 1, 'the other tool is told once');
|
||||
} finally {
|
||||
h.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('Draw turns off, as if toggled off, when a newer tool takes the pointer', async () => {
|
||||
const h = harness({
|
||||
beforeInput(viewer) {
|
||||
viewer.screenSpaceEventHandler.setInputAction(() => {}, LEFT_CLICK);
|
||||
},
|
||||
});
|
||||
try {
|
||||
h.act('toggleDraw');
|
||||
assert.equal(h.tool.diagnostics().stockSingleClick, false);
|
||||
assert.ok(h.tool.addVertex(10, 20), 'a shape is under way');
|
||||
const other = claimPointer('directions');
|
||||
assert.equal(h.tool.active, false);
|
||||
assert.equal(h.tool.session, null, 'the half-drawn shape is dropped');
|
||||
assert.equal(h.shown.view.active, false, 'the Draw control reads off');
|
||||
const after = h.tool.diagnostics();
|
||||
assert.equal(after.sceneHandler, false, 'its subscriptions are gone');
|
||||
assert.equal(after.stockSingleClick, true, 'the stock clicks are back');
|
||||
assert.equal(after.previewItems, 0, 'the preview is cleared');
|
||||
assert.equal(pointerOwner(), 'directions', 'the newer tool keeps it');
|
||||
releasePointer(other);
|
||||
h.act('toggleDraw');
|
||||
assert.equal(h.tool.active, true, 'and it starts once the pointer is free');
|
||||
assert.equal(h.tool.active, true, 'and it turns on again when asked');
|
||||
} finally {
|
||||
h.restore();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user