diff --git a/docs/changelog.md b/docs/changelog.md index 58ba912..eb68070 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,7 +1,11 @@ # v7.0.0.3 Beta (2023-??-??) +- mpv.net can no longer be downloaded from the Microsoft store due + to a general very poor experience with the package creation and submission. + This means winget download support is unavailable until a new winget solution is implemented. - New menu item added at Settings/Setup to add mpv.net to the path environment variable. +- Improved conf file reader/writer. # v7.0.0.2 Beta (2023-12-13) diff --git a/src/MpvNet.Windows/.editorconfig b/src/MpvNet.Windows/.editorconfig index 2c285fe..768e2dc 100644 --- a/src/MpvNet.Windows/.editorconfig +++ b/src/MpvNet.Windows/.editorconfig @@ -23,3 +23,6 @@ dotnet_diagnostic.IDE0044.severity = silent # Member does not access instance data and can be marked as static dotnet_diagnostic.CA1822.severity = none + +# IDE0057: Use range operator +csharp_style_prefer_range_operator = false diff --git a/src/MpvNet.Windows/WPF/ConfWindow.xaml.cs b/src/MpvNet.Windows/WPF/ConfWindow.xaml.cs index 7be26f7..9e0c136 100644 --- a/src/MpvNet.Windows/WPF/ConfWindow.xaml.cs +++ b/src/MpvNet.Windows/WPF/ConfWindow.xaml.cs @@ -3,6 +3,7 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.Runtime.CompilerServices; using System.Text; +using System.Text.RegularExpressions; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -131,7 +132,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged { if (setting.Name == confItem.Name && confItem.Section == "" && !confItem.IsSectionItem) { - setting.Value = confItem.Value.Trim('\'', '"'); + setting.Value = confItem.Value; setting.StartValue = setting.Value; setting.ConfItem = confItem; confItem.SettingBase = setting; @@ -221,14 +222,10 @@ public partial class ConfWindow : Window, INotifyPropertyChanged string line = currentLine.Trim(); if (line == "") - { comment += "\r\n"; - } else if (line.StartsWith("#")) - { comment += line.Trim() + "\r\n"; - } - else if (line.StartsWith("[") && line.Contains("]")) + else if (line.StartsWith("[") && line.Contains(']')) { if (!isSectionItem && comment != "" && comment != "\r\n") ConfItems.Add(new ConfItem() { @@ -238,8 +235,11 @@ public partial class ConfWindow : Window, INotifyPropertyChanged comment = ""; isSectionItem = true; } - else if (line.Contains("=")) + else if (line.Contains('=') || Regex.Match(line, "^[\\w-]+$").Success) { + if (!line.Contains('=')) + line += "=yes"; + ConfItem item = new ConfItem(); item.File = Path.GetFileNameWithoutExtension(file); item.IsSectionItem = isSectionItem; @@ -248,15 +248,21 @@ public partial class ConfWindow : Window, INotifyPropertyChanged item.Section = section; section = ""; - if (line.Contains("#") && !line.Contains("'") && !line.Contains("\"")) + if (line.Contains('#') && !line.Contains("'") && !line.Contains("\"")) { item.LineComment = line.Substring(line.IndexOf("#")).Trim(); line = line.Substring(0, line.IndexOf("#")).Trim(); } int pos = line.IndexOf("="); - string left = line.Substring(0, pos).Trim().ToLower(); + string left = line.Substring(0, pos).Trim().ToLower().TrimStart('-'); string right = line.Substring(pos + 1).Trim(); + + if (right.StartsWith('\'') && right.EndsWith('\'')) + right = right.Trim('\''); + + if (right.StartsWith('"') && right.EndsWith('"')) + right = right.Trim('"'); if (left == "fs") left = "fullscreen"; @@ -271,6 +277,23 @@ public partial class ConfWindow : Window, INotifyPropertyChanged } } + string EscapeValue(string value) + { + if (value.Contains('\'')) + return '"' + value + '"'; + + if (value.Contains('"')) + return '\'' + value + '\''; + + if (value.Contains('"') || value.Contains('#') || value.StartsWith("%") || + value.StartsWith(" ") || value.EndsWith(" ")) + { + return '\'' + value + '\''; + } + + return value; + } + string GetContent(string filename) { StringBuilder sb = new StringBuilder(); @@ -288,7 +311,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged { if (item.Name != "") { - sb.Append(item.Name + " = " + item.Value); + sb.Append(item.Name + " = " + EscapeValue(item.Value)); if (item.LineComment != "") sb.Append(" " + item.LineComment); @@ -299,17 +322,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged } else if ((item.SettingBase.Value ?? "") != item.SettingBase.Default) { - string? value; - - if (item.SettingBase.Type == "string" || - item.SettingBase.Type == "folder" || - item.SettingBase.Type == "color") - - value = "'" + item.SettingBase.Value + "'"; - else - value = item.SettingBase.Value; - - sb.Append(item.Name + " = " + value); + sb.Append(item.Name + " = " + EscapeValue(item.SettingBase.Value!)); if (item.LineComment != "") sb.Append(" " + item.LineComment); @@ -325,19 +338,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged continue; if ((setting.Value ?? "") != setting.Default) - { - string? value; - - if (setting.Type == "string" || - setting.Type == "folder" || - setting.Type == "color") - - value = "'" + setting.Value + "'"; - else - value = setting.Value; - - sb.AppendLine(setting.Name + " = " + value); - } + sb.AppendLine(setting.Name + " = " + EscapeValue(setting.Value!)); } foreach (ConfItem item in ConfItems) @@ -356,7 +357,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged if (item.Comment != "") sb.Append(item.Comment); - sb.Append(item.Name + " = " + item.Value); + sb.Append(item.Name + " = " + EscapeValue(item.Value)); if (item.LineComment != "") sb.Append(" " + item.LineComment); diff --git a/src/MpvNet/Player.cs b/src/MpvNet/Player.cs index 1d4e83b..c13d948 100644 --- a/src/MpvNet/Player.cs +++ b/src/MpvNet/Player.cs @@ -268,38 +268,47 @@ public class MainPlayer : MpvClient Dictionary? _Conf; public Dictionary Conf { - get { - if (_Conf == null) + get + { + if (_Conf != null) + return _Conf; + + App.ApplyInputDefaultBindingsFix(); + + _Conf = new Dictionary(); + + if (File.Exists(ConfPath)) { - App.ApplyInputDefaultBindingsFix(); - - _Conf = new Dictionary(); - - if (File.Exists(ConfPath)) + foreach (string? it in File.ReadAllLines(ConfPath)) { - foreach (string? it in File.ReadAllLines(ConfPath)) + string line = it.TrimStart(' ', '-').TrimEnd(); + + if (line.StartsWith("#")) + continue; + + if (!line.Contains('=')) { - string line = it.TrimStart(' ', '-').TrimEnd(); - - if (!line.Contains('=') || line.StartsWith("#")) + if (Regex.Match(line, "^[\\w-]+$").Success) + line += "=yes"; + else continue; - - string key = line[..line.IndexOf("=")].Trim(); - string value = line[(line.IndexOf("=") + 1)..].Trim(); - - if (value.Contains('#') && !value.StartsWith("#") && - !value.StartsWith("'#") && !value.StartsWith("\"#")) - - value = value[..value.IndexOf("#")].Trim(); - - _Conf[key] = value; } - } - foreach (var i in _Conf) - ProcessProperty(i.Key, i.Value); + string key = line[..line.IndexOf("=")].Trim(); + string value = line[(line.IndexOf("=") + 1)..].Trim(); + + if (value.Contains('#') && !value.StartsWith("#") && + !value.StartsWith("'#") && !value.StartsWith("\"#")) + + value = value[..value.IndexOf("#")].Trim(); + + _Conf[key] = value; + } } + foreach (var i in _Conf) + ProcessProperty(i.Key, i.Value); + return _Conf; } } diff --git a/src/Setup/MSIX/Images/LockScreenLogo.scale-200.png b/src/Setup/MSIX/Images/LockScreenLogo.scale-200.png deleted file mode 100644 index 16f7037..0000000 Binary files a/src/Setup/MSIX/Images/LockScreenLogo.scale-200.png and /dev/null differ diff --git a/src/Setup/MSIX/Images/SplashScreen.scale-200.png b/src/Setup/MSIX/Images/SplashScreen.scale-200.png deleted file mode 100644 index 47d37e1..0000000 Binary files a/src/Setup/MSIX/Images/SplashScreen.scale-200.png and /dev/null differ diff --git a/src/Setup/MSIX/Images/Square150x150Logo.scale-200.png b/src/Setup/MSIX/Images/Square150x150Logo.scale-200.png deleted file mode 100644 index 6ddf941..0000000 Binary files a/src/Setup/MSIX/Images/Square150x150Logo.scale-200.png and /dev/null differ diff --git a/src/Setup/MSIX/Images/Square44x44Logo.scale-200.png b/src/Setup/MSIX/Images/Square44x44Logo.scale-200.png deleted file mode 100644 index 65cf8f3..0000000 Binary files a/src/Setup/MSIX/Images/Square44x44Logo.scale-200.png and /dev/null differ diff --git a/src/Setup/MSIX/Images/Square44x44Logo.targetsize-24_altform-unplated.png b/src/Setup/MSIX/Images/Square44x44Logo.targetsize-24_altform-unplated.png deleted file mode 100644 index 4febf14..0000000 Binary files a/src/Setup/MSIX/Images/Square44x44Logo.targetsize-24_altform-unplated.png and /dev/null differ diff --git a/src/Setup/MSIX/Images/StoreLogo.png b/src/Setup/MSIX/Images/StoreLogo.png deleted file mode 100644 index e5073ed..0000000 Binary files a/src/Setup/MSIX/Images/StoreLogo.png and /dev/null differ diff --git a/src/Setup/MSIX/Images/Wide310x150Logo.scale-200.png b/src/Setup/MSIX/Images/Wide310x150Logo.scale-200.png deleted file mode 100644 index b9dec64..0000000 Binary files a/src/Setup/MSIX/Images/Wide310x150Logo.scale-200.png and /dev/null differ diff --git a/src/Setup/MSIX/MSIX.wapproj b/src/Setup/MSIX/MSIX.wapproj deleted file mode 100644 index 1f08ac6..0000000 --- a/src/Setup/MSIX/MSIX.wapproj +++ /dev/null @@ -1,73 +0,0 @@ - - - - 15.0 - - - - Debug - x64 - - - Release - x64 - - - - $(MSBuildExtensionsPath)\Microsoft\DesktopBridge\ - - - - 81daee3a-76ff-4494-9384-d28a651d70bb - 10.0.22000.0 - 10.0.14393.0 - en-US - false - False - False - True - x64 - True - 0 - ..\MpvNet.Windows\MpvNet.Windows.csproj - - - Always - - - Always - - - - Designer - - - - - libmpv-2.dll - PreserveNewest - - - MediaInfo.dll - PreserveNewest - - - mpvnet.com - PreserveNewest - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Setup/MSIX/Package.appxmanifest b/src/Setup/MSIX/Package.appxmanifest deleted file mode 100644 index c7c3f4c..0000000 --- a/src/Setup/MSIX/Package.appxmanifest +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - mpv.net - Frank Skare - Images\StoreLogo.png - - - - - - - - - - - - - - - - - - - - - - - - - - - - - .264 - .265 - .asf - .avc - .avi - .avs - .dav - .flv - .h264 - .h265 - .hevc - .m2t - .m2ts - .m2v - .m4v - .mkv - .mov - .mp4 - .mpeg - .mpg - .mpv - .mts - .ts - .vob - .vpy - .webm - .wmv - .y4m - - - - - - - - .aac - .ac3 - .dts - .dtshd - .dtshr - .dtsma - .eac3 - .flac - .m4a - .mka - .mp2 - .mp3 - .mpa - .mpc - .ogg - .opus - .thd - .w64 - .wav - - - - - - - - - - - - - - - - - - - - - - - - - - - - -