|
| 1 | +using HarmonyLib; |
| 2 | +using static SceneCharacterSelect; |
| 3 | + |
| 4 | +namespace COM3D2.DressCode; |
| 5 | + |
| 6 | +internal class CharacterSelectThumbnail { |
| 7 | + private static CostumeScene _scene; |
| 8 | + |
| 9 | + private static bool TryGetThumbnailPath(Maid maid, out string path) { |
| 10 | + path = string.Empty; |
| 11 | + if (DressCode.TryGetMaidProfile(maid, _scene, out var profile) && profile is { PreferredProfile: CostumeProfile.Personal, HasCostume: true }) { |
| 12 | + path = DressCode.GetThumbnailPath(maid, _scene); |
| 13 | + return true; |
| 14 | + } |
| 15 | + return false; |
| 16 | + } |
| 17 | + |
| 18 | + [HarmonyPrefix] |
| 19 | + [HarmonyPatch(typeof(CharacterSelectManager), nameof(CharacterSelectManager.Awake))] |
| 20 | + private static void CharacterSelectManager_Awake() { |
| 21 | + _scene = CostumeScene.None; |
| 22 | + } |
| 23 | + |
| 24 | + [HarmonyPostfix] |
| 25 | + [HarmonyPatch(typeof(CharacterSelectMain), nameof(CharacterSelectMain.OnCall))] |
| 26 | + private static void CharacterSelectMain_OnCall(CharacterSelectMain __instance) { |
| 27 | + _scene = __instance.scene_chara_select_.select_type switch { |
| 28 | + SelectType.Yotogi => CostumeScene.YotogiTalk, |
| 29 | + SelectType.NewYotogi or SelectType.NewYotogiAdditional => CostumeScene.Yotogi, |
| 30 | + SelectType.HoneymoonMode => CostumeScene.Honeymoon, |
| 31 | + _ => CostumeScene.None, |
| 32 | + }; |
| 33 | + |
| 34 | + if (_scene != CostumeScene.None && TryGetThumbnailPath(__instance.select_maid_, out var thumbnailPath)) { |
| 35 | + __instance.chara_select_mgr_.big_thumbnail.SetFile(thumbnailPath); |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + [HarmonyPostfix] |
| 40 | + [HarmonyPatch(typeof(DanceSelect), nameof(DanceSelect.Awake))] |
| 41 | + private static void DanceSelect_Awake() { |
| 42 | + _scene = CostumeScene.Dance; |
| 43 | + } |
| 44 | + |
| 45 | + [HarmonyPostfix] |
| 46 | + [HarmonyPatch(typeof(YotogiSubCharacterSelectManager), nameof(YotogiSubCharacterSelectManager.OnCall))] |
| 47 | + private static void YotogiSubCharacterSelectManager_OnCall() { |
| 48 | + _scene = CostumeScene.Yotogi; |
| 49 | + } |
| 50 | + |
| 51 | + [HarmonyPrefix] |
| 52 | + [HarmonyPatch(typeof(BigThumbnail), nameof(BigThumbnail.SetMaid))] |
| 53 | + private static bool BigThumbnail_SetMaid(BigThumbnail __instance, Maid maid) { |
| 54 | + if (_scene == CostumeScene.None) { |
| 55 | + return true; |
| 56 | + } |
| 57 | + |
| 58 | + if (_scene is CostumeScene.Dance or CostumeScene.PoleDance) { |
| 59 | + if (DanceSelect.m_SelectedDance.First() is { RhythmGameCorrespond: true }) { |
| 60 | + _scene = CostumeScene.Dance; |
| 61 | + } else { |
| 62 | + _scene = CostumeScene.PoleDance; |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + if (_scene != CostumeScene.None && TryGetThumbnailPath(maid, out var thumbnailPath)) { |
| 67 | + __instance.SetFile(thumbnailPath); |
| 68 | + return false; |
| 69 | + } |
| 70 | + |
| 71 | + return true; |
| 72 | + } |
| 73 | +} |
0 commit comments