mirror of
https://github.com/parnic/LibDogTag-Unit-3.0.git
synced 2025-06-16 21:41:53 -05:00
- add categories Abbrev and Talent.
- Talent uses LibTalentQuery-1.0
This commit is contained in:
103
Categories/Abbrev.lua
Normal file
103
Categories/Abbrev.lua
Normal file
@ -0,0 +1,103 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = tonumber(("$Revision$"):match("%d+")) or 0
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
end
|
||||
|
||||
DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
|
||||
|
||||
local L = DogTag_Unit.L
|
||||
|
||||
local ShortClass_abbrev = {
|
||||
[L["Priest"]] = L["Priest_short"],
|
||||
[L["Mage"]] = L["Mage_short"],
|
||||
[L["Shaman"]] = L["Shaman_short"],
|
||||
[L["Paladin"]] = L["Paladin_short"],
|
||||
[L["Warlock"]] = L["Warlock_short"],
|
||||
[L["Druid"]] = L["Druid_short"],
|
||||
[L["Rogue"]] = L["Rogue_short"],
|
||||
[L["Hunter"]] = L["Warrior_short"],
|
||||
}
|
||||
|
||||
DogTag:AddTag("Unit", "ShortClass", {
|
||||
code = function(value)
|
||||
return ShortClass_abbrev[value]
|
||||
end,
|
||||
arg = {
|
||||
'value', 'string', '@req',
|
||||
},
|
||||
ret = "string;nil",
|
||||
doc = L["Turn value into its shortened class equivalent"],
|
||||
example = ('[%q:ShortClass] => %q; ["Hello":ShortClass] => ""'):format(L["Priest"], L["Priest_short"]),
|
||||
category = L["Abbreviations"],
|
||||
})
|
||||
|
||||
local ShortRace_abbrev = {
|
||||
[L["Blood Elf"]] = L["Blood Elf_short"],
|
||||
[L["Draenei"]] = L["Draenei_short"],
|
||||
[L["Dwarf"]] = L["Dwarf_short"],
|
||||
[L["Gnome"]] = L["Gnome_short"],
|
||||
[L["Human"]] = L["Human_short"],
|
||||
[L["Night Elf"]] = L["Night Elf_short"],
|
||||
[L["Orc"]] = L["Orc_short"],
|
||||
[L["Tauren"]] = L["Tauren_short"],
|
||||
[L["Troll"]] = L["Troll_short"],
|
||||
[L["Undead"]] = L["Undead_short"],
|
||||
}
|
||||
|
||||
DogTag:AddTag("Unit", "ShortRace", {
|
||||
code = function(value)
|
||||
return ShortClass_abbrev[value]
|
||||
end,
|
||||
arg = {
|
||||
'value', 'string', '@req',
|
||||
},
|
||||
ret = "string;nil",
|
||||
doc = L["Turn value into its shortened racial equivalent"],
|
||||
example = ('[%q:ShortRace] => %q; ["Hello":ShortRace] => ""'):format(L["Blood Elf"], L["Blood Elf_short"]),
|
||||
category = L["Abbreviations"]
|
||||
})
|
||||
|
||||
local ShortDruidForm_abbrev = {
|
||||
[L["Bear"]] = L["Bear_short"],
|
||||
[L["Cat"]] = L["Cat_short"],
|
||||
[L["Moonkin"]] = L["Moonkin_short"],
|
||||
[L["Aquatic"]] = L["Aquatic_short"],
|
||||
[L["Flight"]] = L["Flight_short"],
|
||||
[L["Travel"]] = L["Travel_short"],
|
||||
[L["Tree"]] = L["Tree_short"],
|
||||
}
|
||||
|
||||
DogTag:AddTag("Unit", "ShortDruidForm", {
|
||||
code = function(value)
|
||||
return ShortDruidForm_abbrev[value]
|
||||
end,
|
||||
arg = {
|
||||
'value', 'string', '@req',
|
||||
},
|
||||
ret = "string;nil",
|
||||
doc = L["Turn value into its shortened druid form equivalent"],
|
||||
example = ('[%q:ShortDruidForm] => %q; ["Hello":ShortDruidForm] => ""'):format(L["Bear"], L["Bear_short"]),
|
||||
category = L["Abbreviations"]
|
||||
})
|
||||
|
||||
local ShortSex_abbrev = {
|
||||
[L["Male"]] = L["Male_short"],
|
||||
[L["Female"]] = L["Female_short"]
|
||||
}
|
||||
|
||||
DogTag:AddTag("Unit", "ShortSex", {
|
||||
code = function(value)
|
||||
return ShortSex_abbrev[value]
|
||||
end,
|
||||
arg = {
|
||||
'value', 'string', '@req',
|
||||
},
|
||||
ret = "string;nil",
|
||||
doc = L["Turn value into its shortened sex equivalent"],
|
||||
example = ('[%q:ShortSex] => %q; ["Hello":ShortSex] => ""'):format(L["Male"], L["Male_short"]),
|
||||
category = L["Abbreviations"]
|
||||
})
|
||||
|
||||
end
|
108
Categories/Talent.lua
Normal file
108
Categories/Talent.lua
Normal file
@ -0,0 +1,108 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = tonumber(("$Revision$"):match("%d+")) or 0
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
end
|
||||
|
||||
DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
|
||||
|
||||
local L = DogTag_Unit.L
|
||||
|
||||
local newList, del = DogTag.newList, DogTag.del
|
||||
|
||||
local function TalentSpec_func(unit) return nil end
|
||||
local function TalentTree_func(unit) return nil end
|
||||
|
||||
DogTag:AddAddonFinder("Unit", "LibStub", "LibTalentQuery-1.0", function(LibTalentQuery)
|
||||
local talentSpecs, talentSpecNames
|
||||
local function mySort(alpha, bravo)
|
||||
return alpha[2] > bravo[2]
|
||||
end
|
||||
LibTalentQuery.RegisterCallback(DogTag_Unit, function(event, name, realm)
|
||||
local fullName = realm and name .. "-" .. realm or name
|
||||
|
||||
local data = newList()
|
||||
for i = 1, 3 do
|
||||
local name, _, points = GetTalentTabInfo(i, true)
|
||||
data[i] = newList(name, points)
|
||||
end
|
||||
talentSpecs[fullName] = data[1][2] .. "/" .. data[2][2] .. "/" .. data[3][2]
|
||||
table.sort(data, mySort)
|
||||
|
||||
if data[1][2] == 0 then
|
||||
talentSpecNames[fullName] = _G.NONE
|
||||
elseif data[1][2]*3/4 <= data[2][2] then
|
||||
if data[1][2]*3/4 <= data[2][3] then
|
||||
talentSpecNames[fullName] = L["Hybrid"]
|
||||
else
|
||||
talentSpecNames[fullName] = data[1][1] .. "/" .. data[2][1]
|
||||
end
|
||||
else
|
||||
talentSpecNames[fullName] = data[1][1]
|
||||
end
|
||||
for i = 1, 3 do
|
||||
data[i] = del(data[i])
|
||||
end
|
||||
data = del(data)
|
||||
|
||||
DogTag:FireEvent("Talent")
|
||||
end)
|
||||
local lastUnit
|
||||
local function func(self, name)
|
||||
LibTalentQuery:Query(lastUnit)
|
||||
|
||||
return nil
|
||||
end
|
||||
local x = {__index=func}
|
||||
talentSpecs = setmetatable({}, x)
|
||||
talentSpecNames = setmetatable({}, x)
|
||||
x = nil
|
||||
local GetNameServer = DogTag_Unit.GetNameServer
|
||||
function TalentSpec_func(unit)
|
||||
if not UnitIsPlayer(unit) then
|
||||
return nil
|
||||
end
|
||||
lastUnit = unit
|
||||
return talentSpecs[GetNameServer(unit)]
|
||||
end
|
||||
function TalentTree_func(unit)
|
||||
if not UnitIsPlayer(unit) then
|
||||
return nil
|
||||
end
|
||||
lastUnit = unit
|
||||
return talentSpecNames[GetNameServer(unit)]
|
||||
end
|
||||
end)
|
||||
|
||||
DogTag:AddTag("Unit", "TalentSpec", {
|
||||
code = function(args)
|
||||
return TalentSpec_func
|
||||
end,
|
||||
dynamicCode = true,
|
||||
arg = {
|
||||
'unit', 'string', '@req',
|
||||
},
|
||||
ret = "string;nil",
|
||||
events = "Talent",
|
||||
doc = L["Return the talent spec of unit if available"],
|
||||
example = '[TalentSpec] => "30/31/0"',
|
||||
category = L["Characteristics"]
|
||||
})
|
||||
|
||||
DogTag:AddTag("Unit", "TalentTree", {
|
||||
code = function(args)
|
||||
return TalentTree_func
|
||||
end,
|
||||
dynamicCode = true,
|
||||
arg = {
|
||||
'unit', 'string', '@req',
|
||||
},
|
||||
ret = "string;nil",
|
||||
events = "Talent",
|
||||
doc = L["Return the talent tree of unit if available"],
|
||||
example = ('[TalentTree] => %q'):format("Holy/Prot"),
|
||||
category = L["Characteristics"]
|
||||
})
|
||||
|
||||
end
|
@ -122,36 +122,6 @@ DogTag_Unit.L = {
|
||||
["Female_short"] = "f",
|
||||
|
||||
["Leader"] = "Leader",
|
||||
|
||||
-- spell trees
|
||||
["Hybrid"] = "Hybrid", -- for all 3 trees
|
||||
["Druid_Tree_1"] = "Balance",
|
||||
["Druid_Tree_2"] = "Feral Combat",
|
||||
["Druid_Tree_3"] = "Restoration",
|
||||
["Hunter_Tree_1"] = "Beast Mastery",
|
||||
["Hunter_Tree_2"] = "Marksmanship",
|
||||
["Hunter_Tree_3"] = "Survival",
|
||||
["Mage_Tree_1"] = "Arcane",
|
||||
["Mage_Tree_2"] = "Fire",
|
||||
["Mage_Tree_3"] = "Frost",
|
||||
["Paladin_Tree_1"] = "Holy",
|
||||
["Paladin_Tree_2"] = "Protection",
|
||||
["Paladin_Tree_3"] = "Retribution",
|
||||
["Priest_Tree_1"] = "Discipline",
|
||||
["Priest_Tree_2"] = "Holy",
|
||||
["Priest_Tree_3"] = "Shadow",
|
||||
["Rogue_Tree_1"] = "Assassination",
|
||||
["Rogue_Tree_2"] = "Combat",
|
||||
["Rogue_Tree_3"] = "Subtlety",
|
||||
["Shaman_Tree_1"] = "Elemental",
|
||||
["Shaman_Tree_2"] = "Enhancement",
|
||||
["Shaman_Tree_3"] = "Restoration",
|
||||
["Warrior_Tree_1"] = "Arms",
|
||||
["Warrior_Tree_2"] = "Fury",
|
||||
["Warrior_Tree_3"] = "Protection",
|
||||
["Warlock_Tree_1"] = "Affliction",
|
||||
["Warlock_Tree_2"] = "Demonology",
|
||||
["Warlock_Tree_3"] = "Destruction",
|
||||
|
||||
-- dispel types
|
||||
["Magic"] = "Magic",
|
||||
|
@ -124,36 +124,6 @@ DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
|
||||
L["Female_short"] = "여"
|
||||
|
||||
L["Leader"] = "지휘관"
|
||||
|
||||
-- spell trees
|
||||
L["Hybrid"] = "혼성" -- for all 3 trees
|
||||
L["Druid_Tree_1"] = "조화"
|
||||
L["Druid_Tree_2"] = "야성"
|
||||
L["Druid_Tree_3"] = "회복"
|
||||
L["Hunter_Tree_1"] = "야수"
|
||||
L["Hunter_Tree_2"] = "사격"
|
||||
L["Hunter_Tree_3"] = "생존"
|
||||
L["Mage_Tree_1"] = "비전"
|
||||
L["Mage_Tree_2"] = "화염"
|
||||
L["Mage_Tree_3"] = "냉기"
|
||||
L["Paladin_Tree_1"] = "신성"
|
||||
L["Paladin_Tree_2"] = "보호"
|
||||
L["Paladin_Tree_3"] = "징벌"
|
||||
L["Priest_Tree_1"] = "수양"
|
||||
L["Priest_Tree_2"] = "신성"
|
||||
L["Priest_Tree_3"] = "암흑"
|
||||
L["Rogue_Tree_1"] = "암살"
|
||||
L["Rogue_Tree_2"] = "전투"
|
||||
L["Rogue_Tree_3"] = "잠행"
|
||||
L["Shaman_Tree_1"] = "정기"
|
||||
L["Shaman_Tree_2"] = "고양"
|
||||
L["Shaman_Tree_3"] = "복원"
|
||||
L["Warrior_Tree_1"] = "무기"
|
||||
L["Warrior_Tree_2"] = "분노"
|
||||
L["Warrior_Tree_3"] = "방어"
|
||||
L["Warlock_Tree_1"] = "고통"
|
||||
L["Warlock_Tree_2"] = "악마"
|
||||
L["Warlock_Tree_3"] = "파괴"
|
||||
end
|
||||
|
||||
end
|
@ -123,36 +123,6 @@ DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function()
|
||||
L["Female_short"] = "女"
|
||||
|
||||
L["Leader"] = "队长"
|
||||
|
||||
-- spell trees
|
||||
L["Hybrid"] = "混合" -- for all 3 trees
|
||||
L["Druid_Tree_1"] = "平衡"
|
||||
L["Druid_Tree_2"] = "野性战斗"
|
||||
L["Druid_Tree_3"] = "恢复"
|
||||
L["Hunter_Tree_1"] = "野兽掌握"
|
||||
L["Hunter_Tree_2"] = "射击"
|
||||
L["Hunter_Tree_3"] = "生存"
|
||||
L["Mage_Tree_1"] = "奥术"
|
||||
L["Mage_Tree_2"] = "火焰"
|
||||
L["Mage_Tree_3"] = "冰霜"
|
||||
L["Paladin_Tree_1"] = "神圣"
|
||||
L["Paladin_Tree_2"] = "防护"
|
||||
L["Paladin_Tree_3"] = "惩戒"
|
||||
L["Priest_Tree_1"] = "戒律"
|
||||
L["Priest_Tree_2"] = "神圣"
|
||||
L["Priest_Tree_3"] = "暗影"
|
||||
L["Rogue_Tree_1"] = "刺杀"
|
||||
L["Rogue_Tree_2"] = "战斗"
|
||||
L["Rogue_Tree_3"] = "敏锐"
|
||||
L["Shaman_Tree_1"] = "元素战斗"
|
||||
L["Shaman_Tree_2"] = "增强"
|
||||
L["Shaman_Tree_3"] = "恢复"
|
||||
L["Warrior_Tree_1"] = "武器"
|
||||
L["Warrior_Tree_2"] = "狂怒"
|
||||
L["Warrior_Tree_3"] = "防御"
|
||||
L["Warlock_Tree_1"] = "痛苦"
|
||||
L["Warlock_Tree_2"] = "恶魔学识"
|
||||
L["Warlock_Tree_3"] = "毁灭"
|
||||
end
|
||||
|
||||
end
|
4
test.lua
4
test.lua
@ -1,9 +1,7 @@
|
||||
--[[
|
||||
TODO:
|
||||
|
||||
Abbreviations
|
||||
AddonVersion? - probably not gonna do this
|
||||
Talent
|
||||
]]
|
||||
|
||||
local old_dofile = dofile
|
||||
@ -363,6 +361,7 @@ DogTag:AddTag("Unit", "MyValue", {
|
||||
|
||||
dofile("Localization/enUS.lua")
|
||||
dofile("LibDogTag-Unit-3.0.lua")
|
||||
dofile("Categories/Abbrev.lua")
|
||||
dofile("Categories/Auras.lua")
|
||||
dofile("Categories/Cast.lua")
|
||||
dofile("Categories/Characteristics.lua")
|
||||
@ -375,6 +374,7 @@ dofile("Categories/Power.lua")
|
||||
dofile("Categories/Range.lua")
|
||||
dofile("Categories/Reputation.lua")
|
||||
dofile("Categories/Status.lua")
|
||||
dofile("Categories/Talent.lua")
|
||||
dofile("Categories/Threat.lua")
|
||||
dofile("Categories/TooltipScanning.lua")
|
||||
dofile("Cleanup.lua")
|
||||
|
Reference in New Issue
Block a user