@@ -129,6 +129,9 @@ local CompareTabClass = newClass("CompareTab", "ControlHost", "Control", functio
129129 self .configSectionLayout = {} -- computed section layout for drawing
130130 self .configTotalContentHeight = 0
131131
132+ -- Notes view state
133+ self .notesActiveEntry = nil
134+
132135 -- Compare power report state
133136 self .comparePowerStat = nil -- selected data.powerStatList entry
134137 self .comparePowerCategories = { treeNodes = true , items = true , skillGems = true , supportGems = true , config = true }
149152
150153function CompareTabClass :InitControls ()
151154 -- Sub-tab buttons
152- local subTabs = { " Summary" , " Tree" , " Skills" , " Items" , " Calcs" , " Config" }
153- local subTabModes = { " SUMMARY" , " TREE" , " SKILLS" , " ITEMS" , " CALCS" , " CONFIG" }
155+ local subTabs = { " Summary" , " Tree" , " Skills" , " Items" , " Calcs" , " Config" , " Notes " }
156+ local subTabModes = { " SUMMARY" , " TREE" , " SKILLS" , " ITEMS" , " CALCS" , " CONFIG" , " NOTES " }
154157
155158 self .controls .subTabAnchor = new (" Control" , nil , {0 , 0 , 0 , 20 })
156159 for i , tabName in ipairs (subTabs ) do
@@ -179,12 +182,23 @@ function CompareTabClass:InitControls()
179182 end
180183 end
181184
185+ -- Notes sub-tab controls
186+ self .controls .notesDesc = new (" LabelControl" , nil , {0 , 0 , 0 , 16 }, " ^7These are the notes from the compared build. Any edits here are saved with this comparison and do not affect the main build's notes." )
187+ self .controls .notesDesc .shown = function ()
188+ return self .compareViewMode == " NOTES" and # self .compareEntries > 0
189+ end
190+ self .controls .notesEdit = new (" EditControl" , nil , {0 , 0 , 0 , 0 }, " " , nil , " ^%C\t\n " , nil , nil , 16 , true )
191+ self .controls .notesEdit .shown = function ()
192+ return self .compareViewMode == " NOTES" and # self .compareEntries > 0
193+ end
194+
182195 -- Build B selector dropdown
183196 self .controls .compareBuildLabel = new (" LabelControl" , {" TOPLEFT" , self .controls .subTabAnchor , " TOPLEFT" }, {0 , - 70 , 0 , 16 }, " ^7Compare with:" )
184197 self .controls .compareBuildSelect = new (" DropDownControl" , {" LEFT" , self .controls .compareBuildLabel , " RIGHT" }, {4 , 0 , 250 , 20 }, {}, function (index , value )
185198 if index and index > 0 and index <= # self .compareEntries then
186199 self .activeCompareIndex = index
187200 self .treeSearchNeedsSync = true
201+ self .notesActiveEntry = nil
188202 end
189203 end )
190204 self .controls .compareBuildSelect .enabled = function ()
@@ -1041,6 +1055,10 @@ function CompareTabClass:Save(xml)
10411055 xml .attrib = {
10421056 activeCompareIndex = tostring (self .activeCompareIndex ),
10431057 }
1058+ -- Sync current notes edit buffer to the active entry before saving
1059+ if self .notesActiveEntry then
1060+ self .notesActiveEntry .notesText = self .controls .notesEdit .buf
1061+ end
10441062 for _ , entry in ipairs (self .compareEntries ) do
10451063 local attrib = {
10461064 label = entry .label ,
@@ -1058,10 +1076,14 @@ function CompareTabClass:Save(xml)
10581076 if entry .configTab then
10591077 attrib .activeConfigSetId = tostring (entry .configTab .activeConfigSetId )
10601078 end
1061- t_insert ( xml , {
1079+ local entryNode = {
10621080 elem = " CompareEntry" ,
10631081 attrib = attrib ,
1064- })
1082+ }
1083+ if entry .notesText and entry .notesText ~= " " then
1084+ t_insert (entryNode , { elem = " Notes" , attrib = {}, entry .notesText })
1085+ end
1086+ t_insert (xml , entryNode )
10651087 end
10661088end
10671089
@@ -1092,6 +1114,18 @@ function CompareTabClass:Load(xml, dbFileName)
10921114 if savedConfigSet and entry .configTab and entry .configTab .configSets [savedConfigSet ] then
10931115 entry .configTab :SetActiveConfigSet (savedConfigSet )
10941116 end
1117+ -- Restore edited notes (overrides notes from original build XML)
1118+ for _ , grandchild in ipairs (child ) do
1119+ if type (grandchild ) == " table" and grandchild .elem == " Notes" then
1120+ for _ , text in ipairs (grandchild ) do
1121+ if type (text ) == " string" then
1122+ entry .notesText = text
1123+ break
1124+ end
1125+ end
1126+ break
1127+ end
1128+ end
10951129 end
10961130 end
10971131 end
@@ -1110,6 +1144,7 @@ function CompareTabClass:RemoveBuild(index)
11101144 if index >= 1 and index <= # self .compareEntries then
11111145 t_remove (self .compareEntries , index )
11121146 self .modFlag = true
1147+ self .notesActiveEntry = nil
11131148 if self .activeCompareIndex > # self .compareEntries then
11141149 self .activeCompareIndex = # self .compareEntries
11151150 end
@@ -1500,6 +1535,8 @@ function CompareTabClass:Draw(viewPort, inputEvents)
15001535 self :DrawCalcs (contentVP , compareEntry )
15011536 elseif self .compareViewMode == " CONFIG" then
15021537 self :DrawConfig (contentVP , compareEntry )
1538+ elseif self .compareViewMode == " NOTES" then
1539+ self :DrawNotes (contentVP , compareEntry , inputEvents )
15031540 end
15041541end
15051542
@@ -4077,4 +4114,47 @@ function CompareTabClass:DrawConfig(vp, compareEntry)
40774114 SetViewport ()
40784115end
40794116
4117+ function CompareTabClass :DrawNotes (vp , compareEntry , inputEvents )
4118+ if not compareEntry then return end
4119+
4120+ -- Sync EditControl with the active compare entry
4121+ if self .notesActiveEntry ~= compareEntry then
4122+ self .controls .notesEdit :SetText (compareEntry .notesText or " " )
4123+ self .notesActiveEntry = compareEntry
4124+ end
4125+
4126+ -- Handle undo/redo
4127+ for id , event in ipairs (inputEvents ) do
4128+ if event .type == " KeyDown" then
4129+ if event .key == " z" and IsKeyDown (" CTRL" ) then
4130+ self .controls .notesEdit :Undo ()
4131+ elseif event .key == " y" and IsKeyDown (" CTRL" ) then
4132+ self .controls .notesEdit :Redo ()
4133+ end
4134+ end
4135+ end
4136+
4137+ -- Position label and edit control
4138+ self .controls .notesDesc .x = vp .x + 8
4139+ self .controls .notesDesc .y = vp .y + 8
4140+
4141+ local editY = vp .y + 30
4142+ self .controls .notesEdit .x = vp .x + 8
4143+ self .controls .notesEdit .y = editY
4144+ self .controls .notesEdit .width = function ()
4145+ return vp .width - 16
4146+ end
4147+ self .controls .notesEdit .height = function ()
4148+ return vp .height - 38
4149+ end
4150+
4151+ -- Sync edits back to the compare entry
4152+ if compareEntry .notesText ~= self .controls .notesEdit .buf then
4153+ compareEntry .notesText = self .controls .notesEdit .buf
4154+ self .modFlag = true
4155+ end
4156+
4157+ main :DrawBackground (vp )
4158+ end
4159+
40804160return CompareTabClass
0 commit comments