Skip to content

Commit 10e1252

Browse files
committed
v1.7 - Anomaly support, custom language directory name
1 parent 9fca21c commit 10e1252

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
lines changed

Properties/launchSettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"profiles": {
33
"RimCzechGitDownloader": {
4-
"commandName": "Project",
5-
"commandLineArgs": "-source https://github.com/lordfanger/RimWorld-Czech"
4+
"commandName": "Project",
5+
"commandLineArgs": "\"U:\\Hry\\SteamLib\\steamapps\\common\\RimWorld\" -language \"czech - git\""
66
}
77
}
88
}

RimCzechGitDownloader.cs

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public Expansion(string rimBase, string name)
2121
_name = name;
2222
_checkPart = $"/{name}/";
2323
var baseDir = Path.Combine(rimBase, "Data", name, "Languages");
24-
LanguageDir = Path.Combine(baseDir, "Czech - git");
24+
LanguageDir = Path.Combine(baseDir, LangugaDirName);
2525
Exists = Directory.Exists(baseDir);
2626
}
2727

@@ -44,27 +44,43 @@ public static Expansion[] GetExpansions(string rimBase, out Expansion core)
4444
new Expansion(rimBase, "Royalty"),
4545
new Expansion(rimBase, "Ideology"),
4646
new Expansion(rimBase, "Biotech"),
47+
new Expansion(rimBase, "Anomaly"),
4748
];
4849
}
4950
}
5051

51-
private const string DEFAULT_GITHUB_URL = "https://github.com/Ludeon/rimworld-Czech/archive/refs/heads/master.zip";
52+
private static string LangugaDirName = "Czech - git";
5253

53-
private static string Version => "1.6";
54+
private const string DEFAULT_GITHUB_URL = "https://github.com/Ludeon/rimworld-Czech/archive/refs/heads/master.zip";
55+
56+
private static string Version => "1.7";
5457

5558
private static void Main(string[] args)
5659
{
5760
Console.OutputEncoding = System.Text.Encoding.UTF8;
5861
Console.WriteLine($"Rim Czech Git Downloader - v {Version}");
5962
Console.WriteLine("Hledám instalaci RimWorldu...");
60-
var (rimWorldDirectory, githubUrl) = args switch
63+
var (rimWorldDirectory, githubUrl) = ((string?)null, DEFAULT_GITHUB_URL);
64+
65+
while (args is not [])
6166
{
62-
[var directory] => (directory, DEFAULT_GITHUB_URL),
63-
[var directory, "-source", var source] => (directory, source),
64-
["-source", var source] => (null, source),
65-
_ => (null, DEFAULT_GITHUB_URL)
66-
};
67-
67+
if (args is ["-source", var source, .. var rest])
68+
{
69+
args = rest;
70+
githubUrl = source;
71+
}
72+
else if (args is ["-language", var language, .. var rest2])
73+
{
74+
args = rest2;
75+
LangugaDirName = language;
76+
}
77+
else if (args is [var directory, .. var rest3])
78+
{
79+
args = rest3;
80+
rimWorldDirectory = directory;
81+
}
82+
}
83+
6884
if (!string.IsNullOrEmpty(rimWorldDirectory))
6985
{
7086
SafeExecute(() => CheckForRimWorldFolder(rimWorldDirectory));
@@ -193,6 +209,7 @@ void CopyToFile(ZipArchiveEntry entry, string path)
193209

194210
Stream GetGitZip()
195211
{
212+
Console.WriteLine($"Downloading from '{githubUrl}'");
196213
using var httpClient = new HttpClient();
197214
//var response = httpClient.Send(new HttpRequestMessage(HttpMethod.Get, @"https://github.com/Ludeon/rimworld-Czech/archive/refs/heads/master.zip"));
198215
//var response = httpClient.Send(new HttpRequestMessage(HttpMethod.Get, @"https://github.com/lordfanger/rimworld-Czech/archive/refs/heads/biotech-1.zip"));
@@ -201,7 +218,8 @@ Stream GetGitZip()
201218
var ms = new MemoryStream();
202219
data.CopyTo(ms);
203220
ms.Position = 0;
204-
return ms;
221+
Console.WriteLine($"Downloaded");
222+
return ms;
205223
}
206224
}
207225
}

0 commit comments

Comments
 (0)