From 1eb533afb379ac9addb9205bf25e32cdc9442e93 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 27 Feb 2015 18:31:24 +0100 Subject: options: handle choice -> flag fallback automatically In the past it happened quite often that flag options (yes/no) were changed to choice options (yes/no/some more). The problem with this was that while flag options don't need a parameter, this wasn't the case with choice options. A hack was introduced to compensate for this: setting M_OPT_OPTIONAL_PARAM on the option, and an empty string ("") was added as choice, so that the choice could be used like a flag. So, for example, "--mute" would set the choice "". Fix this by 1. not requiring a parameter if there's a "yes" choice, and 2. redirect an empty parameter to "yes". The effect is that a choice option with the choices ["yes", "no"] is pretty much equivalent to a flag option. --- video/out/gl_video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'video') diff --git a/video/out/gl_video.c b/video/out/gl_video.c index d812ad7960..4f554fbada 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -398,9 +398,9 @@ const struct m_sub_options gl_video_conf = { ({"auto", MP_CHROMA_AUTO}, {"center", MP_CHROMA_CENTER}, {"left", MP_CHROMA_LEFT})), - OPT_CHOICE("alpha", alpha_mode, M_OPT_OPTIONAL_PARAM, + OPT_CHOICE("alpha", alpha_mode, 0, ({"no", 0}, - {"yes", 1}, {"", 1}, + {"yes", 1}, {"blend", 2})), OPT_FLAG("rectangle-textures", use_rectangle, 0), OPT_COLOR("background", background, 0), -- cgit v1.2.3