Skip to content

Commit

Permalink
Add nag dialog regarding PLC
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanKell committed May 28, 2023
1 parent f331b30 commit f88c10d
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions Source/RP0.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<Compile Include="GameplayTips.cs" />
<Compile Include="HarmonyPatcher.cs" />
<Compile Include="Harmony\BaseCrewAssignmentDialog.cs" />
<Compile Include="StartupPopup.cs" />
<Compile Include="LoadingScreenChanger.cs" />
<Compile Include="Maintenance\MaintenanceSettings.cs" />
<Compile Include="Maintenance\MaintenanceHandler.cs" />
Expand Down
45 changes: 45 additions & 0 deletions Source/StartupPopup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.IO;
using System.Reflection;
using UnityEngine;

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

public void Start()
{
if (File.Exists(PreferenceFilePath)) return;


PopupDialog.SpawnPopupDialog(
new Vector2(0, 0),
new Vector2(0, 0),
new MultiOptionDialog(
"RP1StartupDialog",
"This is the legacy version of RP-1, and is no longer supported. There is a new version of RP-1, the Programs and Launch Complexes rework, now available. It is savebreaking, and a work in progress, but if you are starting a new save it is highly recommended to switch to that version. Please uninstall RP-1 (Legacy) and install RP-1 (PLC). You can do this by uninstalling and reinstalling the RP-1 Express Install and choosing one of the non-Legacy options.",
"RP-1",
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 f88c10d

Please sign in to comment.