vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local L = AceLibrary("AceLocale-2.0"):new("FruityLoots")
2 FruityLoots = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceDB-2.0", "AceConsole-2.0")
3  
4 function FruityLoots:OnInitialize()
5 self:RegisterDB("FruityLootsDB")
6 self:RegisterChatCommand({ "/floots", "/fruityloots" }, {
7 desc = self.notes,
8 type = "group",
9 args = {
10 mode = {
11 name = L"Once",
12 desc = L"Once",
13 type = "toggle",
14 get = function() return self.db.profile.Once end,
15 set = function(v)
16 self.db.profile.Once = v
17 end,
18 }
19 }
20 })
21 end
22  
23 function FruityLoots:OnEnable()
24 UIPanelWindows["LootFrame"] = nil
25 LootFrame:SetMovable(1)
26 LootFrame:SetFrameStrata("DIALOG")
27 LootFrame:SetScript("OnMouseUp", function () this:StopMovingOrSizing() end)
28 LootFrame:SetScript("OnMouseDown", function () this:StartMoving() end)
29 self:RegisterEvent("LOOT_OPENED", "ItemUnderCursor")
30 self:RegisterEvent("LOOT_SLOT_CLEARED", "ItemUnderCursor")
31 self:RegisterEvent("LOOT_CLOSED")
32 end
33  
34 function FruityLoots:OnDisable()
35 self:UnregisterAllEvents()
36 end
37  
38  
39 --[[------------------------------------------------------
40 Main Function taken and improved from Telo's QuickLoot
41 ----------------------------------------------------------]]
42  
43 function FruityLoots:ItemUnderCursor()
44 self:AutoClose()
45 if self.called then return end
46 self.called = nil
47 local x, y = GetCursorPosition()
48 local s = LootFrame:GetEffectiveScale()
49 x = x / s
50 y = y / s
51 for i = 1, LOOTFRAME_NUMBUTTONS, 1 do
52 local button = getglobal("LootButton"..i)
53 if button:IsVisible() then
54 x = x - 29
55 y = y + 66 + (40 * i)
56 self:LootFrame_SetPoint(x,y)
57 if self.db.profile.Once then self.called = true return end
58 return
59 end
60 end
61 if LootFrameDownButton:IsVisible() then
62 x = x - 158
63 y = y + 223
64 self:LootFrame_SetPoint(x,y)
65 end
66 end
67  
68 function FruityLoots:LOOT_CLOSED()
69 self.called = nil
70 end
71  
72 -- code submitted by hshh on www.wowace.com
73 function FruityLoots:LootFrame_SetPoint(x, y)
74 local screenWidth = GetScreenWidth()
75 if (UIParent:GetWidth() > screenWidth) then screenWidth = UIParent:GetWidth() end
76 local screenHeight = GetScreenHeight()
77 -- LootFrame is set to 256 wide in the xml file, but is actually only 191 wide
78 -- This is based on calculation envolving the offset on the close button:
79 -- The height is always 256, which is the correct number.
80 local windowWidth = 191
81 local windowHeight = 256
82 if (x + windowWidth) > screenWidth then x = screenWidth - windowWidth end
83 if y > screenHeight then y = screenHeight end
84 if x < 0 then x = 0 end
85 if (y - windowHeight) < 0 then y = windowHeight end
86 LootFrame:ClearAllPoints()
87 LootFrame:SetPoint("TOPLEFT", "UIParent", "BOTTOMLEFT", x, y)
88 end
89  
90 function FruityLoots:AutoClose()
91 if GetNumLootItems() == 0 then HideUIPanel(LootFrame) return end
92 end