• 0

    posted a message on SKILL_LINES_CHANGED
    Is it also the same event that is raised when a new recipe is learned?
    Posted in: Lua Code Discussion
  • 0

    posted a message on Creating New Font Objects
    Quote from Coldfury »

    instead of inherit of GameFontNormal, why just not set it as?

    MyNormalFontObject:SetFont(GameFontNormal)

    just an tough i had, still a newbie in coding.

    Like you, I'm also a newbie in coding WoW Addons.

    And, the syntax you mentioned actually didn't work.

    However, I did get it to work with:
    local MyNormalFontObject = CreateFont("MyNormalFontObject")
    MyNormalFontObject:SetFontObject(GameFontNormal)
    MyNormalFontObject:SetJustifyH("LEFT")


    With the above code, I was able to "inherit" the GameFontNormal object and override the default of "CENTER" for the GetJustifyH setting and still have my button text appear as apparently the CopyFontObject is inadequate for my task.

    However, apparently, I didn't need to create a new font to override the default horizontal setting of the GameFontNormal font object.

    I just had to create a font string (using frame:CreateFontString), set the properties of that font string (size, anchor points with offsets, and the horizontal justify setting).

    I can then set my button's fontstring property to the newly create font string to inherit the settings.

    Now in the button XML structure:
      <NormalText inherits="GameFontNormal" />
      <HighlightText inherits="GameFontHighlight" />


    can be coded with:
      button:SetTextFontObject(GameFontNormal)
      button:SetHighlightFontObject(GameFontHighlight)



    The "/dump" command (which I was told was an Ace2 command) really help me further get insight with the various objects and allow me to create objects without the use of XML files/templates.


    Posted in: Lua Code Discussion
  • 0

    posted a message on Creating New Font Objects
    I want to create a new font object.

    local MyNormalFontObject = CreateFont("MyNormalFontObject")
    MyNormalFontObject:CopyFontObject(GameFontNormal)
    MyNormalFontObject:SetJustifyH("LEFT")


    My understanding is that the code above will inherit the GameFontNormal font object and I can override the SetJustifyH to the "LEFT" option (the GameFontNormal defaults to "CENTER" for the SetJustifyH).

    However, when I set my button to MyNormalFontObject, the text doesn't appear.

      button:SetTextFontObject(MyNormalFontObject)
      button:SetText("My Button Text")


    It appears that when I do "/dump MyButton" the GetTextHeight is set to 1.

    How do I set my new font object text height to a higher number than 1?

    I tried:
    MyNormalFontObject:SetTextHeight(12)

    but, it doesn't work.

    Your assistance is greatly appreciated.

    Posted in: Lua Code Discussion
  • 0

    posted a message on UIDropDownMenu_CreateInfo()
    I managed to add an OnClick event in the button of my drop down with:
      -- Add OnClick script to dropdown menu button
      local button = MyDropDownMenuButton;
      button:SetScript("OnClick", function() MyDropDownMenuButton_OnClick() end);


    I tried using:
    ToggleDropDownMenu(1, nil, MyDropDownMenu, MyDropDownMenuButton, 0, 0);


    But, the drop down list won't appear when the button is clicked.
    Posted in: Lua Code Discussion
  • 0

    posted a message on UIDropDownMenu_CreateInfo()
    Might as well reuse this thread.

    I managed to create a dropdown control on my frame with this:

    function CreateDropDownMenu(frame)
    
      self:Print("CreateDropDownMenu")
      
      local MyDropDownMenu = CreateFrame("Frame", "MyDropDownMenu", frame, "UIDropDownMenuTemplate"); 
      MyDropDownMenu:SetPoint("TOPLEFT",frame,"TOPLEFT",-6,-40); 
      UIDropDownMenu_SetWidth(100, MyDropDownMenu);
    
      UIDropDownMenu_Initialize(MyDropDownMenu, MyDropDownMenu_Initialize());  
      MyDropDownMenu.displayMode = "MENU" 
      
    end


    I pass into it the parent frame I wanted the control to be in.

    Here is my Initialize function:
    function MyDropDownMenu_Initialize()
    
      self:Print("DropDownMenu Initialize");
    
      local info = {};
      info = UIDropDownMenu_CreateInfo()
      info.text = "MenuItem 1"
      info.func = function() self:SelectMyDropDown_OnClick() end;
      info.value = 1
      info.owner = this:GetParent()
      UIDropDownMenu_AddButton(info)
      info = {}
      info = UIDropDownMenu_CreateInfo()
      info.text = "MenuItem 2"
      info.func = function() self:SelectMyDropDown_OnClick() end;
      info.value = 2
      info.owner = this:GetParent()
      UIDropDownMenu_AddButton(info)
    
      self:Print("Exit DropDown_Initialize")
    
    end


    The control does appear, but, when I click on the button, the dropdown doesn't appear.

    I know I'm doing something wrong.

    I try to mimic this XML:
    <Frame name="<MyDropDownMenu" inherits="UIDropDownMenuTemplate">
      <Anchors>
        <Anchor point="TOPLEFT" relativeTo="MyFrame" relativePoint="TOPLEFT">
          <Offset>
            <AbsDimension x="84" y="3"/>
          </Offset>
        </Anchor>
      </Anchors>
            
      <Scripts>
        <OnLoad>
          UIDropDownMenu_Initialize(this, function() MyDropDownMenu_Initialize() end);
          MyDropDownMenu.displayMode = "MENU"
        </OnLoad>
        <OnShow>
          UIDropDownMenu_Initialize(this, function() MyDropDownMenu_Initialize() end);
          MyDropDownMenu.displayMode = "MENU"
        </OnShow>      
      </Scripts>
    </Frame>


    Using:
    MyDropDownMenu:SetScript("OnLoad", function() 
          UIDropDownMenu_Initialize(this, function() MyDropDownMenu_Initialize() end);
          MyDropDownMenu.displayMode = "MENU";
    end)


    My "hacks" are not working. I'd like to NOT use XML though, hence I've been trying to convert the XML I have.

    Posted in: Lua Code Discussion
  • 0

    posted a message on UIDropDownMenu_CreateInfo()
    After a few trial and errors, I've learned that the icon property of the UIDropDownMenu_CreateInfo() table accepts the path to the texture file.

    I actually wondered if it can accept a frame type, but, I couldn't get it to work.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Loosing the parent of a resizing window
    Quote from Ragnor »

    Before patch 1.10 lua code couldn't create frames, you had to declare them in your xml. So you could say XML was the way things were done originally.


    I see. Interesting to know.

    Pretty much, except lua is better :)

    After seeing (via trial and errors), I'll be re-coding my addon to go Lua and use Xinhuan's suggestion in writing custom template functions to create the various templates.

    There we go some answers not 100% sure they are 100% correct, I'm sure someone else will point out errors.


    Thanks for the response, Ragnor. :)


    Posted in: Lua Code Discussion
  • 0

    posted a message on UIDropDownMenu_CreateInfo()
    I've been reading: http://www.wowwiki.com/UI_Object_UIDropDownMenu

    function MyDropDownMenu_Initialise() 
    level = level or 1 --drop down menues can have sub menues. The value of level determines the drop down sub menu tier 
    local info = UIDropDownMenu_CreateInfo(); 
    info.text = "First Menu Item"; --the text of the menu item 
    info.value = 0; -- the value of the menu item. This can be a string also. 
    info.func = MyDropDownMenuItem_OnClick; --sets the function to execute when this item is clicked 
    info.owner = this:GetParent(); --binds the drop down menu as the parent of the menu item. This is very important for dynamic drop down menues. 
    info.checked = nil; --initially set the menu item to being unchecked with a yellow tick 
    info.icon = nil; --we can use this to set an icon for the drop down menu item to accompany the text 
    UIDropDownMenu_AddButton(info, level); --Adds the new button to the drop down menu specified in the UIDropDownMenu_Initialise function. In this case, it's MyDropDownMenu 


    What is the structure/type/value that can be placed in the info.icon property?

    Posted in: Lua Code Discussion
  • 0

    posted a message on SKILL_LINES_CHANGED
    When does this event get fired?

    I researched that when this event is triggered, the current character's skills (GetNumSkillLines()) will be available instead of during the PLAYER_LOGIN event.

    Will it ever fire again? I'm guessing yes based on the name of the event.

    Is it everytime the player learns a new skill (profession/spell: i.e. any change to the spellbook)?

    What about increasing the level/rank of said skill?


    Also, is there a site/page that lists ALL of the WoW events AND that has descriptions about them? I've been using http://www.wowwiki.com/Events_%28API%29

    Posted in: Lua Code Discussion
  • 0

    posted a message on Loosing the parent of a resizing window
    Quote from Xinhuan »

    Don't use XML. Put your "virtual templates" into a custom frame creation function and call that function instead and have it return a frame.

    Have one function per virtual template.


    Ok, rookie questions...

    What is XML good for if Lua code can create them?

    What can XML do that Lua code cannot and visa-versa? I'm guessing that Lua will be more flexible.

    Is XML only used to load the Lua files (as done in Ace3 Alpha)?

    Is it just a matter of preferences?

    Also, what is the difference between "<Script file="xxx.lua" />" and <include file="yyy.xml" />?


    Posted in: Lua Code Discussion
  • 0

    posted a message on Programmatically create virtual frames/objects
    Quote from Industrial »

    You can't make templates with lua. You can just make a function that spews out a frame though.


    Thanks, Industrial for clarifying that. :)

    Now, what other rookie questions can I dream up. ;)
    Posted in: Lua Code Discussion
  • 0

    posted a message on Programmatically create virtual frames/objects
    Is there a programmatic way to create virtual frames and objects?

    AFAIK, CreateFrame is the function used to create frames and objects.

    Is it as simple as

    local frame = CreateFrame("Frame", "MyVirtualFrame", "UIParent")
    frame:SetVirtual = true

    I've tried searchinig for SetVirtual but keep coming up empty.

    Posted in: Lua Code Discussion
  • 0

    posted a message on Loosing the parent of a resizing window
    Quote from Funkydude »

    Using XML makes babies cry. :(

    I merely used XML to present my case. :)

    You got me to start thinking though...

    Maybe I can re-code my addon to use XML to setup my virtual templates (virtual="true") and use Lua code to put them all together via CreateFrame function.


    Posted in: Lua Code Discussion
  • 0

    posted a message on Loosing the parent of a resizing window
    Quote from Xinhuan »

    It's not a bug.

    Thank you for clarifying that.


    It is well known that after moving or resizing a frame from using Blizzard's :StartMoving() or :StartSizing(), it performs a :ClearAllPoints() and sets a single new point with the frame anchor to UIParent, and the position and framelevel of this frame gets saved in layout-cache.txt in your character specific savedvar folder. The point can be TOPLEFT, TOPRIGHT, BOTTOMLEFT, BOTTOMRIGHT or CENTER, depending on which corner the frame is nearest at the end of it, but only 1 anchor point is set. This prevents the frame from going offscreen when the screen resolution is changed.

    Moving or sizing a frame in this manner makes the frame's :IsUserPlaced() become true and its position and size gets saved in layout-cache.txt. This value can be toggled programatically of course. Or maybe this isn't so well-known seeing as nobody that replied above seemed to know this.

    I didn't know this. In my defense, I'm just a budding developer. :)


    Now note that FrameB's parent is still FrameA, that isn't changed, so hiding FrameA will hide FrameB accordingly. But moving FrameA will not move FrameB because FrameB's anchor point (which determines its position on screen) isn't to FrameA.

    This was my original problem. And yes, FrameB's parent still says FrameA and I assumed that FrameB would still be attached to FrameA.


    As a rule of thumb, visibility is controlled by frame level and frame parent. Positioning is controlled by anchor points. These 2 are separate. A frame's parent (control's visibility) and the frame it is anchored to (controls position) can be 2 entirely different objects.

    I see.


    Note that when a frame's position gets saved in layout-cache.txt, disabling the addon, logging in, logging out, then enabling the addon again will clear its saved position data because the frame didn't exist in one of the game sessions. This causes positioning to "mysteriously reset to defaults" causing frustration.

    :) Well, I discovered this and use it as a way to "reset to defaults". No frustration there. :D


    The way to fix all this is to have a OnDragStop event handling for the frame. In the event, call :StopMovingOrSizing() then perform a :GetPoint() on the frame. Of the 5 return values, save 4 of them into your savedvars. The value you don't save is the 2nd return value which is the anchor frame object. When you load your addon, in the ADDON_LOADED event, get the 4 values from the savedvar and anchor the frame properly to the "last position".

    I'll bank this note for when my internal knowledge of Lua and WoW Addon development gets increased.


    To fix the OP's original problem, you should be using a small frame (with FrameB as its parent) in the FrameB's bottomright corner which has a OnMouseUp and OnMouseDown event handler. The OnMouseDown event calls this:GetParent():StartSizing("BOTTOMRIGHT") and the OnMouseUp event will then look something like

    local f = this:GetParent()
    f:StopMovingOrSizing()
    f:ClearAllPoints()
    f:SetPoint(blah blah reanchor it to frameA)


    The two small boxes in the frames were my "small frame". However, I didn't have
    local f = this:GetParent()
    f:StopMovingOrSizing()
    f:ClearAllPoints()
    f:SetPoint(blah blah reanchor it to frameA)

    in my OnMouseUp Event of the small frame in FrameB.

    I changed my script tags (XML) in the small "resizer frame" to:

            <Scripts>
              <OnMouseDown>
                this:GetParent():StartSizing("BOTTOMRIGHT")
              </OnMouseDown>
              <OnMouseUp>
                this:GetParent():StopMovingOrSizing()
                this:GetParent():ClearAllPoints()
                this:GetParent():SetPoint("TOPLEFT",FrameA,"TOPRIGHT")
              </OnMouseUp>
            </Scripts>

    And it made FrameB continue to move when FrameA gets moved even after FrameB gets resized (and removed all of the Script tags in the FrameB section)

    Thanks a million, Xinhuan!

    Now, I can comment-in my resizer function (which programmatically creates the resizer frame and sets the scripts). I added your code-snippet to my function and it works perfectly! :D


    Posted in: Lua Code Discussion
  • 0

    posted a message on Loosing the parent of a resizing window
    Quote from JaedxRapture »

    In XML use "this":

        <Scripts>
          <OnSizeChanged>
            this:SetPoint("TOPLEFT",FrameA,"TOPRIGHT")
          </OnSizeChanged>
          <OnDragStart>
            this:SetPoint("TOPLEFT",FrameA,"TOPRIGHT")
          </OnDragStart>
        </Scripts>



    It seems like even that doesn't work.

    Also, I noticed that when I resize FrameA, the "/dump FrameA" comes back as:

    GetName() => "FrameA"
    GetObjectType() => "Frame"
    GetParent() => "<Frame:UIParent>"
    GetPoint(1) => "CENTER", nil, "CENTER", xxx, yyy


    I also tried:
        <Scripts>
          <OnSizeChanged>
            this:ClearAllPoints()
            this:SetPoint("TOPLEFT",FrameA,"TOPRIGHT")
          </OnSizeChanged>
          <OnDragStart>
            this:ClearAllPoints()
            this:SetPoint("TOPLEFT",FrameA,"TOPRIGHT")
          </OnDragStart>
        </Scripts>


    And it still doesn't work.

    Guess, I'll have to wait for the fix.
    Posted in: Lua Code Discussion
  • To post a comment, please or register a new account.