1- using System . Diagnostics ;
1+ using System . Diagnostics ;
22using System . IO . Compression ;
33using System . Security . Cryptography ;
44using MaiChartManager . Utils ;
@@ -34,7 +34,8 @@ public record GameModInfo(
3434 bool IsJudgeDisplay4BInstalled ,
3535 bool IsHidConflictExist ,
3636 AquaMaiSignatureV2 . VerifyResult ? Signature ,
37- bool IsMmlLibInstalled
37+ bool IsAdxHidIoModAbsent ,
38+ bool IsMmlLegacyLibsInstalled
3839 ) ;
3940
4041 [ HttpGet ]
@@ -55,7 +56,17 @@ public GameModInfo GetGameModInfo()
5556 sig = AquaMaiSignatureV2 . VerifySignature ( System . IO . File . ReadAllBytes ( ModPaths . AquaMaiDllInstalledPath ) ) ;
5657 }
5758
58- return new GameModInfo ( IsMelonInstalled ( ) , aquaMaiInstalled , aquaMaiVersion , aquaMaiBuiltinVersion ! , GetIsJudgeDisplay4BInstalled ( ) , GetIsHidConflictExist ( ) , sig , GetIsMmlLibInstalled ( ) ) ;
59+ return new GameModInfo (
60+ IsMelonInstalled ( ) ,
61+ aquaMaiInstalled ,
62+ aquaMaiVersion ,
63+ aquaMaiBuiltinVersion ! ,
64+ GetIsJudgeDisplay4BInstalled ( ) ,
65+ GetIsHidConflictExist ( ) ,
66+ sig ,
67+ GetIsAdxHidIoModAbsent ( ) ,
68+ GetIsMmlLegacyLibsInstalled ( )
69+ ) ;
5970 }
6071
6172 [ NonAction ]
@@ -100,12 +111,14 @@ public void DeleteHidConflict()
100111 #endregion
101112
102113 [ NonAction ]
103- private static bool GetIsMmlLibInstalled ( )
114+ private static bool GetIsAdxHidIoModAbsent ( )
115+ {
116+ return ! System . IO . File . Exists ( Path . Combine ( StaticSettings . GamePath , @"Mods\ADXHIDIOMod.dll" ) ) ;
117+ }
118+
119+ [ NonAction ]
120+ private static bool GetIsMmlLegacyLibsInstalled ( )
104121 {
105- if ( System . IO . File . Exists ( Path . Combine ( StaticSettings . GamePath , @"Mods\ADXHIDIOMod.dll" ) ) )
106- {
107- return false ;
108- }
109122 if ( ! System . IO . File . Exists ( Path . Combine ( StaticSettings . GamePath , @"Sinmai_Data\Plugins\hidapi.dll" ) ) )
110123 {
111124 return false ;
@@ -118,21 +131,32 @@ private static bool GetIsMmlLibInstalled()
118131 return true ;
119132 }
120133
134+ private static void CopyFile ( string src , string dest )
135+ {
136+ Directory . CreateDirectory ( Path . GetDirectoryName ( dest ) ! ) ;
137+ using var read = System . IO . File . OpenRead ( src ) ;
138+ using var write = System . IO . File . Open ( dest , FileMode . Create ) ;
139+ read . CopyTo ( write ) ;
140+ }
141+
142+ public record InstallMmlLibsDto ( bool UseLegacy ) ;
143+
121144 [ HttpPost ]
122- public void InstallMmlLibs ( )
145+ public void InstallMmlLibs ( [ FromBody ] InstallMmlLibsDto req )
123146 {
124- if ( GetIsMmlLibInstalled ( ) ) return ;
147+ var isMaimollerLegacyModeEnabled = req . UseLegacy ;
125148 if ( System . IO . File . Exists ( Path . Combine ( StaticSettings . GamePath , @"Mods\ADXHIDIOMod.dll" ) ) )
126149 {
127150 System . IO . File . Delete ( Path . Combine ( StaticSettings . GamePath , @"Mods\ADXHIDIOMod.dll" ) ) ;
128151 }
152+ if ( ! isMaimollerLegacyModeEnabled || GetIsMmlLegacyLibsInstalled ( ) ) return ;
129153 if ( ! System . IO . File . Exists ( Path . Combine ( StaticSettings . GamePath , @"Sinmai_Data\Plugins\hidapi.dll" ) ) )
130154 {
131- System . IO . File . Copy ( Path . Combine ( StaticSettings . exeDir , @"hidapi.dll" ) , Path . Combine ( StaticSettings . GamePath , @"Sinmai_Data\Plugins\hidapi.dll" ) ) ;
155+ CopyFile ( Path . Combine ( StaticSettings . exeDir , @"hidapi.dll" ) , Path . Combine ( StaticSettings . GamePath , @"Sinmai_Data\Plugins\hidapi.dll" ) ) ;
132156 }
133157 if ( ! System . IO . File . Exists ( Path . Combine ( StaticSettings . GamePath , @"Sinmai_Data\Plugins\libadxhid.dll" ) ) )
134158 {
135- System . IO . File . Copy ( Path . Combine ( StaticSettings . exeDir , @"libadxhid.dll" ) , Path . Combine ( StaticSettings . GamePath , @"Sinmai_Data\Plugins\libadxhid.dll" ) ) ;
159+ CopyFile ( Path . Combine ( StaticSettings . exeDir , @"libadxhid.dll" ) , Path . Combine ( StaticSettings . GamePath , @"Sinmai_Data\Plugins\libadxhid.dll" ) ) ;
136160 }
137161 }
138162
@@ -143,7 +167,7 @@ public void InstallJudgeDisplay4B()
143167
144168 foreach ( var file in Directory . EnumerateFiles ( judgeDisplay4BPath ) )
145169 {
146- System . IO . File . Copy ( file , Path . Combine ( StaticSettings . SkinAssetsDir , Path . GetFileName ( file ) ) , true ) ;
170+ CopyFile ( file , Path . Combine ( StaticSettings . SkinAssetsDir , Path . GetFileName ( file ) ) ) ;
147171 }
148172 }
149173
@@ -173,10 +197,7 @@ public void InstallAquaMai()
173197 {
174198 var src = Path . Combine ( StaticSettings . exeDir , "AquaMai.dll" ) ;
175199 var dest = Path . Combine ( StaticSettings . GamePath , @"Mods\AquaMai.dll" ) ;
176- Directory . CreateDirectory ( Path . GetDirectoryName ( dest ) ) ;
177- using var read = System . IO . File . OpenRead ( src ) ;
178- using var write = System . IO . File . Open ( dest , FileMode . Create ) ;
179- read . CopyTo ( write ) ;
200+ CopyFile ( src , dest ) ;
180201 }
181202
182203 [ HttpPost ]
@@ -263,4 +284,4 @@ public void KillGameProcess()
263284 }
264285 }
265286 }
266- }
287+ }
0 commit comments