mirror of
https://github.com/TheJordanDev/PEAK-JordanMod.git
synced 2026-10-17 08:05:25 +02:00
0.1.9 | Centralized Audio loading & BingBong voices
This commit is contained in:
@@ -45,7 +45,7 @@ public class BetterBuglePatch
|
||||
// BetterBugleUI.Instance?.ShowActionbar("No songs available.");
|
||||
// return;
|
||||
// }
|
||||
if (BetterBugleModule.IsLoading) return;
|
||||
if (AudioSyncWorker.IsLoading) return;
|
||||
if (!BetterBugleModule.HadConfirmation)
|
||||
{
|
||||
BetterBugleUI.Instance?.ShowActionbar("Are you sure you want to refresh songs ? Right-click again to reload.");
|
||||
@@ -57,7 +57,7 @@ public class BetterBuglePatch
|
||||
{
|
||||
BetterBugleModule.HadConfirmation = false; // Reset confirmation state
|
||||
BetterBugleUI.Instance?.ShowActionbar("Refreshing songs...");
|
||||
BetterBugleModule.Instance?.GetAudioClips();
|
||||
AudioSyncService.GetAudioClips();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public class BetterBuglePatch
|
||||
|
||||
private static void OnScroll(float scrollDelta)
|
||||
{
|
||||
if (BetterBugleModule.IsLoading) return;
|
||||
if (AudioSyncWorker.IsLoading) return;
|
||||
bool isNext = scrollDelta > 0;
|
||||
if (Song.Songs.Count == 0)
|
||||
{
|
||||
@@ -80,15 +80,15 @@ public class BetterBuglePatch
|
||||
return;
|
||||
}
|
||||
|
||||
if (isNext && BetterBugleModule.CurrentSongIndex < Song.Songs.Count - 1) BetterBugleModule.CurrentSongIndex++;
|
||||
else if (isNext && BetterBugleModule.CurrentSongIndex == Song.Songs.Count - 1) BetterBugleModule.CurrentSongIndex = 0;
|
||||
else if (!isNext && BetterBugleModule.CurrentSongIndex > 0) BetterBugleModule.CurrentSongIndex--;
|
||||
else BetterBugleModule.CurrentSongIndex = Song.Songs.Count - 1;
|
||||
BetterBugleModule.CurrentSongName = Song.GetSongNames_Alphabetically()[BetterBugleModule.CurrentSongIndex];
|
||||
if (isNext && AudioSyncWorker.CurrentSongIndex < Song.Songs.Count - 1) AudioSyncWorker.CurrentSongIndex++;
|
||||
else if (isNext && AudioSyncWorker.CurrentSongIndex == Song.Songs.Count - 1) AudioSyncWorker.CurrentSongIndex = 0;
|
||||
else if (!isNext && AudioSyncWorker.CurrentSongIndex > 0) AudioSyncWorker.CurrentSongIndex--;
|
||||
else AudioSyncWorker.CurrentSongIndex = Song.Songs.Count - 1;
|
||||
AudioSyncWorker.CurrentSongName = Song.GetSongNames_Alphabetically()[AudioSyncWorker.CurrentSongIndex];
|
||||
|
||||
Song currentSong = Song.Songs[BetterBugleModule.CurrentSongName];
|
||||
Song currentSong = Song.Songs[AudioSyncWorker.CurrentSongName];
|
||||
|
||||
bool isFavorite = Song.FavoriteSongs.Contains(BetterBugleModule.CurrentSongName);
|
||||
bool isFavorite = Song.FavoriteSongs.Contains(AudioSyncWorker.CurrentSongName);
|
||||
BetterBugleUI.Instance?.ShowActionbar($" {(isFavorite ? "★" : " ")} {currentSong.RealIndex} | {currentSong.Name.Replace("_", " ")}");
|
||||
}
|
||||
|
||||
@@ -104,10 +104,10 @@ public class BetterBuglePatch
|
||||
if (currentItem.itemState != ItemState.Held) return;
|
||||
if (currentItem.TryGetComponent<BugleSFX>(out var bugleSFX))
|
||||
{
|
||||
Song? song = Song.Songs.GetValueOrDefault(BetterBugleModule.CurrentSongName);
|
||||
Song? song = Song.Songs.GetValueOrDefault(AudioSyncWorker.CurrentSongName);
|
||||
if (song == null) return;
|
||||
|
||||
bool isFavorite = Song.FavoriteSongs.Contains(BetterBugleModule.CurrentSongName);
|
||||
bool isFavorite = Song.FavoriteSongs.Contains(AudioSyncWorker.CurrentSongName);
|
||||
BetterBugleUI.Instance?.ShowActionbar($"{(isFavorite ? "★" : " ")} {song.RealIndex} | {song.Name}");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HarmonyLib;
|
||||
using JordanMod.Utils;
|
||||
@@ -8,6 +9,14 @@ namespace JordanMod.Modules.ReplaceBingBong;
|
||||
public class ReplaceBingBongPatch
|
||||
{
|
||||
|
||||
[HarmonyPatch(typeof(Item), "Start")]
|
||||
[HarmonyPrefix]
|
||||
static void OnItemStart(Item __instance)
|
||||
{
|
||||
if (__instance.name != "BingBong_Prop Variant") return;
|
||||
Debug.Log($"Item {__instance.name} Start in scene {__instance.gameObject.scene.name} ({__instance.gameObject.scene.buildIndex})");
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(ItemActionBase), "OnEnable")]
|
||||
[HarmonyPrefix]
|
||||
static bool PreActionAskBingBongConstructorFix(ItemActionBase __instance)
|
||||
@@ -16,54 +25,18 @@ public class ReplaceBingBongPatch
|
||||
return true;
|
||||
|
||||
Action_AskBingBong.BingBongResponse[] currentResponses = [..askBingBong.responses];
|
||||
// Each response has a .sfx which has a Object.name, store a ref to the sfx with key being sfx name
|
||||
Dictionary<string, SFX_Instance> sfxDict = new();
|
||||
for (int i = 0; i < currentResponses.Length; i++)
|
||||
|
||||
if (!ReplaceBingBongModule.HasReplacedSounds)
|
||||
{
|
||||
Action_AskBingBong.BingBongResponse response = currentResponses[i];
|
||||
if (response.sfx != null && response.sfx.clips != null && response.sfx.clips.Length > 0)
|
||||
ReplaceBingBongModule.OriginalResponsesData = new BingBongResponseData[currentResponses.Length];
|
||||
for (int index = 0; index < currentResponses.Length; index++)
|
||||
{
|
||||
foreach (AudioClip clip in response.sfx.clips)
|
||||
{
|
||||
sfxDict[response.sfx.name] = response.sfx;
|
||||
}
|
||||
ReplaceBingBongModule.OriginalResponsesData[index] = BingBongResponseData.FromBingBongResponse(currentResponses[index]);
|
||||
}
|
||||
ReplaceBingBongModule.HasReplacedSounds = true;
|
||||
}
|
||||
|
||||
List<Song> voices = [.. Song.BB_VoiceLines.Values];
|
||||
|
||||
foreach (Song voice in voices)
|
||||
{
|
||||
AudioClip clip = voice.AudioClip;
|
||||
|
||||
bool isNew = !sfxDict.ContainsKey(voice.Name);
|
||||
if (isNew)
|
||||
{
|
||||
SFX_Instance sFX_Instance = new()
|
||||
{
|
||||
clips = [clip]
|
||||
};
|
||||
Action_AskBingBong.BingBongResponse newResponse = new()
|
||||
{
|
||||
sfx = sFX_Instance,
|
||||
subtitleID = "idk_funny",
|
||||
mouthCurve = null,
|
||||
mouthCurveTime = 1f
|
||||
};
|
||||
currentResponses = [.. currentResponses, newResponse];
|
||||
}
|
||||
else
|
||||
{
|
||||
sfxDict[voice.Name].clips = [clip];
|
||||
}
|
||||
}
|
||||
|
||||
askBingBong.responses = new Action_AskBingBong.BingBongResponse[currentResponses.Length];
|
||||
for (int i = 0; i < currentResponses.Length; i++)
|
||||
{
|
||||
askBingBong.responses[i] = currentResponses[i];
|
||||
}
|
||||
|
||||
ReplaceBingBongModule.ReplaceBingBongResponses(askBingBong);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user