|
Sun, Jan 11 2009 2:42 AM
|
|
|
Hello,
I would need to know the page number of the Merchant's Frame I'm on.
Is there directly a function that gets this number ?
Or an event that could be fired when the user changes page...
Thanks a lot !
[edited by: adriweb at 2:43 AM (GMT -6) on 11 Jan 2009]
better
|
|
|
|
|
Sun, Jan 11 2009 9:19 AM
|
|
|
Hmm... never thought about it. wowprogramming.com has both a function and event listed. That is a great resource for info.
Looks like http://wowprogramming.com/docs/api/ItemTextGetPage returns the current page
and http://wowprogramming.com/docs/events/ITEM_TEXT_READY fires when you change pages.
|
|
|
|
|
Sun, Jan 11 2009 10:52 AM
|
|
|
I actually looked at that earlier, but it's only for books that we can find kind of everywhere... it's not working for a merchant's frame :/
And yes, wowprogramming.com is really good :D
|
|
|
|
|
Sun, Jan 11 2009 12:18 PM
|
|
|
Now I have a problem in my addon VendorSearch....
Blizzard apparently changed the way the MerchantFrames work from 2.4.3 to 3.0 ...
Before, the items in a slot had a unique number, for each one of them. Now, the numbers are resetted each page ..
So if I want to hide the slot number 2, I can write :
/script MerchantItem2:Hide()
That works for the Item2 in 2.4.3
In 3.0.*, all the items in the second slot *of any pages* will be hidden...
And I would have done /script MerchantItem12:Hide() for the 2nd slot of the 2nd page, in 2.4.3
But in 3.0 that doesn't work at all... because Blizzard set the max number to 10, and then it's the other page.
But what's even more weird, it is that when I want some info about a
specific item, the way it works in 2.4.3 with IDs > 10 works in
3.0.3 too !
Example : /script GetMerchantItemInfo(12)
that works in both version of the game !
Even if the Item 12 doesn't refer to any particular item in version 3.0.3 because 10 is the limit, then it changes page....
That same ID for different items is really bad for my addon
Anybody can help me ?
[edited by: adriweb at 12:45 PM (GMT -6) on 11 Jan 2009]
|
|
|
|
|
Sun, Jan 11 2009 1:22 PM
|
|
|
This works: Code: function update() local currPage = MerchantFrame.page; local totalPages = math.ceil(GetMerchantNumItems() / MERCHANT_ITEMS_PER_PAGE); DEFAULT_CHAT_FRAME:AddMessage("Page: " .. currPage .. " Total Pages: " .. totalPages); end hooksecurefunc("MerchantFrame_Update", update);
[edited by: teek5449 at 1:24 PM (GMT -6) on 11 Jan 2009]
|
|
|
|
|
Sun, Jan 11 2009 2:04 PM
|
|
|
wow thanks a lot, that resolves my problem....
you will be in the "special thanks" :P
|
|
|
|
|
Sun, Jan 11 2009 2:52 PM
|
|
|
NP. You may also want to bookmark http://wowcompares.com/. This is where I found the MerchantFrame_Update function in the MerchantFrame.lua file.
In fact you may find a cleaner way in that file than to do what you are describing than hooking an update function.
[edited by: teek5449 at 2:53 PM (GMT -6) on 11 Jan 2009]
|
|
|
|
|
Sun, Jan 11 2009 2:53 PM
|
|
|
hmm..
is that "hooksecurefunc("MerchantFrame_Update", update);" supposed to "refresh" the frame like if it was a new opening ?
if it's that, it doesn't work..
Because, what I would like to do is th Hide for example a specific Item on a specific page... and that "refresh" function could be useful because when I want to hide the number 2 for example, all the items on the slot 2 will be hidden *on all the pages*...
|
|
|
|
|
Sun, Jan 11 2009 2:56 PM
|
|
|
 Quote: Originally Posted by adriweb 
hmm..
is that "hooksecurefunc("MerchantFrame_Update", update);" supposed to "refresh" the frame like if it was a new opening ?
if it's that, it doesn't work..
Because, what I would like to do is th Hide for example a specific Item on a specific page... and that "refresh" function could be useful because when I want to hide the number 2 for example, all the items on the slot 2 will be hidden *on all the pages*...
If you just want to hide item2 on page2 you can just use a conditional right? Code: if(currPage == "2") then MerchantItem2:Hide(); end
|
|
|
|
|
Sun, Jan 11 2009 3:08 PM
|
|
|
The problem with that is it hides all the items with the ID of 2 !
so, for everypages, the 2nd item will be hidden... weird, because you still can get info by doing GetMerchantItemInfo(12), but when you try to Hide Item 12, it doesn't exit, because the max. is 10
and btw, thanks for the link... :D
|
|
|
|
|
Sun, Jan 11 2009 4:06 PM
|
|
|
well, I have another question for you :P
How do you make the "If page changed" an event.
So I'd like my addon to execute the fuction search() each time "page changed"...
That'd be awesome....
[edited by: adriweb at 4:24 PM (GMT -6) on 11 Jan 2009]
|
|
|
|
|
Sun, Jan 11 2009 4:25 PM
|
|
|
There is no page changing event for the merchant window I tested for that first.
Code: if(currPage == 2) then MerchantItem2:Hide(); else MerchantItem2:Show(); end
Works but there is a blank space left over over where the item should be. I am not sure yet about how to remove that blank slot without overriding the entire MerchantFrame_UpdateMerchantInfo() function which seems like overkill.
[edited by: teek5449 at 4:26 PM (GMT -6) on 11 Jan 2009]
|
|
|
|
|
Sun, Jan 11 2009 5:11 PM
|
|
|
Yep, I noticed th blank slot on my versions too...
If everything else works fine, that's not really important
|
|
|
|
|
Sun, Jan 11 2009 6:36 PM
|
|
|
All right, problems solved ...
Thanks a lot !
|
|
|
|