diff --git a/package-lock.json b/package-lock.json index caa76a49b..75c4d21cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "license": "Apache-2.0", "dependencies": { "@actions/core": "^1.10.0", - "@dcl/protocol": "1.0.0-11406954347.commit-ba19c4f", + "@dcl/protocol": "1.0.0-11599848164.commit-ef74edc", "@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1", "@dcl/ts-proto": "1.153.0", "@types/fs-extra": "^9.0.12", @@ -577,9 +577,9 @@ } }, "node_modules/@dcl/protocol": { - "version": "1.0.0-11406954347.commit-ba19c4f", - "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-11406954347.commit-ba19c4f.tgz", - "integrity": "sha512-oMoq5IKAe1gout5SbP2w3Jq3Im+tbUiREW70BC+aVwwOly0YDtTWTZG9FyjeF36RDhyCg7z6jwtHL/rbWp0skw==", + "version": "1.0.0-11599848164.commit-ef74edc", + "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-11599848164.commit-ef74edc.tgz", + "integrity": "sha512-XSUOA0LbchlBUk5/BMJFBl0+qOm4UOIxwMGp38A1n4LQAatGO/RXjzReJRveqiFma+X7eq3e6+KCDqTLwepN0w==", "dependencies": { "@dcl/ts-proto": "1.154.0" } @@ -8232,9 +8232,9 @@ } }, "@dcl/protocol": { - "version": "1.0.0-11406954347.commit-ba19c4f", - "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-11406954347.commit-ba19c4f.tgz", - "integrity": "sha512-oMoq5IKAe1gout5SbP2w3Jq3Im+tbUiREW70BC+aVwwOly0YDtTWTZG9FyjeF36RDhyCg7z6jwtHL/rbWp0skw==", + "version": "1.0.0-11599848164.commit-ef74edc", + "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-11599848164.commit-ef74edc.tgz", + "integrity": "sha512-XSUOA0LbchlBUk5/BMJFBl0+qOm4UOIxwMGp38A1n4LQAatGO/RXjzReJRveqiFma+X7eq3e6+KCDqTLwepN0w==", "requires": { "@dcl/ts-proto": "1.154.0" }, diff --git a/package.json b/package.json index 0c809b80a..28538db1a 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "bugs": "https://github.com/decentraland/js-sdk-toolchain/issues", "dependencies": { "@actions/core": "^1.10.0", - "@dcl/protocol": "1.0.0-11406954347.commit-ba19c4f", + "@dcl/protocol": "1.0.0-11599848164.commit-ef74edc", "@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1", "@dcl/ts-proto": "1.153.0", "@types/fs-extra": "^9.0.12", diff --git a/packages/@dcl/ecs/src/systems/events.ts b/packages/@dcl/ecs/src/systems/events.ts index 433b810d9..91d92dc2e 100644 --- a/packages/@dcl/ecs/src/systems/events.ts +++ b/packages/@dcl/ecs/src/systems/events.ts @@ -20,8 +20,14 @@ export type EventSystemOptions = { hoverText?: string maxDistance?: number showFeedback?: boolean + showHighlight?: boolean } +export const getDefaultOpts = (opts: Partial = {}): EventSystemOptions => ({ + button: InputAction.IA_ANY, + ...opts +}) + /** * @public */ @@ -98,11 +104,6 @@ export function createPointerEventsSystem(engine: IEngine, inputSystem: IInputSy } type EventMapType = Map - const getDefaultOpts = (opts: Partial = {}): EventSystemOptions => ({ - button: InputAction.IA_ANY, - ...opts - }) - const eventsMap = new Map() function getEvent(entity: Entity) { @@ -110,19 +111,17 @@ export function createPointerEventsSystem(engine: IEngine, inputSystem: IInputSy } function setPointerEvent(entity: Entity, type: PointerEventType, opts: EventSystemOptions) { - if (opts.hoverText || opts.showFeedback) { - const pointerEvent = PointerEvents.getMutableOrNull(entity) || PointerEvents.create(entity) - - pointerEvent.pointerEvents.push({ - eventType: type, - eventInfo: { - button: opts.button, - showFeedback: opts.showFeedback, - hoverText: opts.hoverText, - maxDistance: opts.maxDistance - } - }) - } + const pointerEvent = PointerEvents.getMutableOrNull(entity) || PointerEvents.create(entity) + pointerEvent.pointerEvents.push({ + eventType: type, + eventInfo: { + button: opts.button, + showFeedback: opts.showFeedback, + showHighlight: opts.showHighlight, + hoverText: opts.hoverText, + maxDistance: opts.maxDistance + } + }) } function removePointerEvent(entity: Entity, type: PointerEventType, button: InputAction) { diff --git a/packages/@dcl/inspector/src/components/EntityInspector/PointerEventsInspector/PointerEventsInspector.tsx b/packages/@dcl/inspector/src/components/EntityInspector/PointerEventsInspector/PointerEventsInspector.tsx index 1ce87c8ab..a28816df8 100644 --- a/packages/@dcl/inspector/src/components/EntityInspector/PointerEventsInspector/PointerEventsInspector.tsx +++ b/packages/@dcl/inspector/src/components/EntityInspector/PointerEventsInspector/PointerEventsInspector.tsx @@ -115,6 +115,12 @@ export default withSdk(({ sdk, entity: entityId }) => { onChange={(e) => handleEventInfoChange({ showFeedback: !!e.target.checked }, idx)} /> + + handleEventInfoChange({ showHighlight: !!e.target.checked }, idx)} + /> + handleRemove(idx)}>Remove Pointer Event ))} diff --git a/packages/@dcl/inspector/src/components/EntityInspector/PointerEventsInspector/utils.spec.ts b/packages/@dcl/inspector/src/components/EntityInspector/PointerEventsInspector/utils.spec.ts index c2ee6996d..8aca0c000 100644 --- a/packages/@dcl/inspector/src/components/EntityInspector/PointerEventsInspector/utils.spec.ts +++ b/packages/@dcl/inspector/src/components/EntityInspector/PointerEventsInspector/utils.spec.ts @@ -23,7 +23,8 @@ describe('InputUtils', () => { button: InputAction.IA_ANY, hoverText: 'Interact', maxDistance: 10, - showFeedback: true + showFeedback: true, + showHighlight: true } } expect(result).toEqual(expected) @@ -36,7 +37,8 @@ describe('InputUtils', () => { button: InputAction.IA_PRIMARY, hoverText: 'Custom Interaction', maxDistance: 15, - showFeedback: false + showFeedback: false, + showHighlight: false } }) const expected = { @@ -45,7 +47,8 @@ describe('InputUtils', () => { button: InputAction.IA_PRIMARY, hoverText: 'Custom Interaction', maxDistance: 15, - showFeedback: false + showFeedback: false, + showHighlight: false } } expect(result).toEqual(expected) @@ -68,7 +71,8 @@ describe('InputUtils', () => { button: InputAction.IA_ANY, hoverText: 'Interact', maxDistance: 10, - showFeedback: true + showFeedback: true, + showHighlight: true } } expect(DEFAULTS).toEqual(expected) diff --git a/packages/@dcl/inspector/src/components/EntityInspector/PointerEventsInspector/utils.ts b/packages/@dcl/inspector/src/components/EntityInspector/PointerEventsInspector/utils.ts index c9ebdbc0e..b0ea8d80f 100644 --- a/packages/@dcl/inspector/src/components/EntityInspector/PointerEventsInspector/utils.ts +++ b/packages/@dcl/inspector/src/components/EntityInspector/PointerEventsInspector/utils.ts @@ -18,6 +18,7 @@ export function getDefaultPointerEvent( hoverText: 'Interact', maxDistance: 10, showFeedback: true, + showHighlight: true, ...def?.eventInfo } } diff --git a/packages/@dcl/playground-assets/etc/playground-assets.api.md b/packages/@dcl/playground-assets/etc/playground-assets.api.md index c05702bbc..5560ba59a 100644 --- a/packages/@dcl/playground-assets/etc/playground-assets.api.md +++ b/packages/@dcl/playground-assets/etc/playground-assets.api.md @@ -1130,6 +1130,7 @@ export type EventSystemOptions = { hoverText?: string; maxDistance?: number; showFeedback?: boolean; + showHighlight?: boolean; }; // @public @@ -1167,6 +1168,11 @@ export function getComponentEntityTree(engine: Pick; +// Warning: (ae-missing-release-tag) "getDefaultOpts" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) +// +// @public (undocumented) +export const getDefaultOpts: (opts?: Partial) => EventSystemOptions; + // Warning: (ae-missing-release-tag) "GlobalDirectionRaycastOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal) // // @public (undocumented) @@ -2677,6 +2683,7 @@ export interface PBPointerEvents_Info { hoverText?: string | undefined; maxDistance?: number | undefined; showFeedback?: boolean | undefined; + showHighlight?: boolean | undefined; } // @public (undocumented) diff --git a/packages/@dcl/sdk-commands/package-lock.json b/packages/@dcl/sdk-commands/package-lock.json index bab6fbf37..2e1fcf497 100644 --- a/packages/@dcl/sdk-commands/package-lock.json +++ b/packages/@dcl/sdk-commands/package-lock.json @@ -15,7 +15,7 @@ "@dcl/inspector": "file:../inspector", "@dcl/linker-dapp": "^0.14.2", "@dcl/mini-comms": "1.0.1-20230216163137.commit-a4c75be", - "@dcl/protocol": "1.0.0-11406954347.commit-ba19c4f", + "@dcl/protocol": "1.0.0-11599848164.commit-ef74edc", "@dcl/quests-client": "^1.0.3", "@dcl/quests-manager": "^0.1.4", "@dcl/rpc": "^1.1.1", @@ -239,9 +239,9 @@ } }, "node_modules/@dcl/protocol": { - "version": "1.0.0-11406954347.commit-ba19c4f", - "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-11406954347.commit-ba19c4f.tgz", - "integrity": "sha512-oMoq5IKAe1gout5SbP2w3Jq3Im+tbUiREW70BC+aVwwOly0YDtTWTZG9FyjeF36RDhyCg7z6jwtHL/rbWp0skw==", + "version": "1.0.0-11599848164.commit-ef74edc", + "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-11599848164.commit-ef74edc.tgz", + "integrity": "sha512-XSUOA0LbchlBUk5/BMJFBl0+qOm4UOIxwMGp38A1n4LQAatGO/RXjzReJRveqiFma+X7eq3e6+KCDqTLwepN0w==", "dependencies": { "@dcl/ts-proto": "1.154.0" } @@ -3228,9 +3228,9 @@ } }, "@dcl/protocol": { - "version": "1.0.0-11406954347.commit-ba19c4f", - "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-11406954347.commit-ba19c4f.tgz", - "integrity": "sha512-oMoq5IKAe1gout5SbP2w3Jq3Im+tbUiREW70BC+aVwwOly0YDtTWTZG9FyjeF36RDhyCg7z6jwtHL/rbWp0skw==", + "version": "1.0.0-11599848164.commit-ef74edc", + "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-11599848164.commit-ef74edc.tgz", + "integrity": "sha512-XSUOA0LbchlBUk5/BMJFBl0+qOm4UOIxwMGp38A1n4LQAatGO/RXjzReJRveqiFma+X7eq3e6+KCDqTLwepN0w==", "requires": { "@dcl/ts-proto": "1.154.0" } diff --git a/packages/@dcl/sdk-commands/package.json b/packages/@dcl/sdk-commands/package.json index e92c50308..aebff11ff 100644 --- a/packages/@dcl/sdk-commands/package.json +++ b/packages/@dcl/sdk-commands/package.json @@ -13,7 +13,7 @@ "@dcl/inspector": "file:../inspector", "@dcl/linker-dapp": "^0.14.2", "@dcl/mini-comms": "1.0.1-20230216163137.commit-a4c75be", - "@dcl/protocol": "1.0.0-11406954347.commit-ba19c4f", + "@dcl/protocol": "1.0.0-11599848164.commit-ef74edc", "@dcl/quests-client": "^1.0.3", "@dcl/quests-manager": "^0.1.4", "@dcl/rpc": "^1.1.1", diff --git a/test/ecs/components/PointerEvents.spec.ts b/test/ecs/components/PointerEvents.spec.ts index 17e1081fc..9ab62634c 100644 --- a/test/ecs/components/PointerEvents.spec.ts +++ b/test/ecs/components/PointerEvents.spec.ts @@ -14,7 +14,8 @@ describe('Generated OnPointerDown ProtoBuf', () => { button: 1, hoverText: 'Tap to run', maxDistance: 10, - showFeedback: true + showFeedback: true, + showHighlight: true } } ] @@ -28,7 +29,8 @@ describe('Generated OnPointerDown ProtoBuf', () => { button: InputAction.IA_ACTION_4, hoverText: 'Run to tap', maxDistance: 5, - showFeedback: false + showFeedback: false, + showHighlight: false } } ] @@ -51,7 +53,8 @@ describe('Generated OnPointerDown ProtoBuf', () => { button: InputAction.IA_ACTION_4, hoverText: 'Run to tap', maxDistance: 5, - showFeedback: false + showFeedback: false, + showHighlight: false } } ] diff --git a/test/ecs/events/system.spec.ts b/test/ecs/events/system.spec.ts index 2532b2a9d..807900a39 100644 --- a/test/ecs/events/system.spec.ts +++ b/test/ecs/events/system.spec.ts @@ -1,6 +1,10 @@ import { Engine, Entity, IEngine, components, PointerEventType, InputAction } from '../../../packages/@dcl/ecs/src' import { createInputSystem } from '../../../packages/@dcl/ecs/src/engine/input' -import { createPointerEventsSystem, PointerEventsSystem } from '../../../packages/@dcl/ecs/src/systems/events' +import { + createPointerEventsSystem, + getDefaultOpts, + PointerEventsSystem +} from '../../../packages/@dcl/ecs/src/systems/events' import { createTestPointerDownCommand } from './utils' let engine: IEngine @@ -69,7 +73,6 @@ describe('Events System', () => { expect(counter).toBe(1) const removedFeedback = PointerEvents.getOrNull(entity)?.pointerEvents expect(removedFeedback?.length).toBe(0) - // Update tick and verify we didnt increment the counter again await engine.update(1) expect(counter).toBe(1) @@ -79,17 +82,20 @@ describe('Events System', () => { const entity = engine.addEntity() const PointerEvents = components.PointerEvents(engine) let counter = 0 - EventsSystem.onPointerDown( - entity, - () => { - counter += 1 - }, - { hoverText: '' } - ) + EventsSystem.onPointerDown(entity, () => { + counter += 1 + }) fakePointer(entity, PointerEventType.PET_DOWN) await engine.update(1) expect(counter).toBe(1) - expect(PointerEvents.getOrNull(entity)).toBe(null) + expect(PointerEvents.getOrNull(entity)).toMatchObject({ + pointerEvents: [ + { + eventInfo: getDefaultOpts(), + eventType: 1 + } + ] + }) }) it('should remove pointer down', async () => { diff --git a/test/snapshots/package-lock.json b/test/snapshots/package-lock.json index 818683995..9ae988780 100644 --- a/test/snapshots/package-lock.json +++ b/test/snapshots/package-lock.json @@ -168,7 +168,7 @@ "@dcl/inspector": "file:../inspector", "@dcl/linker-dapp": "^0.14.2", "@dcl/mini-comms": "1.0.1-20230216163137.commit-a4c75be", - "@dcl/protocol": "1.0.0-10704143848.commit-a0c6d86", + "@dcl/protocol": "1.0.0-11599848164.commit-ef74edc", "@dcl/quests-client": "^1.0.3", "@dcl/quests-manager": "^0.1.4", "@dcl/rpc": "^1.1.1",