@@ -177,16 +177,20 @@ class _Option extends StatefulWidget {
177177
178178 final String title;
179179 final List <SettingsBodyBase > descriptionList;
180+ final bool controlsMultipleOptions;
180181 final Widget ? subtitle;
181182 final Widget ? button;
182183 final bool shouldPadBottom;
184+ final bool enabled;
183185
184186 const _Option ({
185187 required this .title,
186188 required this .descriptionList,
189+ required this .controlsMultipleOptions,
187190 this .subtitle,
188191 this .button,
189192 this .shouldPadBottom = false ,
193+ this .enabled = true ,
190194 });
191195
192196 @override
@@ -201,7 +205,7 @@ class _OptionState extends State<_Option> {
201205 @override
202206 Widget build (BuildContext context) {
203207 hoverColour ?? = Theme .of (context).hoverColor;
204- return MouseRegion (
208+ final child = MouseRegion (
205209 onEnter: (_) => setState (() => hovered = true ),
206210 onExit: (_) => setState (() => hovered = false ),
207211 child: ListTile (
@@ -210,6 +214,7 @@ class _OptionState extends State<_Option> {
210214 widget.title,
211215 padding: _Option ._settingHeadingPadding,
212216 widget.descriptionList,
217+ strikeThroughTitle: ! widget.enabled,
213218 ),
214219 subtitle: widget.shouldPadBottom
215220 ? Padding (
@@ -221,6 +226,19 @@ class _OptionState extends State<_Option> {
221226 tileColor: hovered ? hoverColour : null ,
222227 ),
223228 );
229+
230+ return widget.enabled
231+ ? child
232+ : Tooltip (
233+ message: widget.controlsMultipleOptions
234+ ? """
235+ Config file does not contain (some of) these options! It is probably too old.
236+ Buttons will be disabled until the config file contains all the options."""
237+ : """
238+ Config file does not contain this option! It is probably too old.
239+ Button will be disabled until the config file contains the option.""" ,
240+ child: child,
241+ );
224242 }
225243}
226244
@@ -266,6 +284,7 @@ class IntSliderOption extends StatelessWidget {
266284 return _Option (
267285 title: title,
268286 descriptionList: descriptionList,
287+ controlsMultipleOptions: false ,
269288 subtitle: Column (
270289 children: [
271290 Row (
@@ -336,46 +355,37 @@ class DoubleSliderOption extends StatelessWidget {
336355
337356 @override
338357 Widget build (BuildContext context) {
339- final child = SliderTheme (
340- data: const SliderThemeData (showValueIndicator: ShowValueIndicator .onDrag),
341- child: _Option (
342- title: title,
343- descriptionList: descriptionList,
344- subtitle: Column (
345- children: [
346- Row (
347- children: [
348- if (value != null )
349- Text (
350- value! .toStringAsFixed (2 ),
351- style: pixelCode200,
352- ),
353- Expanded (
354- child: Slider (
355- value: value ?? max,
356- label: value? .toStringAsFixed (2 ) ?? "" ,
357- min: min,
358- max: math.max (value ?? max, max),
359- onChanged: value == null || value! > max ? null : onChanged,
360- onChangeEnd: onChangeEnd,
361- activeColor: sliderColor,
362- ),
358+ return _Option (
359+ title: title,
360+ descriptionList: descriptionList,
361+ controlsMultipleOptions: false ,
362+ enabled: value != null ,
363+ subtitle: Column (
364+ children: [
365+ Row (
366+ children: [
367+ if (value != null )
368+ Text (
369+ value! .toStringAsFixed (2 ),
370+ style: pixelCode200,
363371 ),
364- ],
365- ),
366- ? warning,
367- ],
368- ),
372+ Expanded (
373+ child: Slider (
374+ value: value ?? max,
375+ label: value? .toStringAsFixed (2 ) ?? "" ,
376+ min: min,
377+ max: math.max (value ?? max, max),
378+ onChanged: value == null || value! > max ? null : onChanged,
379+ onChangeEnd: onChangeEnd,
380+ activeColor: sliderColor,
381+ ),
382+ ),
383+ ],
384+ ),
385+ ? warning,
386+ ],
369387 ),
370388 );
371- return value == null
372- ? Tooltip (
373- message: """
374- Config file does not contain this option! It is probably too old.
375- Button will be disabled until the config file contains the option.""" ,
376- child: child,
377- )
378- : child;
379389 }
380390}
381391
@@ -424,6 +434,7 @@ class TextFieldOption extends StatelessWidget {
424434 return _Option (
425435 title: title,
426436 descriptionList: descriptionList,
437+ controlsMultipleOptions: false ,
427438 subtitle: TextFormField (
428439 controller: controller,
429440 decoration: InputDecoration (
@@ -497,9 +508,11 @@ class Vector2XZOption extends StatelessWidget {
497508 return oldValue;
498509 });
499510
500- final child = _Option (
511+ return _Option (
501512 title: title,
502513 descriptionList: descriptionList,
514+ controlsMultipleOptions: true ,
515+ enabled: controllerX != null && controllerZ != null ,
503516 subtitle: Row (
504517 children: [
505518 Flexible (
@@ -537,15 +550,6 @@ class Vector2XZOption extends StatelessWidget {
537550 ),
538551 shouldPadBottom: true ,
539552 );
540-
541- return controllerX != null && controllerZ != null
542- ? child
543- : Tooltip (
544- message: """
545- Config file does not contain (some of) these options! It is probably too old.
546- Buttons will be disabled until the config file contains all the options.""" ,
547- child: child,
548- );
549553 }
550554}
551555
@@ -573,30 +577,22 @@ class ToggleOption extends StatelessWidget {
573577
574578 @override
575579 Widget build (BuildContext context) {
576- final child = CheckboxListTile (
577- title: SettingHeading (
578- context,
579- title,
580- padding: _Option ._settingHeadingPadding,
581- descriptionList,
580+ final enabled = value != null ;
581+ return _Option (
582+ title: title,
583+ descriptionList: descriptionList,
584+ controlsMultipleOptions: false ,
585+ enabled: enabled,
586+ button: Checkbox (
587+ value: value,
588+ onChanged: (bool ? value) {
589+ if (value == null ) return ;
590+ onChanged (value);
591+ },
592+ tristate: ! enabled,
593+ fillColor: ! enabled ? .all (Colors .grey) : null ,
582594 ),
583- value: value,
584- onChanged: (bool ? value) {
585- if (value == null ) return ;
586- onChanged (value);
587- },
588- tristate: value == null ,
589- enabled: value != null ,
590- fillColor: value == null ? .all (Colors .grey) : null ,
591595 );
592- return value == null
593- ? Tooltip (
594- message: """
595- Config file does not contain this option! It is probably too old.
596- Button will be disabled until the config file contains the option.""" ,
597- child: child,
598- )
599- : child;
600596 }
601597}
602598
@@ -631,6 +627,7 @@ class ColourOption extends StatelessWidget {
631627 return _Option (
632628 title: title,
633629 descriptionList: descriptionList,
630+ controlsMultipleOptions: false ,
634631 button: ElevatedButton .icon (
635632 style: ElevatedButton .styleFrom (backgroundColor: colour),
636633 icon: Icon (Icons .color_lens, color: textColour),
@@ -778,13 +775,15 @@ class BoolListOption extends StatelessWidget {
778775
779776 @override
780777 Widget build (BuildContext context) {
778+ final bool enabled = ! options.any ((option) => option.enabled == null );
781779 return _Option (
782780 title: title,
783781 descriptionList: descriptionList,
782+ controlsMultipleOptions: true ,
783+ enabled: enabled,
784784 subtitle: LayoutBuilder (
785785 builder: (context, constraints) {
786- final bool enabled = ! options.any ((option) => option.enabled == null );
787- final child = ToggleButtons (
786+ return ToggleButtons (
788787 borderRadius: const BorderRadius .all (Radius .circular (8 )),
789788 direction: constraints.maxWidth < breakpoint ? .vertical : .horizontal,
790789 onPressed: enabled
@@ -808,15 +807,6 @@ class BoolListOption extends StatelessWidget {
808807 })
809808 .toList (growable: false ),
810809 );
811-
812- return enabled
813- ? child
814- : Tooltip (
815- message: """
816- Config file does not contain (some of) these options! It is probably too old.
817- Buttons will be disabled until the config file contains all the options.""" ,
818- child: child,
819- );
820810 },
821811 ),
822812 shouldPadBottom: true ,
0 commit comments