From f561b91e2fc17120d75b37bdc93f9fb6966186d0 Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 5 Jun 2021 23:48:44 -0400 Subject: [PATCH 1/5] Update packets --- src/nitro/communication/NitroMessages.ts | 3 +- .../messages/incoming/IncomingHeader.ts | 1 + .../incoming/room/engine/ObjectData.ts | 30 ++++++++++++++ .../room/engine/ObjectsDataUpdateEvent.ts | 16 ++++++++ .../messages/incoming/room/engine/index.ts | 2 + .../room/engine/ObjectsDataUpdateParser.ts | 41 +++++++++++++++++++ .../room/engine/ObjectsRollingParser.ts | 4 +- .../parser/room/engine/RoomCreatedParser.ts | 4 +- .../messages/parser/room/engine/index.ts | 1 + .../subscription/UserSubscriptionParser.ts | 23 ++++++----- src/nitro/room/RoomMessageHandler.ts | 16 ++++++++ 11 files changed, 125 insertions(+), 16 deletions(-) create mode 100644 src/nitro/communication/messages/incoming/room/engine/ObjectData.ts create mode 100644 src/nitro/communication/messages/incoming/room/engine/ObjectsDataUpdateEvent.ts create mode 100644 src/nitro/communication/messages/parser/room/engine/ObjectsDataUpdateParser.ts diff --git a/src/nitro/communication/NitroMessages.ts b/src/nitro/communication/NitroMessages.ts index 54ad2d5e..0d71f390 100644 --- a/src/nitro/communication/NitroMessages.ts +++ b/src/nitro/communication/NitroMessages.ts @@ -1,5 +1,5 @@ import { IMessageConfiguration } from '../../core/communication/messages/IMessageConfiguration'; -import { ApproveNameMessageComposer, CatalogApproveNameResultEvent, SellablePetPalettesEvent } from './messages'; +import { ApproveNameMessageComposer, CatalogApproveNameResultEvent, ObjectsDataUpdateEvent, SellablePetPalettesEvent } from './messages'; import { AvailabilityStatusMessageEvent } from './messages/incoming/availability/AvailabilityStatusMessageEvent'; import { ChangeNameUpdateEvent } from './messages/incoming/avatar/ChangeNameUpdateEvent'; import { CatalogClubEvent } from './messages/incoming/catalog/CatalogClubEvent'; @@ -593,6 +593,7 @@ export class NitroMessages implements IMessageConfiguration this._events.set(IncomingHeader.LOVELOCK_FURNI_FINISHED, LoveLockFurniFinishedEvent); this._events.set(IncomingHeader.LOVELOCK_FURNI_FRIEND_COMFIRMED, LoveLockFurniFriendConfirmedEvent); this._events.set(IncomingHeader.LOVELOCK_FURNI_START, LoveLockFurniStartEvent); + this._events.set(IncomingHeader.OBJECTS_DATA_UPDATE, ObjectsDataUpdateEvent); // FLOOR this._events.set(IncomingHeader.FURNITURE_FLOOR_ADD, FurnitureFloorAddEvent); diff --git a/src/nitro/communication/messages/incoming/IncomingHeader.ts b/src/nitro/communication/messages/incoming/IncomingHeader.ts index 35522812..fac838bb 100644 --- a/src/nitro/communication/messages/incoming/IncomingHeader.ts +++ b/src/nitro/communication/messages/incoming/IncomingHeader.ts @@ -247,4 +247,5 @@ export class IncomingHeader public static MARKETPLACE_AFTER_ORDER_STATUS = 2032; public static CATALOG_RECEIVE_PET_BREEDS = 3331; public static CATALOG_APPROVE_NAME_RESULT = 1503; + public static OBJECTS_DATA_UPDATE = 1453; } diff --git a/src/nitro/communication/messages/incoming/room/engine/ObjectData.ts b/src/nitro/communication/messages/incoming/room/engine/ObjectData.ts new file mode 100644 index 00000000..64a6fe46 --- /dev/null +++ b/src/nitro/communication/messages/incoming/room/engine/ObjectData.ts @@ -0,0 +1,30 @@ +import { IObjectData } from '../../../../../room'; + +export class ObjectData +{ + private _id: number = 0; + private _state: number = 0; + private _data: IObjectData; + + constructor(id: number, state: number, objectData: IObjectData) + { + this._id = id; + this._state = state; + this._data = objectData; + } + + public get id(): number + { + return this._id; + } + + public get state(): number + { + return this._state; + } + + public get data(): IObjectData + { + return this._data; + } +} diff --git a/src/nitro/communication/messages/incoming/room/engine/ObjectsDataUpdateEvent.ts b/src/nitro/communication/messages/incoming/room/engine/ObjectsDataUpdateEvent.ts new file mode 100644 index 00000000..2a6035a2 --- /dev/null +++ b/src/nitro/communication/messages/incoming/room/engine/ObjectsDataUpdateEvent.ts @@ -0,0 +1,16 @@ +import { IMessageEvent } from '../../../../../../core/communication/messages/IMessageEvent'; +import { MessageEvent } from '../../../../../../core/communication/messages/MessageEvent'; +import { ObjectsDataUpdateParser } from '../../../parser/room/engine/ObjectsDataUpdateParser'; + +export class ObjectsDataUpdateEvent extends MessageEvent implements IMessageEvent +{ + constructor(callBack: Function) + { + super(callBack, ObjectsDataUpdateParser); + } + + public getParser(): ObjectsDataUpdateParser + { + return this.parser as ObjectsDataUpdateParser; + } +} diff --git a/src/nitro/communication/messages/incoming/room/engine/index.ts b/src/nitro/communication/messages/incoming/room/engine/index.ts index efa236d4..efc44418 100644 --- a/src/nitro/communication/messages/incoming/room/engine/index.ts +++ b/src/nitro/communication/messages/incoming/room/engine/index.ts @@ -1,2 +1,4 @@ +export * from './ObjectData'; +export * from './ObjectsDataUpdateEvent'; export * from './ObjectsRollingEvent'; export * from './RoomCreatedEvent'; diff --git a/src/nitro/communication/messages/parser/room/engine/ObjectsDataUpdateParser.ts b/src/nitro/communication/messages/parser/room/engine/ObjectsDataUpdateParser.ts new file mode 100644 index 00000000..2fc9ce0c --- /dev/null +++ b/src/nitro/communication/messages/parser/room/engine/ObjectsDataUpdateParser.ts @@ -0,0 +1,41 @@ +import { IMessageDataWrapper } from '../../../../../../core/communication/messages/IMessageDataWrapper'; +import { IMessageParser } from '../../../../../../core/communication/messages/IMessageParser'; +import { ObjectData } from '../../../incoming/room/engine/ObjectData'; +import { FurnitureDataParser } from '../furniture/FurnitureDataParser'; + +export class ObjectsDataUpdateParser implements IMessageParser +{ + private _objects: ObjectData[]; + + public flush(): boolean + { + this._objects = []; + + return true; + } + + public parse(wrapper: IMessageDataWrapper): boolean + { + if(!wrapper) return false; + + let totalObjects = wrapper.readInt(); + + while(totalObjects > 0) + { + const id = wrapper.readInt(); + const stuffData = FurnitureDataParser.parseObjectData(wrapper); + const state = parseFloat(stuffData.getLegacyString()); + + this._objects.push(new ObjectData(id, state, stuffData)); + + totalObjects--; + } + + return true; + } + + public get objects(): ObjectData[] + { + return this._objects; + } +} diff --git a/src/nitro/communication/messages/parser/room/engine/ObjectsRollingParser.ts b/src/nitro/communication/messages/parser/room/engine/ObjectsRollingParser.ts index 4e971c31..925b4f95 100644 --- a/src/nitro/communication/messages/parser/room/engine/ObjectsRollingParser.ts +++ b/src/nitro/communication/messages/parser/room/engine/ObjectsRollingParser.ts @@ -21,7 +21,7 @@ export class ObjectsRollingParser implements IMessageParser public parse(wrapper: IMessageDataWrapper): boolean { - if(!wrapper) return; + if(!wrapper) return false; const x = wrapper.readInt(); const y = wrapper.readInt(); @@ -79,4 +79,4 @@ export class ObjectsRollingParser implements IMessageParser { return this._unitRolling; } -} \ No newline at end of file +} diff --git a/src/nitro/communication/messages/parser/room/engine/RoomCreatedParser.ts b/src/nitro/communication/messages/parser/room/engine/RoomCreatedParser.ts index 4e14ece8..7b524d74 100644 --- a/src/nitro/communication/messages/parser/room/engine/RoomCreatedParser.ts +++ b/src/nitro/communication/messages/parser/room/engine/RoomCreatedParser.ts @@ -16,7 +16,7 @@ export class RoomCreatedParser implements IMessageParser public parse(wrapper: IMessageDataWrapper): boolean { - if(!wrapper) return; + if(!wrapper) return false; this._roomId = wrapper.readInt(); this._roomName = wrapper.readString(); @@ -33,4 +33,4 @@ export class RoomCreatedParser implements IMessageParser { return this._roomName; } -} \ No newline at end of file +} diff --git a/src/nitro/communication/messages/parser/room/engine/index.ts b/src/nitro/communication/messages/parser/room/engine/index.ts index faa96179..775700d3 100644 --- a/src/nitro/communication/messages/parser/room/engine/index.ts +++ b/src/nitro/communication/messages/parser/room/engine/index.ts @@ -1,2 +1,3 @@ +export * from './ObjectsDataUpdateParser'; export * from './ObjectsRollingParser'; export * from './RoomCreatedParser'; diff --git a/src/nitro/communication/messages/parser/user/inventory/subscription/UserSubscriptionParser.ts b/src/nitro/communication/messages/parser/user/inventory/subscription/UserSubscriptionParser.ts index 9d9cdcf2..f47ab7af 100644 --- a/src/nitro/communication/messages/parser/user/inventory/subscription/UserSubscriptionParser.ts +++ b/src/nitro/communication/messages/parser/user/inventory/subscription/UserSubscriptionParser.ts @@ -18,16 +18,16 @@ export class UserSubscriptionParser implements IMessageParser public flush(): boolean { - this._name = null; - this._days = 0; - this._int1 = 0; - this._months = 0; - this._years = 0; - this._hasEverBeenMember = false; - this._isVip = false; - this._pastClubDays = 0; - this._pastVIPDays = 0; - this._totalSeconds = 0; + this._name = null; + this._days = 0; + this._int1 = 0; + this._months = 0; + this._years = 0; + this._hasEverBeenMember = false; + this._isVip = false; + this._pastClubDays = 0; + this._pastVIPDays = 0; + this._totalSeconds = 0; return true; } @@ -45,7 +45,8 @@ export class UserSubscriptionParser implements IMessageParser this._isVip = wrapper.readBoolean(); this._pastClubDays = wrapper.readInt(); this._pastVIPDays = wrapper.readInt(); - this._totalSeconds = wrapper.readInt(); + + if(wrapper.bytesAvailable) this._totalSeconds = wrapper.readInt(); return true; } diff --git a/src/nitro/room/RoomMessageHandler.ts b/src/nitro/room/RoomMessageHandler.ts index f04469aa..8cc609dd 100644 --- a/src/nitro/room/RoomMessageHandler.ts +++ b/src/nitro/room/RoomMessageHandler.ts @@ -3,6 +3,7 @@ import { IConnection } from '../../core/communication/connections/IConnection'; import { IVector3D } from '../../room/utils/IVector3D'; import { Vector3d } from '../../room/utils/Vector3d'; import { PetType } from '../avatar/pets/PetType'; +import { ObjectsDataUpdateEvent } from '../communication'; import { ObjectsRollingEvent } from '../communication/messages/incoming/room/engine/ObjectsRollingEvent'; import { FurnitureFloorAddEvent } from '../communication/messages/incoming/room/furniture/floor/FurnitureFloorAddEvent'; import { FurnitureFloorEvent } from '../communication/messages/incoming/room/furniture/floor/FurnitureFloorEvent'; @@ -113,6 +114,7 @@ export class RoomMessageHandler extends Disposable this._connection.addMessageEvent(new RoomThicknessEvent(this.onRoomThicknessEvent.bind(this))); this._connection.addMessageEvent(new RoomDoorEvent(this.onRoomDoorEvent.bind(this))); this._connection.addMessageEvent(new ObjectsRollingEvent(this.onRoomRollingEvent.bind(this))); + this._connection.addMessageEvent(new ObjectsDataUpdateEvent(this.onObjectsDataUpdateEvent.bind(this))); this._connection.addMessageEvent(new FurnitureAliasesEvent(this.onFurnitureAliasesEvent.bind(this))); this._connection.addMessageEvent(new FurnitureFloorAddEvent(this.onFurnitureFloorAddEvent.bind(this))); this._connection.addMessageEvent(new FurnitureFloorEvent(this.onFurnitureFloorEvent.bind(this))); @@ -459,6 +461,20 @@ export class RoomMessageHandler extends Disposable } } + private onObjectsDataUpdateEvent(event: ObjectsDataUpdateEvent): void + { + if(!(event instanceof ObjectsDataUpdateEvent) || !event.connection || !this._roomCreator) return; + + const parser = event.getParser(); + + if(!parser) return; + + for(const object of parser.objects) + { + this._roomCreator.updateRoomObjectFloor(this._currentRoomId, object.id, null, null, object.state, object.data); + } + } + private onFurnitureAliasesEvent(event: FurnitureAliasesEvent): void { if(!(event instanceof FurnitureAliasesEvent) || !event.connection || !this._roomCreator) return; From 56ef76361bf15130a6a14148e9b5cb2f7adbe4e6 Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 5 Jun 2021 23:48:53 -0400 Subject: [PATCH 2/5] Update localization --- .../localization/NitroLocalizationManager.ts | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/nitro/localization/NitroLocalizationManager.ts b/src/nitro/localization/NitroLocalizationManager.ts index 848d8db1..5af66058 100644 --- a/src/nitro/localization/NitroLocalizationManager.ts +++ b/src/nitro/localization/NitroLocalizationManager.ts @@ -153,7 +153,48 @@ export class NitroLocalizationManager extends NitroManager implements INitroLoca { for(let i = 0; i < parameters.length; i++) { - value = value.replace('%' + parameters[i] + '%', replacements[i]); + const parameter = parameters[i]; + const replacement = replacements[i]; + + value = value.replace('%' + parameter + '%', replacement); + + if(value.startsWith('%{')) + { + const regex = new RegExp('%{' + parameter.toUpperCase() + '\\|([^|]*)\\|([^|]*)\\|([^|]*)}'); + const result = value.match(regex); + + if(!result) continue; + + const replacementAsNumber = parseInt(replacement); + + let indexKey = -1; + let replace = false; + + switch(replacementAsNumber) + { + case 0: + indexKey = 1; + break; + case 1: + indexKey = 2; + break; + case 2: + default: + indexKey = 3; + replace = true; + break; + } + + + if((indexKey === -1) || (typeof result[indexKey] === 'undefined')) continue; + + const valueFromResults = result[indexKey]; + + if(valueFromResults) + { + value = valueFromResults.replace('%%', replacement); + } + } } } From c56f0d86c1af2c1c95d750d7592c59c415e94abf Mon Sep 17 00:00:00 2001 From: Bill Date: Thu, 10 Jun 2021 03:02:26 -0400 Subject: [PATCH 3/5] FPS update --- src/nitro/Nitro.ts | 2 +- src/room/renderer/RoomSpriteCanvas.ts | 81 ++++++++++++++++----------- 2 files changed, 49 insertions(+), 34 deletions(-) diff --git a/src/nitro/Nitro.ts b/src/nitro/Nitro.ts index 4f8fa875..a286a053 100644 --- a/src/nitro/Nitro.ts +++ b/src/nitro/Nitro.ts @@ -221,7 +221,7 @@ export class Nitro extends Application implements INitro const animationFPS = this.getConfiguration('animation.fps', 24); const limitsFPS = this.getConfiguration('limits.fps', true); - Nitro.instance.ticker.maxFPS = animationFPS; + if(limitsFPS) Nitro.instance.ticker.maxFPS = animationFPS; } private onRoomEngineReady(event: RoomEngineEvent): void diff --git a/src/room/renderer/RoomSpriteCanvas.ts b/src/room/renderer/RoomSpriteCanvas.ts index e9b25172..09912b3d 100644 --- a/src/room/renderer/RoomSpriteCanvas.ts +++ b/src/room/renderer/RoomSpriteCanvas.ts @@ -26,7 +26,10 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas private _container: IRoomSpriteCanvasContainer; private _geometry: RoomGeometry; + private _animationFPS: number; private _renderTimestamp: number; + private _totalTimeRunning: number; + private _lastFrame: number; private _master: Sprite; private _display: Container; @@ -71,7 +74,10 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas this._container = container; this._geometry = new RoomGeometry(scale, new Vector3d(-135, 30, 0), new Vector3d(11, 11, 5), new Vector3d(-135, 0.5, 0)); + this._animationFPS = Nitro.instance.getConfiguration('animation.fps', 24); this._renderTimestamp = 0; + this._totalTimeRunning = 0; + this._lastFrame = 0; this._master = null; this._display = null; @@ -321,12 +327,14 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas { this._canvasUpdated = false; + this._totalTimeRunning += Nitro.instance.ticker.deltaTime; + + if(this._totalTimeRunning === this._renderTimestamp) return; + if(time === -1) time = (this._renderTimestamp + 1); if(!this._container || !this._geometry) return; - if(time === this._renderTimestamp) return; - if((this._width !== this._renderedWidth) || (this._height !== this._renderedHeight)) update = true; if((this._display.x !== this._screenOffsetX) || (this._display.y !== this._screenOffsetY)) @@ -344,46 +352,53 @@ export class RoomSpriteCanvas implements IRoomRenderingCanvas update = true; } - let spriteCount = 0; + const frame = Math.round(this._totalTimeRunning / (60 / this._animationFPS)); - const objects = this._container.objects; - - if(objects.size) + if(frame !== this._lastFrame) { - for(const object of objects.values()) + this._lastFrame = frame; + + let spriteCount = 0; + + const objects = this._container.objects; + + if(objects.size) { - if(!object) continue; + for(const object of objects.values()) + { + if(!object) continue; - spriteCount = (spriteCount + this.renderObject(object, object.instanceId.toString(), time, update, spriteCount)); + spriteCount = (spriteCount + this.renderObject(object, object.instanceId.toString(), time, update, spriteCount)); + } } + + this._sortableSprites.sort((a, b) => + { + return b.z - a.z; + }); + + if(spriteCount < this._sortableSprites.length) + { + this._sortableSprites.splice(spriteCount); + } + + let iterator = 0; + + while(iterator < spriteCount) + { + const sprite = this._sortableSprites[iterator]; + + if(sprite && sprite.sprite) this.renderSprite(iterator, sprite); + + iterator++; + } + + this._Str_20677(spriteCount); } - this._sortableSprites.sort((a, b) => - { - return b.z - a.z; - }); - - if(spriteCount < this._sortableSprites.length) - { - this._sortableSprites.splice(spriteCount); - } - - let iterator = 0; - - while(iterator < spriteCount) - { - const sprite = this._sortableSprites[iterator]; - - if(sprite && sprite.sprite) this.renderSprite(iterator, sprite); - - iterator++; - } - - this._Str_20677(spriteCount); - if(update) this._canvasUpdated = true; - this._renderTimestamp = time; + this._renderTimestamp = this._totalTimeRunning; this._renderedWidth = this._width; this._renderedHeight = this._height; } From 4b85e85626c36b09e322361b30255628a228b250 Mon Sep 17 00:00:00 2001 From: Bill Date: Thu, 10 Jun 2021 03:02:59 -0400 Subject: [PATCH 4/5] Add long touch/mouse events --- src/nitro/room/RoomEngine.ts | 8 +++-- src/nitro/room/RoomObjectEventHandler.ts | 29 +++++++++++++++++++ .../room/events/RoomEngineObjectEvent.ts | 25 ++++++++-------- .../object/logic/furniture/FurnitureLogic.ts | 12 ++++++-- src/nitro/ui/MouseEventType.ts | 3 +- src/nitro/ui/TouchEventType.ts | 3 +- src/room/events/RoomObjectMouseEvent.ts | 17 ++++++----- 7 files changed, 70 insertions(+), 27 deletions(-) diff --git a/src/nitro/room/RoomEngine.ts b/src/nitro/room/RoomEngine.ts index d54ff4a5..2dfd98ee 100644 --- a/src/nitro/room/RoomEngine.ts +++ b/src/nitro/room/RoomEngine.ts @@ -2476,6 +2476,8 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato else if(type === MouseEventType.MOUSE_DOWN) eventType = RoomObjectMouseEvent.MOUSE_DOWN; + else if(type === MouseEventType.MOUSE_DOWN_LONG) eventType = RoomObjectMouseEvent.MOUSE_DOWN_LONG; + else if(type === MouseEventType.MOUSE_UP) eventType = RoomObjectMouseEvent.MOUSE_UP; } @@ -2483,9 +2485,9 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato } } - this._activeRoomActiveCanvas = canvasId; - this._activeRoomActiveCanvasMouseX = x; - this._activeRoomActiveCanvasMouseY = y; + this._activeRoomActiveCanvas = canvasId; + this._activeRoomActiveCanvasMouseX = x; + this._activeRoomActiveCanvasMouseY = y; } private _Str_25871(canvas: IRoomRenderingCanvas, x: number, y: number, type: string, altKey: boolean, ctrlKey: boolean, shiftKey: boolean): boolean diff --git a/src/nitro/room/RoomObjectEventHandler.ts b/src/nitro/room/RoomObjectEventHandler.ts index 58a20147..18ce0f1b 100644 --- a/src/nitro/room/RoomObjectEventHandler.ts +++ b/src/nitro/room/RoomObjectEventHandler.ts @@ -338,6 +338,9 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou case RoomObjectMouseEvent.MOUSE_DOWN: this.handleRoomObjectMouseDownEvent(event, roomId); return; + case RoomObjectMouseEvent.MOUSE_DOWN_LONG: + this.handleRoomObjectMouseDownLongEvent(event, roomId); + return; case RoomObjectMouseEvent.MOUSE_ENTER: this.handleRoomObjectMouseEnterEvent(event, roomId); return; @@ -605,6 +608,32 @@ export class RoomObjectEventHandler extends Disposable implements IRoomCanvasMou } } + private handleRoomObjectMouseDownLongEvent(event: RoomObjectMouseEvent, roomId: number): void + { + if(!event) return; + + let operation = RoomObjectOperationType.OBJECT_UNDEFINED; + + const selectedData = this.getSelectedRoomObjectData(roomId); + + if(selectedData) operation = selectedData.operation; + + const category = this._roomEngine.getRoomObjectCategoryForType(event.objectType); + + switch(operation) + { + case RoomObjectOperationType.OBJECT_UNDEFINED: + if((category === RoomObjectCategory.FLOOR) || (category === RoomObjectCategory.WALL) || (event.objectType === RoomObjectUserType.MONSTER_PLANT)) + { + if((!event.ctrlKey && !event.shiftKey) || this._Str_25211(event)) + { + if(this._roomEngine.events) this._roomEngine.events.dispatchEvent(new RoomEngineObjectEvent(RoomEngineObjectEvent.REQUEST_MANIPULATION, roomId, event.objectId, category)); + } + } + return; + } + } + private handleRoomObjectMouseEnterEvent(event: RoomObjectMouseEvent, roomId: number): void { const id = event.objectId; diff --git a/src/nitro/room/events/RoomEngineObjectEvent.ts b/src/nitro/room/events/RoomEngineObjectEvent.ts index 04f78656..ac88815f 100644 --- a/src/nitro/room/events/RoomEngineObjectEvent.ts +++ b/src/nitro/room/events/RoomEngineObjectEvent.ts @@ -2,17 +2,18 @@ import { RoomEngineEvent } from './RoomEngineEvent'; export class RoomEngineObjectEvent extends RoomEngineEvent { - public static SELECTED: string = 'REOE_SELECTED'; - public static DESELECTED: string = 'REOE_DESELECTED'; - public static ADDED: string = 'REOE_ADDED'; - public static REMOVED: string = 'REOE_REMOVED'; - public static PLACED: string = 'REOE_PLACED'; - public static PLACED_ON_USER: string = 'REOE_PLACED_ON_USER'; - public static CONTENT_UPDATED: string = 'REOE_CONTENT_UPDATED'; - public static REQUEST_MOVE: string = 'REOE_REQUEST_MOVE'; - public static REQUEST_ROTATE: string = 'REOE_REQUEST_ROTATE'; - public static MOUSE_ENTER: string = 'REOE_MOUSE_ENTER'; - public static MOUSE_LEAVE: string = 'REOE_MOUSE_LEAVE'; + public static SELECTED: string = 'REOE_SELECTED'; + public static DESELECTED: string = 'REOE_DESELECTED'; + public static ADDED: string = 'REOE_ADDED'; + public static REMOVED: string = 'REOE_REMOVED'; + public static PLACED: string = 'REOE_PLACED'; + public static PLACED_ON_USER: string = 'REOE_PLACED_ON_USER'; + public static CONTENT_UPDATED: string = 'REOE_CONTENT_UPDATED'; + public static REQUEST_MOVE: string = 'REOE_REQUEST_MOVE'; + public static REQUEST_ROTATE: string = 'REOE_REQUEST_ROTATE'; + public static REQUEST_MANIPULATION: string = 'REOE_REQUEST_MANIPULATION'; + public static MOUSE_ENTER: string = 'REOE_MOUSE_ENTER'; + public static MOUSE_LEAVE: string = 'REOE_MOUSE_LEAVE'; private _objectId: number; private _category: number; @@ -34,4 +35,4 @@ export class RoomEngineObjectEvent extends RoomEngineEvent { return this._category; } -} \ No newline at end of file +} diff --git a/src/nitro/room/object/logic/furniture/FurnitureLogic.ts b/src/nitro/room/object/logic/furniture/FurnitureLogic.ts index c3e70a6d..db82ca0c 100644 --- a/src/nitro/room/object/logic/furniture/FurnitureLogic.ts +++ b/src/nitro/room/object/logic/furniture/FurnitureLogic.ts @@ -62,7 +62,7 @@ export class FurnitureLogic extends MovingObjectLogic public getEventTypes(): string[] { - const types = [ RoomObjectStateChangedEvent.STATE_CHANGE, RoomObjectMouseEvent.CLICK, RoomObjectMouseEvent.MOUSE_DOWN ]; + const types = [ RoomObjectStateChangedEvent.STATE_CHANGE, RoomObjectMouseEvent.CLICK, RoomObjectMouseEvent.MOUSE_DOWN, RoomObjectMouseEvent.MOUSE_DOWN_LONG ]; if(this.widget) types.push(RoomObjectWidgetRequestEvent.OPEN_WIDGET, RoomObjectWidgetRequestEvent.CLOSE_WIDGET); @@ -316,6 +316,14 @@ export class FurnitureLogic extends MovingObjectLogic this.eventDispatcher.dispatchEvent(mouseEvent); } return; + case MouseEventType.MOUSE_DOWN_LONG: + if(this.eventDispatcher) + { + const mouseEvent = new RoomObjectMouseEvent(RoomObjectMouseEvent.MOUSE_DOWN_LONG, this.object, event._Str_3463, event.altKey, event.ctrlKey, event.shiftKey, event.buttonDown); + + this.eventDispatcher.dispatchEvent(mouseEvent); + } + return; } } @@ -371,4 +379,4 @@ export class FurnitureLogic extends MovingObjectLogic super.tearDown(); } -} \ No newline at end of file +} diff --git a/src/nitro/ui/MouseEventType.ts b/src/nitro/ui/MouseEventType.ts index 4d5c7f19..f7b0892e 100644 --- a/src/nitro/ui/MouseEventType.ts +++ b/src/nitro/ui/MouseEventType.ts @@ -4,7 +4,8 @@ export class MouseEventType public static DOUBLE_CLICK: string = 'double_click'; public static MOUSE_MOVE: string = 'mousemove'; public static MOUSE_DOWN: string = 'mousedown'; + public static MOUSE_DOWN_LONG: string = 'mousedown_long'; public static MOUSE_UP: string = 'mouseup'; public static ROLL_OVER: string = 'mouseover'; public static ROLL_OUT: string = 'mouseout'; -} \ No newline at end of file +} diff --git a/src/nitro/ui/TouchEventType.ts b/src/nitro/ui/TouchEventType.ts index 4f903421..0944c48f 100644 --- a/src/nitro/ui/TouchEventType.ts +++ b/src/nitro/ui/TouchEventType.ts @@ -4,4 +4,5 @@ export class TouchEventType public static TOUCH_MOVE: string = 'touchmove'; public static TOUCH_CANCEL: string = 'touchcancel'; public static TOUCH_END: string = 'touchend'; -} \ No newline at end of file + public static TOUCH_LONG: string = 'touchlong'; +} diff --git a/src/room/events/RoomObjectMouseEvent.ts b/src/room/events/RoomObjectMouseEvent.ts index 487e4d85..18ebb530 100644 --- a/src/room/events/RoomObjectMouseEvent.ts +++ b/src/room/events/RoomObjectMouseEvent.ts @@ -3,13 +3,14 @@ import { RoomObjectEvent } from './RoomObjectEvent'; export class RoomObjectMouseEvent extends RoomObjectEvent { - public static CLICK: string = 'ROE_MOUSE_CLICK'; - public static DOUBLE_CLICK: string = 'ROE_MOUSE_DOUBLE_CLICK'; - public static MOUSE_MOVE: string = 'ROE_MOUSE_MOVE'; - public static MOUSE_DOWN: string = 'ROE_MOUSE_DOWN'; - public static MOUSE_UP: string = 'ROE_MOUSE_UP'; - public static MOUSE_ENTER: string = 'ROE_MOUSE_ENTER'; - public static MOUSE_LEAVE: string = 'ROE_MOUSE_LEAVE'; + public static CLICK: string = 'ROE_MOUSE_CLICK'; + public static DOUBLE_CLICK: string = 'ROE_MOUSE_DOUBLE_CLICK'; + public static MOUSE_MOVE: string = 'ROE_MOUSE_MOVE'; + public static MOUSE_DOWN: string = 'ROE_MOUSE_DOWN'; + public static MOUSE_DOWN_LONG: string = 'ROE_MOUSE_DOWN_LONG'; + public static MOUSE_UP: string = 'ROE_MOUSE_UP'; + public static MOUSE_ENTER: string = 'ROE_MOUSE_ENTER'; + public static MOUSE_LEAVE: string = 'ROE_MOUSE_LEAVE'; private _eventId: string = ''; private _altKey: boolean; @@ -96,4 +97,4 @@ export class RoomObjectMouseEvent extends RoomObjectEvent { this._spriteOffsetY = k; } -} \ No newline at end of file +} From 557c773ad92a1fe50ac7a270e57ee95ebc13fc4e Mon Sep 17 00:00:00 2001 From: Bill Date: Sat, 12 Jun 2021 00:41:17 -0400 Subject: [PATCH 5/5] Updates --- src/nitro/room/RoomEngine.ts | 102 +++++++++++++++++------------------ 1 file changed, 48 insertions(+), 54 deletions(-) diff --git a/src/nitro/room/RoomEngine.ts b/src/nitro/room/RoomEngine.ts index 2dfd98ee..bb242ac5 100644 --- a/src/nitro/room/RoomEngine.ts +++ b/src/nitro/room/RoomEngine.ts @@ -2508,87 +2508,81 @@ export class RoomEngine extends NitroManager implements IRoomEngine, IRoomCreato } } } - else + + else if(type === MouseEventType.MOUSE_UP) { - if(type === MouseEventType.MOUSE_UP) + if(this._activeRoomIsDragged) { - if(this._activeRoomIsDragged) + this._activeRoomIsDragged = false; + + if(this._activeRoomWasDragged) { - this._activeRoomIsDragged = false; + const instanceData = this.getRoomInstanceData(this._activeRoomId); - if(this._activeRoomWasDragged) + if(instanceData) { - const instanceData = this.getRoomInstanceData(this._activeRoomId); + const camera = instanceData.roomCamera; - if(instanceData) + if(camera) { - const camera = instanceData.roomCamera; - - if(camera) + if(this._Str_11555) { - if(this._Str_11555) + if(!camera._Str_12536) { - if(!camera._Str_12536) - { - camera._Str_8564 = false; - camera._Str_8690 = false; - } - - camera._Str_25467(new Vector3d(-(canvas.screenOffsetX), -(canvas.screenOffsetY))); + camera._Str_8564 = false; + camera._Str_8690 = false; } - if(this._roomDraggingAlwaysCenters) camera.reset(); + camera._Str_25467(new Vector3d(-(canvas.screenOffsetX), -(canvas.screenOffsetY))); } + + if(this._roomDraggingAlwaysCenters) camera.reset(); } } } } - else + } + + else if(type === MouseEventType.MOUSE_MOVE) + { + if(this._activeRoomIsDragged) { - if(type === MouseEventType.MOUSE_MOVE) + if(!this._activeRoomWasDragged) { - if(this._activeRoomIsDragged) + offsetX = (x - this._activeRoomDragStartX); + offsetY = (y - this._activeRoomDragStartY); + + if(((((offsetX <= -(RoomEngine.DRAG_THRESHOLD)) || (offsetX >= RoomEngine.DRAG_THRESHOLD)) || (offsetY <= -(RoomEngine.DRAG_THRESHOLD))) || (offsetY >= RoomEngine.DRAG_THRESHOLD))) { - if(!this._activeRoomWasDragged) - { - offsetX = (x - this._activeRoomDragStartX); - offsetY = (y - this._activeRoomDragStartY); - - if(((((offsetX <= -(RoomEngine.DRAG_THRESHOLD)) || (offsetX >= RoomEngine.DRAG_THRESHOLD)) || (offsetY <= -(RoomEngine.DRAG_THRESHOLD))) || (offsetY >= RoomEngine.DRAG_THRESHOLD))) - { - this._activeRoomWasDragged = true; - } - - offsetX = 0; - offsetY = 0; - } - - if(((!(offsetX == 0)) || (!(offsetY == 0)))) - { - this._activeRoomDragX += offsetX; - this._activeRoomDragY += offsetY; - - this._activeRoomWasDragged = true; - } + this._activeRoomWasDragged = true; } + + offsetX = 0; + offsetY = 0; } - else + + if(((!(offsetX == 0)) || (!(offsetY == 0)))) { - if((type === MouseEventType.MOUSE_CLICK) || (type === MouseEventType.DOUBLE_CLICK)) - { - this._activeRoomIsDragged = false; + this._activeRoomDragX += offsetX; + this._activeRoomDragY += offsetY; - if(this._activeRoomWasDragged) - { - this._activeRoomWasDragged = false; - - return true; - } - } + this._activeRoomWasDragged = true; } } } + else if((type === MouseEventType.MOUSE_CLICK) || (type === MouseEventType.DOUBLE_CLICK)) + { + this._activeRoomIsDragged = false; + + if(this._activeRoomWasDragged) + { + this._activeRoomWasDragged = false; + + return true; + } + } + return false; }