Apply Saving Replay dialog when pressing Enter (closes #424)

This commit is contained in:
Jonas Herzig
2020-11-22 14:55:07 +01:00
parent 4739d2278b
commit f895a13b61

View File

@@ -83,10 +83,7 @@ public class GuiSavingReplay {
GuiButton applyButton = new GuiButton() GuiButton applyButton = new GuiButton()
.setSize(150, 20) .setSize(150, 20)
.setI18nLabel("replaymod.gui.done") .setI18nLabel("replaymod.gui.done")
.onClick(() -> { .onClick(this::apply);
apply.forEach(Runnable::run);
close();
});
panel.addElements(new VerticalLayout.Data(0.5), applyButton); panel.addElements(new VerticalLayout.Data(0.5), applyButton);
} }
@@ -98,6 +95,7 @@ public class GuiSavingReplay {
.setText(originalName) .setText(originalName)
.setI18nHint("replaymod.gui.delete") .setI18nHint("replaymod.gui.delete")
.setTextColorDisabled(Colors.RED) .setTextColorDisabled(Colors.RED)
.onEnter(this::apply)
.setTooltip(createTooltip(path, metaData)); .setTooltip(createTooltip(path, metaData));
GuiButton clearButton = new GuiButton() GuiButton clearButton = new GuiButton()
.setSize(20, 20) .setSize(20, 20)
@@ -133,6 +131,11 @@ public class GuiSavingReplay {
}).addElements(null, tooltip, entry); }).addElements(null, tooltip, entry);
} }
private void apply() {
apply.forEach(Runnable::run);
close();
}
private void applyOutput(Path path, String newName) { private void applyOutput(Path path, String newName) {
if (newName.isEmpty()) { if (newName.isEmpty()) {
try { try {