Skip to content

Commit d22921e

Browse files
authored
Merge pull request #53 from Kevin0M16/v2.3
V2.3
2 parents 5d47798 + 3e63dc7 commit d22921e

File tree

13 files changed

+1421
-1133
lines changed

13 files changed

+1421
-1133
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dotnet.preferCSharpExtension": true
3+
}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CHANGELOG
22

3+
## v2.3 (DEC 25 2024)
4+
- Update for NMS 5.x compatibility, keeping previous NMS 4.0 compatibility.
5+
36
## v2.2 (NOV 4 2022)
47
- Update for NMS 4.0 compatibility and save names, difficulty
58
- Added new features for locations management. Merge, delete, open, etc.

NMSCoordinates/App.config

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,23 @@
77
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
88
<dependentAssembly>
99
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
10-
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
10+
<bindingRedirect oldVersion="0.0.0.0-6.0.1.0" newVersion="6.0.1.0" />
1111
</dependentAssembly>
1212
<dependentAssembly>
1313
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
14-
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
14+
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
15+
</dependentAssembly>
16+
<dependentAssembly>
17+
<assemblyIdentity name="K4os.Compression.LZ4" publicKeyToken="2186fa9121ef231d" culture="neutral" />
18+
<bindingRedirect oldVersion="0.0.0.0-1.3.8.0" newVersion="1.3.8.0" />
19+
</dependentAssembly>
20+
<dependentAssembly>
21+
<assemblyIdentity name="Octokit" publicKeyToken="0be8860aee462442" culture="neutral" />
22+
<bindingRedirect oldVersion="0.0.0.0-7.0.1.0" newVersion="7.0.1.0" />
23+
</dependentAssembly>
24+
<dependentAssembly>
25+
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
26+
<bindingRedirect oldVersion="0.0.0.0-4.0.4.0" newVersion="4.0.4.0" />
1527
</dependentAssembly>
1628
</assemblyBinding>
1729
</runtime>

NMSCoordinates/CoordinateCalculator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ private void Button2_Click(object sender, EventArgs e)
441441
}
442442

443443
//Validate Coordinate
444-
if (CoordCalculations.ValidateCoord(gc))
444+
if (CoordCalculations.CoordinateOutOfRange(gc))
445445
{
446446
MessageBox.Show("Invalid Coordinates! Out of Range!", "Alert");
447447
Clear();
@@ -586,7 +586,7 @@ private void Button3_Click(object sender, EventArgs e)
586586
Destination dest = HexToAll(basehx, textBox7);
587587

588588
//Validate Coordinates
589-
if (CoordCalculations.ValidateCoord(dest.GalacticCoordinate))
589+
if (CoordCalculations.CoordinateOutOfRange(dest.GalacticCoordinate))
590590
{
591591
MessageBox.Show("Invalid Coordinates! Out of Range!", "Alert");
592592
Clear();
@@ -659,7 +659,7 @@ private void Button4_Click(object sender, EventArgs e)
659659
Destination dest = HexToAll(basehx, textBox7);
660660

661661
//Validate Coordinates
662-
if (CoordCalculations.ValidateCoord(dest.GalacticCoordinate))
662+
if (CoordCalculations.CoordinateOutOfRange(dest.GalacticCoordinate))
663663
{
664664
MessageBox.Show("Invalid Coordinates! Out of Range!", "Alert");
665665
Clear();
@@ -834,7 +834,7 @@ private void ToolStripMenuItem1_Click(object sender, EventArgs e)
834834
{
835835
if (textBox2.Text != "")
836836
{
837-
f1 = (NMSCoordinatesMain)Application.OpenForms["Form1"];
837+
f1 = (NMSCoordinatesMain)Application.OpenForms["NMSCoordinatesMain"];
838838
if (!f1.TextBoxPerm == true)
839839
{
840840
f1.TextBoxValue = textBox2.Text;

NMSCoordinates/Coords/CoordCalculations.cs

Lines changed: 17 additions & 280 deletions
Large diffs are not rendered by default.

NMSCoordinates/Coords/Coordinates.cs

Lines changed: 66 additions & 176 deletions
Large diffs are not rendered by default.

NMSCoordinates/Globals/Globals.cs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using NMSCoordinates.LocationData;
1+
using Newtonsoft.Json.Linq;
2+
using NMSCoordinates.LocationData;
3+
using NMSCoordinates.SaveData;
4+
using NMSCoordinates.SaveDataOld;
25
using System;
36
using System.Collections.Generic;
47
using System.Drawing;
@@ -10,8 +13,12 @@ namespace NMSCoordinates
1013
{
1114
public partial class Globals
1215
{
16+
public static bool IsNewSaveFormat { get; private set; }
17+
1318
public static void AppendLine(TextBox source, string value)
1419
{
20+
if (source == null) return; // Safely handle null TextBox
21+
1522
//My neat little textbox handler
1623
if (source.Text.Length == 0)
1724
source.Text = value;
@@ -51,6 +58,45 @@ public static string GameModeLookupInt(int mode)
5158
{
5259
return "Unknown";
5360
}
61+
}
62+
public static class SaveFormatDetector
63+
{
64+
public static bool IsNewSaveFormat(string json)
65+
{
66+
try
67+
{
68+
var jsonObject = JObject.Parse(json);
69+
70+
// Check for a unique property in the new save format
71+
if (jsonObject["BaseContext"] != null)
72+
return true;
73+
74+
// Default to old format if nothing specific to the new format is detected
75+
return false;
76+
}
77+
catch
78+
{
79+
// If parsing fails, assume it's not the new save format
80+
return false;
81+
}
82+
}
83+
}
84+
public static class SaveFileParser
85+
{
86+
public static dynamic ParseSaveData(string json)
87+
{
88+
// Detect and set save format
89+
Globals.IsNewSaveFormat = SaveFormatDetector.IsNewSaveFormat(json);
90+
91+
if (Globals.IsNewSaveFormat)
92+
{
93+
return GameSaveData.FromJson(json); // New save format
94+
}
95+
else
96+
{
97+
return GameSaveDataOld.FromJson(json); // Old save format
98+
}
99+
}
54100
}
55101
public static string GalaxyLookup(string galaxy)
56102
{

NMSCoordinates/NMSCoordinates.csproj

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,45 +76,45 @@
7676
<ApplicationIcon>nms.ico</ApplicationIcon>
7777
</PropertyGroup>
7878
<ItemGroup>
79-
<Reference Include="K4os.Compression.LZ4, Version=1.2.16.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
80-
<HintPath>..\packages\K4os.Compression.LZ4.1.2.16\lib\net46\K4os.Compression.LZ4.dll</HintPath>
79+
<Reference Include="K4os.Compression.LZ4, Version=1.3.8.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
80+
<HintPath>..\packages\K4os.Compression.LZ4.1.3.8\lib\net462\K4os.Compression.LZ4.dll</HintPath>
8181
</Reference>
82-
<Reference Include="libNOM.map, Version=0.8.3.0, Culture=neutral, processorArchitecture=MSIL">
83-
<HintPath>..\packages\libNOM.map.0.8.3\lib\netstandard2.0\libNOM.map.dll</HintPath>
82+
<Reference Include="libNOM.map, Version=0.13.4.0, Culture=neutral, processorArchitecture=MSIL">
83+
<HintPath>..\packages\libNOM.map.0.13.4\lib\netstandard2.0\libNOM.map.dll</HintPath>
8484
</Reference>
8585
<Reference Include="Mnemosyne, Version=1.1.0.2, Culture=neutral, processorArchitecture=MSIL">
8686
<HintPath>..\packages\Mnemosyne.1.1.0.2\lib\netstandard2.0\Mnemosyne.dll</HintPath>
8787
</Reference>
8888
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
89-
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
89+
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
9090
</Reference>
91-
<Reference Include="NMSSaveManager, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
92-
<HintPath>..\packages\NMSSaveManager.1.0.2\lib\net472\NMSSaveManager.dll</HintPath>
91+
<Reference Include="NMSSaveManager, Version=1.0.4.0, Culture=neutral, processorArchitecture=MSIL">
92+
<HintPath>..\packages\NMSSaveManager.1.0.4\lib\net472\NMSSaveManager.dll</HintPath>
9393
</Reference>
94-
<Reference Include="Octokit, Version=4.0.1.0, Culture=neutral, PublicKeyToken=0be8860aee462442, processorArchitecture=MSIL">
95-
<HintPath>..\packages\Octokit.4.0.1\lib\netstandard2.0\Octokit.dll</HintPath>
94+
<Reference Include="Octokit, Version=13.0.1.0, Culture=neutral, PublicKeyToken=0be8860aee462442, processorArchitecture=MSIL">
95+
<HintPath>..\packages\Octokit.13.0.1\lib\netstandard2.0\Octokit.dll</HintPath>
9696
</Reference>
9797
<Reference Include="SpookilySharp, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
9898
<HintPath>..\packages\SpookilySharp.1.2.0\lib\netstandard2.0\SpookilySharp.dll</HintPath>
9999
</Reference>
100100
<Reference Include="System" />
101-
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
102-
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
101+
<Reference Include="System.Buffers, Version=4.0.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
102+
<HintPath>..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll</HintPath>
103103
</Reference>
104104
<Reference Include="System.Core" />
105105
<Reference Include="System.IO.Compression" />
106106
<Reference Include="System.IO.Compression.FileSystem" />
107107
<Reference Include="System.Management" />
108-
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
109-
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
108+
<Reference Include="System.Memory, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
109+
<HintPath>..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll</HintPath>
110110
</Reference>
111111
<Reference Include="System.Net" />
112112
<Reference Include="System.Numerics" />
113-
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
114-
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
113+
<Reference Include="System.Numerics.Vectors, Version=4.1.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
114+
<HintPath>..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll</HintPath>
115115
</Reference>
116-
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
117-
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
116+
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
117+
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
118118
</Reference>
119119
<Reference Include="System.Xml.Linq" />
120120
<Reference Include="System.Data.DataSetExtensions" />
@@ -146,6 +146,7 @@
146146
</Compile>
147147
<Compile Include="SaveData\JsonMap.cs" />
148148
<Compile Include="SaveData\SaveData.cs" />
149+
<Compile Include="SaveData\SaveDataOld.cs" />
149150
<Compile Include="SaveData\ufSaveData.cs" />
150151
<Compile Include="ScreenShotPreviewQuad.cs">
151152
<SubType>Form</SubType>

0 commit comments

Comments
 (0)