|
1 | 1 | using commonItems; |
2 | 2 | using commonItems.Collections; |
| 3 | +using commonItems.Exceptions; |
3 | 4 | using commonItems.Mods; |
4 | | -using ImperatorToCK3.Exceptions; |
5 | 5 | using System; |
6 | 6 | using System.Collections.Generic; |
7 | 7 | using System.Globalization; |
@@ -29,6 +29,8 @@ internal sealed class Configuration { |
29 | 29 | public Date CK3BookmarkDate { get; set; } = new(0, 1, 1); |
30 | 30 | public bool SkipDynamicCoAExtraction { get; set; } = false; |
31 | 31 | public bool SkipHoldingOwnersImport { get; set; } = true; |
| 32 | + public GameVersion IRVersion { get; private set; } = new(); |
| 33 | + public GameVersion CK3Version { get; private set; } = new(); |
32 | 34 | public bool FallenEagleEnabled { get; private set; } |
33 | 35 | public bool WhenTheWorldStoppedMakingSenseEnabled { get; private set; } |
34 | 36 | public bool RajasOfAsiaEnabled { get; private set; } |
@@ -291,40 +293,34 @@ private void SetOutputName() { |
291 | 293 |
|
292 | 294 | private void VerifyImperatorVersion(ConverterVersion converterVersion) { |
293 | 295 | var path = Path.Combine(ImperatorPath, "launcher/launcher-settings.json"); |
294 | | - var irVersion = GameVersion.ExtractVersionFromLauncher(path); |
295 | | - if (irVersion is null) { |
296 | | - Logger.Error("Imperator version could not be determined, proceeding blind!"); |
297 | | - return; |
298 | | - } |
| 296 | + IRVersion = GameVersion.ExtractVersionFromLauncher(path) ?? |
| 297 | + throw new ConverterException("Imperator version could not be determined."); |
299 | 298 |
|
300 | | - Logger.Info($"Imperator version: {irVersion.ToShortString()}"); |
| 299 | + Logger.Info($"Imperator version: {IRVersion.ToShortString()}"); |
301 | 300 |
|
302 | | - if (converterVersion.MinSource > irVersion) { |
303 | | - Logger.Error($"Imperator version is v{irVersion.ToShortString()}, converter requires minimum v{converterVersion.MinSource.ToShortString()}!"); |
| 301 | + if (converterVersion.MinSource > IRVersion) { |
| 302 | + Logger.Error($"Imperator version is v{IRVersion.ToShortString()}, converter requires minimum v{converterVersion.MinSource.ToShortString()}!"); |
304 | 303 | throw new UserErrorException("Converter vs Imperator installation mismatch!"); |
305 | 304 | } |
306 | | - if (!converterVersion.MaxSource.IsLargerishThan(irVersion)) { |
307 | | - Logger.Error($"Imperator version is v{irVersion.ToShortString()}, converter requires maximum v{converterVersion.MaxSource.ToShortString()}!"); |
| 305 | + if (!converterVersion.MaxSource.IsLargerishThan(IRVersion)) { |
| 306 | + Logger.Error($"Imperator version is v{IRVersion.ToShortString()}, converter requires maximum v{converterVersion.MaxSource.ToShortString()}!"); |
308 | 307 | throw new UserErrorException("Converter vs Imperator installation mismatch!"); |
309 | 308 | } |
310 | 309 | } |
311 | 310 |
|
312 | 311 | private void VerifyCK3Version(ConverterVersion converterVersion) { |
313 | 312 | var path = Path.Combine(CK3Path, "launcher/launcher-settings.json"); |
314 | | - var ck3Version = GameVersion.ExtractVersionFromLauncher(path); |
315 | | - if (ck3Version is null) { |
316 | | - Logger.Error("CK3 version could not be determined, proceeding blind!"); |
317 | | - return; |
318 | | - } |
| 313 | + CK3Version = GameVersion.ExtractVersionFromLauncher(path) ?? |
| 314 | + throw new ConverterException("CK3 version could not be determined."); |
319 | 315 |
|
320 | | - Logger.Info($"CK3 version: {ck3Version.ToShortString()}"); |
| 316 | + Logger.Info($"CK3 version: {CK3Version.ToShortString()}"); |
321 | 317 |
|
322 | | - if (converterVersion.MinTarget > ck3Version) { |
323 | | - Logger.Error($"CK3 version is v{ck3Version.ToShortString()}, converter requires minimum v{converterVersion.MinTarget.ToShortString()}!"); |
| 318 | + if (converterVersion.MinTarget > CK3Version) { |
| 319 | + Logger.Error($"CK3 version is v{CK3Version.ToShortString()}, converter requires minimum v{converterVersion.MinTarget.ToShortString()}!"); |
324 | 320 | throw new UserErrorException("Converter vs CK3 installation mismatch!"); |
325 | 321 | } |
326 | | - if (!converterVersion.MaxTarget.IsLargerishThan(ck3Version)) { |
327 | | - Logger.Error($"CK3 version is v{ck3Version.ToShortString()}, converter requires maximum v{converterVersion.MaxTarget.ToShortString()}!"); |
| 322 | + if (!converterVersion.MaxTarget.IsLargerishThan(CK3Version)) { |
| 323 | + Logger.Error($"CK3 version is v{CK3Version.ToShortString()}, converter requires maximum v{converterVersion.MaxTarget.ToShortString()}!"); |
328 | 324 | throw new UserErrorException("Converter vs CK3 installation mismatch!"); |
329 | 325 | } |
330 | 326 | } |
|
0 commit comments