vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | |
2 | ------------------------------ |
||
3 | -- Are you local? -- |
||
4 | ------------------------------ |
||
5 | |||
6 | local L = AceLibrary("AceLocale-2.0"):new("FuBar_Mail") |
||
7 | local Tablet = AceLibrary("Tablet-2.0") |
||
8 | local Dewdrop = AceLibrary("Dewdrop-2.0") |
||
9 | |||
10 | local pendmail, checked |
||
11 | local files = { |
||
12 | iconnomail = "Interface\\AddOns\\FuBar_MailFu\\nomail.tga", |
||
13 | iconnew = "Interface\\AddOns\\FuBar_MailFu\\newmail.tga", |
||
14 | iconAH = "Interface\\AddOns\\FuBar_MailFu\\auction.tga", |
||
15 | soundpath = "Interface\\AddOns\\FuBar_MailFu\\mail.wav", |
||
16 | } |
||
17 | |||
18 | |||
19 | ---------------------------- |
||
20 | -- Localization -- |
||
21 | ---------------------------- |
||
22 | |||
23 | L:RegisterTranslations("enUS", function() return { |
||
24 | ["No mail"] = true, |
||
25 | ["New Mail"] = true, |
||
26 | ["AH Alert!"] = true, |
||
27 | |||
28 | ["New Mail Received (%d/%d)"] = true, |
||
29 | |||
30 | ttnew = " new mail items", |
||
31 | tttotal = " total mail items", |
||
32 | |||
33 | OUTBID = "Outbid: ", |
||
34 | WON = "Won: ", |
||
35 | EXPIRED = "Expired: ", |
||
36 | REMOVED = "Cancelled: ", |
||
37 | SOLD = "Sold: ", |
||
38 | |||
39 | minimap = true, |
||
40 | ["Default Minimap"] = true, |
||
41 | ["Show Blizzard's minimap icon"] = true, |
||
42 | |||
43 | chat = true, |
||
44 | ["Chat Alert"] = true, |
||
45 | ["Print a chat message when mail is received"] = true, |
||
46 | |||
47 | sound = true, |
||
48 | ["Use Sound"] = true, |
||
49 | ["Play a sound when mail is received"] = true, |
||
50 | |||
51 | textformat = true, |
||
52 | ["Text Format"] = true, |
||
53 | ["Bar text formatting"] = true, |
||
54 | both = true, |
||
55 | number = true, |
||
56 | text = true, |
||
57 | } end) |
||
58 | |||
59 | |||
60 | L:RegisterTranslations("frFR", function() return { |
||
61 | ["No mail"] = "Aucun courier", |
||
62 | ["New Mail"] = "Nouveau courier", |
||
63 | ["AH Alert!"] = "Alerte AH!", |
||
64 | } end) |
||
65 | |||
66 | |||
67 | L:RegisterTranslations("deDE", function() return { |
||
68 | ["No mail"] = "Keine Post ", |
||
69 | ["New Mail"] = "Neue Post ", |
||
70 | ["AH Alert!"] = "AH-Alarm! ", |
||
71 | |||
72 | ["New Mail Received (%d/%d)"] = "Neue Post erhalten (%d/%d)", |
||
73 | |||
74 | ttnew = " neue Nachrichten", |
||
75 | tttotal = " Nachrichten insgesamt", |
||
76 | |||
77 | OUTBID = "\195\156berboten: ", |
||
78 | WON = "Gewonnen: ", |
||
79 | EXPIRED = "Abgelaufen: ", |
||
80 | REMOVED = "Abgebrochen: ", |
||
81 | SOLD = "Verkauft: ", |
||
82 | |||
83 | ["Chat Alert"] = "Chat-Alarm", |
||
84 | ["Use Sound"] = "Sound verwenden", |
||
85 | } end) |
||
86 | |||
87 | |||
88 | ------------------------------------- |
||
89 | -- Namespace Declaration -- |
||
90 | ------------------------------------- |
||
91 | |||
92 | FuBar_Mail = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceConsole-2.0", "AceDB-2.0", "FuBarPlugin-2.0", "AceHook-2.0") |
||
93 | FuBar_Mail.hideWithoutStandby = true |
||
94 | FuBar_Mail.hasIcon = files.iconnomail |
||
95 | FuBar_Mail:RegisterDB("FuBar_MailDB", "FuBar_MailDBPC") |
||
96 | FuBar_Mail:RegisterDefaults("char", {new = 0, total = 0}) |
||
97 | FuBar_Mail:RegisterDefaults("profile", { |
||
98 | playsounds = true, |
||
99 | showminimap = false, |
||
100 | chatalerts = true, |
||
101 | textformat = "both", |
||
102 | showtext = true, |
||
103 | showcount = true, |
||
104 | }) |
||
105 | local opts = {type = "group", handler = FuBar_Mail, args = { |
||
106 | [L.minimap] = { |
||
107 | type = "toggle", name = L["Default Minimap"], desc = L["Show Blizzard's minimap icon"], order = 1, |
||
108 | get = function() return FuBar_Mail.db.profile.showminimap end, set = function(v) FuBar_Mail.db.profile.showminimap = v end, |
||
109 | }, |
||
110 | [L.sound] = { |
||
111 | type = "toggle", name = L["Use Sound"], desc = L["Play a sound when mail is received"], order = 1, |
||
112 | get = function() return FuBar_Mail.db.profile.playsounds end, set = function(v) FuBar_Mail.db.profile.playsounds = v end, |
||
113 | }, |
||
114 | [L.chat] = { |
||
115 | type = "toggle", name = L["Chat Alert"], desc = L["Print a chat message when mail is received"], order = 1, |
||
116 | get = function() return FuBar_Mail.db.profile.chatalerts end, set = function(v) FuBar_Mail.db.profile.chatalerts = v end, |
||
117 | }, |
||
118 | [L.textformat] = { |
||
119 | type = "text", |
||
120 | name = L["Text Format"], |
||
121 | desc = L["Bar text formatting"], |
||
122 | get = function() return FuBar_Mail.db.profile.textformat end, |
||
123 | set = function(v) FuBar_Mail.db.profile.textformat = v; FuBar_Mail:Update() end, |
||
124 | validate = {L["text"], L["number"], L["both"]}, |
||
125 | disabled = function() return not FuBar_Mail:IsTextShown() end, |
||
126 | }, |
||
127 | |||
128 | }} |
||
129 | FuBar_Mail:RegisterChatCommand({"/mailfu"}, opts) |
||
130 | FuBar_Mail.OnMenuRequest = opts |
||
131 | |||
132 | |||
133 | --------------------------- |
||
134 | -- Ace Methods -- |
||
135 | --------------------------- |
||
136 | |||
137 | function FuBar_Mail:OnEnable() |
||
138 | pendmail = 0 |
||
139 | |||
140 | self:RegisterEvent("SpecialEvents_MailReceived") |
||
141 | self:RegisterEvent("SpecialEvents_AHAlert") |
||
142 | self:RegisterEvent("SpecialEvents_MailInit", "Update") |
||
143 | self:RegisterEvent("AceEvent_FullyInitialized", "Update") |
||
144 | |||
145 | self:RegisterEvent("MAIL_SHOW") |
||
146 | self:RegisterEvent("MAIL_INBOX_UPDATE") |
||
147 | self:Hook(MiniMapMailFrame, "Show", "MMMailShow") |
||
148 | if not self.db.profile.showminimap and MiniMapMailFrame:IsVisible() then MiniMapMailFrame:Hide() end |
||
149 | end |
||
150 | |||
151 | |||
152 | function FuBar_Mail:MMMailShow(object) |
||
153 | if self.db.profile.showminimap then return self.hooks[object].Show.orig(object) end |
||
154 | end |
||
155 | |||
156 | |||
157 | function FuBar_Mail:MAIL_SHOW() |
||
158 | checked = true |
||
159 | self.db.char.ahalerts = nil |
||
160 | self:Update() |
||
161 | end |
||
162 | |||
163 | |||
164 | function FuBar_Mail:MAIL_INBOX_UPDATE() |
||
165 | self.db.char.new = 0 |
||
166 | self.db.char.total = GetInboxNumItems() |
||
167 | self:Update() |
||
168 | end |
||
169 | |||
170 | |||
171 | function FuBar_Mail:SpecialEvents_MailReceived() |
||
172 | pendmail = pendmail + 1 |
||
173 | self.db.char.new, self.db.char.total = self.db.char.new + 1, self.db.char.total + 1 |
||
174 | if checked then self.db.char.total = GetInboxNumItems() + self.db.char.new end |
||
175 | if self.db.profile.playsounds then PlaySoundFile(files.soundpath) end |
||
176 | if self.db.profile.chatalerts then self:Print(L["New Mail Received (%d/%d)"], self.db.char.new, self.db.char.total) end |
||
177 | |||
178 | self:Update() |
||
179 | end |
||
180 | |||
181 | |||
182 | function FuBar_Mail:SpecialEvents_AHAlert(ahtype, item) |
||
183 | if not self.db.char.ahalerts then self.db.char.ahalerts = {} end |
||
184 | table.insert(self.db.char.ahalerts, {L[ahtype], item}) |
||
185 | |||
186 | self:Update() |
||
187 | end |
||
188 | |||
189 | |||
190 | function FuBar_Mail:OnTextUpdate() |
||
191 | -- self.hasNoText = self:IsIconShown() and not self.db.profile.showtext and not self.db.profile.showcount |
||
192 | local showt = self.db.profile.textformat == L.both or self.db.profile.textformat == L.text |
||
193 | local showc = self.db.profile.textformat == L.both or self.db.profile.textformat == L.number |
||
194 | local hasmail = self.db.char.ahalerts or self.db.char.total > 0 or (HasNewMail() and not checked) |
||
195 | local numstr = (self.db.char.total > 0) and string.format(showt and "(%u/%u)" or "%u/%u", self.db.char.new, self.db.char.total) or showt and "(0)" or "0" |
||
196 | local colorstr = self.db.char.ahalerts and "|cffff0000" or hasmail and "|cff00ff00" or "" |
||
197 | local txtstr = self.db.char.ahalerts and L["AH Alert!"] or hasmail and L["New Mail"] or L["No mail"] |
||
198 | |||
199 | self:SetText(colorstr.. (showt and txtstr or "").. (showt and showc and " " or "").. (showc and numstr or "")) |
||
200 | self:SetIcon(self.db.char.ahalerts and files.iconAH or hasmail and files.iconnew or files.iconnomail) |
||
201 | end |
||
202 | |||
203 | |||
204 | function FuBar_Mail:OnTooltipUpdate() |
||
205 | local hasmail = self.db.char.ahalerts or self.db.char.total > 0 or (HasNewMail() and not checked) |
||
206 | local colorstr = self.db.char.ahalerts and "|cffff0000" or hasmail and "|cff00ff00" or "" |
||
207 | local txtstr = self.db.char.ahalerts and L["AH Alert!"] or hasmail and L["New Mail"] or L["No mail"] |
||
208 | |||
209 | Tablet:SetTitle(colorstr..txtstr) |
||
210 | |||
211 | local cat = Tablet:AddCategory("columns", 2) |
||
212 | cat:AddLine("text", "New", "text2", self.db.char.new or "No data", "textR", 0, "textG", 1, "textB", 0, "text2R", 0, "text2G", 1, "text2B", 0) |
||
213 | cat:AddLine("text", "Total", "text2", self.db.char.total) |
||
214 | if self.db.char.ahalerts then |
||
215 | cat = Tablet:AddCategory("text", "Auction Alerts", "isTitle", true, "justify", "CENTER") |
||
216 | cat = Tablet:AddCategory("hideBlankLine", true, "columns", 2, "child_textR", 1, "child_textG", 0, "child_textB", 0, "child_text2R", 1, "child_text2G", 0, "child_text2B", 0) |
||
217 | for _,val in ipairs(self.db.char.ahalerts) do cat:AddLine("text", val[1], "text2", val[2]) end |
||
218 | end |
||
219 | end |
||
220 | |||
221 |