vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local tradeskillPluginLoaded = false;
2 local craftPluginLoaded = false;
3  
4 GuildAdsCraftFrame = {
5  
6 metaInformations = {
7 name = "GuildAdsCraftFrame",
8 guildadsCompatible = 100,
9 };
10  
11 onLoad = function()
12 this:RegisterEvent("CRAFT_SHOW");
13 this:RegisterEvent("TRADE_SKILL_SHOW");
14 GuildAdsPlugin.UIregister(GuildAdsCraftFrame);
15 end;
16  
17 onEvent = function(event)
18 if event=="CRAFT_SHOW" then
19 if not craftPluginLoaded then
20 GuildAdsCraftButton:ClearAllPoints();
21 GuildAdsCraftButton:SetParent("CraftFrame");
22 GuildAdsCraftButton:SetPoint("BOTTOMRIGHT", CraftCancelButton, "TOPRIGHT");
23 GuildAdsCraftButton:Show();
24 craftPluginLoaded = true;
25 end
26 elseif event=="TRADE_SKILL_SHOW" then
27 if not tradeskillPluginLoaded then
28 GuildAdsTradeskillButton:ClearAllPoints();
29 GuildAdsTradeskillButton:SetParent("TradeSkillFrame");
30 GuildAdsTradeskillButton:SetPoint("BOTTOMRIGHT", TradeSkillCancelButton, "TOPRIGHT");
31 GuildAdsTradeskillButton:Show();
32 tradeskillPluginLoaded = true;
33 end
34 end
35 end;
36  
37 onChannelJoin = function()
38 if tradeskillPluginLoaded then
39 GuildAdsTradeskillButton:Show();
40 end
41 if craftPluginLoaded then
42 GuildAdsCraftButton:Show();
43 end
44 end;
45  
46 onChannelLeave = function()
47 if tradeskillPluginLoaded then
48 GuildAdsTradeskillButton:Hide();
49 end
50 if craftPluginLoaded then
51 GuildAdsCraftButton:Hide();
52 end
53 end;
54  
55 askItem = function(item)
56 if item and item.name then
57 GuildAdsPlugin.addMyAd(GUILDADS_MSG_TYPE_REQUEST, "", item.color, item.ref, item.name, item.texture, item.count);
58 end
59 end;
60  
61 onClickHave = function()
62 local item = this.value;
63 GuildAdsPlugin.addMyAd(GUILDADS_MSG_TYPE_AVAILABLE, item.text, item.color, item.ref, item.name, item.texture, item.count);
64 end;
65  
66 onClickAskItem = function()
67 local item = this.value;
68 GuildAdsCraftFrame.askItem(item);
69 end;
70  
71 onClickAskEverything = function()
72 for k,item in this.value do
73 GuildAdsCraftFrame.askItem(item);
74 end
75 end;
76  
77 buttons = {
78 onClick = function(initializeMenu)
79 HideDropDownMenu(1);
80 GuildAdsCraftFrameMenu.initialize = initializeMenu;
81 GuildAdsCraftFrameMenu.displayMode = "MENU";
82 GuildAdsCraftFrameMenu.name = "Titre";
83 ToggleDropDownMenu(1, nil, GuildAdsCraftFrameMenu, "cursor");
84 end;
85  
86 initializeTradeskillMenu = function(level)
87 local id = TradeSkillFrame.selectedSkill;
88 local skillName, skillType, numAvailable, isExpanded = GetTradeSkillInfo(id);
89 local count = TradeSkillInputBox:GetNumber();
90  
91 ------
92 local composants = { };
93 local menu = { };
94  
95 local count = TradeSkillInputBox:GetNumber();
96 local numReagents = GetTradeSkillNumReagents(id);
97 for i=1, numReagents, 1 do
98 local reagentName, reagentTexture, reagentCount, playerReagentCount = GetTradeSkillReagentInfo(id, i);
99 local link = GetTradeSkillReagentItemLink(id, i);
100 local itemColor, itemRef, itemName = GAS_UnpackLink(link);
101  
102 local info = {
103 notCheckable = 1;
104 func = GuildAdsCraftFrame.onClickAskItem;
105 tooltipTitle = info.text;
106 tooltipText = GUILDADS_TS_ASKITEMS_TT;
107 value = {
108 color = itemColor;
109 ref = itemRef;
110 name = itemName;
111 texture = reagentTexture;
112 }
113 };
114 if (count > 1) then
115 info.value.count = (count*reagentCount)-playerReagentCount;
116 info.text = GUILDADS_BUTTON_ADDREQUEST.." "..info.value.count.." "..reagentName;
117  
118 else
119 info.text = GUILDADS_BUTTON_ADDREQUEST.." "..reagentName;
120 end
121  
122 tinsert(composants, info.value);
123 tinsert(menu, info);
124 end
125  
126 ---- Propose
127 local link = GetTradeSkillItemLink(id);
128 local itemColor, itemRef, itemName = GAS_UnpackLink(link);
129  
130 info = {
131 text = GUILDADS_BUTTON_ADDAVAILABLE.." "..skillName;
132 notCheckable = 1;
133 func = GuildAdsCraftFrame.onClickHave;
134 value = {
135 color=itemColor;
136 ref=itemRef;
137 name=itemName;
138 count=count;
139 texture=GetTradeSkillIcon(id)
140 };
141 };
142 UIDropDownMenu_AddButton(info, 1);
143  
144 ---- Demande tous les composants
145 info = {
146 notCheckable = 1;
147 text = string.format(GUILDADS_TS_ASKITEMS, count, skillName);
148 tooltipTitle = skillName;
149 tooltipText = GUILDADS_TS_ASKITEMS_TT;
150 func = GuildAdsCraftFrame.onClickAskEverything;
151 value = composants;
152 };
153 UIDropDownMenu_AddButton(info, 1);
154  
155 ---- Demande un composant en particulier
156 for k,info in menu do
157 UIDropDownMenu_AddButton(info, 1);
158 end
159  
160 PlaySound("igMainMenuOpen");
161 end;
162  
163 -- by ElPico
164 initializeCraftMenu = function(level)
165 local id = GetCraftSelectionIndex();
166 local craftName, craftSubSpellName, craftType, numAvailable, isExpanded = GetCraftInfo(id);
167 local craftDesc = GetCraftDescription(id);
168 local count = 1;
169  
170 ------
171 local composants = { };
172 local menu = { };
173  
174 local numReagents = GetCraftNumReagents(id);
175 for i=1, numReagents, 1 do
176 local reagentName, reagentTexture, reagentCount, playerReagentCount = GetCraftReagentInfo(id, i);
177 local link = GetCraftReagentItemLink(id, i);
178 local itemColor, itemRef, itemName = GAS_UnpackLink(link);
179  
180 local info = {
181 value = {
182 color = itemColor;
183 ref = itemRef;
184 name = itemName;
185 count = reagentCount;
186 texture=reagentTexture
187 };
188 text = GUILDADS_BUTTON_ADDREQUEST.." "..reagentCount.." "..reagentName;
189 notCheckable = 1;
190 func = GuildAdsCraftFrame.onClickAskItem;
191 tooltipTitle = info.text;
192 };
193  
194 tinsert(composants, info.value);
195 tinsert(menu, info);
196 end
197  
198 ---- Propose
199 ---- GetCraftItemLink(id) ne marche pas :
200 ---- cas1: le link est invalide pour des objets comme "Cuir enchanté" ou "Baguettes" (...)
201 ---- cas2: le link est nil pour des enchantements (...)
202 info = {
203 text = GUILDADS_BUTTON_ADDAVAILABLE.." "..craftName.." "..craftSubSpellName;
204 notCheckable = 1;
205 func = GuildAdsCraftFrame.onClickHave;
206 value = {
207 color="ffffffff";
208 ref=nil; -- GetCraftItemLink(id);
209 name=craftName;
210 texture=GetCraftIcon(id);
211 -- quelques enchants n'ont pas de description ("Thorium enchanté"...)
212 text=craftDesc
213 };
214 };
215 UIDropDownMenu_AddButton(info, 1);
216  
217 ---- Demande tous les composants
218 info = {
219 notCheckable = 1;
220 text = string.format(GUILDADS_TS_ASKITEMS, count, craftName);
221 tooltipTitle = craftName;
222 tooltipText = GUILDADS_TS_ASKITEMS_TT;
223 func = GuildAdsCraftFrame.onClickAskEverything;
224 value = composants;
225 };
226 UIDropDownMenu_AddButton(info, 1);
227  
228 ---- Demande un composant en particulier
229 for k,info in menu do
230 UIDropDownMenu_AddButton(info, 1);
231 end
232  
233 PlaySound("igMainMenuOpen");
234 end;
235  
236 };
237  
238 };