mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-20 17:11:20 -08:00
Fix optional in the feeder and bring back none option in the gui (#194)
This commit is contained in:
1 parent
c02b95346f
commit
0afe9d2ef8
3 files changed
+15
-9
No files matched your search
@@ -181,22 +181,28 @@ public class TrackersList extends EJBoxNoStretch {
|
||||
desSelect = new JComboBox<>(),
|
||||
s(c(0, row, 2, GridBagConstraints.FIRST_LINE_START), 2, 1)
|
||||
);
|
||||
desSelect.addItem("NONE");
|
||||
for (TrackerPosition p : TrackerPosition.values) {
|
||||
desSelect.addItem(p.name());
|
||||
}
|
||||
if (cfg.designation != null) {
|
||||
TrackerPosition
|
||||
.getByDesignation(cfg.designation)
|
||||
.ifPresent(
|
||||
trackerPosition -> desSelect.setSelectedItem(trackerPosition.name())
|
||||
.ifPresentOrElse(
|
||||
trackerPosition -> desSelect.setSelectedItem(trackerPosition.name()),
|
||||
() -> desSelect.setSelectedItem("NONE")
|
||||
);
|
||||
}
|
||||
desSelect.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
TrackerPosition p = TrackerPosition
|
||||
.valueOf(String.valueOf(desSelect.getSelectedItem()));
|
||||
t.setBodyPosition(p);
|
||||
if (desSelect.getSelectedItem() == "NONE") {
|
||||
t.setBodyPosition(null);
|
||||
} else {
|
||||
TrackerPosition p = TrackerPosition
|
||||
.valueOf(String.valueOf(desSelect.getSelectedItem()));
|
||||
t.setBodyPosition(p);
|
||||
}
|
||||
server.trackerUpdated(t);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -114,7 +114,7 @@ public class WindowsNamedPipeBridge extends ProtobufBridge<VRTracker> implements
|
||||
);
|
||||
TrackerRole role = TrackerRole.getById(trackerAdded.getTrackerRole());
|
||||
if (role != null) {
|
||||
TrackerPosition.getByTrackerRole(role).ifPresent(tracker::setBodyPosition);
|
||||
tracker.setBodyPosition(TrackerPosition.getByTrackerRole(role).orElse(null));
|
||||
}
|
||||
return tracker;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package dev.slimevr.vr.trackers;
|
||||
|
||||
import solarxr_protocol.datatypes.BodyPart;
|
||||
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
@@ -7,8 +9,6 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import solarxr_protocol.datatypes.BodyPart;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a position on the body that a tracker could be placed. Any bone is
|
||||
@@ -135,7 +135,7 @@ public enum TrackerPosition {
|
||||
}
|
||||
|
||||
public static Optional<TrackerPosition> getByBodyPart(int bodyPart) {
|
||||
if (bodyPart < 0 || bodyPart >= TrackerPosition.byBodyPart.length) {
|
||||
if (bodyPart <= 0 || bodyPart >= TrackerPosition.byBodyPart.length) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(TrackerPosition.byBodyPart[bodyPart]);
|
||||
|
||||
Reference in new issue
Block a user