added back button sounds because SOMEONE fucked it up.....

This commit is contained in:
michiel
2025-12-02 11:51:00 +01:00
parent 9f55f8e1c7
commit 4dbc4997a0
2 changed files with 33 additions and 12 deletions

View File

@@ -1,6 +1,8 @@
package org.toop.app.widget; package org.toop.app.widget;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import org.toop.framework.audio.events.AudioEvents;
import org.toop.framework.eventbus.EventFlow;
import org.toop.framework.resource.resources.ImageAsset; import org.toop.framework.resource.resources.ImageAsset;
import org.toop.local.AppContext; import org.toop.local.AppContext;
@@ -73,8 +75,11 @@ public final class Primitive {
} }
if (onAction != null) { if (onAction != null) {
button.setOnAction(_ -> button.setOnAction(_ -> {
onAction.run()); onAction.run();
playButtonSound();
System.out.println("HI I got called button");
});
} }
return button; return button;
@@ -115,12 +120,18 @@ public final class Primitive {
slider.setMax(max); slider.setMax(max);
slider.setValue(value); slider.setValue(value);
if (onValueChanged != null) { if (onValueChanged != null) {
slider.valueProperty().addListener((_, _, newValue) -> slider.valueProperty().addListener((_, _, newValue) -> {
onValueChanged.accept(newValue.intValue())); onValueChanged.accept(newValue.intValue());
} });
}
return slider; slider.setOnMouseReleased(event -> {
playButtonSound();
System.out.println("I got called!");
});
return slider;
} }
@SafeVarargs @SafeVarargs
@@ -137,9 +148,12 @@ public final class Primitive {
} }
if (onValueChanged != null) { if (onValueChanged != null) {
choice.valueProperty().addListener((_, _, newValue) -> choice.valueProperty().addListener((_, _, newValue) -> {
onValueChanged.accept(newValue)); onValueChanged.accept(newValue);
} playButtonSound();
System.out.println("hi i got called choice");
});
}
choice.setItems(FXCollections.observableArrayList(items)); choice.setItems(FXCollections.observableArrayList(items));
@@ -191,4 +205,8 @@ public final class Primitive {
return vbox; return vbox;
} }
private static void playButtonSound() {
new EventFlow().addPostEvent(new AudioEvents.ClickButton()).postEvent();
}
} }

View File

@@ -2,6 +2,8 @@ package org.toop.app.widget.complex;
import org.toop.app.widget.Primitive; import org.toop.app.widget.Primitive;
import org.toop.app.widget.Widget; import org.toop.app.widget.Widget;
import org.toop.framework.audio.events.AudioEvents;
import org.toop.framework.eventbus.EventFlow;
import org.toop.local.AppContext; import org.toop.local.AppContext;
import java.util.function.Consumer; import java.util.function.Consumer;
@@ -29,8 +31,9 @@ public class ToggleWidget implements Widget {
state = !state; state = !state;
updateText(); updateText();
if (onToggle != null) { if (onToggle != null) {
onToggle.accept(state); onToggle.accept(state);
} new EventFlow().addPostEvent(new AudioEvents.ClickButton()).postEvent(); // TODO FIX PRIMITIVES
}
}); });
container = Primitive.vbox(button); container = Primitive.vbox(button);