From ea5bea4a804a5f810ef5498f1dc0778cd766e3ee Mon Sep 17 00:00:00 2001 From: dank074 Date: Sun, 5 Dec 2021 00:27:15 -0600 Subject: [PATCH 1/3] fix floorplan touch interactions --- .../floorplan-editor/FloorplanEditorView.scss | 8 ++-- .../common/FloorplanEditor.ts | 4 +- .../views/FloorplanCanvasView.tsx | 38 ++++++++++++++++++- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/views/floorplan-editor/FloorplanEditorView.scss b/src/views/floorplan-editor/FloorplanEditorView.scss index 7bc41e59..dcacff14 100644 --- a/src/views/floorplan-editor/FloorplanEditorView.scss +++ b/src/views/floorplan-editor/FloorplanEditorView.scss @@ -9,9 +9,11 @@ overflow: scroll; } - .color { - height: 50px; - width: 10px; + .arrow-button { + + @include media-breakpoint-up(md) { + display:none; + } } } diff --git a/src/views/floorplan-editor/common/FloorplanEditor.ts b/src/views/floorplan-editor/common/FloorplanEditor.ts index 71fcbed9..7d1aad13 100644 --- a/src/views/floorplan-editor/common/FloorplanEditor.ts +++ b/src/views/floorplan-editor/common/FloorplanEditor.ts @@ -87,10 +87,10 @@ export class FloorplanEditor extends PixiApplicationProxy this._tilemapRenderer.on('pointerdown', (event: PixiInteractionEventProxy) => { - if(!(event.data.originalEvent instanceof PointerEvent)) return; + if(!(event.data.originalEvent instanceof PointerEvent) && !(event.data.originalEvent instanceof TouchEvent)) return; const pointerEvent = event.data.originalEvent; - if(pointerEvent.button === 2) return; + if((pointerEvent instanceof MouseEvent) && pointerEvent.button === 2) return; const location = event.data.global; diff --git a/src/views/floorplan-editor/views/FloorplanCanvasView.tsx b/src/views/floorplan-editor/views/FloorplanCanvasView.tsx index f68a9248..a52fae94 100644 --- a/src/views/floorplan-editor/views/FloorplanCanvasView.tsx +++ b/src/views/floorplan-editor/views/FloorplanCanvasView.tsx @@ -1,6 +1,7 @@ import { GetOccupiedTilesMessageComposer, GetRoomEntryTileMessageComposer, NitroPoint, RoomEntryTileMessageEvent, RoomOccupiedTilesMessageEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useRef, useState } from 'react'; import { CreateMessageHook, SendMessageHook, UseMountEffect } from '../../../hooks'; +import { NitroLayoutFlex } from '../../../layout'; import { FloorplanEditor } from '../common/FloorplanEditor'; import { useFloorplanEditorContext } from '../context/FloorplanEditorContext'; @@ -68,6 +69,29 @@ export const FloorplanCanvasView: FC<{}> = props => CreateMessageHook(RoomEntryTileMessageEvent, onRoomEntryTileMessageEvent); + const onClickArrowButton = useCallback((scrollDirection: string) => + { + const element = elementRef.current; + + if(!element) return; + + switch(scrollDirection) + { + case 'up': + element.scrollBy({ top: -10 }); + break; + case 'down': + element.scrollBy({ top: 10 }); + break; + case 'left': + element.scrollBy({ left: -10 }); + break; + case 'right': + element.scrollBy({ left: 10 }); + break; + } + }, []); + useEffect(() => { if(entryTileReceived && occupiedTilesReceived) @@ -75,6 +99,18 @@ export const FloorplanCanvasView: FC<{}> = props => }, [entryTileReceived, occupiedTilesReceived]) return ( -
+ <> + +
+
+ +
+
+
+ + +
+
+ ); } From 7cb42452078c1e49dd6e20a0ede4f05e4fa53842 Mon Sep 17 00:00:00 2001 From: dank074 Date: Sun, 5 Dec 2021 20:29:23 -0600 Subject: [PATCH 2/3] add habblet link handler --- src/views/main/MainView.tsx | 41 +++++++++++++++++++++++++-- src/views/navigator/NavigatorView.tsx | 13 ++++++++- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/views/main/MainView.tsx b/src/views/main/MainView.tsx index 5cd09f84..a01a09c7 100644 --- a/src/views/main/MainView.tsx +++ b/src/views/main/MainView.tsx @@ -1,6 +1,6 @@ -import { RoomSessionEvent } from '@nitrots/nitro-renderer'; +import { HabboWebTools, RoomSessionEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; -import { GetCommunication } from '../../api'; +import { AddEventLinkTracker, GetCommunication, RemoveLinkEventTracker } from '../../api'; import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event'; import { TransitionAnimation, TransitionAnimationTypes } from '../../layout'; import { AchievementsView } from '../achievements/AchievementsView'; @@ -46,6 +46,32 @@ export const MainView: FC = props => useRoomSessionManagerEvent(RoomSessionEvent.CREATED, onRoomSessionEvent); useRoomSessionManagerEvent(RoomSessionEvent.ENDED, onRoomSessionEvent); + const onLinkReceived = useCallback((link: string) => + { + const parts = link.split('/'); + + if(parts.length < 2) return; + + switch(parts[1]) + { + case 'open': + if(parts.length > 2) + { + switch(parts[2]) + { + case 'credits': + //HabboWebTools.openWebPageAndMinimizeClient(this._windowManager.getProperty(ExternalVariables.WEB_SHOP_RELATIVE_URL)); + break; + default: { + const name = parts[2]; + HabboWebTools.openHabblet(name); + } + } + } + return; + } + }, []); + useEffect(() => { setIsReady(true); @@ -53,6 +79,17 @@ export const MainView: FC = props => GetCommunication().connection.onReady(); }, []); + useEffect(() => + { + const linkTracker = { linkReceived: onLinkReceived, eventUrlPrefix: 'habblet/' }; + AddEventLinkTracker(linkTracker); + + return () => + { + RemoveLinkEventTracker(linkTracker); + } + }, [onLinkReceived]); + return (
diff --git a/src/views/navigator/NavigatorView.tsx b/src/views/navigator/NavigatorView.tsx index d26d9147..62f8acad 100644 --- a/src/views/navigator/NavigatorView.tsx +++ b/src/views/navigator/NavigatorView.tsx @@ -1,7 +1,8 @@ -import { ILinkEventTracker, NavigatorInitComposer, NavigatorSearchComposer, RoomDataParser, RoomSessionEvent } from '@nitrots/nitro-renderer'; +import { ConvertGlobalRoomIdMessageComposer, HabboWebTools, ILinkEventTracker, LegacyExternalInterface, NavigatorInitComposer, NavigatorSearchComposer, RoomDataParser, RoomSessionEvent } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useMemo, useReducer, useState } from 'react'; import { AddEventLinkTracker, GoToDesktop, LocalizeText, RemoveLinkEventTracker, TryVisitRoom } from '../../api'; import { NavigatorEvent, UpdateDoorStateEvent } from '../../events'; +import { UseMountEffect } from '../../hooks'; import { useRoomSessionManagerEvent } from '../../hooks/events/nitro/session/room-session-manager-event'; import { useUiEvent } from '../../hooks/events/ui/ui-event'; import { SendMessageHook } from '../../hooks/messages/message-event'; @@ -181,6 +182,16 @@ export const NavigatorView: FC = props => return () => RemoveLinkEventTracker(linkTracker); }, [ linkReceived]); + const enterRoomWebRequest = useCallback((k: string, _arg_2:boolean=false, _arg_3:string=null) => + { + SendMessageHook(new ConvertGlobalRoomIdMessageComposer(k)); + }, []); + + UseMountEffect(() => + { + LegacyExternalInterface.addCallback(HabboWebTools.OPENROOM, enterRoomWebRequest); + }); + useEffect(() => { if(!isVisible || !needsNavigatorUpdate) return; From 2fd73efa1dbb62fba6f0a5b7accc086d5094a092 Mon Sep 17 00:00:00 2001 From: dank074 Date: Wed, 8 Dec 2021 02:20:00 -0600 Subject: [PATCH 3/3] updated renderer packet --- .../views/groups-container/GroupsContainerView.tsx | 8 ++++---- .../views/groups-container/GroupsContainerView.types.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/views/user-profile/views/groups-container/GroupsContainerView.tsx b/src/views/user-profile/views/groups-container/GroupsContainerView.tsx index a5dcb17f..92fdf691 100644 --- a/src/views/user-profile/views/groups-container/GroupsContainerView.tsx +++ b/src/views/user-profile/views/groups-container/GroupsContainerView.tsx @@ -28,7 +28,7 @@ export const GroupsContainerView: FC = props => useEffect(() => { - if(groups.length > 0 && !selectedGroupId) setSelectedGroupId(groups[0].id); + if(groups.length > 0 && !selectedGroupId) setSelectedGroupId(groups[0].groupId); }, [ groups, selectedGroupId ]); useEffect(() => @@ -49,9 +49,9 @@ export const GroupsContainerView: FC = props =>
{ groups.map((group, index) => { - return
setSelectedGroupId(group.id) } className={ 'profile-groups-item position-relative flex-shrink-0 d-flex align-items-center justify-content-center cursor-pointer' + classNames({ ' active': selectedGroupId === group.id }) }> - { itsMe && favoriteGroup(group.id) } /> } - + return
setSelectedGroupId(group.groupId) } className={ 'profile-groups-item position-relative flex-shrink-0 d-flex align-items-center justify-content-center cursor-pointer' + classNames({ ' active': selectedGroupId === group.groupId }) }> + { itsMe && favoriteGroup(group.groupId) } /> } +
}) }
diff --git a/src/views/user-profile/views/groups-container/GroupsContainerView.types.ts b/src/views/user-profile/views/groups-container/GroupsContainerView.types.ts index 40b273af..0bfdf75e 100644 --- a/src/views/user-profile/views/groups-container/GroupsContainerView.types.ts +++ b/src/views/user-profile/views/groups-container/GroupsContainerView.types.ts @@ -1,8 +1,8 @@ -import { GroupDataParser } from '@nitrots/nitro-renderer'; +import { HabboGroupEntryData } from '@nitrots/nitro-renderer'; export interface GroupsContainerViewProps { itsMe: boolean; - groups: GroupDataParser[]; + groups: HabboGroupEntryData[]; onLeaveGroup: () => void; }