From 8c123ef52cc4213de1785ed4336c3cca90e0de5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lancelot=20de=20Ferri=C3=A8re?= Date: Thu, 3 Mar 2022 12:03:16 +0100 Subject: [PATCH] Move input states to their own subfolder --- src/builder/inputs/BuilderInput.ts | 2 +- src/builder/inputs/InputMap.ts | 12 ++++----- .../{ => input_states}/BuilderInputState.ts | 6 ++--- .../inputs/{ => input_states}/CameraOnly.ts | 0 .../inputs/{ => input_states}/CopyPaste.ts | 13 ++++------ .../inputs/{ => input_states}/Eraser.ts | 8 +++--- .../inputs/{ => input_states}/Inspect.ts | 26 +++++++++---------- .../inputs/{ => input_states}/Painter.ts | 10 +++---- .../inputs/{ => input_states}/Placer.ts | 12 ++++----- .../inputs/{ => input_states}/Selecting.ts | 16 ++++++------ 10 files changed, 51 insertions(+), 54 deletions(-) rename src/builder/inputs/{ => input_states}/BuilderInputState.ts (95%) rename src/builder/inputs/{ => input_states}/CameraOnly.ts (100%) rename src/builder/inputs/{ => input_states}/CopyPaste.ts (94%) rename src/builder/inputs/{ => input_states}/Eraser.ts (93%) rename src/builder/inputs/{ => input_states}/Inspect.ts (95%) rename src/builder/inputs/{ => input_states}/Painter.ts (92%) rename src/builder/inputs/{ => input_states}/Placer.ts (91%) rename src/builder/inputs/{ => input_states}/Selecting.ts (95%) diff --git a/src/builder/inputs/BuilderInput.ts b/src/builder/inputs/BuilderInput.ts index 94ea6705..b4e962e7 100644 --- a/src/builder/inputs/BuilderInput.ts +++ b/src/builder/inputs/BuilderInput.ts @@ -1,5 +1,5 @@ import type { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'; -import { BuilderInputState, MouseInputState } from './BuilderInputState' +import { BuilderInputState, MouseInputState } from './input_states/BuilderInputState'; import { inputMap } from '../../builder/inputs/InputMap' diff --git a/src/builder/inputs/InputMap.ts b/src/builder/inputs/InputMap.ts index 61249691..944fea6b 100644 --- a/src/builder/inputs/InputMap.ts +++ b/src/builder/inputs/InputMap.ts @@ -1,11 +1,11 @@ import type { BuilderInputState } from './BuilderInputState'; -import { CameraOnlyInput } from './CameraOnly'; -import { PlacerInput, PlacerMultiInput } from './Placer'; -import { EraserInput, EraserMultiInput } from './Eraser'; -import { PainterInput, PainterMultiInput } from './Painter'; -import { InspectInput, BoxSelect, VASelect, DragInput } from './Inspect'; -import { CopyPasteInput } from './CopyPaste'; +import { CameraOnlyInput } from './input_states/CameraOnly'; +import { PlacerInput, PlacerMultiInput } from './input_states/Placer'; +import { EraserInput, EraserMultiInput } from './input_states/Eraser'; +import { PainterInput, PainterMultiInput } from './input_states/Painter'; +import { InspectInput, BoxSelect, VASelect, DragInput } from './input_states/Inspect'; +import { CopyPasteInput } from './input_states/CopyPaste'; export const inputMap: { [key: string]: typeof BuilderInputState } = { "place": PlacerInput, diff --git a/src/builder/inputs/BuilderInputState.ts b/src/builder/inputs/input_states/BuilderInputState.ts similarity index 95% rename from src/builder/inputs/BuilderInputState.ts rename to src/builder/inputs/input_states/BuilderInputState.ts index 918b4079..17620954 100644 --- a/src/builder/inputs/BuilderInputState.ts +++ b/src/builder/inputs/input_states/BuilderInputState.ts @@ -1,6 +1,6 @@ -import builderSettings from '../graphics/Settings'; -import { getCameraRay, voxWorld } from "../graphics/Builder" -import type { BuilderInputFSM } from './BuilderInput' +import builderSettings from '../../graphics/Settings'; +import { getCameraRay, voxWorld } from "../../graphics/Builder" +import type { BuilderInputFSM } from '../BuilderInput' export class BuilderInputState { diff --git a/src/builder/inputs/CameraOnly.ts b/src/builder/inputs/input_states/CameraOnly.ts similarity index 100% rename from src/builder/inputs/CameraOnly.ts rename to src/builder/inputs/input_states/CameraOnly.ts diff --git a/src/builder/inputs/CopyPaste.ts b/src/builder/inputs/input_states/CopyPaste.ts similarity index 94% rename from src/builder/inputs/CopyPaste.ts rename to src/builder/inputs/input_states/CopyPaste.ts index 02ec963c..4358ce60 100644 --- a/src/builder/inputs/CopyPaste.ts +++ b/src/builder/inputs/input_states/CopyPaste.ts @@ -1,14 +1,11 @@ import { MouseInputState } from './BuilderInputState'; -import { store } from '../../store/Store' +import { store } from '../../../store/Store' -import type { SetData } from '../SetData' -import type { Briq } from '../Briq.js'; +import type { HotkeyHandle } from '../../../Hotkeys'; -import type { HotkeyManager, HotkeyHandle } from '../../Hotkeys'; - -import { SelectionManager, selectionRender } from './Selection'; -import { THREE } from '../../three'; -import { pushMessage } from '../../Messages'; +import { SelectionManager, selectionRender } from '../Selection'; +import { THREE } from '../../../three'; +import { pushMessage } from '../../../Messages'; export class CopyPasteInput extends MouseInputState { lastClickPos: [number, number, number] | undefined; diff --git a/src/builder/inputs/Eraser.ts b/src/builder/inputs/input_states/Eraser.ts similarity index 93% rename from src/builder/inputs/Eraser.ts rename to src/builder/inputs/input_states/Eraser.ts index 73e8f2ea..b64b929c 100644 --- a/src/builder/inputs/Eraser.ts +++ b/src/builder/inputs/input_states/Eraser.ts @@ -1,9 +1,9 @@ import { MouseInputState } from './BuilderInputState'; import { VoxelAlignedSelection } from './Selecting'; -import getPreviewCube from '../graphics/PreviewCube' -import { store } from '../../store/Store'; +import getPreviewCube from '../../graphics/PreviewCube' +import { store } from '../../../store/Store'; -import { THREE } from '../../three'; +import { THREE } from '../../../three'; export class EraserInput extends MouseInputState { @@ -20,7 +20,7 @@ export class EraserInput extends MouseInputState getPreviewCube().visible = false; } - onPointerMove(event: PointerEvent) + async onPointerMove(event: PointerEvent) { let pos = this.getIntersectionPos(this.curX, this.curY, true); if (!pos) diff --git a/src/builder/inputs/Inspect.ts b/src/builder/inputs/input_states/Inspect.ts similarity index 95% rename from src/builder/inputs/Inspect.ts rename to src/builder/inputs/input_states/Inspect.ts index e2fad8c2..93934b3d 100644 --- a/src/builder/inputs/Inspect.ts +++ b/src/builder/inputs/input_states/Inspect.ts @@ -1,17 +1,17 @@ import { MouseInputState } from './BuilderInputState'; -import { store } from '../../store/Store' -import type { SetData } from '../SetData' -import type { Briq } from '../Briq.js'; -import { SelectionManager, selectionRender } from './Selection'; -import getPreviewCube from '../graphics/PreviewCube' -import { THREE, BufferGeometryUtils } from '../../three'; - -import { camera, inputObjects } from '../graphics/Builder'; - -import { featureFlags } from "../../FeatureFlags"; -import { pushMessage } from '../../Messages'; -import { setsManager } from '../SetsManager'; -import type { HotkeyManager, HotkeyHandle } from '../../Hotkeys'; +import { store } from '../../../store/Store'; +import type { SetData } from '../../SetData'; +import type { Briq } from '../../Briq'; +import { selectionRender } from '../Selection'; +import getPreviewCube from '../../graphics/PreviewCube' +import { THREE, BufferGeometryUtils } from '../../../three'; + +import { camera, inputObjects } from '../../graphics/Builder'; + +import { featureFlags } from '../../../FeatureFlags'; +import { pushMessage } from '../../../Messages'; +import { setsManager } from '../../SetsManager'; +import type { HotkeyHandle } from '../../../Hotkeys'; import { watchEffect, WatchStopHandle } from 'vue'; import { BoxSelection, VoxelAlignedSelection } from './Selecting'; diff --git a/src/builder/inputs/Painter.ts b/src/builder/inputs/input_states/Painter.ts similarity index 92% rename from src/builder/inputs/Painter.ts rename to src/builder/inputs/input_states/Painter.ts index b7e4536b..f59a1f41 100644 --- a/src/builder/inputs/Painter.ts +++ b/src/builder/inputs/input_states/Painter.ts @@ -1,11 +1,11 @@ import { MouseInputState } from './BuilderInputState'; -import getPreviewCube from '../graphics/PreviewCube' -import { inputStore } from "./InputStore"; -import { store } from '../../store/Store'; +import getPreviewCube from '../../graphics/PreviewCube' +import { inputStore } from "../InputStore"; +import { store } from '../../../store/Store'; -import type { SetData } from '../SetData'; +import type { SetData } from '../../SetData'; -import { THREE } from '../../three'; +import { THREE } from '../../../three'; import { VoxelAlignedSelection } from './Selecting'; import { watchEffect } from 'vue'; diff --git a/src/builder/inputs/Placer.ts b/src/builder/inputs/input_states/Placer.ts similarity index 91% rename from src/builder/inputs/Placer.ts rename to src/builder/inputs/input_states/Placer.ts index 8297ef2b..7c26bbe7 100644 --- a/src/builder/inputs/Placer.ts +++ b/src/builder/inputs/input_states/Placer.ts @@ -1,9 +1,9 @@ import { MouseInputState } from './BuilderInputState'; -import getPreviewCube from '../graphics/PreviewCube' -import { inputStore } from "./InputStore"; -import { store } from '../../store/Store' +import getPreviewCube from '../../graphics/PreviewCube' +import { inputStore } from "../InputStore"; +import { store } from '../../../store/Store' -import { THREE } from '../../three'; +import { THREE } from '../../../three'; import { VoxelAlignedSelection } from './Selecting'; import { watchEffect } from 'vue'; @@ -23,7 +23,7 @@ export class PlacerInput extends MouseInputState getPreviewCube().visible = false; } - onPointerMove(event: PointerEvent) + async onPointerMove(event: PointerEvent) { const pos = this.getIntersectionPos(this.curX, this.curY); if (!pos) @@ -38,7 +38,7 @@ export class PlacerInput extends MouseInputState getPreviewCube().visible = false; } - onPointerDown(event: PointerEvent) + async onPointerDown(event: PointerEvent) { if (event.shiftKey) this.fsm.switchTo("place_multi", { x: event.clientX, y: event.clientY }); diff --git a/src/builder/inputs/Selecting.ts b/src/builder/inputs/input_states/Selecting.ts similarity index 95% rename from src/builder/inputs/Selecting.ts rename to src/builder/inputs/input_states/Selecting.ts index 822e2356..7aa9ee0b 100644 --- a/src/builder/inputs/Selecting.ts +++ b/src/builder/inputs/input_states/Selecting.ts @@ -1,12 +1,12 @@ import { MouseInputState } from './BuilderInputState'; -import { selectionRender } from './Selection'; -import { THREE, SelectionBox as ThreeSelectionBox } from '../../three'; -import getPreviewCube from '../graphics/PreviewCube'; - -import { store } from '../../store/Store' -import { camera } from '../graphics/Builder'; -import type { HotkeyHandle } from '../../Hotkeys'; -import type { Briq } from '../Briq'; +import { selectionRender } from '../Selection'; +import { THREE, SelectionBox as ThreeSelectionBox } from '../../../three'; +import getPreviewCube from '../../graphics/PreviewCube'; + +import { store } from '../../../store/Store' +import { camera } from '../../graphics/Builder'; +import type { HotkeyHandle } from '../../../Hotkeys'; +import type { Briq } from '../../Briq'; export class BoxSelection extends MouseInputState {