Skip to content

Commit d511e7c

Browse files
committed
refactor(GalaxyMapViewerForGateBuilder): add GalaxyMapViewerForGateBuilder class
src/ChemGateBuilder/GalaxyMapViewerForGateBuilder.cs: +added class to handle extra connections in the galaxy map src/ChemGateBuilder/GalaxyMapWindow.xaml: ~updated to use GalaxyMapViewerForGateBuilder instead of GalaxyMapViewer
1 parent 9ff6662 commit d511e7c

2 files changed

Lines changed: 57 additions & 3 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System.ComponentModel;
2+
using System.Windows;
3+
using System.Windows.Controls;
4+
using System.Windows.Data;
5+
using Utilities.Logging;
6+
using X4DataLoader;
7+
using X4Map;
8+
9+
namespace ChemGateBuilder
10+
{
11+
public class GalaxyMapViewerForGateBuilder : GalaxyMapViewer
12+
{
13+
private List<string> _extraConnectionsNames = [];
14+
15+
public void Connect(
16+
Galaxy galaxy,
17+
Canvas galaxyCanvas,
18+
double mapColorsOpacity,
19+
bool editorMode = true,
20+
Dictionary<string, List<ObjectInSector>>? extraObjects = null,
21+
List<string>? extraConnectionsNames = null
22+
)
23+
{
24+
base.Connect(galaxy, galaxyCanvas, mapColorsOpacity, editorMode, extraObjects);
25+
_extraConnectionsNames = extraConnectionsNames ?? [];
26+
}
27+
28+
protected override void CreateMap()
29+
{
30+
base.CreateMap();
31+
foreach (string connectionName in _extraConnectionsNames)
32+
{
33+
if (connectionName == null)
34+
{
35+
continue;
36+
}
37+
List<SectorMapItem> extraGatesItems = SectorsItems.FindAll(item => item.Id == connectionName);
38+
if (extraGatesItems.Count == 2)
39+
{
40+
GalaxyMapInterConnection galaxyMapGateConnection = new(extraGatesItems[0], extraGatesItems[1], true);
41+
galaxyMapGateConnection.Create(GalaxyCanvas);
42+
InterConnections.Add(galaxyMapGateConnection);
43+
}
44+
}
45+
List<SectorMapItem> newGatesItems = SectorsItems.FindAll(item => item.Id == SectorMap.NewGateId);
46+
if (newGatesItems.Count == 2)
47+
{
48+
GalaxyMapInterConnection galaxyMapGateConnection = new(newGatesItems[0], newGatesItems[1], true);
49+
galaxyMapGateConnection.Create(GalaxyCanvas);
50+
InterConnections.Add(galaxyMapGateConnection);
51+
}
52+
}
53+
}
54+
}

src/ChemGateBuilder/GalaxyMapWindow.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:fa="http://schemas.awesome.incremented/wpf/xaml/fontawesome.sharp"
5-
xmlns:x4map="clr-namespace:X4Map;assembly=X4Map"
5+
xmlns:local="clr-namespace:ChemGateBuilder"
66
xmlns:attributeConverters="clr-namespace:SharedWindows.Converters;assembly=SharedWindows"
77
Title="Galaxy Map"
88
Height="600"
@@ -69,14 +69,14 @@
6969
</Button.Content>
7070
</Button>
7171
</Grid>
72-
<x4map:GalaxyMapViewer x:Name="GalaxyMapViewer"
72+
<local:GalaxyMapViewerForGateBuilder x:Name="GalaxyMapViewer"
7373
Grid.Row="1"
7474
HorizontalScrollBarVisibility="Auto"
7575
VerticalScrollBarVisibility="Auto"
7676
Background="LightGray">
7777
<Canvas x:Name="GalaxyMapCanvas"
7878
Background="LightGray"/>
79-
</x4map:GalaxyMapViewer>
79+
</local:GalaxyMapViewerForGateBuilder>
8080
<Grid Grid.Row="1"
8181
Grid.Column="1"
8282
Background="LightGray">

0 commit comments

Comments
 (0)