Skip to content

Commit f69a64c

Browse files
author
LocalIdentity
committed
Stop bloodline ascendancy list running every frame
The list was not being caches before and was running every frame for some reason
1 parent 771f4e9 commit f69a64c

1 file changed

Lines changed: 51 additions & 35 deletions

File tree

src/Modules/Build.lua

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
107107
self.abortSave = true
108108

109109
wipeTable(self.controls)
110+
self.secondaryAscendDropAltAscendancies = nil
111+
self.secondaryAscendDropLegacySelection = nil
112+
self.secondaryAscendDropEntryCount = nil
110113

111114
local miscTooltip = new("Tooltip")
112115

@@ -1071,6 +1074,53 @@ function buildMode:ResetModFlags()
10711074
self.calcsTab.modFlag = false
10721075
end
10731076

1077+
function buildMode:UpdateSecondaryAscendancyDropdown(forceListUpdate)
1078+
local secondaryDrop = self.controls.secondaryAscendDrop
1079+
if not secondaryDrop then
1080+
return
1081+
end
1082+
local legacyAlternateAscendancyIds = {
1083+
Warden = true,
1084+
Warlock = true,
1085+
Primalist = true,
1086+
}
1087+
local selection = (self.spec and self.spec.curSecondaryAscendClassId) or 0
1088+
local altAscendancies = self.spec and self.spec.tree and self.spec.tree.alternate_ascendancies
1089+
local selectedAscendancy = altAscendancies and altAscendancies[selection]
1090+
local selectedLegacyAscendancy = selectedAscendancy and legacyAlternateAscendancyIds[selectedAscendancy.id] and selectedAscendancy.id or nil
1091+
if forceListUpdate
1092+
or self.secondaryAscendDropAltAscendancies ~= altAscendancies
1093+
or self.secondaryAscendDropLegacySelection ~= selectedLegacyAscendancy
1094+
then
1095+
local entries = {
1096+
{ label = "None", ascendClassId = 0 },
1097+
}
1098+
if altAscendancies then
1099+
local sortable = { }
1100+
for ascendClassId, ascendClass in pairs(altAscendancies) do
1101+
if ascendClass and ascendClass.id then
1102+
if not legacyAlternateAscendancyIds[ascendClass.id] or ascendClassId == selection then
1103+
t_insert(sortable, { label = ascendClass.name, ascendClassId = ascendClassId })
1104+
end
1105+
end
1106+
end
1107+
t_sort(sortable, function(a, b)
1108+
return a.label < b.label
1109+
end)
1110+
for _, entry in ipairs(sortable) do
1111+
t_insert(entries, entry)
1112+
end
1113+
end
1114+
secondaryDrop:SetList(entries)
1115+
secondaryDrop:CheckDroppedWidth(true)
1116+
self.secondaryAscendDropEntryCount = #entries
1117+
self.secondaryAscendDropAltAscendancies = altAscendancies
1118+
self.secondaryAscendDropLegacySelection = selectedLegacyAscendancy
1119+
end
1120+
secondaryDrop:SelByValue(selection, "ascendClassId")
1121+
secondaryDrop.enabled = self.spec ~= nil and (self.secondaryAscendDropEntryCount or 1) > 1
1122+
end
1123+
10741124
function buildMode:OnFrame(inputEvents)
10751125
-- Stop at drawing the background if the loaded build needs to be converted
10761126
if not self.targetVersion then
@@ -1127,41 +1177,7 @@ function buildMode:OnFrame(inputEvents)
11271177
self.controls.ascendDrop.list = self.controls.classDrop:GetSelValueByKey("ascendancies")
11281178
self.controls.ascendDrop:SelByValue(self.spec.curAscendClassId, "ascendClassId")
11291179
self.controls.ascendDrop:CheckDroppedWidth(true)
1130-
local secondaryDrop = self.controls.secondaryAscendDrop
1131-
if secondaryDrop then
1132-
local legacyAlternateAscendancyIds = {
1133-
Warden = true,
1134-
Warlock = true,
1135-
Primalist = true,
1136-
}
1137-
local entries = {
1138-
{ label = "None", ascendClassId = 0 },
1139-
}
1140-
local selection = (self.spec and self.spec.curSecondaryAscendClassId) or 0
1141-
if self.spec and self.spec.tree then
1142-
local altAscendancies = self.spec.tree.alternate_ascendancies
1143-
if altAscendancies then
1144-
local sortable = { }
1145-
for ascendClassId, ascendClass in pairs(altAscendancies) do
1146-
if ascendClass and ascendClass.id then
1147-
if not legacyAlternateAscendancyIds[ascendClass.id] or ascendClassId == selection then
1148-
t_insert(sortable, { label = ascendClass.name, ascendClassId = ascendClassId })
1149-
end
1150-
end
1151-
end
1152-
t_sort(sortable, function(a, b)
1153-
return a.label < b.label
1154-
end)
1155-
for _, entry in ipairs(sortable) do
1156-
t_insert(entries, entry)
1157-
end
1158-
end
1159-
end
1160-
secondaryDrop:SetList(entries)
1161-
secondaryDrop:SelByValue(selection, "ascendClassId")
1162-
secondaryDrop:CheckDroppedWidth(true)
1163-
secondaryDrop.enabled = self.spec ~= nil and #entries > 1
1164-
end
1180+
self:UpdateSecondaryAscendancyDropdown()
11651181

11661182
if self.buildFlag then
11671183
-- Wipe Global Cache

0 commit comments

Comments
 (0)