• 0

    posted a message on Tooltips best practice?
    Ya, that's what I was planning on doing. I just wasn't aware that I could arbitrarily define new variables to the frame class like that ^_^
    Posted in: Lua Code Discussion
  • 0

    posted a message on Tooltips best practice?
    Quote from OrionShock
    Eh no, that would be bad.

    Now if you need extra "data" for a tooltip, use a dictinary style look up or attach the referencnce to the frame when you set the debuff.

    local debuffFrame_OnEnter = function(frame)
        GameTooltip:SetOwner(self, "ANCHOR_RIGHT") 
        GameTooltip:SetText("~~")
        if frame.offset then
            --Find data in lookup table via frame.offset
            GameTooltip:AddLine("~~")
        end
        GameTooltip:Show() 
    end
    What you can do then, when setting up the debuff frames, just set the frame.offset to what ever, then you can access that from with in your OnEnter call.

    I think that fits with what your trying to do.

    Yep, that should work, wasn't sure if I could just arbitrarily assign variables to frames or not >_<
    Posted in: Lua Code Discussion
  • 0

    posted a message on Tooltips best practice?
    Quick question before I write all the code to do it, but would using closure to encapsulate the tooltip functions inside of my adddebuff function work, and more importantly retain the memory efficiency of declaring it as a local?

    ie.
    function AddDebuff(...)
       local function TooltipOnEnter(...)
          tooltip code here using a local variable like offset to set tooltip text properly
       end
    
       frame:SetScript("OnEnter". TooltipOnenter)
    end


    That is to say, a locally defined tooltip template script, that uses closure on the offset parameter (which controls the debuff text). Thoughts?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Tooltips best practice?
    Quote from Xinhuan
    The only other reason I can think of for the OnEnter/Leave not to work is that your debuff frames are not actualy detecting the mouse cursor. This would happen if there's some other transparent frame on top of them.

    Also note that a new OnEnter/OnLeave function is created for each debuff frame. It will be wise to upvalue the function to local file scope, and just assign the function variable in the SetScript:

    local myfunc = function(self, motion)
        print("this function ran")
        GameTooltip:SetOwner(self, "ANCHOR_RIGHT") 
        GameTooltip:SetText("Debuff Tooltip!") 
        GameTooltip:AddLine("Debuff Tooltip!") 
        GameTooltip:Show() 
    end
    
    function Overlord:AddDebuff(texture, offset) 
        ...
        frame:SetScript("OnEnter", myfunc)  
        ...
    end

    I would, but wouldn't that be impossible if I wanted the tooltips to be different for each frame? Or is there some form of lamda notation I could use to write a local function that returns a function?

    edit:
    Or would it be better to only set the scripts if it's creating the frame originally, and then have the scripts just reference a variable tied to whatever debuff frame the script is set to? (ie. setscripts get tied in to the 'or CreateFrame' part of the code, and the GameTooltip:AddLine becomes 'GameTooltip:AddLine(debuffTooltips[offset])'

    edit2:
    Now that I think about it, I like the way the idea I talked about in my first edit would work, but I can't think of any way to update that offset value to be correct... any ideas?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Tooltips best practice?
    Yep that was it. Just added frame:EnableMouse(true) and everything works fine now ^_^
    Posted in: Lua Code Discussion
  • 0

    posted a message on Tooltips best practice?
    Quote from Seerah
    Are your frames mouse enabled?

    You know... That might just be it. The parent frame is, but I don't think I'm setting it for the children. I'll give it a try when I'm at my work machine next.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Tooltips best practice?
    @Xinhaun: No luck with the extra hide(). There isn't any transparent frame on top of it. Frame strata is: Debuff Frame > Debuff Bar Frame > UIParent. At least there shouldn't be. If the bar frame was over the debuffs they'd be shaded out by the bar frame's backdrop, and they're not.

    @Torhal: I'm aware, I've been meaning to change that line, I just keep getting side tracked every time I see it :P
    Posted in: Lua Code Discussion
  • 0

    posted a message on Tooltips best practice?
    SetText didn't work, and the issue with the others is I want just my custom text in the tooltip, not the debuff information.

    edit:
    For simplicities sake, here's another pastey with the full code. http://www.pastey.net/112852
    Posted in: Lua Code Discussion
  • 0

    posted a message on Tooltips best practice?
    Example code doesn't seem to function. No errors, no tooltip, and the rest of my code continues to work normally. Thoughts?

    -- Add a debuff frame onto the main debuff bar
    function Overlord:AddDebuff(texture, offset)
       -- Create a local frame variable to hold the frame while we work
       local frame = nil
    
       -- Check if an already used frame is available, otherwise use a new frame
       frame = debuffFrames[offset] or CreateFrame("FRAME", nil, self.debuffBarFrame)
    
       -- Update our backdrop template with the texture we want
       debuffBackdrop.bgFile = "Interface\\Icons\\" .. texture
    
       -- Set the backdrop to our local frame
       frame:SetBackdrop(debuffBackdrop)
    
       -- Set the width / heigh of our local frame
       frame:SetWidth(16)
       frame:SetHeight(16)
       frame:ClearAllPoints()
    
       -- Set the local frame's anchor to the proper location for the given offset
       frame:SetPoint("TOPLEFT", self.debuffBarFrame, "TOPLEFT", 2 + (18 * offset), -2)
    
       -- Set up the tooltip functions for the frame
       frame:SetScript("OnEnter", function(self, motion)
          GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
          GameTooltip:ClearLines()
          GameTooltip:AddLine("Debuff Tooltip!")
          GameTooltip:Show()
       end)
    
       frame:SetScript("OnLeave", function(self, motion)
          GameTooltip:Hide()
       end)
    
       -- place our local frame back into the frame recycling array
       debuffFrames[offset] = frame
    
       -- Update our parent frame's width to fit the new debuff
       self.debuffBarFrame:SetWidth(20 + (18 * offset))
    end
    Posted in: Lua Code Discussion
  • 0

    posted a message on Localization and Buff Names...
    Oh I know, I just wanted to make sure x87bliss knew that there were exceptions :P
    Posted in: Lua Code Discussion
  • 0

    posted a message on Localization and Buff Names...
    Just be careful to double check the spells you're looking at. Some talents apply a differently named buff/debuff than the talent themselves (Improved Shadow Bolt procs Shadow Mastery, for example).

    A debuff example would be something like Ebon Plaguebringer, which actually applies a debuff named Ebon Plague. Another example would be Devistate, which procs sunder armor, not a debuffa named 'devistate' There's also the warrior ability Charge, which triggers the "Charge Stun" debuff

    More than likely you won't encounter the few odd cases like those, but best to be aware of them :P
    Posted in: Lua Code Discussion
  • 0

    posted a message on Tooltips best practice?
    Is there a tutorial and/or a good bit of code that I should be looking at for learning how to deal with the crazy mess that is the WoW gametooltip object?

    edit:
    Specifically, I'm looking to add custom tooltip text to a couple frames, not replace the tooltip system all together.
    Posted in: Lua Code Discussion
  • 0

    posted a message on AceDBOptions and profile updating...
    That's what I was looking for, thanks! I figured there was something like that that I was missing, I just couldn't seem to figure out which one it was XD Works fine now.

    Thanks again for all the help ^_^
    Posted in: Lua Code Discussion
  • 0

    posted a message on AceDBOptions and profile updating...
    It's not the scaling that is the issue. It's changing profiles.

    If you scale it to say 2, and then change profiles to something with a scale of 1, it STAYS at the scale of 2 until you console reloadui even though the variable controlling the frame scale has been changed. The only way for that to happen is for profile changing to not fire the set methods for all my options, which seems to be the case.

    Also, the only other addons running on my test character are bugsack. Everything else is disabled for that character, and I get absolutely no errors at all.
    Posted in: Lua Code Discussion
  • 0

    posted a message on AceDBOptions and profile updating...
    the entire body of Overlord.lua is in the pasty in my second post in this thread.

    Maybe it has something to do with aceDBOptions calling the functions, but the functions themselves reference self rather than Overlord?
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.