-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAutoBarChooseCategory.lua
138 lines (125 loc) · 4.97 KB
/
AutoBarChooseCategory.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
--
-- AutoBarConfigSlot
--
-- Slot Config functions
--
-- Maintained by Azethoth / Toadkiller of Proudmoore.
-- http://www.curse-gaming.com/en/wow/addons-4430-1-autobar-toadkiller.html
--
--
-- Config Checkbox Handling
--
AutoBarChooseCategory = {};
local L = AceLibrary("AceLocale-2.1"):GetInstance("AutoBar", true);
function AutoBarChooseCategory.OnScroll()
GameTooltip:Hide();
AutoBarChooseCategory:OnShow();
end
function AutoBarChooseCategory:OnShow()
if (AutoBarChooseCategoryFrame.categoryexplore and not AutoBar_Category_Info[AutoBarChooseCategoryFrame.categoryexplore]) then
AutoBarChooseCategoryFrame.categoryexplore = nil;
end
if (AutoBarChooseCategoryFrame.categoryexplore) then
AutoBarChooseCategoryFrame_HintText1:Hide();
local category = AutoBarChooseCategoryFrame.categoryexplore;
FauxScrollFrame_Update(AutoBarChooseCategoryFrame_Scroll, table.getn(AutoBar_Category_Info[category].items), 7, 36);
local offset = FauxScrollFrame_GetOffset(AutoBarChooseCategoryFrame_Scroll);
local index,name,texture;
for index = 1, 7, 1 do
local button = getglobal("AutoBarChooseCategoryFrame_Button"..index);
local hotkey = getglobal("AutoBarChooseCategoryFrame_Button"..index.."HotKey");
local count = getglobal("AutoBarChooseCategoryFrame_Button"..index.."Count");
local icon = getglobal("AutoBarChooseCategoryFrame_Button"..index.."Icon");
local text = getglobal("AutoBarChooseCategoryFrame_Text"..index);
button.category = nil;
if (AutoBar_Category_Info[category].items[index+offset]) then
if (type(AutoBar_Category_Info[category].items[index+offset]) == "number") then
name,_,_,_,_,_,_,_,texture = GetItemInfo(AutoBar_Category_Info[category].items[index+offset]);
if (not name) then
name = AUTOBAR_CONFIG_NOTFOUND..AutoBar_Category_Info[category].items[index+offset]..")";
texture = "Interface\\Icons\\INV_Misc_Gift_01";
elseif (not texture) then
texture = "Interface\\Icons\\INV_Misc_Gift_02";
end
else
texture = "Interface\\Icons\\INV_Misc_Gift_03";
name = AutoBar_Category_Info[category].items[index+offset];
end
icon:SetTexture(texture);
text:SetText(name);
count:SetText("");
button:Show();
button.itemid = tonumber(AutoBar_Category_Info[category].items[index+offset]);
else
button:Hide();
button.itemid = nil;
text:SetText("");
end
end
else
AutoBarChooseCategoryFrame_HintText1:Show();
local sortedCategories = {};
for categoryName, rec in pairs(AutoBar_Category_Info) do
table.insert(sortedCategories, categoryName);
end
table.sort (sortedCategories);
table.insert(sortedCategories, 1, "EMPTY");
FauxScrollFrame_Update(AutoBarChooseCategoryFrame_Scroll, table.getn(sortedCategories), 7, 36);
local offset = FauxScrollFrame_GetOffset(AutoBarChooseCategoryFrame_Scroll);
local index;
for index = 1, 7, 1 do
local button = getglobal("AutoBarChooseCategoryFrame_Button"..index);
local hotkey = getglobal("AutoBarChooseCategoryFrame_Button"..index.."HotKey");
local count = getglobal("AutoBarChooseCategoryFrame_Button"..index.."Count");
local icon = getglobal("AutoBarChooseCategoryFrame_Button"..index.."Icon");
local text = getglobal("AutoBarChooseCategoryFrame_Text"..index);
button.itemid = nil;
if (sortedCategories[index+offset] == "EMPTY") then
icon:SetTexture("");
count:SetText(L["EMPTY"]);
text:SetText(L["AUTOBAR_CONFIG_REMOVECAT"]);
button:Show();
button.category = sortedCategories[index+offset];
elseif (sortedCategories[index+offset]) then
icon:SetTexture(AutoBar_GetTexture(sortedCategories[index+offset]));
count:SetText("");
text:SetText(AutoBar_Category_Info[sortedCategories[index+offset]].description);
button.category = sortedCategories[index+offset];
button:Show();
else
button:Hide();
button.category = nil;
text:SetText("");
end
end
end
end
function AutoBarChooseCategory:ButtonOnClick(mousebutton)
ResetCursor();
AutoBar.dragging = nil;
if (IsShiftKeyDown()) then
if (AutoBarChooseCategoryFrame.categoryexplore) then
AutoBarChooseCategoryFrame.categoryexplore = nil;
this:GetParent():Hide();
else
local category = this.category;
if (category == "EMPTY") then category = nil; end
if (category) then
AutoBarChooseCategoryFrame.categoryexplore = category;
AutoBarChooseCategory:OnShow();
end
end
else
local category = this.category;
if (category == "EMPTY") then category = nil; end
if (AutoBarChooseCategoryFrame.editting) then
AutoBar_Config[AutoBarConfig.editPlayer].buttons[AutoBarConfigSlot.slotsIndex][AutoBarChooseCategoryFrame.editting] = category;
else
AutoBar_Config[AutoBarConfig.editPlayer].buttons[AutoBarConfigSlot.slotsIndex] = category;
end
AutoBarChooseCategoryFrame.categoryexplore = nil;
this:GetParent():Hide();
AutoBarProfile:ButtonsChanged();
end
return nil;
end