Add long touch/mouse events

This commit is contained in:
Bill 2021-06-10 03:02:59 -04:00
parent c56f0d86c1
commit 4b85e85626
7 changed files with 70 additions and 27 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;
}
}
}

View File

@ -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();
}
}
}

View File

@ -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';
}
}

View File

@ -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';
}
public static TOUCH_LONG: string = 'touchlong';
}

View File

@ -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;
}
}
}