vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2  
3 ntmysFixLoadingTimes (v13 /apr /06)
4 -----------------------------------
5  
6 Improves loading-times between zoning (ie: switching continents, entering/leaving an instance).
7 This works by preventing numerous events from being processed by the event-handlers during zoning,
8 events that would otherwise update your interface with information that you simply won't need
9 when you are starring at a loading-screen. Depending on your system and installed addons, zoning
10 will be 5-10 times faster (no kidding: for me as an example, MC loads in 6-8s instead of over 1 minute).
11  
12 use /nFLT to cycle between different modes:
13  
14 on (with messages) - the default
15 on (without messages)
16 off (with messages)
17 off
18  
19 With messages, it shows how long zoning took and how many events had been processed.
20 When using [off (with messages)] you can see how much time passes when all events are being processed,
21 so you can compare your loading times with and without FLT turned on.
22  
23 A big Thankyou to Tigerheart for pointing out the events-slowering-loading-times-during-zoning-problem on the
24 official interface-forum.
25  
26 Christopher "ntmy" Steglich (dantmy@gmx.net)
27  
28  
29 Version History
30 ---------------
31 v13/apr/06
32 - working on all frames now and thus blocking a few more events
33 - code optimization
34  
35 v12/apr/06
36 - fixed slashes in french localization
37 - french localization by RaSk
38  
39 v11/apr/06
40 - initial release
41  
42 ]]--
43 local Title = "ntmysFixLoadingTimes (v13 /apr /06)";
44  
45 ntmysFLT_isActive = 1; -- default is on with messages
46  
47 function ntmysFLT_OnLoad()
48 DEFAULT_CHAT_FRAME:AddMessage(Title..NFLT_TITLEUSAGE,1,1,0.5);
49  
50 SlashCmdList["NFLT"] = function(msg)
51 ntmysFLT_isActive = mod(ntmysFLT_isActive+1,4);
52 DEFAULT_CHAT_FRAME:AddMessage(NFLT_SETTING[ntmysFLT_isActive+1],1,1,0.5);
53 ntmysFLT_setMode();
54 end
55 SLASH_NFLT1 = "/nFLT";
56  
57 this:RegisterEvent("VARIABLES_LOADED");
58 end
59  
60 local ntmysFLT_PLW_Time = nil;
61  
62 function ntmysFLT_OnEvent()
63 if(event == "VARIABLES_LOADED") then
64 ntmysFLT_setMode();
65 end
66 if(event == "PLAYER_ENTERING_WORLD") then
67 if(not ntmysFLT_PLW_Time) then return; end -- first time entering world
68  
69 if(ntmysFLT_isActive == 1 or ntmysFLT_isActive == 2) then
70 ntmysFLT_RestoreOnEvents();
71 end
72  
73 if(ntmysFLT_isActive == 2) then return; end -- no messages
74  
75 local time = GetTime() - ntmysFLT_PLW_Time;
76 DEFAULT_CHAT_FRAME:AddMessage(NFLT_ZONECHANGE..(floor(time*10)/10).."s",1,0.8,0.2);
77  
78 if(ntmysFLT_isActive == 3) then return; end -- off, no events counted
79  
80 DEFAULT_CHAT_FRAME:AddMessage(NFLT_PROCEVENTS..ntmysFLT_PassedEvents.."/"..ntmysFLT_AllEvents,1,0.8,0.2);
81 end
82 if(event == "PLAYER_LEAVING_WORLD") then
83 ntmysFLT_PLW_Time = GetTime();
84 if(ntmysFLT_isActive == 3) then return; end -- off
85  
86 ntmysFLT_KillOnEvents();
87 end
88 end
89  
90 function ntmysFLT_setMode()
91 if(ntmysFLT_isActive > 0) then
92 ntmysFLT_Frame:RegisterEvent("PLAYER_ENTERING_WORLD");
93 ntmysFLT_Frame:RegisterEvent("PLAYER_LEAVING_WORLD");
94 else
95 ntmysFLT_Frame:UnregisterEvent("PLAYER_ENTERING_WORLD");
96 ntmysFLT_Frame:UnregisterEvent("PLAYER_LEAVING_WORLD");
97 end
98 end
99  
100 function ntmysFLT_KillOnEvents()
101 ntmysFLT_AllEvents = 0;
102 ntmysFLT_PassedEvents = 0;
103 local f = EnumerateFrames();
104 local OnEvent;
105 while f do
106 OnEvent = f:GetScript("OnEvent");
107 if(OnEvent) then
108 f.ntmysFLT_OnEvent = OnEvent;
109 -- some events still need to be checked
110 f:SetScript("OnEvent", function()
111 if(event == "PLAYER_ENTERING_WORLD" or
112 event == "PLAYER_TARGET_CHANGED" or
113 event == "PLAYER_LOGOUT" or
114 string.sub(event,0,4) == "CHAT") then
115 this.ntmysFLT_OnEvent();
116 ntmysFLT_PassedEvents = ntmysFLT_PassedEvents +1;
117 end
118 ntmysFLT_AllEvents = ntmysFLT_AllEvents +1;
119 end
120 );
121 end
122 f = EnumerateFrames(f);
123 end
124 end
125  
126 function ntmysFLT_RestoreOnEvents()
127 local f = EnumerateFrames();
128 while f do
129 if(f.ntmysFLT_OnEvent) then
130 f:SetScript("OnEvent",f.ntmysFLT_OnEvent);
131 f.ntmysFLT_OnEvent = nil;
132 end
133 f = EnumerateFrames(f);
134 end
135 end