Skip to content

Commit

Permalink
Merge pull request #170 from fuag15/bugfix/auto_launch_smoketest_fixes
Browse files Browse the repository at this point in the history
had the wrong icons for the wrong states and never hooked up the hand…
  • Loading branch information
JoeLudwig authored Nov 18, 2020
2 parents 6703d63 + 1b8a92b commit 9a0daff
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 39 deletions.
5 changes: 5 additions & 0 deletions packages/aardvark-shared/src/aardvark_protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ export interface MsgInstallGadget
gadgetUri: string;
}

export interface MsgSetGadgetToAutoLaunch
{
gadgetUri: string;
}


export interface MsgResourceLoadFailed
{
Expand Down
21 changes: 14 additions & 7 deletions websrc/gadget_menu/src/gadget_menu_main.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiInterfaceSender, ActiveInterface, AvGadget, AvGadgetSeed, AvGrabButton, AvHeadFacingTransform, AvHighlightTransmitters, AvInterfaceEntity, AvLine, AvModel, AvOrigin, AvPanel, AvPrimitive, AvStandardGrabbable, AvTransform, GadgetInfoEvent, GadgetSeedHighlight, HiddenChildrenBehavior, k_GadgetInfoInterface, PrimitiveType, PrimitiveYOrigin, renderGadgetIcon, ShowGrabbableChildren, k_GadgetListInterface, GadgetListEventType, AvMessagebox, AvApiInterface, ApiInterfaceHandler, GadgetListResult, AvMenuItem, GrabbableStyle } from '@aardvarkxr/aardvark-react';
import { Av, WindowInfo, AvStartGadgetResult, AardvarkManifest, AvNodeTransform, AvVector, emptyVolume, EndpointAddr, g_builtinModelFlask, g_builtinModelRocketship, g_builtinModelBarcodeScanner, nodeTransformToMat4, nodeTransformFromMat4, g_builtinModelDropAttract, g_builtinModelNetwork, g_builtinModelHammerAndWrench, g_builtinModelStar, g_builtinModelTrashcan, MessageType, MsgDestroyGadget, rayVolume, MsgInstallGadget, g_builtinModelPanel, AvVolume, EVolumeType, g_builtinModelArrowFlat, g_builtinModelWindowIcon, infiniteVolume, endpointAddrToString, AvGadgetSettings } from '@aardvarkxr/aardvark-shared';
import { Av, WindowInfo, AvStartGadgetResult, AardvarkManifest, AvNodeTransform, AvVector, emptyVolume, EndpointAddr, g_builtinModelFlask, g_builtinModelRocketship, g_builtinModelBarcodeScanner, nodeTransformToMat4, nodeTransformFromMat4, g_builtinModelDropAttract, g_builtinModelNetwork, g_builtinModelHammerAndWrench, g_builtinModelStar, g_builtinModelTrashcan, MessageType, MsgDestroyGadget, rayVolume, MsgInstallGadget, MsgSetGadgetToAutoLaunch, g_builtinModelPanel, AvVolume, EVolumeType, g_builtinModelArrowFlat, g_builtinModelWindowIcon, infiniteVolume, endpointAddrToString, AvGadgetSettings } from '@aardvarkxr/aardvark-shared';
import { mat4, vec3, vec4 } from '@tlaukkan/tsm';
import Axios from 'axios';
import bind from 'bind-decorator';
Expand All @@ -17,12 +17,12 @@ interface Icon {
rotateX: number
}

const k_iconAutoLaunchActive: Icon = {
const k_iconAutoLaunchInactive: Icon = {
modelUri: g_builtinModelRocketship,
rotateX: 0
}

const k_iconAutoLaunchInactive: Icon = {
const k_iconAutoLaunchActive: Icon = {
modelUri: g_builtinModelTrashcan,
rotateX: 90
}
Expand Down Expand Up @@ -297,6 +297,7 @@ class ControlPanel extends React.Component< {}, ControlPanelState >
};

AvGadget.instance().registerMessageHandler( MessageType.InstallGadget, this.onWebFavorite );
AvGadget.instance().registerMessageHandler( MessageType.SetGadgetToAutoLaunch, this.onWebSetAutoLaunch );

let settingsString = window.localStorage.getItem( "aardvark_gadget_menu_settings" );
if( !settingsString )
Expand Down Expand Up @@ -872,13 +873,13 @@ class ControlPanel extends React.Component< {}, ControlPanelState >
{
if( this.settings.gadgetSettings[ gadget.url ]?.autoLaunchEnabled )
{
autoLaunchSet = false;
toggleAutoLaunchFn = () => { this.enableAutoLaunch( gadget.url ); }
autoLaunchSet = true;
toggleAutoLaunchFn = () => { this.removeAutoLaunch( gadget.url ); }
}
else
{
autoLaunchSet = true;
toggleAutoLaunchFn = () => { this.removeAutoLaunch( gadget.url ); }
autoLaunchSet = false;
toggleAutoLaunchFn = () => { this.enableAutoLaunch( gadget.url ); }
}
}

Expand Down Expand Up @@ -1118,6 +1119,12 @@ class ControlPanel extends React.Component< {}, ControlPanelState >
}

}

@bind
private onWebSetAutoLaunch( m: MsgSetGadgetToAutoLaunch )
{
this.enableAutoLaunch( m.gadgetUri );
}

@bind
private onWebFavorite( m: MsgInstallGadget )
Expand Down
43 changes: 12 additions & 31 deletions websrc/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion websrc/server/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AardvarkManifest, manifestUriFromGadgetUri, AardvarkPort, AvNode, AvNodeTransform, AvNodeType, EndpointAddr, endpointAddrsMatch, endpointAddrToString, EndpointType, ENodeFlags, Envelope, gadgetDetailsToId, MessageType, MsgDestroyGadget, MsgError, MsgGadgetStarted, MsgGeAardvarkManifestResponse, MsgGetAardvarkManifest, MsgGetInstalledGadgets, MsgGetInstalledGadgetsResponse, MsgInstallGadget, MsgInterfaceEnded, MsgInterfaceEvent, MsgInterfaceReceiveEvent, MsgInterfaceSendEvent, MsgInterfaceStarted, MsgInterfaceTransformUpdated, MsgLostEndpoint, MsgNewEndpoint, MsgNodeHaptic, MsgOverrideTransform, MsgResourceLoadFailed, MsgSaveSettings, MsgSetEndpointType, MsgSetEndpointTypeResponse, MsgUpdateActionState, MsgUpdateSceneGraph, parseEnvelope, Permission, WebSocketCloseCodes } from '@aardvarkxr/aardvark-shared';
import { AardvarkManifest, manifestUriFromGadgetUri, AardvarkPort, AvNode, AvNodeTransform, AvNodeType, EndpointAddr, endpointAddrsMatch, endpointAddrToString, EndpointType, ENodeFlags, Envelope, gadgetDetailsToId, MessageType, MsgDestroyGadget, MsgError, MsgGadgetStarted, MsgGeAardvarkManifestResponse, MsgGetAardvarkManifest, MsgGetInstalledGadgets, MsgGetInstalledGadgetsResponse, MsgInstallGadget, MsgInterfaceEnded, MsgInterfaceEvent, MsgInterfaceReceiveEvent, MsgInterfaceSendEvent, MsgInterfaceStarted, MsgInterfaceTransformUpdated, MsgLostEndpoint, MsgNewEndpoint, MsgNodeHaptic, MsgOverrideTransform, MsgResourceLoadFailed, MsgSaveSettings, MsgSetEndpointType, MsgSetEndpointTypeResponse, MsgUpdateActionState, MsgUpdateSceneGraph, parseEnvelope, Permission, WebSocketCloseCodes, MsgSetGadgetToAutoLaunch } from '@aardvarkxr/aardvark-shared';
import bind from 'bind-decorator';
import * as express from 'express';
import * as http from 'http';
Expand Down Expand Up @@ -628,6 +628,7 @@ class CEndpoint
this.registerEnvelopeHandler( MessageType.GetInstalledGadgets, this.onGetInstalledGadgets );
this.registerEnvelopeHandler( MessageType.DestroyGadget, this.onDestroyGadget );
this.registerEnvelopeHandler( MessageType.InstallGadget, this.onInstallGadget );
this.registerEnvelopeHandler( MessageType.SetGadgetToAutoLaunch, this.onSetGadgetToAutoLaunch );
}

public getId() { return this.m_id; }
Expand Down Expand Up @@ -918,6 +919,18 @@ class CEndpoint
}
}

@bind private onSetGadgetToAutoLaunch( env: Envelope, m: MsgSetGadgetToAutoLaunch )
{
console.log( `Setting gadget to Auto Launch from web ${ m.gadgetUri }` );
for( let gadget of this.m_dispatcher.getListForType( EndpointType.Gadget ) )
{
if( gadget.hasPermission( Permission.Favorites ) )
{
gadget.sendMessage( MessageType.SetGadgetToAutoLaunch, m );
}
}
}

public hasPermission( permissionName: Permission ): boolean
{
return this.getGadgetData() && this.getGadgetData().hasPermission( permissionName );
Expand Down

0 comments on commit 9a0daff

Please sign in to comment.