2024-08-13 17:24:00 +00:00
|
|
|
using System.IO;
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
namespace KeepersCompound.TMV;
|
|
|
|
|
|
|
|
// TODO: Error handling lol
|
|
|
|
public class InstallPaths
|
|
|
|
{
|
|
|
|
public string rootPath;
|
|
|
|
public string famPath;
|
2024-08-17 19:53:16 +00:00
|
|
|
public string objPath;
|
2024-08-13 17:24:00 +00:00
|
|
|
public string omsPath;
|
|
|
|
public string fmsPath;
|
|
|
|
|
|
|
|
public InstallPaths(string root)
|
|
|
|
{
|
|
|
|
var searchOptions = new EnumerationOptions
|
|
|
|
{
|
|
|
|
MatchCasing = MatchCasing.CaseInsensitive,
|
|
|
|
RecurseSubdirectories = true
|
|
|
|
};
|
|
|
|
|
|
|
|
rootPath = root;
|
|
|
|
famPath = Directory.GetFiles(rootPath, "fam.crf", searchOptions)[0];
|
2024-08-17 19:53:16 +00:00
|
|
|
objPath = Directory.GetFiles(rootPath, "obj.crf", searchOptions)[0];
|
2024-08-13 18:10:05 +00:00
|
|
|
var paths = Directory.GetFiles(rootPath, "install.cfg", searchOptions);
|
|
|
|
if (paths.Length == 0)
|
|
|
|
{
|
|
|
|
paths = Directory.GetFiles(rootPath, "darkinst.cfg", searchOptions);
|
|
|
|
}
|
|
|
|
var installCfgPath = paths[0];
|
2024-08-13 17:24:00 +00:00
|
|
|
GD.Print($"Install.cfg: {installCfgPath}");
|
|
|
|
foreach (var line in File.ReadLines(installCfgPath))
|
|
|
|
{
|
|
|
|
if (line.StartsWith("load_path"))
|
|
|
|
{
|
|
|
|
var path = line.Split(" ")[1].Replace("\\", "/");
|
|
|
|
omsPath = Path.GetFullPath(rootPath + path);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var camModPath = Directory.GetFiles(rootPath, "cam_mod.ini", searchOptions)[0];
|
|
|
|
fmsPath = rootPath + "/FMs";
|
|
|
|
foreach (var line in File.ReadLines(camModPath))
|
|
|
|
{
|
|
|
|
if (line.StartsWith("fm_path"))
|
|
|
|
{
|
|
|
|
var path = line.Split(" ")[1].Replace("\\", "/");
|
|
|
|
fmsPath = Path.GetFullPath(rootPath + path);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GD.Print($"OMs Path: {omsPath}");
|
|
|
|
}
|
|
|
|
}
|