Skip to content

Commit 0f433f0

Browse files
committed
Update to v1.1 - supporting Bepinex installation
1 parent 4583239 commit 0f433f0

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

ZLheim_Modloader/Form1.Designer.cs

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ZLheim_Modloader/Form1.cs

+30-4
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,26 @@ private void BrowseFolderButton_Click(object sender, EventArgs e)
206206

207207
private void WriteToConfigFile(string text)
208208
{
209-
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.txt");
209+
string local = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
210+
string folderName = "HunterModloader";
211+
string configName = "config.txt";
212+
string folderPath = Path.Combine(local, folderName);
213+
string filePath = Path.Combine(local, folderName, configName);
214+
MessageBox.Show(filePath);
215+
216+
if (!System.IO.File.Exists(folderPath))
217+
{
218+
try
219+
{
220+
Directory.CreateDirectory(folderPath);
221+
}
222+
catch
223+
{
224+
MessageBox.Show("An error occurred while creating appdata folder");
225+
return;
226+
}
227+
}
228+
210229

211230
if (!File.Exists(filePath))
212231
{
@@ -231,12 +250,19 @@ private void WriteToConfigFile(string text)
231250
catch (IOException)
232251
{
233252
MessageBox.Show("An error occurred while writing to config.txt.");
253+
return;
234254
}
235255
}
236256

237257
private string ReadFromConfigFile()
238258
{
239-
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.txt");
259+
260+
string local = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
261+
string folderName = "HunterModloader";
262+
string configName = "config.txt";
263+
string filePath = Path.Combine(local, folderName, configName);
264+
MessageBox.Show(filePath);
265+
240266
string fileContents = "";
241267

242268
if (File.Exists(filePath))
@@ -485,12 +511,12 @@ private void InstallZLM()
485511

486512
//Now Create all of the directories
487513
foreach (string dirPath in Directory.GetDirectories(ZLMZipExtractionPath, "*", SearchOption.AllDirectories))
488-
Directory.CreateDirectory(dirPath.Replace(ZLMZipExtractionPath, $"{ValheimGameFolder}\\BepInEx"));
514+
Directory.CreateDirectory(dirPath.Replace(ZLMZipExtractionPath, $"{ValheimGameFolder}"));
489515

490516
//Copy all the files & Replaces any files with the same name
491517
foreach (string newPath in Directory.GetFiles(ZLMZipExtractionPath, "*.*",
492518
SearchOption.AllDirectories))
493-
File.Copy(newPath, newPath.Replace(ZLMZipExtractionPath, $"{ValheimGameFolder}\\BepInEx"), true);
519+
File.Copy(newPath, newPath.Replace(ZLMZipExtractionPath, $"{ValheimGameFolder}"), true);
494520

495521
}
496522
catch

0 commit comments

Comments
 (0)