mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
add restart dialog on World selectbox
This commit is contained in:
@@ -37,7 +37,7 @@ public class SettingsScene extends UIScene {
|
|||||||
|
|
||||||
SelectBox<String> selectSourcePlane;
|
SelectBox<String> selectSourcePlane;
|
||||||
TextField newPlaneName;
|
TextField newPlaneName;
|
||||||
Dialog createNewPlane, copyPlane, errorDialog;
|
Dialog createNewPlane, copyPlane, errorDialog, restartDialog;
|
||||||
|
|
||||||
private void copyNewPlane() {
|
private void copyNewPlane() {
|
||||||
String plane = selectSourcePlane.getSelected();
|
String plane = selectSourcePlane.getSelected();
|
||||||
@@ -98,16 +98,20 @@ public class SettingsScene extends UIScene {
|
|||||||
super(Forge.isLandscapeMode() ? "ui/settings.json" : "ui/settings_portrait.json");
|
super(Forge.isLandscapeMode() ? "ui/settings.json" : "ui/settings_portrait.json");
|
||||||
|
|
||||||
settingGroup = new Table();
|
settingGroup = new Table();
|
||||||
//temporary disable custom world until it works correctly on each update
|
|
||||||
selectSourcePlane = Controls.newComboBox();
|
selectSourcePlane = Controls.newComboBox();
|
||||||
newPlaneName = Controls.newTextField("");
|
newPlaneName = Controls.newTextField("");
|
||||||
|
|
||||||
selectSourcePlane.setItems(Config.instance().getAllAdventures());
|
selectSourcePlane.setItems(Config.instance().getAllAdventures());
|
||||||
SelectBox plane = Controls.newComboBox(Config.instance().getAllAdventures(), Config.instance().getSettingData().plane, o -> {
|
SelectBox plane = Controls.newComboBox(Config.instance().getAllAdventures(), Config.instance().getSettingData().plane, o -> {
|
||||||
Config.instance().getSettingData().plane = (String) o;
|
Config.instance().getSettingData().plane = (String) o;
|
||||||
Config.instance().saveSettings();
|
Config.instance().saveSettings();
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
plane.addListener(new ChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void changed(ChangeEvent changeEvent, Actor actor) {
|
||||||
|
restartForge();
|
||||||
|
}
|
||||||
|
});
|
||||||
/*newPlane = Controls.newTextButton("Create own plane");
|
/*newPlane = Controls.newTextButton("Create own plane");
|
||||||
newPlane.addListener(new ClickListener() {
|
newPlane.addListener(new ClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -115,9 +119,9 @@ public class SettingsScene extends UIScene {
|
|||||||
createNewPlane();
|
createNewPlane();
|
||||||
}
|
}
|
||||||
});*/
|
});*/
|
||||||
addLabel(Forge.getLocalizer().getMessage("lblWorld"));
|
addLabel(Forge.getLocalizer().getMessage("lblWorld") + " (" + Forge.getLocalizer().getMessage("lblRestartRequired") + ")");
|
||||||
settingGroup.add(plane).align(Align.right).pad(2);
|
settingGroup.add(plane).align(Align.right).pad(2);
|
||||||
addLabel(Forge.getLocalizer().getMessage("lblCreate") + Forge.getLocalizer().getMessage("lblWorld"));
|
//addLabel(Forge.getLocalizer().getMessage("lblCreate") + Forge.getLocalizer().getMessage("lblWorld"));
|
||||||
settingGroup.add(newPlane).align(Align.right).pad(2);
|
settingGroup.add(newPlane).align(Align.right).pad(2);
|
||||||
|
|
||||||
if (!GuiBase.isAndroid()) {
|
if (!GuiBase.isAndroid()) {
|
||||||
@@ -370,6 +374,18 @@ public class SettingsScene extends UIScene {
|
|||||||
settingGroup.add(label).align(Align.left).pad(2, 2, 2, 5).width(w).expand();
|
settingGroup.add(label).align(Align.left).pad(2, 2, 2, 5).width(w).expand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void restartForge() {
|
||||||
|
if (restartDialog == null) {
|
||||||
|
restartDialog = createGenericDialog("",
|
||||||
|
Forge.getLocalizer().getMessage("lblAreYouSureYouWishRestartForge"),
|
||||||
|
Forge.getLocalizer().getMessage("lblOK"),
|
||||||
|
Forge.getLocalizer().getMessage("lblAbort"), () -> {
|
||||||
|
Forge.restart(true);
|
||||||
|
removeDialog();
|
||||||
|
}, this::removeDialog);
|
||||||
|
}
|
||||||
|
showDialog(restartDialog);
|
||||||
|
}
|
||||||
|
|
||||||
private static SettingsScene object;
|
private static SettingsScene object;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user