Thread Tools Display Modes
04-25-12, 06:32 PM   #21
Billtopia
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 110
never thought about forcing blizzard addons to load... that could be bad as they don't follow the rules we are supposed to lol
  Reply With Quote
09-21-12, 09:04 AM   #22
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Originally Posted by Phanx View Post
The Blizzard UI is just Lua/XML code like addons. If information is available to the Blizzard UI, it is also available to addons, though the exact same API.

See:
http://wowprogramming.com/utils/xmlb...L/GameTime.lua

The following events are relevant:
- PLAYER_ENTERING_WORLD
- CALENDAR_UPDATE_PENDING_INVITES
- CALENDAR_EVENT_ALARM

See the "GameTimeFrame_OnEvent" function to see which API functions are called to determine if there is a calendar invite pending. There's nothing magical going on there. You can even just copy/paste the code directly into your addon if you want.
I fixed some of the stuff from this post but i want to clarify some things since it seems people are still finding this post helpful. Also to clarify what i meant to Phanx

The issue with both guild and the calendar is that the data is in fact NOT available to me or blizzard or anything until you actually click the button for the calendar or click on the guild button. The guild and calendar buttons are actually LOD triggers because the guild window and the calendar data only load for use if you click those buttons. Once they are clicked the data is loaded for the rest of your session but when you first log in that data is not available. Go try it...

Its the same long standing issue that there has been with all the mail addons. You can not make your own mail monitoring system that functions properly without the player opening the mail box or doing as i did by linking the bliz functions to my own stuff. Blizzard has magic access to pending mail when the player doesnt and there is a "magic" tooltip for the mail button that shows data that blizzard magicaly knows but if you try to do a print on the pending mail using data and get functions available on login, it will come back nil until you open the mail box, even though blizzards magic tooltip somehow knows it without you going to a mailbox. Once again its because the mail is a magic blizzard LOD.

Data for mail is not available to the player until the mailbox is opened. Data for the calendar is not available to the player until the calendar is opened and same for guild data. Even though blizzard tooltips and other such stuff functions correctly on login. Such as the pending mail tooltip showing the pending mail even though if you do a print it will return nil.

go do prints on guild xp right after you log in without opening the guild window... its going to come back as nil, then open the guild window and it will come back proper.

The easy fix is to have your addon open and close those windows upon login so the data is available. This of course does not work for the mail because it requires the mailbox be opened.
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]

Last edited by Grimsin : 09-21-12 at 09:20 AM.
  Reply With Quote
09-21-12, 04:47 PM   #23
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,892
Well with the following block of code I managed to get hold of your Guild Rep and XP and Events. But like you said access to the Calendar information seems to only trigger when you physically open the calendar. Then it carries out your code for the respective events.

XGIDB_Data is just my saved variables data for this test addon. Play about with it as you will. I only spent a couple of hours on it so may have missed some possibilities out.

Lua Code:
  1. local addonName, addonData = ...
  2.  
  3. local addonLoaded = false
  4. local calendarLoaded = false
  5. local guildLoaded = false
  6. local calendarOpened = false
  7.  
  8. XGIDB_Data = {}
  9. XGIDB_Data.index = 0
  10.  
  11. local function OnEvent(self,event,...)
  12.     local args = { ... }
  13.  
  14.     print(event,...)
  15.  
  16.     XGIDB_Data.index = XGIDB_Data.index or 0
  17.     XGIDB_Data.index = XGIDB_Data.index + 1
  18.  
  19.     XGIDB_Data[XGIDB_Data.index] = {}
  20.     XGIDB_Data[XGIDB_Data.index][event] = {}
  21.     XGIDB_Data[XGIDB_Data.index][event]["Arguments"] = {}
  22.     for i,v in pairs(args) do
  23.         tinsert(XGIDB_Data[XGIDB_Data.index][event]["Arguments"],v)
  24.     end
  25.  
  26.     if ( event == "ADDON_LOADED" and args[1] == addonName) then
  27.         if not IsAddOnLoaded("Blizzard_Calendar") then
  28.             LoadAddOn("Blizzard_Calendar")
  29.         end
  30.         addonLoaded = true
  31.     end
  32.  
  33.     if ( event == "ADDON_LOADED" and args[1] == "Blizzard_Calendar") then
  34.         calendarLoaded = true
  35.     end
  36.  
  37.     if ( event == "UPDATE_FACTION") then
  38.         local numFactions = GetNumFactions()
  39.         XGIDB_Data[XGIDB_Data.index]["Factions"] = {}
  40.         XGIDB_Data[XGIDB_Data.index]["Factions"].Count = numFactions
  41.         for index = 1,numFactions do
  42.             local name, description, standingID, barMin, barMax, barValue, atWarWith, canToggleAtWar, isHeader, isCollapsed, hasRep, isWatched, isChild = GetFactionInfo(index)
  43.             if ( name == "Guild" ) then
  44.                 XGIDB_Data[XGIDB_Data.index]["GuildRep"] =
  45.                 {
  46.                     description = description,
  47.                     standing = standingID,
  48.                     hasRep = hasRep,
  49.                     value = barValue,
  50.                     max = barMax,
  51.                 }
  52.             end
  53.         end
  54.     end
  55.  
  56.     if ( event == "GUILD_ROSTER_UPDATE") then
  57.         QueryGuildXP()
  58.         QueryGuildEventLog()
  59.     end
  60.  
  61.  
  62.     if ( event == "GUILD_XP_UPDATE" ) then
  63.         local currentXP, nextLevelXP, dailyXP, maxDailyXP, weeklyXP, totalXP, isUncapped = UnitGetGuildXP("player")
  64.         XGIDB_Data[XGIDB_Data.index]["GuildXP"] =
  65.         {
  66.             CurrentXP = currentXP,
  67.             DailyXP = dailyXP,
  68.             WeeklyXP = weeklyXP,
  69.             TotalXP = totalXP,
  70.         }
  71.     end
  72.  
  73.     if ( event == "GUILD_EVENT_LOG_UPDATE" ) then
  74.         local numEvents = GetNumGuildEvents()
  75.         XGIDB_Data[XGIDB_Data.index]["GuildEvents"] = {}
  76.         XGIDB_Data[XGIDB_Data.index]["GuildEvents"]["Number of Events"] = numEvents
  77.         for index = 1,numEvents do
  78.             local type, player1, player2, rank, year, month, day, hour = GetGuildEventInfo(index)
  79.             tinsert(XGIDB_Data[XGIDB_Data.index]["GuildEvents"],
  80.             {
  81.                 Index = index,
  82.                 Type = type,
  83.                 Source = player1,
  84.                 Target = player2,
  85.                 Rank = rank,
  86.                 Year = year,
  87.                 Month = month,
  88.                 Day = day,
  89.                 Hour = hour,
  90.             }
  91.             )
  92.         end
  93.     end
  94.  
  95.     if ( event == "PLAYER_GUILD_UPDATE") then
  96.         if ( args[1] == "player" ) then
  97.             GuildRoster()
  98.         end
  99.     end
  100.  
  101.     if ( event == "CALENDAR_UPDATE_GUILD_EVENTS") then
  102.         local numEvents = CalendarGetNumGuildEvents()
  103.         XGIDB_Data[XGIDB_Data.index]["GuildCalendarEvents"] = {}
  104.         XGIDB_Data[XGIDB_Data.index]["GuildCalendarEvents"]["Number of Events"] = numEvents
  105.         for index = 1,numEvents do
  106.             local month, day, weekday, hour, minute, eventType, title, calendarType, textureName = CalendarGetGuildEventInfo(index)
  107.             tinsert(XGIDB_Data[XGIDB_Data.index]["GuildCalendarEvents"],
  108.             {
  109.                 Index = index,
  110.                 CalendarType = calendarType,
  111.                 EventType = eventType,
  112.                 Title = title,
  113.                 Month = month,
  114.                 Day = day,
  115.                 Hour = hour,
  116.                 Weekday = weekday,
  117.             }
  118.             )
  119.         end
  120.     end
  121.  
  122.     if ( event == "CALENDAR_UPDATE_EVENT_LIST") then
  123.         local weekday,month,day,year = CalendarGetDate()
  124.         local numEvents = CalendarGetNumDayEvents(0, day)
  125.         XGIDB_Data[XGIDB_Data.index]["CalendarEvents"] = {}
  126.         XGIDB_Data[XGIDB_Data.index]["CalendarEvents"]["Number of Events"] = numEvents
  127.         for index = 1,numEvents do
  128.             local title, hour, minute, calendarType, sequenceType, eventType, texture, modStatus, inviteStatus, invitedBy, difficulty, inviteType = CalendarGetDayEvent(0, day, index)
  129.             tinsert(XGIDB_Data[XGIDB_Data.index]["CalendarEvents"],
  130.             {
  131.                 Index = index,
  132.                 CalendarType = calendarType,
  133.                 EventType = eventType,
  134.                 Title = title,
  135.                 Month = month,
  136.                 Day = day,
  137.                 Hour = hour,
  138.                 Weekday = weekday,
  139.             }
  140.             )          
  141.         end
  142.     end
  143.  
  144.     if addonLoaded and calendarLoaded and not calendarOpened then
  145.         local weekday,month,day,year = CalendarGetDate()
  146.         local month, year, numDays, firstWeekday = CalendarGetMonth(0)
  147.         CalendarSetAbsMonth(month,year)    
  148.         OpenCalendar()
  149.         calendarOpened = true
  150.     end
  151.  
  152. end
  153.  
  154. local frame = CreateFrame("Frame","XGIFrame",UIParent)
  155. frame:RegisterEvent("ADDON_LOADED")
  156. frame:RegisterEvent("UPDATE_FACTION")
  157. frame:RegisterEvent("PLAYER_GUILD_UPDATE")
  158. frame:RegisterEvent("GUILD_ROSTER_UPDATE")
  159. frame:RegisterEvent("GUILD_XP_UPDATE")
  160. frame:RegisterEvent("GUILD_EVENT_LOG_UPDATE")
  161. frame:RegisterEvent("CALENDAR_UPDATE_GUILD_EVENTS")
  162. frame:RegisterEvent("CALENDAR_UPDATE_EVENT_LIST")
  163. frame:SetScript("OnEvent",OnEvent)
__________________
  Reply With Quote
09-21-12, 05:57 PM   #24
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Grimsin View Post
Blizzard has magic access to pending mail when the player doesnt and there is a "magic" tooltip for the mail button that shows data that blizzard magicaly knows but if you try to do a print on the pending mail using data and get functions available on login, it will come back nil until you open the mail box, even though blizzards magic tooltip somehow knows it without you going to a mailbox. Once again its because the mail is a magic blizzard LOD.
Once again, it's not magic. It's just code. If you don't understand how it works, that's fine, but that doesn't mean it's some incomprehensible black-box voodoo that nobody can understand or use.

As I already said, the Blizzard UI is 100% pure Lua and XML code, and is plainly visible to anyone who bothers to look at it. Here is the function that runs when you mouse over the minimap mail button:

http://wow.go-hero.net/framexml/16030/Minimap.lua#213

As you can see, there's nothing "magic" about it, just simple function calls:

Code:
  local sender1,sender2,sender3 = GetLatestThreeSenders();
  local toolText;
  
  if( sender1 or sender2 or sender3 ) then
    toolText = HAVE_MAIL_FROM;
  else
    toolText = HAVE_MAIL;
  end
  
  if( sender1 ) then
    toolText = toolText.."\n"..sender1;
  end
  if( sender2 ) then
    toolText = toolText.."\n"..sender2;
  end
  if( sender3 ) then
    toolText = toolText.."\n"..sender3;
  end
  GameTooltip:SetText(toolText);
If I log into a character I know has mail from the auction house and an alt, and type "/run local sender1, sender2, sender3 = GetLatestThreeSenders(); print("sender1:", sender1); print("sender2:", sender2); print("sender3:", sender)" -- without any addons, without opening the mailbox, and without even mousing over the minimap mail button -- I get exactly what I expect:

sender1: Altname
sender2: Horde Auction House
sender3: nil
If I then mouse over the minimap mail button, lo and behold, I see the same senders in the tooltip. If I then walk to the mailbox and open it, surprise, surprise, I see mail from the same senders.

Do you have any evidence of any function in the entire UI that returns values when Blizzard calls it but not when you call it under the same circumstances? (eg. the same addon is loaded, the same event has fired, etc.) I'd be extremely surprised if you could even identify one such function. Obviously functions which depend on a particular addon being loaded won't return any values before that addon is loaded -- they wouldn't return any values if the Blizzard UI called them before loading that addon, either.

Instead of throwing around ridiculous claims like "it's magic!" why don't you actually test stuff, or just ask questions if you don't understand how something works?
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
09-21-12, 06:15 PM   #25
Talyrius
An Onyxian Warder
 
Talyrius's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 363
“Any sufficiently advanced technology is indistinguishable from magic.” ― Arthur C. Clarke

  Reply With Quote
10-03-12, 08:01 AM   #26
Grimsin
A Molten Giant
 
Grimsin's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 990
Sure you can pull the names of the top 3 pending. You could use that to highlight things maybe. BUT You can not get an accurate count of how many mails you have. Because that information is only available once you open the mailbox.

And here is where we may all have some confusion... and your right phanx none of it is magic...

So im pretty sure that at some point in time the blizzard UI displayed a actual number of total mail on the mail icon when you had mail in the box. I just ran the original blizzard UI and noticed that it no longer shows a number, all it shows is the top 3 names of unopened mail. Sooo maybe your right now... but im pretty sure at one point in time blizzards ui was capable of showing a mail total when you could not get one yourself without opening the mailbox. I will go back and check into the calendar stuff again as well but...
__________________
"Are we there yet?"

GrimUI
[SIGPIC][/SIGPIC]
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Mass confusion, loading process

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off