vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local Tablet = AceLibrary("Tablet-2.0") -- Nice Tooltips
2 local Dewdrop = AceLibrary("Dewdrop-2.0") -- and Menus
3 local L = AceLibrary("AceLocale-2.0"):new("KCIFu")
4  
5 KCIFu = AceLibrary("AceAddon-2.0"):new("AceDB-2.0","FuBarPlugin-2.0")
6  
7 KCIFu.version = "2.0"
8 KCIFu.date = "2006-09-08"
9 KCIFu.hasIcon = true
10 KCIFu.cannotDetachTooltip = true
11 KCIFu.cannotAttachToMinimap = true
12  
13 KCIFu:RegisterDB("KCIFuDB")
14 KCIFu:RegisterDefaults("profile", {
15 UseShortCaption = false
16 })
17  
18 function KCIFu:UseShortCaption ()
19 return self.db.profile.UseShortCaption
20 end
21  
22 function KCIFu:ToggleCaption ()
23 self.db.profile.UseShortCaption = not self.db.profile.UseShortCaption
24 self:Update()
25 end
26  
27 function KCIFu:OnTextUpdate()
28 if self:UseShortCaption() then
29 self:SetText(L["ShortCaption"])
30 else
31 self:SetText(L["Caption"])
32 end
33 end
34  
35 function KCIFu:OnClick()
36 if KC_Linkview ~= nil then
37 KC_Linkview:show()
38 end
39 end
40  
41 function KCIFu:OnTooltipUpdate()
42 -- With 2 Columns, Left values - yellow, right - white
43 local TipCategory = Tablet:AddCategory("text", L["Stats"], "columns", 2,
44 'child_textR', 1,'child_textG', 1,'child_textB', 0,
45 'child_text2R', 1,'child_text2G', 1,'child_text2B', 1
46 )
47 local _,sSubCount,_,_,sSellPercent,sBuyPercent = KC_Common:Explode(KC_Common.app.db:get("stats"), ",")
48 if (type(sSellPercent) ~= "string") then
49 TipCategory:AddLine('text', L["Stats_Items"] , 'text2', sSubCount)
50 TipCategory:AddLine('text', L["Stats_Sell"] , 'text2', format('%s (%s%%)',floor(sSubCount * (sSellPercent/100)), sSellPercent))
51 TipCategory:AddLine('text', L["Stats_Buy"] , 'text2', format('%s (%s%%)',floor(sSubCount * (sBuyPercent/100)), sBuyPercent))
52 else
53 TipCategory:AddLine('text', L["Stats_NoItems"])
54 end
55 if ( KC_Linkview ~= nil ) then
56 Tablet:SetHint(L["ClickTooltip"]);
57 end
58 end
59  
60  
61 function KCIFu:OnMenuRequest(mLevel,mValue)
62 if mLevel == 1 then
63 -- Primary Items
64 if KC_Auction ~= nil then
65 Dewdrop:AddLine("text", L["Menu_Auction"], "hasArrow", true, "value", "Menu_Auction")
66 end
67 if KC_Broker ~= nil then
68 Dewdrop:AddLine("text", L["Menu_Broker"] , "hasArrow", true, "value", "Menu_Broker")
69 end
70 if KC_ChatLink ~= nil then
71 Dewdrop:AddLine("text", L["Menu_ChatLink"], "hasArrow", true, "value", "Menu_ChatLink")
72 end
73 if KC_ItemInfo ~= nil then
74 Dewdrop:AddLine("text", L["Menu_ItemInfo"], "hasArrow", true, "value", "Menu_ItemInfo")
75 end
76 if KC_Tooltip ~= nil then
77 Dewdrop:AddLine("text", L["Menu_Tooltip"], "hasArrow", true, "value", "Menu_Tooltip")
78 end
79 if KC_SellValue ~= nil then
80 Dewdrop:AddLine("text", L["Menu_SellValue"], "hasArrow", true, "value", "Menu_SellValue")
81 end
82  
83 Dewdrop:AddLine()
84 Dewdrop:AddLine("text", L["UseShortCaption"], "arg1", KCIFu, "func", "ToggleCaption", "checked", self:UseShortCaption())
85 Dewdrop:AddLine()
86  
87 elseif mLevel == 2 then
88 if mValue == "Menu_Auction" then
89 -- Auction Module Settings
90 Dewdrop:AddLine("text", L["Menu_Auction_Short"],
91 "arg1", KC_Auction,
92 "func", "short",
93 "checked", (KC_Auction:GetOpt(KC_Auction.optPath, "short") == 1))
94 Dewdrop:AddLine("text", L["Menu_Auction_Bid"],
95 "arg1", KC_Auction,
96 "func", "showbid",
97 "checked", (KC_Auction:GetOpt(KC_Auction.optPath, "showbid") == 1))
98 Dewdrop:AddLine("text", L["Menu_Auction_Stats"],
99 "arg1", KC_Auction,
100 "func", "showstats",
101 "checked", (KC_Auction:GetOpt(KC_Auction.optPath, "showstats") == 1))
102 elseif mValue == "Menu_Broker" then
103 Dewdrop:AddLine("text", L["Menu_Broker_AF"],
104 "arg1", KC_Broker,
105 "func", "TogAutofill",
106 "checked", (KC_Broker:GetOpt(KC_Broker.optPath, "autofill") == 1))
107 --Dewdrop:AddLine()
108 Dewdrop:AddLine("text",L["Menu_Broker_AF_Mode"],
109 "isTitle", true,
110 "disabled", (KC_Broker:GetOpt(KC_Broker.optPath, "autofill") ~= 1))
111 Dewdrop:AddLine("text",L["Menu_Broker_AF_Mixed"],
112 "isRadio", true,
113 "disabled", (KC_Broker:GetOpt(KC_Broker.optPath, "autofill") ~= 1),
114 "checked", (KC_Broker:GetOpt(KC_Broker.optPath, "fillmode") == KC_ITEMS_LOCALS.modules.broker.modes.mixed),
115 "arg1", KC_Broker,
116 "func", "SetMode",
117 "arg2", "mixed")
118 Dewdrop:AddLine("text",L["Menu_Broker_AF_Memory"],
119 "isRadio", true,
120 "disabled", (KC_Broker:GetOpt(KC_Broker.optPath, "autofill") ~= 1),
121 "checked", (KC_Broker:GetOpt(KC_Broker.optPath, "fillmode") == KC_ITEMS_LOCALS.modules.broker.modes.memory),
122 "arg1", KC_Broker,
123 "func", "SetMode",
124 "arg2", "memory")
125 Dewdrop:AddLine("text",L["Menu_Broker_AF_Smart"],
126 "isRadio", true,
127 "disabled", (KC_Broker:GetOpt(KC_Broker.optPath, "autofill") ~= 1),
128 "checked", (KC_Broker:GetOpt(KC_Broker.optPath, "fillmode") == KC_ITEMS_LOCALS.modules.broker.modes.smart),
129 "arg1", KC_Broker,
130 "func", "SetMode",
131 "arg2", "smart")
132 Dewdrop:AddLine("text",L["Menu_Broker_AF_Vendor"],
133 "isRadio", true,
134 "disabled", (KC_Broker:GetOpt(KC_Broker.optPath, "autofill") ~= 1),
135 "checked", (KC_Broker:GetOpt(KC_Broker.optPath, "fillmode") == KC_ITEMS_LOCALS.modules.broker.modes.vendor),
136 "arg1", KC_Broker,
137 "func", "SetMode",
138 "arg2", "vendor")
139 Dewdrop:AddLine("text",L["Menu_Broker_AF_None"],
140 "isRadio", true,
141 "disabled", (KC_Broker:GetOpt(KC_Broker.optPath, "autofill") ~= 1),
142 "checked", (KC_Broker:GetOpt(KC_Broker.optPath, "fillmode") == KC_ITEMS_LOCALS.modules.broker.modes.none),
143 "arg1", KC_Broker,
144 "func", "SetMode",
145 "arg2", "none")
146 Dewdrop:AddLine("text", L["Menu_Broker_Cut"],
147 "hasSlider" , true, "hasArrow", true,
148 "disabled", (KC_Broker:GetOpt(KC_Broker.optPath, "autofill") ~= 1) or ((KC_Broker:GetOpt(KC_Broker.optPath, "fillmode") ~= KC_ITEMS_LOCALS.modules.broker.modes.mixed) and (KC_Broker:GetOpt(KC_Broker.optPath, "fillmode") ~= KC_ITEMS_LOCALS.modules.broker.modes.smart)),
149 "sliderMin", 50,
150 "sliderMax", 150,
151 "sliderValue", ((KC_Broker:GetOpt(KC_Broker.optPath, "cut") or 1) * 100),
152 "sliderFunc", function(value)
153 -- suppress multiple messages
154 KC_Broker:SetOpt(KC_Broker.optPath,"cut", floor(value) / 100)
155 end)
156 Dewdrop:AddLine("text", L["Menu_Broker_AF_SkipMem"],
157 "arg1", KC_Broker,
158 "func", "SkipMem",
159 -- Disabled when Autofill Off or Mode not Mixed
160 "disabled", (KC_Broker:GetOpt(KC_Broker.optPath, "autofill") ~= 1) or (KC_Broker:GetOpt(KC_Broker.optPath, "fillmode") ~= KC_ITEMS_LOCALS.modules.broker.modes.mixed),
161 "checked", (KC_Broker:GetOpt(KC_Broker.optPath, "skipmem") == 1))
162  
163 Dewdrop:AddLine()
164 Dewdrop:AddLine("text", L["Menu_Broker_Remdur"],
165 "checked", (KC_Broker:GetOpt(KC_Broker.optPath, "remduration") == 1),
166 "arg1", KC_Broker,
167 "func", "RememberDuration")
168  
169 Dewdrop:AddLine()
170 Dewdrop:AddLine("text", L["Menu_Broker_Colorize"],
171 "checked", KC_Broker:GetOpt(KC_Broker.optPath,"ahcolor"),
172 "arg1", KC_Broker,
173 "func", "AHColor")
174 Dewdrop:AddLine("text", L["Menu_Broker_AHColors"],
175 "isTitle", true,
176 "disabled", not KC_Broker:GetOpt(KC_Broker.optPath,"ahcolor") )
177  
178 -- get colors
179 local knownColor = {KC_Broker.common:Explode(KC_Broker:GetOpt(KC_Broker.optPath, "knownColor") or ".1!.1!1", "!")}
180 local sellColor = {KC_Broker.common:Explode(KC_Broker:GetOpt(KC_Broker.optPath, "sellColor") or "1!.5!.8", "!")}
181 local buyColor = {KC_Broker.common:Explode(KC_Broker:GetOpt(KC_Broker.optPath, "buyColor") or "1!1!0", "!")}
182 local minColor = {KC_Broker.common:Explode(KC_Broker:GetOpt(KC_Broker.optPath, "minColor") or "0!.8!1", "!")}
183 -- Known Color
184  
185 Dewdrop:AddLine("text", L["Menu_Broker_AHC_Known"],
186 "hasColorSwatch", true,
187 "disabled", not KC_Broker:GetOpt(KC_Broker.optPath,"ahcolor"),
188 "r", knownColor[1], "g", knownColor[2], "b", knownColor[3],
189 "colorFunc", function (r,g,b) KCIFu:SetBrokerColor("knownColor", r,g,b) end)
190  
191 Dewdrop:AddLine("text", L["Menu_Broker_AHC_Sell"],
192 "hasColorSwatch", true,
193 "disabled", not KC_Broker:GetOpt(KC_Broker.optPath,"ahcolor"),
194 "r", sellColor[1], "g", sellColor[2], "b", sellColor[3],
195 "colorFunc", function (r,g,b) KCIFu:SetBrokerColor("sellColor", r,g,b) end)
196  
197 Dewdrop:AddLine("text", L["Menu_Broker_AHC_Buy"],
198 "hasColorSwatch", true,
199 "disabled", not KC_Broker:GetOpt(KC_Broker.optPath,"ahcolor"),
200 "r", buyColor[1], "g", buyColor[2], "b", buyColor[3],
201 "colorFunc", function (r,g,b) KCIFu:SetBrokerColor("buyColor", r,g,b) end)
202  
203 Dewdrop:AddLine("text", L["Menu_Broker_AHC_Min"],
204 "hasColorSwatch", true,
205 "disabled", not KC_Broker:GetOpt(KC_Broker.optPath,"ahcolor"),
206 "r", minColor[1], "g", minColor[2], "b", minColor[3],
207 "colorFunc", function (r,g,b) KCIFu:SetBrokerColor("minColor", r,g,b) end)
208  
209 elseif mValue == "Menu_ChatLink" then
210 Dewdrop:AddLine("text", L["Menu_ChatLink_Enable"],
211 "checked", KC_ChatLink.app:ModEnabled(KC_ChatLink),
212 "arg1", KC_ChatLink,
213 "func", "Toggle")
214  
215 elseif mValue == "Menu_ItemInfo" then
216 -- Item Info Settings
217 Dewdrop:AddLine("text",L["Menu_ItemInfo_Enable"],
218 "checked", (KC_ItemInfo.app:ModEnabled(KC_ItemInfo)),
219 "arg1", KC_ItemInfo,
220 "func", "Toggle")
221  
222 elseif mValue == "Menu_Tooltip" then
223 -- Tooltip Module Settings
224 Dewdrop:AddLine("text", L["Menu_Tooltip_Mode"],
225 "isTitle", true)
226 Dewdrop:AddLine("text", L["Menu_Tooltip_Separated"],
227 "isRadio", true,
228 "arg1", KC_Tooltip,
229 "func", "modeswitch",
230 "checked", (KC_Tooltip:GetOpt(KC_Tooltip.optPath, "separated") == 1))
231 Dewdrop:AddLine("text", L["Menu_Tooltip_Merged"],
232 "isRadio", true,
233 "arg1", KC_Tooltip,
234 "func", "modeswitch",
235 "checked", (KC_Tooltip:GetOpt(KC_Tooltip.optPath, "separated") ~= 1))
236 Dewdrop:AddLine()
237 Dewdrop:AddLine("text", L["Menu_Tooltip_Splitline"],
238 "arg1", KC_Tooltip,
239 "func", "splitline",
240 "checked", (KC_Tooltip:GetOpt(KC_Tooltip.optPath, "splitline") == 1))
241 Dewdrop:AddLine("text", L["Menu_Tooltip_Separate"],
242 "arg1", KC_Tooltip,
243 "func", "separatortog",
244 "checked", (KC_Tooltip:GetOpt(KC_Tooltip.optPath, "separator") == 1))
245 Dewdrop:AddLine("text", L["Menu_Tooltip_Moneyframe"],
246 "arg1", KC_Tooltip,
247 "func", "moneyframe",
248 "checked", (KC_Tooltip:GetOpt(KC_Tooltip.optPath, "moneyframe") == 1))
249  
250 elseif mValue == "Menu_SellValue" then
251 -- SellValue Module Settings
252 Dewdrop:AddLine("text", L["Menu_SellValue_Enable"],
253 "arg1", KC_SellValue,
254 "func", "Toggle",
255 "checked", KC_SellValue.app:ModEnabled(KC_SellValue))
256 Dewdrop:AddLine("text", L["Menu_SellValue_Short"],
257 "arg1", KC_SellValue,
258 "func", "short",
259 "checked", (KC_SellValue:GetOpt(KC_SellValue.optPath, "short") == 1))
260  
261 end -- selection of mValue
262 end -- end selection of mLevel
263 end
264  
265 function KCIFu:SetBrokerColor(colorType, r, g, b)
266 KC_Broker:SetOpt(KC_Broker.optPath, colorType, format("%s!%s!%s", r, g, b))
267 KC_Broker:UpdateGuide()
268 if BrowseTitle then
269 BrowseTitle:SetText(format("%s - %s", KC_Broker.BrowseTitle, KC_ITEMS_LOCALS.modules.broker.labels.guide))
270 end
271 end