From 98d3a58861259da46ba3881ac8f1941d7f759bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Thu, 16 Dec 2021 10:04:55 +0100 Subject: [PATCH] Improving typings of VirtualJoystick --- .../src/Phaser/UserInput/UserInputManager.ts | 2 +- front/src/rex-plugins.d.ts | 37 ++++++++++++++++++- front/src/types.ts | 23 ------------ messages/package.json | 2 +- 4 files changed, 37 insertions(+), 27 deletions(-) delete mode 100644 front/src/types.ts diff --git a/front/src/Phaser/UserInput/UserInputManager.ts b/front/src/Phaser/UserInput/UserInputManager.ts index bb7041d2..28b87e69 100644 --- a/front/src/Phaser/UserInput/UserInputManager.ts +++ b/front/src/Phaser/UserInput/UserInputManager.ts @@ -1,8 +1,8 @@ -import type { Direction } from "../../types"; import type { GameScene } from "../Game/GameScene"; import { touchScreenManager } from "../../Touch/TouchScreenManager"; import { MobileJoystick } from "../Components/MobileJoystick"; import { enableUserInputsStore } from "../../Stores/UserInputStore"; +import type { Direction } from "phaser3-rex-plugins/plugins/virtualjoystick.js"; interface UserInputManagerDatum { keyInstance: Phaser.Input.Keyboard.Key; diff --git a/front/src/rex-plugins.d.ts b/front/src/rex-plugins.d.ts index 9884d425..e171f0ba 100644 --- a/front/src/rex-plugins.d.ts +++ b/front/src/rex-plugins.d.ts @@ -1,6 +1,39 @@ +//import Phaser from "phaser"; + declare module "phaser3-rex-plugins/plugins/virtualjoystick.js" { - const content: any; // eslint-disable-line - export default content; + /*const content: any; // eslint-disable-line + export default content;*/ + import GameObject = Phaser.GameObjects.GameObject; + import { Scene } from "phaser"; + + type CursorKey = { + isDown: boolean; + }; + + export type Direction = "left" | "right" | "up" | "down"; + + interface CursorKeys extends Record { + left: CursorKey; + right: CursorKey; + up: CursorKey; + down: CursorKey; + } + + class VirtualJoystick extends GameObject { + constructor(scene: Scene, config: unknown); + enable: boolean; + base: GameObjects.Image; + thumb: GameObjects.Image; + setRadius: (radius: number) => void; + y: number; + x: number; + forceX: number; + forceY: number; + visible: boolean; + createCursorKeys: () => CursorKeys; + } + + export default VirtualJoystick; } declare module "phaser3-rex-plugins/plugins/gestures-plugin.js" { const content: any; // eslint-disable-line diff --git a/front/src/types.ts b/front/src/types.ts deleted file mode 100644 index d957a2c2..00000000 --- a/front/src/types.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type Phaser from "phaser"; - -export type CursorKey = { - isDown: boolean; -}; - -export type Direction = "left" | "right" | "up" | "down"; - -export interface CursorKeys extends Record { - left: CursorKey; - right: CursorKey; - up: CursorKey; - down: CursorKey; -} - -export interface IVirtualJoystick extends Phaser.GameObjects.GameObject { - y: number; - x: number; - forceX: number; - forceY: number; - visible: boolean; - createCursorKeys: () => CursorKeys; -} diff --git a/messages/package.json b/messages/package.json index d4906977..596bb089 100644 --- a/messages/package.json +++ b/messages/package.json @@ -36,7 +36,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/CatsMiaow/node-grpc-typescript.git" + "url": "https://github.com/CatsMiaow/node-grpc-typescript.git#grpc_tools_node_protoc_ts" }, "keywords": [ "Node.js",