Skip to content

Commit

Permalink
Fix cycling controls not playing a sound when activated using the key…
Browse files Browse the repository at this point in the history
…board

fixes #2309
  • Loading branch information
haykam821 authored and douira committed Nov 4, 2024
1 parent a3a5b84 commit 0ad3f83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (this.option.isEnabled() && button == 0 && this.isMouseOver(mouseX, mouseY)) {
cycleControl(Screen.hasShiftDown());
this.playClickSound();

return true;
}

Expand All @@ -89,7 +87,9 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
return false;
}

public void cycleControl(boolean reverse) {
private void cycleControl(boolean reverse) {
this.playClickSound();

var currentValue = this.option.getValidatedValue();
int startIndex = 0;
for (; startIndex < this.baseValues.length; startIndex++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (this.option.isEnabled() && button == 0 && this.isMouseOver(mouseX, mouseY)) {
toggleControl();
this.playClickSound();

return true;
}

Expand All @@ -94,15 +92,15 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {

if (CommonInputs.selected(keyCode)) {
toggleControl();
this.playClickSound();

return true;
}

return false;
}

public void toggleControl() {
private void toggleControl() {
this.playClickSound();

this.option.modifyValue(!this.option.getValidatedValue());
}
}
Expand Down

0 comments on commit 0ad3f83

Please sign in to comment.