fix menu slider sounds

This commit is contained in:
hackgrid 2023-11-12 17:44:26 +01:00 committed by GitHub
parent 47ac5c663f
commit 3c2f6fe4e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -60,7 +60,7 @@ enum MenuDirection checkboxMenuItemUpdate(struct MenuBuilderElement* element, Me
action.type = MenuElementTypeCheckbox;
action.state.checkbox.isChecked = checkbox->checked;
actionCallback(data, element->selectionIndex, &action);
soundPlayerPlay(SOUNDS_BUTTONCLICKRELEASE, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
soundPlayerPlay(SOUNDS_BUTTONCLICKRELEASE, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
}
return MenuDirectionStay;
@ -113,10 +113,9 @@ void sliderMenuItemInit(struct MenuBuilderElement* element) {
enum MenuDirection sliderMenuItemUpdate(struct MenuBuilderElement* element, MenuActionCalback actionCallback, void* data) {
struct MenuSlider* slider = (struct MenuSlider*)element->data;
int controllerDir = controllerGetDirectionDown(0);
if (element->params->params.slider.discrete) {
int controllerDir = controllerGetDirectionDown(0);
int numTicks = element->params->params.slider.numberOfTicks;
int currentValue = (int)floorf(slider->value * (numTicks - 1));
int newValue = currentValue;
@ -196,6 +195,9 @@ enum MenuDirection sliderMenuItemUpdate(struct MenuBuilderElement* element, Menu
slider->value = newValue;
}
}
if (controllerGetButtonDown(0, L_JPAD | R_JPAD | A_BUTTON) || (element->params->params.slider.discrete && ((controllerDir & ControllerDirectionLeft) || (controllerDir & ControllerDirectionRight))))
soundPlayerPlay(SOUNDS_BUTTONCLICKRELEASE, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
return MenuDirectionStay;
}
@ -334,4 +336,4 @@ void menuBuilderSetISlider(struct MenuBuilderElement* element, int value) {
struct MenuSlider* slider = (struct MenuSlider*)element->data;
slider->value = (float)value / (float)(element->params->params.slider.numberOfTicks - 1);
}
}