diff --git a/MuzikaGromche/Plugin.cs b/MuzikaGromche/Plugin.cs index a1e968e..7f256b3 100644 --- a/MuzikaGromche/Plugin.cs +++ b/MuzikaGromche/Plugin.cs @@ -27,36 +27,42 @@ namespace MuzikaGromche new Track { Name = "MuzikaGromche", + Language = Language.RUSSIAN, WindUpTimer = 46.3f, Bpm = 130f, }, new Track { Name = "VseVZale", + Language = Language.RUSSIAN, WindUpTimer = 39f, Bpm = 138f, }, new Track { Name = "DeployDestroy", + Language = Language.RUSSIAN, WindUpTimer = 40.7f, Bpm = 130f, }, new Track { Name = "MoyaZhittya", + Language = Language.ENGLISH, WindUpTimer = 34.5f, Bpm = 120f, }, new Track { Name = "Gorgorod", + Language = Language.RUSSIAN, WindUpTimer = 43.2f, Bpm = 180f, }, new Track { Name = "Durochka", + Language = Language.RUSSIAN, WindUpTimer = 37f, Bpm = 130f, } @@ -168,11 +174,19 @@ namespace MuzikaGromche Logger.LogError("Could not load audio file"); } } + }; + + public record Language(string Short, string Full) + { + public static readonly Language ENGLISH = new("EN", "English"); + public static readonly Language RUSSIAN = new("RU", "Russian"); } public class Track { public string Name; + // Language of the track's lyrics. + public Language Language; // Wind-up time can and should be shorter than the Start audio track, // so that the "pop" effect can be baked into the Start audio and kept away // from the looped part. This also means that the light show starts before @@ -295,12 +309,42 @@ namespace MuzikaGromche public Config(ConfigFile configFile) : base(PluginInfo.PLUGIN_GUID) { var chanceRange = new AcceptableValueRange(0, 100); + var languageSectionButtonExists = new HashSet(); foreach (var track in Plugin.Tracks) { - string description = $"Random (relative) chance of selecting track {track.Name}. Set to zero to effectively disable the track."; + var language = track.Language; + string section = $"Tracks.{language.Short}"; + + // Create section toggle + if (!languageSectionButtonExists.Contains(language)) + { + languageSectionButtonExists.Add(language); + string buttonOptionName = $"Toggle all {language.Full} tracks"; + string buttonDescription = "Toggle all tracks in this section ON or OFF. Effective immediately."; + string buttonText = "Toggle"; + var button = new GenericButtonConfigItem(section, buttonOptionName, buttonDescription, buttonText, () => + { + if (CanModifyWeightsNow()) + { + var tracks = Plugin.Tracks.Where(t => t.Language.Equals(language)).ToList(); + var isOff = tracks.All(t => t.Weight.Value == 0); + var newWeight = isOff ? 50 : 0; + foreach (var t in tracks) + { + t.Weight.LocalValue = newWeight; + } + } + }); + button.ButtonOptions.CanModifyCallback = CanModifyWeightsNow; + LethalConfigManager.AddConfigItem(button); + } + + // Create slider entry for track + string name = $"[{language.Short}] {track.Name}"; + string description = $"Language: {language.Full}\n\nRandom (relative) chance of selecting this track.\n\nSet to zero to effectively disable the track."; track.Weight = configFile.BindSyncedEntry( - new ConfigDefinition("Tracks", track.Name), + new ConfigDefinition(section, track.Name), 50, new ConfigDescription(description, chanceRange, track));