Skip to content

Commit 9a1cdcf

Browse files
committed
Warning dialog for breaking change
1 parent e6b87b6 commit 9a1cdcf

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

Source/RealSolarSystem.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<Compile Include="KopernicusMods\VertexHeightMapRSS.cs" />
5151
<Compile Include="Properties\AssemblyInfo.cs" />
5252
<Compile Include="RSSRunwayFix.cs" />
53+
<Compile Include="StartupPopup.cs" />
5354
<Compile Include="TimeWarpFixer.cs" />
5455
<Compile Include="VesselGroundPositionEnhancer.cs" />
5556
<Compile Include="Watchdogs.cs" />

Source/StartupPopup.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using System;
2+
using System.IO;
3+
using System.Linq;
4+
using System.Reflection;
5+
using UnityEngine;
6+
7+
namespace RealSolarSystem
8+
{
9+
[KSPAddon(KSPAddon.Startup.Instantly, true)]
10+
public class StartupPopup : MonoBehaviour
11+
{
12+
private const string PreferenceFileName = "RSSFinalizeOrbitWarning";
13+
private static string PreferenceFilePath => Path.Combine(
14+
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
15+
"PluginData",
16+
PreferenceFileName);
17+
18+
public void Start()
19+
{
20+
if (AssemblyLoader.loadedAssemblies.Any(a => string.Equals(a.name, "ksp_plugin_adapter", StringComparison.OrdinalIgnoreCase)))
21+
return;
22+
23+
if (File.Exists(PreferenceFilePath)) return;
24+
25+
PopupDialog.SpawnPopupDialog(
26+
new Vector2(0, 0),
27+
new Vector2(0, 0),
28+
new MultiOptionDialog(
29+
"RSSStartupDialog",
30+
"Warning: This version contains breaking changes for non-Principia users. Significant and necessary fixes have been implemented, which may result in planets changing positions in their orbits. Existing maneuvers and vessels in flight may have dramatically altered future encounters. For existing saves, it is recommended to revert to the prior CKAN version and upgrading is not recommended. Please create backups before attempting to update existing saves.",
31+
"Real Solar System",
32+
HighLogic.UISkin,
33+
new DialogGUIVerticalLayout(
34+
new DialogGUIButton("Don't show again", RememberPreference, true),
35+
new DialogGUIButton("Ok", () => { }, true)
36+
)
37+
),
38+
true,
39+
HighLogic.UISkin);
40+
}
41+
42+
private static void RememberPreference()
43+
{
44+
// create empty file
45+
File.Create(PreferenceFilePath).Close();
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)