Details | Compare with Previous | View Log
Line No. | Rev | Author | Line |
---|---|---|---|
1 | 2 | Wildbreath-135052 | --[[------------------------------------------------------------------------- |
2 | Wildbreath-135052 | Copyright (c) 2007-2008, Trond A Ekseth |
|
3 | Wildbreath-135052 | All rights reserved. |
|
4 | Wildbreath-135052 | ||
5 | Wildbreath-135052 | Redistribution and use in source and binary forms, with or without |
|
6 | Wildbreath-135052 | modification, are permitted provided that the following conditions are |
|
7 | Wildbreath-135052 | met: |
|
8 | Wildbreath-135052 | ||
9 | Wildbreath-135052 | * Redistributions of source code must retain the above copyright |
|
10 | Wildbreath-135052 | notice, this list of conditions and the following disclaimer. |
|
11 | Wildbreath-135052 | * Redistributions in binary form must reproduce the above |
|
12 | Wildbreath-135052 | copyright notice, this list of conditions and the following |
|
13 | Wildbreath-135052 | disclaimer in the documentation and/or other materials provided |
|
14 | Wildbreath-135052 | with the distribution. |
|
15 | Wildbreath-135052 | * Neither the name of Butsu nor the names of its contributors may |
|
16 | Wildbreath-135052 | be used to endorse or promote products derived from this |
|
17 | Wildbreath-135052 | software without specific prior written permission. |
|
18 | Wildbreath-135052 | ||
19 | Wildbreath-135052 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
20 | Wildbreath-135052 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
21 | Wildbreath-135052 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
22 | Wildbreath-135052 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
23 | Wildbreath-135052 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
24 | Wildbreath-135052 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
25 | Wildbreath-135052 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
26 | Wildbreath-135052 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
27 | Wildbreath-135052 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
28 | Wildbreath-135052 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
29 | Wildbreath-135052 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
30 | Wildbreath-135052 | ---------------------------------------------------------------------------]] |
|
31 | Wildbreath-135052 | ||
32 | Wildbreath-135052 | local L = { |
|
33 | Wildbreath-135052 | fish = "Fishy loot", |
|
34 | Wildbreath-135052 | empty = "Empty slot", |
|
35 | Wildbreath-135052 | } |
|
36 | Wildbreath-135052 | ||
37 | Wildbreath-135052 | local addon = CreateFrame("Button", "Butsu") |
|
38 | Wildbreath-135052 | local title = addon:CreateFontString(nil, "OVERLAY") |
|
39 | Wildbreath-135052 | ||
40 | Wildbreath-135052 | local print = function(a) ChatFrame1:AddMessage("|cff33ff99Butsu:|r "..a) end |
|
41 | Wildbreath-135052 | local iconsize = 35 |
|
42 | Wildbreath-135052 | local sq, ss, sn |
|
43 | Wildbreath-135052 | ||
44 | Wildbreath-135052 | local OnEnter = function(self) |
|
45 | Wildbreath-135052 | local slot = self:GetID() |
|
46 | Wildbreath-135052 | if(LootSlotIsItem(slot)) then |
|
47 | Wildbreath-135052 | GameTooltip:SetOwner(self, "ANCHOR_RIGHT") |
|
48 | Wildbreath-135052 | GameTooltip:SetLootItem(slot) |
|
49 | Wildbreath-135052 | CursorUpdate(self) |
|
50 | Wildbreath-135052 | end |
|
51 | Wildbreath-135052 | ||
52 | Wildbreath-135052 | self.drop:Show() |
|
53 | Wildbreath-135052 | self.drop:SetVertexColor(1, 1, 0) |
|
54 | Wildbreath-135052 | end |
|
55 | Wildbreath-135052 | ||
56 | Wildbreath-135052 | local OnLeave = function(self) |
|
57 | Wildbreath-135052 | if(self.quality > 1) then |
|
58 | Wildbreath-135052 | local color = ITEM_QUALITY_COLORS[self.quality] |
|
59 | Wildbreath-135052 | self.drop:SetVertexColor(color.r, color.g, color.b) |
|
60 | Wildbreath-135052 | else |
|
61 | Wildbreath-135052 | self.drop:Hide() |
|
62 | Wildbreath-135052 | end |
|
63 | Wildbreath-135052 | ||
64 | Wildbreath-135052 | GameTooltip:Hide() |
|
65 | Wildbreath-135052 | ResetCursor() |
|
66 | Wildbreath-135052 | end |
|
67 | Wildbreath-135052 | ||
68 | Wildbreath-135052 | local OnClick = function(self) |
|
69 | Wildbreath-135052 | if(IsModifiedClick()) then |
|
70 | Wildbreath-135052 | HandleModifiedItemClick(GetLootSlotLink(self:GetID())) |
|
71 | Wildbreath-135052 | else |
|
72 | Wildbreath-135052 | StaticPopup_Hide"CONFIRM_LOOT_DISTRIBUTION" |
|
73 | Wildbreath-135052 | ss = self:GetID() |
|
74 | Wildbreath-135052 | sq = self.quality |
|
75 | Wildbreath-135052 | sn = self.name:GetText() |
|
76 | Wildbreath-135052 | LootSlot(ss) |
|
77 | Wildbreath-135052 | end |
|
78 | Wildbreath-135052 | end |
|
79 | Wildbreath-135052 | ||
80 | Wildbreath-135052 | local OnUpdate = function(self) |
|
81 | Wildbreath-135052 | if(GameTooltip:IsOwned(self)) then |
|
82 | Wildbreath-135052 | GameTooltip:SetOwner(self, "ANCHOR_RIGHT") |
|
83 | Wildbreath-135052 | GameTooltip:SetLootItem(self:GetID()) |
|
84 | Wildbreath-135052 | CursorOnUpdate(self) |
|
85 | Wildbreath-135052 | end |
|
86 | Wildbreath-135052 | end |
|
87 | Wildbreath-135052 | ||
88 | Wildbreath-135052 | local createSlot = function(id) |
|
89 | Wildbreath-135052 | local frame = CreateFrame("Button", 'ButsuSlot'..id, addon) |
|
90 | Wildbreath-135052 | frame:SetPoint("LEFT", 8, 0) |
|
91 | Wildbreath-135052 | frame:SetPoint("RIGHT", -8, 0) |
|
92 | Wildbreath-135052 | frame:SetHeight(iconsize) |
|
93 | Wildbreath-135052 | frame:SetID(id) |
|
94 | Wildbreath-135052 | ||
95 | Wildbreath-135052 | frame:SetScript("OnEnter", OnEnter) |
|
96 | Wildbreath-135052 | frame:SetScript("OnLeave", OnLeave) |
|
97 | Wildbreath-135052 | frame:SetScript("OnClick", OnClick) |
|
98 | Wildbreath-135052 | frame:SetScript("OnUpdate", OnUpdate) |
|
99 | Wildbreath-135052 | ||
100 | Wildbreath-135052 | local iconFrame = CreateFrame("Frame", nil, frame) |
|
101 | Wildbreath-135052 | iconFrame:SetHeight(iconsize) |
|
102 | Wildbreath-135052 | iconFrame:SetWidth(iconsize) |
|
103 | Wildbreath-135052 | iconFrame:ClearAllPoints() |
|
104 | Wildbreath-135052 | iconFrame:SetPoint("RIGHT", frame) |
|
105 | Wildbreath-135052 | ||
106 | Wildbreath-135052 | local icon = iconFrame:CreateTexture(nil, "ARTWORK") |
|
107 | Wildbreath-135052 | icon:SetAlpha(.8) |
|
108 | Wildbreath-135052 | icon:SetTexCoord(.07, .93, .07, .93) |
|
109 | Wildbreath-135052 | icon:SetAllPoints(iconFrame) |
|
110 | Wildbreath-135052 | frame.icon = icon |
|
111 | Wildbreath-135052 | ||
112 | Wildbreath-135052 | local count = iconFrame:CreateFontString(nil, "OVERLAY") |
|
113 | Wildbreath-135052 | count:ClearAllPoints() |
|
114 | Wildbreath-135052 | count:SetJustifyH"RIGHT" |
|
115 | Wildbreath-135052 | count:SetPoint("BOTTOMRIGHT", iconFrame, 2, 2) |
|
116 | Wildbreath-135052 | count:SetFontObject(NumberFontNormalSmall) |
|
117 | Wildbreath-135052 | count:SetShadowOffset(.8, -.8) |
|
118 | Wildbreath-135052 | count:SetShadowColor(0, 0, 0, 1) |
|
119 | Wildbreath-135052 | count:SetText(1) |
|
120 | Wildbreath-135052 | frame.count = count |
|
121 | Wildbreath-135052 | ||
122 | Wildbreath-135052 | local name = frame:CreateFontString(nil, "OVERLAY") |
|
123 | Wildbreath-135052 | name:SetJustifyH"LEFT" |
|
124 | Wildbreath-135052 | name:ClearAllPoints() |
|
125 | Wildbreath-135052 | name:SetPoint("LEFT", frame) |
|
126 | Wildbreath-135052 | name:SetPoint("RIGHT", icon, "LEFT") |
|
127 | Wildbreath-135052 | name:SetNonSpaceWrap(true) |
|
128 | Wildbreath-135052 | name:SetFontObject(GameFontWhite) |
|
129 | Wildbreath-135052 | name:SetShadowOffset(.8, -.8) |
|
130 | Wildbreath-135052 | name:SetShadowColor(0, 0, 0, 1) |
|
131 | Wildbreath-135052 | frame.name = name |
|
132 | Wildbreath-135052 | ||
133 | Wildbreath-135052 | local drop = frame:CreateTexture(nil, "ARTWORK") |
|
134 | Wildbreath-135052 | drop:SetTexture"Interface\\QuestFrame\\UI-QuestLogTitleHighlight" |
|
135 | Wildbreath-135052 | ||
136 | Wildbreath-135052 | drop:SetPoint("LEFT", icon, "RIGHT", 0, 0) |
|
137 | Wildbreath-135052 | drop:SetPoint("RIGHT", frame) |
|
138 | Wildbreath-135052 | drop:SetAllPoints(frame) |
|
139 | Wildbreath-135052 | drop:SetAlpha(.3) |
|
140 | Wildbreath-135052 | frame.drop = drop |
|
141 | Wildbreath-135052 | ||
142 | Wildbreath-135052 | frame:SetPoint("TOP", addon, 4, (-8+iconsize)-(id*iconsize)) |
|
143 | Wildbreath-135052 | addon.slots[id] = frame |
|
144 | Wildbreath-135052 | return frame |
|
145 | Wildbreath-135052 | end |
|
146 | Wildbreath-135052 | ||
147 | Wildbreath-135052 | title:SetFontObject(GameTooltipHeaderText) |
|
148 | Wildbreath-135052 | title:SetPoint("BOTTOMLEFT", addon, "TOPLEFT", 5, 0) |
|
149 | Wildbreath-135052 | ||
150 | Wildbreath-135052 | addon:SetScript("OnMouseDown", function(self) if(IsAltKeyDown()) then self:StartMoving() end end) |
|
151 | Wildbreath-135052 | addon:SetScript("OnMouseUp", function(self) self:StopMovingOrSizing() end) |
|
152 | Wildbreath-135052 | addon:SetScript("OnHide", function(self) |
|
153 | Wildbreath-135052 | StaticPopup_Hide"CONFIRM_LOOT_DISTRIBUTION" |
|
154 | Wildbreath-135052 | CloseLoot() |
|
155 | Wildbreath-135052 | end) |
|
156 | Wildbreath-135052 | addon:SetMovable(true) |
|
157 | Wildbreath-135052 | addon:RegisterForClicks"anyup" |
|
158 | Wildbreath-135052 | ||
159 | Wildbreath-135052 | addon:SetParent(UIParent) |
|
160 | Wildbreath-135052 | addon:SetUserPlaced(true) |
|
161 | Wildbreath-135052 | addon:SetPoint("TOPLEFT", 0, -104) |
|
162 | Wildbreath-135052 | addon:SetBackdrop{ |
|
163 | Wildbreath-135052 | bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, |
|
164 | Wildbreath-135052 | edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", edgeSize = 16, |
|
165 | Wildbreath-135052 | insets = {left = 4, right = 4, top = 4, bottom = 4}, |
|
166 | Wildbreath-135052 | } |
|
167 | Wildbreath-135052 | addon:SetWidth(256) |
|
168 | Wildbreath-135052 | addon:SetHeight(64) |
|
169 | Wildbreath-135052 | addon:SetBackdropColor(0, 0, 0, 1) |
|
170 | Wildbreath-135052 | ||
171 | Wildbreath-135052 | addon:SetClampedToScreen(true) |
|
172 | Wildbreath-135052 | addon:SetClampRectInsets(0, 0, 14, 0) |
|
173 | Wildbreath-135052 | addon:SetHitRectInsets(0, 0, -14, 0) |
|
174 | Wildbreath-135052 | addon:SetFrameStrata"HIGH" |
|
175 | Wildbreath-135052 | addon:SetToplevel(true) |
|
176 | Wildbreath-135052 | ||
177 | Wildbreath-135052 | addon.slots = {} |
|
178 | Wildbreath-135052 | addon.LOOT_OPENED = function(self, event, autoloot) |
|
179 | Wildbreath-135052 | self:Show() |
|
180 | Wildbreath-135052 | ||
181 | Wildbreath-135052 | if(not self:IsShown()) then |
|
182 | Wildbreath-135052 | CloseLoot(not autoLoot) |
|
183 | Wildbreath-135052 | end |
|
184 | Wildbreath-135052 | ||
185 | Wildbreath-135052 | local items = GetNumLootItems() |
|
186 | Wildbreath-135052 | ||
187 | Wildbreath-135052 | if(IsFishingLoot()) then |
|
188 | Wildbreath-135052 | title:SetText(L.fish) |
|
189 | Wildbreath-135052 | elseif(not UnitIsFriend("player", "target") and UnitIsDead"target") then |
|
190 | Wildbreath-135052 | title:SetText(UnitName"target") |
|
191 | Wildbreath-135052 | else |
|
192 | Wildbreath-135052 | title:SetText(LOOT) |
|
193 | Wildbreath-135052 | end |
|
194 | Wildbreath-135052 | ||
195 | Wildbreath-135052 | -- Blizzard uses strings here |
|
196 | Wildbreath-135052 | if(GetCVar("lootUnderMouse") == "1") then |
|
197 | Wildbreath-135052 | local x, y = GetCursorPosition() |
|
198 | Wildbreath-135052 | x = x / self:GetEffectiveScale() |
|
199 | Wildbreath-135052 | y = y / self:GetEffectiveScale() |
|
200 | Wildbreath-135052 | ||
201 | Wildbreath-135052 | self:ClearAllPoints() |
|
202 | Wildbreath-135052 | self:SetPoint("TOPLEFT", nil, "BOTTOMLEFT", x-40, y+20) |
|
203 | Wildbreath-135052 | self:GetCenter() |
|
204 | Wildbreath-135052 | self:Raise() |
|
205 | Wildbreath-135052 | end |
|
206 | Wildbreath-135052 | ||
207 | Wildbreath-135052 | local m, w, t = 0, 0, title:GetStringWidth() |
|
208 | Wildbreath-135052 | if(items > 0) then |
|
209 | Wildbreath-135052 | for i=1, items do |
|
210 | Wildbreath-135052 | local slot = addon.slots[i] or createSlot(i) |
|
211 | Wildbreath-135052 | local texture, item, quantity, quality, locked = GetLootSlotInfo(i) |
|
212 | Wildbreath-135052 | local color = ITEM_QUALITY_COLORS[quality] |
|
213 | Wildbreath-135052 | ||
214 | Wildbreath-135052 | if(LootSlotIsCoin(i)) then |
|
215 | Wildbreath-135052 | item = item:gsub("\n", ", ") |
|
216 | Wildbreath-135052 | end |
|
217 | Wildbreath-135052 | ||
218 | Wildbreath-135052 | if(quantity > 1) then |
|
219 | Wildbreath-135052 | slot.count:SetText(quantity) |
|
220 | Wildbreath-135052 | slot.count:Show() |
|
221 | Wildbreath-135052 | else |
|
222 | Wildbreath-135052 | slot.count:Hide() |
|
223 | Wildbreath-135052 | end |
|
224 | Wildbreath-135052 | ||
225 | Wildbreath-135052 | if(quality > 1) then |
|
226 | Wildbreath-135052 | slot.drop:SetVertexColor(color.r, color.g, color.b) |
|
227 | Wildbreath-135052 | slot.drop:Show() |
|
228 | Wildbreath-135052 | else |
|
229 | Wildbreath-135052 | slot.drop:Hide() |
|
230 | Wildbreath-135052 | end |
|
231 | Wildbreath-135052 | ||
232 | Wildbreath-135052 | slot.quality = quality |
|
233 | Wildbreath-135052 | slot.name:SetText(item) |
|
234 | Wildbreath-135052 | slot.name:SetTextColor(color.r, color.g, color.b) |
|
235 | Wildbreath-135052 | slot.icon:SetTexture(texture) |
|
236 | Wildbreath-135052 | ||
237 | Wildbreath-135052 | m = math.max(m, quality) |
|
238 | Wildbreath-135052 | w = math.max(w, slot.name:GetStringWidth()) |
|
239 | Wildbreath-135052 | ||
240 | Wildbreath-135052 | slot:Enable() |
|
241 | Wildbreath-135052 | slot:Show() |
|
242 | Wildbreath-135052 | end |
|
243 | Wildbreath-135052 | else |
|
244 | Wildbreath-135052 | local slot = addon.slots[1] or createSlot(1) |
|
245 | Wildbreath-135052 | local color = ITEM_QUALITY_COLORS[0] |
|
246 | Wildbreath-135052 | ||
247 | Wildbreath-135052 | slot.name:SetText(L.empty) |
|
248 | Wildbreath-135052 | slot.name:SetTextColor(color.r, color.g, color.b) |
|
249 | Wildbreath-135052 | slot.icon:SetTexture[[Interface\Icons\INV_Misc_Herb_AncientLichen]] |
|
250 | Wildbreath-135052 | ||
251 | Wildbreath-135052 | items = 1 |
|
252 | Wildbreath-135052 | w = math.max(w, slot.name:GetStringWidth()) |
|
253 | Wildbreath-135052 | ||
254 | Wildbreath-135052 | slot.count:Hide() |
|
255 | Wildbreath-135052 | slot.drop:Hide() |
|
256 | Wildbreath-135052 | slot:Disable() |
|
257 | Wildbreath-135052 | slot:Show() |
|
258 | Wildbreath-135052 | end |
|
259 | Wildbreath-135052 | ||
260 | Wildbreath-135052 | w = w + 60 |
|
261 | Wildbreath-135052 | t = t + 5 |
|
262 | Wildbreath-135052 | ||
263 | Wildbreath-135052 | local color = ITEM_QUALITY_COLORS[m] |
|
264 | Wildbreath-135052 | self:SetBackdropBorderColor(color.r, color.g, color.b, .8) |
|
265 | Wildbreath-135052 | self:SetHeight(math.max((items*iconsize)+16), 20) |
|
266 | Wildbreath-135052 | self:SetWidth(math.max(w, t)) |
|
267 | Wildbreath-135052 | end |
|
268 | Wildbreath-135052 | ||
269 | Wildbreath-135052 | addon.LOOT_SLOT_CLEARED = function(self, event, slot) |
|
270 | Wildbreath-135052 | if(not self:IsShown()) then return end |
|
271 | Wildbreath-135052 | ||
272 | Wildbreath-135052 | addon.slots[slot]:Hide() |
|
273 | Wildbreath-135052 | end |
|
274 | Wildbreath-135052 | ||
275 | Wildbreath-135052 | addon.LOOT_CLOSED = function(self) |
|
276 | Wildbreath-135052 | StaticPopup_Hide"LOOT_BIND" |
|
277 | Wildbreath-135052 | self:Hide() |
|
278 | Wildbreath-135052 | ||
279 | Wildbreath-135052 | for _, v in pairs(self.slots) do |
|
280 | Wildbreath-135052 | v:Hide() |
|
281 | Wildbreath-135052 | end |
|
282 | Wildbreath-135052 | end |
|
283 | Wildbreath-135052 | ||
284 | Wildbreath-135052 | addon.OPEN_MASTER_LOOT_LIST = function(self) |
|
285 | Wildbreath-135052 | ToggleDropDownMenu(1, nil, GroupLootDropDown, addon.slots[ss], 0, 0) |
|
286 | Wildbreath-135052 | end |
|
287 | Wildbreath-135052 | ||
288 | Wildbreath-135052 | addon.UPDATE_MASTER_LOOT_LIST = function(self) |
|
289 | Wildbreath-135052 | UIDropDownMenu_Refresh(GroupLootDropDown) |
|
290 | Wildbreath-135052 | end |
|
291 | Wildbreath-135052 | ||
292 | Wildbreath-135052 | addon:SetScript("OnEvent", function(self, event, ...) |
|
293 | Wildbreath-135052 | self[event](self, event, ...) |
|
294 | Wildbreath-135052 | end) |
|
295 | Wildbreath-135052 | ||
296 | Wildbreath-135052 | addon:RegisterEvent"LOOT_OPENED" |
|
297 | Wildbreath-135052 | addon:RegisterEvent"LOOT_SLOT_CLEARED" |
|
298 | Wildbreath-135052 | addon:RegisterEvent"LOOT_CLOSED" |
|
299 | Wildbreath-135052 | addon:RegisterEvent"OPEN_MASTER_LOOT_LIST" |
|
300 | Wildbreath-135052 | addon:RegisterEvent"UPDATE_MASTER_LOOT_LIST" |
|
301 | Wildbreath-135052 | addon:Hide() |
|
302 | Wildbreath-135052 | ||
303 | Wildbreath-135052 | -- Fuzz |
|
304 | Wildbreath-135052 | LootFrame:UnregisterAllEvents() |
|
305 | Wildbreath-135052 | table.insert(UISpecialFrames, "Butsu") |
|
306 | Wildbreath-135052 | ||
307 | Wildbreath-135052 | function _G.GroupLootDropDown_GiveLoot(self) |
|
308 | Wildbreath-135052 | if ( sq >= MASTER_LOOT_THREHOLD ) then |
|
309 | Wildbreath-135052 | local dialog = StaticPopup_Show("CONFIRM_LOOT_DISTRIBUTION", ITEM_QUALITY_COLORS[sq].hex..sn..FONT_COLOR_CODE_CLOSE, self:GetText()) |
|
310 | Wildbreath-135052 | if (dialog) then |
|
311 | Wildbreath-135052 | dialog.data = self.value |
|
312 | Wildbreath-135052 | end |
|
313 | Wildbreath-135052 | else |
|
314 | Wildbreath-135052 | GiveMasterLoot(ss, self.value) |
|
315 | Wildbreath-135052 | end |
|
316 | Wildbreath-135052 | CloseDropDownMenus() |
|
317 | Wildbreath-135052 | end |
|
318 | Wildbreath-135052 | ||
319 | Wildbreath-135052 | StaticPopupDialogs["CONFIRM_LOOT_DISTRIBUTION"].OnAccept = function(self, data) |
|
320 | Wildbreath-135052 | GiveMasterLoot(ss, data) |
|
321 | Wildbreath-135052 | end |