diff --git a/RedBookPlayer/Settings.cs b/RedBookPlayer/Settings.cs
index 0411c1d..8640e43 100644
--- a/RedBookPlayer/Settings.cs
+++ b/RedBookPlayer/Settings.cs
@@ -6,18 +6,55 @@ namespace RedBookPlayer
{
public class Settings
{
- string filePath;
+ ///
+ /// Indicates if discs should start playing on load
+ ///
+ public bool AutoPlay { get; set; } = false;
+
+ ///
+ /// Indicates if an index change can trigger a track change
+ ///
+ public bool IndexButtonChangeTrack { get; set; } = false;
+
+ ///
+ /// Indicates if the index 0 of track 1 is treated like a hidden track
+ ///
+ public bool AllowSkipHiddenTrack { get; set; } = false;
+
+ ///
+ /// Indicates if data tracks should be played like old, non-compliant players
+ ///
+ public bool PlayDataTracks { get; set; } = false;
+
+ ///
+ /// Generate a TOC if the disc is missing one
+ ///
+ public bool GenerateMissingTOC { get; set; } = true;
+
+ ///
+ /// Indicates the default playback volume
+ ///
+ public int Volume { get; set; } = 100;
+
+ ///
+ /// Indicates the currently selected theme
+ ///
+ public string SelectedTheme { get; set; } = "default";
+
+ ///
+ /// Path to the settings file
+ ///
+ private string _filePath;
public Settings() {}
- public Settings(string filePath) => this.filePath = filePath;
-
- public bool AutoPlay { get; set; }
- public bool IndexButtonChangeTrack { get; set; }
- public bool AllowSkipHiddenTrack { get; set; }
- public int Volume { get; set; } = 100;
- public string SelectedTheme { get; set; } = "default";
+ public Settings(string filePath) => _filePath = filePath;
+ ///
+ /// Load settings from a file
+ ///
+ /// Path to the settings JSON file
+ /// Settings derived from the input file, if possible
public static Settings Load(string filePath)
{
if(File.Exists(filePath))
@@ -25,7 +62,7 @@ namespace RedBookPlayer
try
{
Settings settings = JsonSerializer.Deserialize(File.ReadAllText(filePath));
- settings.filePath = filePath;
+ settings._filePath = filePath;
MainWindow.ApplyTheme(settings.SelectedTheme);
@@ -42,6 +79,9 @@ namespace RedBookPlayer
return new Settings(filePath);
}
+ ///
+ /// Save settings to a file
+ ///
public void Save()
{
var options = new JsonSerializerOptions
@@ -50,7 +90,7 @@ namespace RedBookPlayer
};
string json = JsonSerializer.Serialize(this, options);
- File.WriteAllText(filePath, json);
+ File.WriteAllText(_filePath, json);
}
}
}
\ No newline at end of file
diff --git a/RedBookPlayer/SettingsWindow.xaml b/RedBookPlayer/SettingsWindow.xaml
index 0760065..3f2ce4c 100644
--- a/RedBookPlayer/SettingsWindow.xaml
+++ b/RedBookPlayer/SettingsWindow.xaml
@@ -17,6 +17,14 @@
Treat index 0 of track 1 as track 0 (hidden track)
+
+
+ Play data tracks like old, non-compliant players
+
+
+
+ Generate a TOC if the disc is missing one
+
Volume
diff --git a/RedBookPlayer/SettingsWindow.xaml.cs b/RedBookPlayer/SettingsWindow.xaml.cs
index 4873089..abc880f 100644
--- a/RedBookPlayer/SettingsWindow.xaml.cs
+++ b/RedBookPlayer/SettingsWindow.xaml.cs
@@ -8,49 +8,47 @@ namespace RedBookPlayer
{
public class SettingsWindow : Window
{
- readonly Settings settings;
- string selectedTheme;
- ListBox themeList;
+ private readonly Settings _settings;
+ private string _selectedTheme;
+ private ListBox _themeList;
public SettingsWindow() {}
public SettingsWindow(Settings settings)
{
- DataContext = this.settings = settings;
+ DataContext = _settings = settings;
InitializeComponent();
}
public void ThemeList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
- if(e.AddedItems.Count == 0)
- {
+ if (e.AddedItems.Count == 0)
return;
- }
- selectedTheme = (string)e.AddedItems[0];
+ _selectedTheme = (string)e.AddedItems[0];
}
public void ApplySettings(object sender, RoutedEventArgs e)
{
- if((selectedTheme ?? "") != "")
+ if (!string.IsNullOrWhiteSpace(_selectedTheme))
{
- settings.SelectedTheme = selectedTheme;
- MainWindow.ApplyTheme(selectedTheme);
+ _settings.SelectedTheme = _selectedTheme;
+ MainWindow.ApplyTheme(_selectedTheme);
}
- PlayerView.Player.Volume = settings.Volume;
+ PlayerView.Player.Volume = _settings.Volume;
- settings.Save();
+ _settings.Save();
}
- public void UpdateView() => this.FindControl("VolumeLabel").Text = settings.Volume.ToString();
+ public void UpdateView() => this.FindControl("VolumeLabel").Text = _settings.Volume.ToString();
void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
- themeList = this.FindControl("ThemeList");
- themeList.SelectionChanged += ThemeList_SelectionChanged;
+ _themeList = this.FindControl("ThemeList");
+ _themeList.SelectionChanged += ThemeList_SelectionChanged;
List items = new List();
items.Add("default");
@@ -61,16 +59,14 @@ namespace RedBookPlayer
{
string themeName = dir.Split('/')[1];
- if(!File.Exists($"themes/{themeName}/view.xaml"))
- {
+ if (!File.Exists($"themes/{themeName}/view.xaml"))
continue;
- }
items.Add(themeName);
}
}
- themeList.Items = items;
+ _themeList.Items = items;
this.FindControl