vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | OmniCC_Min |
||
3 | Simplified version of OmniCC |
||
4 | --]] |
||
5 | |||
6 | --[[ |
||
7 | To use this setting, you must remove the saved variables entry from the TOC file. |
||
8 | --]] |
||
9 | OmniCC = { |
||
10 | min = 3, --minimum duration to show text |
||
11 | font = STANDARD_TEXT_FONT, --cooldown text font |
||
12 | size = 20, --cooldown text size |
||
13 | } |
||
14 | |||
15 | --returns the formatted time with the appropiate scale and color |
||
16 | local function GetFormattedTime(time) |
||
17 | if (time > 86400) then |
||
18 | return ( math.floor((time / 86400 + 1)) .. DAY_ONELETTER_ABBR ); |
||
19 | elseif (time >= 3600) then |
||
20 | return ( math.floor((time / 3600 + 1)) .. HOUR_ONELETTER_ABBR ); |
||
21 | elseif (time >= 60) then |
||
22 | return ( math.floor((time / 60 + 1)) .. MINUTE_ONELETTER_ABBR ); |
||
23 | elseif (time > 5) then |
||
24 | return math.floor(time + 1); |
||
25 | end |
||
26 | return math.floor(time + 1); |
||
27 | end |
||
28 | |||
29 | --[[ |
||
30 | Constructor |
||
31 | --]] |
||
32 | |||
33 | local function CreateCooldownCount(cooldown, start, duration) |
||
34 | cooldown.textFrame = CreateFrame("Frame", nil, cooldown:GetParent()); |
||
35 | cooldown.textFrame:SetAllPoints(cooldown:GetParent()); |
||
36 | cooldown.textFrame:SetFrameLevel(cooldown.textFrame:GetFrameLevel() + 1); |
||
37 | |||
38 | cooldown.textFrame.text = cooldown.textFrame:CreateFontString(nil, "OVERLAY"); |
||
39 | cooldown.textFrame.text:SetFont(OmniCC.font , OmniCC.size, "OUTLINE"); |
||
40 | cooldown.textFrame.text:SetTextColor(1, 1, 0.2); |
||
41 | cooldown.textFrame.text:SetPoint("CENTER", cooldown.textFrame, "CENTER", 0, 1); |
||
42 | |||
43 | --[[ |
||
44 | OmniCC hides the text cooldown if the icon the button is hidden or not. |
||
45 | This makes it a bit more dependent on other mods as far as their icon format goes. |
||
46 | Its the only way I can think of to absolutely make sure that the text cooldown is hidden properly. |
||
47 | --]] |
||
48 | cooldown.textFrame.icon = |
||
49 | --standard action button icon, $parentIcon |
||
50 | getglobal(cooldown:GetParent():GetName() .. "Icon") or |
||
51 | --standard item button icon, $parentIconTexture |
||
52 | getglobal(cooldown:GetParent():GetName() .. "IconTexture") or |
||
53 | --discord action button, $parent_Icon |
||
54 | getglobal(cooldown:GetParent():GetName() .. "_Icon"); |
||
55 | |||
56 | if(cooldown.textFrame.icon) then |
||
57 | cooldown.textFrame:SetScript("OnUpdate", OmniCC_OnUpdate); |
||
58 | end |
||
59 | |||
60 | cooldown.textFrame:Hide(); |
||
61 | end |
||
62 | --[[ |
||
63 | OnX functions |
||
64 | --]] |
||
65 | |||
66 | function OmniCC_OnUpdate() |
||
67 | local remain = this.duration - (GetTime() - this.start); |
||
68 | if( remain >= 0 and this.icon:IsVisible() ) then |
||
69 | this.text:SetText( GetFormattedTime( remain ) ); |
||
70 | else |
||
71 | this:Hide(); |
||
72 | end |
||
73 | end |
||
74 | |||
75 | --[[ |
||
76 | Function Overrides |
||
77 | --]] |
||
78 | function CooldownFrame_SetTimer(this, start, duration, enable) |
||
79 | if ( start > 0 and duration > 0 and enable > 0) then |
||
80 | this.start = start; |
||
81 | this.duration = duration; |
||
82 | this.stopping = 0; |
||
83 | this:SetSequence(0); |
||
84 | this:Show(); |
||
85 | |||
86 | --show cooldown text if the duration exceeds the minimum duration to show text |
||
87 | if( duration > OmniCC.min ) then |
||
88 | if( not this.textFrame ) then |
||
89 | CreateCooldownCount(this, start, duration); |
||
90 | end |
||
91 | this.textFrame.start = start; |
||
92 | this.textFrame.duration = duration; |
||
93 | this.textFrame:Show(); |
||
94 | elseif( this.textFrame ) then |
||
95 | this.textFrame:Hide(); |
||
96 | end |
||
97 | else |
||
98 | this:Hide(); |
||
99 | end |
||
100 | end |