disable ds options conditionally

This commit is contained in:
thecozies 2024-03-30 10:36:23 -05:00
parent 1caf81e1cf
commit 7648753fe7
4 changed files with 41 additions and 14 deletions

View File

@ -21,9 +21,9 @@
<div class="config-option__list"> <div class="config-option__list">
<input type="radio" name="downsampling" data-checked="ds_option" value="1" id="ds_windowed" style="nav-up:#tab_graphics"/> <input type="radio" name="downsampling" data-checked="ds_option" value="1" id="ds_windowed" style="nav-up:#tab_graphics"/>
<label class="config-option__tab-label" for="ds_windowed">Off</label> <label class="config-option__tab-label" for="ds_windowed">Off</label>
<input type="radio" name="downsampling" data-checked="ds_option" value="2" id="ds_2x" style="nav-up:#tab_graphics"/> <input type="radio" name="downsampling" data-attrif-disabled="res_option == 'Auto'" data-checked="ds_option" value="2" id="ds_2x" style="nav-up:#tab_graphics"/>
<label class="config-option__tab-label" for="ds_2x">2x</label> <label class="config-option__tab-label" for="ds_2x">2x</label>
<input type="radio" name="downsampling" data-checked="ds_option" value="4" id="ds_4x" style="nav-right:none;nav-up:#tab_graphics"/> <input type="radio" name="downsampling" data-attrif-disabled="res_option == 'Auto'" data-checked="ds_option" value="4" id="ds_4x" style="nav-right:none;nav-up:#tab_graphics"/>
<label class="config-option__tab-label" for="ds_4x">4x</label> <label class="config-option__tab-label" for="ds_4x">4x</label>
</div> </div>
<div class="config-option__details">{{ds_info}}</div> <div class="config-option__details">{{ds_info}}</div>

File diff suppressed because one or more lines are too long

View File

@ -103,10 +103,12 @@
input.radio { input.radio {
@extend %nav-all; @extend %nav-all;
@include trans-colors-opa;
visibility: visible; visibility: visible;
width: 0; width: 0;
height: 0; height: 0;
&:not(:disabled) {
&:checked + .config-option__tab-label { &:checked + .config-option__tab-label {
border-bottom: 1dp; border-bottom: 1dp;
border-color: $color-border-hard; border-color: $color-border-hard;
@ -122,6 +124,15 @@
} }
} }
&:disabled + .config-option__tab-label {
opacity: 0.5;
&:hover {
cursor: default;
}
}
}
input.range slidertrack { input.range slidertrack {
@include trans-colors; @include trans-colors;
margin-top: 7dp; margin-top: 7dp;

View File

@ -45,7 +45,11 @@ template <typename T>
void bind_option(Rml::DataModelConstructor& constructor, const std::string& name, T* option) { void bind_option(Rml::DataModelConstructor& constructor, const std::string& name, T* option) {
constructor.BindFunc(name, constructor.BindFunc(name,
[option](Rml::Variant& out) { get_option(*option, out); }, [option](Rml::Variant& out) { get_option(*option, out); },
[option](const Rml::Variant& in) { set_option(*option, in); graphics_model_handle.DirtyVariable("options_changed"); graphics_model_handle.DirtyVariable("ds_info"); } [option](const Rml::Variant& in) {
set_option(*option, in);
graphics_model_handle.DirtyVariable("options_changed");
graphics_model_handle.DirtyVariable("ds_info");
}
); );
}; };
@ -293,7 +297,15 @@ public:
} }
new_options = ultramodern::get_graphics_config(); new_options = ultramodern::get_graphics_config();
bind_option(constructor, "res_option", &new_options.res_option); constructor.BindFunc("res_option",
[](Rml::Variant& out) { get_option(new_options.res_option, out); },
[](const Rml::Variant& in) {
set_option(new_options.res_option, in);
graphics_model_handle.DirtyVariable("options_changed");
graphics_model_handle.DirtyVariable("ds_info");
graphics_model_handle.DirtyVariable("ds_option");
}
);
bind_option(constructor, "wm_option", &new_options.wm_option); bind_option(constructor, "wm_option", &new_options.wm_option);
bind_option(constructor, "ar_option", &new_options.ar_option); bind_option(constructor, "ar_option", &new_options.ar_option);
bind_option(constructor, "msaa_option", &new_options.msaa_option); bind_option(constructor, "msaa_option", &new_options.msaa_option);
@ -308,7 +320,11 @@ public:
}); });
constructor.BindFunc("ds_option", constructor.BindFunc("ds_option",
[](Rml::Variant& out) { [](Rml::Variant& out) {
if (new_options.res_option == ultramodern::Resolution::Auto) {
out = 1;
} else {
out = new_options.ds_option; out = new_options.ds_option;
}
}, },
[](const Rml::Variant& in) { [](const Rml::Variant& in) {
new_options.ds_option = in.Get<int>(); new_options.ds_option = in.Get<int>();