-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TitleShortcuts - Add KoikatuSunshine version
- Loading branch information
1 parent
9fdb8ad
commit feebcde
Showing
3 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/TitleShortcuts.KoikatuSunshine/TitleShortcuts.KoikatuSunshine.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="..\BuildSettings.Common.props" /> | ||
<Import Project="..\BuildSettings.KoikatsuSunshine.props" /> | ||
<ItemGroup> | ||
<PackageReference Include="BepInEx.Core" Version="5.4.4" /> | ||
<PackageReference Include="IllusionLibs.KoikatsuSunshine.Assembly-CSharp" Version="2021.9.17" /> | ||
<PackageReference Include="IllusionLibs.KoikatsuSunshine.Assembly-CSharp-firstpass" Version="2021.9.17" /> | ||
<PackageReference Include="IllusionLibs.KoikatsuSunshine.UniTask" Version="2021.9.17" /> | ||
<PackageReference Include="IllusionLibs.KoikatsuSunshine.UnityEngine.CoreModule" Version="2019.4.9" /> | ||
<PackageReference Include="IllusionLibs.KoikatsuSunshine.UnityEngine.UI" Version="2019.4.9" /> | ||
<PackageReference Include="IllusionLibs.KoikatsuSunshine.UnityEngine.UIModule" Version="2019.4.9" /> | ||
</ItemGroup> | ||
<Import Project="..\TitleShortcuts.Core\TitleShortcuts.Core.projitems" Label="Shared" /> | ||
<Import Project="..\Common.Core\Common.Core.projitems" Label="Shared" /> | ||
<Import Project="..\Common.KoikatsuSunshine\Common.KoikatsuSunshine.projitems" Label="Shared" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using System; | ||
using BepInEx; | ||
using BepInEx.Configuration; | ||
using HarmonyLib; | ||
using KeelPlugins.Koikatu; | ||
using System.Collections; | ||
using TitleShortcuts.Core; | ||
using UnityEngine; | ||
|
||
[assembly: System.Reflection.AssemblyFileVersion(TitleShortcuts.KoikatuSunshine.TitleShortcuts.Version)] | ||
|
||
namespace TitleShortcuts.KoikatuSunshine | ||
{ | ||
[BepInProcess(Constants.MainGameProcessName)] | ||
//[BepInProcess(Constants.MainGameProcessNameSteam)] | ||
[BepInPlugin(GUID, PluginName, Version)] | ||
public class TitleShortcuts : TitleShortcutsCore | ||
{ | ||
public const string Version = "1.3.0." + BuildNumber.Version; | ||
|
||
private static ConfigEntry<KeyboardShortcut> StartFemaleMaker { get; set; } | ||
private static ConfigEntry<KeyboardShortcut> StartMaleMaker { get; set; } | ||
private static ConfigEntry<KeyboardShortcut> StartUploader { get; set; } | ||
private static ConfigEntry<KeyboardShortcut> StartDownloader { get; set; } | ||
private static ConfigEntry<KeyboardShortcut> StartFreeH { get; set; } | ||
private static ConfigEntry<KeyboardShortcut> StartGameLoad { get; set; } | ||
|
||
protected override void Awake() | ||
{ | ||
base.Awake(); | ||
|
||
StartFemaleMaker = Config.Bind(SECTION_HOTKEYS, "Open female maker", new KeyboardShortcut(KeyCode.F)); | ||
StartMaleMaker = Config.Bind(SECTION_HOTKEYS, "Open male maker", new KeyboardShortcut(KeyCode.M)); | ||
StartUploader = Config.Bind(SECTION_HOTKEYS, "Open uploader", new KeyboardShortcut(KeyCode.U)); | ||
StartDownloader = Config.Bind(SECTION_HOTKEYS, "Open downloader", new KeyboardShortcut(KeyCode.D)); | ||
StartFreeH = Config.Bind(SECTION_HOTKEYS, "Start free H", new KeyboardShortcut(KeyCode.H)); | ||
StartGameLoad = Config.Bind(SECTION_HOTKEYS, "Open Load Game screen", new KeyboardShortcut(KeyCode.G)); | ||
|
||
Harmony.CreateAndPatchAll(GetType()); | ||
} | ||
|
||
[HarmonyPrefix, HarmonyPatch(typeof(TitleScene), nameof(TitleScene.Start))] | ||
private static void TitleStart(TitleScene __instance) | ||
{ | ||
Plugin.StartCoroutine(TitleInput(__instance)); | ||
} | ||
|
||
private static IEnumerator TitleInput(TitleScene titleScene) | ||
{ | ||
do | ||
{ | ||
yield return null; | ||
|
||
if(StartFemaleMaker.Value.IsDown()) StartMode(titleScene.OnCustomFemale, "Starting female maker"); | ||
else if(StartMaleMaker.Value.IsDown()) StartMode(titleScene.OnCustomMale, "Starting male maker"); | ||
else if(StartUploader.Value.IsDown()) StartMode(titleScene.OnUploader, "Starting uploader"); | ||
else if(StartDownloader.Value.IsDown()) StartMode(titleScene.OnDownloader, "Starting downloader"); | ||
else if(StartFreeH.Value.IsDown()) StartMode(titleScene.OnOtherFreeH, "Starting free H"); | ||
else if(StartGameLoad.Value.IsDown()) StartMode(titleScene.OnLoad, "Opening Load Game screen"); | ||
} | ||
while(titleScene); | ||
|
||
void StartMode(Action action, string msg) | ||
{ | ||
if(titleScene && (!FindObjectOfType<ConfigScene>() || !ConfigScene.active)) | ||
{ | ||
Log.Message(msg); | ||
action(); | ||
titleScene = null; | ||
} | ||
} | ||
} | ||
|
||
[HarmonyPostfix, HarmonyPatch(typeof(FreeHScene), nameof(FreeHScene.Start))] | ||
private static void TitleStart(FreeHScene __instance, ref IEnumerator __result) | ||
{ | ||
var origResult = __result; | ||
__result = new object[]{origResult, HSceneInput(__instance)}.GetEnumerator(); | ||
} | ||
|
||
private static IEnumerator HSceneInput(FreeHScene freeHScene) | ||
{ | ||
for(int i = 0; i < 4; i++) | ||
yield return null; | ||
|
||
while(freeHScene != null) | ||
{ | ||
if(StartFreeH.Value.IsDown()) | ||
{ | ||
freeHScene.enterButton.onClick.Invoke(); | ||
freeHScene = null; | ||
} | ||
yield return null; | ||
} | ||
} | ||
} | ||
} |