From 54d9579e19655d15ef719ac6f5bd8f091c821040 Mon Sep 17 00:00:00 2001 From: DeathWeasel1337 Date: Sun, 30 May 2021 13:41:56 -0500 Subject: [PATCH] KKS port --- KK_Plugins.sln | 9 ++ src/Subtitles.Core/Core.Subtitles.cs | 2 +- src/Subtitles.KKS/KKS.Subtitles.Hooks.cs | 21 +++ src/Subtitles.KKS/KKS.Subtitles.csproj | 141 +++++++++++++++++++ src/Subtitles.KKS/Resources/EmbeddedSubs.xml | 120 ++++++++++++++++ src/Subtitles.KKS/packages.config | 14 ++ 6 files changed, 306 insertions(+), 1 deletion(-) create mode 100644 src/Subtitles.KKS/KKS.Subtitles.Hooks.cs create mode 100644 src/Subtitles.KKS/KKS.Subtitles.csproj create mode 100644 src/Subtitles.KKS/Resources/EmbeddedSubs.xml create mode 100644 src/Subtitles.KKS/packages.config diff --git a/KK_Plugins.sln b/KK_Plugins.sln index 7a3692c5..929c1d15 100644 --- a/KK_Plugins.sln +++ b/KK_Plugins.sln @@ -420,6 +420,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KKS.ReloadCharaListOnChange EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EC.ReloadCharaListOnChange", "src\ReloadCharaListOnChange.EC\EC.ReloadCharaListOnChange.csproj", "{906CF257-347F-4AC7-AC8F-74082346B74A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KKS.Subtitles", "src\Subtitles.KKS\KKS.Subtitles.csproj", "{86BDC6AF-B123-4116-B0CE-6884360CF070}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution src\Shared\Shared.projitems*{002aa641-4dc8-4fef-83dd-a7fab3af6daf}*SharedItemsImports = 4 @@ -602,6 +604,8 @@ Global src\AccessoryClothes.Core\AccessoryClothes.Core.projitems*{84060175-95bd-4ad7-ba46-508dc8959b32}*SharedItemsImports = 4 src\Shared\Shared.projitems*{84060175-95bd-4ad7-ba46-508dc8959b32}*SharedItemsImports = 4 src\Shared\Shared.projitems*{841ffff7-1940-4b7b-b21f-83e2f16333d4}*SharedItemsImports = 13 + src\Shared\Shared.projitems*{86bdc6af-b123-4116-b0ce-6884360cf070}*SharedItemsImports = 4 + src\Subtitles.Core\Core.Subtitles.projitems*{86bdc6af-b123-4116-b0ce-6884360cf070}*SharedItemsImports = 4 src\MakerDefaults.Core.KKEC\Core.MakerDefaults.KKEC.projitems*{878bb100-7d7c-43d2-8e9d-608d93d738e4}*SharedItemsImports = 4 src\Shared\Shared.projitems*{878bb100-7d7c-43d2-8e9d-608d93d738e4}*SharedItemsImports = 4 src\CharacterExport.Core\Core.CharacterExport.projitems*{87c4f79c-3074-476b-849b-ce1498840e55}*SharedItemsImports = 4 @@ -1264,6 +1268,10 @@ Global {906CF257-347F-4AC7-AC8F-74082346B74A}.Debug|Any CPU.Build.0 = Debug|Any CPU {906CF257-347F-4AC7-AC8F-74082346B74A}.Release|Any CPU.ActiveCfg = Release|Any CPU {906CF257-347F-4AC7-AC8F-74082346B74A}.Release|Any CPU.Build.0 = Release|Any CPU + {86BDC6AF-B123-4116-B0CE-6884360CF070}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {86BDC6AF-B123-4116-B0CE-6884360CF070}.Debug|Any CPU.Build.0 = Debug|Any CPU + {86BDC6AF-B123-4116-B0CE-6884360CF070}.Release|Any CPU.ActiveCfg = Release|Any CPU + {86BDC6AF-B123-4116-B0CE-6884360CF070}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1432,6 +1440,7 @@ Global {F6368CED-8F10-4949-9D53-71707C111BD0} = {74D9C2ED-06F3-41D4-88EA-EB7A664157B3} {4B3E58C9-E9AC-4EA6-AA0B-D5C2FB520484} = {74D9C2ED-06F3-41D4-88EA-EB7A664157B3} {906CF257-347F-4AC7-AC8F-74082346B74A} = {74D9C2ED-06F3-41D4-88EA-EB7A664157B3} + {86BDC6AF-B123-4116-B0CE-6884360CF070} = {A17C16DF-D157-4751-94E7-686FD22E1DAC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D0F79985-4CB7-46CB-BEC2-FF89C476ED20} diff --git a/src/Subtitles.Core/Core.Subtitles.cs b/src/Subtitles.Core/Core.Subtitles.cs index 4f552149..9c4f6b71 100644 --- a/src/Subtitles.Core/Core.Subtitles.cs +++ b/src/Subtitles.Core/Core.Subtitles.cs @@ -41,7 +41,7 @@ public partial class Subtitles : BaseUnityPlugin internal static Dictionary SubtitleDictionary = new Dictionary(); -#if KK || EC || HS || PC +#if KK || EC || HS || PC || KKS internal const float WorldScale = 1f; #elif AI || HS2 internal const float WorldScale = 10f; diff --git a/src/Subtitles.KKS/KKS.Subtitles.Hooks.cs b/src/Subtitles.KKS/KKS.Subtitles.Hooks.cs new file mode 100644 index 00000000..0978f93e --- /dev/null +++ b/src/Subtitles.KKS/KKS.Subtitles.Hooks.cs @@ -0,0 +1,21 @@ +using HarmonyLib; +using UnityEngine; + +namespace KK_Plugins +{ + public partial class Subtitles + { + internal static class Hooks + { + [HarmonyPostfix, HarmonyPatch(typeof(Manager.Sound), nameof(Manager.Sound.Play_Standby), typeof(AudioSource), typeof(Manager.Sound.Loader))] + private static void PlayVoice(AudioSource audioSource, Manager.Sound.Loader loader) + { + if (loader.asset.IsNullOrEmpty() || loader.asset.Contains("_bgm_")) + return; + + if (SubtitleDictionary.TryGetValue(loader.asset, out string text)) + Caption.DisplaySubtitle(audioSource.gameObject, text); + } + } + } +} \ No newline at end of file diff --git a/src/Subtitles.KKS/KKS.Subtitles.csproj b/src/Subtitles.KKS/KKS.Subtitles.csproj new file mode 100644 index 00000000..157aa63e --- /dev/null +++ b/src/Subtitles.KKS/KKS.Subtitles.csproj @@ -0,0 +1,141 @@ + + + + + Debug + AnyCPU + {86BDC6AF-B123-4116-B0CE-6884360CF070} + Library + Properties + KK_Plugins + KKS_Subtitles + v4.6 + 512 + true + + + + + true + full + false + ..\..\bin\ + TRACE;DEBUG;KKS + prompt + 4 + true + + + full + true + ..\..\bin\ + TRACE;KKS + prompt + 4 + true + true + + + + ..\..\packages\IllusionLibs.BepInEx.Harmony.2.3.2\lib\net35\0Harmony.dll + False + + + ..\..\packages\IllusionLibs.KoikatsuSunshine.Assembly-CSharp.2021.5.28\lib\net46\Assembly-CSharp.dll + False + + + ..\..\packages\IllusionLibs.BepInEx.5.4.8\lib\net35\BepInEx.dll + False + + + ..\..\packages\IllusionLibs.BepInEx.Harmony.2.3.2\lib\net35\BepInEx.Harmony.dll + False + + + ..\..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\lib\net46\Sirenix.Serialization.dll + False + + + + + + + + + + + ..\..\packages\IllusionLibs.KoikatsuSunshine.UniRx.2021.5.28\lib\net46\UniRx.dll + False + + + ..\..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\lib\net46\UnityEngine.dll + False + + + ..\..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.AudioModule.2019.4.9\lib\net46\UnityEngine.AudioModule.dll + False + + + ..\..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule.2019.4.9\lib\net46\UnityEngine.CoreModule.dll + False + + + ..\..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.TextRenderingModule.2019.4.9\lib\net46\UnityEngine.TextRenderingModule.dll + False + + + ..\..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.UI.2019.4.9\lib\net46\UnityEngine.UI.dll + False + + + ..\..\packages\IllusionLibs.KoikatsuSunshine.UnityEngine.UIModule.2019.4.9\lib\net46\UnityEngine.UIModule.dll + False + + + + + + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + + + + + + + IF EXIST "$(TargetDir)$(TargetName).pdb" IF EXIST "$(SolutionDir)pdb2mdb.exe" CALL "$(SolutionDir)pdb2mdb.exe" "$(TargetPath)" +IF EXIST "$(SolutionDir)PostBuild.bat" CALL "$(SolutionDir)PostBuild.bat" "$(TargetPath)" KKS + + + + + + \ No newline at end of file diff --git a/src/Subtitles.KKS/Resources/EmbeddedSubs.xml b/src/Subtitles.KKS/Resources/EmbeddedSubs.xml new file mode 100644 index 00000000..40fe7f57 --- /dev/null +++ b/src/Subtitles.KKS/Resources/EmbeddedSubs.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Subtitles.KKS/packages.config b/src/Subtitles.KKS/packages.config new file mode 100644 index 00000000..7b55fa5f --- /dev/null +++ b/src/Subtitles.KKS/packages.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file