Mercurial > wow > reagentmaker
comparison SecureMenu.lua @ 10:b6a5902f376f
Display the percent chance to have an item while prospecting
| author | contrebasse |
|---|---|
| date | Sat, 02 Apr 2011 22:42:53 +0200 |
| parents | cea9633a6d4e |
| children | 2716889648bd |
comparison
equal
deleted
inserted
replaced
| 9:70f7d02c2cec | 10:b6a5902f376f |
|---|---|
| 133 countDetail:SetPoint("BOTTOMRIGHT",icon,"BOTTOMRIGHT",-1,1) | 133 countDetail:SetPoint("BOTTOMRIGHT",icon,"BOTTOMRIGHT",-1,1) |
| 134 countDetail:SetJustifyH("RIGHT") | 134 countDetail:SetJustifyH("RIGHT") |
| 135 countDetail:SetJustifyV("BOTTOM") | 135 countDetail:SetJustifyV("BOTTOM") |
| 136 btn.countDetail = countDetail | 136 btn.countDetail = countDetail |
| 137 | 137 |
| 138 local resultNumber = btn:CreateFontString(nil,"ARTWORK","NumberFontNormal") | |
| 139 resultNumber:SetPoint("TOPLEFT",icon,"TOPLEFT",1,-1) | |
| 140 resultNumber:SetJustifyH("LEFT") | |
| 141 resultNumber:SetJustifyV("TOP") | |
| 142 btn.resultNumber = resultNumber | |
| 143 | |
| 138 btn:HookScript("OnEnter", btnEntered) | 144 btn:HookScript("OnEnter", btnEntered) |
| 139 btn:HookScript("OnLeave", btnLeft) | 145 btn:HookScript("OnLeave", btnLeft) |
| 140 | 146 |
| 141 return btn | 147 return btn |
| 142 end | 148 end |
| 178 itemIcon:SetVertexColor(0.5, 0.5, 0.5) | 184 itemIcon:SetVertexColor(0.5, 0.5, 0.5) |
| 179 TitleText:SetTextColor(r,g,b,0.7) | 185 TitleText:SetTextColor(r,g,b,0.7) |
| 180 end | 186 end |
| 181 end | 187 end |
| 182 | 188 |
| 183 local function menuAddItem(action,itemID,reagentID,reagentsForOneRecipe,spellID) | 189 local function menuAddItem(action,itemID,reagent,spellID) |
| 184 local btn | 190 local btn |
| 185 -- Create a button only if necessary | 191 -- Create a button only if necessary |
| 186 if numActiveEntries >= #menuEntries then | 192 if numActiveEntries >= #menuEntries then |
| 187 btn = createMenuEntry() | 193 btn = createMenuEntry() |
| 188 else | 194 else |
| 189 btn = menuEntries[numActiveEntries+1] | 195 btn = menuEntries[numActiveEntries+1] |
| 190 end | 196 end |
| 191 | 197 |
| 192 -- Set text and icon | 198 -- Set text and icon |
| 193 local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(reagentID) | 199 local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(reagent[1]) |
| 194 if name then | 200 if name then |
| 195 btn.itemName:SetText(name) | 201 btn.itemName:SetText(name) |
| 196 else | 202 else |
| 197 A.DEBUG("No item name : "..reagentID) | 203 A.DEBUG("No item name : "..reagent[1]) |
| 198 return | 204 return |
| 199 end | 205 end |
| 200 | 206 |
| 201 if texture then | 207 if texture then |
| 202 btn.icon:SetTexture(texture) | 208 btn.icon:SetTexture(texture) |
| 203 else | 209 else |
| 204 A.DEBUG("No item texture : "..reagentID) | 210 A.DEBUG("No item texture : "..reagent[1]) |
| 205 return | 211 return |
| 212 end | |
| 213 | |
| 214 -- Set chance to have the item or the number of items created | |
| 215 if reagent[3] then | |
| 216 if reagent[3]<1 then | |
| 217 btn.resultNumber:SetText((reagent[3]*100).."%") | |
| 218 elseif reagent[3]>1 then | |
| 219 btn.resultNumber:SetText(reagent[3]) | |
| 220 end | |
| 206 end | 221 end |
| 207 | 222 |
| 208 -- Save params | 223 -- Save params |
| 209 btn.itemID = itemID | 224 btn.itemID = itemID |
| 210 btn.reagentID = reagentID | 225 btn.reagentID = reagent[1] |
| 211 btn.reagentLink = link | 226 btn.reagentLink = link |
| 212 btn.reagentsForOneRecipe = reagentsForOneRecipe | 227 btn.reagentsForOneRecipe = reagent[2] |
| 213 btn.spellID = spellID | 228 btn.spellID = spellID |
| 214 | 229 |
| 215 -- Set action | 230 -- Set action |
| 216 if type(action)=="function" then | 231 if type(action)=="function" then |
| 217 btn:SetScript("PreClick",action) | 232 btn:SetScript("PreClick",action) |
| 253 | 268 |
| 254 -- Loop over the available recipes | 269 -- Loop over the available recipes |
| 255 for _,reagent in ipairs(A.data[itemID]) do | 270 for _,reagent in ipairs(A.data[itemID]) do |
| 256 if A.data[itemID].spell then | 271 if A.data[itemID].spell then |
| 257 -- Special spell | 272 -- Special spell |
| 258 menuAddItem(A.data[itemID].spell,itemID,reagent[1],reagent[2],A.data[itemID].spellID) | 273 menuAddItem(A.data[itemID].spell,itemID,reagent,A.data[itemID].spellID) |
| 259 else | 274 else |
| 260 -- Standard tradeskill spell UNTESTED | 275 -- Standard tradeskill spell UNTESTED |
| 261 menuAddItem(A.craft,itemID,reagent[1],reagent[2]) | 276 menuAddItem(A.craft,itemID,reagent) |
| 262 end -- if | 277 end -- if |
| 263 end -- for | 278 end -- for |
| 264 | 279 |
| 265 MenuFrame:SetHeight(89 + numActiveEntries*(MENU_ENTRY_HEIGHT+2)) | 280 MenuFrame:SetHeight(89 + numActiveEntries*(MENU_ENTRY_HEIGHT+2)) |
| 266 | 281 |
