diff --git a/public/Derelik.json b/public/Derelik.json index 93199f7..4e438e7 100644 --- a/public/Derelik.json +++ b/public/Derelik.json @@ -4,30 +4,35 @@ "solarSystemName": "Hophib", "x": "15", "y": "105", - "security": 0.02914748942441414 + "security": 0.02914748942441414, + "connectsTo": ["Ziriert", "Yashunen"] }, { "solarSystemName": "Ziriert", "x": "150", "y": "200", - "security": 0.4 + "security": 0.4, + "connectsTo": ["Hophib", "Danera", "Yashunen"] }, { "solarSystemName": "Yashunen", "x": "300", "y": "150", - "security": 0.8 + "security": 0.8, + "connectsTo": ["Hophib", "Ziriert", "Shastal"] }, { "solarSystemName": "Danera", "x": "200", "y": "350", - "security": -0.3 + "security": -0.3, + "connectsTo": ["Ziriert", "Shastal"] }, { "solarSystemName": "Shastal", "x": "400", "y": "300", - "security": -0.8 + "security": -0.8, + "connectsTo": ["Yashunen", "Danera"] } ] diff --git a/public/Devoid.json b/public/Devoid.json index c99e24f..fdcd8c8 100644 --- a/public/Devoid.json +++ b/public/Devoid.json @@ -4,18 +4,21 @@ "solarSystemName": "Amarr", "x": "100", "y": "200", - "security": 1.0 + "security": 1.0, + "connectsTo": ["Sarum Prime"] }, { "solarSystemName": "Sarum Prime", "x": "250", "y": "300", - "security": 0.9 + "security": 0.9, + "connectsTo": ["Amarr", "Niarja"] }, { "solarSystemName": "Niarja", "x": "400", "y": "250", - "security": 0.5 + "security": 0.5, + "connectsTo": ["Sarum Prime"] } ] diff --git a/public/Domain.json b/public/Domain.json index 848e785..48c4ac8 100644 --- a/public/Domain.json +++ b/public/Domain.json @@ -4,18 +4,21 @@ "solarSystemName": "Jita", "x": "200", "y": "150", - "security": 0.9 + "security": 0.9, + "connectsTo": ["Dodixie", "Rens"] }, { "solarSystemName": "Dodixie", "x": "350", "y": "280", - "security": 0.7 + "security": 0.7, + "connectsTo": ["Jita", "Rens"] }, { "solarSystemName": "Rens", "x": "150", "y": "400", - "security": 0.6 + "security": 0.6, + "connectsTo": ["Jita", "Dodixie"] } ] diff --git a/public/Genesis.json b/public/Genesis.json index f7a0a1e..440657d 100644 --- a/public/Genesis.json +++ b/public/Genesis.json @@ -4,18 +4,21 @@ "solarSystemName": "Yulai", "x": "180", "y": "120", - "security": 1.0 + "security": 1.0, + "connectsTo": ["Crielere"] }, { "solarSystemName": "Crielere", "x": "320", "y": "200", - "security": 0.3 + "security": 0.3, + "connectsTo": ["Yulai", "Promised Land"] }, { "solarSystemName": "Promised Land", "x": "250", "y": "350", - "security": -0.5 + "security": -0.5, + "connectsTo": ["Crielere"] } ] diff --git a/public/Kador.json b/public/Kador.json index 0959085..70a9493 100644 --- a/public/Kador.json +++ b/public/Kador.json @@ -4,18 +4,21 @@ "solarSystemName": "Kador Prime", "x": "200", "y": "180", - "security": 0.8 + "security": 0.8, + "connectsTo": ["Zirsem", "Thebeka"] }, { "solarSystemName": "Zirsem", "x": "350", "y": "250", - "security": 0.2 + "security": 0.2, + "connectsTo": ["Kador Prime", "Thebeka"] }, { "solarSystemName": "Thebeka", "x": "150", "y": "320", - "security": -0.2 + "security": -0.2, + "connectsTo": ["Kador Prime", "Zirsem"] } ] diff --git a/public/universe.json b/public/universe.json index 5d2cf14..021df2e 100644 --- a/public/universe.json +++ b/public/universe.json @@ -3,26 +3,31 @@ { "regionName": "Derelik", "x": "413", - "y": "357" + "y": "357", + "connectsTo": ["Devoid", "Domain"] }, { "regionName": "Devoid", "x": "200", - "y": "250" + "y": "250", + "connectsTo": ["Derelik", "Domain", "Genesis"] }, { "regionName": "Domain", "x": "600", - "y": "300" + "y": "300", + "connectsTo": ["Devoid", "Derelik", "Kador"] }, { "regionName": "Genesis", "x": "350", - "y": "500" + "y": "500", + "connectsTo": ["Devoid", "Kador"] }, { "regionName": "Kador", "x": "500", - "y": "180" + "y": "180", + "connectsTo": ["Domain", "Genesis"] } ] diff --git a/src/components/GalaxyMap.tsx b/src/components/GalaxyMap.tsx index 4326db5..c2ac970 100644 --- a/src/components/GalaxyMap.tsx +++ b/src/components/GalaxyMap.tsx @@ -2,12 +2,14 @@ import React, { useState, useRef, useCallback, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { MapNode } from './MapNode'; +import { Connection } from './Connection'; import { useQuery } from '@tanstack/react-query'; interface Region { regionName: string; x: string; y: string; + connectsTo: string[]; } interface Position { @@ -118,6 +120,23 @@ export const GalaxyMap = () => { + {/* Render connections first (behind nodes) */} + {regions?.map((region) => + region.connectsTo?.map((connectedRegion) => { + const fromPos = nodePositions[region.regionName]; + const toPos = nodePositions[connectedRegion]; + if (!fromPos || !toPos) return null; + + return ( + + ); + }) + )} + {/* Render nodes */} {regions?.map((region) => ( = ({ }) => { const [isHovered, setIsHovered] = useState(false); - const nodeSize = type === 'region' ? 12 : 8; - const textOffset = type === 'region' ? 20 : 15; - // Use security-based color for systems, default colors for regions const nodeColor = type === 'system' && security !== undefined ? getSecurityColor(security) @@ -35,67 +32,139 @@ export const MapNode: React.FC = ({ ? (isHovered ? '#8b5cf6' : '#a855f7') : (isHovered ? '#06b6d4' : '#0891b2'); - return ( - setIsHovered(true)} - onMouseLeave={() => setIsHovered(false)} - onMouseDown={(e) => { - e.preventDefault(); - onMouseDown(); - }} - onClick={(e) => { - e.stopPropagation(); - if (!isDragging) { - onClick(); - } - }} - > - {/* Node glow effect */} - - - {/* Main node */} - - - {/* Inner core */} - - - {/* Node label */} - setIsHovered(true)} + onMouseLeave={() => setIsHovered(false)} + onMouseDown={(e) => { + e.preventDefault(); + onMouseDown(); + }} + onClick={(e) => { + e.stopPropagation(); + if (!isDragging) { + onClick(); + } + }} > - {name} - - - ); + {/* Glow effect */} + + + {/* Main pill */} + + + {/* Text inside pill */} + + {name} + + + ); + } else { + // Render system as a dot with external label + const nodeSize = 8; + const textOffset = 15; + + return ( + setIsHovered(true)} + onMouseLeave={() => setIsHovered(false)} + onMouseDown={(e) => { + e.preventDefault(); + onMouseDown(); + }} + onClick={(e) => { + e.stopPropagation(); + if (!isDragging) { + onClick(); + } + }} + > + {/* Node glow effect */} + + + {/* Main node */} + + + {/* Inner core */} + + + {/* Node label */} + + {name} + + + ); + } }; diff --git a/src/components/RegionMap.tsx b/src/components/RegionMap.tsx index 1a1fff2..d2c66cf 100644 --- a/src/components/RegionMap.tsx +++ b/src/components/RegionMap.tsx @@ -2,6 +2,7 @@ import React, { useState, useRef, useCallback, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { MapNode } from './MapNode'; +import { Connection } from './Connection'; import { Button } from '@/components/ui/button'; import { ArrowLeft } from 'lucide-react'; import { useQuery } from '@tanstack/react-query'; @@ -11,6 +12,7 @@ interface System { x: string; y: string; security: number; + connectsTo: string[]; } interface Position { @@ -137,6 +139,23 @@ export const RegionMap: React.FC = ({ regionName }) => { + {/* Render connections first (behind nodes) */} + {systems?.map((system) => + system.connectsTo?.map((connectedSystem) => { + const fromPos = nodePositions[system.solarSystemName]; + const toPos = nodePositions[connectedSystem]; + if (!fromPos || !toPos) return null; + + return ( + + ); + }) + )} + {/* Render systems */} {systems?.map((system) => (