Skip to content

Commit

Permalink
Merge pull request #1 from SFBdragon/master
Browse files Browse the repository at this point in the history
Add option to disable popup announcements during gameplay.
  • Loading branch information
SabreML committed Feb 16, 2023
2 parents 820c034 + 5e5c537 commit 3a057a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
18 changes: 12 additions & 6 deletions src/MusicAnnouncementsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ namespace MusicAnnouncements
public class MusicAnnouncementsConfig : OptionInterface
{
public static Configurable<bool> pauseMenuText;
public static Configurable<bool> ingameText;

public MusicAnnouncementsConfig()
{
pauseMenuText = config.Bind("pauseMenuText", true, new ConfigurableInfo("Show the name of the currently playing song in the top right of the pause menu.", tags: new object[]
{
"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)
Expand All @@ -27,7 +32,8 @@ public override void Initialize()
AddDivider(593f);
AddTitle();
AddDivider(540f);
AddCheckbox();
AddCheckbox(pauseMenuText, 500f);
AddCheckbox(ingameText, 460f);
}

private void AddDivider(float y)
Expand Down Expand Up @@ -59,16 +65,16 @@ private void AddTitle()
});
}

private void AddCheckbox()
private void AddCheckbox(Configurable<bool> optionText, float y)
{
OpCheckBox checkbox = new OpCheckBox(pauseMenuText, new Vector2(150f, 500f))
OpCheckBox checkbox = new OpCheckBox(optionText, new Vector2(150f, y))
{
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, y + 2f, optionText.info.Tags[0] as string)
{
description = pauseMenuText.info.description
description = optionText.info.description
};

Tabs[0].AddItems(new UIelement[]
Expand Down
10 changes: 9 additions & 1 deletion src/MusicAnnouncementsMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit 3a057a0

Please sign in to comment.