Skip to content

Commit bf9f84c

Browse files
authored
Add support for export and importing warcry buffs to the Party Tab (#8116)
* add support for export and importing warcry buffs to the party tab * fix to work with minions * add support for extraWarcryMods (like rallying cry) * fix merge conflict
1 parent d770618 commit bf9f84c

File tree

2 files changed

+125
-28
lines changed

2 files changed

+125
-28
lines changed

src/Classes/PartyTab.lua

Lines changed: 80 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ local PartyTabClass = newClass("PartyTab", "ControlHost", "Control", function(se
1515

1616
self.build = build
1717

18-
self.actor = { Aura = { }, Curse = { }, Link = { }, modDB = new("ModDB"), output = { } }
18+
self.actor = { Aura = { }, Curse = { }, Warcry = { }, Link = { }, modDB = new("ModDB"), output = { } }
1919
self.actor.modDB.actor = self.actor
2020
self.enemyModList = new("ModList")
2121
self.buffExports = { }
@@ -24,14 +24,15 @@ local PartyTabClass = newClass("PartyTab", "ControlHost", "Control", function(se
2424
self.lastContent = {
2525
Aura = "",
2626
Curse = "",
27+
Warcry = "",
2728
Link = "",
2829
EnemyCond = "",
2930
EnemyMods = "",
3031
EnableExportBuffs = false,
3132
showAdvancedTools = false,
3233
}
3334

34-
local partyDestinations = { "All", "Party Member Stats", "Aura", "Curse", "Link Skills", "EnemyConditions", "EnemyMods" }
35+
local partyDestinations = { "All", "Party Member Stats", "Aura", "Curse", "Warcry Skills", "Link Skills", "EnemyConditions", "EnemyMods" }
3536

3637
local theme = {
3738
stringHeight = 16,
@@ -49,7 +50,7 @@ local PartyTabClass = newClass("PartyTab", "ControlHost", "Control", function(se
4950
bufferHeightSmall = 106,
5051
bufferHeightLeft = function()
5152
-- 2 elements
52-
return (self.height - 258 - ((self.width > 1350) and 0 or 24) - self.controls.importCodeHeader.y() - self.controls.editAurasLabel.y())
53+
return (self.height - 378 - ((self.width > 1350) and 0 or 24) - self.controls.importCodeHeader.y() - self.controls.editAurasLabel.y())
5354
end,
5455
-- 4 elements
5556
bufferHeightRight = 434,
@@ -90,6 +91,12 @@ local PartyTabClass = newClass("PartyTab", "ControlHost", "Control", function(se
9091
wipeTable(self.actor["Curse"])
9192
self.actor["Curse"] = {}
9293
end
94+
if partyDestinations[self.controls.importCodeDestination.selIndex] == "All" or partyDestinations[self.controls.importCodeDestination.selIndex] == "Warcry Skills" then
95+
self.controls.simpleLinks.label = ""
96+
self.controls.editLinks:SetText("")
97+
wipeTable(self.actor["Warcry"])
98+
self.actor["Warcry"] = {}
99+
end
93100
if partyDestinations[self.controls.importCodeDestination.selIndex] == "All" or partyDestinations[self.controls.importCodeDestination.selIndex] == "Link Skills" then
94101
self.controls.simpleLinks.label = ""
95102
self.controls.editLinks:SetText("")
@@ -168,6 +175,10 @@ local PartyTabClass = newClass("PartyTab", "ControlHost", "Control", function(se
168175
wipeTable(self.actor["Curse"])
169176
self.actor["Curse"] = { }
170177
end
178+
if partyDestinations[self.controls.importCodeDestination.selIndex] == "All" or partyDestinations[self.controls.importCodeDestination.selIndex] == "Warcry Skills" then
179+
wipeTable(self.actor["Warcry"])
180+
self.actor["Warcry"] = { }
181+
end
171182
if partyDestinations[self.controls.importCodeDestination.selIndex] == "All" or partyDestinations[self.controls.importCodeDestination.selIndex] == "Link Skills" then
172183
-- only one link can be applied at a time anyway
173184
currentLinkBuffer = self.controls.editLinks.buf
@@ -221,6 +232,14 @@ local PartyTabClass = newClass("PartyTab", "ControlHost", "Control", function(se
221232
self.controls.editCurses:SetText(node[1] or "")
222233
self:ParseBuffs(self.actor["Curse"], self.controls.editCurses.buf, "Curse", self.controls.simpleCurses)
223234
end
235+
elseif node.attrib.name == "Warcry Skills" then
236+
if partyDestinations[self.controls.importCodeDestination.selIndex] == "All" or partyDestinations[self.controls.importCodeDestination.selIndex] == "Warcry Skills" then
237+
if #self.controls.editWarcries.buf > 0 then
238+
node[1] = self.controls.editWarcries.buf.."\n"..(node[1] or "")
239+
end
240+
self.controls.editWarcries:SetText(node[1] or "")
241+
self:ParseBuffs(self.actor["Warcry"], self.controls.editWarcries.buf, "Warcry", self.controls.simpleWarcries)
242+
end
224243
elseif node.attrib.name == "Link Skills" then
225244
if partyDestinations[self.controls.importCodeDestination.selIndex] == "All" or partyDestinations[self.controls.importCodeDestination.selIndex] == "Link Skills" then
226245
if #self.controls.editLinks.buf > 0 then
@@ -330,7 +349,7 @@ local PartyTabClass = newClass("PartyTab", "ControlHost", "Control", function(se
330349
self.controls.removeEffects = new("ButtonControl", {"LEFT",self.controls.ShowAdvanceTools,"RIGHT"}, 8, 0, 160, theme.buttonHeight, "Disable Party Effects", function()
331350
wipeTable(self.actor)
332351
wipeTable(self.enemyModList)
333-
self.actor = { Aura = {}, Curse = {}, Link = {}, modDB = new("ModDB"), output = { } }
352+
self.actor = { Aura = {}, Curse = {}, Warcry = { }, Link = {}, modDB = new("ModDB"), output = { } }
334353
self.actor.modDB.actor = self.actor
335354
self.enemyModList = new("ModList")
336355
self.build.buildFlag = true
@@ -340,12 +359,13 @@ local PartyTabClass = newClass("PartyTab", "ControlHost", "Control", function(se
340359
self.controls.rebuild = new("ButtonControl", {"LEFT",self.controls.removeEffects,"RIGHT"}, 8, 0, 160, theme.buttonHeight, "^7Rebuild All", function()
341360
wipeTable(self.actor)
342361
wipeTable(self.enemyModList)
343-
self.actor = { Aura = {}, Curse = {}, Link = {}, modDB = new("ModDB"), output = { } }
362+
self.actor = { Aura = {}, Curse = {}, Warcry = { }, Link = {}, modDB = new("ModDB"), output = { } }
344363
self.actor.modDB.actor = self.actor
345364
self.enemyModList = new("ModList")
346365
self:ParseBuffs(self.actor["modDB"], self.controls.editPartyMemberStats.buf, "PartyMemberStats", self.actor["output"])
347366
self:ParseBuffs(self.actor["Aura"], self.controls.editAuras.buf, "Aura", self.controls.simpleAuras)
348367
self:ParseBuffs(self.actor["Curse"], self.controls.editCurses.buf, "Curse", self.controls.simpleCurses)
368+
self:ParseBuffs(self.actor["Warcry"], self.controls.editWarcries.buf, "Warcry", self.controls.simpleWarcries)
349369
self:ParseBuffs(self.actor["Link"], self.controls.editLinks.buf, "Link", self.controls.simpleLinks)
350370
self:ParseBuffs(self.enemyModList, self.controls.enemyCond.buf, "EnemyConditions")
351371
self:ParseBuffs(self.enemyModList, self.controls.enemyMods.buf, "EnemyMods", self.controls.simpleEnemyMods)
@@ -368,7 +388,7 @@ local PartyTabClass = newClass("PartyTab", "ControlHost", "Control", function(se
368388
return self.width / 2 - 16
369389
end
370390
self.controls.editAuras.height = function()
371-
return self.controls.editLinks.hasFocus and theme.bufferHeightSmall or theme.bufferHeightLeft()
391+
return (self.controls.editWarcries.hasFocus or self.controls.editLinks.hasFocus) and theme.bufferHeightSmall or theme.bufferHeightLeft()
372392
end
373393

374394
self.controls.editAuras.shown = function()
@@ -379,10 +399,29 @@ local PartyTabClass = newClass("PartyTab", "ControlHost", "Control", function(se
379399
return not self.controls.ShowAdvanceTools.state
380400
end
381401

382-
self.controls.editLinksLabel = new("LabelControl", {"TOPLEFT",self.controls.editAurasLabel,"BOTTOMLEFT"}, 0, 8, 0, theme.stringHeight, "^7Link Skills")
383-
self.controls.editLinksLabel.y = function()
402+
self.controls.editWarcriesLabel = new("LabelControl", {"TOPLEFT",self.controls.editAurasLabel,"BOTTOMLEFT"}, 0, 8, 0, theme.stringHeight, "^7Warcry Skills")
403+
self.controls.editWarcriesLabel.y = function()
384404
return self.controls.ShowAdvanceTools.state and (self.controls.editAuras.height() + 8) or (theme.lineCounter(self.controls.simpleAuras.label) + 4)
385405
end
406+
self.controls.editWarcries = new("EditControl", {"TOPLEFT",self.controls.editWarcriesLabel,"TOPLEFT"}, 0, 18, 0, 0, "", nil, "^%C\t\n", nil, nil, 14, true)
407+
self.controls.editWarcries.width = function()
408+
return self.width / 2 - 16
409+
end
410+
self.controls.editWarcries.height = function()
411+
return (self.controls.editWarcries.hasFocus and theme.bufferHeightLeft() or theme.bufferHeightSmall)
412+
end
413+
self.controls.editWarcries.shown = function()
414+
return self.controls.ShowAdvanceTools.state
415+
end
416+
self.controls.simpleWarcries = new("LabelControl", {"TOPLEFT",self.controls.editWarcriesLabel,"TOPLEFT"}, 0, 18, 0, theme.stringHeight, "")
417+
self.controls.simpleWarcries.shown = function()
418+
return not self.controls.ShowAdvanceTools.state
419+
end
420+
421+
self.controls.editLinksLabel = new("LabelControl", {"TOPLEFT",self.controls.editWarcriesLabel,"BOTTOMLEFT"}, 0, 8, 0, theme.stringHeight, "^7Link Skills")
422+
self.controls.editLinksLabel.y = function()
423+
return self.controls.ShowAdvanceTools.state and (self.controls.editWarcries.height() + 8) or (theme.lineCounter(self.controls.simpleWarcries.label) + 4)
424+
end
386425
self.controls.editLinks = new("EditControl", {"TOPLEFT",self.controls.editLinksLabel,"TOPLEFT"}, 0, 18, 0, 0, "", nil, "^%C\t\n", nil, nil, 14, true)
387426
self.controls.editLinks.width = function()
388427
return self.width / 2 - 16
@@ -483,6 +522,9 @@ function PartyTabClass:Load(xml, fileName)
483522
elseif node.attrib.name == "Curse" then
484523
self.controls.editCurses:SetText(node[1] or "")
485524
self:ParseBuffs(self.actor["Curse"], node[1] or "", "Curse", self.controls.simpleCurses)
525+
elseif node.attrib.name == "Warcry Skills" then
526+
self.controls.editWarcries:SetText(node[1] or "")
527+
self:ParseBuffs(self.actor["Warcry"], node[1] or "", "Warcry", self.controls.simpleWarcries)
486528
elseif node.attrib.name == "Link Skills" then
487529
self.controls.editLinks:SetText(node[1] or "")
488530
self:ParseBuffs(self.actor["Link"], node[1] or "", "Link", self.controls.simpleLinks)
@@ -503,6 +545,7 @@ function PartyTabClass:Load(xml, fileName)
503545
--self:ParseBuffs(self.buffExports, node[1] or "", "PartyMemberStats")
504546
--self:ParseBuffs(self.buffExports, node[1] or "", "Aura")
505547
--self:ParseBuffs(self.buffExports, node[1] or "", "Curse")
548+
--self:ParseBuffs(self.buffExports, node[1] or "", "Warcry")
506549
--self:ParseBuffs(self.buffExports, node[1] or "", "Link")
507550
--self:ParseBuffs(self.buffExports, node[1] or "", "EnemyConditions")
508551
--self:ParseBuffs(self.buffExports, node[1] or "", "EnemyMods")
@@ -511,6 +554,7 @@ function PartyTabClass:Load(xml, fileName)
511554
self.lastContent.PartyMemberStats = self.controls.editPartyMemberStats.buf
512555
self.lastContent.Aura = self.controls.editAuras.buf
513556
self.lastContent.Curse = self.controls.editCurses.buf
557+
self.lastContent.Warcry = self.controls.editWarcries.buf
514558
self.lastContent.Link = self.controls.editLinks.buf
515559
self.lastContent.EnemyCond = self.controls.enemyCond.buf
516560
self.lastContent.EnemyMods = self.controls.enemyMods.buf
@@ -540,6 +584,11 @@ function PartyTabClass:Save(xml)
540584
t_insert(child, self.controls.editCurses.buf)
541585
t_insert(xml, child)
542586
end
587+
if self.controls.editWarcries.buf and self.controls.editWarcries.buf ~= "" then
588+
child = { elem = "ImportedBuffs", attrib = { name = "Warcry Skills" } }
589+
t_insert(child, self.controls.editWarcries.buf)
590+
t_insert(xml, child)
591+
end
543592
if self.controls.editLinks.buf and self.controls.editLinks.buf ~= "" then
544593
child = { elem = "ImportedBuffs", attrib = { name = "Link Skills" } }
545594
t_insert(child, self.controls.editLinks.buf)
@@ -573,6 +622,12 @@ function PartyTabClass:Save(xml)
573622
t_insert(child, exportString)
574623
t_insert(xml, child)
575624
end
625+
exportString = self:exportBuffs("Warcry")
626+
if exportString ~= "" then
627+
child = { elem = "ExportedBuffs", attrib = { name = "Warcry Skills" } }
628+
t_insert(child, exportString)
629+
t_insert(xml, child)
630+
end
576631
exportString = self:exportBuffs("Link")
577632
if exportString ~= "" then
578633
child = { elem = "ExportedBuffs", attrib = { name = "Link Skills" } }
@@ -594,6 +649,7 @@ function PartyTabClass:Save(xml)
594649
self.lastContent.PartyMemberStats = self.controls.editPartyMemberStats.buf
595650
self.lastContent.Aura = self.controls.editAuras.buf
596651
self.lastContent.Curse = self.controls.editCurses.buf
652+
self.lastContent.Warcry = self.controls.editWarcries.buf
597653
self.lastContent.Link = self.controls.editLinks.buf
598654
self.lastContent.EnemyCond = self.controls.enemyCond.buf
599655
self.lastContent.EnemyMods = self.controls.enemyMods.buf
@@ -645,6 +701,7 @@ function PartyTabClass:Draw(viewPort, inputEvents)
645701

646702
self.modFlag = (self.lastContent.Aura ~= self.controls.editAuras.buf
647703
or self.lastContent.Curse ~= self.controls.editCurses.buf
704+
or self.lastContent.Warcry ~= self.controls.editWarcries.buf
648705
or self.lastContent.Link ~= self.controls.editLinks.buf
649706
or self.lastContent.PartyMemberStats ~= self.controls.editPartyMemberStats.buf
650707
or self.lastContent.EnemyCond ~= self.controls.enemyCond.buf
@@ -733,7 +790,7 @@ function PartyTabClass:ParseBuffs(list, buf, buffType, label)
733790
local currentName
734791
local currentEffect
735792
local isMark
736-
local currentModType = (buffType == "Link") and "Link" or "Unknown"
793+
local currentModType = (buffType == "Link") and "Link" or (buffType == "Warcry") and "Warcry" or "Unknown"
737794
for line in buf:gmatch("([^\n]*)\n?") do
738795
if line ~= "---" and line:match("%-%-%-") then
739796
-- comment but not divider, skip the line
@@ -770,7 +827,7 @@ function PartyTabClass:ParseBuffs(list, buf, buffType, label)
770827
local mod = modLib.parseFormattedSourceMod(line)
771828
if mod then
772829
for _, tag in ipairs(mod) do
773-
if tag.type == "GlobalEffect" and currentModType ~= "Link" and currentModType ~= "otherEffects" then
830+
if tag.type == "GlobalEffect" and currentModType ~= "Link" and currentModType ~= "Warcry" and currentModType ~= "otherEffects" then
774831
currentModType = tag.effectType
775832
end
776833
end
@@ -866,6 +923,17 @@ function PartyTabClass:ParseBuffs(list, buf, buffType, label)
866923
end
867924
label.label = label.label.."---------------------------\n"
868925
end
926+
elseif buffType == "Warcry" then
927+
local labelList = {}
928+
for warcry, warcryMod in pairs(list["Warcry"] or {}) do
929+
t_insert(labelList, warcry..": "..warcryMod.effectMult.."%\n")
930+
end
931+
if #labelList > 0 then
932+
table.sort(labelList)
933+
label.label = "^7---------------------------\n"..table.concat(labelList).."---------------------------\n"
934+
else
935+
label.label = ""
936+
end
869937
elseif buffType == "Link" then
870938
local labelList = {}
871939
for link, linkMod in pairs(list["Link"] or {}) do
@@ -922,7 +990,7 @@ function PartyTabClass:exportBuffs(buffType)
922990
else
923991
buf = buf.."\nfalse"
924992
end
925-
elseif buffType == "Link" or buffType == "Aura" and buffName ~= "extraAura" and buffName ~= "otherEffects" then
993+
elseif buffType == "Link" or buffType == "Warcry" or buffType == "Aura" and buffName ~= "extraAura" and buffName ~= "otherEffects" then
926994
buf = buf.."\n"..tostring(buff.effectMult * 100)
927995
end
928996
if buffType == "Aura" and buffName == "otherEffects" then
@@ -932,7 +1000,7 @@ function PartyTabClass:exportBuffs(buffType)
9321000
end
9331001
end
9341002
buf = buf.."\n---"
935-
elseif buffType == "Curse" or buffType == "Aura" or buffType == "Link" then
1003+
elseif buffType == "Curse" or buffType == "Aura" or buffType == "Warcry" or buffType == "Link" then
9361004
for _, mod in ipairs(buff.modList) do
9371005
buf = buf.."\n"..modLib.formatSourceMod(mod)
9381006
end

0 commit comments

Comments
 (0)