Support for The Sims 3 in config file

This commit is contained in:
Tony Bark 2025-04-30 09:04:18 -04:00
parent 8d07e6d307
commit 7af7fc427b
3 changed files with 19 additions and 4 deletions

View file

@ -2,7 +2,7 @@ namespace S2PK;
public class Config
{
public string Destination { get; set; } = string.Empty;
public Destination Games { get; set; } = new();
/// <summary>
/// Loads the configuration from the specified file path.
@ -16,3 +16,9 @@ public class Config
return config;
}
}
public class Destination
{
public string Sims2 { get; set; } = string.Empty;
public string Sims3 { get; set; } = string.Empty;
}

View file

@ -46,12 +46,19 @@ public static class PackageManager
/// </summary>
/// <param name="package">The path to the package file.</param>
/// <param name="destination">The destination directory. If not provided, the destination is read from the configuration file.</param>
public static void UnpackPackages(string package, string destination = "")
/// <param name="ts3">Whether to unpack for The Sims 3.</param>
public static void UnpackPackages(string package, string destination = "", bool ts3 = false)
{
// If destination is not provided, read from configuration file
if (string.IsNullOrEmpty(destination))
{
var config = Config.Load("s2pk.toml"); // TODO: Config file should be in home directory
destination = config.Destination;
// If The Sims 3 is not specified, use the default destination
if (!ts3)
destination = config.Games.Sims2;
else
destination = config.Games.Sims3;
}
var file = new FileInfo(package);

View file

@ -1 +1,3 @@
destination ≡ "path/to/destination"
[games]
sims2 ≡ "path/to/sims2"
sims3 ≡ "path/to/sims3"