mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-24 23:27:14 -05:00
Dump patterns with index
#443 People can zip up indexed or non-indexed for sharing.
This commit is contained in:
parent
1c4df60920
commit
b7b16bdc5e
|
|
@ -142,7 +142,10 @@ private static void Dump(this IVillager v, string path)
|
|||
public static void DumpDesigns(this MainSave sav, string path)
|
||||
{
|
||||
for (int i = 0; i < MainSaveOffsets.PatternCount; i++)
|
||||
sav.GetDesign(i).Dump(path);
|
||||
{
|
||||
var dp = sav.GetDesign(i);
|
||||
dp.Dump(path, i);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -150,18 +153,27 @@ public static void DumpDesigns(this MainSave sav, string path)
|
|||
/// </summary>
|
||||
/// <param name="patterns">Patterns to dump</param>
|
||||
/// <param name="path">Path to dump to</param>
|
||||
public static void Dump(this IEnumerable<DesignPattern> patterns, string path)
|
||||
public static void Dump(this IReadOnlyList<DesignPattern> patterns, string path)
|
||||
{
|
||||
foreach (var dp in patterns)
|
||||
dp.Dump(path);
|
||||
for (var index = 0; index < patterns.Count; index++)
|
||||
{
|
||||
var dp = patterns[index];
|
||||
dp.Dump(path, index);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Dump(this DesignPattern dp, string path)
|
||||
private static void Dump(this DesignPattern dp, string path, int index)
|
||||
{
|
||||
// Dump without index
|
||||
var name = dp.DesignName;
|
||||
var fn = StringUtil.CleanFileName($"{name}.nhd");
|
||||
var dest = Path.Combine(path, fn);
|
||||
File.WriteAllBytes(dest, dp.Data);
|
||||
|
||||
// Dump with index
|
||||
fn = StringUtil.CleanFileName($"{index:00} - {name}.nhd");
|
||||
dest = Path.Combine(path, fn);
|
||||
File.WriteAllBytes(dest, dp.Data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -199,7 +211,10 @@ public static void Load(this DesignPattern[] patterns, string path)
|
|||
public static void DumpDesignsPRO(this MainSave sav, string path)
|
||||
{
|
||||
for (int i = 0; i < MainSaveOffsets.PatternCount; i++)
|
||||
sav.GetDesignPRO(i).Dump(path);
|
||||
{
|
||||
var dp = sav.GetDesignPRO(i);
|
||||
dp.Dump(path, i);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -207,10 +222,13 @@ public static void DumpDesignsPRO(this MainSave sav, string path)
|
|||
/// </summary>
|
||||
/// <param name="patterns">Patterns to dump</param>
|
||||
/// <param name="path">Path to dump to</param>
|
||||
public static void Dump(this IEnumerable<DesignPatternPRO> patterns, string path)
|
||||
public static void Dump(this IReadOnlyList<DesignPatternPRO> patterns, string path)
|
||||
{
|
||||
foreach (var dp in patterns)
|
||||
dp.Dump(path);
|
||||
for (var index = 0; index < patterns.Count; index++)
|
||||
{
|
||||
var dp = patterns[index];
|
||||
dp.Dump(path, index);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -240,12 +258,18 @@ public static void Load(this DesignPatternPRO[] patterns, string path)
|
|||
}
|
||||
}
|
||||
|
||||
private static void Dump(this DesignPatternPRO dp, string path)
|
||||
private static void Dump(this DesignPatternPRO dp, string path, int index)
|
||||
{
|
||||
// Dump without index
|
||||
var name = dp.DesignName;
|
||||
var fn = StringUtil.CleanFileName($"{name}.nhpd");
|
||||
var dest = Path.Combine(path, fn);
|
||||
File.WriteAllBytes(dest, dp.Data);
|
||||
|
||||
// Dump with index
|
||||
fn = StringUtil.CleanFileName($"{index:00} - {name}.nhpd");
|
||||
dest = Path.Combine(path, fn);
|
||||
File.WriteAllBytes(dest, dp.Data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user