Fixed config errors related to how static actions are handled separately

This commit is contained in:
Brendan Robert 2023-08-01 21:26:37 -05:00
parent e867ab2611
commit 5a74750479

View File

@ -6,6 +6,7 @@ import java.lang.reflect.Field;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Optional;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.Set; import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
@ -162,7 +163,7 @@ public class ConfigurationUIController {
if (node == null) { if (node == null) {
return; return;
} }
node.hotkeys.forEach((name, values) -> settingsVbox.getChildren().add(buildKeyShortcutRow(node, name, values))); node.hotkeys.forEach((name, values) -> buildKeyShortcutRow(node, name, values).ifPresent(settingsVbox.getChildren()::add));
node.settings.forEach((name, value) -> settingsVbox.getChildren().add(buildSettingRow(node, name, value))); node.settings.forEach((name, value) -> settingsVbox.getChildren().add(buildSettingRow(node, name, value)));
} }
@ -183,11 +184,14 @@ public class ConfigurationUIController {
return row; return row;
} }
private Node buildKeyShortcutRow(ConfigNode node, String actionName, String[] values) { private Optional<Node> buildKeyShortcutRow(ConfigNode node, String actionName, String[] values) {
InvokableActionRegistry registry = InvokableActionRegistry.getInstance(); InvokableActionRegistry registry = InvokableActionRegistry.getInstance();
InvokableAction actionInfo = registry.getInstanceMethodInfo(actionName); InvokableAction actionInfo = registry.getInstanceMethodInfo(actionName);
if (actionInfo == null) { if (actionInfo == null) {
return null; actionInfo = registry.getStaticMethodInfo(actionName);
}
if (actionInfo == null) {
return Optional.empty();
} }
HBox row = new HBox(); HBox row = new HBox();
row.getStyleClass().add("setting-row"); row.getStyleClass().add("setting-row");
@ -202,7 +206,7 @@ public class ConfigurationUIController {
label.setLabelFor(widget); label.setLabelFor(widget);
row.getChildren().add(label); row.getChildren().add(label);
row.getChildren().add(widget); row.getChildren().add(widget);
return row; return Optional.of(row);
} }
private void editKeyboardShortcut(ConfigNode node, String actionName, Text widget) { private void editKeyboardShortcut(ConfigNode node, String actionName, Text widget) {