vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 Bagnon_Menu
3 Functions for the dropdown menu for Bagnon_Forever
4  
5 Essentially the dropdown is used to switch between the inventory of other characters
6 Why not use a normal dropdown? It takes a lot of memory
7 --]]
8  
9 --[[ Dropdown Menus --]]--
10  
11 --create a player button, which is used to switch between characters
12 local function CreatePlayerButton(id, parent)
13 local button = CreateFrame("CheckButton", parent:GetName() .. id, parent, "BagnonForeverMenuNameBox");
14 if(id == 1) then
15 button:SetPoint("TOPLEFT", getglobal(parent:GetName() .. "Text"), "BOTTOMLEFT", -24, 2);
16 else
17 button:SetPoint("TOP", getglobal(parent:GetName() .. (id - 1) ), "BOTTOM", 0, 6);
18 end
19 return button;
20 end
21  
22 function BagnonForeverMenu_Show(frame)
23 BagnonForeverMenu.frame = frame;
24  
25 --update button info
26 local button, player;
27 local index = 0;
28  
29 for player in BagnonDB[GetRealmName()] do
30 index = index + 1;
31  
32 button = getglobal("BagnonForeverMenu" .. index) or CreatePlayerButton(index, BagnonForeverMenu);
33 button:SetText(player);
34  
35 if(frame.player == player) then
36 button:SetChecked(true);
37 button:Show();
38 else
39 button:SetChecked(false);
40 end
41 end
42  
43 local i = index + 1;
44 while getglobal("BagnonForeverMenu" .. i) do
45 getglobal("BagnonForeverMenu" .. i):Hide();
46 i = i + 1;
47 end
48  
49 --resize and position the frame
50 BagnonForeverMenu:SetHeight(38 + index * 20);
51 local x, y = GetCursorPosition();
52 x = x / UIParent:GetScale();
53 y = y / UIParent:GetScale();
54  
55 BagnonForeverMenu:ClearAllPoints();
56 BagnonForeverMenu:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", x - 32, y + 32);
57 BagnonForeverMenu:Show();
58 end