Mercurial > wow > reagentmaker
comparison ReagentMaker.lua @ 70:32ec6417874a
Change the internal data format (not done yet for the external window)
| author | contrebasse |
|---|---|
| date | Sat, 14 May 2011 20:19:22 +0200 |
| parents | 60871b43531d |
| children | 9cf4ca2145a3 |
comparison
equal
deleted
inserted
replaced
| 69:0675410645de | 70:32ec6417874a |
|---|---|
| 124 | 124 |
| 125 -- Continue only if the reagent is known | 125 -- Continue only if the reagent is known |
| 126 if not reagentID or not A.data[reagentID] then return end | 126 if not reagentID or not A.data[reagentID] then return end |
| 127 | 127 |
| 128 -- If only one recipe is known for the reagent, use it | 128 -- If only one recipe is known for the reagent, use it |
| 129 if #(A.data[reagentID]) == 1 and not A.data[reagentID].spell then | 129 if #(A.data[reagentID]) == 1 and not A.data[reagentID][1].macro then |
| 130 local numMakable, reagentIndex = A.numMakable(reagentID) | 130 local numMakable, reagentIndex = A.numMakable(reagentID) |
| 131 if not numMakable then | 131 if not numMakable then |
| 132 A.Error(L["The recipe to make the reagent seems to be hidden, it is not makable."]) | 132 A.Error(L["The recipe to make the reagent seems to be hidden, it is not makable."]) |
| 133 return | 133 return |
| 134 end | 134 end |
| 137 return | 137 return |
| 138 end | 138 end |
| 139 | 139 |
| 140 -- If we can make the item needed to make the reagent, open a window to make it | 140 -- If we can make the item needed to make the reagent, open a window to make it |
| 141 -- one step recursion, enables to mill to create an ink | 141 -- one step recursion, enables to mill to create an ink |
| 142 if (not A.data[reagentID].manyReagents) and A.data[A.data[reagentID][1][1]] then | 142 if (not A.data[reagentID][1].manyReagents) and A.data[A.data[reagentID][1][1]] then |
| 143 A.externalCraftWindow(A.data[reagentID][1][1],reagentID) | 143 A.externalCraftWindow(A.data[reagentID][1][1],reagentID) |
| 144 else | 144 else |
| 145 A.Error(L["You do not have enough reagents to craft [%s]"]:format(GetItemInfo(reagentID) or "item #"..reagentID)) | 145 A.Error(L["You do not have enough reagents to craft [%s]"]:format(GetItemInfo(reagentID) or "item #"..reagentID)) |
| 146 end | 146 end |
| 147 return | 147 return |
| 212 -- Continue only if the reagent is known | 212 -- Continue only if the reagent is known |
| 213 if not reagentID or not A.data[reagentID] then return end | 213 if not reagentID or not A.data[reagentID] then return end |
| 214 | 214 |
| 215 btn.textureHighlight:Show() | 215 btn.textureHighlight:Show() |
| 216 | 216 |
| 217 -- Check if the item is made by only one recipe. If not, return | |
| 218 if #A.data[reagentID]>1 then | |
| 219 local spellLink | |
| 220 for _,v in ipairs(A.data[reagentID]) do | |
| 221 if not spellLink then | |
| 222 spellLink = v.spellLink | |
| 223 else | |
| 224 if v.spellLink ~= spellLink then | |
| 225 return | |
| 226 end | |
| 227 end | |
| 228 end | |
| 229 end | |
| 230 | |
| 217 -- Tooltips | 231 -- Tooltips |
| 218 local link = A.data[reagentID].spellLink | 232 local link = A.data[reagentID][1].spellLink |
| 219 if link then | 233 if link then |
| 220 A.tooltipRecipe:SetOwner(btn) | 234 A.tooltipRecipe:SetOwner(btn) |
| 221 A.tooltipRecipe:SetHyperlink(link) | 235 A.tooltipRecipe:SetHyperlink(link) |
| 222 A.tooltipRecipe:Show() | 236 A.tooltipRecipe:Show() |
| 223 A.tooltipRecipe:ClearAllPoints() | 237 A.tooltipRecipe:ClearAllPoints() |
| 224 A.tooltipRecipe:SetPoint("BOTTOMLEFT",GameTooltip,"BOTTOMRIGHT") | 238 A.tooltipRecipe:SetPoint("BOTTOMLEFT",GameTooltip,"BOTTOMRIGHT") |
| 225 else | |
| 226 -- Shouldn't happend, but just in case... | |
| 227 A.Error(L["Recipe link not found for %s"]:format(reagentID)) | |
| 228 end | 239 end |
| 229 end | 240 end |
| 230 | 241 |
| 231 function A.btnLeft(btn) | 242 function A.btnLeft(btn) |
| 232 btn.textureHighlight:Hide() | 243 btn.textureHighlight:Hide() |
| 238 if not recipeIndex then return end | 249 if not recipeIndex then return end |
| 239 | 250 |
| 240 -- Do not manage guild tradeskill | 251 -- Do not manage guild tradeskill |
| 241 if IsTradeSkillGuild() or IsTradeSkillLinked() then | 252 if IsTradeSkillGuild() or IsTradeSkillLinked() then |
| 242 for reagentRecipeIndex = 1,GetTradeSkillNumReagents(recipeIndex) do | 253 for reagentRecipeIndex = 1,GetTradeSkillNumReagents(recipeIndex) do |
| 243 _G["TradeSkillReagent"..reagentRecipeIndex].label:Hide() | 254 -- If the normal tradeskill hasn't been opened yet, the field 'label' doesn't exists yet |
| 255 local label = _G["TradeSkillReagent"..reagentRecipeIndex].label | |
| 256 if label then | |
| 257 label:Hide() | |
| 258 end | |
| 244 end | 259 end |
| 245 return | 260 return |
| 246 end | 261 end |
| 247 | 262 |
| 248 -- Count makable items and show it | 263 -- Count makable items and show it |
| 250 -- ID of the reagent we want to craft | 265 -- ID of the reagent we want to craft |
| 251 local reagentLink = GetTradeSkillReagentItemLink(recipeIndex, reagentRecipeIndex) | 266 local reagentLink = GetTradeSkillReagentItemLink(recipeIndex, reagentRecipeIndex) |
| 252 local reagentID = A.link2ID(reagentLink) | 267 local reagentID = A.link2ID(reagentLink) |
| 253 | 268 |
| 254 local label = _G["TradeSkillReagent"..reagentRecipeIndex].label | 269 local label = _G["TradeSkillReagent"..reagentRecipeIndex].label |
| 255 if not label then return end | 270 if not label then break end -- Shouldn't happen... |
| 256 | 271 |
| 257 -- Continue only if the reagent is known | 272 -- Continue only if the reagent is known |
| 258 if not reagentID or not A.data[reagentID] or #(A.data[reagentID]) ~= 1 or A.data[reagentID].spell then | 273 if not reagentID or not A.data[reagentID] then |
| 259 label:Hide() | 274 label:Hide() |
| 260 else | 275 else |
| 261 -- Count and show | 276 -- Count and show |
| 262 local numMakable = A.numMakable(reagentID) | 277 local numMakable = A.numMakable(reagentID) |
| 263 label:SetText(numMakable or "?") | 278 if not numMakable or #(A.data[reagentID]) ~= 1 or A.data[reagentID][1].macro then |
| 264 if not numMakable or numMakable==0 then | 279 label:SetText("?") |
| 265 label:SetTextColor(1, 0, 0, 1) | 280 label:SetTextColor(0, 0.5, 1, 1) -- blue |
| 266 else | 281 else |
| 267 label:SetTextColor(0, 5, 0, 1) | 282 label:SetText(numMakable) |
| 283 if numMakable==0 then | |
| 284 label:SetTextColor(1, 0, 0, 1) -- red | |
| 285 else | |
| 286 label:SetTextColor(0, 1, 0, 1) -- green | |
| 287 end | |
| 268 end -- if | 288 end -- if |
| 269 label:Show() | 289 label:Show() |
| 270 end -- if | 290 end -- if |
| 271 end -- for | 291 end -- for |
| 272 end -- function | 292 end -- function |
