Updated to v1.2.0, now supports MultiSelect ListBoxes. This update is required for the Alerts Filter Mod.
In the instructions you might want to say that you should use Code: model.addSetting_DropDown(displayName, id, tab, optionsArray, defaultIndex, group); instead of Code: addSetting_DropDown(displayName, id, tab, optionsArray, defaultIndex, group); That confused me a bit at first. (same for the other functions of course)
Would you mind making a quick update to the MultiSelect function? I'm writing a mod that needs to update its MultiSelect setting on the fly. I'd need either a way to request that the MultiSelect has a certain ID or a function telling that MultiSelect to update from its settings? Thanks!
The created multiselect will use the following variables, which you can edit on-the-fly: Options list: <id>_options Select Options list: <id> You can refer to the Favourite Colour mod for an example, as DeathByDenim dynamically alters the secondary colour drop-down menu based on the chosen primary colour.
After some log commands I've figured out that it's actually an issue with my buttons's callbacks. I can't figure out how to make it work and the only mod that I know of that used them (Floating UI) has been taken down. Could you tell me what's wrong here? Code: model.addSetting_Button("", "Add new rule", "UI", "LUnitNames_Add()", "Unit renaming rules"); Thanks
I can't see a callback in there. You are passing 5 Strings. The 4th one looks like a method name though.
Yes but without the "" and the (). Anything within "" is just a string, but a callback has to be a function. The () should not be in, because if you put them in you would call the function and pass the result. But you want to pass the function itself, so the function can be called back later. So no "" or ()
I haven't seen the rest of your code, but you would usually pass a callback through without quotes or parentheses. Code: model.addSetting_Button("", "Add new rule", "UI", LUnitNames_Add, "Unit renaming rules"); And then later on you would just call LUnitNames_Add() from inside the function. It is also probably bad practice to use a capital letter at the beginning of the function name.
The button code in generated as followss: <input type="Button" class="settings_button" data-bind="click: ' + callback + '" value="' + buttonText + '" /> So text is appropriate, however remove the parenthesis (as this would instead deposit the output of the function into the button): model.addSetting_Button("", "Add new rule", "UI", "LUnitNames_Add", "Unit renaming rules");
Thanks but neither of those are working either. I thought the callback was supposed to be an event handler for the click. I tried just passing the function name like both of you suggested as well as this: Code: model.addSetting_Button("", "Add new rule", "UI", function () { LUnitNames_Add(); }, "Unit renaming rules"); I also tried that before and it didn't work. Something tells me I'm making a stupid mistake here but I have no clue as to what.
If it helps, the code for the button in the image above is: Code: model.addSetting_Button('RESET UI LAYOUT', 'RESET', 'UI', "model.resetUIFrames","Floating Framework"); ... model.resetUIFrames = function() { var activeFrames = decode(localStorage['activeFrames']); for (var key in activeFrames) { if (activeFrames.hasOwnProperty(key)) { console.log("[rFloatFrame] Forgetting position for frame '" + key + "'"); forgetFramePosition(key); } } }
Still not working. Here's what I have: Code: model.addSetting_Button("", "Add new rule", "UI", "LUnitNames_Add", "Unit renaming rules"); ... var LUnitNames_Add = function () { console.log('LUnitNames: Added'); }
The method needs to be part of model, as it is used as a knockout binding. A function in some var somewhere is hidden to knockout.
I wonder if the function is out-of-scope. Does it work if you do "model.LUnitNames_Add" and change the function to model. instead of var? Edit: Cola beat me too it.
Still not working. Code: model.addSetting_Button("", "Add new rule", "UI", "model.LUnitNames_Add", "Unit renaming rules"); ... model.LUnitNames_Add = function () { var settings = decode(localStorage.settings); var rules = settings.LUnitNames_Rules_options; rules.push('Original Unit Name -> Custom Unit Name'); console.log('LUnitNames: Added'); } Thanks for all your help though guys!