vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | AceLoot = {} |
2 | |||
3 | -- German Localization |
||
4 | function AceLoot_Locals_deDE() |
||
5 | |||
6 | AceLoot.Const = { |
||
7 | CmdOptions = { |
||
8 | { option = "mode", |
||
9 | desc = "Nur einmal positionieren.", |
||
10 | method = "Toggle", |
||
11 | } |
||
12 | }, |
||
13 | Chat = { |
||
14 | Toggle = "Nur einmal positionieren." |
||
15 | } |
||
16 | } |
||
17 | |||
18 | ace:RegisterGlobals({ |
||
19 | version = 2.0, |
||
20 | translation = "deDE", |
||
21 | ACEG_ON = "|cff00ff00An|r", |
||
22 | ACEG_OFF = "|cffff5050Aus|r", |
||
23 | }) |
||
24 | end |
||
25 | |||
26 | -- English Localization |
||
27 | if not ace:LoadTranslation("AceLoot") then |
||
28 | |||
29 | AceLoot.Const = { |
||
30 | CmdOptions = { |
||
31 | { option = "mode", |
||
32 | desc = "Only position once.", |
||
33 | method = "Toggle", |
||
34 | } |
||
35 | }, |
||
36 | Chat = { |
||
37 | Toggle = "Only position once." |
||
38 | } |
||
39 | } |
||
40 | |||
41 | ace:RegisterGlobals({ |
||
42 | version = 2.0, |
||
43 | ACEG_ON = "|cff00ff00On|r", |
||
44 | ACEG_OFF = "|cffff5050Off|r", |
||
45 | }) |
||
46 | end |
||
47 | |||
48 | -- MainCode |
||
49 | local const = AceLoot.Const |
||
50 | |||
51 | AceLoot.Obj = AceAddon:new({ |
||
52 | name = "AceLoot", |
||
53 | version = " a./R9." .. string.sub("$Revision: 3091 $", 12, -3), |
||
54 | releaseDate = string.sub("$Date: 2006-06-21 20:52:26 +0200 (Mi, 21 Jun 2006) $", 8, 17), |
||
55 | author = "Neriak", |
||
56 | email = "pk@neriak.de", |
||
57 | website = "http://neriak_x.wowinterface.com", |
||
58 | aceCompatible = 103, |
||
59 | category = ACE_CATEGORY_INTERFACE, |
||
60 | db = AceDatabase:new("AceLootDB"), |
||
61 | cmd = AceChatCmdClass:new({"/aceloot", "/al"},const.CmdOptions), |
||
62 | |||
63 | |||
64 | --[[--------------------------- |
||
65 | Hooking and Event Registration |
||
66 | -----------------------------]] |
||
67 | |||
68 | Enable = function(self) |
||
69 | UIPanelWindows["LootFrame"] = nil |
||
70 | LootFrame:SetMovable(1) |
||
71 | LootFrame:SetFrameStrata("DIALOG") |
||
72 | LootFrame:SetScript("OnMouseUp", function () this:StopMovingOrSizing() end) |
||
73 | LootFrame:SetScript("OnMouseDown", function () this:StartMoving() end) |
||
74 | self:RegisterEvent("PLAYER_ENTERING_WORLD") |
||
75 | self:RegisterEvent("PLAYER_LEAVING_WORLD") |
||
76 | self:Reg() |
||
77 | end, |
||
78 | |||
79 | PLAYER_ENTERING_WORLD = function(self) |
||
80 | self:Reg() |
||
81 | end, |
||
82 | |||
83 | PLAYER_LEAVING_WORLD = function(self) |
||
84 | self:UnregisterEvent("LOOT_OPENED") |
||
85 | self:UnregisterEvent("LOOT_SLOT_CLEARED") |
||
86 | self:UnregisterEvent("LOOT_CLOSED") |
||
87 | |||
88 | self.registered = nil |
||
89 | end, |
||
90 | |||
91 | Reg = function(self) |
||
92 | if self.registered then self:debug("Events already registered") return end |
||
93 | self:RegisterEvent("LOOT_OPENED", "ItemUnderCursor") |
||
94 | self:RegisterEvent("LOOT_SLOT_CLEARED", "ItemUnderCursor") |
||
95 | self:RegisterEvent("LOOT_CLOSED") |
||
96 | self.registered = true |
||
97 | end, |
||
98 | |||
99 | --[[---------------------------------------------------- |
||
100 | Main Function taken and improved from Telo's QuickLoot |
||
101 | ------------------------------------------------------]] |
||
102 | |||
103 | ItemUnderCursor = function(self) |
||
104 | self:AutoClose() |
||
105 | if self.called then return end |
||
106 | self.called = nil |
||
107 | local x, y = GetCursorPosition() |
||
108 | local s = LootFrame:GetEffectiveScale() |
||
109 | x = x / s |
||
110 | y = y / s |
||
111 | for i = 1, LOOTFRAME_NUMBUTTONS, 1 do |
||
112 | local button = getglobal("LootButton"..i) |
||
113 | if button:IsVisible() then |
||
114 | x = x - 29 |
||
115 | y = y + 66 + (40 * i) |
||
116 | self:LootFrame_SetPoint(x,y) |
||
117 | if self:IsOnce() then self.called = true return end |
||
118 | return |
||
119 | end |
||
120 | end |
||
121 | if LootFrameDownButton:IsVisible() then |
||
122 | x = x - 158 |
||
123 | y = y + 223 |
||
124 | self:LootFrame_SetPoint(x,y) |
||
125 | end |
||
126 | end, |
||
127 | |||
128 | LOOT_CLOSED = function(self) |
||
129 | self.called = nil |
||
130 | end, |
||
131 | |||
132 | -- code submitted by hshh on www.wowace.com |
||
133 | LootFrame_SetPoint = function(self, x, y) |
||
134 | local screenWidth = GetScreenWidth() |
||
135 | if (UIParent:GetWidth() > screenWidth) then screenWidth = UIParent:GetWidth() end |
||
136 | local screenHeight = GetScreenHeight() |
||
137 | |||
138 | -- LootFrame is set to 256 wide in the xml file, but is actually only 191 wide |
||
139 | -- This is based on calculation envolving the offset on the close button: |
||
140 | -- The height is always 256, which is the correct number. |
||
141 | local windowWidth = 191 |
||
142 | local windowHeight = 256 |
||
143 | if (x + windowWidth) > screenWidth then x = screenWidth - windowWidth end |
||
144 | if y > screenHeight then y = screenHeight end |
||
145 | if x < 0 then x = 0 end |
||
146 | if (y - windowHeight) < 0 then y = windowHeight end |
||
147 | LootFrame:ClearAllPoints() |
||
148 | LootFrame:SetPoint("TOPLEFT", "UIParent", "BOTTOMLEFT", x, y) |
||
149 | end, |
||
150 | |||
151 | AutoClose = function(self) |
||
152 | if GetNumLootItems() == 0 then |
||
153 | HideUIPanel(LootFrame) |
||
154 | return |
||
155 | end |
||
156 | end, |
||
157 | |||
158 | IsOnce = function(self) |
||
159 | return self:Get("Once") |
||
160 | end, |
||
161 | |||
162 | Toggle = function(self) |
||
163 | self:Tog("Once", const.Chat.Toggle.." [%s]") |
||
164 | end, |
||
165 | |||
166 | Report = function(self) |
||
167 | self.cmd:report({ |
||
168 | {text=const.Chat.Toggle, val= self:Get("Once") and 1 or 0, map = ACEG_MAP_ONOFF} |
||
169 | }) |
||
170 | end |
||
171 | }) |
||
172 | |||
173 | --[[------------------------ |
||
174 | The End -> Register Object |
||
175 | --------------------------]] |
||
176 | AceLoot.Obj:RegisterForLoad() |
||
177 | |||
178 | -- The Util Functions |
||
179 | ace:RegisterFunctions(AceLoot.Obj,{ |
||
180 | version= 1.3, |
||
181 | Get = function(self, var) if type(self) == "string" then ace:print("! ERROR: "..self) end |
||
182 | return self.db:get(self.profilePath, var) end, |
||
183 | Set = function(self, var, val) self.db:set(self.profilePath, var, val) end, |
||
184 | Tog = function(self, var, c) self.cmd:result(format(c, self.db:toggle(self.profilePath, var) and ACEG_ON or ACEG_OFF)) end |
||
185 | }) |