@@ -1030,73 +1030,6 @@ function CompareTabClass:GetShortBuildName(fullName)
10301030 return fullName
10311031end
10321032
1033- -- Format a numeric value with separator and rounding
1034- function CompareTabClass :FormatVal (val , p )
1035- return formatNumSep (tostring (round (val , p )))
1036- end
1037-
1038- -- Resolve format strings against an actor's output/modDB
1039- -- Handles: {output:Key}, {p:output:Key}, {p:mod:indices}
1040- function CompareTabClass :FormatStr (str , actor , colData )
1041- if not actor then return " " end
1042- str = str :gsub (" {output:([%a%.:]+)}" , function (c )
1043- local ns , var = c :match (" ^(%a+)%.(%a+)$" )
1044- if ns then
1045- return actor .output [ns ] and actor .output [ns ][var ] or " "
1046- else
1047- return actor .output [c ] or " "
1048- end
1049- end )
1050- str = str :gsub (" {(%d+):output:([%a%.:]+)}" , function (p , c )
1051- local ns , var = c :match (" ^(%a+)%.(%a+)$" )
1052- if ns then
1053- return self :FormatVal (actor .output [ns ] and actor .output [ns ][var ] or 0 , tonumber (p ))
1054- else
1055- return self :FormatVal (actor .output [c ] or 0 , tonumber (p ))
1056- end
1057- end )
1058- str = str :gsub (" {(%d+):mod:([%d,]+)}" , function (p , n )
1059- local numList = { }
1060- for num in n :gmatch (" %d+" ) do
1061- t_insert (numList , tonumber (num ))
1062- end
1063- if not colData [numList [1 ]] or not colData [numList [1 ]].modType then
1064- return " ?"
1065- end
1066- local modType = colData [numList [1 ]].modType
1067- local modTotal = modType == " MORE" and 1 or 0
1068- for _ , num in ipairs (numList ) do
1069- local sectionData = colData [num ]
1070- if not sectionData then break end
1071- local modCfg = (sectionData .cfg and actor .mainSkill and actor .mainSkill [sectionData .cfg .. " Cfg" ]) or { }
1072- if sectionData .modSource then
1073- modCfg .source = sectionData .modSource
1074- end
1075- if sectionData .actor then
1076- modCfg .actor = sectionData .actor
1077- end
1078- local modVal
1079- local modStore = (sectionData .enemy and actor .enemy and actor .enemy .modDB ) or (sectionData .cfg and actor .mainSkill and actor .mainSkill .skillModList ) or actor .modDB
1080- if not modStore then break end
1081- if type (sectionData .modName ) == " table" then
1082- modVal = modStore :Combine (sectionData .modType , modCfg , unpack (sectionData .modName ))
1083- else
1084- modVal = modStore :Combine (sectionData .modType , modCfg , sectionData .modName )
1085- end
1086- if modType == " MORE" then
1087- modTotal = modTotal * modVal
1088- else
1089- modTotal = modTotal + modVal
1090- end
1091- end
1092- if modType == " MORE" then
1093- modTotal = (modTotal - 1 ) * 100
1094- end
1095- return self :FormatVal (modTotal , tonumber (p ))
1096- end )
1097- return str
1098- end
1099-
11001033-- Populate a set-selector dropdown from a tab's ordered set list.
11011034-- tab: the tab object (e.g. itemsTab, skillsTab, configTab)
11021035-- orderListField/setsField/activeIdField: string keys on tab
@@ -4399,8 +4332,8 @@ function CompareTabClass:DrawCalcs(vp, compareEntry)
43994332 if subSec .data and subSec .data .extra then
44004333 local extraTextW = DrawStringWidth (16 , " VAR BOLD" , subSec .label .. " :" )
44014334 local extraX = x + 3 + extraTextW + 8
4402- local ok1 , pExtra = pcall (self . FormatStr , self , subSec .data .extra , primaryActor )
4403- local ok2 , cExtra = pcall (self . FormatStr , self , subSec .data .extra , compareActor )
4335+ local ok1 , pExtra = pcall (formatCalcStr , subSec .data .extra , primaryActor )
4336+ local ok2 , cExtra = pcall (formatCalcStr , subSec .data .extra , compareActor )
44044337 if ok1 and ok2 then
44054338 DrawString (extraX , lineY + 3 , " LEFT" , 16 , " VAR" ,
44064339 colorCodes .POSITIVE .. pExtra .. " ^8| " .. colorCodes .WARNING .. cExtra )
@@ -4452,7 +4385,7 @@ function CompareTabClass:DrawCalcs(vp, compareEntry)
44524385 DrawImage (nil , x + valCol1X , lineY , valColWidth , 18 )
44534386 end
44544387 if colData and colData .format then
4455- local ok , str = pcall (self . FormatStr , self , colData .format , primaryActor , colData )
4388+ local ok , str = pcall (formatCalcStr , colData .format , primaryActor , colData )
44564389 if ok and str then
44574390 DrawString (x + valCol1X + 2 , lineY + 9 - textSize / 2 , " LEFT" , textSize , " VAR" , " ^7" .. str )
44584391 end
@@ -4466,7 +4399,7 @@ function CompareTabClass:DrawCalcs(vp, compareEntry)
44664399 DrawImage (nil , x + valCol2X , lineY , valColWidth , 18 )
44674400 end
44684401 if colData and colData .format then
4469- local ok , str = pcall (self . FormatStr , self , colData .format , compareActor , colData )
4402+ local ok , str = pcall (formatCalcStr , colData .format , compareActor , colData )
44704403 if ok and str then
44714404 DrawString (x + valCol2X + 2 , lineY + 9 - textSize / 2 , " LEFT" , textSize , " VAR" , " ^7" .. str )
44724405 end
0 commit comments