View Single Post
04-07-12, 12:56 PM   #18
MiRai
A Warpwood Thunder Caller
Join Date: Jul 2011
Posts: 96
Looking at the 4.3.3.15354 files from go-hero.net, I found that Timer.lua and Timer.xml both hold the term TimerTracker in them.

I've also made a post on the WoW Macro & UI forums to see what feedback I would get from there.

http://us.battle.net/wow/en/forum/topic/4362521168

Timer.lua
lua Code:
  1. TIMER_MINUTES_DISPLAY = "%d:%02d"
  2.  
  3. TIMER_MEDIUM_MARKER = 11;
  4. TIMER_LARGE_MARKER = 6;
  5. TIMER_UPDATE_INTERVAL = 10;
  6.  
  7. TIMER_NUMBERS_SETS = {};
  8. TIMER_NUMBERS_SETS["BigGold"]  = {  texture = "Interface\\Timer\\BigTimerNumbers",
  9.                                     w=256, h=170, texW=1024, texH=512,
  10.                                     numberHalfWidths = {
  11.                                         --0,   1,   2,   3,   4,   5,   6,   7,   8,   9,
  12.                                         35/128, 14/128, 33/128, 32/128, 36/128, 32/128, 33/128, 29/128, 31/128, 31/128,
  13.                                     }
  14.                                 }
  15.  
  16.  
  17. function TimerTracker_OnLoad(self)
  18.     self.timerList = {};
  19.     self:RegisterEvent("START_TIMER");
  20.     self:RegisterEvent("PLAYER_ENTERING_WORLD");
  21. end
  22.  
  23.  
  24. function StartTimer_OnShow(self)
  25.     self.time = self.endTime - GetTime();
  26.     if self.time <= 0 then
  27.         self:Hide();
  28.         self.isFree = true;
  29.     elseif self.startNumbers:IsPlaying() then
  30.         self.startNumbers:Stop();
  31.         self.startNumbers:Play();
  32.     end
  33. end
  34.  
  35. function GetPlayerFactionGroup()
  36.     local factionGroup = UnitFactionGroup("player");
  37.     -- this might be a rated BG or wargame and if so the player's faction might be altered
  38.     if ( not IsActiveBattlefieldArena() ) then
  39.         factionGroup = PLAYER_FACTION_GROUP[GetBattlefieldArenaFaction()];
  40.     end
  41.    
  42.     return factionGroup
  43. end
  44.  
  45. function TimerTracker_OnEvent(self, event, ...)
  46.    
  47.     if event == "START_TIMER" then
  48.         local timerType, timeSeconds, totalTime  = ...;
  49.         local timer;
  50.         local numTimers = 0;
  51.         local isTimerRuning = false;
  52.        
  53.         for a,b in pairs(self.timerList) do
  54.             if b.type == timerType and not b.isFree then
  55.                 timer = b;
  56.                 isTimerRuning = true;
  57.                 break;
  58.             end
  59.         end
  60.  
  61.         if isTimerRuning then
  62.             -- don't interupt the final count down
  63.             if not timer.startNumbers:IsPlaying() then
  64.                 timer.time = timeSeconds;
  65.             end
  66.            
  67.             local factionGroup = GetPlayerFactionGroup();
  68.  
  69.             if ( not timer.factionGroup or (timer.factionGroup ~= factionGroup) ) then
  70.                 timer.faction:SetTexture("Interface\\Timer\\"..factionGroup.."-Logo");
  71.                 timer.factionGlow:SetTexture("Interface\\Timer\\"..factionGroup.."Glow-Logo");
  72.                 timer.factionGroup = factionGroup;
  73.             end
  74.         else
  75.             for a,b in pairs(self.timerList) do
  76.                 if not timer and b.isFree then
  77.                     timer = b;
  78.                 else
  79.                     numTimers = numTimers + 1;
  80.                 end
  81.             end
  82.            
  83.            
  84.             if not timer then
  85.                 timer = CreateFrame("FRAME", self:GetName().."Timer"..(#self.timerList+1), UIParent, "StartTimerBar");
  86.                 self.timerList[#self.timerList+1] = timer;
  87.             end
  88.            
  89.            
  90.             timer:ClearAllPoints();
  91.             timer:SetPoint("TOP", 0, -155 - (24*numTimers));
  92.            
  93.             timer.isFree = false;
  94.             timer.type = timerType;
  95.             timer.time = timeSeconds;
  96.             timer.endTime = GetTime() + timeSeconds;
  97.             timer.bar:SetMinMaxValues(0, totalTime);
  98.             timer.style = TIMER_NUMBERS_SETS["BigGold"];
  99.            
  100.             timer.digit1:SetTexture(timer.style.texture);
  101.             timer.digit2:SetTexture(timer.style.texture);
  102.             timer.digit1:SetSize(timer.style.w/2, timer.style.h/2);
  103.             timer.digit2:SetSize(timer.style.w/2, timer.style.h/2);
  104.             --This is to compensate texture size not affecting GetWidth() right away.
  105.             timer.digit1.width, timer.digit2.width = timer.style.w/2, timer.style.w/2;
  106.            
  107.             timer.digit1.glow = timer.glow1;
  108.             timer.digit2.glow = timer.glow2;
  109.             timer.glow1:SetTexture(timer.style.texture.."Glow");
  110.             timer.glow2:SetTexture(timer.style.texture.."Glow");
  111.            
  112.             local factionGroup = GetPlayerFactionGroup();
  113.             if ( factionGroup ) then
  114.                 timer.faction:SetTexture("Interface\\Timer\\"..factionGroup.."-Logo");
  115.                 timer.factionGlow:SetTexture("Interface\\Timer\\"..factionGroup.."Glow-Logo");
  116.             end
  117.             timer.factionGroup = factionGroup;
  118.             timer.updateTime = TIMER_UPDATE_INTERVAL;
  119.             timer:SetScript("OnUpdate", StartTimer_BigNumberOnUpdate);
  120.             timer:Show();
  121.         end
  122.     elseif event == "PLAYER_ENTERING_WORLD" then
  123.         for a,timer in pairs(self.timerList) do
  124.             timer.time = nil;
  125.             timer.type = nil;
  126.             timer.isFree = nil;
  127.             timer:SetScript("OnUpdate", nil);
  128.             timer.fadeBarOut:Stop();
  129.             timer.fadeBarIn:Stop();
  130.             timer.startNumbers:Stop();
  131.             timer.factionAnim:Stop();
  132.             timer.bar:SetAlpha(0);
  133.         end
  134.     end
  135. end
  136.  
  137.  
  138. function StartTimer_BigNumberOnUpdate(self, elasped)
  139.     self.time = self.endTime - GetTime();
  140.     self.updateTime = self.updateTime - elasped;
  141.     local minutes, seconds = floor(self.time/60), floor(mod(self.time, 60));
  142.  
  143.    
  144.     if self.time < TIMER_MEDIUM_MARKER then
  145.         self.fadeBarOut:Play();
  146.         self.barShowing = false;
  147.         self.anchorCenter = false;
  148.         self:SetScript("OnUpdate", nil);
  149.     elseif not self.barShowing then
  150.         self.fadeBarIn:Play();
  151.         self.barShowing = true;
  152.     elseif self.updateTime <= 0 then
  153.         ValidateTimer(self.type);
  154.         self.updateTime = TIMER_UPDATE_INTERVAL;
  155.     end
  156.  
  157.     self.bar:SetValue(self.time);
  158.     self.bar.timeText:SetText(string.format(TIMER_MINUTES_DISPLAY, minutes, seconds));
  159. end
  160.  
  161.  
  162. function StartTimer_BarOnlyOnUpdate(self, elasped)
  163.     self.time = self.endTime - GetTime();
  164.     local minutes, seconds = floor(self.time/60), mod(self.time, 60);
  165.  
  166.     self.bar:SetValue(self.time);
  167.     self.bar.timeText:SetText(string.format(TIMER_MINUTES_DISPLAY, minutes, seconds));
  168.    
  169.     if self.time < 0 then
  170.         self:SetScript("OnUpdate", nil);
  171.         self.barShowing = false;
  172.         self.isFree = true;
  173.         self:Hide();
  174.     end
  175.    
  176.     if not self.barShowing then
  177.         self.fadeBarIn:Play();
  178.         self.barShowing = true;
  179.     end
  180. end
  181.  
  182.  
  183. function StartTimer_SetTexNumbers(self, ...)
  184.     local digits = {...}
  185.     local timeDigits = floor(self.time);
  186.     local digit;
  187.     local style = self.style;
  188.     local i = 1;
  189.    
  190.     local texCoW = style.w/style.texW;
  191.     local texCoH = style.h/style.texH;
  192.     local l,r,t,b;
  193.     local columns = floor(style.texW/style.w);
  194.     local numberOffset = 0;
  195.     local numShown = 0;
  196.    
  197.     while digits[i] do -- THIS WILL DISPLAY SECOND AS A NUMBER 2:34 would be 154
  198.         if timeDigits > 0 then
  199.             digit = mod(timeDigits, 10);
  200.            
  201.             digits[i].hw = style.numberHalfWidths[digit+1]*digits[i].width;
  202.             numberOffset  = numberOffset + digits[i].hw;
  203.            
  204.             l = mod(digit, columns) * texCoW;
  205.             r = l + texCoW;
  206.             t = floor(digit/columns) * texCoH;
  207.             b = t + texCoH;
  208.             digits[i]:SetTexCoord(l,r,t,b);
  209.             digits[i].glow:SetTexCoord(l,r,t,b);
  210.            
  211.             timeDigits = floor(timeDigits/10); 
  212.             numShown = numShown + 1;           
  213.         else
  214.             digits[i]:SetTexCoord(0,0,0,0);
  215.             digits[i].glow:SetTexCoord(0,0,0,0);
  216.         end
  217.         i = i + 1;
  218.     end
  219.    
  220.    
  221.     if numberOffset > 0 then
  222.         PlaySoundKitID(25477, "SFX", false);
  223.         digits[1]:ClearAllPoints();
  224.         if self.anchorCenter then
  225.             digits[1]:SetPoint("CENTER", UIParent, "CENTER", numberOffset - digits[1].hw, 0);
  226.         else
  227.             digits[1]:SetPoint("CENTER", self, "CENTER", numberOffset - digits[1].hw, 0);
  228.         end
  229.        
  230.         for i=2,numShown do
  231.             digits[i]:ClearAllPoints();
  232.             digits[i]:SetPoint("CENTER", digits[i-1], "CENTER", -(digits[i].hw + digits[i-1].hw), 0)
  233.             i = i + 1;
  234.         end
  235.     end
  236. end
  237.  
  238.  
  239.  
  240. function StartTimer_NumberAnimOnFinished(self)
  241.     self.time = self.time - 1;
  242.     if self.time > 0 then
  243.         if self.time < TIMER_LARGE_MARKER then
  244.             if not self.anchorCenter then
  245.                 self.anchorCenter = true;
  246.                 --This is to compensate texture size not affecting GetWidth() right away.
  247.                 self.digit1.width, self.digit2.width = self.style.w, self.style.w;
  248.                 self.digit1:SetSize(self.style.w, self.style.h);
  249.                 self.digit2:SetSize(self.style.w, self.style.h);
  250.             end
  251.         end
  252.    
  253.         self.startNumbers:Play();
  254.     else
  255.         self.isFree = true;
  256.         PlaySoundKitID(25478);
  257.         self.factionAnim:Play();
  258.     end
  259. end


Timer.xml
xml Code:
  1. <Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
  2. ..\FrameXML\UI.xsd">
  3.     <Script file="Timer.lua"/>
  4.  
  5.    
  6.     <Frame name="StartTimerBar" virtual="true" hidden="true">
  7.         <Animations>
  8.             <AnimationGroup parentKey="fadeBarIn">
  9.                 <Alpha target="$parentStatusBar" change="1.0" duration="1.9" order="1"/>
  10.                 <Scripts>
  11.                     <OnPlay>
  12.                         local frame = self:GetParent();
  13.                         frame.bar:SetAlpha(0);
  14.                     </OnPlay>
  15.                     <OnFinished>
  16.                         local frame = self:GetParent();
  17.                         frame.bar:SetAlpha(1);
  18.                     </OnFinished>
  19.                 </Scripts>
  20.             </AnimationGroup>
  21.             <AnimationGroup parentKey="fadeBarOut">
  22.                 <Alpha target="$parentStatusBar" change="-1.0" duration="0.9" order="1"/>
  23.                 <Scripts>
  24.                     <OnFinished>
  25.                         local frame = self:GetParent();
  26.                         frame.bar:SetAlpha(0);
  27.                         -- Subtract this animations time
  28.                         frame.time = frame.time - 0.9
  29.                         frame.startNumbers:Play();
  30.                     </OnFinished>
  31.                 </Scripts>
  32.             </AnimationGroup>
  33.            
  34.             <AnimationGroup parentKey="startNumbers">
  35.                 <Scale target="$parentDigit1" scaleX="0.25" scaleY="0.25" duration="0.0" order="1"/>
  36.                 <Scale target="$parentDigit2" scaleX="0.25" scaleY="0.25" duration="0.0" order="1"/>
  37.                 <Scale target="$parentGlow1" scaleX="0.25" scaleY="0.25" duration="0.0" order="1"/>
  38.                 <Scale target="$parentGlow2" scaleX="0.25" scaleY="0.25" duration="0.0" order="1"/>
  39.                 <Alpha target="$parentDigit1" change="1"                duration="0.0" order="1"/>
  40.                 <Alpha target="$parentDigit2" change="1"                duration="0.0" order="1"/>
  41.                 <Alpha target="$parentGlow1" change="1"                 duration="0.0" order="1"/>
  42.                 <Alpha target="$parentGlow2" change="1"                 duration="0.0" order="1"/>
  43.                
  44.                
  45.                 <Scale target="$parentDigit1" scaleX="4" scaleY="4" duration="0.3" smoothing="OUT" order="2"/>
  46.                 <Scale target="$parentDigit2" scaleX="4" scaleY="4" duration="0.3" smoothing="OUT" order="2"/>
  47.                 <Scale target="$parentGlow1" scaleX="4" scaleY="4" duration="0.3" smoothing="OUT" order="2"/>
  48.                 <Scale target="$parentGlow2" scaleX="4" scaleY="4" duration="0.3" smoothing="OUT" order="2"/>
  49.                 <Alpha target="$parentGlow1" change="-1.0"          duration="0.3" smoothing="IN" order="2"/>
  50.                 <Alpha target="$parentGlow2" change="-1.0"          duration="0.3" smoothing="IN" order="2"/>
  51.                
  52.                
  53.                 <Scale target="$parentDigit1" startDelay="0.6" scaleX="1.2" scaleY="1.2"    duration="0.1" order="3"/>
  54.                 <Scale target="$parentDigit2" startDelay="0.6" scaleX="1.2" scaleY="1.2"    duration="0.1" order="3"/>
  55.                 <Alpha target="$parentDigit1" startDelay="0.6" change="-1.0"            duration="0.1" order="3"/>
  56.                 <Alpha target="$parentDigit2" startDelay="0.6" change="-1.0"            duration="0.1" order="3"/>
  57.                 <Scripts>
  58.                     <OnPlay>
  59.                         local frame = self:GetParent();
  60.                         StartTimer_SetTexNumbers(frame, frame.digit1, frame.digit2)
  61.                     </OnPlay>
  62.                     <OnFinished>
  63.                         local frame = self:GetParent();
  64.                         StartTimer_NumberAnimOnFinished(frame)
  65.                     </OnFinished>
  66.                 </Scripts>
  67.             </AnimationGroup>
  68.            
  69.             <AnimationGroup parentKey="factionAnim">
  70.                 <Scale target="$parentFaction"      scaleX="0.25" scaleY="0.25" duration="0.0" order="1"/>
  71.                 <Scale target="$parentFactionGlow"  scaleX="0.25" scaleY="0.25" duration="0.0" order="1"/>
  72.                
  73.                 <Alpha target="$parentFaction"      change="1"                  duration="0.0" order="2"/>
  74.                 <Alpha target="$parentFactionGlow"  change="1"                  duration="0.0" order="2"/>
  75.                
  76.                
  77.                 <Scale target="$parentFaction"      scaleX="4" scaleY="4"   duration="0.4" smoothing="OUT" order="3"/>
  78.                 <Scale target="$parentFactionGlow"  scaleX="4" scaleY="4"   duration="0.4" smoothing="OUT" order="3"/>
  79.                 <Alpha target="$parentFactionGlow"  change="-1.0"           duration="0.4" smoothing="IN" order="3"/>
  80.                
  81.                
  82.                 <Scale target="$parentFaction" startDelay="0.6" scaleX="1.4" scaleY="1.4"   duration="0.2" smoothing="OUT" order="4"/>
  83.                 <Alpha target="$parentFaction" startDelay="0.6" change="-1.0"               duration="0.2" smoothing="OUT" order="4"/>
  84.             </AnimationGroup>
  85.         </Animations>
  86.         <Size x="206" y="26"/>
  87.         <Layers>
  88.             <Layer level="OVERLAY">
  89.                 <Texture name="$parentDigit1" parentKey="digit1" alpha="0"/>
  90.                 <Texture name="$parentDigit2" parentKey="digit2" alpha="0"/>
  91.                 <Texture name="$parentFaction" parentKey="faction" alpha="0">
  92.                     <Size x="256" y="256"/>
  93.                     <Anchors>
  94.                         <Anchor point="CENTER" relativeTo="UIParent" x="0" y="0"/>
  95.                     </Anchors>
  96.                 </Texture>
  97.             </Layer>
  98.             <Layer level="OVERLAY" textureSubLevel="2">
  99.                 <Texture name="$parentGlow1" parentKey="glow1" alpha="0">
  100.                     <Anchors>
  101.                         <Anchor point="TOPLEFT" relativeTo="$parentDigit1" x="0" y="0"/>
  102.                         <Anchor point="BOTTOMRIGHT" relativeTo="$parentDigit1" x="0" y="0"/>
  103.                     </Anchors>
  104.                 </Texture>
  105.                 <Texture name="$parentGlow2" parentKey="glow2" alpha="0">
  106.                     <Anchors>
  107.                         <Anchor point="TOPLEFT" relativeTo="$parentDigit2" x="0" y="0"/>
  108.                         <Anchor point="BOTTOMRIGHT" relativeTo="$parentDigit2" x="0" y="0"/>
  109.                     </Anchors>
  110.                 </Texture>
  111.                 <Texture name="$parentFactionGlow" parentKey="factionGlow" alpha="0">
  112.                     <Anchors>
  113.                         <Anchor point="TOPLEFT" relativeTo="$parentFaction" x="0" y="0"/>
  114.                         <Anchor point="BOTTOMRIGHT" relativeTo="$parentFaction" x="0" y="0"/>
  115.                     </Anchors>
  116.                 </Texture>
  117.             </Layer>
  118.         </Layers>
  119.         <Frames>
  120.             <StatusBar name="$parentStatusBar" useParentLevel="true" parentKey="bar" alpha="0">
  121.                 <Size x="195" y="13"/>
  122.                 <Anchors>
  123.                     <Anchor point="TOP" x="0" y="-2"/>
  124.                 </Anchors>
  125.                 <Layers>
  126.                     <Layer level="BACKGROUND">
  127.                         <Texture>
  128.                             <Size x="195" y="13"/>
  129.                             <Anchors>
  130.                                 <Anchor point="TOP" x="0" y="-2"/>
  131.                             </Anchors>
  132.                             <Color r="0" g="0" b="0" a="0.5"/>
  133.                         </Texture>     
  134.                     </Layer>
  135.                     <Layer level="OVERLAY">
  136.                         <Texture name="$parentBorder" file="Interface\CastingBar\UI-CastingBar-Border">
  137.                             <Size x="256" y="64"/>
  138.                             <Anchors>
  139.                                 <Anchor point="TOP" x="0" y="25"/>
  140.                             </Anchors>
  141.                         </Texture>
  142.                         <FontString name="$parentTimeText" inherits="GameFontHighlight" justifyH="CENTER" parentKey="timeText">
  143.                             <Size x="0" y="9"/>
  144.                             <Anchors>
  145.                                 <Anchor point="CENTER" x="0" y="0"/>
  146.                             </Anchors>
  147.                         </FontString>
  148.                     </Layer>
  149.                 </Layers>
  150.                 <BarTexture file="Interface\TargetingFrame\UI-StatusBar"/>
  151.                 <BarColor r="1" g="0.0" b="0.0" />
  152.             </StatusBar>
  153.         </Frames>
  154.         <Scripts>
  155.             <OnShow function="StartTimer_OnShow"/>
  156.         </Scripts>
  157.     </Frame>
  158.    
  159.     <Frame name="TimerTracker" toplevel="true" parent="UIParent" hidden="true">
  160.         <Size x="0" y="0"/>
  161.         <Anchors>
  162.             <Anchor point="BOTTOMLEFT" x="0" y="0"/>
  163.         </Anchors>
  164.         <Scripts>
  165.             <OnLoad function="TimerTracker_OnLoad"/>
  166.             <OnEvent function="TimerTracker_OnEvent"/>
  167.         </Scripts>
  168.     </Frame>
  169. </Ui>

Last edited by MiRai : 04-07-12 at 12:59 PM.
  Reply With Quote