Merge pull request #64 from wanderer-industries/design-issues

feat(Map): a lot of design issues
This commit is contained in:
Aleksei Chichenkov
2024-11-16 18:05:08 +03:00
committed by GitHub
22 changed files with 309 additions and 173 deletions

View File

@@ -15,11 +15,10 @@ const ErrorFallback = () => {
}; };
export default function MapRoot({ hooks }) { export default function MapRoot({ hooks }) {
const mapRef = useRef<MapHandlers>(null);
const providerRef = useRef<MapHandlers>(null); const providerRef = useRef<MapHandlers>(null);
const hooksRef = useRef<any>(hooks); const hooksRef = useRef<any>(hooks);
const mapperHandlerRefs = useRef([mapRef, providerRef]); const mapperHandlerRefs = useRef([providerRef]);
const { handleCommand, handleMapEvent, handleMapEvents } = useMapperHandlers(mapperHandlerRefs.current, hooksRef); const { handleCommand, handleMapEvent, handleMapEvents } = useMapperHandlers(mapperHandlerRefs.current, hooksRef);
@@ -41,7 +40,7 @@ export default function MapRoot({ hooks }) {
return ( return (
<PrimeReactProvider> <PrimeReactProvider>
<MapRootProvider fwdRef={providerRef} outCommand={handleCommand} mapRef={mapRef}> <MapRootProvider fwdRef={providerRef} outCommand={handleCommand}>
<ErrorBoundary FallbackComponent={ErrorFallback} onError={logError}> <ErrorBoundary FallbackComponent={ErrorFallback} onError={logError}>
<ReactFlowProvider> <ReactFlowProvider>
<MapRootContent /> <MapRootContent />

View File

@@ -1,20 +1,19 @@
import { useCallback } from 'react'; import { useCallback } from 'react';
import clsx from 'clsx'; import clsx from 'clsx';
import { useAutoAnimate } from '@formkit/auto-animate/react'; import { useAutoAnimate } from '@formkit/auto-animate/react';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
import { Commands } from '@/hooks/Mapper/types/mapHandlers.ts'; import { Commands } from '@/hooks/Mapper/types/mapHandlers.ts';
import { CharacterTypeRaw } from '@/hooks/Mapper/types'; import { CharacterTypeRaw } from '@/hooks/Mapper/types';
import { emitMapEvent } from '@/hooks/Mapper/events';
const Characters = ({ data }: { data: CharacterTypeRaw[] }) => { const Characters = ({ data }: { data: CharacterTypeRaw[] }) => {
const [parent] = useAutoAnimate(); const [parent] = useAutoAnimate();
const { mapRef } = useMapRootState();
const handleSelect = useCallback( const handleSelect = useCallback((character: CharacterTypeRaw) => {
(character: CharacterTypeRaw) => { emitMapEvent({
mapRef.current?.command(Commands.centerSystem, character?.location?.solar_system_id?.toString()); name: Commands.centerSystem,
}, data: character?.location?.solar_system_id?.toString(),
[mapRef], });
); }, []);
const items = data.map(character => ( const items = data.map(character => (
<li <li

View File

@@ -1,25 +1,25 @@
import { RefObject, useCallback, useRef, useState } from 'react'; import * as React from 'react';
import { useCallback, useRef, useState } from 'react';
import { ContextMenu } from 'primereact/contextmenu'; import { ContextMenu } from 'primereact/contextmenu';
import { Commands, MapHandlers, OutCommand, OutCommandHandler } from '@/hooks/Mapper/types/mapHandlers.ts'; import { Commands, OutCommand, OutCommandHandler } from '@/hooks/Mapper/types/mapHandlers.ts';
import { WaypointSetContextHandler } from '@/hooks/Mapper/components/contexts/types.ts'; import { WaypointSetContextHandler } from '@/hooks/Mapper/components/contexts/types.ts';
import { ctxManager } from '@/hooks/Mapper/utils/contextManager.ts'; import { ctxManager } from '@/hooks/Mapper/utils/contextManager.ts';
import * as React from 'react';
import { SolarSystemStaticInfoRaw } from '@/hooks/Mapper/types'; import { SolarSystemStaticInfoRaw } from '@/hooks/Mapper/types';
import { emitMapEvent } from '@/hooks/Mapper/events';
interface UseContextMenuSystemHandlersProps { interface UseContextMenuSystemHandlersProps {
hubs: string[]; hubs: string[];
outCommand: OutCommandHandler; outCommand: OutCommandHandler;
mapRef: RefObject<MapHandlers>;
} }
export const useContextMenuSystemInfoHandlers = ({ hubs, outCommand, mapRef }: UseContextMenuSystemHandlersProps) => { export const useContextMenuSystemInfoHandlers = ({ hubs, outCommand }: UseContextMenuSystemHandlersProps) => {
const contextMenuRef = useRef<ContextMenu | null>(null); const contextMenuRef = useRef<ContextMenu | null>(null);
const [system, setSystem] = useState<string>(); const [system, setSystem] = useState<string>();
const routeRef = useRef<(SolarSystemStaticInfoRaw | undefined)[]>([]); const routeRef = useRef<(SolarSystemStaticInfoRaw | undefined)[]>([]);
const ref = useRef({ hubs, system, outCommand, mapRef }); const ref = useRef({ hubs, system, outCommand });
ref.current = { hubs, system, outCommand, mapRef }; ref.current = { hubs, system, outCommand };
const open = useCallback( const open = useCallback(
(ev: React.SyntheticEvent, systemId: string, route: (SolarSystemStaticInfoRaw | undefined)[]) => { (ev: React.SyntheticEvent, systemId: string, route: (SolarSystemStaticInfoRaw | undefined)[]) => {
@@ -48,7 +48,7 @@ export const useContextMenuSystemInfoHandlers = ({ hubs, outCommand, mapRef }: U
}, []); }, []);
const onAddSystem = useCallback(() => { const onAddSystem = useCallback(() => {
const { system: solarSystemId, outCommand, mapRef } = ref.current; const { system: solarSystemId, outCommand } = ref.current;
if (!solarSystemId) { if (!solarSystemId) {
return; return;
} }
@@ -60,7 +60,11 @@ export const useContextMenuSystemInfoHandlers = ({ hubs, outCommand, mapRef }: U
}, },
}); });
setTimeout(() => { setTimeout(() => {
mapRef.current?.command(Commands.centerSystem, solarSystemId); emitMapEvent({
name: Commands.centerSystem,
data: solarSystemId,
});
setSystem(undefined); setSystem(undefined);
}, 200); }, 200);
}, []); }, []);

View File

@@ -1,10 +1,11 @@
import { ForwardedRef, forwardRef, MouseEvent, useCallback, useEffect, useRef } from 'react'; import { ForwardedRef, forwardRef, MouseEvent, useCallback, useEffect } from 'react';
import ReactFlow, { import ReactFlow, {
Background, Background,
ConnectionMode, ConnectionMode,
Edge, Edge,
MiniMap, MiniMap,
Node, Node,
NodeChange,
NodeDragHandler, NodeDragHandler,
OnConnect, OnConnect,
OnMoveEnd, OnMoveEnd,
@@ -13,7 +14,6 @@ import ReactFlow, {
SelectionMode, SelectionMode,
useEdgesState, useEdgesState,
useNodesState, useNodesState,
NodeChange,
useReactFlow, useReactFlow,
} from 'reactflow'; } from 'reactflow';
import 'reactflow/dist/style.css'; import 'reactflow/dist/style.css';
@@ -21,7 +21,6 @@ import classes from './Map.module.scss';
import './styles/neon-theme.scss'; import './styles/neon-theme.scss';
import './styles/eve-common.scss'; import './styles/eve-common.scss';
import { MapProvider, useMapState } from './MapProvider'; import { MapProvider, useMapState } from './MapProvider';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
import { useMapHandlers, useUpdateNodes } from './hooks'; import { useMapHandlers, useUpdateNodes } from './hooks';
import { MapHandlers, OutCommand, OutCommandHandler } from '@/hooks/Mapper/types/mapHandlers.ts'; import { MapHandlers, OutCommand, OutCommandHandler } from '@/hooks/Mapper/types/mapHandlers.ts';
import { import {
@@ -37,7 +36,6 @@ import { SESSION_KEY } from '@/hooks/Mapper/constants.ts';
import { SolarSystemConnection, SolarSystemRawType } from '@/hooks/Mapper/types'; import { SolarSystemConnection, SolarSystemRawType } from '@/hooks/Mapper/types';
import { ctxManager } from '@/hooks/Mapper/utils/contextManager.ts'; import { ctxManager } from '@/hooks/Mapper/utils/contextManager.ts';
import { NodeSelectionMouseHandler } from '@/hooks/Mapper/components/contexts/types.ts'; import { NodeSelectionMouseHandler } from '@/hooks/Mapper/components/contexts/types.ts';
import { useDeleteSystems } from '@/hooks/Mapper/components/contexts/hooks';
const DEFAULT_VIEW_PORT = { zoom: 1, x: 0, y: 0 }; const DEFAULT_VIEW_PORT = { zoom: 1, x: 0, y: 0 };
@@ -93,12 +91,14 @@ interface MapCompProps {
refn: ForwardedRef<MapHandlers>; refn: ForwardedRef<MapHandlers>;
onCommand: OutCommandHandler; onCommand: OutCommandHandler;
onSelectionChange: OnMapSelectionChange; onSelectionChange: OnMapSelectionChange;
onManualDelete(systems: string[]): void;
onConnectionInfoClick?(e: SolarSystemConnection): void; onConnectionInfoClick?(e: SolarSystemConnection): void;
onSelectionContextMenu?: NodeSelectionMouseHandler; onSelectionContextMenu?: NodeSelectionMouseHandler;
minimapClasses?: string; minimapClasses?: string;
isShowMinimap?: boolean; isShowMinimap?: boolean;
onSystemContextMenu: (event: MouseEvent<Element>, systemId: string) => void; onSystemContextMenu: (event: MouseEvent<Element>, systemId: string) => void;
showKSpaceBG?: boolean; showKSpaceBG?: boolean;
isThickConnections?: boolean;
} }
const MapComp = ({ const MapComp = ({
@@ -109,8 +109,10 @@ const MapComp = ({
onSystemContextMenu, onSystemContextMenu,
onConnectionInfoClick, onConnectionInfoClick,
onSelectionContextMenu, onSelectionContextMenu,
onManualDelete,
isShowMinimap, isShowMinimap,
showKSpaceBG, showKSpaceBG,
isThickConnections,
}: MapCompProps) => { }: MapCompProps) => {
const { getNode } = useReactFlow(); const { getNode } = useReactFlow();
const [nodes, , onNodesChange] = useNodesState<SolarSystemRawType>(initialNodes); const [nodes, , onNodesChange] = useNodesState<SolarSystemRawType>(initialNodes);
@@ -121,14 +123,6 @@ const MapComp = ({
const { handleRootContext, ...rootCtxProps } = useContextMenuRootHandlers(); const { handleRootContext, ...rootCtxProps } = useContextMenuRootHandlers();
const { handleConnectionContext, ...connectionCtxProps } = useContextMenuConnectionHandlers(); const { handleConnectionContext, ...connectionCtxProps } = useContextMenuConnectionHandlers();
const { update } = useMapState(); const { update } = useMapState();
const {
data: { systems },
} = useMapRootState();
const { deleteSystems } = useDeleteSystems();
const systemsRef = useRef({ systems });
systemsRef.current = { systems };
const onConnect: OnConnect = useCallback( const onConnect: OnConnect = useCallback(
params => { params => {
@@ -186,35 +180,41 @@ const MapComp = ({
const handleNodesChange = useCallback( const handleNodesChange = useCallback(
(changes: NodeChange[]) => { (changes: NodeChange[]) => {
const systemsIdsToRemove: string[] = []; const systemsIdsToRemove: string[] = [];
const nextChanges = changes.reduce((acc, change) => { const nextChanges = changes.reduce((acc, change) => {
if (change.type === 'remove') { if (change.type !== 'remove') {
const node = getNode(change.id); return [...acc, change];
const { systems = [] } = systemsRef.current; }
if (node?.data?.id && !systems.map(s => s.id).includes(node?.data?.id)) {
return [...acc, change]; const node = getNode(change.id);
} else if (!node?.data?.locked) { if (!node) {
systemsIdsToRemove.push(node?.data?.id); return [...acc, change];
} }
if (node.data.locked) {
return acc; return acc;
} }
systemsIdsToRemove.push(node.data.id);
return [...acc, change]; return [...acc, change];
}, [] as NodeChange[]); }, [] as NodeChange[]);
if (systemsIdsToRemove.length) { if (systemsIdsToRemove.length > 0) {
deleteSystems(systemsIdsToRemove); onManualDelete(systemsIdsToRemove);
} }
onNodesChange(nextChanges); onNodesChange(nextChanges);
}, },
[deleteSystems, getNode, onNodesChange], [getNode, onManualDelete, onNodesChange],
); );
useEffect(() => { useEffect(() => {
update(x => ({ update(x => ({
...x, ...x,
showKSpaceBG: showKSpaceBG, showKSpaceBG: showKSpaceBG,
isThickConnections: isThickConnections,
})); }));
}, [showKSpaceBG, update]); }, [showKSpaceBG, isThickConnections, update]);
return ( return (
<> <>
@@ -238,6 +238,7 @@ const MapComp = ({
onConnectStart={() => update({ isConnecting: true })} onConnectStart={() => update({ isConnecting: true })}
onConnectEnd={() => update({ isConnecting: false })} onConnectEnd={() => update({ isConnecting: false })}
onNodeMouseEnter={(_, node) => update({ hoverNodeId: node.id })} onNodeMouseEnter={(_, node) => update({ hoverNodeId: node.id })}
// onKeyUp=
onNodeMouseLeave={() => update({ hoverNodeId: null })} onNodeMouseLeave={() => update({ hoverNodeId: null })}
onEdgeClick={(_, t) => { onEdgeClick={(_, t) => {
onConnectionInfoClick?.(t.data); onConnectionInfoClick?.(t.data);

View File

@@ -8,6 +8,7 @@ export type MapData = MapUnionTypes & {
hoverNodeId: string | null; hoverNodeId: string | null;
visibleNodes: Set<string>; visibleNodes: Set<string>;
showKSpaceBG: boolean; showKSpaceBG: boolean;
isThickConnections: boolean;
}; };
interface MapProviderProps { interface MapProviderProps {
@@ -17,6 +18,7 @@ interface MapProviderProps {
const INITIAL_DATA: MapData = { const INITIAL_DATA: MapData = {
wormholesData: {}, wormholesData: {},
wormholes: [],
effects: {}, effects: {},
characters: [], characters: [],
userCharacters: [], userCharacters: [],
@@ -29,6 +31,7 @@ const INITIAL_DATA: MapData = {
hoverNodeId: null, hoverNodeId: null,
visibleNodes: new Set(), visibleNodes: new Set(),
showKSpaceBG: false, showKSpaceBG: false,
isThickConnections: false,
}; };
export interface MapContextProps { export interface MapContextProps {

View File

@@ -21,7 +21,7 @@
} }
&.Frigate { &.Frigate {
stroke: #4e62c9; stroke: #d4f0ff;
} }
&.Hovered { &.Hovered {
@@ -37,9 +37,16 @@
} }
&.Frigate { &.Frigate {
stroke: #41acd7; stroke: #d4f0ff;
} }
}
&.Tick {
stroke-width: 3px;
&.Hovered {
stroke-width: 3px;
}
} }
} }
@@ -61,6 +68,14 @@
stroke: #ef7dce; stroke: #ef7dce;
} }
} }
&.Tick {
stroke-width: 5px;
&.TimeCrit {
stroke-width: 6px;
}
}
} }
.ClickPath { .ClickPath {
@@ -93,5 +108,14 @@
width: 5px; width: 5px;
height: 5px; height: 5px;
z-index: 1001; z-index: 1001;
&.Tick {
width: 7px;
height: 7px;
&.Right {
margin-left: 0px;
}
}
} }

View File

@@ -7,33 +7,54 @@ import clsx from 'clsx';
import { MassState, ShipSizeStatus, SolarSystemConnection, TimeStatus } from '@/hooks/Mapper/types'; import { MassState, ShipSizeStatus, SolarSystemConnection, TimeStatus } from '@/hooks/Mapper/types';
import { PrimeIcons } from 'primereact/api'; import { PrimeIcons } from 'primereact/api';
import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper'; import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper';
import { useMapState } from '@/hooks/Mapper/components/map/MapProvider.tsx';
const MAP_TRANSLATES: Record<string, string> = { const MAP_TRANSLATES: Record<string, string> = {
[Position.Top]: 'translate(-50%, 0%)', [Position.Top]: 'translate(-48%, 0%)',
[Position.Bottom]: 'translate(-50%, -100%)', [Position.Bottom]: 'translate(-50%, -100%)',
[Position.Left]: 'translate(0%, -50%)', [Position.Left]: 'translate(0%, -50%)',
[Position.Right]: 'translate(-100%, -50%)', [Position.Right]: 'translate(-100%, -50%)',
}; };
const MAP_OFFSETS_TICK: Record<string, { x: number; y: number }> = {
[Position.Top]: { x: 0, y: 3 },
[Position.Bottom]: { x: 0, y: -3 },
[Position.Left]: { x: 3, y: 0 },
[Position.Right]: { x: -3, y: 0 },
};
const MAP_OFFSETS: Record<string, { x: number; y: number }> = {
[Position.Top]: { x: 0, y: 0 },
[Position.Bottom]: { x: 0, y: 0 },
[Position.Left]: { x: 0, y: 0 },
[Position.Right]: { x: 0, y: 0 },
};
export const SolarSystemEdge = ({ id, source, target, markerEnd, style, data }: EdgeProps<SolarSystemConnection>) => { export const SolarSystemEdge = ({ id, source, target, markerEnd, style, data }: EdgeProps<SolarSystemConnection>) => {
const sourceNode = useStore(useCallback(store => store.nodeInternals.get(source), [source])); const sourceNode = useStore(useCallback(store => store.nodeInternals.get(source), [source]));
const targetNode = useStore(useCallback(store => store.nodeInternals.get(target), [target])); const targetNode = useStore(useCallback(store => store.nodeInternals.get(target), [target]));
const {
data: { isThickConnections },
} = useMapState();
const [hovered, setHovered] = useState(false); const [hovered, setHovered] = useState(false);
const [path, labelX, labelY, sx, sy, tx, ty, sourcePos, targetPos] = useMemo(() => { const [path, labelX, labelY, sx, sy, tx, ty, sourcePos, targetPos] = useMemo(() => {
const { sx, sy, tx, ty, sourcePos, targetPos } = getEdgeParams(sourceNode, targetNode); const { sx, sy, tx, ty, sourcePos, targetPos } = getEdgeParams(sourceNode, targetNode);
const offset = isThickConnections ? MAP_OFFSETS_TICK[targetPos] : MAP_OFFSETS[targetPos];
const [edgePath, labelX, labelY] = getBezierPath({ const [edgePath, labelX, labelY] = getBezierPath({
sourceX: sx, sourceX: sx - offset.x,
sourceY: sy, sourceY: sy - offset.y,
sourcePosition: sourcePos, sourcePosition: sourcePos,
targetPosition: targetPos, targetPosition: targetPos,
targetX: tx, targetX: tx + offset.x,
targetY: ty, targetY: ty + offset.y,
}); });
return [edgePath, labelX, labelY, sx, sy, tx, ty, sourcePos, targetPos]; return [edgePath, labelX, labelY, sx, sy, tx, ty, sourcePos, targetPos];
}, [sourceNode, targetNode]); }, [isThickConnections, sourceNode, targetNode]);
if (!sourceNode || !targetNode || !data) { if (!sourceNode || !targetNode || !data) {
return null; return null;
@@ -44,6 +65,7 @@ export const SolarSystemEdge = ({ id, source, target, markerEnd, style, data }:
<path <path
id={`back_${id}`} id={`back_${id}`}
className={clsx(classes.EdgePathBack, { className={clsx(classes.EdgePathBack, {
[classes.Tick]: isThickConnections,
[classes.TimeCrit]: data.time_status === TimeStatus.eol, [classes.TimeCrit]: data.time_status === TimeStatus.eol,
[classes.Hovered]: hovered, [classes.Hovered]: hovered,
})} })}
@@ -54,6 +76,7 @@ export const SolarSystemEdge = ({ id, source, target, markerEnd, style, data }:
<path <path
id={`front_${id}`} id={`front_${id}`}
className={clsx(classes.EdgePathFront, { className={clsx(classes.EdgePathFront, {
[classes.Tick]: isThickConnections,
[classes.Hovered]: hovered, [classes.Hovered]: hovered,
[classes.MassVerge]: data.mass_status === MassState.verge, [classes.MassVerge]: data.mass_status === MassState.verge,
[classes.MassHalf]: data.mass_status === MassState.half, [classes.MassHalf]: data.mass_status === MassState.half,
@@ -75,11 +98,19 @@ export const SolarSystemEdge = ({ id, source, target, markerEnd, style, data }:
<EdgeLabelRenderer> <EdgeLabelRenderer>
<div <div
className={clsx(classes.Handle, 'react-flow__handle absolute nodrag pointer-events-none')} className={clsx(
classes.Handle,
{ [classes.Tick]: isThickConnections, [classes.Right]: Position.Right === sourcePos },
'react-flow__handle absolute nodrag pointer-events-none',
)}
style={{ transform: `${MAP_TRANSLATES[sourcePos]} translate(${sx}px,${sy}px)` }} style={{ transform: `${MAP_TRANSLATES[sourcePos]} translate(${sx}px,${sy}px)` }}
/> />
<div <div
className={clsx(classes.Handle, 'react-flow__handle absolute nodrag pointer-events-none')} className={clsx(
classes.Handle,
{ [classes.Tick]: isThickConnections },
'react-flow__handle absolute nodrag pointer-events-none',
)}
style={{ transform: `${MAP_TRANSLATES[targetPos]} translate(${tx}px,${ty}px)` }} style={{ transform: `${MAP_TRANSLATES[targetPos]} translate(${tx}px,${ty}px)` }}
/> />

View File

@@ -212,6 +212,14 @@ $tooltip-bg: #202020; // Темный фон для подсказок
color: #ffb01d; color: #ffb01d;
} }
/* Firefox kostyl */
@-moz-document url-prefix() {
.classSystemName {
font-family: inherit !important;
font-weight: bold;
}
}
.classSystemName { .classSystemName {
//font-weight: bold; //font-weight: bold;
} }
@@ -262,6 +270,13 @@ $tooltip-bg: #202020; // Темный фон для подсказок
& > * { & > * {
line-height: 10px; line-height: 10px;
} }
/* Firefox kostyl */
@-moz-document url-prefix() {
position: relative;
top: -1px;
}
} }
.Handlers { .Handlers {
@@ -299,4 +314,25 @@ $tooltip-bg: #202020; // Темный фон для подсказок
&.HandleLeft { &.HandleLeft {
left: -2px; left: -2px;
} }
&.Tick {
width: 7px;
height: 7px;
&.HandleTop {
top: -3px;
}
&.HandleRight {
right: -3px;
}
&.HandleBottom {
bottom: -3px;
}
&.HandleLeft {
left: -3px;
}
}
} }

View File

@@ -79,6 +79,7 @@ export const SolarSystemNode = memo(({ data, selected }: WrapNodeProps<MapSolarS
hoverNodeId, hoverNodeId,
visibleNodes, visibleNodes,
showKSpaceBG, showKSpaceBG,
isThickConnections,
}, },
outCommand, outCommand,
} = useMapState(); } = useMapState();
@@ -239,28 +240,40 @@ export const SolarSystemNode = memo(({ data, selected }: WrapNodeProps<MapSolarS
<div onMouseDownCapture={dbClick} className={classes.Handlers}> <div onMouseDownCapture={dbClick} className={classes.Handlers}>
<Handle <Handle
type="source" type="source"
className={clsx(classes.Handle, classes.HandleTop, { [classes.selected]: selected })} className={clsx(classes.Handle, classes.HandleTop, {
[classes.selected]: selected,
[classes.Tick]: isThickConnections,
})}
style={{ visibility: showHandlers ? 'visible' : 'hidden' }} style={{ visibility: showHandlers ? 'visible' : 'hidden' }}
position={Position.Top} position={Position.Top}
id="a" id="a"
/> />
<Handle <Handle
type="source" type="source"
className={clsx(classes.Handle, classes.HandleRight, { [classes.selected]: selected })} className={clsx(classes.Handle, classes.HandleRight, {
[classes.selected]: selected,
[classes.Tick]: isThickConnections,
})}
style={{ visibility: showHandlers ? 'visible' : 'hidden' }} style={{ visibility: showHandlers ? 'visible' : 'hidden' }}
position={Position.Right} position={Position.Right}
id="b" id="b"
/> />
<Handle <Handle
type="source" type="source"
className={clsx(classes.Handle, classes.HandleBottom, { [classes.selected]: selected })} className={clsx(classes.Handle, classes.HandleBottom, {
[classes.selected]: selected,
[classes.Tick]: isThickConnections,
})}
style={{ visibility: showHandlers ? 'visible' : 'hidden' }} style={{ visibility: showHandlers ? 'visible' : 'hidden' }}
position={Position.Bottom} position={Position.Bottom}
id="c" id="c"
/> />
<Handle <Handle
type="source" type="source"
className={clsx(classes.Handle, classes.HandleLeft, { [classes.selected]: selected })} className={clsx(classes.Handle, classes.HandleLeft, {
[classes.selected]: selected,
[classes.Tick]: isThickConnections,
})}
style={{ visibility: showHandlers ? 'visible' : 'hidden' }} style={{ visibility: showHandlers ? 'visible' : 'hidden' }}
position={Position.Left} position={Position.Left}
id="d" id="d"

View File

@@ -5,24 +5,21 @@ import { OnMapSelectionChange } from '@/hooks/Mapper/components/map/map.types.ts
export const useMapRemoveSystems = (onSelectionChange: OnMapSelectionChange) => { export const useMapRemoveSystems = (onSelectionChange: OnMapSelectionChange) => {
const rf = useReactFlow(); const rf = useReactFlow();
const ref = useRef({ onSelectionChange }); const ref = useRef({ onSelectionChange, rf });
ref.current = { onSelectionChange }; ref.current = { onSelectionChange, rf };
return useCallback( return useCallback((systems: CommandRemoveSystems) => {
(systems: CommandRemoveSystems) => { ref.current.rf.deleteElements({ nodes: systems.map(x => ({ id: `${x}` })) });
rf.deleteElements({ nodes: systems.map(x => ({ id: `${x}` })) });
const newSelection = rf const newSelection = ref.current.rf
.getNodes() .getNodes()
.filter(x => !systems.includes(parseInt(x.id))) .filter(x => !systems.includes(parseInt(x.id)))
.filter(x => x.selected) .filter(x => x.selected)
.map(x => x.id); .map(x => x.id);
ref.current.onSelectionChange({ ref.current.onSelectionChange({
systems: newSelection, systems: newSelection,
connections: [], connections: [],
}); });
}, }, []);
[rf],
);
}; };

View File

@@ -19,8 +19,6 @@ import {
MapHandlers, MapHandlers,
} from '@/hooks/Mapper/types/mapHandlers.ts'; } from '@/hooks/Mapper/types/mapHandlers.ts';
import { useMapEventListener } from '@/hooks/Mapper/events';
import { import {
useCommandsCharacters, useCommandsCharacters,
useCommandsConnections, useCommandsConnections,
@@ -60,13 +58,16 @@ export const useMapHandlers = (ref: ForwardedRef<MapHandlers>, onSelectionChange
mapInit(data as CommandInit); mapInit(data as CommandInit);
break; break;
case Commands.addSystems: case Commands.addSystems:
setTimeout(() => mapAddSystems(data as CommandAddSystems), 100);
break; break;
case Commands.updateSystems: case Commands.updateSystems:
mapUpdateSystems(data as CommandUpdateSystems); mapUpdateSystems(data as CommandUpdateSystems);
break; break;
case Commands.removeSystems: case Commands.removeSystems:
setTimeout(() => removeSystems(data as CommandRemoveSystems), 100);
break; break;
case Commands.addConnections: case Commands.addConnections:
setTimeout(() => addConnections(data as CommandAddConnections), 100);
break; break;
case Commands.removeConnections: case Commands.removeConnections:
removeConnections(data as CommandRemoveConnections); removeConnections(data as CommandRemoveConnections);
@@ -131,20 +132,4 @@ export const useMapHandlers = (ref: ForwardedRef<MapHandlers>, onSelectionChange
}, },
[], [],
); );
useMapEventListener(event => {
switch (event.name) {
case Commands.addConnections:
addConnections(event.data as CommandAddConnections);
break;
case Commands.addSystems:
mapAddSystems(event.data as CommandAddSystems);
break;
case Commands.removeSystems:
removeSystems(event.data as CommandRemoveSystems);
break;
default:
break;
}
});
}; };

View File

@@ -5,7 +5,7 @@ import { SystemViewStandalone, WdTooltip, WdTooltipHandlers } from '@/hooks/Mapp
import { getBackgroundClass, getShapeClass } from '@/hooks/Mapper/components/map/helpers'; import { getBackgroundClass, getShapeClass } from '@/hooks/Mapper/components/map/helpers';
import { MouseEvent, useCallback, useRef, useState } from 'react'; import { MouseEvent, useCallback, useRef, useState } from 'react';
import { Commands } from '@/hooks/Mapper/types'; import { Commands } from '@/hooks/Mapper/types';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider'; import { emitMapEvent } from '@/hooks/Mapper/events';
export type RouteSystemProps = { export type RouteSystemProps = {
destination: number; destination: number;
@@ -88,11 +88,10 @@ export interface RoutesListProps {
export const RoutesList = ({ data, onContextMenu }: RoutesListProps) => { export const RoutesList = ({ data, onContextMenu }: RoutesListProps) => {
const [selected, setSelected] = useState<number | null>(null); const [selected, setSelected] = useState<number | null>(null);
const { mapRef } = useMapRootState();
const handleClick = useCallback( const handleClick = useCallback(
(systemId: number) => mapRef.current?.command(Commands.centerSystem, systemId.toString()), (systemId: number) => emitMapEvent({ name: Commands.centerSystem, data: systemId?.toString() }),
[mapRef], [],
); );
if (!data.has_connection) { if (!data.has_connection) {

View File

@@ -30,7 +30,6 @@ const sortByDist = (a: Route, b: Route) => {
export const RoutesWidgetContent = () => { export const RoutesWidgetContent = () => {
const { const {
data: { selectedSystems, hubs = [], systems, routes }, data: { selectedSystems, hubs = [], systems, routes },
mapRef,
outCommand, outCommand,
} = useMapRootState(); } = useMapRootState();
@@ -42,7 +41,6 @@ export const RoutesWidgetContent = () => {
const { open, ...systemCtxProps } = useContextMenuSystemInfoHandlers({ const { open, ...systemCtxProps } = useContextMenuSystemInfoHandlers({
outCommand, outCommand,
hubs, hubs,
mapRef,
}); });
const preparedHubs = useMemo(() => { const preparedHubs = useMemo(() => {

View File

@@ -7,13 +7,13 @@ import { useCallback, useState } from 'react';
import { OnTheMap, RightBar } from '@/hooks/Mapper/components/mapRootContent/components'; import { OnTheMap, RightBar } from '@/hooks/Mapper/components/mapRootContent/components';
import { MapContextMenu } from '@/hooks/Mapper/components/mapRootContent/components/MapContextMenu/MapContextMenu.tsx'; import { MapContextMenu } from '@/hooks/Mapper/components/mapRootContent/components/MapContextMenu/MapContextMenu.tsx';
import { useSkipContextMenu } from '@/hooks/Mapper/hooks/useSkipContextMenu'; import { useSkipContextMenu } from '@/hooks/Mapper/hooks/useSkipContextMenu';
import { MapSettings } from "@/hooks/Mapper/components/mapRootContent/components/MapSettings"; import { MapSettings } from '@/hooks/Mapper/components/mapRootContent/components/MapSettings';
export interface MapRootContentProps {} export interface MapRootContentProps {}
// eslint-disable-next-line no-empty-pattern // eslint-disable-next-line no-empty-pattern
export const MapRootContent = ({}: MapRootContentProps) => { export const MapRootContent = ({}: MapRootContentProps) => {
const { mapRef, interfaceSettings } = useMapRootState(); const { interfaceSettings } = useMapRootState();
const { isShowMenu } = interfaceSettings; const { isShowMenu } = interfaceSettings;
const [showOnTheMap, setShowOnTheMap] = useState(false); const [showOnTheMap, setShowOnTheMap] = useState(false);
@@ -26,7 +26,7 @@ export const MapRootContent = ({}: MapRootContentProps) => {
useSkipContextMenu(); useSkipContextMenu();
return ( return (
<Layout map={<MapWrapper refn={mapRef} />}> <Layout map={<MapWrapper />}>
{!isShowMenu ? ( {!isShowMenu ? (
<div className="absolute top-0 left-14 w-[calc(100%-3.5rem)] h-[calc(100%-3.5rem)] pointer-events-none"> <div className="absolute top-0 left-14 w-[calc(100%-3.5rem)] h-[calc(100%-3.5rem)] pointer-events-none">
<div className="absolute top-0 left-0 w-[calc(100%-3.5rem)] h-full pointer-events-none"> <div className="absolute top-0 left-0 w-[calc(100%-3.5rem)] h-full pointer-events-none">

View File

@@ -61,6 +61,7 @@ const CONNECTIONS_CHECKBOXES_PROPS: CheckboxesList = [
const UI_CHECKBOXES_PROPS: CheckboxesList = [ const UI_CHECKBOXES_PROPS: CheckboxesList = [
{ prop: InterfaceStoredSettingsProps.isShowMenu, label: 'Enable compact map menu bar' }, { prop: InterfaceStoredSettingsProps.isShowMenu, label: 'Enable compact map menu bar' },
{ prop: InterfaceStoredSettingsProps.isThickConnections, label: 'Tick connections' },
]; ];
export const MapSettings = ({ show, onHide }: MapSettingsProps) => { export const MapSettings = ({ show, onHide }: MapSettingsProps) => {

View File

@@ -1,14 +1,14 @@
import { Map } from '@/hooks/Mapper/components/map/Map.tsx'; import { Map } from '@/hooks/Mapper/components/map/Map.tsx';
import { ForwardedRef, useCallback, useRef, useState } from 'react'; import { useCallback, useRef, useState } from 'react';
import { MapHandlers, OutCommand, OutCommandHandler, SolarSystemConnection } from '@/hooks/Mapper/types'; import { OutCommand, OutCommandHandler, SolarSystemConnection } from '@/hooks/Mapper/types';
import { MapRootData, useMapRootState } from '@/hooks/Mapper/mapRootProvider'; import { MapRootData, useMapRootState } from '@/hooks/Mapper/mapRootProvider';
import { OnMapSelectionChange } from '@/hooks/Mapper/components/map/map.types.ts'; import { OnMapSelectionChange } from '@/hooks/Mapper/components/map/map.types.ts';
import isEqual from 'lodash.isequal'; import isEqual from 'lodash.isequal';
import { ContextMenuSystem, useContextMenuSystemHandlers } from '@/hooks/Mapper/components/contexts'; import { ContextMenuSystem, useContextMenuSystemHandlers } from '@/hooks/Mapper/components/contexts';
import { import {
SystemCustomLabelDialog, SystemCustomLabelDialog,
SystemSettingsDialog,
SystemLinkSignatureDialog, SystemLinkSignatureDialog,
SystemSettingsDialog,
} from '@/hooks/Mapper/components/mapInterface/components'; } from '@/hooks/Mapper/components/mapInterface/components';
import classes from './MapWrapper.module.scss'; import classes from './MapWrapper.module.scss';
import { Connections } from '@/hooks/Mapper/components/mapRootContent/components/Connections'; import { Connections } from '@/hooks/Mapper/components/mapRootContent/components/Connections';
@@ -20,25 +20,45 @@ import { Commands } from '@/hooks/Mapper/types/mapHandlers.ts';
import { useMapEventListener } from '@/hooks/Mapper/events'; import { useMapEventListener } from '@/hooks/Mapper/events';
import { STORED_INTERFACE_DEFAULT_VALUES } from '@/hooks/Mapper/mapRootProvider/MapRootProvider'; import { STORED_INTERFACE_DEFAULT_VALUES } from '@/hooks/Mapper/mapRootProvider/MapRootProvider';
import { useDeleteSystems } from '@/hooks/Mapper/components/contexts/hooks';
interface MapWrapperProps { import { useCommonMapEventProcessor } from '@/hooks/Mapper/components/mapWrapper/hooks/useCommonMapEventProcessor.ts';
refn: ForwardedRef<MapHandlers>;
}
// TODO: INFO - this component needs for abstract work with Map instance // TODO: INFO - this component needs for abstract work with Map instance
export const MapWrapper = ({ refn }: MapWrapperProps) => { export const MapWrapper = () => {
const { const {
update, update,
outCommand, outCommand,
data: { selectedConnections, selectedSystems, hubs, systems }, data: { selectedConnections, selectedSystems, hubs, systems },
interfaceSettings: { isShowMenu, isShowMinimap = STORED_INTERFACE_DEFAULT_VALUES.isShowMinimap, isShowKSpace }, interfaceSettings: {
isShowMenu,
isShowMinimap = STORED_INTERFACE_DEFAULT_VALUES.isShowMinimap,
isShowKSpace,
isThickConnections,
},
} = useMapRootState(); } = useMapRootState();
const { deleteSystems } = useDeleteSystems();
const { mapRef, runCommand } = useCommonMapEventProcessor();
const { open, ...systemContextProps } = useContextMenuSystemHandlers({ systems, hubs, outCommand }); const { open, ...systemContextProps } = useContextMenuSystemHandlers({ systems, hubs, outCommand });
const { handleSystemMultipleContext, ...systemMultipleCtxProps } = useContextMenuSystemMultipleHandlers(); const { handleSystemMultipleContext, ...systemMultipleCtxProps } = useContextMenuSystemMultipleHandlers();
const ref = useRef({ selectedConnections, selectedSystems, systemContextProps, systems }); const [openSettings, setOpenSettings] = useState<string | null>(null);
ref.current = { selectedConnections, selectedSystems, systemContextProps, systems }; const [openLinkSignatures, setOpenLinkSignatures] = useState<any | null>(null);
const [openCustomLabel, setOpenCustomLabel] = useState<string | null>(null);
const [selectedConnection, setSelectedConnection] = useState<SolarSystemConnection | null>(null);
const ref = useRef({ selectedConnections, selectedSystems, systemContextProps, systems, deleteSystems });
ref.current = { selectedConnections, selectedSystems, systemContextProps, systems, deleteSystems };
useMapEventListener(event => {
switch (event.name) {
case Commands.linkSignatureToSystem:
setOpenLinkSignatures(event.data);
return true;
}
runCommand(event);
});
const onSelectionChange: OnMapSelectionChange = useCallback( const onSelectionChange: OnMapSelectionChange = useCallback(
({ systems, connections }) => { ({ systems, connections }) => {
@@ -59,9 +79,6 @@ export const MapWrapper = ({ refn }: MapWrapperProps) => {
[update], [update],
); );
const [openSettings, setOpenSettings] = useState<string | null>(null);
const [openLinkSignatures, setOpenLinkSignatures] = useState<any | null>(null);
const [openCustomLabel, setOpenCustomLabel] = useState<string | null>(null);
const handleCommand: OutCommandHandler = useCallback( const handleCommand: OutCommandHandler = useCallback(
event => { event => {
switch (event.type) { switch (event.type) {
@@ -95,22 +112,19 @@ export const MapWrapper = ({ refn }: MapWrapperProps) => {
[open], [open],
); );
const [selectedConnection, setSelectedConnection] = useState<SolarSystemConnection | null>(null);
const handleConnectionDbClick = useCallback((e: SolarSystemConnection) => setSelectedConnection(e), []); const handleConnectionDbClick = useCallback((e: SolarSystemConnection) => setSelectedConnection(e), []);
useMapEventListener(event => { const handleManualDelete = useCallback((toDelete: string[]) => {
switch (event.name) { const restDel = toDelete.filter(x => ref.current.systems.some(y => y.id === x));
case Commands.linkSignatureToSystem: if (restDel.length > 0) {
setOpenLinkSignatures(event.data); ref.current.deleteSystems(restDel);
return true;
} }
}); }, []);
return ( return (
<> <>
<Map <Map
ref={refn} ref={mapRef}
onCommand={handleCommand} onCommand={handleCommand}
onSelectionChange={onSelectionChange} onSelectionChange={onSelectionChange}
onConnectionInfoClick={handleConnectionDbClick} onConnectionInfoClick={handleConnectionDbClick}
@@ -119,6 +133,8 @@ export const MapWrapper = ({ refn }: MapWrapperProps) => {
minimapClasses={!isShowMenu ? classes.MiniMap : undefined} minimapClasses={!isShowMenu ? classes.MiniMap : undefined}
isShowMinimap={isShowMinimap} isShowMinimap={isShowMinimap}
showKSpaceBG={isShowKSpace} showKSpaceBG={isShowKSpace}
onManualDelete={handleManualDelete}
isThickConnections={isThickConnections}
/> />
{openSettings != null && ( {openSettings != null && (

View File

@@ -0,0 +1,38 @@
import { MutableRefObject, useCallback, useEffect, useRef } from 'react';
import { Command, Commands, MapHandlers } from '@/hooks/Mapper/types';
import { MapEvent } from '@/hooks/Mapper/events';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
export const useCommonMapEventProcessor = () => {
const mapRef = useRef<MapHandlers>() as MutableRefObject<MapHandlers>;
const {
data: { systems },
} = useMapRootState();
const refQueue = useRef<MapEvent<Command>[]>([]);
// const ref = useRef({})
const runCommand = useCallback(({ name, data }: MapEvent<Command>) => {
switch (name) {
case Commands.addSystems:
case Commands.removeSystems:
// case Commands.addConnections:
refQueue.current.push({ name, data });
return;
}
// @ts-ignore hz why here type error
mapRef.current?.command(name, data);
}, []);
useEffect(() => {
refQueue.current.forEach(x => mapRef.current?.command(x.name, x.data));
refQueue.current = [];
}, [systems]);
return {
mapRef,
runCommand,
};
};

View File

@@ -4,7 +4,7 @@ import classes from './CharacterCard.module.scss';
import { SystemView } from '@/hooks/Mapper/components/ui-kit/SystemView'; import { SystemView } from '@/hooks/Mapper/components/ui-kit/SystemView';
import { CharacterTypeRaw, WithIsOwnCharacter } from '@/hooks/Mapper/types'; import { CharacterTypeRaw, WithIsOwnCharacter } from '@/hooks/Mapper/types';
import { Commands } from '@/hooks/Mapper/types/mapHandlers.ts'; import { Commands } from '@/hooks/Mapper/types/mapHandlers.ts';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider'; import { emitMapEvent } from '@/hooks/Mapper/events';
type CharacterCardProps = { type CharacterCardProps = {
compact?: boolean; compact?: boolean;
@@ -34,11 +34,12 @@ export const CharacterCard = ({
useSystemsCache, useSystemsCache,
...char ...char
}: CharacterCardProps) => { }: CharacterCardProps) => {
const { mapRef } = useMapRootState();
const handleSelect = useCallback(() => { const handleSelect = useCallback(() => {
mapRef.current?.command(Commands.centerSystem, char?.location?.solar_system_id?.toString()); emitMapEvent({
}, [mapRef, char]); name: Commands.centerSystem,
data: char?.location?.solar_system_id?.toString(),
});
}, [char]);
return ( return (
<div className={clsx(classes.CharacterCard, 'w-full text-xs', 'flex flex-col box-border')} onClick={handleSelect}> <div className={clsx(classes.CharacterCard, 'w-full text-xs', 'flex flex-col box-border')} onClick={handleSelect}>

View File

@@ -31,24 +31,26 @@ export enum InterfaceStoredSettingsProps {
isShowMenu = 'isShowMenu', isShowMenu = 'isShowMenu',
isShowMinimap = 'isShowMinimap', isShowMinimap = 'isShowMinimap',
isShowKSpace = 'isShowKSpace', isShowKSpace = 'isShowKSpace',
isThickConnections = 'isThickConnections',
} }
export type InterfaceStoredSettings = { export type InterfaceStoredSettings = {
isShowMenu: boolean; isShowMenu: boolean;
isShowMinimap: boolean; isShowMinimap: boolean;
isShowKSpace: boolean; isShowKSpace: boolean;
isThickConnections: boolean;
}; };
export const STORED_INTERFACE_DEFAULT_VALUES: InterfaceStoredSettings = { export const STORED_INTERFACE_DEFAULT_VALUES: InterfaceStoredSettings = {
isShowMenu: false, isShowMenu: false,
isShowMinimap: true, isShowMinimap: true,
isShowKSpace: false, isShowKSpace: false,
isThickConnections: false,
}; };
export interface MapRootContextProps { export interface MapRootContextProps {
update: ContextStoreDataUpdate<MapRootData>; update: ContextStoreDataUpdate<MapRootData>;
data: MapRootData; data: MapRootData;
mapRef: RefObject<MapHandlers>;
outCommand: OutCommandHandler; outCommand: OutCommandHandler;
interfaceSettings: InterfaceStoredSettings; interfaceSettings: InterfaceStoredSettings;
setInterfaceSettings: Dispatch<SetStateAction<InterfaceStoredSettings>>; setInterfaceSettings: Dispatch<SetStateAction<InterfaceStoredSettings>>;
@@ -57,7 +59,6 @@ export interface MapRootContextProps {
const MapRootContext = createContext<MapRootContextProps>({ const MapRootContext = createContext<MapRootContextProps>({
update: () => {}, update: () => {},
data: { ...INITIAL_DATA }, data: { ...INITIAL_DATA },
mapRef: { current: null },
// @ts-ignore // @ts-ignore
outCommand: async () => void 0, outCommand: async () => void 0,
interfaceSettings: STORED_INTERFACE_DEFAULT_VALUES, interfaceSettings: STORED_INTERFACE_DEFAULT_VALUES,
@@ -67,7 +68,6 @@ const MapRootContext = createContext<MapRootContextProps>({
type MapRootProviderProps = { type MapRootProviderProps = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
fwdRef: ForwardedRef<any>; fwdRef: ForwardedRef<any>;
mapRef: RefObject<MapHandlers>;
outCommand: OutCommandHandler; outCommand: OutCommandHandler;
} & WithChildren; } & WithChildren;
@@ -78,7 +78,7 @@ const MapRootHandlers = forwardRef(({ children }: WithChildren, fwdRef: Forwarde
}); });
// eslint-disable-next-line react/display-name // eslint-disable-next-line react/display-name
export const MapRootProvider = ({ children, fwdRef, mapRef, outCommand }: MapRootProviderProps) => { export const MapRootProvider = ({ children, fwdRef, outCommand }: MapRootProviderProps) => {
const { update, ref } = useContextStore<MapRootData>({ ...INITIAL_DATA }); const { update, ref } = useContextStore<MapRootData>({ ...INITIAL_DATA });
const [interfaceSettings, setInterfaceSettings] = useLocalStorageState<InterfaceStoredSettings>( const [interfaceSettings, setInterfaceSettings] = useLocalStorageState<InterfaceStoredSettings>(
@@ -94,7 +94,6 @@ export const MapRootProvider = ({ children, fwdRef, mapRef, outCommand }: MapRoo
update, update,
data: ref, data: ref,
outCommand: outCommand, outCommand: outCommand,
mapRef: mapRef,
setInterfaceSettings, setInterfaceSettings,
interfaceSettings, interfaceSettings,
}} }}

View File

@@ -44,87 +44,79 @@ export const useMapRootHandlers = (ref: ForwardedRef<MapHandlers>) => {
return { return {
command(type, data) { command(type, data) {
switch (type) { switch (type) {
case Commands.init: case Commands.init: // USED
mapInit(data as CommandInit); mapInit(data as CommandInit);
break; break;
case Commands.addSystems: case Commands.addSystems: // USED
addSystems(data as CommandAddSystems); addSystems(data as CommandAddSystems);
setTimeout(() => {
emitMapEvent({ name: Commands.addSystems, data });
}, 100);
break; break;
case Commands.updateSystems: case Commands.updateSystems: // USED
updateSystems(data as CommandUpdateSystems); updateSystems(data as CommandUpdateSystems);
break; break;
case Commands.removeSystems: case Commands.removeSystems: // USED
removeSystems(data as CommandRemoveSystems); removeSystems(data as CommandRemoveSystems);
setTimeout(() => {
emitMapEvent({ name: Commands.removeSystems, data });
}, 100);
break; break;
case Commands.addConnections: case Commands.addConnections: // USED
addConnections(data as CommandAddConnections); addConnections(data as CommandAddConnections);
setTimeout(() => {
emitMapEvent({ name: Commands.addConnections, data });
}, 100);
break; break;
case Commands.removeConnections: case Commands.removeConnections: // USED
removeConnections(data as CommandRemoveConnections); removeConnections(data as CommandRemoveConnections);
break; break;
case Commands.updateConnection: case Commands.updateConnection: // USED
updateConnection(data as CommandUpdateConnection); updateConnection(data as CommandUpdateConnection);
break; break;
case Commands.charactersUpdated: case Commands.charactersUpdated: // USED
charactersUpdated(data as CommandCharactersUpdated); charactersUpdated(data as CommandCharactersUpdated);
break; break;
case Commands.characterAdded: case Commands.characterAdded: // USED
characterAdded(data as CommandCharacterAdded); characterAdded(data as CommandCharacterAdded);
break; break;
case Commands.characterRemoved: case Commands.characterRemoved: // USED
characterRemoved(data as CommandCharacterRemoved); characterRemoved(data as CommandCharacterRemoved);
break; break;
case Commands.characterUpdated: case Commands.characterUpdated: // USED
characterUpdated(data as CommandCharacterUpdated); characterUpdated(data as CommandCharacterUpdated);
break; break;
case Commands.presentCharacters: case Commands.presentCharacters: // USED
presentCharacters(data as CommandPresentCharacters); presentCharacters(data as CommandPresentCharacters);
break; break;
case Commands.mapUpdated: case Commands.mapUpdated: // USED
mapUpdated(data as CommandMapUpdated); mapUpdated(data as CommandMapUpdated);
break; break;
case Commands.routes: case Commands.routes:
mapRoutes(data as CommandRoutes); mapRoutes(data as CommandRoutes);
break; break;
case Commands.centerSystem: case Commands.centerSystem: // USED
// do nothing here // do nothing here
break; break;
case Commands.selectSystem: case Commands.selectSystem: // USED
// do nothing here // do nothing here
break; break;
case Commands.linkSignatureToSystem: // case Commands.linkSignatureToSystem:
// TODO command data type lost // // TODO command data type lost
// @ts-ignore // // @ts-ignore
emitMapEvent({ name: Commands.linkSignatureToSystem, data }); // emitMapEvent({ name: Commands.linkSignatureToSystem, data });
break; // break;
case Commands.killsUpdated: case Commands.killsUpdated:
// do nothing here // do nothing here
break; break;
case Commands.signaturesUpdated: // case Commands.signaturesUpdated:
// TODO command data type lost // // TODO command data type lost
// @ts-ignore // // @ts-ignore
emitMapEvent({ name: Commands.signaturesUpdated, data }); // emitMapEvent({ name: Commands.signaturesUpdated, data });
break; // break;
default: default:
console.warn(`JOipP Interface handlers: Unknown command: ${type}`, data); console.warn(`JOipP Interface handlers: Unknown command: ${type}`, data);
break; break;
} }
emitMapEvent({ name: type, data });
}, },
}; };
}, },

View File

@@ -33,7 +33,7 @@
"react-grid-layout": "^1.3.4", "react-grid-layout": "^1.3.4",
"react-hook-form": "^7.53.1", "react-hook-form": "^7.53.1",
"react-usestateref": "^1.0.9", "react-usestateref": "^1.0.9",
"reactflow": "^11.10.4", "reactflow": "^11.11.4",
"rxjs": "^7.8.1", "rxjs": "^7.8.1",
"tailwindcss": "^3.3.6", "tailwindcss": "^3.3.6",
"topbar": "^3.0.0", "topbar": "^3.0.0",

View File

@@ -3280,9 +3280,9 @@ react@18.2.0:
dependencies: dependencies:
loose-envify "^1.1.0" loose-envify "^1.1.0"
reactflow@^11.10.4: reactflow@^11.11.4:
version "11.11.4" version "11.11.4"
resolved "https://registry.npmjs.org/reactflow/-/reactflow-11.11.4.tgz" resolved "https://registry.yarnpkg.com/reactflow/-/reactflow-11.11.4.tgz#e3593e313420542caed81aecbd73fb9bc6576653"
integrity sha512-70FOtJkUWH3BAOsN+LU9lCrKoKbtOPnz2uq0CV2PLdNSwxTXOhCbsZr50GmZ+Rtw3jx8Uv7/vBFtCGixLfd4Og== integrity sha512-70FOtJkUWH3BAOsN+LU9lCrKoKbtOPnz2uq0CV2PLdNSwxTXOhCbsZr50GmZ+Rtw3jx8Uv7/vBFtCGixLfd4Og==
dependencies: dependencies:
"@reactflow/background" "11.3.14" "@reactflow/background" "11.3.14"