[REL] Better Build Bar [Not Currently Working]

Discussion in 'Released Mods' started by Corang, March 1, 2014.

  1. Corang

    Corang Well-Known Member

    Messages:
    772
    Likes Received:
    313
    that would be cool, could you throw in some comments explaining what is happening too?
  2. Corang

    Corang Well-Known Member

    Messages:
    772
    Likes Received:
    313
    pick one:

    option 1
    box off.png
    option2
    box on.png
    tatsujb likes this.
  3. Corang

    Corang Well-Known Member

    Messages:
    772
    Likes Received:
    313
    Also, this is obviously first pass, there is some stuff I would like to tweak. I just threw this together with the debugger in 5 minutes
  4. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    N°1
  5. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    Ok, here you go. This may have a bug or two since I didn't test it and the thread for the settings manager framework is here: https://forums.uberent.com/threads/rel-settings-manager-v1-4-0-58772.54588/
    The framework doesn't support checkboxes so I used a drop down but that means you can easily add other styles in the future. (Like no border transparent, hint, hint.)
    1. Add these two lines to your modinfo.json:
      Code:
      "settings": [
              "coui://ui/mods/ID/Settings.js"
          ],
          "requires": [
              "rSettingsManager"
          ]
    2. Make the settings.js file as listed in step one and put this code in it:
      Code:
      (function () {
          model.addSetting_DropDown("Transparency: ", "cBBB_Trans", "UI", ["Transparent", "Invisible"], 0, "Better Build Bar");
      })();
    3. Now add this line before the first line that reads the setting in your main js file:
      Code:
      initialSettingValue("cBBB_Trans", 0);
    4. Now use this line to get the index of the current selected value: (0 = "Transparent", 1 = "Invisible")
      Code:
      var value = settings.cBBB_Trans;
    5. Realize that it wasn't that hard and be glad you didn't have to write something like the monster of a settings.js file that I wrote for my custom unit names mod.
    Basicly what is happening here is you are using the settings framework mod from raevn to add a new settings group and item when the settings menu is loaded. (Same way the main part of your mod works.) The framework also takes care of saving that setting using the localstorage functions in js. Then in the main js file you use the initialSettingValue function to set the default value in case the user hasn't loaded the settings menu yet. Finally, you read the value from the localstorage using settings.id and use it for your UI.
    Last edited: March 4, 2014
  6. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    at step 4 it reverted the bar to stock are we still talking about corBetterBuildBar.js?
  7. Corang

    Corang Well-Known Member

    Messages:
    772
    Likes Received:
    313
    I have a present for you


    unzip it and place it in the PAMM mods directory

    Attached Files:

    tatsujb likes this.
  8. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    odd. Did it show any errors in the debugger? Yeah, I think that's the main js file.
  9. Corang

    Corang Well-Known Member

    Messages:
    772
    Likes Received:
    313
    after much frustration I found there is something wrong with your code at some point, this is because it says settings is not defined from step 4, any ideas?
  10. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    oops, stupid me. I just released that I mixed raevn's example code and my code in the wrong way there. Replace settings with localStorage and it should work.
  11. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    thaaaaaaaaaanks
  12. Corang

    Corang Well-Known Member

    Messages:
    772
    Likes Received:
    313
    okay, well i am still having problems the variable is still undefined, can you look at this @LavaSnake i have my wip attached

    Attached Files:

  13. tatsujb

    tatsujb Post Master General

    Messages:
    12,902
    Likes Received:
    5,385
    thanks @Corang ! by the way I like to be referred to as tatsu rather than tatsujb, just a heads up now that we know each other better :)
  14. Corang

    Corang Well-Known Member

    Messages:
    772
    Likes Received:
    313
    hey, no problem, I enjoy doing this, after I get this all sorted out with settings manager I will start trying to get the auto commander select to work.
  15. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    I looked it over real quick and it seems to be an issue with the ID. I'll look into it more when I get the time and post the fixed version here.
  16. Corang

    Corang Well-Known Member

    Messages:
    772
    Likes Received:
    313
    okay, thanks, I am at school right now so I can't do much, let me know what you find out.
  17. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    Fixed it. There were two issues. First, we were using the wrong command to get the value in settings. We should have used this command:
    Code:
    decode(localStorage.settings).cBBB_Trans;
    Second the value we get is actually the text and not the index of the selection.

    I've uploaded the fixed version.

    Attached Files:

  18. Corang

    Corang Well-Known Member

    Messages:
    772
    Likes Received:
    313
    Okay, thanks I will fix my if/if else/else statment when I get home.
  19. LavaSnake

    LavaSnake Post Master General

    Messages:
    1,620
    Likes Received:
    691
    I already fixed that. In the version I uploaded everything works fine and it works great!
  20. Corang

    Corang Well-Known Member

    Messages:
    772
    Likes Received:
    313
    oh wow, thanks

Share This Page