Typescript
This commit is contained in:
@@ -2,22 +2,39 @@ import Konva from "konva";
|
||||
import { DefaultDice } from "./Dice";
|
||||
import { Map } from "./Map";
|
||||
import { MapState } from "./MapState";
|
||||
import { Note } from "./Note";
|
||||
import { TokenState } from "./TokenState";
|
||||
|
||||
export type MapChangeEventHandler = (map?: Map, mapState?: MapState) => void;
|
||||
|
||||
export type MapResetEventHandler = (newState: MapState) => void;
|
||||
export type MapSettingsChangeEventHandler = (change: Partial<Map>) => void;
|
||||
export type MapStateSettingsChangeEventHandler = (
|
||||
change: Partial<MapState>
|
||||
) => void;
|
||||
|
||||
export type DiceSelectEventHandler = (dice: DefaultDice) => void;
|
||||
|
||||
export type RequestCloseEventHandler = () => void;
|
||||
|
||||
export type MapTokensStateCreateHandler = (states: TokenState[]) => void;
|
||||
export type MapTokenStateRemoveHandler = (state: TokenState) => void;
|
||||
|
||||
export type TokenStateChangeEventHandler = (
|
||||
change: Partial<Record<string, Partial<TokenState>>>
|
||||
changes: Record<string, Partial<TokenState>>
|
||||
) => void;
|
||||
export type TokenMenuOpenChangeEventHandler = (
|
||||
tokenStateId: string,
|
||||
tokenImage: Konva.Node
|
||||
) => void;
|
||||
|
||||
export type NoteAddEventHander = (note: Note) => void;
|
||||
export type NoteRemoveEventHander = (noteId: string) => void;
|
||||
export type NoteChangeEventHandler = (change: Partial<Note>) => void;
|
||||
export type NoteMenuOpenEventHandler = (
|
||||
noteId: string,
|
||||
noteNode: Konva.Node
|
||||
) => void;
|
||||
export type NoteDragEventHandler = (
|
||||
event: Konva.KonvaEventObject<DragEvent>,
|
||||
noteId: string
|
||||
) => void;
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import React from "react";
|
||||
import Action from "../actions/Action";
|
||||
import { Drawing } from "./Drawing";
|
||||
import { Fog } from "./Fog";
|
||||
import { Grid } from "./Grid";
|
||||
|
||||
export type MapToolId =
|
||||
| "map"
|
||||
| "move"
|
||||
| "fog"
|
||||
| "drawing"
|
||||
@@ -42,12 +46,30 @@ export type FileMapResolutions = {
|
||||
ultra?: string;
|
||||
};
|
||||
|
||||
export type MapQuality = keyof FileMapResolutions | "original";
|
||||
|
||||
export type FileMap = BaseMap & {
|
||||
type: "file";
|
||||
file: string;
|
||||
resolutions: FileMapResolutions;
|
||||
thumbnail: string;
|
||||
quality: keyof FileMapResolutions | "original";
|
||||
quality: MapQuality;
|
||||
};
|
||||
|
||||
export type Map = DefaultMap | FileMap;
|
||||
|
||||
export type MapActions = {
|
||||
mapDrawActions: Action<Drawing>[];
|
||||
mapDrawActionIndex: number;
|
||||
fogDrawActions: Action<Fog>[];
|
||||
fogDrawActionIndex: number;
|
||||
};
|
||||
|
||||
export type MapActionsKey = keyof Pick<
|
||||
MapActions,
|
||||
"mapDrawActions" | "fogDrawActions"
|
||||
>;
|
||||
export type MapActionsIndexKey = keyof Pick<
|
||||
MapActions,
|
||||
"mapDrawActionIndex" | "fogDrawActionIndex"
|
||||
>;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import Konva from "konva";
|
||||
import { Color } from "../helpers/colors";
|
||||
|
||||
export type Note = {
|
||||
@@ -13,3 +14,14 @@ export type Note = {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
|
||||
export type NoteMenuOptions = {
|
||||
noteId: string;
|
||||
noteNode: Konva.Node;
|
||||
};
|
||||
|
||||
export type NoteDraggingOptions = {
|
||||
dragging: boolean;
|
||||
noteId: string;
|
||||
noteGroup: Konva.Node;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import Konva from "konva";
|
||||
import { Outline } from "./Outline";
|
||||
import { TokenState } from "./TokenState";
|
||||
|
||||
export type TokenCategory = "character" | "vehicle" | "prop";
|
||||
|
||||
@@ -29,3 +31,14 @@ export type FileToken = BaseToken & {
|
||||
};
|
||||
|
||||
export type Token = DefaultToken | FileToken;
|
||||
|
||||
export type TokenMenuOptions = {
|
||||
tokenStateId: string;
|
||||
tokenImage: Konva.Node;
|
||||
};
|
||||
|
||||
export type TokenDraggingOptions = {
|
||||
dragging: boolean;
|
||||
tokenState: TokenState;
|
||||
tokenGroup: Konva.Node;
|
||||
};
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { Outline } from "./Outline";
|
||||
import { TokenCategory } from "./Token";
|
||||
|
||||
export type BaseTokenState = {
|
||||
id: string;
|
||||
tokenId: string;
|
||||
owner: string;
|
||||
size: number;
|
||||
category: string;
|
||||
category: TokenCategory;
|
||||
label: string;
|
||||
statuses: string[];
|
||||
x: number;
|
||||
|
||||
Reference in New Issue
Block a user