MSUTeam/MSU

Add a way to react to setting changes immediately

Opened this issue · 2 comments

Suor commented

I am trying to disable some settings immediately as they become irrelevant:

local function add(elem) {
    page.addElement(elem);
    elem.Data.NewCampaign <- true;
}
local function get(name) {
    return ::EliteFew.Mod.ModSettings.getSetting(name)
}

add(::MSU.Class.EnumSetting("selectMode", "roll", ["roll" "all" "none"], "Select masters"));
add(::MSU.Class.RangeSetting("multiplier", 1, 1, 20, 1, "Chance multiplier"));

get("selectMode").addCallback(function (_value) {
    if (_value == "roll") {
        get("multiplier").unlock();
    } else if (_value == "all") {
        get("multiplier").lock("No need to roll");
    } else if (_value == "none") {
        get("multiplier").lock("No point to roll");
    }
});

However callback is only fired once I click Apply or Save which defeats the purpose.

I am not sure how this could be implemented though. I understand that if we start to change actual setting values upon a user clicking fields then this will be a significant change in behaviour. So probably some new callback is needed, i.e. onUIChange(_value) or smth. Then one might want to query "UI values" of some other fields around though.

Hm, I guess we missed this one. Yeah, it's bothered me too, but it would require a redesign as you say.

Yeah this idea is tough, I agree it'd be useful, but I think it'd be a pain to make work within the current system. Ideally though I'm thinking this would be JS side only which would decrease the amount of work necessary