fix: InputSystem#getInputsForBindButton was throwing NPE
import org.terasology.engine.Time;
import org.terasology.engine.subsystem.DisplayDevice;
import org.terasology.engine.subsystem.config.BindsManager;
-import org.terasology.engine.subsystem.config.BindsSubsystem;
import org.terasology.entitySystem.entity.EntityRef;
import org.terasology.entitySystem.systems.BaseComponentSystem;
import org.terasology.entitySystem.systems.RegisterSystem;
@In
private CameraTargetSystem targetSystem;
- @In
- private BindsSubsystem bindsSubsystem;
-
private MouseDevice mouse = new NullMouseDevice();
private KeyboardDevice keyboard = new NullKeyboardDevice();
private ControllerDevice controllers = new NullControllerDevice();
@@ -477,7 +473,8 @@ private void sendCharEvent(char character, float delta) {
*/
private boolean sendMouseEvent(MouseInput button, boolean buttonDown, Vector2i jomlposition, float delta) {
MouseButtonEvent event;
- org.terasology.math.geom.Vector2i position = new org.terasology.math.geom.Vector2i(jomlposition.x, jomlposition.y);
+ org.terasology.math.geom.Vector2i position = new org.terasology.math.geom.Vector2i(jomlposition.x,
+ jomlposition.y);
switch (button) {
case NONE:
return false;
@@ -508,7 +505,8 @@ private boolean sendMouseEvent(MouseInput button, boolean buttonDown, Vector2i j
* @return True if the event has been consumed by an event listener, false otherwise.
*/
private boolean sendMouseWheelEvent(Vector2i pos, int wheelTurns, float delta) {
- MouseWheelEvent mouseWheelEvent = new MouseWheelEvent(new org.terasology.math.geom.Vector2i(pos.x, pos.y) , wheelTurns, delta);
+ MouseWheelEvent mouseWheelEvent = new MouseWheelEvent(new org.terasology.math.geom.Vector2i(pos.x, pos.y),
+ wheelTurns, delta);
return send(mouseWheelEvent);
}
@@ -554,13 +552,15 @@ public void drainQueues() {
}
/**
- * API-exposed caller to {@link BindsSubsystem#getInputsForBindButton(SimpleUri)}. TODO: Restored for API reasons,
- * may be duplicating code elsewhere. Should be reviewed.
+ * API-exposed caller to {@link BindsManager#getBindsConfig()} and
+ * {@link org.terasology.config.BindsConfig#getBinds(SimpleUri)}.
+ * <p>
+ * TODO: Restored for API reasons, may be duplicating code elsewhere. Should be reviewed.
*
* @param bindId the ID.
* @return a list of keyboard/mouse inputs that trigger the binding.
*/
public List<Input> getInputsForBindButton(SimpleUri bindId) {
- return bindsSubsystem.getInputsForBindButton(bindId);
+ return bindsManager.getBindsConfig().getBinds(bindId);
}
}
