2727// ReSharper disable IdentifierTypo
2828// ReSharper disable SwitchStatementMissingSomeEnumCasesNoDefault
2929// ReSharper disable SwitchStatementHandlesSomeKnownEnumValuesWithDefault
30+ #pragma warning disable IDE0130
3031
32+ #nullable enable
3133namespace CollapseLauncher . InstallManager . Honkai
3234{
3335 internal sealed partial class HonkaiInstall : InstallManagerBase
3436 {
3537 #region Override Properties
3638
37- protected override bool _canDeltaPatch => GameVersionManager . IsGameHasDeltaPatch ( ) ;
38- protected override DeltaPatchProperty _gameDeltaPatchProperty => GameVersionManager . GetDeltaPatchInfo ( ) ;
39+ protected override bool _canDeltaPatch => GameVersionManager . IsGameHasDeltaPatch ( ) ;
40+ protected override DeltaPatchProperty ? _gameDeltaPatchProperty => GameVersionManager . GetDeltaPatchInfo ( ) ;
3941
4042 #endregion
4143
4244 #region Properties
4345
44- private HonkaiRepairV2 _gameRepairManager { get ; set ; }
46+ private HonkaiRepairV2 _gameRepairManager { get ; }
4547
4648 #endregion
4749
48- public HonkaiInstall ( UIElement parentUI , IGameVersion gameVersionManager , IGameSettings gameSettings )
50+ public HonkaiInstall ( UIElement parentUI , IGameVersion gameVersionManager , IGameSettings gameSettings , IRepair gameRepairManager )
4951 : base ( parentUI , gameVersionManager , gameSettings )
5052 {
53+ _gameRepairManager = ( HonkaiRepairV2 ) gameRepairManager ;
5154 }
5255
5356 #region Public Methods
@@ -64,7 +67,7 @@ public override async ValueTask<int> StartPackageVerification(List<GameInstallPa
6467
6568 // If the confirm is 1 (verified) or -1 (cancelled), then return the code
6669 int deltaPatchConfirm = await ConfirmDeltaPatchDialog ( _gameDeltaPatchProperty ,
67- _gameRepairManager ??= GetGameRepairInstance ( _gameDeltaPatchProperty . SourceVer ) ) ;
70+ _gameRepairManager ) ;
6871 if ( deltaPatchConfirm is - 1 or 1 )
6972 {
7073 return deltaPatchConfirm ;
@@ -74,16 +77,14 @@ public override async ValueTask<int> StartPackageVerification(List<GameInstallPa
7477 return await base . StartPackageVerification ( gamePackage ) ;
7578 }
7679
77- #nullable enable
7880 protected override HonkaiRepairV2 GetGameRepairInstance ( string ? versionString ) =>
79- new HonkaiRepairV2 ( ParentUI ,
80- GameVersionManager ,
81- GameSettings ! ,
82- versionString ,
83- true ) ;
84- #nullable restore
85-
86- protected override async Task StartPackageInstallationInner ( List < GameInstallPackage > gamePackage = null ,
81+ new ( ParentUI ,
82+ GameVersionManager ,
83+ GameSettings ! ,
84+ versionString ,
85+ true ) ;
86+
87+ protected override async Task StartPackageInstallationInner ( List < GameInstallPackage > ? gamePackage = null ,
8788 bool isOnlyInstallPackage = false ,
8889 bool doNotDeleteZipExplicit = false )
8990 {
@@ -100,8 +101,8 @@ protected override async Task StartPackageInstallationInner(List<GameInstallPack
100101 public override async ValueTask < bool > TryShowFailedGameConversionState ( )
101102 {
102103 // Get the target and source path
103- string gamePath = GameVersionManager . GameDirPath ;
104- string gamePathIngredients = GetFailedGameConversionFolder ( gamePath ) ;
104+ string gamePath = GameVersionManager . GameDirPath ;
105+ string ? gamePathIngredients = GetFailedGameConversionFolder ( gamePath ) ;
105106 // If path doesn't exist or null, then return false
106107 if ( gamePathIngredients is null || ! Directory . Exists ( gamePathIngredients ) )
107108 {
@@ -136,24 +137,24 @@ public override async ValueTask<bool> TryShowFailedGameConversionState()
136137
137138 #region Private Methods - Utilities
138139
139- private string GetFailedGameConversionFolder ( string basepath )
140+ private string ? GetFailedGameConversionFolder ( string basepath )
140141 {
141142 try
142143 {
143144 // Step back once from the game directory
144- string ParentPath = Path . GetDirectoryName ( basepath ) ;
145+ string ? parentPath = Path . GetDirectoryName ( basepath ) ;
145146 // Get the ingredient path
146- if ( ParentPath != null )
147+ if ( ! string . IsNullOrEmpty ( parentPath ) )
147148 {
148- string IngredientPath = Directory
149- . EnumerateDirectories ( ParentPath ,
149+ string ? ingredientPath = Directory
150+ . EnumerateDirectories ( parentPath ,
150151 $ "{ GameVersionManager . GamePreset . GameDirectoryName } *_ConvertedTo-*_Ingredients",
151152 SearchOption . TopDirectoryOnly )
152153 . FirstOrDefault ( ) ;
153154 // If the path is not null, then return
154- if ( IngredientPath is not null )
155+ if ( ingredientPath is not null )
155156 {
156- return IngredientPath ;
157+ return ingredientPath ;
157158 }
158159 }
159160 }
0 commit comments