Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Commit

Permalink
v2.26.0
Browse files Browse the repository at this point in the history
* Update Interface version
* Store and display new talents
  • Loading branch information
onechiporenko committed Nov 27, 2022
1 parent 733ffe0 commit 7c6248f
Show file tree
Hide file tree
Showing 13 changed files with 324 additions and 87 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
@@ -1,4 +1,9 @@
### v2.25.0
### v2.26.0

* Update Interface version
* Store and display new talents

### v2.25.0

* Timewalking challenges should not be filtered out when "current week"-filter is used
* Fix template for CastOnMe WA (improve caster's target checking)
Expand Down
111 changes: 98 additions & 13 deletions Challenge.lua
Expand Up @@ -48,33 +48,117 @@ function MyDungeonsBook:InitNewDungeonChallenge(id)
self:DebugPrint(string.format("New challenge is init with id %s", id));
end

function MyDungeonsBook:GetUnitTalents(unitId)
local talents = {};
local exportStream = ExportUtil.MakeExportDataStream();
local specID = GetInspectSpecialization(unitId);
local configID = unitId == "player" and C_ClassTalents.GetActiveConfigID() or -1;

local configInfo = C_Traits.GetConfigInfo(configID);
local treeID = configInfo.treeIDs[1];
local treeInfo = C_Traits.GetTreeInfo(configID, treeID);
local treeHash = C_Traits.GetTreeHash(treeInfo.ID);
local serializationVersion = (C_Traits.GetLoadoutSerializationVersion ~= nil and C_Traits.GetLoadoutSerializationVersion()) or 1;

local function GetActiveEntryIndex(treeNode)
for i, entryID in ipairs(treeNode.entryIDs) do
if(entryID == treeNode.activeEntry.entryID) then
return i;
end
end
return 0;
end

local bitWidthHeaderVersion = 8;
local bitWidthSpecID = 16;
local bitWidthRanksPurchased = 6;

-- HEADER
exportStream:AddValue(bitWidthHeaderVersion, serializationVersion);
exportStream:AddValue(bitWidthSpecID, specID);
for i, hashVal in ipairs(treeHash) do
exportStream:AddValue(8, hashVal);
end

-- CONTENT
local treeNodes = C_Traits.GetTreeNodes(treeID);
for i, treeNodeID in ipairs(treeNodes) do
local treeNode = C_Traits.GetNodeInfo(configID, treeNodeID);
local isNodeSelected = treeNode.ranksPurchased > 0 or treeNode.activeRank > 0;
local isPartiallyRanked = treeNode.ranksPurchased ~= treeNode.maxRanks;
local isChoiceNode = treeNode.type == Enum.TraitNodeType.Selection;

exportStream:AddValue(1, isNodeSelected and 1 or 0);

if(isNodeSelected) then
exportStream:AddValue(1, isPartiallyRanked and 1 or 0);
if(isPartiallyRanked) then
exportStream:AddValue(bitWidthRanksPurchased, treeNode.ranksPurchased);
end

local entryId = treeNode.activeEntry.entryID;
local entry = C_Traits.GetEntryInfo(configID, entryId);
if (entry) then
local definitionInfo = C_Traits.GetDefinitionInfo(entry.definitionID);
if (definitionInfo) then
local spellId = definitionInfo.spellID;
if (spellId) then
tinsert(talents, {
spellId = spellId;
maxRanks = treeNode.maxRanks;
activeRank = treeNode.activeRank;
displayType = entry.type;
group = treeNode.posX > 10000 and "spec" or "class";
});
end
end
end

exportStream:AddValue(1, isChoiceNode and 1 or 0);
if(isChoiceNode) then
local entryIndex = GetActiveEntryIndex(treeNode);
if(entryIndex <= 0 or entryIndex > 4) then
error("Error exporting tree node " .. treeNode.ID .. ". The active choice node entry index (" .. entryIndex .. ") is out of bounds. ");
end

-- store entry index as zero-index
exportStream:AddValue(2, entryIndex - 1);
end
end
end

local exportString = exportStream:GetExportString();
return exportString, talents;
end

--[[--
Parse info about player or any other party member (`unit`).
@param[type=unitId] unit
@param[type=unitId] unitId
]]
function MyDungeonsBook:ParseUnitInfoWithWowApi(unit)
if (not UnitExists(unit)) then
function MyDungeonsBook:ParseUnitInfoWithWowApi(unitId)
if (not UnitExists(unitId)) then
return {};
end
local unitInfoFromLGI = LGIST:GetCachedInfo(UnitGUID(unit));
local _, _, class = UnitClass(unit);
local name, realm = UnitFullName(unit);
local _, race = UnitRace(unit);
local spec = GetInspectSpecialization(unit);
local unitInfoFromLGI = LGIST:GetCachedInfo(UnitGUID(unitId));
local _, _, class = UnitClass(unitId);
local name, realm = UnitFullName(unitId);
local _, race = UnitRace(unitId);
local spec = GetInspectSpecialization(unitId);
if (spec == 0) then
spec = nil;
end
local role = UnitGroupRolesAssigned(unit);
local role = UnitGroupRolesAssigned(unitId);
if (not realm) then
local _, myRealm = UnitFullName("player");
realm = myRealm;
end
local items = {};
for i = 1, 17 do
local itemLink = GetInventoryItemLink(unit, i);
local itemLink = GetInventoryItemLink(unitId, i);
items[i] = itemLink;
end
local talentsStr, talents = self:GetUnitTalents();
local unitInfo = {
name = name,
role = role,
Expand All @@ -84,11 +168,12 @@ function MyDungeonsBook:ParseUnitInfoWithWowApi(unit)
realm = realm,
items = items,
gender = unitInfoFromLGI.gender,
talents = self:CopyTable(unitInfoFromLGI.talents),
talents = talents,
talentsStr = talentsStr,
misc = {},
covenant = {}
};
if (unit == "player") then
if (unitId == "player") then
local covenantId = C_Covenants.GetActiveCovenantID();
local activeSoulbindId = C_Soulbinds.GetActiveSoulbindID();
local activeSoulbindData = C_Soulbinds.GetSoulbindData(activeSoulbindId);
Expand Down Expand Up @@ -123,7 +208,7 @@ function MyDungeonsBook:UpdateUnitInfo(guid)
return false;
end
local unitInfo = self:ParseUnitInfoWithWowApi(unit);
if (unitInfo.talents and #unitInfo.talents > 0 and #self.db.char.challenges[id].players[unit].talents > 0) then
if (unitInfo and unitInfo.talents and #unitInfo.talents > 0 and self.db.char.challenges[id].players[unit] and self.db.char.challenges[id].players[unit].talents and #self.db.char.challenges[id].players[unit].talents > 0) then
wipe(self.db.char.challenges[id].players[unit].talents);
end
self.db.char.challenges[id].players[unit] = self:MergeTables(self.db.char.challenges[id].players[unit], unitInfo);
Expand Down
1 change: 1 addition & 0 deletions Locales/enUS.lua
Expand Up @@ -310,4 +310,5 @@ L["DarkIronDwarf"] = "Dark Iron Dwarf";
L["MagharOrc"] = "Maghar Orc";
L["Mechagnome"] = "Mechagnome";
L["Vulpera"] = "Vulpera";
L["Dracthyr"] = "Dracthyr";
-- Race end
1 change: 1 addition & 0 deletions Locales/ruRU.lua
Expand Up @@ -311,4 +311,5 @@ L["DarkIronDwarf"] = "Дворф Черного Железа";
L["MagharOrc"] = "Маг'хар";
L["Mechagnome"] = "Механогном";
L["Vulpera"] = "Вульпера";
L["Dracthyr"] = "Драктир";
-- Race end
7 changes: 5 additions & 2 deletions MyDungeonsBook.toc
@@ -1,8 +1,8 @@
## Title: MyDungeonsBook
## Notes: Addon to collect and store specific information about your myth+ challenges.
## Version: 2.25.0
## Version: 2.26.0
## Author: GelioS
## Interface: 100000
## Interface: 100002
## OptionalDeps: LibStub, CallbackHandler-1.0, Ace3, LibCompress, LibGroupInSpecT-1.1
## SavedVariables: MyDungeonsBookDB
## SavedVariablesPerCharacter: MyDungeonsBookData
Expand Down Expand Up @@ -75,7 +75,10 @@ UI/ChallengeDetails/Tabs/Roster/Tabs/Covenant.lua
UI/ChallengeDetails/Tabs/Roster/Tabs/Equipment.lua
UI/ChallengeDetails/Tabs/Roster/Tabs/Misc.lua
UI/ChallengeDetails/Tabs/Roster/Tabs/Info.lua
UI/ChallengeDetails/Tabs/Roster/Tabs/OldTalents.lua
UI/ChallengeDetails/Tabs/Roster/Tabs/Talents.lua
UI/ChallengeDetails/Tabs/Roster/Tabs/Talents/Tabs.lua
UI/ChallengeDetails/Tabs/Roster/Tabs/Talents/Tabs/TalentsPartyMember.lua

UI/ChallengeDetails/Tabs/Summary.lua

Expand Down
Expand Up @@ -47,7 +47,7 @@ function MyDungeonsBook:OwnCastsByPartyMemberFrame_FilterBySpellId_Create(parent
local filterBySpellIdOptions = {
["ALL"] = L["All"]
};
local filterBySpellIdOptionsOrder = {"ALL"}
local filterBySpellIdOptionsOrder = {"ALL"};
for _, row in pairs(summaryData) do
local spellId = row.cols[1].value;
filterBySpellIdOptions[spellId] = GetSpellInfo(spellId);
Expand Down
4 changes: 2 additions & 2 deletions UI/ChallengeDetails/Tabs/Roster.lua
Expand Up @@ -13,9 +13,9 @@ Creates a frame for Roster tab
@param[type=Frame] parentFrame
@return[type=Frame] rosterFrame
]]
function MyDungeonsBook:RosterFrame_Create(parentFrame)
function MyDungeonsBook:RosterFrame_Create(parentFrame, challengeId)
local rosterFrame = self:TabContentWrapperWidget_Create(parentFrame);
rosterFrame.tabButtonsFrame = self:RosterFrame_CreateTabButtonsFrame(rosterFrame);
rosterFrame.tabButtonsFrame = self:RosterFrame_CreateTabButtonsFrame(rosterFrame, challengeId);
rosterFrame.tabButtonsFrame:SelectTab("shortInfo");
return rosterFrame;
end
31 changes: 24 additions & 7 deletions UI/ChallengeDetails/Tabs/Roster/Tabs.lua
Expand Up @@ -15,15 +15,29 @@ Creates tabs (with click-handlers) for Roster frame.
@param[type=Frame] parentFrame
@return[type=Frame] tabsButtonsFrame
]]
function MyDungeonsBook:RosterFrame_CreateTabButtonsFrame(parentFrame)
function MyDungeonsBook:RosterFrame_CreateTabButtonsFrame(parentFrame, challengeId)
local tabs = self:TabsWidget_Create(parentFrame);
tabs:SetTabs({
local tabsConfig = {
{value = "shortInfo", text = L["Info"]},
{value = "equipment", text = L["Equipment"]},
{value = "talents", text = L["Talents"]},
{value = "covenant", text = L["Covenant"]},
{value = "misc", text = L["Misc"]},
});
};
local challenge = self:Challenge_GetById(challengeId);
if (not challenge) then
return tabs;
end
if (challenge.gameInfo and challenge.gameInfo.version) then
local version = challenge.gameInfo.version;
local major = string.sub(version, 1, string.find(version, "%.") - 1);
if (tonumber(major, 10) >= 10) then
tinsert(tabsConfig, {value = "talents", text = L["Talents"]});
else
tinsert(tabsConfig, {value = "oldTalents", text = L["Talents"]});
end
else
end
tinsert(tabsConfig, {value = "covenant", text = L["Covenant"]});
tinsert(tabsConfig, {value = "misc", text = L["Misc"]});
tabs:SetTabs(tabsConfig);
tabs:SetCallback("OnGroupSelected", function (container, _, tabId)
container:ReleaseChildren();
if (tabId == "covenant") then
Expand All @@ -35,9 +49,12 @@ function MyDungeonsBook:RosterFrame_CreateTabButtonsFrame(parentFrame)
if (tabId == "equipment") then
self.equipmentFrame = self:EquipmentFrame_Create(container, self.activeChallengeId);
end
if (tabId == "talents") then
if (tabId == "oldTalents") then
self.talentsFrame = self:TalentsFrame_Create(container, self.activeChallengeId);
end
if (tabId == "talents") then
self.talentsFrame = self:TalentsPartyMembersFrame_Create(container, self.activeChallengeId);
end
if (tabId == "misc") then
self.talentsFrame = self:MiscFrame_Create(container, self.activeChallengeId);
end
Expand Down
72 changes: 72 additions & 0 deletions UI/ChallengeDetails/Tabs/Roster/Tabs/OldTalents.lua
@@ -0,0 +1,72 @@
--[[--
@module MyDungeonsBook
]]

--[[--
UI
@section UI
]]

local L = LibStub("AceLocale-3.0"):GetLocale("MyDungeonsBook");
local AceGUI = LibStub("AceGUI-3.0");

--[[--
Creates a frame for Equipment tab
@param[type=Frame] parentFrame
@param[type=number] challengeId
@return[type=Frame]
]]
function MyDungeonsBook:TalentsFrame_Create(parentFrame, challengeId)
local equipmentFrame = self:TabContentWrapperWidget_Create(parentFrame);
local challenge = self.db.char.challenges[challengeId];
if (not challenge) then
return;
end
for _, unit in pairs(self:GetPartyRoster()) do
local partyMemberFrame = AceGUI:Create("InlineGroup");
partyMemberFrame:SetLayout("Flow");
partyMemberFrame:SetFullWidth(true);
equipmentFrame:AddChild(partyMemberFrame);
local challenge = self.db.char.challenges[challengeId];
partyMemberFrame:SetTitle(self:GetUnitNameRealmRoleStr(challenge.players[unit]) or L["Not Found"]);
self:TalentsFrame_PartyMember_Create(partyMemberFrame, unit, challengeId);
end
return equipmentFrame;
end


--[[--
Creates a frame with `unitId`'s talents.
@param[type=Frame] parentFrame
@param[type=unitId] unitId
@param[type=number] challengeId
]]
function MyDungeonsBook:TalentsFrame_PartyMember_Create(parentFrame, unitId, challengeId)
local challenge = self.db.char.challenges[challengeId];
local talents = self:SafeNestedGet(challenge.players, unitId, "talents");
if (not talents) then
return;
end
local talentsInfo = {};
for _, v in pairs(talents) do tinsert(talentsInfo, v) end
table.sort(talentsInfo, function (t1, t2)
return t1.tier < t2.tier;
end);
local suffix = self:GetIconTextureSuffix(30);
for _, talent in pairs(talentsInfo) do
local talentFrame = AceGUI:Create("InteractiveLabel");
local spellId = talent.spell_id;
local icon = talent.icon;
talentFrame:SetText("|T".. icon .. suffix .."|t");
talentFrame:SetWidth(35);
talentFrame:SetCallback("OnEnter", function()
self:Table_Cell_SpellMouseHover(talentFrame.frame, spellId);
end);
talentFrame:SetCallback("OnLeave", function()
self:Table_Cell_MouseOut();
end);
parentFrame:AddChild(talentFrame);
end
end

0 comments on commit 7c6248f

Please sign in to comment.