Skip to content

Commit

Permalink
Warning dialog for breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanKell committed May 29, 2023
1 parent e6b87b6 commit 9a1cdcf
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
1 change: 1 addition & 0 deletions Source/RealSolarSystem.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<Compile Include="KopernicusMods\VertexHeightMapRSS.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RSSRunwayFix.cs" />
<Compile Include="StartupPopup.cs" />
<Compile Include="TimeWarpFixer.cs" />
<Compile Include="VesselGroundPositionEnhancer.cs" />
<Compile Include="Watchdogs.cs" />
Expand Down
48 changes: 48 additions & 0 deletions Source/StartupPopup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using UnityEngine;

namespace RealSolarSystem
{
[KSPAddon(KSPAddon.Startup.Instantly, true)]
public class StartupPopup : MonoBehaviour
{
private const string PreferenceFileName = "RSSFinalizeOrbitWarning";
private static string PreferenceFilePath => Path.Combine(
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
"PluginData",
PreferenceFileName);

public void Start()
{
if (AssemblyLoader.loadedAssemblies.Any(a => string.Equals(a.name, "ksp_plugin_adapter", StringComparison.OrdinalIgnoreCase)))
return;

if (File.Exists(PreferenceFilePath)) return;

PopupDialog.SpawnPopupDialog(
new Vector2(0, 0),
new Vector2(0, 0),
new MultiOptionDialog(
"RSSStartupDialog",
"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.",
"Real Solar System",
HighLogic.UISkin,
new DialogGUIVerticalLayout(
new DialogGUIButton("Don't show again", RememberPreference, true),
new DialogGUIButton("Ok", () => { }, true)
)
),
true,
HighLogic.UISkin);
}

private static void RememberPreference()
{
// create empty file
File.Create(PreferenceFilePath).Close();
}
}
}

0 comments on commit 9a1cdcf

Please sign in to comment.