1
0
Fork 0

Implement a better way to disable tracks while keeping them in JSON

This commit is contained in:
ivan tkachenko 2026-01-23 15:32:33 +02:00
parent f20a500992
commit 8942b2ee37
3 changed files with 13 additions and 2 deletions

View File

@ -54,6 +54,7 @@ namespace MuzikaGromche
{
var obj = new Dictionary<string, object?>
{
["Enabled"] = selectableTrack.Enabled,
["Name"] = audioTrack.Name, // may be different from selectableTrack.Name, if selectable track is a group
["Artist"] = selectableTrack.Artist,
["Song"] = selectableTrack.Song,

View File

@ -364,9 +364,9 @@ public static class Library
FlickerLightsTimeSeries = [-8, 31],
Lyrics = [],
},
#if DEBUG // No one knows it, and it's a bit out of place with a long 52 seconds intro
new SelectableAudioTrack
{
Enabled = false, // No one knows it, and it's a bit out of place with a long 52 seconds intro
Name = "Yalgaar",
Artist = "Ajey Nagar and Wily Frenzy",
Song = "Yalgaar",
@ -385,7 +385,6 @@ public static class Library
FlickerLightsTimeSeries = [-5],
Lyrics = [],
},
#endif
new SelectableAudioTrack
{
Name = "Chereshnya",

View File

@ -53,6 +53,7 @@ namespace MuzikaGromche
{
tracksEnumerable = tracksEnumerable.Where(track => !track.IsExplicit);
}
tracksEnumerable = tracksEnumerable.Where(track => track.Enabled);
var tracks = tracksEnumerable.ToArray();
return (tracks, season);
}
@ -324,6 +325,9 @@ namespace MuzikaGromche
// can be selected using weighted random from a list of selectable tracks.
public interface ISelectableTrack : ISeasonalContent
{
// Provide means to disable the track and hide it from user-facing config, while keeping it around in code and still exporting to JSON.
public bool Enabled { get; init; }
// Name of the track, as shown in config entry UI; also used for default file names.
public string Name { get; init; }
@ -575,6 +579,7 @@ namespace MuzikaGromche
// Standalone, top-level, selectable audio track
public class SelectableAudioTrack : CoreAudioTrack, ISelectableTrack
{
public bool Enabled { get; init; } = true;
public /* required */ string Artist { get; init; } = "";
public /* required */ string Song { get; init; } = "";
@ -595,6 +600,7 @@ namespace MuzikaGromche
public class SelectableTracksGroup : ISelectableTrack
{
public bool Enabled { get; init; } = true;
public /* required */ string Name { get; init; } = "";
public /* required */ string Artist { get; init; } = "";
@ -1614,6 +1620,11 @@ namespace MuzikaGromche
foreach (var track in Plugin.Tracks)
{
if (!track.Enabled)
{
// hide disabled tracks from user-facing config
continue;
}
var language = track.Language;
string section = $"Tracks.{language.Short}";