From 5264f7665e09a6b2490711629d53caba49fcccf0 Mon Sep 17 00:00:00 2001 From: wertiop Date: Tue, 6 Aug 2024 16:18:56 +0100 Subject: [PATCH] feat(hud customizer): Add resizing --- layout/hud/hud.xml | 2 +- scripts/hud/customizer.ts | 271 +++++++++++++++++++++++--------------- styles/hud/hud.scss | 13 +- 3 files changed, 168 insertions(+), 118 deletions(-) diff --git a/layout/hud/hud.xml b/layout/hud/hud.xml index fc9228be..46dfa83f 100644 --- a/layout/hud/hud.xml +++ b/layout/hud/hud.xml @@ -28,7 +28,7 @@ - + diff --git a/scripts/hud/customizer.ts b/scripts/hud/customizer.ts index b50461d5..84aa030e 100644 --- a/scripts/hud/customizer.ts +++ b/scripts/hud/customizer.ts @@ -40,6 +40,31 @@ namespace HudCustomizer { TOP_LEFT: 8 }; + function getResizeVector(dir: number) { + return [ + [0, -1], + [1, -1], + [1, 0], + [1, 1], + [0, 1], + [-1, 1], + [-1, 0], + [-1, -1] + ][dir - 1]; + } + + enum DragMode { + MOVE = 0, + TOP = 1, + TOP_RIGHT = 2, + RIGHT = 3, + BOTTOM_RIGHT = 4, + BOTTOM = 5, + BOTTOM_LEFT = 6, + LEFT = 7, + TOP_LEFT = 8 + } + // Tuple of X, Y axis snaps respectively const DEFAULT_SNAP_MODES: Snaps = [SnapMode.OFF, SnapMode.OFF]; const DEFAULT_GRID_SIZE = 5; @@ -48,6 +73,7 @@ namespace HudCustomizer { components: { [id: string]: { position: LayoutUtil.Position; + size: LayoutUtil.Size; snaps: [number, number]; }; }; @@ -60,6 +86,7 @@ namespace HudCustomizer { panel: Panel; snaps: Snaps; position: LayoutUtil.Position; + size: LayoutUtil.Size; properties?: Record; } @@ -133,8 +160,7 @@ namespace HudCustomizer { virtualName: $