[REL] Settings Manager v1.6.0 [67342]

Discussion in 'Released Mods' started by Raevn, December 9, 2013.

  1. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    Updated to v1.2.0, now supports MultiSelect ListBoxes.
    This update is required for the Alerts Filter Mod.
  2. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    Updated to v1.3.0, now supports Buttons.
    proeleert likes this.
  3. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    Updated to v1.4.0, now supports setting groups.

    SettingsGroups.PNG
  4. proeleert

    proeleert Post Master General

    Messages:
    1,681
    Likes Received:
    1,656
  5. DeathByDenim

    DeathByDenim Post Master General

    Messages:
    4,328
    Likes Received:
    2,125
    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)
    Raevn likes this.
  6. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    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!
  7. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    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.
  8. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    I tried doing that and it didn't work. I'll check that mod and see if I missed anything.
  9. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    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 :oops:
  10. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    I can't see a callback in there. You are passing 5 Strings. The 4th one looks like a method name though.
  11. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    Isn't it supposed to be a method name?
  12. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    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 ()
  13. cptconundrum

    cptconundrum Post Master General

    Messages:
    4,186
    Likes Received:
    4,900
    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.
  14. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    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");
  15. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    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.
  16. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    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);
            }
        }
    }
  17. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    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');
    }
  18. cola_colin

    cola_colin Moderator Alumni

    Messages:
    12,074
    Likes Received:
    16,221
    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.
  19. Raevn

    Raevn Moderator Alumni

    Messages:
    4,226
    Likes Received:
    4,324
    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.
  20. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    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!

Share This Page