Skip to content

Commit

Permalink
Better compatibility for mod music
Browse files Browse the repository at this point in the history
Excluding tracks starting with "BM_", rather than ones that don't contain " - ".
This doesn't make any difference if there's only vanilla/downpour music, but it should now allow modded tracks to get through.
  • Loading branch information
SabreML committed Dec 23, 2023
1 parent 049aa87 commit 9f16467
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
9 changes: 8 additions & 1 deletion MusicAnnouncements.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /Y "$(TargetPath)" "$(RainWorldSteam)\RainWorld_Data\StreamingAssets\mods\$(ProjectName)\plugins"</PostBuildEvent>
<PostBuildEvent>
IF "$(ConfigurationName)" == "Debug" (
copy /Y "$(TargetDir)" "$(RainWorldSteam)\RainWorld_Data\StreamingAssets\mods\$(ProjectName)\plugins"
) ELSE (
copy /Y "$(TargetPath)" "$(RainWorldSteam)\RainWorld_Data\StreamingAssets\mods\$(ProjectName)\plugins"
)
copy /Y "$(ProjectDir)\$(TargetName)\modinfo.json" "$(RainWorldSteam)\RainWorld_Data\StreamingAssets\mods\$(ProjectName)"
</PostBuildEvent>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion MusicAnnouncements/modinfo.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "sabreml.musicannouncements",
"name": "Music Announcements",
"version": "1.2.2",
"version": "1.2.3",
"target_game_version": "v1.9.07",
"authors": "SabreML",
"description": "Shows the name of the currently playing music track in-game.",
Expand Down
21 changes: 15 additions & 6 deletions src/MusicAnnouncementsMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace MusicAnnouncements
{
[BepInPlugin("sabreml.musicannouncements", "MusicAnnouncements", "1.2.2")]
[BepInPlugin("sabreml.musicannouncements", "MusicAnnouncements", "1.2.3")]
public class MusicAnnouncementsMod : BaseUnityPlugin
{
// The current mod version. (Stored here as a variable so that I don't have to update it in as many places.)
Expand Down Expand Up @@ -57,7 +57,7 @@ private void SongHK(On.Music.Song.orig_ctor orig, Song self, MusicPlayer musicPl
{
return;
}
if (!name.Contains(" - ")) // Probably background music. (E.g. 'BM_CC_CANOPY')
if (name.StartsWith("BM_")) // Background music. (E.g. 'BM_CC_CANOPY')
{
return;
}
Expand All @@ -66,19 +66,28 @@ private void SongHK(On.Music.Song.orig_ctor orig, Song self, MusicPlayer musicPl
return;
}

// The full `name` will be something like "RW_24 - Kayava". We want the part after the dash.
SongToAnnounce = Regex.Split(name, " - ")[1];
if (name.Contains(" - "))
{
// The full `name` will be something like "RW_24 - Kayava". We want the part after the dash.
SongToAnnounce = Regex.Split(name, " - ")[1];
}
else
{
// If it's not background music or regular music, then it might be something added by a mod.
// Just announce its full track name in this case.
SongToAnnounce = name;
}

// Arena mode announces the song name in the bottom left by itself already, so there's no need to do it here with `AnnounceAttempts`.
// (`SongToAnnounce` is still set though so that the pause menu text is shown.)
// (This is checked after `SongToAnnounce` is set so that the pause menu text still works.)
if (context == MusicPlayer.MusicContext.Arena)
{
return;
}

if (MusicAnnouncementsConfig.IngameText.Value) // Gameplay announcements are enabled.
{
AnnounceAttempts = 500; // 500 attempts
AnnounceAttempts = 500; // 500 frames worth of attempts
}
else // Gameplay announcements are disabled.
{
Expand Down

0 comments on commit 9f16467

Please sign in to comment.