-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from ManlyMarco/master
- Loading branch information
Showing
6 changed files
with
95 additions
and
109 deletions.
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
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
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
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
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 |
---|---|---|
@@ -1,157 +1,124 @@ | ||
using BepInEx; | ||
using BepInEx.Configuration; | ||
using BepInEx.Logging; | ||
using HarmonyLib; | ||
using System.Collections; | ||
using System.ComponentModel; | ||
using UnityEngine; | ||
using UnityEngine.Events; | ||
using UnityEngine.SceneManagement; | ||
|
||
namespace KeelPlugins | ||
{ | ||
[BepInProcess(KoikatuConstants.MainGameProcessName)] | ||
[BepInProcess(KoikatuConstants.MainGameProcessNameSteam)] | ||
[BepInProcess(KoikatuConstants.VRProcessName)] | ||
[BepInProcess(KoikatuConstants.VRProcessNameSteam)] | ||
[BepInPlugin(GUID, PluginName, Version)] | ||
public class TitleShortcuts : TitleShortcutsCore | ||
{ | ||
private ConfigEntry<AutoStartOption> AutoStart { get; set; } | ||
private ConfigEntry<KeyboardShortcut> StartFemaleMaker { get; set; } | ||
private ConfigEntry<KeyboardShortcut> StartMaleMaker { get; set; } | ||
private ConfigEntry<KeyboardShortcut> StartUploader { get; set; } | ||
private ConfigEntry<KeyboardShortcut> StartDownloader { get; set; } | ||
private ConfigEntry<KeyboardShortcut> StartFreeH { get; set; } | ||
private ConfigEntry<KeyboardShortcut> StartLiveShow { get; set; } | ||
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> StartLiveShow { get; set; } | ||
|
||
private bool checkInput = false; | ||
private bool cancelAuto = false; | ||
private TitleScene titleScene; | ||
private const string ArgumentFemaleMaker = "-femalemaker"; | ||
private const string ArgumentMaleMaker = "-malemaker"; | ||
private const string ArgumentFreeH= "-freeh"; | ||
private const string ArgumentLive = "-live"; | ||
|
||
protected override string[] PossibleArguments => new[] { "-femalemaker", "-malemaker", "-freeh", "-live" }; | ||
private static bool autostartFinished = false; | ||
private static TitleScene titleScene; | ||
|
||
private void Awake() | ||
protected override string[] PossibleArguments => new[] { ArgumentFemaleMaker, ArgumentMaleMaker, ArgumentFreeH, ArgumentLive }; | ||
|
||
protected override void Awake() | ||
{ | ||
AutoStart = Config.Bind(SECTION_GENERAL, "Automatic start mode", AutoStartOption.Disabled, new ConfigDescription(DESCRIPTION_AUTOSTART)); | ||
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)); | ||
StartLiveShow = Config.Bind(SECTION_HOTKEYS, "Start live show", new KeyboardShortcut(KeyCode.L)); | ||
|
||
SceneManager.sceneLoaded += StartInput; | ||
Harmony.CreateAndPatchAll(GetType()); | ||
} | ||
|
||
private void StartInput(Scene scene, LoadSceneMode mode) | ||
[HarmonyPrefix] | ||
[HarmonyPatch(typeof(TitleScene), "Start")] | ||
private static void TitleSceneStart(TitleScene __instance) | ||
{ | ||
var title = FindObjectOfType<TitleScene>(); | ||
titleScene = __instance; | ||
Plugin.StartCoroutine(TitleSceneInput()); | ||
} | ||
|
||
if(title) | ||
[HarmonyPrefix] | ||
[HarmonyPatch(typeof(Manager.Scene.Data), nameof(Manager.Scene.Data.isFade), MethodType.Setter)] | ||
private static bool DisableFadeout() | ||
{ | ||
return autostartFinished; | ||
} | ||
|
||
[HarmonyPrefix] | ||
[HarmonyPatch(typeof(LogoScene), "Start")] | ||
private static bool DisableIntro(ref IEnumerator __result) | ||
{ | ||
IEnumerator LoadTitle() | ||
{ | ||
if(!checkInput) | ||
Singleton<Manager.Scene>.Instance.LoadReserve(new Manager.Scene.Data | ||
{ | ||
titleScene = title; | ||
checkInput = true; | ||
StartCoroutine(InputCheck()); | ||
} | ||
} | ||
else | ||
{ | ||
checkInput = false; | ||
levelName = "Title", | ||
isFade = false | ||
}, false); | ||
yield break; | ||
} | ||
__result = LoadTitle(); | ||
return false; | ||
} | ||
|
||
private IEnumerator InputCheck() | ||
private static IEnumerator TitleSceneInput() | ||
{ | ||
while(checkInput) | ||
while(titleScene != null) | ||
{ | ||
if(!cancelAuto && AutoStart.Value != AutoStartOption.Disabled && (Input.GetKey(KeyCode.Escape) || Input.GetKey(KeyCode.F1))) | ||
if(StartFemaleMaker.Value.IsDown() || !autostartFinished && StartupArgument == ArgumentFemaleMaker) | ||
{ | ||
Logger.Log(LogLevel.Message, "Automatic start cancelled"); | ||
cancelAuto = true; | ||
StartMode(titleScene.OnCustomFemale, "Starting female maker"); | ||
} | ||
|
||
if(!Manager.Scene.Instance.IsNowLoadingFade) | ||
else if(StartMaleMaker.Value.IsDown() || !autostartFinished && StartupArgument == ArgumentMaleMaker) | ||
{ | ||
if(StartFemaleMaker.Value.IsPressed() || firstLaunch && StartupArgument == "-femalemaker") | ||
{ | ||
StartMode(titleScene.OnCustomFemale, "Starting female maker"); | ||
} | ||
else if(StartMaleMaker.Value.IsPressed() || firstLaunch && StartupArgument == "-malemaker") | ||
{ | ||
StartMode(titleScene.OnCustomMale, "Starting male maker"); | ||
} | ||
|
||
else if(StartUploader.Value.IsPressed()) | ||
{ | ||
StartMode(titleScene.OnUploader, "Starting uploader"); | ||
} | ||
else if(StartDownloader.Value.IsPressed()) | ||
{ | ||
StartMode(titleScene.OnDownloader, "Starting downloader"); | ||
} | ||
|
||
else if(StartFreeH.Value.IsPressed() || firstLaunch && StartupArgument == "-freeh") | ||
{ | ||
StartMode(titleScene.OnOtherFreeH, "Starting free H"); | ||
} | ||
else if(StartLiveShow.Value.IsPressed() || firstLaunch && StartupArgument == "-live") | ||
{ | ||
StartMode(titleScene.OnOtherIdolLive, "Starting live show"); | ||
} | ||
|
||
else if(!cancelAuto && AutoStart.Value != AutoStartOption.Disabled) | ||
{ | ||
switch(AutoStart.Value) | ||
{ | ||
case AutoStartOption.FemaleMaker: | ||
StartMode(titleScene.OnCustomFemale, "Automatically starting female maker"); | ||
break; | ||
|
||
case AutoStartOption.MaleMaker: | ||
StartMode(titleScene.OnCustomMale, "Automatically starting male maker"); | ||
break; | ||
|
||
case AutoStartOption.FreeH: | ||
StartMode(titleScene.OnOtherFreeH, "Automatically starting free H"); | ||
break; | ||
StartMode(titleScene.OnCustomMale, "Starting male maker"); | ||
} | ||
|
||
case AutoStartOption.LiveStage: | ||
StartMode(titleScene.OnOtherIdolLive, "Automatically starting live show"); | ||
break; | ||
} | ||
} | ||
else if(StartUploader.Value.IsDown()) | ||
{ | ||
StartMode(titleScene.OnUploader, "Starting uploader"); | ||
} | ||
else if(StartDownloader.Value.IsDown()) | ||
{ | ||
StartMode(titleScene.OnDownloader, "Starting downloader"); | ||
} | ||
|
||
cancelAuto = true; | ||
else if(StartFreeH.Value.IsDown() || !autostartFinished && StartupArgument == ArgumentFreeH) | ||
{ | ||
StartMode(titleScene.OnOtherFreeH, "Starting free H"); | ||
} | ||
else if(StartLiveShow.Value.IsDown() || !autostartFinished && StartupArgument == ArgumentLive) | ||
{ | ||
StartMode(titleScene.OnOtherIdolLive, "Starting live show"); | ||
} | ||
|
||
yield return null; | ||
} | ||
} | ||
|
||
private void StartMode(UnityAction action, string msg) | ||
private static void StartMode(UnityAction action, string msg) | ||
{ | ||
firstLaunch = false; | ||
if(!FindObjectOfType<ConfigScene>()) | ||
{ | ||
Logger.LogMessage(msg); | ||
checkInput = false; | ||
titleScene = null; | ||
action(); | ||
autostartFinished = true; | ||
} | ||
} | ||
|
||
private enum AutoStartOption | ||
{ | ||
Disabled, | ||
[Description("Female maker")] | ||
FemaleMaker, | ||
[Description("Male maker")] | ||
MaleMaker, | ||
[Description("Free H")] | ||
FreeH, | ||
[Description("Live stage")] | ||
LiveStage | ||
} | ||
} | ||
} |
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