Skip to content

Commit 0d6f96d

Browse files
Merge pull request #15 from SteveBenz/master
Make the configuration file not depend on Environment.CurrentDirector…
2 parents c8c3b92 + 9e937d4 commit 0d6f96d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

ClickThroughBlocker/OneTimePopup.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using KSP.IO;
55
using UnityEngine;
66
using ClickThroughFix;
7-
7+
using System.Reflection;
88

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

21+
public OneTimePopup()
22+
{
23+
popUpShownCfgPath = Path.Combine(
24+
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
25+
"../PluginData/PopUpShown.cfg");
26+
}
27+
2128
public void Start()
2229
{
23-
if (HighLogic.CurrentGame.Parameters.CustomParams<ClickThroughFix.CTB>().showPopup || !System.IO.File.Exists(POPUP_FILE_FLAG))
30+
if (HighLogic.CurrentGame.Parameters.CustomParams<ClickThroughFix.CTB>().showPopup || !System.IO.File.Exists(popUpShownCfgPath))
2431
visible = true;
2532
if (ClearInputLocks.modeWindow != null)
2633
{
@@ -114,12 +121,12 @@ void PopUpWindow(int id)
114121
void CreatePopUpFlagFile()
115122
{
116123
RemovePopUpFlagFile(); // remove first to avoid any overwriting
117-
System.IO.File.WriteAllText(POPUP_FILE_FLAG, "popupshown = true");
124+
System.IO.File.WriteAllText(popUpShownCfgPath, "popupshown = true");
118125
}
119126

120127
public static void RemovePopUpFlagFile()
121128
{
122-
System.IO.File.Delete(POPUP_FILE_FLAG);
129+
System.IO.File.Delete(popUpShownCfgPath);
123130
}
124131
}
125132
}

0 commit comments

Comments
 (0)