@@ -2,12 +2,12 @@ import { ModOptionsOptionConstructor, ModOptionsOptionElement, optGet, optSet }
22
33declare global {
44 namespace modmanager . gui . Options {
5- interface OBJECT_SLIDER extends sc . OPTION_GUIS_DEFS . OBJECT_SLIDER , ModOptionsOptionElement {
5+ interface OBJECT_SLIDER extends sc . OPTION_GUIS_DEFS . OBJECT_SLIDER , ModOptionsOptionElement < 'OBJECT_SLIDER' > {
66 currentNumber : sc . TextGui
77 }
88 interface OBJECT_SLIDER_CONSTRUCTOR
99 extends ImpactClass < OBJECT_SLIDER > ,
10- ModOptionsOptionConstructor < OBJECT_SLIDER > { }
10+ ModOptionsOptionConstructor < OBJECT_SLIDER , 'OBJECT_SLIDER' > { }
1111 var OBJECT_SLIDER : OBJECT_SLIDER_CONSTRUCTOR
1212 }
1313}
@@ -18,33 +18,33 @@ modmanager.gui.Options.OBJECT_SLIDER = ig.GuiElementBase.extend({
1818 this . parent ( )
1919
2020 this . base = optionRow
21+ this . guiOption = optionRow . guiOption
2122
22- const option = ( optionRow as modmanager . gui . OptionsOptionRow ) . guiOption
23- this . guiOption = option
24- if ( option . type != 'OBJECT_SLIDER' ) throw new Error ( 'what' )
23+ const snap = this . guiOption . snap ?? true
2524
26- const snap = option . snap ?? true
27-
28- const data = option . data
25+ const data = this . guiOption . data
2926 this . entries = Object . values ( data ! )
3027 width -= 4
31- this . showPercentage = option . showPercentage
28+ this . showPercentage = this . guiOption . showPercentage
3229
33- this . slider = new sc . OptionFocusSlider ( this . onChange . bind ( this ) , snap , option . fill , rowGroup )
30+ this . slider = new sc . OptionFocusSlider ( this . onChange . bind ( this ) , snap , this . guiOption . fill , rowGroup )
3431
35- this . slider . setPreferredThumbSize ( Math . max ( 30 , option . thumbWidth ?? Math . floor ( 252 / this . entries . length ) ) , 21 )
32+ this . slider . setPreferredThumbSize (
33+ Math . max ( 30 , this . guiOption . thumbWidth ?? Math . floor ( 252 / this . entries . length ) ) ,
34+ 21
35+ )
3636
3737 this . slider . setPos ( 0 , 0 )
3838 this . slider . setMinMaxValue ( 0 , this . entries . length - 1 )
3939 this . slider . setSize ( width - 4 , 21 , 9 )
40- this . slider . data = option . description
40+ this . slider . data = this . guiOption . description
4141 this . addChildGui ( this . slider )
4242 this . currentNumber = new sc . TextGui ( '' )
4343 this . currentNumber . setAlign ( ig . GUI_ALIGN . X_CENTER , ig . GUI_ALIGN . Y_CENTER )
4444 this . slider . thumb . addChildGui ( this . currentNumber )
4545 rowGroup . addFocusGui ( this . slider , 0 , this . base . row )
4646
47- const value = optGet ( option ) as number
47+ const value = optGet ( this . guiOption ) as number
4848 let index = this . entries . findIndex ( v => v == value )
4949 if ( index == - 1 ) index = 0
5050 this . slider . setValue ( index )
@@ -54,8 +54,6 @@ modmanager.gui.Options.OBJECT_SLIDER = ig.GuiElementBase.extend({
5454 return { has : true }
5555 } ,
5656 updateNumberDisplay ( ) {
57- if ( this . guiOption . type != 'OBJECT_SLIDER' ) throw new Error ( 'what' )
58-
5957 const func = this . guiOption . customNumberDisplay
6058 if ( func ) {
6159 let ret = func . call ( this . guiOption , this . _lastVal )
0 commit comments