Skip to content

Commit

Permalink
Make the configuration file not depend on Environment.CurrentDirector…
Browse files Browse the repository at this point in the history
…y and instead depend on the deployment location of the DLL
  • Loading branch information
SteveBenz committed Jul 19, 2020
1 parent fdefef1 commit 9e937d4
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions ClickThroughBlocker/OneTimePopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using KSP.IO;
using UnityEngine;
using ClickThroughFix;

using System.Reflection;

namespace ClearAllInputLocks
{
Expand All @@ -15,12 +15,19 @@ public class OneTimePopup : MonoBehaviour
const int HEIGHT = 350;
Rect popupRect = new Rect(300, 50, WIDTH, HEIGHT);
bool visible = false;
const string POPUP_FILE_FLAG = "GameData/000_ClickThroughBlocker/PluginData/PopUpShown.cfg";
string popUpShownCfgPath;
string cancelStr = "Cancel (window will open next startup)";

public OneTimePopup()
{
popUpShownCfgPath = Path.Combine(
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
"../PluginData/PopUpShown.cfg");
}

public void Start()
{
if (HighLogic.CurrentGame.Parameters.CustomParams<ClickThroughFix.CTB>().showPopup || !System.IO.File.Exists(POPUP_FILE_FLAG))
if (HighLogic.CurrentGame.Parameters.CustomParams<ClickThroughFix.CTB>().showPopup || !System.IO.File.Exists(popUpShownCfgPath))
visible = true;
if (ClearInputLocks.modeWindow != null)
{
Expand Down Expand Up @@ -112,12 +119,12 @@ void PopUpWindow(int id)
void CreatePopUpFlagFile()
{
RemovePopUpFlagFile(); // remove first to avoid any overwriting
System.IO.File.WriteAllText(POPUP_FILE_FLAG, "popupshown = true");
System.IO.File.WriteAllText(popUpShownCfgPath, "popupshown = true");
}

public static void RemovePopUpFlagFile()
{
System.IO.File.Delete(POPUP_FILE_FLAG);
System.IO.File.Delete(popUpShownCfgPath);
}
}
}

0 comments on commit 9e937d4

Please sign in to comment.