GTK: More work on InstanceSettingsWindow
This commit is contained in:
parent
0cb3df331a
commit
18c4953b36
|
@ -42,7 +42,7 @@ public class Utils {
|
|||
Desktop.desktop.open(file);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Utils.LOGGER.error("Error opening web browser!", e);
|
||||
Utils.LOGGER.error("Error opening file!", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,4 +26,13 @@ public class IRow extends Box {
|
|||
head.valign = Align.CENTER;
|
||||
append(head);
|
||||
}
|
||||
|
||||
public void setButton(@PropertyKey(resourceBundle = I18n.BUNDLE) String text, Button.Clicked action) {
|
||||
firstChild.hexpand = true;
|
||||
Button btn = Button.newWithLabel(I18n.get(text));
|
||||
btn.valign = Align.CENTER;
|
||||
btn.halign = Align.END;
|
||||
btn.onClicked(action);
|
||||
append(btn);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ public class InstanceListEntryFactory extends SignalListItemFactory {
|
|||
}, R::nop);
|
||||
}).iconName = "edit-copy-symbolic";
|
||||
settingsSection.literalButton("delete", I18n.get("instance.delete"), () -> {
|
||||
LauncherEnv.showOkCancel("This instance will be removed forever (a long time)", "Are you sure?", () -> {
|
||||
LauncherEnv.showOkCancel(I18n.get("instance.delete.confirm"), I18n.get("instance.delete.confirm.title"), () -> {
|
||||
try {
|
||||
JFiles.deleteRecursive(li.instance.path);
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package io.gitlab.jfronny.inceptum.gtk.window;
|
|||
|
||||
import io.gitlab.jfronny.commons.ArgumentsTokenizer;
|
||||
import io.gitlab.jfronny.commons.StringFormatter;
|
||||
import io.gitlab.jfronny.commons.io.JFiles;
|
||||
import io.gitlab.jfronny.commons.ref.R;
|
||||
import io.gitlab.jfronny.inceptum.common.MetaHolder;
|
||||
import io.gitlab.jfronny.inceptum.common.Utils;
|
||||
|
@ -10,10 +11,12 @@ import io.gitlab.jfronny.inceptum.gtk.GtkMain;
|
|||
import io.gitlab.jfronny.inceptum.gtk.control.*;
|
||||
import io.gitlab.jfronny.inceptum.gtk.util.I18n;
|
||||
import io.gitlab.jfronny.inceptum.gtk.window.dialog.ProcessStateWatcherDialog;
|
||||
import io.gitlab.jfronny.inceptum.launcher.model.inceptum.InstanceMeta;
|
||||
import io.gitlab.jfronny.inceptum.launcher.system.exporter.Exporter;
|
||||
import io.gitlab.jfronny.inceptum.launcher.system.exporter.Exporters;
|
||||
import io.gitlab.jfronny.inceptum.launcher.system.instance.*;
|
||||
import io.gitlab.jfronny.inceptum.launcher.util.ProcessState;
|
||||
import manifold.ext.props.rt.api.var;
|
||||
import org.gnome.adw.HeaderBar;
|
||||
import org.gnome.adw.*;
|
||||
import org.gtk.gobject.BindingFlags;
|
||||
|
@ -82,15 +85,7 @@ public class InstanceSettingsWindow extends Window {
|
|||
close();
|
||||
new InstanceSettingsWindow(application, InstanceList.read(newPath)).show();
|
||||
} catch (IOException e) {
|
||||
GtkEnvBackend.simpleDialog(
|
||||
this,
|
||||
StringFormatter.toString(e),
|
||||
"Could not rename",
|
||||
MessageType.ERROR,
|
||||
ButtonsType.CLOSE,
|
||||
null,
|
||||
null
|
||||
);
|
||||
showError("Could not rename", e);
|
||||
}
|
||||
});
|
||||
entry.onChanged(s -> {
|
||||
|
@ -101,6 +96,9 @@ public class InstanceSettingsWindow extends Window {
|
|||
lb.append(row);
|
||||
}
|
||||
}
|
||||
//TODO Version (dropdown) + checkbox: "show snapshots"
|
||||
//TODO Fabric support (checkbox) + dropdown: Loader version
|
||||
//TODO Custom Java (checkbox) + String: path
|
||||
{
|
||||
box.append(new ILabel("instance.settings.general.args", ILabel.Mode.HEADING));
|
||||
Frame frame = new Frame(null);
|
||||
|
@ -108,6 +106,10 @@ public class InstanceSettingsWindow extends Window {
|
|||
lb.selectionMode = SelectionMode.NONE;
|
||||
frame.child = lb;
|
||||
box.append(frame);
|
||||
if (instance.meta.arguments == null) instance.meta.arguments = new InstanceMeta.Arguments(List.of(), List.of(), List.of());
|
||||
if (instance.meta.arguments.jvm == null) instance.meta.arguments = instance.meta.arguments.withJvm(List.of());
|
||||
if (instance.meta.arguments.client == null) instance.meta.arguments = instance.meta.arguments.withClient(List.of());
|
||||
if (instance.meta.arguments.server == null) instance.meta.arguments = instance.meta.arguments.withServer(List.of());
|
||||
{
|
||||
var row = new IRow("instance.settings.general.args.jvm", "instance.settings.general.args.jvm.subtitle");
|
||||
ISEntry entry = new ISEntry(ArgumentsTokenizer.join(instance.meta.arguments.jvm.toArray(String[]::new)));
|
||||
|
@ -139,11 +141,45 @@ public class InstanceSettingsWindow extends Window {
|
|||
lb.append(row);
|
||||
}
|
||||
}
|
||||
//TODO Open Directory (button)
|
||||
//TODO Version (dropdown) + checkbox: "show snapshots"
|
||||
//TODO Fabric support (checkbox) + dropdown: Loader version
|
||||
//TODO Delete (button) -> confirmation + delete
|
||||
//TODO Custom Java (checkbox) + String: path
|
||||
{
|
||||
box.append(new ILabel("instance.settings.general.manage", ILabel.Mode.HEADING));
|
||||
Frame frame = new Frame(null);
|
||||
ListBox lb = new ListBox();
|
||||
lb.selectionMode = SelectionMode.NONE;
|
||||
frame.child = lb;
|
||||
box.append(frame);
|
||||
{
|
||||
var row = new IRow("instance.delete", "instance.delete.subtitle");
|
||||
row.setButton("instance.delete", () -> {
|
||||
MessageDialog dialog = new MessageDialog(this, DialogFlags.MODAL.or(DialogFlags.DESTROY_WITH_PARENT), MessageType.WARNING, ButtonsType.OK_CANCEL, null);
|
||||
dialog.markup = I18n.get("instance.delete.confirm");
|
||||
dialog.title = I18n.get("instance.delete.confirm.title");
|
||||
dialog.onResponse(responseId -> {
|
||||
switch (ResponseType.of(responseId)) {
|
||||
case OK -> {
|
||||
try {
|
||||
JFiles.deleteRecursive(instance.path);
|
||||
dialog.close();
|
||||
close();
|
||||
} catch (IOException e) {
|
||||
showError("Could not delete the instance", e);
|
||||
}
|
||||
dialog.close();
|
||||
}
|
||||
case CLOSE, CANCEL -> dialog.close();
|
||||
case DELETE_EVENT -> dialog.destroy();
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
});
|
||||
lb.append(row);
|
||||
}
|
||||
{
|
||||
var row = new IRow("instance.directory", "instance.directory.subtitle");
|
||||
row.setButton("instance.directory", () -> Utils.openFile(instance.path.toFile()));
|
||||
lb.append(row);
|
||||
}
|
||||
}
|
||||
stack.addTitledWithIcon(box, null, I18n.get("instance.settings.general"), "preferences-other-symbolic");
|
||||
}
|
||||
|
||||
|
@ -180,11 +216,7 @@ public class InstanceSettingsWindow extends Window {
|
|||
}
|
||||
for (Exporter<?> exporter : Exporters.EXPORTERS) {
|
||||
var row = new IRow("instance.settings.export.title", "instance.settings.export.subtitle", exporter.name, exporter.fileExtension);
|
||||
row.firstChild.hexpand = true;
|
||||
Button btn = Button.newWithLabel(I18n.get("instance.settings.export"));
|
||||
btn.valign = Align.CENTER;
|
||||
btn.halign = Align.END;
|
||||
btn.onClicked(() -> {
|
||||
row.setButton("instance.settings.export", () -> {
|
||||
FileChooserNative dialog = new FileChooserNative(
|
||||
I18n.get("instance.settings.export.dialog.title", exporter.name),
|
||||
this,
|
||||
|
@ -195,25 +227,24 @@ public class InstanceSettingsWindow extends Window {
|
|||
dialog.currentName = exporter.getDefaultFileName(instance);
|
||||
dialog.onResponse(responseId -> {
|
||||
if (responseId == ResponseType.ACCEPT.value) {
|
||||
var file = dialog.getFile().path;
|
||||
if (file == null) {
|
||||
GtkEnvBackend.simpleDialog(
|
||||
this,
|
||||
"The path returned by the file dialog is null",
|
||||
"Could not export",
|
||||
MessageType.ERROR,
|
||||
ButtonsType.CLOSE,
|
||||
null,
|
||||
null
|
||||
);
|
||||
return;
|
||||
}
|
||||
export(exporter, Path.of(file));
|
||||
var file = dialog.getFile().path;
|
||||
if (file == null) {
|
||||
GtkEnvBackend.simpleDialog(
|
||||
this,
|
||||
"The path returned by the file dialog is null",
|
||||
"Could not export",
|
||||
MessageType.ERROR,
|
||||
ButtonsType.CLOSE,
|
||||
null,
|
||||
null
|
||||
);
|
||||
return;
|
||||
}
|
||||
export(exporter, Path.of(file));
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
});
|
||||
row.append(btn);
|
||||
lb.append(row);
|
||||
}
|
||||
}
|
||||
|
@ -257,4 +288,16 @@ public class InstanceSettingsWindow extends Window {
|
|||
R::nop
|
||||
);
|
||||
}
|
||||
|
||||
private void showError(String message, Throwable t) {
|
||||
GtkEnvBackend.simpleDialog(
|
||||
this,
|
||||
StringFormatter.toString(t),
|
||||
message,
|
||||
MessageType.ERROR,
|
||||
ButtonsType.CLOSE,
|
||||
null,
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,14 +148,20 @@ public class MainWindow extends ApplicationWindow {
|
|||
if (listButton != null) listButton.visible = !InceptumConfig.listView;
|
||||
if (gridButton != null) gridButton.visible = InceptumConfig.listView;
|
||||
try {
|
||||
// Unbind then clear
|
||||
instanceListIndex.size = 0;
|
||||
instanceList.clear();
|
||||
|
||||
// Add new entries
|
||||
instanceList.addAll(InstanceList.ordered());
|
||||
instanceListIndex.size = instanceList.size();
|
||||
|
||||
// Choose view for this amount of entries
|
||||
if (InstanceList.isEmpty) stack.visibleChild = empty;
|
||||
else if (InceptumConfig.listView) stack.visibleChild = listContainer;
|
||||
else stack.visibleChild = gridView;
|
||||
|
||||
// This is called from a tick callback, so re-render
|
||||
stack.queueResize();
|
||||
stack.queueDraw();
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package io.gitlab.jfronny.inceptum.gtk.window.dialog;
|
||||
|
||||
import io.gitlab.jfronny.commons.StringFormatter;
|
||||
import io.gitlab.jfronny.commons.throwable.ThrowingConsumer;
|
||||
import io.gitlab.jfronny.inceptum.common.Utils;
|
||||
import io.gitlab.jfronny.inceptum.gtk.GtkEnvBackend;
|
||||
import io.gitlab.jfronny.inceptum.gtk.GtkMain;
|
||||
import io.gitlab.jfronny.inceptum.gtk.util.I18n;
|
||||
import io.gitlab.jfronny.inceptum.launcher.LauncherEnv;
|
||||
|
@ -31,9 +34,13 @@ public class ProcessStateWatcherDialog extends MessageDialog {
|
|||
this.title = title;
|
||||
if (cancel != null) addButton(I18n.get("cancel"), ResponseType.CANCEL.value);
|
||||
onResponse(responseId -> {
|
||||
if (responseId == ResponseType.CANCEL.value) {
|
||||
canceled.set(true);
|
||||
close();
|
||||
switch (ResponseType.of(responseId)) {
|
||||
case CLOSE, CANCEL -> {
|
||||
canceled.set(true);
|
||||
close();
|
||||
}
|
||||
case DELETE_EVENT -> destroy();
|
||||
default -> Utils.LOGGER.error("Unexpected response type: " + responseId);
|
||||
}
|
||||
});
|
||||
onCloseRequest(() -> {
|
||||
|
@ -64,7 +71,15 @@ public class ProcessStateWatcherDialog extends MessageDialog {
|
|||
executor.accept(canceled);
|
||||
} catch (Throwable e) {
|
||||
canceled.set(true);
|
||||
LauncherEnv.showError(errorMessage, e);
|
||||
GtkEnvBackend.simpleDialog(
|
||||
parent,
|
||||
StringFormatter.toString(e),
|
||||
errorMessage,
|
||||
MessageType.ERROR,
|
||||
ButtonsType.CLOSE,
|
||||
null,
|
||||
null
|
||||
);
|
||||
} finally {
|
||||
finished.set(true);
|
||||
GtkMain.schedule(this::close);
|
||||
|
|
|
@ -18,6 +18,8 @@ about.unsupported-build=This is a custom build. No support will be provided.
|
|||
about.jvm.unsupported=Java VM %d (unsupported)
|
||||
ok=Ok
|
||||
cancel=Cancel
|
||||
show=Show
|
||||
save=Save
|
||||
menu.hamburger.support=Support
|
||||
menu.hamburger.preferences=Preferences
|
||||
menu.hamburger.about=About
|
||||
|
@ -31,11 +33,15 @@ instance.launch=Launch
|
|||
main.empty.title=Welcome to Inceptum
|
||||
main.empty.description=To get started, create (or import) a new instance using the + button
|
||||
instance.directory=Open Directory
|
||||
instance.directory.subtitle=Open the Directory of this Instance in your File Manager
|
||||
instance.launch.client=Launch Client
|
||||
instance.launch.server=Launch Server
|
||||
instance.settings=Settings
|
||||
instance.copy=Duplicate
|
||||
instance.delete=Delete
|
||||
instance.delete.subtitle=Irrevocably remove this instance
|
||||
instance.delete.confirm=This instance will be removed forever (a long time)
|
||||
instance.delete.confirm.title=Are you sure?
|
||||
instance.copy.prompt=New Name
|
||||
instance.copy.details=Please enter a name for the new instance
|
||||
instance.settings.general=General
|
||||
|
@ -57,15 +63,14 @@ instance.settings.export.title=%1$s
|
|||
instance.settings.export.subtitle=Export this Pack as a %1$s %2$s file
|
||||
instance.settings.export.version=Version
|
||||
instance.settings.export.version.subtitle=Version of the exported Pack
|
||||
save=Save
|
||||
instance.settings.export.dialog.title=Export %1$s Pack
|
||||
instance.settings.export.dialog.success=%1$s has been successfully exported to %2$s
|
||||
instance.settings.export.dialog.success.title=Sucessfully exported
|
||||
instance.settings.export.dialog.error=Could not export %1$s
|
||||
instance.launch.error=Could not start instance
|
||||
instance.launch.title=Starting instance
|
||||
show=Show
|
||||
auth.title=Microsoft Login
|
||||
auth.description=This feature uses modified ATLauncher code, so the login prompt will ask you to log in to ATLauncher.\
|
||||
Click the button below to begin!
|
||||
auth.open-browser=Open in Browser
|
||||
auth.open-browser=Open in Browser
|
||||
instance.settings.general.manage=Manage
|
|
@ -17,6 +17,8 @@ about.unsupported-build=Dies ist ein selbst-erstelltes Build. Es wird kein Suppo
|
|||
about.jvm.unsupported=Java VM %d (nicht unterstützt)
|
||||
ok=OK
|
||||
cancel=Abbrechen
|
||||
show=Anzeigen
|
||||
save=Speichern
|
||||
menu.hamburger.support=Unterstützung
|
||||
menu.hamburger.preferences=Einstellungen
|
||||
menu.hamburger.about=Über
|
||||
|
@ -31,11 +33,15 @@ instance.launch=Starten
|
|||
main.empty.title=Willkommen bei Inceptum
|
||||
main.empty.description=Importiere oder erstelle um anzufangen eine Instanz mit dem +
|
||||
instance.directory=Verzeichnis öffnen
|
||||
instance.directory.subtitle=Verzeichnis dieser Instanz in ihrem File-Manager öffnen
|
||||
instance.launch.client=Starte Client
|
||||
instance.launch.server=Starte Server
|
||||
instance.settings=Einstellungen
|
||||
instance.copy=Klonen
|
||||
instance.delete=Löschen
|
||||
instance.delete.subtitle=Diese Instanz unwiederruflich löschen
|
||||
instance.delete.confirm=Diese Instanz wird unwiederruflich gelöscht
|
||||
instance.delete.confirm.title=Bist du sicher?
|
||||
instance.copy.prompt=Neuer Name
|
||||
instance.copy.details=Gib den Namen für die neue Instanz ein
|
||||
instance.settings.general=Allgemein
|
||||
|
@ -57,15 +63,14 @@ instance.settings.export.title=%1$s
|
|||
instance.settings.export.subtitle=Dieses Pack als %2$s für %1$s exportieren
|
||||
instance.settings.export.version=Version
|
||||
instance.settings.export.version.subtitle=Version des exportierten Packs
|
||||
save=Speichern
|
||||
instance.settings.export.dialog.title=%1$s-Pack exportieren
|
||||
instance.settings.export.dialog.success=%1$s wurde erfolgreich nach %2$s exportiert
|
||||
instance.settings.export.dialog.success.title=Erfolgreich exportiert
|
||||
instance.settings.export.dialog.error=Konnte %1$s nicht exportieren
|
||||
instance.launch.error=Konnte Instanz nicht starten
|
||||
instance.launch.title=Starting instance
|
||||
show=Anzeigen
|
||||
auth.title=Microsoft-Anmeldung
|
||||
auth.description=Diese Funktion nutzt Code des ATLauncher, weshalb der Anmeldebildschirm nach einer Anmeldung für ATLauncher fragen wird.\
|
||||
Klicken Sie auf die Schaltfläche unten, um zu beginnen!<
|
||||
auth.open-browser=Im Browser öffnen
|
||||
auth.open-browser=Im Browser öffnen
|
||||
instance.settings.general.manage=Manage
|
Loading…
Reference in New Issue