From b23542d6810bc53ad987c6ef72ae5aab3173a276 Mon Sep 17 00:00:00 2001 From: stax76 Date: Fri, 15 Dec 2023 08:35:01 +0100 Subject: [PATCH] Conf editor crash fixed --- docs/changelog.md | 5 +- src/MpvNet.Windows/.editorconfig | 3 + src/MpvNet.Windows/Conf.cs | 3 + src/MpvNet.Windows/Resources/editor_conf.txt | 273 ++++++++++-------- src/MpvNet.Windows/WPF/ConfWindow.xaml.cs | 78 ++++- .../WPF/Controls/HyperlinkEx.cs | 3 +- .../WPF/Controls/SearchControl.xaml.cs | 2 +- 7 files changed, 231 insertions(+), 136 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 4a9bb26..12861bb 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,15 +1,18 @@ # v7.0.0.3 Beta (2023-??-??) +- New conf editor option `Video/libplacebo/preset`. +- New conf editor option `Video/libplacebo/Scaling/upscaler`. - New menu item `Settings/Setup/Add mpv.net to Path environment variable' added. - New menu item `Settings/Edit mpv.conf` added for opening mpv.conf with a text editor. Default binding `c`. - New menu item `Settings/Edit input.conf` added for opening input.conf with a text editor. Default binding `k`. - 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. + I've submitted mpv.net to the winget package repository, it's not yet processed. - Improved conf file reader/writer. - Conf editor support added for the mpv options: `reset-on-next-file`, `input-ipc-server`, `background`, `title` +- Conf editor crash fixed. - When mpv.net is started for the first time from a new startup location, it asks if mpv.net should be added to the Path environment variable. # v7.0.0.2 Beta (2023-12-13) diff --git a/src/MpvNet.Windows/.editorconfig b/src/MpvNet.Windows/.editorconfig index 4d27587..0e5f83e 100644 --- a/src/MpvNet.Windows/.editorconfig +++ b/src/MpvNet.Windows/.editorconfig @@ -29,3 +29,6 @@ csharp_style_prefer_range_operator = false # CA1401: P/Invokes should not be visible dotnet_diagnostic.CA1401.severity = none + +# IDE0017: Simplify object initialization +dotnet_style_object_initializer = false diff --git a/src/MpvNet.Windows/Conf.cs b/src/MpvNet.Windows/Conf.cs index 844c1b4..27ccd73 100644 --- a/src/MpvNet.Windows/Conf.cs +++ b/src/MpvNet.Windows/Conf.cs @@ -90,6 +90,9 @@ public class ConfParser { string line = it.Trim(); + if (line.StartsWith('#')) + continue; + if (line == "") { currentGroup = new ConfSection(); diff --git a/src/MpvNet.Windows/Resources/editor_conf.txt b/src/MpvNet.Windows/Resources/editor_conf.txt index f280200..12db7ce 100644 --- a/src/MpvNet.Windows/Resources/editor_conf.txt +++ b/src/MpvNet.Windows/Resources/editor_conf.txt @@ -42,7 +42,6 @@ help = Image file extensions used to create file associations and used by the au name = menu-syntax file = mpvnet directory = General -default = #menu: help = Used menu syntax for defining the context menu in input.conf.\nmpv.net by default uses '#menu:', uosc uses '#!' by default. name = debug-mode @@ -119,10 +118,57 @@ option = display-adrop option = display-desync option = desync -name = dither-depth +name = d3d11va-zero-copy file = mpv default = no directory = Video +help = By default, when using hardware decoding with --gpu-api=d3d11, the video image will be copied (GPU-to-GPU) from the decoder surface to a shader resource. Set this option to avoid that copy by sampling directly from the decoder image. This may increase performance and reduce power usage, but can cause the image to be sampled incorrectly on the bottom and right edges due to padding, and may invoke driver bugs, since Direct3D 11 technically does not allow sampling from a decoder surface (though most drivers support it.) +option = yes +option = no + +name = scale +file = mpv +default = bilinear +directory = Video/Render Options +help = The GPU renderer filter function to use when upscaling video. There are some more filters, but most are not as useful. For a complete list, pass help as value, e.g.: mpv --scale=help +option = bilinear Bilinear hardware texture filtering (fastest, very low quality). +option = spline36 Mid quality and speed. This is the default when using gpu-hq. +option = lanczos Lanczos scaling. Provides mid quality and speed. Generally worse than spline36, but it results in a slightly sharper image which is good for some content types. The number of taps can be controlled with scale-radius, but is best left unchanged. (This filter is an alias for sinc-windowed sinc) +option = ewa_lanczos Elliptic weighted average Lanczos scaling. Also known as Jinc. Relatively slow, but very good quality. The radius can be controlled with scale-radius. Increasing the radius makes the filter sharper but adds more ringing. (This filter is an alias for jinc-windowed jinc) +option = ewa_lanczossharp A slightly sharpened version of ewa_lanczos, preconfigured to use an ideal radius and parameter. If your hardware can run it, this is probably what you should use by default. +option = mitchell Mitchell-Netravali. The B and C parameters can be set with scale-param1 and scale-param2. This filter is very good at downscaling (see dscale). +option = oversample A version of nearest neighbour that (naively) oversamples pixels, so that pixels overlapping edges get linearly interpolated instead of rounded. This essentially removes the small imperfections and judder artifacts caused by nearest-neighbour interpolation, in exchange for adding some blur. This filter is good at temporal interpolation, and also known as "smoothmotion" (see tscale). + +name = cscale +file = mpv +default = bilinear +directory = Video/Render Options +help = As scale, but for interpolating chroma information. If the image is not subsampled, this option is ignored entirely. +option = bilinear Bilinear hardware texture filtering (fastest, very low quality). +option = spline36 Mid quality and speed. This is the default when using gpu-hq. +option = lanczos Lanczos scaling. Provides mid quality and speed. Generally worse than spline36, but it results in a slightly sharper image which is good for some content types. The number of taps can be controlled with scale-radius, but is best left unchanged. (This filter is an alias for sinc-windowed sinc) +option = ewa_lanczos Elliptic weighted average Lanczos scaling. Also known as Jinc. Relatively slow, but very good quality. The radius can be controlled with scale-radius. Increasing the radius makes the filter sharper but adds more ringing. (This filter is an alias for jinc-windowed jinc) +option = ewa_lanczossharp A slightly sharpened version of ewa_lanczos, preconfigured to use an ideal radius and parameter. If your hardware can run it, this is probably what you should use by default. +option = mitchell Mitchell-Netravali. The B and C parameters can be set with scale-param1 and scale-param2. This filter is very good at downscaling (see dscale). +option = oversample A version of nearest neighbour that (naively) oversamples pixels, so that pixels overlapping edges get linearly interpolated instead of rounded. This essentially removes the small imperfections and judder artifacts caused by nearest-neighbour interpolation, in exchange for adding some blur. This filter is good at temporal interpolation, and also known as "smoothmotion" (see tscale). + +name = dscale +file = mpv +default = +directory = Video/Render Options +help = Like scale, but apply these filters on downscaling instead. \nIf no option is selected, it will keep the same with the upscaler. +option = bilinear Bilinear hardware texture filtering (fastest, very low quality). +option = spline36 Mid quality and speed. This is the default when using gpu-hq. +option = lanczos Lanczos scaling. Provides mid quality and speed. Generally worse than spline36, but it results in a slightly sharper image which is good for some content types. The number of taps can be controlled with scale-radius, but is best left unchanged. (This filter is an alias for sinc-windowed sinc) +option = ewa_lanczos Elliptic weighted average Lanczos scaling. Also known as Jinc. Relatively slow, but very good quality. The radius can be controlled with scale-radius. Increasing the radius makes the filter sharper but adds more ringing. (This filter is an alias for jinc-windowed jinc) +option = ewa_lanczossharp A slightly sharpened version of ewa_lanczos, preconfigured to use an ideal radius and parameter. If your hardware can run it, this is probably what you should use by default. +option = mitchell Mitchell-Netravali. The B and C parameters can be set with scale-param1 and scale-param2. This filter is very good at downscaling (see dscale). +option = oversample A version of nearest neighbour that (naively) oversamples pixels, so that pixels overlapping edges get linearly interpolated instead of rounded. This essentially removes the small imperfections and judder artifacts caused by nearest-neighbour interpolation, in exchange for adding some blur. This filter is good at temporal interpolation, and also known as "smoothmotion" (see tscale). + +name = dither-depth +file = mpv +default = no +directory = Video/Render Options help = Set dither target depth to N. Note that the depth of the connected video display device cannot be detected. Often, LCD panels will do dithering on their own, which conflicts with this option and leads to ugly output. option = no Disable any dithering done by mpv. option = auto Automatic selection. If output bit depth cannot be detected, 8 bits per component are assumed. @@ -132,7 +178,7 @@ option = 10 Dither to 10 bit output. name = correct-downscaling file = mpv default = no -directory = Video +directory = Video/Render Options help = When using convolution based filters, extend the filter size when downscaling. Increases quality, but reduces performance while downscaling.\n\nThis will perform slightly sub-optimally for anamorphic video (but still better than without it) since it will extend the size to match only the milder of the scale factors between the axes. option = yes option = no @@ -140,7 +186,7 @@ option = no name = sigmoid-upscaling file = mpv default = no -directory = Video +directory = Video/Render Options help = When upscaling, use a sigmoidal color transform to avoid emphasizing ringing artifacts. This also implies linear-scaling. option = yes option = no @@ -148,23 +194,15 @@ option = no name = deband file = mpv default = no -directory = Video +directory = Video/Render Options help = Enable the debanding algorithm. This greatly reduces the amount of visible banding, blocking and other quantization artifacts, at the expense of very slightly blurring some of the finest details. In practice, it's virtually always an improvement - the only reason to disable it would be for performance. option = yes option = no -name = d3d11va-zero-copy -file = mpv -default = no -directory = Video -help = By default, when using hardware decoding with --gpu-api=d3d11, the video image will be copied (GPU-to-GPU) from the decoder surface to a shader resource. Set this option to avoid that copy by sampling directly from the decoder image. This may increase performance and reduce power usage, but can cause the image to be sampled incorrectly on the bottom and right edges due to padding, and may invoke driver bugs, since Direct3D 11 technically does not allow sampling from a decoder surface (though most drivers support it.) -option = yes -option = no - name = hdr-compute-peak file = mpv default = auto -directory = Video +directory = Video/Render Options help = Compute the HDR peak and frame average brightness per-frame instead of relying on tagged metadata. These values are averaged over local regions as well as over several frames to prevent the value from jittering around too much. This option basically gives you dynamic, per-scene tone mapping. Requires compute shaders, which is a fairly recent OpenGL feature, and will probably also perform horribly on some drivers, so enable at your own risk. The special value auto (default) will enable HDR peak computation automatically if compute shaders and SSBOs are supported. option = auto option = yes @@ -173,11 +211,111 @@ option = no name = allow-delayed-peak-detect file = mpv default = yes -directory = Video +directory = Video/Render Options help = When using --hdr-compute-peak, allow delaying the detected peak by a frame when beneficial for performance. In particular, this is required to avoid an unnecessary FBO indirection when no advanced rendering is required otherwise. Has no effect if there already is an indirect pass, such as when advanced scaling is enabled. (Only affects --vo=gpu-next, note that --vo=gpu always delays the peak.) option = yes option = no +name = background +file = mpv +directory = Video/Render Options +help = Color used to draw parts of the mpv window not covered by video. See the --sub-color option for how colors are defined. + +name = libplacebo-opts +file = mpv +directory = Video/Render Options +help = Passes extra raw option to the libplacebo rendering backend (used by --vo=gpu-next). May override the effects of any other options set using the normal options system. + +name = preset +file = libplacebo +directory = Video/libplacebo +default = default +help = Override all libplacebo options by the values from the given preset. +url = https://libplacebo.org/options/#presetdefaultfasthigh_quality +option = default Default settings, tuned to provide a balance of performance and quality. +option = fast Disable all advanced rendering, equivalent to passing no to every option. +option = high_quality Reset all everything to high quality presets (where available). + +name = upscaler +file = libplacebo +directory = Video/libplacebo/Scaling +default = default +help = Sets the filter used for upscaling. Defaults to lanczos. +url = https://libplacebo.org/options/#upscalerfilter +option = default Default. +option = none No filter, only use basic GPU texture sampling. +option = nearest Nearest-neighbour (box) sampling (very fast). +option = bilinear Bilinear sampling (very fast). +option = oversample Aspect-ratio preserving nearest neighbour sampling (very fast). +option = bicubic Bicubic interpolation (fast). +option = gaussian Gaussian smoothing (fast). +option = catmull_rom Catmull-Rom cubic spline. +option = lanczos Lanczos reconstruction. +option = ewa_lanczos EWA Lanczos ("Jinc") reconstruction (slow). +option = ewa_lanczossharp Sharpened version of ewa_lanczos (slow). +option = ewa_lanczos4sharpest Very sharp version of ewa_lanczos, with anti-ringing (very slow). + +name = screenshot-directory +file = mpv +width = 500 +type = folder +directory = Video/Screenshot +help = Store screenshots in this directory. This path is joined with the filename generated by screenshot-template. If the template filename is already absolute, the directory is ignored.\n\nIf the directory does not exist, it is created on the first screenshot. If it is not a directory, an error is generated when trying to write a screenshot. + +name = screenshot-format +file = mpv +default = jpg +directory = Video/Screenshot +help = Set the image file type used for saving screenshots. +option = jpg +option = png + +name = screenshot-tag-colorspace +file = mpv +default = no +directory = Video/Screenshot +help = Tag screenshots with the appropriate colorspace. Note that not all formats are supported. +option = yes +option = no + +name = screenshot-high-bit-depth +file = mpv +default = yes +directory = Video/Screenshot +help = If possible, write screenshots with a bit depth similar to the source video. This is interesting in particular for PNG, as this sometimes triggers writing 16 bit PNGs with huge file sizes. This will also include an unused alpha channel in the resulting files if 16 bit is used. +option = yes +option = no + +name = screenshot-jpeg-source-chroma +file = mpv +default = yes +directory = Video/Screenshot +help = Write JPEG files with the same chroma subsampling as the video. If disabled, the libjpeg default is used. +option = yes +option = no + +name = screenshot-template +file = mpv +directory = Video/Screenshot +type = string +help = Specify the filename template used to save screenshots. The template specifies the filename without file extension, and can contain format specifiers, which will be substituted when taking a screenshot. By default, the template is mpv-shot%n, which results in filenames like mpv-shot0012.png for example.\n\nFind the full documentation here: +url = https://mpv.io/manual/master/#options-screenshot-template + +name = screenshot-jpeg-quality +file = mpv +directory = Video/Screenshot +help = <0-100> Set the JPEG quality level. Higher means better quality. The default is 90. + +name = screenshot-png-compression +file = mpv +directory = Video/Screenshot +help = <0-9> Set the PNG compression level. Higher means better compression. This will affect the file size of the written screenshot file and the time it takes to write a screenshot. Too high compression might occupy enough CPU time to interrupt playback. The default is 7. + +name = screenshot-png-filter +file = mpv +directory = Video/Screenshot +help = <0-5> Set the filter applied prior to PNG compression. 0 is none, 1 is 'sub', 2 is 'up', 3 is 'average', 4 is 'Paeth', and 5 is 'mixed'. This affects the level of compression that can be achieved. For most images, 'mixed' achieves the best compression ratio, hence it is the default. + name = volume file = mpv directory = Audio @@ -535,111 +673,6 @@ directory = UI url = https://github.com/mpvnet-player/mpv.net/blob/main/docs/manual.md#color-theme help = Color theme used in light mode.\nmpv.net must be restarted after a change.\nmpv.net specific option. Default: light -name = screenshot-directory -file = mpv -width = 500 -type = folder -directory = Video/Screenshot -help = Store screenshots in this directory. This path is joined with the filename generated by screenshot-template. If the template filename is already absolute, the directory is ignored.\n\nIf the directory does not exist, it is created on the first screenshot. If it is not a directory, an error is generated when trying to write a screenshot. - -name = screenshot-format -file = mpv -default = jpg -directory = Video/Screenshot -help = Set the image file type used for saving screenshots. -option = jpg -option = png - -name = screenshot-tag-colorspace -file = mpv -default = no -directory = Video/Screenshot -help = Tag screenshots with the appropriate colorspace. Note that not all formats are supported. -option = yes -option = no - -name = screenshot-high-bit-depth -file = mpv -default = yes -directory = Video/Screenshot -help = If possible, write screenshots with a bit depth similar to the source video. This is interesting in particular for PNG, as this sometimes triggers writing 16 bit PNGs with huge file sizes. This will also include an unused alpha channel in the resulting files if 16 bit is used. -option = yes -option = no - -name = screenshot-jpeg-source-chroma -file = mpv -default = yes -directory = Video/Screenshot -help = Write JPEG files with the same chroma subsampling as the video. If disabled, the libjpeg default is used. -option = yes -option = no - -name = screenshot-template -file = mpv -directory = Video/Screenshot -type = string -help = Specify the filename template used to save screenshots. The template specifies the filename without file extension, and can contain format specifiers, which will be substituted when taking a screenshot. By default, the template is mpv-shot%n, which results in filenames like mpv-shot0012.png for example.\n\nFind the full documentation here: -url = https://mpv.io/manual/master/#options-screenshot-template - -name = screenshot-jpeg-quality -file = mpv -directory = Video/Screenshot -help = <0-100> Set the JPEG quality level. Higher means better quality. The default is 90. - -name = screenshot-png-compression -file = mpv -directory = Video/Screenshot -help = <0-9> Set the PNG compression level. Higher means better compression. This will affect the file size of the written screenshot file and the time it takes to write a screenshot. Too high compression might occupy enough CPU time to interrupt playback. The default is 7. - -name = screenshot-png-filter -file = mpv -directory = Video/Screenshot -help = <0-5> Set the filter applied prior to PNG compression. 0 is none, 1 is 'sub', 2 is 'up', 3 is 'average', 4 is 'Paeth', and 5 is 'mixed'. This affects the level of compression that can be achieved. For most images, 'mixed' achieves the best compression ratio, hence it is the default. - -name = scale -file = mpv -default = bilinear -directory = Render Options -help = The GPU renderer filter function to use when upscaling video. There are some more filters, but most are not as useful. For a complete list, pass help as value, e.g.: mpv --scale=help -option = bilinear Bilinear hardware texture filtering (fastest, very low quality). -option = spline36 Mid quality and speed. This is the default when using gpu-hq. -option = lanczos Lanczos scaling. Provides mid quality and speed. Generally worse than spline36, but it results in a slightly sharper image which is good for some content types. The number of taps can be controlled with scale-radius, but is best left unchanged. (This filter is an alias for sinc-windowed sinc) -option = ewa_lanczos Elliptic weighted average Lanczos scaling. Also known as Jinc. Relatively slow, but very good quality. The radius can be controlled with scale-radius. Increasing the radius makes the filter sharper but adds more ringing. (This filter is an alias for jinc-windowed jinc) -option = ewa_lanczossharp A slightly sharpened version of ewa_lanczos, preconfigured to use an ideal radius and parameter. If your hardware can run it, this is probably what you should use by default. -option = mitchell Mitchell-Netravali. The B and C parameters can be set with scale-param1 and scale-param2. This filter is very good at downscaling (see dscale). -option = oversample A version of nearest neighbour that (naively) oversamples pixels, so that pixels overlapping edges get linearly interpolated instead of rounded. This essentially removes the small imperfections and judder artifacts caused by nearest-neighbour interpolation, in exchange for adding some blur. This filter is good at temporal interpolation, and also known as "smoothmotion" (see tscale). - -name = cscale -file = mpv -default = bilinear -directory = Render Options -help = As scale, but for interpolating chroma information. If the image is not subsampled, this option is ignored entirely. -option = bilinear Bilinear hardware texture filtering (fastest, very low quality). -option = spline36 Mid quality and speed. This is the default when using gpu-hq. -option = lanczos Lanczos scaling. Provides mid quality and speed. Generally worse than spline36, but it results in a slightly sharper image which is good for some content types. The number of taps can be controlled with scale-radius, but is best left unchanged. (This filter is an alias for sinc-windowed sinc) -option = ewa_lanczos Elliptic weighted average Lanczos scaling. Also known as Jinc. Relatively slow, but very good quality. The radius can be controlled with scale-radius. Increasing the radius makes the filter sharper but adds more ringing. (This filter is an alias for jinc-windowed jinc) -option = ewa_lanczossharp A slightly sharpened version of ewa_lanczos, preconfigured to use an ideal radius and parameter. If your hardware can run it, this is probably what you should use by default. -option = mitchell Mitchell-Netravali. The B and C parameters can be set with scale-param1 and scale-param2. This filter is very good at downscaling (see dscale). -option = oversample A version of nearest neighbour that (naively) oversamples pixels, so that pixels overlapping edges get linearly interpolated instead of rounded. This essentially removes the small imperfections and judder artifacts caused by nearest-neighbour interpolation, in exchange for adding some blur. This filter is good at temporal interpolation, and also known as "smoothmotion" (see tscale). - -name = dscale -file = mpv -default = -directory = Render Options -help = Like scale, but apply these filters on downscaling instead. \nIf no option is selected, it will keep the same with the upscaler. -option = bilinear Bilinear hardware texture filtering (fastest, very low quality). -option = spline36 Mid quality and speed. This is the default when using gpu-hq. -option = lanczos Lanczos scaling. Provides mid quality and speed. Generally worse than spline36, but it results in a slightly sharper image which is good for some content types. The number of taps can be controlled with scale-radius, but is best left unchanged. (This filter is an alias for sinc-windowed sinc) -option = ewa_lanczos Elliptic weighted average Lanczos scaling. Also known as Jinc. Relatively slow, but very good quality. The radius can be controlled with scale-radius. Increasing the radius makes the filter sharper but adds more ringing. (This filter is an alias for jinc-windowed jinc) -option = ewa_lanczossharp A slightly sharpened version of ewa_lanczos, preconfigured to use an ideal radius and parameter. If your hardware can run it, this is probably what you should use by default. -option = mitchell Mitchell-Netravali. The B and C parameters can be set with scale-param1 and scale-param2. This filter is very good at downscaling (see dscale). -option = oversample A version of nearest neighbour that (naively) oversamples pixels, so that pixels overlapping edges get linearly interpolated instead of rounded. This essentially removes the small imperfections and judder artifacts caused by nearest-neighbour interpolation, in exchange for adding some blur. This filter is good at temporal interpolation, and also known as "smoothmotion" (see tscale). - -name = background -file = mpv -directory = Render Options -help = Color used to draw parts of the mpv window not covered by video. See the --sub-color option for how colors are defined. - name = cache file = mpv default = auto diff --git a/src/MpvNet.Windows/WPF/ConfWindow.xaml.cs b/src/MpvNet.Windows/WPF/ConfWindow.xaml.cs index 9e0c136..49111ef 100644 --- a/src/MpvNet.Windows/WPF/ConfWindow.xaml.cs +++ b/src/MpvNet.Windows/WPF/ConfWindow.xaml.cs @@ -35,6 +35,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged DataContext = this; LoadConf(Player.ConfPath); LoadConf(App.ConfPath); + LoadLibplaceboConf(); LoadSettings(); InitialContent = GetCompareString(); @@ -83,6 +84,9 @@ public partial class ConfWindow : Window, INotifyPropertyChanged public static TreeNode? AddNode(IList nodes, string path) { + if (string.IsNullOrEmpty(path)) + return null; + string[] parts = path.Split('/', StringSplitOptions.RemoveEmptyEntries); for (int x = 0; x < parts.Length; x++) @@ -128,14 +132,14 @@ public partial class ConfWindow : Window, INotifyPropertyChanged if (!FilterStrings.Contains(setting.Directory!)) FilterStrings.Add(setting.Directory!); - foreach (ConfItem confItem in ConfItems) + foreach (ConfItem item in ConfItems) { - if (setting.Name == confItem.Name && confItem.Section == "" && !confItem.IsSectionItem) + if (setting.Name == item.Name && item.Section == "" && !item.IsSectionItem) { - setting.Value = confItem.Value; + setting.Value = item.Value; setting.StartValue = setting.Value; - setting.ConfItem = confItem; - confItem.SettingBase = setting; + setting.ConfItem = item; + item.SettingBase = setting; } } @@ -161,6 +165,15 @@ public partial class ConfWindow : Window, INotifyPropertyChanged if (InitialContent == GetCompareString()) return; + foreach (Setting setting in Settings) + { + if (setting.Name == "libplacebo-opts") + { + setting.Value = GetKeyValueContent("libplacebo"); + break; + } + } + File.WriteAllText(Player.ConfPath, GetContent("mpv")); File.WriteAllText(App.ConfPath, GetContent("mpvnet")); @@ -202,10 +215,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged DispatcherPriority.Background); } - string GetCompareString() - { - return string.Join("", Settings.Select(item => item.Name + item.Value).ToArray()); - } + string GetCompareString() => string.Join("", Settings.Select(item => item.Name + item.Value).ToArray()); void LoadConf(string file) { @@ -229,7 +239,7 @@ public partial class ConfWindow : Window, INotifyPropertyChanged { if (!isSectionItem && comment != "" && comment != "\r\n") ConfItems.Add(new ConfItem() { - Comment = comment, File = Path.GetFileNameWithoutExtension(file)}); + Comment = comment, File = System.IO.Path.GetFileNameWithoutExtension(file)}); section = line.Substring(0, line.IndexOf("]") + 1); comment = ""; @@ -240,8 +250,8 @@ public partial class ConfWindow : Window, INotifyPropertyChanged if (!line.Contains('=')) line += "=yes"; - ConfItem item = new ConfItem(); - item.File = Path.GetFileNameWithoutExtension(file); + ConfItem item = new(); + item.File = System.IO.Path.GetFileNameWithoutExtension(file); item.IsSectionItem = isSectionItem; item.Comment = comment; comment = ""; @@ -277,6 +287,50 @@ public partial class ConfWindow : Window, INotifyPropertyChanged } } + string GetKeyValueContent(string filename) + { + List pairs = new(); + + foreach (Setting setting in Settings) + { + if (filename != setting.File) + continue; + + if ((setting.Value ?? "") != setting.Default) + pairs.Add(setting.Name + "=" + EscapeValue(setting.Value!)); + } + + return string.Join(',', pairs); + } + + void LoadLibplaceboConf() + { + foreach (ConfItem item in ConfItems.ToArray()) + if (item.Name == "libplacebo-opts") + LoadKeyValueList(item.Value, "libplacebo"); + } + + void LoadKeyValueList(string options, string file) + { + string[] optionStrings = options.Split(",", StringSplitOptions.RemoveEmptyEntries); + + foreach (string pair in optionStrings) + { + if (!pair.Contains('=')) + continue; + + int pos = pair.IndexOf("="); + string left = pair.Substring(0, pos).Trim().ToLower(); + string right = pair.Substring(pos + 1).Trim(); + + ConfItem item = new(); + item.Name = left; + item.Value = right; + item.File = file; + ConfItems.Add(item); + } + } + string EscapeValue(string value) { if (value.Contains('\'')) diff --git a/src/MpvNet.Windows/WPF/Controls/HyperlinkEx.cs b/src/MpvNet.Windows/WPF/Controls/HyperlinkEx.cs index 638d92b..0a11f9d 100644 --- a/src/MpvNet.Windows/WPF/Controls/HyperlinkEx.cs +++ b/src/MpvNet.Windows/WPF/Controls/HyperlinkEx.cs @@ -4,7 +4,6 @@ using System.Windows.Navigation; using MpvNet.Help; -// TODO: change namespace to MpvNet.Windows.WPF.Controls namespace MpvNet.Windows.WPF; public class HyperlinkEx : Hyperlink @@ -20,6 +19,6 @@ public class HyperlinkEx : Hyperlink NavigateUri = new Uri(url); RequestNavigate += HyperLinkEx_RequestNavigate; Inlines.Clear(); - Inlines.Add(url); + Inlines.Add("Manual"); } } diff --git a/src/MpvNet.Windows/WPF/Controls/SearchControl.xaml.cs b/src/MpvNet.Windows/WPF/Controls/SearchControl.xaml.cs index 024ba8a..68769c3 100644 --- a/src/MpvNet.Windows/WPF/Controls/SearchControl.xaml.cs +++ b/src/MpvNet.Windows/WPF/Controls/SearchControl.xaml.cs @@ -39,7 +39,7 @@ public partial class SearchControl : UserControl { HintTextBlock.Text = string.IsNullOrEmpty(Text) ? HintText : ""; - if (string.IsNullOrEmpty(Text) || HideClearButton) + if (string.IsNullOrEmpty(Text) || HideClearButton || Text.Length > 21) SearchClearButton.Visibility = Visibility.Hidden; else SearchClearButton.Visibility = Visibility.Visible;