@@ -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
@@ -119,9 +122,29 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
119122 self :CloseBuild ()
120123 end
121124 end )
122- self .controls .buildName = new (" Control" , {" LEFT" ,self .controls .back ," RIGHT" }, {8 , 0 , 0 , 20 })
125+ self .controls .save = new (" ButtonControl" , {" LEFT" ,self .controls .back ," RIGHT" }, {8 , 0 , 50 , 20 }, " Save" , function ()
126+ self :SaveDBFile ()
127+ end )
128+ self .controls .save .enabled = function ()
129+ return not self .dbFileName or self .unsaved
130+ end
131+ self .controls .saveAs = new (" ButtonControl" , {" LEFT" ,self .controls .save ," RIGHT" }, {8 , 0 , 70 , 20 }, " Save As" , function ()
132+ self :OpenSaveAsPopup ()
133+ end )
134+ self .controls .saveAs .enabled = function ()
135+ return self .dbFileName
136+ end
137+
138+ -- conditional for smaller screens to move "Current build" to the side bar
139+ local function buildNameConditional ()
140+ return self .anchorTopBarRight :GetPos () < 800
141+ end
142+ self .controls .buildName = new (" Control" , {" LEFT" ,self .controls .saveAs ," RIGHT" }, {4 , 36 , 0 , 20 })
123143 self .controls .buildName .width = function (control )
124- local limit = self .anchorTopBarRight :GetPos () - 98 - 40 - self .controls .back :GetSize () - self .controls .save :GetSize () - self .controls .saveAs :GetSize ()
144+ local limit = buildNameConditional () and 203 or
145+ (self .anchorTopBarRight :GetPos () - 98 - 62
146+ - self .controls .pointDisplay :GetSize () - self .controls .levelScalingButton :GetSize () - self .controls .characterLevel :GetSize ()
147+ - self .controls .back :GetSize () - self .controls .save :GetSize () - self .controls .saveAs :GetSize ())
125148 local bnw = DrawStringWidth (16 , " VAR" , self .buildName )
126149 self .strWidth = m_min (bnw , limit )
127150 self .strLimited = bnw > limit
@@ -150,30 +173,20 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
150173 SetDrawLayer (nil , 0 )
151174 end
152175 end
153- self .controls .save = new (" ButtonControl" , {" LEFT" ,self .controls .buildName ," RIGHT" }, {8 , 0 , 50 , 20 }, " Save" , function ()
154- self :SaveDBFile ()
155- end )
156- self .controls .save .enabled = function ()
157- return not self .dbFileName or self .unsaved
176+ self .controls .buildName .x = function ()
177+ return buildNameConditional () and - 196 or 8
158178 end
159- self .controls .saveAs = new (" ButtonControl" , {" LEFT" ,self .controls .save ," RIGHT" }, {8 , 0 , 70 , 20 }, " Save As" , function ()
160- self :OpenSaveAsPopup ()
161- end )
162- self .controls .saveAs .enabled = function ()
163- return self .dbFileName
179+ self .controls .buildName .y = function ()
180+ return buildNameConditional () and 32 or 0
164181 end
165182
166183 -- Controls: top bar, right side
167184 self .anchorTopBarRight = new (" Control" , nil , {function () return main .screenW / 2 + 6 end , 4 , 0 , 20 })
168- self .controls .pointDisplay = new (" Control" , {" LEFT" ,self .anchorTopBarRight ," RIGHT" }, {- 12 , 0 , 0 , 20 })
169- self .controls .pointDisplay .x = function (control )
170- local width , height = control :GetSize ()
171- if self .controls .saveAs :GetPos () + self .controls .saveAs :GetSize () < self .anchorTopBarRight :GetPos () - width - 16 then
172- return - 12 - width
173- else
174- return 0
175- end
185+
186+ local function getPointDisplayX () -- I had it hardcoded to -323 before switching to the control sizing
187+ return - (23 + self .controls .pointDisplay :GetSize () + self .controls .levelScalingButton :GetSize () + self .controls .characterLevel :GetSize ())
176188 end
189+ self .controls .pointDisplay = new (" Control" , {" LEFT" ,self .anchorTopBarRight ," RIGHT" }, {function () return getPointDisplayX () end , 0 , 0 , 20 })
177190 self .controls .pointDisplay .width = function (control )
178191 control .str , control .req = self :EstimatePlayerProgress ()
179192 return DrawStringWidth (16 , " FIXED" , control .str ) + 8
@@ -195,7 +208,7 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
195208 SetDrawLayer (nil , 0 )
196209 end
197210 end
198- self .controls .levelScalingButton = new (" ButtonControl" , {" LEFT" ,self .controls .pointDisplay ," RIGHT" }, {10 , 0 , 50 , 20 }, self .characterLevelAutoMode and " Auto" or " Manual" , function ()
211+ self .controls .levelScalingButton = new (" ButtonControl" , {" LEFT" ,self .controls .pointDisplay ," RIGHT" }, {7 , 0 , 50 , 20 }, self .characterLevelAutoMode and " Auto" or " Manual" , function ()
199212 self .characterLevelAutoMode = not self .characterLevelAutoMode
200213 self .controls .levelScalingButton .label = self .characterLevelAutoMode and " Auto" or " Manual"
201214 self .configTab :BuildModList ()
@@ -239,7 +252,7 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
239252 end
240253 end
241254 end
242- self .controls .classDrop = new (" DropDownControl" , {" LEFT" ,self .controls .characterLevel ," RIGHT" }, {5 , 0 , 85 , 20 }, nil , function (index , value )
255+ self .controls .classDrop = new (" DropDownControl" , {" LEFT" ,self .controls .characterLevel ," RIGHT" }, {10 , 0 , 85 , 20 }, nil , function (index , value )
243256 if value .classId ~= self .spec .curClassId then
244257 if self .spec :CountAllocNodes () == 0 or self .spec :IsClassConnected (value .classId ) then
245258 self .spec :SelectClass (value .classId )
@@ -263,7 +276,29 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
263276 end
264277 end
265278 end )
266- self .controls .buildLoadouts = new (" DropDownControl" , {" LEFT" ,self .controls .classDrop ," RIGHT" }, {5 , 0 , 190 , 20 }, {}, function (index , value )
279+ self .controls .ascendDrop = new (" DropDownControl" , {" LEFT" ,self .controls .classDrop ," RIGHT" }, {4 , 0 , 120 , 20 }, nil , function (index , value )
280+ self .spec :SelectAscendClass (value .ascendClassId )
281+ self .spec :AddUndoState ()
282+ self .spec :SetWindowTitleWithBuildClass ()
283+ self .buildFlag = true
284+ end )
285+ self .controls .secondaryAscendDrop = new (" DropDownControl" , {" LEFT" ,self .controls .ascendDrop ," RIGHT" }, {4 , 0 , 160 , 20 }, {
286+ { label = " None" , ascendClassId = 0 },
287+ }, function (index , value )
288+ if not value or not self .spec then
289+ return
290+ end
291+ self .spec :SelectSecondaryAscendClass (value .ascendClassId )
292+ self .spec :AddUndoState ()
293+ self .spec :SetWindowTitleWithBuildClass ()
294+ self .buildFlag = true
295+ end )
296+ self .controls .secondaryAscendDrop .enableDroppedWidth = true
297+ self .controls .secondaryAscendDrop .maxDroppedWidth = 360
298+ local initialSecondarySelection = (self .spec and self .spec .curSecondaryAscendClassId ) or 0
299+ self .controls .secondaryAscendDrop :SelByValue (initialSecondarySelection , " ascendClassId" )
300+
301+ self .controls .buildLoadouts = new (" DropDownControl" , {" LEFT" ,self .controls .secondaryAscendDrop ," RIGHT" }, {4 , 0 , 190 , 20 }, {}, function (index , value )
267302 if value == " ^7^7Loadouts:" or value == " ^7^7-----" then
268303 self .controls .buildLoadouts :SetSel (1 )
269304 return
@@ -378,15 +413,6 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
378413
379414 self .controls .buildLoadouts :SelByValue (value )
380415 end )
381-
382- -- self.controls.similarBuilds = new("ButtonControl", {"LEFT",self.controls.buildLoadouts,"RIGHT"}, {8, 0, 100, 20}, "Similar Builds", function()
383- -- self:OpenSimilarPopup()
384- -- end)
385- -- self.controls.similarBuilds.tooltipFunc = function(tooltip)
386- -- tooltip:Clear()
387- -- tooltip:AddLine(16, "Search for builds similar to your current character.")
388- -- tooltip:AddLine(16, "For best results, make sure to select your main item set, tree, and skills before opening the popup.")
389- -- end
390416
391417 if buildName == " ~~temp~~" then
392418 -- Remove temporary build file
@@ -401,7 +427,11 @@ function buildMode:Init(dbFileName, buildName, buildXML, convertBuild, importLin
401427 self .displayStats , self .minionDisplayStats , self .extraSaveStats = LoadModule (" Modules/BuildDisplayStats" )
402428
403429 -- Controls: Side bar
404- self .anchorSideBar = new (" Control" , nil , {4 , 36 , 0 , 0 })
430+ self .anchorSideBar = new (" Control" , nil , {4 , 60 , 0 , 0 })
431+ self .anchorSideBar .y = function ()
432+ return buildNameConditional () and 60 or 36
433+ end
434+
405435 self .controls .modeImport = new (" ButtonControl" , {" TOPLEFT" ,self .anchorSideBar ," TOPLEFT" }, {0 , 0 , 134 , 20 }, " Import/Export Build" , function ()
406436 self .viewMode = " IMPORT"
407437 end )
@@ -1044,6 +1074,53 @@ function buildMode:ResetModFlags()
10441074 self .calcsTab .modFlag = false
10451075end
10461076
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+
10471124function buildMode :OnFrame (inputEvents )
10481125 -- Stop at drawing the background if the loaded build needs to be converted
10491126 if not self .targetVersion then
@@ -1097,6 +1174,10 @@ function buildMode:OnFrame(inputEvents)
10971174 self :ProcessControlsInput (inputEvents , main .viewPort )
10981175
10991176 self .controls .classDrop :SelByValue (self .spec .curClassId , " classId" )
1177+ self .controls .ascendDrop .list = self .controls .classDrop :GetSelValueByKey (" ascendancies" )
1178+ self .controls .ascendDrop :SelByValue (self .spec .curAscendClassId , " ascendClassId" )
1179+ self .controls .ascendDrop :CheckDroppedWidth (true )
1180+ self :UpdateSecondaryAscendancyDropdown ()
11001181
11011182 if self .buildFlag then
11021183 -- Wipe Global Cache
0 commit comments