Skip to content

Commit

Permalink
Merge pull request #15 from SteveBenz/master
Browse files Browse the repository at this point in the history
Make the configuration file not depend on Environment.CurrentDirector…
  • Loading branch information
linuxgurugamer authored Oct 6, 2020
2 parents c8c3b92 + 9e937d4 commit 0d6f96d
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 @@ -114,12 +121,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 0d6f96d

Please sign in to comment.