Skip to content

Commit 9e937d4

Browse files
committed
Make the configuration file not depend on Environment.CurrentDirectory and instead depend on the deployment location of the DLL
1 parent fdefef1 commit 9e937d4

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
{
@@ -112,12 +119,12 @@ void PopUpWindow(int id)
112119
void CreatePopUpFlagFile()
113120
{
114121
RemovePopUpFlagFile(); // remove first to avoid any overwriting
115-
System.IO.File.WriteAllText(POPUP_FILE_FLAG, "popupshown = true");
122+
System.IO.File.WriteAllText(popUpShownCfgPath, "popupshown = true");
116123
}
117124

118125
public static void RemovePopUpFlagFile()
119126
{
120-
System.IO.File.Delete(POPUP_FILE_FLAG);
127+
System.IO.File.Delete(popUpShownCfgPath);
121128
}
122129
}
123130
}

0 commit comments

Comments
 (0)