Skip to content

Commit a3df691

Browse files
committed
Show Talent profile on UI
1 parent c8f84cc commit a3df691

2 files changed

Lines changed: 203 additions & 20 deletions

File tree

Core.lua

Lines changed: 203 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ local charDefaults = {
3636
enableLegendaryItemDPS = true,
3737
enableBaseTalentDPS = true,
3838
enableBestTalentDPS = true,
39+
enableTalentDPSOnUI = true,
3940
enableSoulbindID = true,
4041
enableSoulbindBaseDPS = true,
4142
enableSoulbindBestDPS = true,
@@ -65,7 +66,9 @@ local UIElements={
6566
importButton,
6667
typeDropdown,
6768
enablecheckbox,
69+
useOnUIChechbox,
6870
colorpicker,
71+
talentStrings={}
6972
}
7073
local UIParameters={
7174
--Consts
@@ -77,7 +80,10 @@ local UIParameters={
7780
OFFSET_GEM_ID_4 = 6,
7881
OFFSET_SUFFIX_ID = 7,
7982
OFFSET_FLAGS = 11,
80-
OFFSET_BONUS_ID = 13,
83+
OFFSET_BONUS_ID = 13,
84+
85+
MAX_TALENT_ROW = 7,
86+
MAX_TALENT_PER_ROW = 3,
8187

8288
detailsLoaded=false,
8389
detailsDrawn=false,
@@ -93,7 +99,8 @@ local UIParameters={
9399
[3] = "conduit",
94100
[4] = "soulbind",
95101
[5] = "legendary"
96-
}
102+
},
103+
talentOnUILoaded=false,
97104
}
98105

99106
local f = CreateFrame("Frame")
@@ -519,12 +526,27 @@ function MoreTooltipInfo.GetDefaultColor(classID)
519526
return MoreTooltipInfo.SpecNames[classID]["color"]
520527
end
521528

522-
function MoreTooltipInfo.NewProfile(type, classID, specID, profileName, data, enable, color, string)
529+
function MoreTooltipInfo.CheckIfUseOnUIExists(InfoType, classID, specID)
530+
local exists = false
531+
local profileName = ""
532+
if profiles[InfoType][classID] == nil then return end
533+
if profiles[InfoType][classID][specID] == nil then return end
534+
for i, v in pairs(profiles[InfoType][classID][specID]) do
535+
if v["useOnUI"] then
536+
exists = true
537+
profileName = i
538+
end
539+
end
540+
return exists,profileName
541+
end
542+
543+
function MoreTooltipInfo.NewProfile(type, classID, specID, profileName, data, enable, color, string, useOnUI)
523544
profiles[type][classID][specID][profileName] = {}
524545
profiles[type][classID][specID][profileName]["enable"] = enable
525546
profiles[type][classID][specID][profileName]["color"] = color
526547
profiles[type][classID][specID][profileName]["data"] = data
527548
profiles[type][classID][specID][profileName]["string"] = string
549+
profiles[type][classID][specID][profileName]["useOnUI"] = useOnUI
528550
end
529551

530552
function MoreTooltipInfo.ValidateItemPersonnalData(info,value)
@@ -551,6 +573,11 @@ function MoreTooltipInfo.ValidateItemPersonnalData(info,value)
551573
local data = {}
552574
local infoType = dpsData[1]
553575
local color = MoreTooltipInfo.GetDefaultColor(classID) .. "ff" --add alpha at the end
576+
local useOnUI = false
577+
if not MoreTooltipInfo.CheckIfUseOnUIExists(infoType, classID, specID) then
578+
useOnUI = true --if no other profile is shown, use this one
579+
end
580+
554581
if infoType == "trinket" then
555582
-- MoreTooltipInfo:8:63:"X.com-patchwerk":trinket^[174103]125=1234;130=1250;150=9999^[174500]125=123;130=456;135=789
556583
if profiles[infoType][classID] == nil then profiles[infoType][classID] = {} end
@@ -649,13 +676,14 @@ function MoreTooltipInfo.ValidateItemPersonnalData(info,value)
649676
tempdata["enable"] = true
650677
tempdata["color"] = color
651678
tempdata["string"] = value
679+
tempdata["useOnUI"] = useOnUI
652680

653681
StaticPopup_Show("MTI_CONFIRM_EXISTS_POPUP","","",tempdata)
654682

655683
return false
656684
end
657685

658-
MoreTooltipInfo.NewProfile(infoType, classID, specID, profileName, data, true, color, value)
686+
MoreTooltipInfo.NewProfile(infoType, classID, specID, profileName, data, true, color, value, useOnUI)
659687

660688
return true
661689
end
@@ -785,7 +813,7 @@ StaticPopupDialogs["MTI_CONFIRM_EXISTS_POPUP"] = {
785813
button2 = "No",
786814
OnAccept = function(self, data, data2)
787815
DeleteProfile(data["classID"],data["specID"],data["profileName"])
788-
MoreTooltipInfo.NewProfile(data["type"], data["classID"], data["specID"], data["profileName"], data["data"], data["enable"], data["color"], data["string"])
816+
MoreTooltipInfo.NewProfile(data["type"], data["classID"], data["specID"], data["profileName"], data["data"], data["enable"], data["color"], data["string"], data["useOnUI"])
789817
OpenProfileUI()
790818
end,
791819
timeout = 0,
@@ -795,6 +823,22 @@ StaticPopupDialogs["MTI_CONFIRM_EXISTS_POPUP"] = {
795823
preferredIndex = 3, -- avoid some UI taint, see http://www.wowace.com/announcements/how-to-avoid-some-ui-taint/
796824
}
797825

826+
StaticPopupDialogs["MTI_CONFIRM_USEONUI_POPUP"] = {
827+
text = "A profile is already shown on UI. Do you want to overwrite it?",
828+
829+
button1 = "Yes",
830+
button2 = "No",
831+
OnAccept = function(self, data, data2)
832+
UIParameters.talentOnUILoaded = false
833+
DisableOnUI(UIParameters.currentClassID, UIParameters.currentSpecID, data["profileName"])
834+
EnableOnUI(UIParameters.currentClassID, UIParameters.currentSpecID, UIParameters.currentProfile)
835+
end,
836+
timeout = 0,
837+
whileDead = true,
838+
hideOnEscape = true,
839+
preferredIndex = 3, -- avoid some UI taint, see http://www.wowace.com/announcements/how-to-avoid-some-ui-taint/
840+
}
841+
798842
StaticPopupDialogs["MTI_EXISTS_POPUP"] = {
799843
text = "The profile %s already exists. ",
800844
button1 = "Cancel",
@@ -869,14 +913,8 @@ function DrawOptionGroup(classID, specID, profileName)
869913
UIParameters.currentClassID = classID
870914
UIParameters.currentSpecID = specID
871915
UIElements.titleLabel:SetText(profileName)
872-
UIElements.enablecheckbox:SetCallback("OnValueChanged", function(widget)
873-
if profiles[UIParameters.currentType][classID][specID][profileName]["enable"] then
874-
DisableProfile(classID, specID, profileName)
875-
else
876-
EnableProfile(classID, specID, profileName)
877-
end
878-
end)
879916
UIElements.enablecheckbox:SetValue(profiles[UIParameters.currentType][classID][specID][profileName]["enable"])
917+
UIElements.useOnUIChechbox:SetValue(profiles[UIParameters.currentType][classID][specID][profileName]["useOnUI"])
880918
local r,g,b = hex2rgb(profiles[UIParameters.currentType][classID][specID][profileName]["color"])
881919
UIElements.colorpicker:SetColor(r/255,g/255,b/255,1)
882920
else
@@ -922,16 +960,26 @@ function EnableProfile(classID, specID, profileName)
922960
profiles[UIParameters.currentType][classID][specID][profileName]["enable"] = true
923961
end
924962

925-
function SetProfileColor(classID, specID, profileName, color)
926-
--print("color "..classID.." "..specID.." "..profileName.." "..color)
927-
profiles[UIParameters.currentType][classID][specID][profileName]["color"] = color
928-
end
929-
930963
function DisableProfile(classID, specID, profileName)
931964
--print("disable "..classID.." "..specID.." "..profileName)
932965
profiles[UIParameters.currentType][classID][specID][profileName]["enable"] = false
933966
end
934967

968+
function EnableOnUI(classID, specID, profileName)
969+
--print("enable "..classID.." "..specID.." "..profileName)
970+
profiles[UIParameters.currentType][classID][specID][profileName]["useOnUI"] = true
971+
end
972+
973+
function DisableOnUI(classID, specID, profileName)
974+
--print("disable "..classID.." "..specID.." "..profileName)
975+
profiles[UIParameters.currentType][classID][specID][profileName]["useOnUI"] = false
976+
end
977+
978+
function SetProfileColor(classID, specID, profileName, color)
979+
--print("color "..classID.." "..specID.." "..profileName.." "..color)
980+
profiles[UIParameters.currentType][classID][specID][profileName]["color"] = color
981+
end
982+
935983
function AddSpacer(targetFrame,full,width,height)
936984
UIElements.spacerTable[#UIElements.spacerTable+1] = AGUI:Create("Label")
937985
if full then
@@ -1061,8 +1109,36 @@ function OpenProfileUI()
10611109
UIElements.enablecheckbox = AGUI:Create("CheckBox")
10621110
UIElements.enablecheckbox:SetLabel("Enable")
10631111
UIElements.enablecheckbox:SetRelativeWidth(1)
1112+
UIElements.enablecheckbox:SetCallback("OnValueChanged", function(widget)
1113+
if profiles[UIParameters.currentType][UIParameters.currentClassID][UIParameters.currentSpecID][UIParameters.currentProfile]["enable"] then
1114+
DisableProfile(UIParameters.currentClassID, UIParameters.currentSpecID, UIParameters.currentProfile)
1115+
else
1116+
EnableProfile(UIParameters.currentClassID, UIParameters.currentSpecID, UIParameters.currentProfile)
1117+
end
1118+
end)
10641119
UIElements.detailsGroup:AddChild(UIElements.enablecheckbox)
10651120

1121+
if UIParameters.availableOption[UIParameters.currentTypeIndex] == "talent" then
1122+
UIElements.useOnUIChechbox = AGUI:Create("CheckBox")
1123+
UIElements.useOnUIChechbox:SetLabel("Show in the talent UI")
1124+
UIElements.useOnUIChechbox:SetRelativeWidth(1)
1125+
UIElements.useOnUIChechbox:SetCallback("OnValueChanged", function(widget)
1126+
if profiles[UIParameters.currentType][UIParameters.currentClassID][UIParameters.currentSpecID][UIParameters.currentProfile]["useOnUI"] then
1127+
DisableOnUI(UIParameters.currentClassID, UIParameters.currentSpecID, UIParameters.currentProfile)
1128+
else
1129+
local onUIExists,profileName = MoreTooltipInfo.CheckIfUseOnUIExists(UIParameters.availableOption[UIParameters.currentTypeIndex], UIParameters.currentClassID, UIParameters.currentSpecID)
1130+
if onUIExists then
1131+
local tempdata = {}
1132+
tempdata["profileName"] = profileName
1133+
StaticPopup_Show ("MTI_CONFIRM_USEONUI_POPUP","","",tempdata)
1134+
else
1135+
EnableOnUI(UIParameters.currentClassID, UIParameters.currentSpecID, UIParameters.currentProfile)
1136+
end
1137+
end
1138+
end)
1139+
UIElements.detailsGroup:AddChild(UIElements.useOnUIChechbox)
1140+
end
1141+
10661142
UIElements.colorpicker = AGUI:Create("ColorPicker")
10671143
UIElements.colorpicker:SetLabel("Color")
10681144
UIElements.colorpicker:SetRelativeWidth(1)
@@ -1287,7 +1363,7 @@ function f:CreateOptions()
12871363
inline = true,
12881364
order = 2,
12891365
args = {
1290-
enableBaseTalentDPS = {
1366+
--[[ enableBaseTalentDPS = {
12911367
order = 0,
12921368
type = "toggle",
12931369
name = NORMAL_FONT_COLOR_CODE .. "Enable Base talent Simulated DPS" .. FONT_COLOR_CODE_CLOSE,
@@ -1298,6 +1374,12 @@ function f:CreateOptions()
12981374
type = "toggle",
12991375
name = NORMAL_FONT_COLOR_CODE .. "Enable Best talent Simulated DPS (with the best talents combination)" .. FONT_COLOR_CODE_CLOSE,
13001376
width = "full",
1377+
}, ]]
1378+
enableTalentDPSOnUI = {
1379+
order = 2,
1380+
type = "toggle",
1381+
name = NORMAL_FONT_COLOR_CODE .. "Show talent Simulated DPS on talent UI" .. FONT_COLOR_CODE_CLOSE,
1382+
width = "full",
13011383
},
13021384
},
13031385
},
@@ -1361,6 +1443,102 @@ ShoppingTooltip1:HookScript("OnTooltipSetItem", function (...) MoreTooltipInfo.M
13611443
ShoppingTooltip2:HookScript("OnTooltipSetItem", function (...) MoreTooltipInfo.ManageTooltips("item", nil, ...) end)
13621444
GameTooltip:HookScript("OnTooltipSetUnit", function(...) MoreTooltipInfo.ManageTooltips("unit", nil, ...) end)
13631445

1446+
function createFontString(parent,text,textType)
1447+
local fontString
1448+
fontString = f:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
1449+
local fontName, _, _ = fontString:GetFont()
1450+
fontString:SetFont(fontName, 9, "")
1451+
1452+
--position switch
1453+
if textType == "talentBase" then
1454+
fontString:SetPoint("TOPRIGHT", parent, "TOPRIGHT", -5, 0)
1455+
elseif textType == "talentBest" then
1456+
fontString:SetPoint("BOTTOMRIGHT", parent, "BOTTOMRIGHT", -5, 0)
1457+
end
1458+
1459+
fontString:SetText(text)
1460+
f:SetFrameStrata("HIGH")
1461+
fontString:Show()
1462+
return fontString
1463+
end
1464+
1465+
function testHook2(tier)
1466+
local lists = _G.SoulbindViewer.ConduitList.ScrollBox.ScrollTarget.Lists
1467+
for index, list in ipairs(lists) do
1468+
local collection = C_Soulbinds.GetConduitCollection(list.conduitType);
1469+
local matchesSpecSet = {};
1470+
for index, collectionData in ipairs(collection) do
1471+
print(collectionData.conduitID)
1472+
end
1473+
end
1474+
end
1475+
1476+
function DrawTalentDPSOnUI()
1477+
if (not _G.PlayerTalentFrameSpecialization:IsShown()) then
1478+
--print("enter")
1479+
1480+
if UIParameters.talentOnUILoaded then
1481+
--print("show")
1482+
for i=1, UIParameters.MAX_TALENT_ROW do
1483+
for j=1, UIParameters.MAX_TALENT_PER_ROW do
1484+
curentTalent = ""..i..j
1485+
if UIElements.talentStrings[curentTalent] then
1486+
if UIElements.talentStrings[curentTalent]["Base"] then UIElements.talentStrings[curentTalent]["Base"]:Show() end
1487+
if UIElements.talentStrings[curentTalent]["Best"] then UIElements.talentStrings[curentTalent]["Best"]:Show() end
1488+
end
1489+
end
1490+
end
1491+
else
1492+
--print("load")
1493+
local classID = MoreTooltipInfo.GetClassID()
1494+
local specID = MoreTooltipInfo.GetSpecID()
1495+
local data = {}
1496+
1497+
if profiles["talent"][classID] == nil then return end
1498+
if profiles["talent"][classID][specID] == nil then return end
1499+
for i, v in pairs(profiles["talent"][classID][specID]) do
1500+
if v["enable"] and v["useOnUI"] then
1501+
--print("profile")
1502+
data = v["data"]
1503+
end
1504+
end
1505+
1506+
local p,curentTalent,currentFrame,spellID
1507+
for i=1, UIParameters.MAX_TALENT_ROW do
1508+
for j=1, UIParameters.MAX_TALENT_PER_ROW do
1509+
curentTalent = ""..i..j
1510+
currentFrame = "PlayerTalentFrameTalentsTalentRow"..i.."Talent"..j
1511+
1512+
_, _, _, _, _, spellID = GetTalentInfoByID(_G[currentFrame]:GetID())
1513+
1514+
p = _G[currentFrame]
1515+
UIElements.talentStrings[curentTalent] = {}
1516+
if data and data[spellID] and data[spellID]["Base"] then
1517+
dps = MoreTooltipInfo.FormatSpace(data[spellID]["Base"])
1518+
UIElements.talentStrings[curentTalent]["Base"] = createFontString(p,dps,"talentBase")
1519+
end
1520+
if data and data[spellID] and data[spellID]["Best"] then
1521+
dps = MoreTooltipInfo.FormatSpace(data[spellID]["Best"])
1522+
UIElements.talentStrings[curentTalent]["Best"] = createFontString(p,dps,"talentBest")
1523+
end
1524+
end
1525+
end
1526+
1527+
UIParameters.talentOnUILoaded = true
1528+
end
1529+
end
1530+
end
1531+
function HideTalentOverlay()
1532+
--print("leave")
1533+
for i=1, UIParameters.MAX_TALENT_ROW do
1534+
for j=1, UIParameters.MAX_TALENT_PER_ROW do
1535+
curentTalent = ""..i..j
1536+
if UIElements.talentStrings[curentTalent] and UIElements.talentStrings[curentTalent]["Base"] then UIElements.talentStrings[curentTalent]["Base"]:Hide() end
1537+
if UIElements.talentStrings[curentTalent] and UIElements.talentStrings[curentTalent]["Best"] then UIElements.talentStrings[curentTalent]["Best"]:Hide() end
1538+
end
1539+
end
1540+
end
1541+
13641542
---------------------
13651543
--Events management -
13661544
---------------------
@@ -1376,6 +1554,13 @@ function f:ADDON_LOADED(event, addon)
13761554
cfg = db.char[playerRealm][playerName]
13771555
profiles = db.profiles
13781556
self:CreateOptions()
1557+
elseif addon == "Blizzard_TalentUI" then
1558+
--print("Talent loaded")
1559+
_G.PlayerTalentFrameTalents.PvpTalentButton:HookScript("OnShow", function() if cfg.enableConduitID then DrawTalentDPSOnUI() end end)
1560+
_G.PlayerTalentFrameTalents.PvpTalentButton:HookScript("OnHide", function() if cfg.enableConduitID then HideTalentOverlay() end end)
1561+
elseif addon == "Blizzard_Soulbinds" then
1562+
--print("Soulbind loaded")
1563+
_G.SoulbindViewer.ConduitList.ScrollBox:HookScript("OnShow", function() testHook2("1") end)
13791564
end
13801565
end
13811566

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ You can enable and disable what you want to show in the tooltip in Game Menu > I
114114

115115
- Show Soulbind and conduit dps directly into the UI
116116

117-
- Show Talent DPS directly into the UI
118-
119117
- Add more data to the addon (Do not hesitate to suggest)
120118

121119
- Add notifications when data changes

0 commit comments

Comments
 (0)