Skip to content
This repository has been archived by the owner on Jul 31, 2020. It is now read-only.

Commit

Permalink
feat(screen): Add mouse event toggles to type
Browse files Browse the repository at this point in the history
  • Loading branch information
DeekyJay committed Jul 12, 2018
1 parent 8ec7c76 commit b9d5d3b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 20 deletions.
16 changes: 12 additions & 4 deletions src/state/controls/Screen.ts
Expand Up @@ -14,11 +14,19 @@ export class Screen extends Control<IScreenData> implements IScreen {
* The throttle rate for input sent
*/
public moveThrottle: number;
/**
* Whether the control sends the mouse down event.
*/
public sendMouseDownEvent: boolean;
/**
* Whether the control sends the mouse up event.
*/
public sendMouseUpEvent: boolean;

/**
/**
* Sends an input event from a participant to the server for consumption.
*/
public giveInput(input: IScreenInput): Promise<void> {
return this.sendInput(input);
}
public giveInput(input: IScreenInput): Promise<void> {
return this.sendInput(input);
}
}
50 changes: 34 additions & 16 deletions src/state/interfaces/controls/IScreen.ts
Expand Up @@ -15,6 +15,14 @@ export interface IScreenData extends IControlData {
* The throttle rate for input sent
*/
moveThrottle?: number;
/**
* Whether the control sends the mouse down event.
*/
sendMouseDownEvent?: boolean;
/**
* Whether the control sends the mouse up event.
*/
sendMouseUpEvent?: boolean;
}

/**
Expand All @@ -30,29 +38,39 @@ export interface IScreenUpdate extends IControlUpdate {
* The throttle rate for input sent
*/
moveThrottle?: number;
/**
* Whether the control sends the mouse down event.
*/
sendMouseDownEvent?: boolean;
/**
* Whether the control sends the mouse up event.
*/
sendMouseUpEvent?: boolean;
}

export interface IScreen extends IControl, IScreenData {
sendMoveEvents: MoveEventType;
moveThrottle: number;
// GameClient
update(changedData: IScreenUpdate): Promise<void>;
sendMoveEvents: MoveEventType;
moveThrottle: number;
sendMouseDownEvent: boolean;
sendMouseUpEvent: boolean;
// GameClient
update(changedData: IScreenUpdate): Promise<void>;

giveInput(input: IScreenInput): Promise<void>;
giveInput(input: IScreenInput): Promise<void>;

/**
/**
* Fired when a participant moves cursor.
*/
on(
event: 'move',
listener: (inputEvent: IInputEvent<IScreenInput>, participant: IParticipant) => void,
): this;
/**
on(
event: 'move',
listener: (inputEvent: IInputEvent<IScreenInput>, participant: IParticipant) => void,
): this;
/**
* Fired when a participant presses this button with their mouse.
*/
on(
event: 'mousedown',
listener: (inputEvent: IInputEvent<IScreenInput>, participant: IParticipant) => void,
): this;
on(event: string, listener: Function): this;
on(
event: 'mousedown',
listener: (inputEvent: IInputEvent<IScreenInput>, participant: IParticipant) => void,
): this;
on(event: string, listener: Function): this;
}

0 comments on commit b9d5d3b

Please sign in to comment.