Skip to content

Commit

Permalink
add profession db and combine with recipe db
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoizame committed Jul 10, 2019
1 parent e2cbfb2 commit c4c5aeb
Show file tree
Hide file tree
Showing 10 changed files with 2,251 additions and 910 deletions.
2 changes: 1 addition & 1 deletion AtlasLootClassic/AtlasLoot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function AtlasLoot:Print(msg)
end

function AtlasLoot:OnInitialize()
if not AtlasLootClassicCharDB.__addonrevision then --or AtlasLootDB.__addonrevision < AtlasLoot.__addonrevision then
if not AtlasLootClassicCharDB.__addonrevision or AtlasLootClassicCharDB.__addonrevision < AtlasLoot.__addonrevision then
wipe(AtlasLootClassicCharDB)
AtlasLootClassicCharDB.__addonrevision = AtlasLoot.__addonrevision
end
Expand Down
76 changes: 49 additions & 27 deletions AtlasLootClassic/Button/Profession_type.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ local AtlasLoot = _G.AtlasLoot
local Prof = AtlasLoot.Button:AddType("Profession", "prof")
local AL = AtlasLoot.Locales
local GetAlTooltip = AtlasLoot.Tooltip.GetTooltip
local Profession = AtlasLoot.Data.Profession

--lua
local str_match = string.match
Expand All @@ -11,36 +12,31 @@ local GetTradeskillLink = AtlasLoot.TooltipScan.GetTradeskillLink
local ProfClickHandler = nil

local PROF_COLOR = "|cffffff00"

local TRADESKILLS = {
[GetSpellInfo(2259)] = GetSpellTexture(2259), -- Alchemy
[GetSpellInfo(2018)] = GetSpellTexture(2018), -- Blacksmithing
[GetSpellInfo(2550)] = GetSpellTexture(2550), -- Cooking
[GetSpellInfo(7411)] = GetSpellTexture(7411), -- Enchanting
[GetSpellInfo(4036)] = GetSpellTexture(4036), -- Engineering
[GetSpellInfo(3273)] = GetSpellTexture(3273), -- First Aid
[GetSpellInfo(2108)] = GetSpellTexture(2108), -- Leatherworking
[GetSpellInfo(3908)] = GetSpellTexture(3908), -- Tailoring
[GetSpellInfo(2575)] = GetSpellTexture(2575), -- Mining
--[GetSpellInfo(63275)] = GetSpellTexture(63275), -- Fishing
[GetSpellInfo(2366)] = GetSpellTexture(2366), -- Herbalism
[GetSpellInfo(921)] = GetSpellTexture(921), -- Pick Pocket
}
local ITEM_COLORS = {}
local WHITE_ICON_FRAME = "Interface\\Common\\WhiteIconFrame"

function Prof.OnSet(button, second)
if not ProfClickHandler then
ProfClickHandler = AtlasLoot.ClickHandler:Add(
"Profession",
{
ChatLink = { "LeftButton", "Shift" },
ShowExtraItems = { "LeftButton", "None" },
types = {
ChatLink = true,
ShowExtraItems = true,
},
},
AtlasLoot.db.Button.Profession.ClickHandler,
{
{ "ChatLink", AL["Chat Link"], AL["Add profession link into chat"] },
{ "ShowExtraItems", AL["Show extra items"], AL["Shows extra items (tokens,mats)"] },
})
-- create item colors
for i=0,7 do
local _, _, _, itemQuality = GetItemQualityColor(i)
ITEM_COLORS[i] = itemQuality
end
end
if not button then return end
if second and button.__atlaslootinfo.secType then
Expand All @@ -61,14 +57,17 @@ function Prof.OnClear(button)
button.secButton.Profession = nil
button.secButton.SpellID = nil
button.secButton.tsLink, button.secButton.tsName = nil, nil

if button.ExtraFrameShown then
AtlasLoot.Button:ExtraItemFrame_ClearFrame()
button.ExtraFrameShown = false
end
end

function Prof.OnEnter(button)
local tooltip = GetAlTooltip()
tooltip:ClearLines()
tooltip:SetOwner(button, "ANCHOR_RIGHT", -(button:GetWidth() * 0.5), 24)
tooltip:SetHyperlink(button.tsLink)
tooltip:SetSpellByID(button.SpellID)
tooltip:Show()
end

Expand All @@ -80,24 +79,47 @@ function Prof.OnMouseAction(button, mouseButton)
if not mouseButton then return end
mouseButton = ProfClickHandler:Get(mouseButton)
if mouseButton == "ChatLink" then
AtlasLoot.Button:AddChatLink(button.tsLink or "spell:"..button.SpellID)
--AtlasLoot.Button:AddChatLink(button.tsLink or "spell:"..button.SpellID)
elseif mouseButton == "ShowExtraItems" then
if Profession.IsProfessionSpell(button.SpellID) then
button.ExtraFrameShown = true
AtlasLoot.Button:ExtraItemFrame_GetFrame(button, Profession.GetDataForExtraFrame(button.SpellID))
end
end
end


-- TODO: Add Query?
function Prof.Refresh(button)
local spellName, _, spellTexture = GetSpellInfo(button.SpellID)
button.tsLink, button.tsName = GetTradeskillLink(button.SpellID)

if button.type == "secButton" then

else
button.name:SetText(PROF_COLOR..spellName)
button.extra:SetText(button.tsName)
if Profession.IsProfessionSpell(button.SpellID) then
local itemName, _, itemQuality, _, _, _, _, _, _, itemTexture
if Profession.GetCreatedItemID(button.SpellID) then
itemName, _, itemQuality, _, _, _, _, _, _, itemTexture = GetItemInfo(Profession.GetCreatedItemID(button.SpellID))
end
itemQuality = itemQuality or 0

button.overlay:Show()
button.overlay:SetTexture(WHITE_ICON_FRAME)
button.overlay:SetAtlas(LOOT_BORDER_BY_QUALITY[itemQuality] or LOOT_BORDER_BY_QUALITY[LE_ITEM_QUALITY_UNCOMMON])
if not LOOT_BORDER_BY_QUALITY[itemQuality] then
button.overlay:SetDesaturated(true)
end

if button.type == "secButton" then

else
if itemName then
button.name:SetText("|c"..ITEM_COLORS[itemQuality or 0]..itemName)
else
button.name:SetText(PROF_COLOR..spellName)
end
button.extra:SetText(Profession.GetSpellDescription(button.SpellID).." ( "..Profession.GetColorSkillRank(button.SpellID).." )")
end

button.icon:SetTexture(itemTexture or Profession.GetIcon(button.SpellID) or spellTexture)
end

button.icon:SetTexture(TRADESKILLS[button.tsName] or spellTexture)

end

--[[
Expand Down
Loading

0 comments on commit c4c5aeb

Please sign in to comment.