From e4bc563fd2dcff1059624efb7b948b2886a382ab Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 2 Jul 2017 16:26:41 +0200 Subject: options: change everything again Fucking bullshit. --- player/command.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'player/command.c') diff --git a/player/command.c b/player/command.c index c7ea6d91f2..bd870e69fd 100644 --- a/player/command.c +++ b/player/command.c @@ -3717,6 +3717,37 @@ done: return mp_property_do(real_property, action, arg, ctx); } +static int mp_property_shitfuck(void *ctx, struct m_property *prop, + int action, void *arg) +{ + MPContext *mpctx = ctx; + int flags = M_SETOPT_RUNTIME; + const char *rname = prop->priv; + + MP_WARN(mpctx, "Do not use %s, use %s, bug reports will be ignored.\n", + prop->name, rname); + + struct m_config_option *co = m_config_get_co_raw(mpctx->mconfig, bstr0(rname)); + if (!co) + return M_PROPERTY_UNKNOWN; + + switch (action) { + case M_PROPERTY_GET_TYPE: + *(struct m_option *)arg = *(co->opt); + return M_PROPERTY_OK; + case M_PROPERTY_GET: + if (!co->data) + return M_PROPERTY_NOT_IMPLEMENTED; + m_option_copy(co->opt, arg, co->data); + return M_PROPERTY_OK; + case M_PROPERTY_SET: + if (m_config_set_option_raw_direct(mpctx->mconfig, co, arg, flags) < 0) + return M_PROPERTY_ERROR; + return M_PROPERTY_OK; + } + return M_PROPERTY_NOT_IMPLEMENTED; +} + static int access_options(struct m_property_action_arg *ka, bool local, MPContext *mpctx) { @@ -5726,7 +5757,8 @@ void command_init(struct MPContext *mpctx) for (int n = 0; n < num_opts; n++) { struct m_config_option *co = m_config_get_co_index(mpctx->mconfig, n); assert(co->name[0]); - if (co->opt->flags & M_OPT_NOPROP) + if ((co->opt->flags & M_OPT_NOPROP) && + co->opt->type != &m_option_type_cli_alias) continue; struct m_property prop = {0}; @@ -5741,6 +5773,21 @@ void command_init(struct MPContext *mpctx) .priv = (void *)alias, .is_option = true, }; + } else if (co->opt->type == &m_option_type_cli_alias) { + bstr rname = bstr0(co->opt->priv); + for (int i = rname.len - 1; i >= 0; i--) { + if (rname.start[i] == '-') { + rname.len = i; + break; + } + } + + prop = (struct m_property){ + .name = co->name, + .call = mp_property_shitfuck, + .priv = bstrto0(ctx, rname), + .is_option = true, + }; } else { prop = (struct m_property){ .name = co->name, -- cgit v1.2.3