Add standalone type definitions
This commit is contained in:
parent
123ebd880a
commit
45a4443dd1
8
src/types/Asset.ts
Normal file
8
src/types/Asset.ts
Normal file
@ -0,0 +1,8 @@
|
||||
export type Asset = {
|
||||
file: Uint8Array;
|
||||
width: number;
|
||||
height: number;
|
||||
id: string;
|
||||
owner: string;
|
||||
mime: string;
|
||||
};
|
20
src/types/Dice.ts
Normal file
20
src/types/Dice.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { InstancedMesh } from "@babylonjs/core";
|
||||
|
||||
export type DiceType = "d4" | "d6" | "d8" | "d10" | "d12" | "d20";
|
||||
|
||||
export type DiceRoll = {
|
||||
type: DiceType;
|
||||
roll: number | "unknown";
|
||||
};
|
||||
|
||||
export type Dice = {
|
||||
type: DiceType;
|
||||
instance: InstancedMesh;
|
||||
asleep: boolean;
|
||||
d10Instance?: InstancedMesh;
|
||||
};
|
||||
|
||||
export type DiceState = {
|
||||
share: boolean;
|
||||
rolls: DiceRoll[];
|
||||
};
|
74
src/types/Drawing.ts
Normal file
74
src/types/Drawing.ts
Normal file
@ -0,0 +1,74 @@
|
||||
import Vector2 from "../helpers/Vector2";
|
||||
|
||||
export type DrawingToolType =
|
||||
| "brush"
|
||||
| "paint"
|
||||
| "line"
|
||||
| "rectangle"
|
||||
| "circle"
|
||||
| "triangle"
|
||||
| "erase";
|
||||
|
||||
export type DrawingToolSettings = {
|
||||
type: DrawingToolType;
|
||||
color: string;
|
||||
useBlending: boolean;
|
||||
};
|
||||
|
||||
export type PointsData = {
|
||||
points: Vector2[];
|
||||
};
|
||||
|
||||
export type RectData = {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
|
||||
export type CircleData = {
|
||||
x: number;
|
||||
y: number;
|
||||
radius: number;
|
||||
};
|
||||
|
||||
export type BaseDrawing = {
|
||||
blend: boolean;
|
||||
color: string;
|
||||
id: string;
|
||||
strokeWidth: number;
|
||||
};
|
||||
|
||||
export type BaseShape = BaseDrawing & {
|
||||
type: "shape";
|
||||
};
|
||||
|
||||
export type Line = BaseShape & {
|
||||
shapeType: "line";
|
||||
data: PointsData;
|
||||
};
|
||||
|
||||
export type Rectangle = BaseShape & {
|
||||
shapeType: "rectangle";
|
||||
data: RectData;
|
||||
};
|
||||
|
||||
export type Circle = BaseShape & {
|
||||
shapeType: "circle";
|
||||
data: CircleData;
|
||||
};
|
||||
|
||||
export type Triangle = BaseShape & {
|
||||
shapeType: "triangle";
|
||||
data: PointsData;
|
||||
};
|
||||
|
||||
export type Shape = Line | Rectangle | Circle | Triangle;
|
||||
|
||||
export type Path = BaseDrawing & {
|
||||
type: "path";
|
||||
pathType: "fill" | "stroke";
|
||||
data: PointsData;
|
||||
};
|
||||
|
||||
export type Drawing = Shape | Path;
|
29
src/types/Fog.ts
Normal file
29
src/types/Fog.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import Vector2 from "../helpers/Vector2";
|
||||
|
||||
export type FogToolType =
|
||||
| "polygon"
|
||||
| "rectangle"
|
||||
| "brush"
|
||||
| "toggle"
|
||||
| "remove";
|
||||
|
||||
export type FogToolSettings = {
|
||||
type: FogToolType;
|
||||
multilayer: boolean;
|
||||
preview: boolean;
|
||||
useFogCut: boolean;
|
||||
};
|
||||
|
||||
export type FogData = {
|
||||
points: Vector2[];
|
||||
holes: Vector2[][];
|
||||
};
|
||||
|
||||
export type Fog = {
|
||||
color: string;
|
||||
data: FogData;
|
||||
id: string;
|
||||
strokeWidth: number;
|
||||
type: "fog";
|
||||
visible: boolean;
|
||||
};
|
26
src/types/Grid.ts
Normal file
26
src/types/Grid.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import Vector2 from "../helpers/Vector2";
|
||||
|
||||
export type GridInset = {
|
||||
topLeft: Vector2;
|
||||
bottomRight: Vector2;
|
||||
};
|
||||
|
||||
export type GridMeasurementType =
|
||||
| "chebyshev"
|
||||
| "alternating"
|
||||
| "euclidean"
|
||||
| "manhattan";
|
||||
|
||||
export type GridMeasurement = {
|
||||
type: GridMeasurementType;
|
||||
scale: string;
|
||||
};
|
||||
|
||||
export type GridType = "square" | "hexVertical" | "hexHorizontal";
|
||||
|
||||
export type Grid = {
|
||||
inset: GridInset;
|
||||
size: Vector2;
|
||||
type: GridType;
|
||||
measurement: GridMeasurement;
|
||||
};
|
13
src/types/Group.ts
Normal file
13
src/types/Group.ts
Normal file
@ -0,0 +1,13 @@
|
||||
export type GroupItem = {
|
||||
id: string;
|
||||
type: "item";
|
||||
};
|
||||
|
||||
export type GroupContainer = {
|
||||
id: string;
|
||||
type: "group";
|
||||
items: GroupItem[];
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type Group = GroupItem | GroupContainer;
|
36
src/types/Map.ts
Normal file
36
src/types/Map.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { Grid } from "./Grid";
|
||||
|
||||
export type BaseMap = {
|
||||
id: string;
|
||||
name: string;
|
||||
owner: string;
|
||||
grid: Grid;
|
||||
width: number;
|
||||
height: number;
|
||||
type: string;
|
||||
lastModified: number;
|
||||
created: number;
|
||||
showGrid: boolean;
|
||||
snapToGrid: boolean;
|
||||
};
|
||||
|
||||
export type DefaultMap = BaseMap & {
|
||||
type: "default";
|
||||
key: string;
|
||||
};
|
||||
|
||||
export type FileMapResolutions = {
|
||||
low?: string;
|
||||
medium?: string;
|
||||
high?: string;
|
||||
ultra?: string;
|
||||
};
|
||||
|
||||
export type FileMap = BaseMap & {
|
||||
type: "file";
|
||||
file: string;
|
||||
resolutions: FileMapResolutions;
|
||||
thumbnail: string;
|
||||
};
|
||||
|
||||
export type Map = DefaultMap | FileMap;
|
15
src/types/MapState.ts
Normal file
15
src/types/MapState.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { Drawing } from "./Drawing";
|
||||
import { Fog } from "./Fog";
|
||||
import { Note } from "./Note";
|
||||
import { TokenState } from "./TokenState";
|
||||
|
||||
export type EditFlag = "drawing" | "tokens" | "notes" | "fog";
|
||||
|
||||
export type MapState = {
|
||||
tokens: Record<string, TokenState>;
|
||||
drawShapes: Record<string, Drawing>;
|
||||
fogShapes: Record<string, Fog>;
|
||||
editFlags: Array<EditFlag>;
|
||||
notes: Record<string, Note>;
|
||||
mapId: string;
|
||||
};
|
13
src/types/Note.ts
Normal file
13
src/types/Note.ts
Normal file
@ -0,0 +1,13 @@
|
||||
export type Note = {
|
||||
id: string;
|
||||
color: string;
|
||||
lastModified: number;
|
||||
lastModifiedBy: string;
|
||||
locked: boolean;
|
||||
size: number;
|
||||
text: string;
|
||||
textOnly: boolean;
|
||||
visible: boolean;
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
21
src/types/Outline.ts
Normal file
21
src/types/Outline.ts
Normal file
@ -0,0 +1,21 @@
|
||||
export type CircleOutline = {
|
||||
type: "circle";
|
||||
x: number;
|
||||
y: number;
|
||||
radius: number;
|
||||
};
|
||||
|
||||
export type RectOutline = {
|
||||
type: "rect";
|
||||
width: number;
|
||||
height: number;
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
|
||||
export type PathOutline = {
|
||||
type: "path";
|
||||
points: number[];
|
||||
};
|
||||
|
||||
export type Outline = CircleOutline | RectOutline | PathOutline;
|
3
src/types/PartyState.ts
Normal file
3
src/types/PartyState.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import { PlayerState } from "./PlayerState";
|
||||
|
||||
export type PartyState = Record<string, PlayerState>;
|
10
src/types/PlayerState.ts
Normal file
10
src/types/PlayerState.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { Timer } from "./Timer";
|
||||
import { DiceState } from "./Dice";
|
||||
|
||||
export type PlayerState = {
|
||||
nickname: string;
|
||||
timer?: Timer;
|
||||
dice: DiceState;
|
||||
sessionId?: string;
|
||||
userId?: string;
|
||||
};
|
12
src/types/Pointer.ts
Normal file
12
src/types/Pointer.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import Vector2 from "../helpers/Vector2";
|
||||
|
||||
export type PointerToolSettings = {
|
||||
color: string;
|
||||
};
|
||||
|
||||
export type PointerState = {
|
||||
position: Vector2;
|
||||
visible: boolean;
|
||||
id: string;
|
||||
color: string;
|
||||
};
|
34
src/types/Settings.ts
Normal file
34
src/types/Settings.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import { Duration } from "./Timer";
|
||||
import { DrawingToolSettings } from "./Drawing";
|
||||
import { FogToolSettings } from "./Fog";
|
||||
import { PointerToolSettings } from "./Pointer";
|
||||
|
||||
export type DrawingSettings = DrawingToolSettings;
|
||||
export type FogSettings = FogToolSettings & {
|
||||
editOpacity: number;
|
||||
showGuides: boolean;
|
||||
};
|
||||
export type DiceSettings = {
|
||||
shareDice: boolean;
|
||||
style: string;
|
||||
};
|
||||
export type GameSettings = {
|
||||
usePassword: boolean;
|
||||
};
|
||||
export type MapSettings = {
|
||||
fullScreen: boolean;
|
||||
labeSize: number;
|
||||
gridSnappingSensitivity: number;
|
||||
};
|
||||
export type PointerSettings = PointerToolSettings;
|
||||
export type TimerSettings = Duration;
|
||||
|
||||
export type Settings = {
|
||||
dice: DiceSettings;
|
||||
drawing: DrawingSettings;
|
||||
fog: FogSettings;
|
||||
game: GameSettings;
|
||||
map: MapSettings;
|
||||
pointer: PointerSettings;
|
||||
timer: TimerSettings;
|
||||
};
|
10
src/types/Timer.ts
Normal file
10
src/types/Timer.ts
Normal file
@ -0,0 +1,10 @@
|
||||
export type Duration = {
|
||||
hour: number;
|
||||
minute: number;
|
||||
second: number;
|
||||
};
|
||||
|
||||
export type Timer = {
|
||||
current: number;
|
||||
max: number;
|
||||
};
|
31
src/types/Token.ts
Normal file
31
src/types/Token.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { Outline } from "./Outline";
|
||||
|
||||
export type TokenCategory = "character" | "vehicle" | "prop";
|
||||
|
||||
export type BaseToken = {
|
||||
id: string;
|
||||
name: string;
|
||||
defaultSize: number;
|
||||
defaultCategory: TokenCategory;
|
||||
defaultLabel: string;
|
||||
hideInSidebar: boolean;
|
||||
width: number;
|
||||
height: number;
|
||||
owner: string;
|
||||
created: number;
|
||||
lastModified: number;
|
||||
outline: Outline;
|
||||
};
|
||||
|
||||
export type DefaultToken = BaseToken & {
|
||||
type: "default";
|
||||
key: string;
|
||||
};
|
||||
|
||||
export type FileToken = BaseToken & {
|
||||
type: "file";
|
||||
file: string;
|
||||
thumbnail: string;
|
||||
};
|
||||
|
||||
export type Token = DefaultToken | FileToken;
|
33
src/types/TokenState.ts
Normal file
33
src/types/TokenState.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { Outline } from "./Outline";
|
||||
|
||||
export type BaseTokenState = {
|
||||
id: string;
|
||||
tokenId: string;
|
||||
owner: string;
|
||||
size: number;
|
||||
category: string;
|
||||
label: string;
|
||||
statuses: string[];
|
||||
x: number;
|
||||
y: number;
|
||||
lastModifiedBy: string;
|
||||
lastModified: number;
|
||||
rotation: number;
|
||||
locked: boolean;
|
||||
visible: boolean;
|
||||
outline: Outline;
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
|
||||
export type DefaultTokenState = BaseTokenState & {
|
||||
type: "default";
|
||||
key: string;
|
||||
};
|
||||
|
||||
export type FileTokenState = BaseTokenState & {
|
||||
type: "file";
|
||||
file: string;
|
||||
};
|
||||
|
||||
export type TokenState = DefaultTokenState | FileTokenState;
|
Loading…
Reference in New Issue
Block a user