@@ -2780,8 +2780,13 @@ function ItemsTabClass:CorruptDisplayItem(modType)
27802780 end
27812781 end
27822782 end
2783- for i , modLine in ipairs (item .explicitModLines ) do
2784- modLine .corruptedRange = (not addingImplicits and corruptedRanges [i ] ~= 1 ) and corruptedRanges [i ] or 1
2783+ if not addingImplicits then
2784+ for i , modLine in ipairs (item .explicitModLines ) do
2785+ local corruptedRange = corruptedRanges [i ]
2786+ if corruptedRange then
2787+ modLine .corruptedRange = corruptedRange ~= 1 and corruptedRange or nil
2788+ end
2789+ end
27852790 end
27862791 item :BuildAndParseRaw ()
27872792 return item
@@ -2800,37 +2805,26 @@ function ItemsTabClass:CorruptDisplayItem(modType)
28002805 selectedVariant = true
28012806 end
28022807 end
2803- -- test if a mod is scalable at all. this will let through mods that scale, but don't actually change within the corrupt range
2804- local testScaledLine = itemLib .applyRange (mod .line , mod .range or main .defaultItemAffixQuality , mod .valueScalar or 1 , 2 )
2805- if not (testScaledLine == mod .line ) and (# variantIds > 0 and selectedVariant or # variantIds == 0 ) then
2806- local label = " "
2808+ local modRange = mod .range or main .defaultItemAffixQuality
2809+ if itemLib .isModLineScalable (mod .line , modRange , mod .valueScalar ) and (# variantIds == 0 or selectedVariant ) then
2810+ local function formatLabel (corruptedRange )
2811+ local line = itemLib .applyRange (mod .line , modRange , mod .valueScalar or 1 , corruptedRange )
2812+ local lines = main :WrapString (" ^7" .. line , 16 , 430 )
2813+ return table.concat (lines , " \n " ), # lines
2814+ end
28072815 controls [" rollRangeValue" .. i ] = new (" LabelControl" , { " TOPLEFT" , nil , " TOPLEFT" },
28082816 { 10 , 10 + offset , 200 , 16 }, " ^71.00" )
28092817 controls [" rollRangeSlider" .. i ] = new (" SliderControl" ,
28102818 { " LEFT" , controls [" rollRangeValue" .. i ], " RIGHT" }, { 5 , 0 , 80 , 18 }, function (val )
28112819 corruptedRanges [i ] = 0.78 + round (0.44 * val , 2 ) -- 0.78-1.22
28122820 controls [" rollRangeValue" .. i ].label = " ^7" .. string.format (" %.2f" , corruptedRanges [i ])
2813- local label = " "
2814- for i , line in ipairs (main :WrapString (" ^7" .. itemLib .applyRange (mod .line , mod .range or main .defaultItemAffixQuality , mod .valueScalar or 1 , corruptedRanges [i ]), 16 , 430 )) do
2815- if i == 1 then
2816- label = line
2817- else
2818- label = label .. " \n " .. line
2819- end
2820- end
2821- controls [" rollRangeLabel" .. i ].label = label
2821+ controls [" rollRangeLabel" .. i ].label = formatLabel (corruptedRanges [i ])
28222822 end )
28232823 corruptedRanges [i ] = mod .corruptedRange or 1
28242824 controls [" rollRangeSlider" .. i ].val = ((corruptedRanges [i ]) - 0.78 ) / 0.44
28252825 controls [" rollRangeValue" .. i ].label = " ^7" .. string.format (" %.2f" , corruptedRanges [i ])
2826- for i , line in ipairs (main :WrapString (" ^7" .. itemLib .applyRange (mod .line , mod .range or main .defaultItemAffixQuality , mod .valueScalar or 1 , corruptedRanges [i ]), 16 , 430 )) do
2827- if i == 1 then
2828- label = line
2829- else
2830- offset = offset + 16
2831- label = label .. " \n " .. line
2832- end
2833- end
2826+ local label , lineCount = formatLabel (corruptedRanges [i ])
2827+ offset = offset + 16 * (lineCount - 1 )
28342828 controls [" rollRangeLabel" .. i ] = new (" LabelControl" ,
28352829 { " LEFT" , controls [" rollRangeSlider" .. i ], " RIGHT" },
28362830 { 5 , 0 , 200 , 16 }, label )
@@ -2844,13 +2838,19 @@ function ItemsTabClass:CorruptDisplayItem(modType)
28442838 end
28452839 explicitOffset = offset
28462840 end
2841+ local function setImplicitControlsShown (implicitNum , canChangeImplicits )
2842+ for i = 1 , 4 do
2843+ local shown = canChangeImplicits and i <= implicitNum
2844+ controls [" implicit" .. i ].shown = shown
2845+ controls [" implicit" .. i .. " Label" ].shown = shown
2846+ end
2847+ controls .implicitCannotBeChangedLabel .shown = implicitNum > 0 and not canChangeImplicits
2848+ end
28472849 controls .implicits = new (" ButtonControl" , { " TOPLEFT" , nil , " TOPLEFT" }, { 5 , 5 , 80 , 20 }, " Implicits" ,
28482850 function ()
28492851 local implicitNum = currentModType == " Corrupted" and 2 or 4
2850- for i = 1 , implicitNum do
2851- controls [" implicit" .. i ].shown = true
2852- controls [" implicit" .. i .. " Label" ].shown = true
2853- end
2852+ local canChangeImplicits = currentModType ~= " Corrupted" or not self .displayItem .implicitsCannotBeChanged
2853+ setImplicitControlsShown (implicitNum , canChangeImplicits )
28542854 for _ , i in ipairs (shownExplicits ) do
28552855 controls [" rollRangeLabel" .. i ].shown = false
28562856 controls [" rollRangeSlider" .. i ].shown = false
@@ -2868,10 +2868,7 @@ function ItemsTabClass:CorruptDisplayItem(modType)
28682868 controls .rolls = new (" ButtonControl" , { " LEFT" , controls .implicits , " RIGHT" }, { 5 , 0 , 80 , 20 },
28692869 " Roll Ranges" ,
28702870 function ()
2871- for i = 1 , 4 do
2872- controls [" implicit" .. i ].shown = false
2873- controls [" implicit" .. i .. " Label" ].shown = false
2874- end
2871+ setImplicitControlsShown (0 , false )
28752872 for _ , i in ipairs (shownExplicits ) do
28762873 controls [" rollRangeLabel" .. i ].shown = true
28772874 controls [" rollRangeSlider" .. i ].shown = true
@@ -2894,32 +2891,14 @@ function ItemsTabClass:CorruptDisplayItem(modType)
28942891 currentModType = " ScourgeUpside"
28952892 buildImplicitList (" ScourgeUpside" )
28962893 buildImplicitList (" ScourgeDownside" )
2897- controls .implicit1 .shown = true
2898- controls .implicit1Label .shown = true
2899- controls .implicit2 .shown = true
2900- controls .implicit2Label .shown = true
2901- controls .implicit3 .shown = true
2902- controls .implicit3Label .shown = true
2903- controls .implicitCannotBeChangedLabel .shown = false
2904- main .popups [1 ].height = 103 + 20 * 3
2905- if self .displayItem .rarity == " UNIQUE" or self .displayItem .rarity == " RELIC" then
2906- controls .implicit4Label .shown = true
2907- controls .implicit4 .shown = true
2908- main .popups [1 ].height = 103 + 20 * 4
2909- end
2894+ local implicitNum = (self .displayItem .rarity == " UNIQUE" or self .displayItem .rarity == " RELIC" ) and 4 or 3
2895+ setImplicitControlsShown (implicitNum , true )
2896+ main .popups [1 ].height = 103 + 20 * implicitNum
29102897 buildList (controls .implicit3 , controls .implicit4 , " ScourgeDownside" )
29112898 buildList (controls .implicit4 , controls .implicit3 , " ScourgeDownside" )
29122899 else
29132900 currentModType = value
2914- controls .implicit1 .shown = not self .displayItem .implicitsCannotBeChanged
2915- controls .implicit1Label .shown = not self .displayItem .implicitsCannotBeChanged
2916- controls .implicit2 .shown = not self .displayItem .implicitsCannotBeChanged
2917- controls .implicit2Label .shown = not self .displayItem .implicitsCannotBeChanged
2918- controls .implicit3Label .shown = false
2919- controls .implicit3 .shown = false
2920- controls .implicit4Label .shown = false
2921- controls .implicit4 .shown = false
2922- controls .implicitCannotBeChangedLabel .shown = self .displayItem .implicitsCannotBeChanged
2901+ setImplicitControlsShown (2 , not self .displayItem .implicitsCannotBeChanged )
29232902 main .popups [1 ].height = 103 + 20 * 2
29242903 end
29252904 if controls .sort then
0 commit comments