|
1 | 1 | using System.Collections.Generic; |
2 | 2 | using System.IO; |
3 | 3 | using AquaMai.Config.Attributes; |
| 4 | +using AquaMai.Core.Attributes; |
4 | 5 | using AquaMai.Core.Helpers; |
5 | 6 | using CriMana; |
6 | 7 | using HarmonyLib; |
7 | 8 | using MAI2.Util; |
8 | 9 | using Manager; |
9 | 10 | using MelonLoader; |
| 11 | +using Monitor; |
10 | 12 | using Monitor.Game; |
11 | 13 | using UnityEngine; |
12 | 14 | using UnityEngine.Video; |
@@ -171,13 +173,15 @@ public static async void GetMovie() { |
171 | 173 | } |
172 | 174 |
|
173 | 175 | // 异步调用后处理函数 |
| 176 | + //MelonLogger.Msg($"[MovieLoader] start {musicID}"); //DEBUG |
174 | 177 | jacket = await JacketPostProcess(jacket); |
175 | 178 | if (jacket is null) { |
176 | 179 | MelonLogger.Msg($"[MovieLoader] post-process return null for {musicID}"); |
177 | 180 | return; |
178 | 181 | } |
179 | 182 | movieInfo.Type = MovieInfo.MovieType.Jacket; // 后处理完成 |
180 | 183 | movieInfo.JacketTexture = jacket; |
| 184 | + //MelonLogger.Msg($"[MovieLoader] success {musicID}"); //DEBUG |
181 | 185 | } |
182 | 186 | } catch (System.Exception e) {MelonLogger.Msg($"[MovieLoader] GetMovie() error: {e}");} |
183 | 187 | } |
@@ -274,11 +278,16 @@ private static async Task<Texture2D> JacketPostProcess(Texture2D jacket) { |
274 | 278 | } |
275 | 279 |
|
276 | 280 | private static VideoPlayer[] _videoPlayers = new VideoPlayer[2]; |
| 281 | + private static bool _isReplaced = false; |
277 | 282 |
|
278 | 283 | [HarmonyPostfix] |
279 | 284 | [HarmonyPatch(typeof(GameCtrl), "Initialize")] |
280 | 285 | public static void LoadLocalBgaAwake(GameObject ____movieMaskObj, int ___monitorIndex) |
281 | 286 | { |
| 287 | + //if (___monitorIndex == 0) MelonLogger.Msg($"[MovieLoader] Load"); //DEBUG |
| 288 | + |
| 289 | + _isReplaced = false; |
| 290 | + |
282 | 291 | if (!movieInfo.IsValid) return; |
283 | 292 |
|
284 | 293 | string mp4Path = ""; |
@@ -309,6 +318,8 @@ public static void LoadLocalBgaAwake(GameObject ____movieMaskObj, int ___monitor |
309 | 318 | return; |
310 | 319 | } |
311 | 320 |
|
| 321 | + _isReplaced = true; |
| 322 | + |
312 | 323 | if (mp4Exists) |
313 | 324 | { |
314 | 325 | if (_videoPlayers[___monitorIndex] == null) |
@@ -368,6 +379,17 @@ public static void LoadLocalBgaAwake(GameObject ____movieMaskObj, int ___monitor |
368 | 379 | } |
369 | 380 | } |
370 | 381 |
|
| 382 | + [HarmonyPrefix] |
| 383 | + [HarmonyPatch(typeof(GameMonitor), "SetMovieMaterial")] |
| 384 | + [EnableGameVersion(minVersion: 25500)] |
| 385 | + public static bool SetMovieMaterial(Material material, int ___monitorIndex) |
| 386 | + { |
| 387 | +# if DEBUG |
| 388 | + MelonLogger.Msg("SetMovieMaterial"); |
| 389 | +# endif |
| 390 | + return !_isReplaced; |
| 391 | + } |
| 392 | + |
371 | 393 | [HarmonyPostfix] |
372 | 394 | [HarmonyPatch(typeof(MovieController), "GetMovieHeight")] |
373 | 395 | public static void GetMovieHeightPostfix(ref uint __result) |
|
0 commit comments