vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 StaticPopupDialogs["BONGOS_OPTIONS_SAVE_PROFILE"] = {
2 text = TEXT("Enter Layout Name:"),
3 button1 = TEXT(ACCEPT),
4 button2 = TEXT(CANCEL),
5 hasEditBox = 1,
6 maxLetters = 24,
7 OnAccept = function()
8 local text = getglobal(this:GetParent():GetName().."EditBox"):GetText();
9 if text ~= "" then
10 BProfile.Save(text);
11 BOptionsProfilesScrollBar_Update();
12 end
13 end,
14 EditBoxOnEnterPressed = function()
15 local text = getglobal(this:GetParent():GetName().."EditBox"):GetText();
16 if text ~= "" then
17 BProfile.Save(text);
18 BOptionsProfilesScrollBar_Update();
19 end
20 end,
21 OnShow = function()
22 getglobal(this:GetName().."EditBox"):SetFocus();
23 getglobal(this:GetName().."EditBox"):SetText(UnitName("player"));
24 getglobal(this:GetName().."EditBox"):HighlightText();
25 end,
26 OnHide = function()
27 if ChatFrameEditBox:IsVisible() then
28 ChatFrameEditBox:SetFocus();
29 end
30 getglobal(this:GetName().."EditBox"):SetText("");
31 end,
32 timeout = 0,
33 exclusive = 1,
34 hideOnEscape = 1
35 };
36  
37  
38 local listSize = 12;
39 local selectedButton;
40  
41 --[[ Profile Button ]]--
42  
43 function BOptionsProfileButton_OnClick(clickedButton)
44 for i = 1, listSize do
45 local button = getglobal("BOptionsPanelProfiles".. i);
46 if clickedButton ~= button then
47 button:UnlockHighlight();
48 else
49 button:LockHighlight();
50 end
51 end
52 selectedButton = clickedButton;
53 end
54  
55 function BOptionsProfilesButton_OnMousewheel(scrollframe, direction)
56 local scrollbar = getglobal(scrollframe:GetName() .. "ScrollBar");
57 scrollbar:SetValue(scrollbar:GetValue() - direction * (scrollbar:GetHeight() / 2));
58 BOptionsProfilesScrollBar_Update();
59 end
60  
61 --[[ Profile Actions ]]--
62 function BOptionsProfiles_SaveProfile()
63 StaticPopup_Show("BONGOS_OPTIONS_SAVE_PROFILE");
64 end
65  
66 function BOptionsProfiles_LoadProfile()
67 if selectedButton then
68 BProfile.Load(selectedButton:GetText());
69 BOptionsProfilesScrollBar_Update();
70 end
71 end
72  
73 --delete
74 function BOptionsProfiles_DeleteProfile()
75 if selectedButton then
76 BProfile.Delete(selectedButton:GetText());
77 BOptionsProfilesScrollBar_Update();
78 end
79 end
80  
81 --set default
82 function BOptionsProfiles_SetDefaultProfile()
83 if selectedButton then
84 BProfile.SetDefault(selectedButton:GetText());
85 BOptionsProfilesScrollBar_Update();
86 end
87 end
88  
89 --[[ Scroll Bar Functions ]]--
90 function BOptionsProfiles_OnShow()
91 BOptionsProfilesScrollBar_Update();
92 end
93  
94 function BOptionsProfilesScrollBar_Update(parentName)
95 --update list if there are changes
96 local list = {}
97  
98 if BongosProfiles then
99 for name in BongosProfiles do
100 if name ~= "default" then
101 table.insert(list, name);
102 end
103 end
104 end
105 table.sort(list);
106  
107 local size = table.getn(list);
108 local offset = BOptionsPanelProfilesScrollFrame.offset;
109 local defaultName = BProfile.GetDefault();
110  
111 FauxScrollFrame_Update(BOptionsPanelProfilesScrollFrame, size, listSize, listSize);
112  
113 for index = 1, listSize do
114 local rIndex = index + offset;
115 local button = getglobal("BOptionsPanelProfiles".. index);
116  
117 if rIndex <= size then
118 button:SetText(list[rIndex]);
119 if defaultName == list[rIndex] then
120 button:SetTextColor(0, 1, 0);
121 else
122 button:SetTextColor(1, 0.82, 0);
123 end
124 button:Show();
125 else
126 button:Hide();
127 end
128 end
129 end