Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion StardewXnbHack/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,24 @@ public static void Run(string[] args, GameRunner game = null, string gamePath =

// read command-line arguments
bool omitDefaultFields = args.Contains("--clean");
bool unlocalizedOnly = args.Contains("--unlocalized");

// the language codes to check for if unlocalizedOnly
HashSet<string> languageCodes = new HashSet<string>
{
"ja-JP", "ru-RU", "zh-CN",
"pt-BR", "es-ES", "de-DE",
"th-TH", "fr-FR", "ko-KR",
"it-IT", "tr-TR", "hu-HU"
};

// start log
logger.OnStepChanged(ProgressStep.Started, $"Running StardewXnbHack {Program.GetUnpackerVersion()}.{(omitDefaultFields ? " Special options: omit default fields." : "")}");
List<string> specialOptions = new();
if (omitDefaultFields)
specialOptions.Add("omit default fields");
if (unlocalizedOnly)
specialOptions.Add("English assets only");
logger.OnStepChanged(ProgressStep.Started, $"Running StardewXnbHack {Program.GetUnpackerVersion()}.{(specialOptions.Any() ? $" Special options: {string.Join(", ", specialOptions)}" : "")}");

// start timer
Stopwatch timer = new Stopwatch();
Expand Down Expand Up @@ -166,6 +181,11 @@ public static void Run(string[] args, GameRunner game = null, string gamePath =
{
// prepare paths
string assetName = file.FullName.Substring(context.ContentPath.Length + 1, file.FullName.Length - context.ContentPath.Length - 5); // remove root path + .xnb extension

if (unlocalizedOnly && assetName[^6] == '.') // localized assets end with e.g. ".ja-JP" & unlocalized assets don't have a period, so this saves some string checking
if (languageCodes.Any(code => assetName.EndsWith(code)))
continue;

string relativePath = $"{assetName}.xnb";
string fileExportPath = Path.Combine(context.ExportPath, assetName);
Directory.CreateDirectory(Path.GetDirectoryName(fileExportPath));
Expand Down