Added mainLayout null checks and simplified setPrimaryBind
@@ -126,6 +126,7 @@ public void initialise() {
UICheckbox mouseInverted = new UICheckbox("mouseYAxisInverted");
mouseInverted.bindChecked(BindHelper.bindBeanProperty("mouseYAxisInverted", inputDeviceConfiguration, Boolean.TYPE));
+ if (mainLayout != null) {
mainLayout.addWidget(new UILabel("mouseLabel", "subheading", translationSystem.translate("${engine:menu#category-mouse}")));
mainLayout.addWidget(new RowLayout(new UILabel(translationSystem.translate("${engine:menu#mouse-sensitivity}") + ":"), mouseSensitivity)
.setColumnRatios(0.4f)
@@ -133,6 +134,7 @@ public void initialise() {
mainLayout.addWidget(new RowLayout(new UILabel(translationSystem.translate("${engine:menu#invert-mouse}") + ":"), mouseInverted)
.setColumnRatios(0.4f)
.setHorizontalSpacing(horizontalSpacing));
+ }
Map<String, InputCategory> inputCategories = Maps.newHashMap();
Map<SimpleUri, RegisterBindButton> inputsById = Maps.newHashMap();
@@ -159,6 +161,7 @@ public void initialise() {
}
}
+ if (mainLayout != null) {
addInputSection(inputCategories.remove("engine:movement"), mainLayout, inputsById);
addInputSection(inputCategories.remove("engine:interaction"), mainLayout, inputsById);
addInputSection(inputCategories.remove("engine:inventory"), mainLayout, inputsById);
@@ -173,6 +176,7 @@ public void initialise() {
ControllerInfo cfg = inputDeviceConfiguration.getController(name);
addInputSection(mainLayout, name, cfg);
}
+ }
WidgetUtil.trySubscribe(this, "reset", button -> {
inputDeviceConfiguration.reset();
@@ -188,11 +192,8 @@ public void initialise() {
* @param bindId the uri for the binding, e.g. <code>engine:forwards</code>.
*/
private void setPrimaryBind(int key, SimpleUri bindId) {
- UIInputBind inputBind = new UIInputBind();
- BindsConfig bindConfig = bindsManager.getBindsConfig();
- inputBind.bindInput(new InputConfigBinding(bindConfig, bindId, PRIMARY_BIND_INDEX));
- inputBind.setNewInput(InputType.KEY.getInput(key));
- inputBind.saveInput();
+ final BindsConfig bindConfig = bindsManager.getBindsConfig();
+ new InputConfigBinding(bindConfig, bindId, PRIMARY_BIND_INDEX).set(InputType.KEY.getInput(key));
}
private void addInputSection(InputCategory category, ColumnLayout layout, Map<SimpleUri, RegisterBindButton> inputsById) {
