vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1  
2 local utility = Nurfed_Utility:New();
3 local framelib = Nurfed_Frames:New();
4 local optionslib = Nurfed_Options:New();
5 local saved = {};
6  
7 local micromenu = {
8 [1] = {text = NRF_MICROHEADER, isTitle = 1 },
9 [2] = {text = NRF_PAPERDOLL, func = function() ToggleCharacter("PaperDollFrame"); end },
10 [3] = {text = NRF_SPELLBOOK, func = function() ToggleSpellBook(BOOKTYPE_SPELL) end },
11 [4] = {text = NRF_TALENTS, func = ToggleTalentFrame },
12 [5] = {text = NRF_QUESTLOG, func = ToggleQuestLog },
13 [6] = {text = NRF_FRIENDS, func = ToggleFriendsFrame },
14 [7] = {text = NRF_HELPMENU, func = ToggleHelpFrame },
15 [8] = { text = KEYRING, func = ToggleKeyRing },
16 };
17  
18 local addons = {
19 [1] = {text = NRF_ADDONHEADER, isTitle = 1, nurfed = true },
20 [2] = {text = NRF_OTHERADDONS, isTitle = 1 },
21 };
22  
23 local addonlist = {
24 ["Nurfed_ActionBars"] = { text = "Nurfed ActionBars", func = function() optionslib:GetMenu("Nurfed_ActionBars") end },
25 ["Nurfed_General"] = { text = "Nurfed General", func = function() optionslib:GetMenu("Nurfed_General") end },
26 ["Nurfed_Hud"] = { text = "Nurfed Hud", func = function() optionslib:GetMenu("Nurfed_Hud") end },
27 ["Nurfed_UnitFrames"] = { text = "Nurfed UnitFrames", func = function() optionslib:GetMenu("Nurfed_UnitFrames") end },
28 ["Nurfed_CombatLog"] = { text = "Nurfed CombatLog", func = function() optionslib:GetMenu("Nurfed_CombatLog") end },
29 ["Nurfed_Raids"] = { text = "Nurfed Raids", func = function() optionslib:GetMenu("Nurfed_Raids") end },
30 ["AutoBar"] = { text = "Autobar Config", func = function() AutoBar_ToggleConfig() end },
31 ["Sct"] = { text = "SCT Menu", func = function() SCT_showMenu() end },
32 ["AF_Tooltip"] = { text = "AF_Tooltip Menu", func = function() aftt_toggleFrames() end },
33 ["TipBuddy"] = { text = "TipBuddy Menu", func = function() TipBuddy_ToggleOptionsFrame() end },
34 };
35  
36 local function AddItem(text, func, nurfed)
37 local index = utility:GetTableIndex(addons, text);
38 if (index == nil) then
39 index = table.getn(addons) + 1;
40 table.setn(addons, index);
41 addons[index] = {};
42 addons[index].text = text;
43 addons[index].func = func;
44 if (string.find(text, "^Nurfed")) then
45 addons[index].nurfed = true;
46 end
47 end
48 end
49  
50 local function Update_Lock_POS()
51 Nurfed_LockButton:ClearAllPoints();
52 Nurfed_LockButton:SetPoint("CENTER", "Minimap", "CENTER", saved.lockx, saved.locky);
53 end
54  
55 local function Nurfed_Lock_OnEvent()
56 Nurfed_LockButton:UnregisterEvent(event);
57 Nurfed_LockButton:RegisterForClicks("LeftButtonUp", "RightButtonUp");
58  
59 local player = UnitName("player").." - "..GetCVar("realmName");
60 if (not NURFED_UTILITY_SAVED) then
61 NURFED_UTILITY_SAVED = {};
62 end
63 if (not NURFED_UTILITY_SAVED[player]) then
64 NURFED_UTILITY_SAVED[player] = {
65 ["lockx"] = 0;
66 ["locky"] = -75;
67 };
68 end
69  
70 for k, v in addonlist do
71 if (string.find(k, "^Nurfed")) then
72 if (IsAddOnLoaded(k)) then
73 local tbl = string.upper(k).."_SAVED";
74 if (not getglobal(tbl)) then
75 setglobal(tbl, {});
76 end
77 if (not getglobal(tbl)[player]) then
78 getglobal(tbl)[player] = utility:TableCopy(getglobal(string.upper(k).."_DEFAULT"));
79 end
80 local func = getglobal(k.."_Init");
81 if (func) then
82 func();
83 end
84 end
85 end
86 end
87  
88 saved = NURFED_UTILITY_SAVED[player];
89 Update_Lock_POS();
90 end
91  
92 local function GenerateMenu()
93 local frame = getglobal(this:GetName().."DropDown");
94  
95 if (not frame.updated) then
96 for k, v in addonlist do
97 if (IsAddOnLoaded(k)) then
98 AddItem(v.text, v.func);
99 end
100 end
101 frame.updated = true;
102 frame.displayMode = "MENU";
103 end
104  
105 frame.initialize = function ()
106 local info = {};
107  
108 if (UIDROPDOWNMENU_MENU_VALUE == "Micro Buttons") then
109 for _, v in micromenu do
110 info = {};
111 info.text = v.text;
112 info.func = v.func;
113 info.isTitle = v.isTitle;
114 info.notCheckable = 1;
115 UIDropDownMenu_AddButton(info, 2);
116 end
117 elseif (UIDROPDOWNMENU_MENU_VALUE == "Other AddOns") then
118 for _, v in addons do
119 if (not v.nurfed) then
120 info = {};
121 info.text = v.text;
122 info.func = v.func;
123 info.isTitle = v.isTitle;
124 info.notCheckable = 1;
125 UIDropDownMenu_AddButton(info, 2);
126 end
127 end
128 else
129 for _, v in addons do
130 if (v.nurfed) then
131 info = {};
132 info.text = v.text;
133 info.func = v.func;
134 info.isTitle = v.isTitle;
135 info.notCheckable = 1;
136 info.textR = 0;
137 info.textG = 1;
138 info.textB = 0;
139 UIDropDownMenu_AddButton(info);
140 end
141 end
142  
143 info = {};
144 info.text = NRF_OTHERADDONS;
145 info.value = "Other AddOns";
146 info.hasArrow = 1;
147 info.notCheckable = 1;
148 UIDropDownMenu_AddButton(info);
149  
150 info = {};
151 info.text = NRF_MICROHEADER;
152 info.value = "Micro Buttons";
153 info.hasArrow = 1;
154 info.notCheckable = 1;
155 UIDropDownMenu_AddButton(info);
156 end
157 end
158 end
159  
160 local function Nurfed_LockButton_OnClick(button)
161 if (IsShiftKeyDown()) then
162 this:SetChecked(NRF_LOCKED);
163 return;
164 end
165 if (button == "LeftButton") then
166 NRF_LOCKED = this:GetChecked();
167 if (NRF_LOCKED) then
168 this:SetNormalTexture(NRF_IMG.."nurfedlocked");
169 else
170 this:SetNormalTexture(NRF_IMG.."nurfedunlocked");
171 end
172 PlaySound("igMainMenuOption");
173 elseif (button == "RightButton") then
174 this:SetChecked(NRF_LOCKED);
175 local dropdown = getglobal(this:GetName().."DropDown");
176 GenerateMenu();
177 ToggleDropDownMenu(1, nil, dropdown, this:GetName(), 0, 0);
178 local offscreenX, offscreenY = utility:OffScreen(DropDownList1);
179 local point;
180 if (offscreenX == 1) then
181 point = "TOPRIGHT";
182 elseif (offscreenY == 1) then
183 point = "BOTTOMRIGHT";
184 else
185 point = "TOPLEFT";
186 end
187 DropDownList1:ClearAllPoints();
188 DropDownList1:SetPoint(point, this, "BOTTOMLEFT", 0, 0);
189 end
190 end
191  
192 local function Nurfed_LockButton_OnUpdate()
193 if (this.isMoving) then
194 if (not IsShiftKeyDown()) then
195 this.isMoving = nil;
196 return;
197 end
198  
199 -- Credit to Alex Brazie for this calculation
200 cursorX, cursorY = GetCursorPosition();
201 centerX, centerY = Minimap:GetCenter();
202 scale = Minimap:GetEffectiveScale();
203 cursorX = cursorX / scale;
204 cursorY = cursorY / scale;
205 local radius = (Minimap:GetWidth()/2) + (this:GetWidth()/3);
206 local x = math.abs(cursorX - centerX);
207 local y = math.abs(cursorY - centerY);
208 local xSign = 1;
209 local ySign = 1;
210 if (not (cursorX >= centerX)) then
211 xSign = -1;
212 end
213 if (not (cursorY >= centerY)) then
214 ySign = -1;
215 end
216  
217 local angle = math.atan(x/y);
218 x = math.sin(angle)*radius;
219 y = math.cos(angle)*radius;
220 saved.lockx = xSign*x;
221 saved.locky = ySign*y;
222  
223 Update_Lock_POS();
224 end
225 end
226  
227 local function Init()
228 local tbl = {
229 type = "CheckButton",
230 size = { 25, 25 },
231 FrameStrata = "LOW",
232 Checked = NRF_LOCKED,
233 events = {
234 "PLAYER_LOGIN",
235 },
236 NormalTexture = NRF_IMG.."nurfedlocked",
237 children = {
238 DropDown = { type = "Frame" },
239 Border = {
240 type = "Texture",
241 size = { 57, 57 },
242 layer = "OVERLAY",
243 Texture = "Interface\\Minimap\\MiniMap-TrackingBorder",
244 Anchor = { "CENTER", "$parent", "CENTER", 11, -11 },
245 },
246 },
247 OnEvent = function() Nurfed_Lock_OnEvent() end,
248 OnClick = function() Nurfed_LockButton_OnClick(arg1) end,
249 OnMouseDown = function() if (IsShiftKeyDown()) then this.isMoving = true end end,
250 OnMouseUp = function() this.isMoving = nil end,
251 OnUpdate = function() Nurfed_LockButton_OnUpdate() end,
252 };
253 framelib:ObjectInit("Nurfed_LockButton", tbl, Minimap);
254 tbl = nil;
255 end
256  
257 Init();