From 3721d5d82ddd80bd3e1cfd3e49a022d630c698b4 Mon Sep 17 00:00:00 2001 From: SFBdragon Date: Wed, 15 Feb 2023 20:29:55 +0200 Subject: [PATCH 1/8] add announce option --- src/MusicAnnouncementsConfig.cs | 18 ++++++++++++------ src/MusicAnnouncementsMod.cs | 6 ++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/MusicAnnouncementsConfig.cs b/src/MusicAnnouncementsConfig.cs index 8a7a5c9..781eb0a 100644 --- a/src/MusicAnnouncementsConfig.cs +++ b/src/MusicAnnouncementsConfig.cs @@ -6,6 +6,7 @@ namespace MusicAnnouncements public class MusicAnnouncementsConfig : OptionInterface { public static Configurable pauseMenuText; + public static Configurable ingameText; public MusicAnnouncementsConfig() { @@ -13,6 +14,10 @@ public MusicAnnouncementsConfig() { "Show currently playing song in the pause menu" })); + ingameText = config.Bind("ingameText", true, new ConfigurableInfo("Announce the name of the currently playing song in the bottom left of the screen.", tags: new object[] + { + "Announce currently playing song in the bottom left" + })); } // Called when the config menu is opened by the player. (I think) @@ -27,7 +32,8 @@ public override void Initialize() AddDivider(593f); AddTitle(); AddDivider(540f); - AddCheckbox(); + AddCheckbox(pauseMenuText); + AddCheckbox(ingameText); } private void AddDivider(float y) @@ -59,16 +65,16 @@ private void AddTitle() }); } - private void AddCheckbox() + private void AddCheckbox(Configurable optionText) { - OpCheckBox checkbox = new OpCheckBox(pauseMenuText, new Vector2(150f, 500f)) + OpCheckBox checkbox = new OpCheckBox(optionText, new Vector2(150f, 500f)) { - description = pauseMenuText.info.description + description = optionText.info.description }; - OpLabel checkboxLabel = new OpLabel(150f + 40f, 500f + 2f, pauseMenuText.info.Tags[0] as string) + OpLabel checkboxLabel = new OpLabel(150f + 40f, 500f + 2f, optionText.info.Tags[0] as string) { - description = pauseMenuText.info.description + description = optionText.info.description }; Tabs[0].AddItems(new UIelement[] diff --git a/src/MusicAnnouncementsMod.cs b/src/MusicAnnouncementsMod.cs index ad7682d..7f06f84 100644 --- a/src/MusicAnnouncementsMod.cs +++ b/src/MusicAnnouncementsMod.cs @@ -1,5 +1,6 @@ using BepInEx; using Music; +using System.Diagnostics; using System.Security.Permissions; using System.Text.RegularExpressions; using UnityEngine; @@ -50,6 +51,11 @@ private void RainWorld_OnModsInitHK(On.RainWorld.orig_OnModsInit orig, RainWorld private void SongHK(On.Music.Song.orig_ctor orig, Song self, MusicPlayer musicPlayer, string name, MusicPlayer.MusicContext context) { orig(self, musicPlayer, name, context); + if (!MusicAnnouncementsConfig.ingameText.Value) // Gameplay announcement disabled + { + Debug.Log("(MusicAnnouncements) Skipping gameplay announcement due to config"); + return; + } if (context != MusicPlayer.MusicContext.StoryMode) // Ingame music only. { return; From bae3c3ba21c2247dd6a2f1bf903387e24ea25995 Mon Sep 17 00:00:00 2001 From: Shaun Beautement Date: Thu, 16 Feb 2023 16:53:04 +0200 Subject: [PATCH 2/8] Update src/MusicAnnouncementsConfig.cs Co-authored-by: SabreML <57483089+SabreML@users.noreply.github.com> --- src/MusicAnnouncementsConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MusicAnnouncementsConfig.cs b/src/MusicAnnouncementsConfig.cs index 781eb0a..5f16c95 100644 --- a/src/MusicAnnouncementsConfig.cs +++ b/src/MusicAnnouncementsConfig.cs @@ -65,7 +65,7 @@ private void AddTitle() }); } - private void AddCheckbox(Configurable optionText) + private void AddCheckbox(Configurable optionText, float y) { OpCheckBox checkbox = new OpCheckBox(optionText, new Vector2(150f, 500f)) { From 48df1c4727bc20bb082a144d93146e6b68ec9b37 Mon Sep 17 00:00:00 2001 From: Shaun Beautement Date: Thu, 16 Feb 2023 16:54:10 +0200 Subject: [PATCH 3/8] L70 use y argument Co-authored-by: SabreML <57483089+SabreML@users.noreply.github.com> --- src/MusicAnnouncementsConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MusicAnnouncementsConfig.cs b/src/MusicAnnouncementsConfig.cs index 5f16c95..7626ec6 100644 --- a/src/MusicAnnouncementsConfig.cs +++ b/src/MusicAnnouncementsConfig.cs @@ -67,7 +67,7 @@ private void AddTitle() private void AddCheckbox(Configurable optionText, float y) { - OpCheckBox checkbox = new OpCheckBox(optionText, new Vector2(150f, 500f)) + OpCheckBox checkbox = new OpCheckBox(optionText, new Vector2(150f, y)) { description = optionText.info.description }; From 133232c7ff6ae0dddf18ef1f7424fb8a49e25916 Mon Sep 17 00:00:00 2001 From: Shaun Beautement Date: Thu, 16 Feb 2023 16:55:02 +0200 Subject: [PATCH 4/8] remove wrong using statement Co-authored-by: SabreML <57483089+SabreML@users.noreply.github.com> --- src/MusicAnnouncementsMod.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/MusicAnnouncementsMod.cs b/src/MusicAnnouncementsMod.cs index 7f06f84..3b24371 100644 --- a/src/MusicAnnouncementsMod.cs +++ b/src/MusicAnnouncementsMod.cs @@ -1,6 +1,5 @@ using BepInEx; using Music; -using System.Diagnostics; using System.Security.Permissions; using System.Text.RegularExpressions; using UnityEngine; From aae1fcc7b889e29767a848651fcafd215b16f3f4 Mon Sep 17 00:00:00 2001 From: Shaun Beautement Date: Thu, 16 Feb 2023 16:55:25 +0200 Subject: [PATCH 5/8] L75 use y argument Co-authored-by: SabreML <57483089+SabreML@users.noreply.github.com> --- src/MusicAnnouncementsConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MusicAnnouncementsConfig.cs b/src/MusicAnnouncementsConfig.cs index 7626ec6..be6ff20 100644 --- a/src/MusicAnnouncementsConfig.cs +++ b/src/MusicAnnouncementsConfig.cs @@ -72,7 +72,7 @@ private void AddCheckbox(Configurable optionText, float y) description = optionText.info.description }; - OpLabel checkboxLabel = new OpLabel(150f + 40f, 500f + 2f, optionText.info.Tags[0] as string) + OpLabel checkboxLabel = new OpLabel(150f + 40f, y + 2f, optionText.info.Tags[0] as string) { description = optionText.info.description }; From 9c9864486db38e66632e5239bdf4371af7df0de1 Mon Sep 17 00:00:00 2001 From: Shaun Beautement Date: Thu, 16 Feb 2023 16:56:15 +0200 Subject: [PATCH 6/8] input y arguments Co-authored-by: SabreML <57483089+SabreML@users.noreply.github.com> --- src/MusicAnnouncementsConfig.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MusicAnnouncementsConfig.cs b/src/MusicAnnouncementsConfig.cs index be6ff20..99b45f4 100644 --- a/src/MusicAnnouncementsConfig.cs +++ b/src/MusicAnnouncementsConfig.cs @@ -32,8 +32,8 @@ public override void Initialize() AddDivider(593f); AddTitle(); AddDivider(540f); - AddCheckbox(pauseMenuText); - AddCheckbox(ingameText); + AddCheckbox(pauseMenuText, 500f); + AddCheckbox(ingameText, 460f); } private void AddDivider(float y) From b065c0385e475306cf41be3902944cb3e9daa9a9 Mon Sep 17 00:00:00 2001 From: Shaun Beautement Date: Thu, 16 Feb 2023 16:57:10 +0200 Subject: [PATCH 7/8] fix conditional response to music event Co-authored-by: SabreML <57483089+SabreML@users.noreply.github.com> --- src/MusicAnnouncementsMod.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/MusicAnnouncementsMod.cs b/src/MusicAnnouncementsMod.cs index 3b24371..ad7682d 100644 --- a/src/MusicAnnouncementsMod.cs +++ b/src/MusicAnnouncementsMod.cs @@ -50,11 +50,6 @@ private void RainWorld_OnModsInitHK(On.RainWorld.orig_OnModsInit orig, RainWorld private void SongHK(On.Music.Song.orig_ctor orig, Song self, MusicPlayer musicPlayer, string name, MusicPlayer.MusicContext context) { orig(self, musicPlayer, name, context); - if (!MusicAnnouncementsConfig.ingameText.Value) // Gameplay announcement disabled - { - Debug.Log("(MusicAnnouncements) Skipping gameplay announcement due to config"); - return; - } if (context != MusicPlayer.MusicContext.StoryMode) // Ingame music only. { return; From 5e5c53756c15105f38ae240ddd6b0bceb6674ebe Mon Sep 17 00:00:00 2001 From: Shaun Beautement Date: Thu, 16 Feb 2023 17:03:13 +0200 Subject: [PATCH 8/8] fix#2 for SongHK --- src/MusicAnnouncementsMod.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/MusicAnnouncementsMod.cs b/src/MusicAnnouncementsMod.cs index ad7682d..bcadf2b 100644 --- a/src/MusicAnnouncementsMod.cs +++ b/src/MusicAnnouncementsMod.cs @@ -65,7 +65,15 @@ private void SongHK(On.Music.Song.orig_ctor orig, Song self, MusicPlayer musicPl // The full `name` will be something like "RW_24 - Kayava". We only want to announce the part after the dash. songToAnnounce = Regex.Split(name, " - ")[1]; - announceAttempts = 500; // 500 attempts + + if (MusicAnnouncementsConfig.inGameText.Value) // Gameplay announcements are enabled. + { + announceAttempts = 500; // 500 attempts + } + else + { + Debug.Log("(MusicAnnouncements) Skipping gameplay announcement due to config"); + } } // Called when a song ends (or is otherwise deleted).