Mercurial > wow > reagentmaker
changeset 5:cea9633a6d4e
Added some tooltips and text color
author | contrebasse |
---|---|
date | Sat, 02 Apr 2011 17:13:16 +0200 |
parents | 3a1997d21468 |
children | 43e21c6513e0 |
files | ReagentMaker.lua SecureMenu.lua |
diffstat | 2 files changed, 53 insertions(+), 69 deletions(-) [+] |
line wrap: on
line diff
--- a/ReagentMaker.lua Sat Apr 02 14:54:55 2011 +0200 +++ b/ReagentMaker.lua Sat Apr 02 17:13:16 2011 +0200 @@ -76,14 +76,12 @@ btn.label = label end -- for - --[[ A.tooltipRecipe = CreateFrame("GameTooltip", "ReagentMaker_tooltipRecipe",UIParent, "GameTooltipTemplate") A.tooltipRecipe:SetFrameStrata("TOOLTIP") A.tooltipRecipe:Hide() A.tooltipReagent = CreateFrame("GameTooltip", "ReagentMaker_tooltipReagent",UIParent, "GameTooltipTemplate") A.tooltipReagent:SetFrameStrata("TOOLTIP") A.tooltipReagent:Hide() - --]] end -- function @@ -190,27 +188,25 @@ btn.label:Show() end - --[[ + -- Tooltips A.tooltipRecipe:SetOwner(btn) A.tooltipRecipe:SetHyperlink(GetTradeSkillRecipeLink(A.findSkillIndex(reagentID))) - A.tooltipRecipe:SetHyperlink(reagentLink) + A.tooltipRecipe:Show() A.tooltipRecipe:ClearAllPoints() - A.tooltipRecipe:SetPoint("TOPLEFT",btn,"TOPRIGHT") - --A.tooltipRecipe:SetSize(100,100) - A.tooltipRecipe:Show() - A.tooltipReagent:SetOwner(btn) - A.tooltipReagent:SetHyperlink(reagentLink) + --A.tooltipRecipe:SetPoint("TOPLEFT",btn,"TOPRIGHT") + A.tooltipRecipe:SetPoint("BOTTOMLEFT",GameTooltip,"BOTTOMRIGHT") + + A.tooltipReagent:SetOwner(A.tooltipRecipe) + local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(A.data[reagentID][1][1]) + A.tooltipReagent:SetHyperlink(link) + A.tooltipReagent:Show() A.tooltipReagent:ClearAllPoints() - A.tooltipReagent:SetPoint("TOPLEFT",A.tooltipRecipe,"TOPRIGHT") - A.tooltipReagent:Show() - --]] + A.tooltipReagent:SetPoint("BOTTOMLEFT",A.tooltipRecipe,"BOTTOMRIGHT") end function A.btnLeft(btn) btn.textureHighlight:Hide() btn.label:Hide() - --[[ A.tooltipRecipe:Hide() A.tooltipReagent:Hide() - --]] end
--- a/SecureMenu.lua Sat Apr 02 14:54:55 2011 +0200 +++ b/SecureMenu.lua Sat Apr 02 17:13:16 2011 +0200 @@ -58,10 +58,10 @@ local menuEntries = {} -- Button hovering -local function btnEntered(self) +local function btnEntered(btn) --[[ -- Index of the reagent in the recipe, taken from the button name - local reagentRecipeIndex = A.buttonNumber(self) + local reagentRecipeIndex = A.buttonNumber(btn) -- ID of the reagent we want to craft local reagentID = A.link2ID(GetTradeSkillReagentItemLink(GetTradeSkillSelectionIndex(), reagentRecipeIndex)) @@ -70,27 +70,26 @@ if not reagentID or not A.data[reagentID] then return end --]] - self.textureHighlight:Show() + if btn.numMakable>0 then + btn.textureHighlight:Show() + end - --[[ - if #(A.data[reagentID]) == 1 and not A.data[reagentID].spell then - local numMakable = A.numMakable(reagentID) - self.itemName:SetText(numMakable) - if numMakable==0 then - self.itemName:SetTextColor(1, 0, 0, 1) - else - self.itemName:SetTextColor(0, 5, 0, 1) - end - self.itemName:Show() - end - --]] + GameTooltip:SetOwner(btn,"ANCHOR_TOPLEFT") + GameTooltip:SetHyperlink(btn.reagentLink) + GameTooltip:Show() + local link, tradeLink = GetSpellLink(btn.spellID) + A.tooltipRecipe:SetOwner(GameTooltip) + A.tooltipRecipe:SetHyperlink(link) + A.tooltipRecipe:Show() + A.tooltipRecipe:ClearAllPoints() + A.tooltipRecipe:SetPoint("BOTTOMLEFT",GameTooltip,"BOTTOMRIGHT") end -local function btnLeft(self) - self.textureHighlight:Hide() - --self.itemName:Hide() +local function btnLeft(btn) + btn.textureHighlight:Hide() + GameTooltip:Hide() + A.tooltipRecipe:Hide() end local function createMenuEntry() - --local btn = CreateFrame("Button", "ReagentMakerMenuButton"..(#menuEntries+1), MenuFrame, "SecureActionButtonTemplate") local btn = CreateFrame("Button", nil, MenuFrame, "SecureActionButtonTemplate") table.insert(menuEntries,btn) @@ -128,26 +127,17 @@ textureHighlight:SetTexture("Interface\\BUTTONS\\CheckButtonHilight") textureHighlight:SetBlendMode("ADD") textureHighlight:SetAllPoints(icon) - --textureHighlight:SetSize(MENU_ENTRY_HEIGHT,MENU_ENTRY_HEIGHT) btn.textureHighlight = textureHighlight + + local countDetail = btn:CreateFontString(nil,"ARTWORK","NumberFontNormal") + countDetail:SetPoint("BOTTOMRIGHT",icon,"BOTTOMRIGHT",-1,1) + countDetail:SetJustifyH("RIGHT") + countDetail:SetJustifyV("BOTTOM") + btn.countDetail = countDetail + btn:HookScript("OnEnter", btnEntered) btn:HookScript("OnLeave", btnLeft) - local countTotal = btn:CreateFontString(nil,"ARTWORK","NumberFontNormal") - --countTotal:SetSize(MENU_ENTRY_HEIGHT,MENU_ENTRY_HEIGHT/2) - countTotal:SetPoint("TOPLEFT",icon,"TOPLEFT",1,-1) - countTotal:SetJustifyH("LEFT") - countTotal:SetJustifyV("TOP") - --countTotal:SetFont("Fonts\\FRIZQT__.TTF", 10, "OUTLINE") - btn.countTotal = countTotal - - local countDetail = btn:CreateFontString(nil,"ARTWORK","NumberFontNormal") - --countDetail:SetSize(MENU_ENTRY_HEIGHT,MENU_ENTRY_HEIGHT/2) - countDetail:SetPoint("BOTTOMRIGHT",icon,"BOTTOMRIGHT",-1,1) - countDetail:SetJustifyH("RIGHT") - countDetail:SetJustifyV("BOTTOM") - --countDetail:SetFont("Fonts\\FRIZQT__.TTF", 12, "OUTLINE") - btn.countDetail = countDetail return btn end @@ -163,35 +153,34 @@ local itemCount = GetItemCount(btn.reagentID) local numMakable = math.floor(itemCount/(btn.reagentsForOneRecipe or 1)) - btn.countTotal:SetText(numMakable) btn.countDetail:SetText(itemCount.."/"..(btn.reagentsForOneRecipe or 1)) if numMakable>0 then anyMakable = true - btn.countTotal:SetTextColor(0, 5, 0, 1) - btn:Enable() - --btn.icon:SetDesaturated(false) + btn.countDetail:SetTextColor(1, 1, 1, 1) btn.icon:SetVertexColor(1,1,1); btn.itemName:SetTextColor(1,1,1,1) else - btn.countTotal:SetTextColor(1, 0, 0, 1) - btn:Disable() - --btn.icon:SetDesaturated(true) + -- Do not disable the button, to be able to show the tooltip + btn.countDetail:SetTextColor(1, 0.1, 0.1, 1) btn.icon:SetVertexColor(0.5, 0.5, 0.5) btn.itemName:SetTextColor(1,1,1,0.5) end + + btn.numMakable = numMakable end + local r,g,b = TitleText:GetTextColor() if anyMakable then itemIcon:SetVertexColor(1,1,1) - TitleText:SetTextColor(1,1,1,1) + TitleText:SetTextColor(r,g,b,1) else itemIcon:SetVertexColor(0.5, 0.5, 0.5) - TitleText:SetTextColor(1,1,1,0.5) + TitleText:SetTextColor(r,g,b,0.7) end end -local function menuAddItem(action,itemID,reagentID,reagentsForOneRecipe) +local function menuAddItem(action,itemID,reagentID,reagentsForOneRecipe,spellID) local btn -- Create a button only if necessary if numActiveEntries >= #menuEntries then @@ -206,37 +195,34 @@ btn.itemName:SetText(name) else A.DEBUG("No item name : "..reagentID) + return end if texture then btn.icon:SetTexture(texture) else A.DEBUG("No item texture : "..reagentID) + return end -- Save params btn.itemID = itemID btn.reagentID = reagentID + btn.reagentLink = link btn.reagentsForOneRecipe = reagentsForOneRecipe + btn.spellID = spellID -- Set action if type(action)=="function" then btn:SetScript("PreClick",action) btn:SetAttribute("type", nil) - btn:SetAttribute("spell", nil) - btn:SetAttribute("target-item",nil) + btn:SetAttribute("macrotext", nil) else --if type(action)=="string" then btn:SetScript("PreClick",nil) btn:SetAttribute("type", "macro") - btn:SetAttribute("macrotext", action..GetItemInfo(reagentID)) - --btn:SetAttribute("type", "macro") - --btn:SetAttribute("macrotext1","/cast Mouture\n/use Gangrelette") + btn:SetAttribute("macrotext", action..name) end -- if - -- Reposition MenuFrame - --MenuFrame:SetPoint("BOTTOMRIGHT",btn,"BOTTOMRIGHT",0,0) - --MenuFrame:SetHeight((numActiveEntries+1)*MENU_ENTRY_HEIGHT) - btn:Show() -- Increase the entry number @@ -262,12 +248,14 @@ local name, link, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(itemID) SetPortraitToTexture(itemIcon, texture) TitleText:SetText(name) + local color = ITEM_QUALITY_COLORS[quality] + TitleText:SetTextColor(color.r, color.g, color.b) -- Loop over the available recipes for _,reagent in ipairs(A.data[itemID]) do if A.data[itemID].spell then -- Special spell - menuAddItem(A.data[itemID].spell,itemID,reagent[1],reagent[2]) + menuAddItem(A.data[itemID].spell,itemID,reagent[1],reagent[2],A.data[itemID].spellID) else -- Standard tradeskill spell UNTESTED menuAddItem(A.craft,itemID,reagent[1],reagent[2])