Apply graphics conf changes with F on kb or X/Start on cont (#11)

This commit is contained in:
thecozies 2024-04-30 09:29:02 -05:00 committed by GitHub
parent 8a70b2313e
commit d555f0c65b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 3 deletions

View File

@ -311,7 +311,7 @@
id="apply_button"
style="nav-up:#hr_original"
>
<div class="button__label">Apply</div>
<div class="button__label">Apply <span class="prompt-font-sm">{{gfx_help__apply}}</span></div>
</button>
</div>
</div>

View File

@ -186,6 +186,7 @@ void recomp::set_cont_or_kb(bool cont_interacted) {
cont_active = cont_interacted;
nav_help_model_handle.DirtyVariable("nav_help__navigate");
nav_help_model_handle.DirtyVariable("nav_help__accept");
graphics_model_handle.DirtyVariable("gfx_help__apply");
nav_help_model_handle.DirtyVariable("nav_help__exit");
}
}
@ -439,8 +440,15 @@ public:
recomp::register_event(listener, "config_keydown",
[](const std::string& param, Rml::Event& event) {
if (!prompt_context.open && event.GetId() == Rml::EventId::Keydown) {
if (event.GetParameter<Rml::Input::KeyIdentifier>("key_identifier", Rml::Input::KeyIdentifier::KI_UNKNOWN) == Rml::Input::KeyIdentifier::KI_ESCAPE) {
close_config_menu();
auto key = event.GetParameter<Rml::Input::KeyIdentifier>("key_identifier", Rml::Input::KeyIdentifier::KI_UNKNOWN);
switch (key) {
case Rml::Input::KeyIdentifier::KI_ESCAPE:
close_config_menu();
break;
case Rml::Input::KeyIdentifier::KI_F:
graphics_model_handle.DirtyVariable("options_changed");
apply_graphics_config();
break;
}
}
});
@ -596,6 +604,14 @@ public:
}
out = "";
});
constructor.BindFunc("gfx_help__apply", [](Rml::Variant& out) {
if (cont_active) {
out = PF_GAMEPAD_X " " PF_GAMEPAD_START;
} else {
out = PF_KEYBOARD_F;
}
});
constructor.Bind("msaa2x_supported", &msaa2x_supported);
constructor.Bind("msaa4x_supported", &msaa4x_supported);

View File

@ -1150,6 +1150,9 @@ int cont_button_to_key(SDL_ControllerButtonEvent& button) {
return SDLK_RIGHT;
case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_A:
return SDLK_RETURN;
case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_X:
case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_START:
return SDLK_f;
// Allows closing the menu
case SDL_GameControllerButton::SDL_CONTROLLER_BUTTON_BACK:
return SDLK_ESCAPE;