Better handling of multiple config file resource paths
This commit is contained in:
parent
7ae7407c2b
commit
ad08d373b7
|
@ -147,11 +147,10 @@ public class ResourcePathManager
|
||||||
throw new InvalidOperationException("Failed to find all installation config paths.");
|
throw new InvalidOperationException("Failed to find all installation config paths.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the paths of the base Fam and Obj resources so we can extract them.
|
// We need to know where all the texture and object resources are
|
||||||
|
var zipPaths = new List<string>();
|
||||||
var installCfgLines = File.ReadAllLines(configPaths[(int)ConfigFile.Install]);
|
var installCfgLines = File.ReadAllLines(configPaths[(int)ConfigFile.Install]);
|
||||||
FindConfigVar(installCfgLines, "resname_base", out var resPaths);
|
FindConfigVar(installCfgLines, "resname_base", out var resPaths);
|
||||||
var baseFamPath = "";
|
|
||||||
var baseObjPath = "";
|
|
||||||
foreach (var resPath in resPaths.Split('+'))
|
foreach (var resPath in resPaths.Split('+'))
|
||||||
{
|
{
|
||||||
var dir = Path.Join(installPath, ConvertSeparator(resPath));
|
var dir = Path.Join(installPath, ConvertSeparator(resPath));
|
||||||
|
@ -160,31 +159,24 @@ public class ResourcePathManager
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This just finds the *first* respath that has these files... They should be merged
|
|
||||||
foreach (var path in Directory.GetFiles(dir))
|
foreach (var path in Directory.GetFiles(dir))
|
||||||
{
|
{
|
||||||
var name = Path.GetFileName(path).ToLower();
|
var name = Path.GetFileName(path).ToLower();
|
||||||
if (name == "fam.crf" && baseFamPath == "")
|
if (name is "fam.crf" or "obj.crf")
|
||||||
{
|
{
|
||||||
baseFamPath = path;
|
zipPaths.Add(path);
|
||||||
}
|
|
||||||
else if (name == "obj.crf" && baseObjPath == "")
|
|
||||||
{
|
|
||||||
baseObjPath = path;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do the extraction bro
|
// Do the extraction bro
|
||||||
(string, string)[] resources = [("fam", baseFamPath), ("obj", baseObjPath)];
|
// The path order is a priority order, so we don't want to overwrite any files when extracting
|
||||||
foreach (var (extractName, zipPath) in resources)
|
// TODO: Check if there's any problems caused by case sensitivity
|
||||||
|
foreach (var zipPath in zipPaths)
|
||||||
{
|
{
|
||||||
var extractPath = Path.Join(_extractionPath, extractName);
|
var resType = Path.GetFileNameWithoutExtension(zipPath);
|
||||||
if (Directory.Exists(extractPath))
|
var extractPath = Path.Join(_extractionPath, resType);
|
||||||
{
|
ZipFile.OpenRead(zipPath).ExtractToDirectory(extractPath, false);
|
||||||
Directory.Delete(extractPath, true);
|
|
||||||
}
|
|
||||||
ZipFile.OpenRead(zipPath).ExtractToDirectory(extractPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FindConfigVar(installCfgLines, "load_path", out var omsPath);
|
FindConfigVar(installCfgLines, "load_path", out var omsPath);
|
||||||
|
|
Loading…
Reference in New Issue