1. #1
    High Overlord
    10+ Year Old Account
    Join Date
    Mar 2010
    Location
    New Zealand
    Posts
    115

    Saving kgpanels variables?

    Ok, heres what I'm working with(my new 4.0 UI )



    Now, the 4 bars to the sides are something I've wanted to do purely for extra things like on-use trinkets, abilities, items etc for cata.
    if you can see the little + and - at the top and bottom on each side, that adds or removes one bar (limited to 2 on each side) I have the scripting for those finished and I'm just fixing the last bug or 2 because I'm finished.
    Anyway, my problem. Is it possible with kgpanels to store which of the bars is shown and which is hidden, for example when I load the game now it shows all 4 bars. But lets say I wanted 2 on the left and 1 on the right, or none on the right and 1 on the left. How do I tell kgpanels to store that variable?

    I'd be thinking maybe the PLAYER_LOGIN and PLAYER_LOGOUT events but I'm probably wrong, but in that case I'd imagine it'd be like

    Code:
    if LeftBar1:IsVisible then
      -- save that its visible
    else
      -- save that its not visible
    end
    and do that for each of the 4 bars

    Couple of things to work around, the innermost bars don't show unless the ones on the edge are showing, and I'm using Dominos instead of Bartender(it means 12 lines of code(instead of 1) as each individual button is a frame, not the whole bar, or at least as far as I know but I'm not overly worried about performance at this stage, that's something I can fix later.
    When I'm sad I stop being sad and be AWESOME instead.

  2. #2
    Deleted
    You would need some SavedVariable. Not sure if kgPanels supports those.

  3. #3
    High Overlord
    10+ Year Old Account
    Join Date
    Mar 2010
    Location
    New Zealand
    Posts
    115
    Assuming thats not possible(because it looks that way), I know I can make each kgpanel component hide itself on load so I'd have no bars(this isn't a problem as I never intended to have commonly used spells on there, just clickable CDs etc) is there any way on load I can force the dominos bar to be hidden?
    Adding the code for the dominos frames to kgpanels doesn't seem to work, although I'm not sure why.
    When I'm sad I stop being sad and be AWESOME instead.

  4. #4
    Possibly a long shot, but since Kgpanels supports what should be a good variety of scripting, is it not possible to have another small addon, with public functions (or however you would describe in lua) to allow it to be called from the script.
    That would then handle the saved variables, but you could have a Bar1Visible, and a Bar2Visible which you could call and get a boolean, or True or False return from.

  5. #5
    Deleted
    Actually, you would only need a single TOC file in a folder with the same name that declares a ## SavedVariables: myFrameStatus tag. Then kgPanels could do the rest (if event == "ADDON_LOADED and arg[1] == "whateveryourtocnameis" then myFrameStatus = myFrameStatus or {defaults}).

  6. #6
    High Overlord
    10+ Year Old Account
    Join Date
    Mar 2010
    Location
    New Zealand
    Posts
    115
    I think I get what you mean. I'm really new to how this stuff works(Im not a total code noob as I'm good with PHP) but I'll see what I can do today.

    ---------- Post added 2010-10-23 at 01:24 AM ----------

    Ok, I think I'm almost there.
    Its saving the saved variables correctly.

    TOC File
    Code:
     
    ## Interface: 40000
    ## Title: Sidebars Status
    ## SavedVariables: 
    ## SavedVariablesPerCharacter: leftbar1, leftbar2, rightbar1, rightbar2
    Saved Variables File(atm)
    Code:
     
    leftbar1 = false
    leftbar2 = false
    rightbar1 = nil
    rightbar2 = nil
    kgpanels code
    OnLoad
    Code:
     
    self:RegisterEvent("ADDON LOADED");
    self:RegisterEvent("PLAYER_LOGOUT");
    OnEvent
    Code:
    local left_bars_1_container = kgPanels:FetchFrame("LEFT_BARS_1_CONTAINER")
    local left_bars_1_connector_top = kgPanels:FetchFrame("LEFT_BARS_1_CONNECTOR_TOP")
    local left_bars_1_connector_mid = kgPanels:FetchFrame("LEFT_BARS_1_CONNECTOR_MID")
    local left_bars_1_connector_bottom = kgPanels:FetchFrame("LEFT_BARS_1_CONNECTOR_BOTTOM")
    
    local left_bars_2_container = kgPanels:FetchFrame("LEFT_BARS_2_CONTAINER")
    local left_bars_2_connector_top = kgPanels:FetchFrame("LEFT_BARS_2_CONNECTOR_TOP")
    local left_bars_2_connector_mid = kgPanels:FetchFrame("LEFT_BARS_2_CONNECTOR_MID")
    local left_bars_2_connector_bottom = kgPanels:FetchFrame("LEFT_BARS_2_CONNECTOR_BOTTOM")
    
    if event == "ADDON_LOADED" and arg[1] == "sidebarstatus" then
        
        if leftbar1 == true then
        
            left_bars_1_container:Show();
            left_bars_1_connector_top:Show();
            left_bars_1_connector_mid:Show();
            left_bars_1_connector_bottom:Show();
            MultiBarBottomLeftButton1:Show();
            MultiBarBottomLeftButton2:Show();
            MultiBarBottomLeftButton3:Show();
            MultiBarBottomLeftButton4:Show();
            MultiBarBottomLeftButton5:Show();
            MultiBarBottomLeftButton6:Show();
            MultiBarBottomLeftButton7:Show();
            MultiBarBottomLeftButton8:Show();
            MultiBarBottomLeftButton9:Show();
            MultiBarBottomLeftButton10:Show();
            MultiBarBottomLeftButton11:Show();
            MultiBarBottomLeftButton12:Show();
            
            if leftbar2 == true then
            
                left_bars_2_container:Show();
                left_bars_2_connector_top:Show();
                left_bars_2_connector_mid:Show();
                left_bars_2_connector_bottom:Show();
                DominosActionButton1:Show();
                DominosActionButton2:Show();
                DominosActionButton3:Show();
                DominosActionButton4:Show();
                DominosActionButton5:Show();
                DominosActionButton6:Show();
                DominosActionButton7:Show();
                DominosActionButton8:Show();
                DominosActionButton9:Show();
                DominosActionButton10:Show();
                DominosActionButton11:Show();
                DominosActionButton12:Show();
            
            else
            
                left_bars_2_container:Hide();
                left_bars_2_connector_top:Hide();
                left_bars_2_connector_mid:Hide();
                left_bars_2_connector_bottom:Hide();
                DominosActionButton1:Hide();
                DominosActionButton2:Hide();
                DominosActionButton3:Hide();
                DominosActionButton4:Hide();
                DominosActionButton5:Hide();
                DominosActionButton6:Hide();
                DominosActionButton7:Hide();
                DominosActionButton8:Hide();
                DominosActionButton9:Hide();
                DominosActionButton10:Hide();
                DominosActionButton11:Hide();
                DominosActionButton12:Hide();        
            
            end
            
        else
        
            left_bars_1_container:Hide();
            left_bars_1_connector_top:Hide();
            left_bars_1_connector_mid:Hide();
            left_bars_1_connector_bottom:Hide();
            MultiBarBottomLeftButton1:Hide();
            MultiBarBottomLeftButton2:Hide();
            MultiBarBottomLeftButton3:Hide();
            MultiBarBottomLeftButton4:Hide();
            MultiBarBottomLeftButton5:Hide();
            MultiBarBottomLeftButton6:Hide();
            MultiBarBottomLeftButton7:Hide();
            MultiBarBottomLeftButton8:Hide();
            MultiBarBottomLeftButton9:Hide();
            MultiBarBottomLeftButton10:Hide();
            MultiBarBottomLeftButton11:Hide();
            MultiBarBottomLeftButton12:Hide();
        
        end
    
    end
    
    if event == "PLAYER_LOGOUT"  then
    
        if left_bars_1_container:IsVisible() then
        
            leftbar1 = true;
            
            if left_bars_2_container:IsVisible() then
    
                leftbar2 = true;
    
            end
            
        else
    
        leftbar1 = false;
        leftbar2 = false;
    
        end
    
    end
    I think the kgpanels part is where its falling over to be honest, Its as if it cant run it correctly, maybe I need a different event for the player login, maybe even PLAYER_ENTERING_WORLD?

    ---------- Post added 2010-10-23 at 01:38 AM ----------

    Switching to PLAYER_ENTERING_WORLD works, I do realise there are limitations to this (it will reset when entering instances etc) but that I can live with.
    Thanks Treeston & ComputerNerd!

    LAST EDIT - It was possible to make the bars stay appeared even through multiple "PLAYER_ENTERING_WORLD" Instances just by changing the leftbar1/leftbar2/rightbar1/rightbar2 every time they are shown or hidden.
    Last edited by Killainstnct; 2010-10-23 at 01:54 AM.
    When I'm sad I stop being sad and be AWESOME instead.

  7. #7
    Deleted
    Just use ADDON_LOADED. Make sure your addon folder (and toc) are called "sidebarstatus" (exactly that [without quotes]).
    This is for the reason that PLAYER_ENTERING_WORLD sometimes happens BEFORE ADDON_LOADED, e.g. when the saved vars aren't loaded yet.

  8. #8
    I really love what you did with you UI...

    Do you upload it in any site? Can I have it?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •