Skip to content

Commit f1741b3

Browse files
committed
Show custom thumbnails on maid selection screens
1 parent dbe669c commit f1741b3

2 files changed

Lines changed: 79 additions & 1 deletion

File tree

CharacterSelectThumbnail.cs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
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+
}

DressCode.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ private void Awake() {
5353

5454
Harmony.CreateAndPatchAll(typeof(DressCode));
5555
Harmony.CreateAndPatchAll(typeof(CostumeEdit));
56+
Harmony.CreateAndPatchAll(typeof(CharacterSelectThumbnail));
5657
}
5758

5859
internal static void LogDebug(object data) {
@@ -63,13 +64,17 @@ internal static void LogDebug(object data) {
6364

6465
internal static Texture2D GetThumbnail(CostumeScene scene, Maid maid) {
6566
Texture2D result = null;
66-
var thumbnailPath = Path.Combine(Maid.ThumbnailDictionary, DressCode.GetThumbnailFileName(maid, scene));
67+
var thumbnailPath = GetThumbnailPath(maid, scene);
6768
if (File.Exists(thumbnailPath)) {
6869
result = UTY.LoadTexture(thumbnailPath);
6970
}
7071
return result;
7172
}
7273

74+
internal static string GetThumbnailPath(Maid maid, CostumeScene scene) {
75+
return Path.Combine(Maid.ThumbnailDictionary, GetThumbnailFileName(maid, scene));
76+
}
77+
7378
internal static string GetThumbnailFileName(Maid maid, CostumeScene scene) {
7479
return $"dresscode_{maid?.status.guid ?? "scene"}_{scene.ToString().ToLower()}.png";
7580
}

0 commit comments

Comments
 (0)