vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 function tradeDispenser_Banlist_OnShow()
2 tradeDispenser_Banlist_Update()
3 if (UnitIsPlayer("target") and UnitIsFriend("target", "player")) then
4 tradeDispenserBanlistName:SetText(UnitName("target"));
5 else
6 tradeDispenserBanlistName:SetText("");
7 end
8 if (GetNumIgnores()>0) then
9 local i;
10 local New = false;
11 for i=1,GetNumIgnores() do
12 local j;
13 local found = false;
14 for j=1,table.getn(tD_GlobalDatas.Bannlist) do
15 if (strlower(tD_GlobalDatas.Bannlist[j])==strlower(GetIgnoreName(i))) then
16 found=true;
17 end
18 end
19 if (not found) then New=true end
20 end
21 if (New) then
22 tradeDispenserBanlistImport:Enable();
23 else
24 tradeDispenserBanlistImport:Disable();
25 end
26 else
27 tradeDispenserBanlistImport:Disable();
28 end
29 tradeDispenserBanlistAdd:Disable();
30 tradeDispenserBanlistRemove:Disable();
31 tradeDispenser_Banlist_Edit(tradeDispenserBanlistName);
32 end
33  
34  
35 function tradeDispenser_Banlist_Update()
36 local H = 0;
37 if (tradeDispenserSettings and tradeDispenserSettings:IsVisible()) then
38 H = 2+tradeDispenserSettingsText:GetHeight()
39 end
40 tradeDispenserBanlist:SetHeight(346+H);
41 tradeDispenserBanlistScrollBkg:SetHeight(206+H);
42 tradeDispenserBanlistScrollBar:SetHeight(206+H);
43 tD_Temp.Scroll.maxlines = math.floor((206+H)/12.25);
44 if (tD_GlobalDatas.Bannlist) then table.sort(tD_GlobalDatas.Bannlist) end
45 tradeDispenser_Banlist_Scroll()
46 end
47  
48  
49 function tradeDispenser_Banlist_Scroll()
50 if (not tD_Temp.Scroll.maxlines) then return end
51 if (not tD_GlobalDatas.Bannlist) then
52 tradeDispenserBanlistScrollText:SetText("");
53 tradeDispenserBanlistScrollBar:Hide();
54 return
55 end
56 tD_Temp.Scroll.start = tradeDispenserBanlistScrollBar:GetValue();
57 tD_Temp.Scroll.ende = table.getn(tD_GlobalDatas.Bannlist);
58 if (tD_Temp.Scroll.ende > tD_Temp.Scroll.maxlines) then
59 tradeDispenserBanlistScrollBar:Show();
60 tradeDispenserBanlistScrollBar:SetMinMaxValues(1, table.getn(tD_GlobalDatas.Bannlist)-tD_Temp.Scroll.maxlines+1);
61 tD_Temp.Scroll.ende = tD_Temp.Scroll.start + tD_Temp.Scroll.maxlines-1;
62 else
63 tD_Temp.Scroll.start=1;
64 tradeDispenserBanlistScrollBar:Hide();
65 end
66  
67 local temp="";
68 local i;
69 for i = tD_Temp.Scroll.start,tD_Temp.Scroll.ende do
70 temp=temp.." \n "..tD_GlobalDatas.Bannlist[i];
71 end
72 tradeDispenserBanlistScrollText:SetText(temp);
73  
74 end
75  
76  
77 function tradeDispenser_Banlist_Edit(Editbox)
78 if (not Editbox) then return end
79 if (not tD_Temp.BanListStatus) then tD_Temp.BanListStatus="inactive"; end
80 local name = strlower( Editbox:GetText() );
81 string.gsub(name," ","");
82 if (strlen(name)<1) then
83 tradeDispenserBanlistAdd:Disable();
84 tradeDispenserBanlistRemove:Disable();
85 tD_Temp.BanListStatus="inactive";
86 else
87 tradeDispenserBanlistAdd:Enable();
88 tradeDispenserBanlistRemove:Disable();
89 tD_Temp.BanListStatus="add";
90  
91 if (tD_GlobalDatas.Bannlist) then
92 local j;
93 local found = false;
94 for j=1,table.getn(tD_GlobalDatas.Bannlist) do
95 if (strlower(tD_GlobalDatas.Bannlist[j])==name) then
96 found=true;
97 end
98 end
99 if (found) then
100 tradeDispenserBanlistAdd:Disable();
101 tradeDispenserBanlistRemove:Enable();
102 tD_Temp.BanListStatus="remove";
103 end
104 end
105 end
106 end
107  
108  
109 function tradeDispenser_Banlist_Remove(name)
110 local j;
111 local found = 0;
112 for j=1,table.getn(tD_GlobalDatas.Bannlist) do
113 if (strlower(tD_GlobalDatas.Bannlist[j])==strlower(name)) then
114 found=j;
115 end
116 end
117 if (found>0) then
118 table.remove(tD_GlobalDatas.Bannlist,found);
119 tradeDispenserVerbose(1,"remove index "..found..": Name="..name);
120 else
121 tradeDispenserVerbose(1,"Name "..name.." not found");
122 end
123 tradeDispenserBanlistName:SetText("");
124 tradeDispenserBanlistRemove:Disable();
125 tradeDispenserBanlistAdd:Disable();
126 tD_Temp.BanListStatus="inactive";
127 tradeDispenser_Banlist_Scroll()
128 end
129  
130 function tradeDispenser_Banlist_Add(name)
131 --tradeDispenserVerbose(0,"Add");
132 if (name) then
133 table.insert(tD_GlobalDatas.Bannlist,name);
134 tradeDispenserVerbose(1,"Added Name "..name.." to Banlist");
135 end
136 table.sort(tD_GlobalDatas.Bannlist)
137 tradeDispenserBanlistRemove:Enable();
138 tradeDispenserBanlistAdd:Disable();
139 tD_Temp.BanListStatus="remove";
140 tradeDispenser_Banlist_Scroll()
141 end
142  
143  
144 function tradeDispenser_Banlist_Import()
145 if (GetNumIgnores()>0) then
146 local i;
147 for i=1,GetNumIgnores() do
148 local j;
149 local found = false;
150 for j=1,table.getn(tD_GlobalDatas.Bannlist) do
151 if (strlower(tD_GlobalDatas.Bannlist[j])==strlower(GetIgnoreName(i))) then
152 found=true;
153 end
154 end
155 if (not found) then
156 table.insert(tD_GlobalDatas.Bannlist,GetIgnoreName(i));
157 tradeDispenserVerbose(1,"Added Name "..GetIgnoreName(i).." to Banlist");
158 end
159 end
160 end
161 table.sort(tD_GlobalDatas.Bannlist)
162 tradeDispenserBanlistImport:Disable();
163 tradeDispenser_Banlist_Scroll()
164 end