mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-23 19:23:12 -04:00
update
This commit is contained in:
parent
8708e7f8b1
commit
f6836ac920
@ -474,4 +474,13 @@ public final class Controllers {
|
||||
|
||||
FXUtils.shutdown();
|
||||
}
|
||||
|
||||
public static void resetAllLazyPage() {
|
||||
rootPage.reset();
|
||||
versionPage.reset();
|
||||
gameListPage.reset();
|
||||
downloadPage.reset();
|
||||
accountListPage.reset();
|
||||
settingsPage.reset();
|
||||
}
|
||||
}
|
||||
|
@ -45,16 +45,23 @@ public class Navigator extends TransitionPane {
|
||||
private boolean initialized = false;
|
||||
|
||||
public void init(Node init) {
|
||||
stack.push(init);
|
||||
backable.set(canGoBack());
|
||||
setRootPage(init);
|
||||
getChildren().setAll(init);
|
||||
|
||||
fireEvent(new NavigationEvent(this, init, Navigation.NavigationDirection.START, NavigationEvent.NAVIGATED));
|
||||
if (init instanceof PageAware) ((PageAware) init).onPageShown();
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public void setRootPage(Node root) {
|
||||
if (stack.isEmpty()) {
|
||||
stack.push(root);
|
||||
} else {
|
||||
stack.set(0, root);
|
||||
}
|
||||
}
|
||||
|
||||
public void navigate(Node node, AnimationProducer animationProducer) {
|
||||
FXUtils.checkFxUserThread();
|
||||
|
||||
|
@ -53,8 +53,8 @@ import org.jackhuang.hmcl.ui.animation.AnimationUtils;
|
||||
import org.jackhuang.hmcl.ui.animation.ContainerAnimations;
|
||||
import org.jackhuang.hmcl.ui.construct.DialogAware;
|
||||
import org.jackhuang.hmcl.ui.construct.DialogCloseEvent;
|
||||
import org.jackhuang.hmcl.ui.construct.Navigator;
|
||||
import org.jackhuang.hmcl.ui.construct.JFXDialogPane;
|
||||
import org.jackhuang.hmcl.ui.construct.Navigator;
|
||||
import org.jackhuang.hmcl.ui.wizard.Refreshable;
|
||||
import org.jackhuang.hmcl.ui.wizard.WizardProvider;
|
||||
import org.jackhuang.hmcl.util.Lang;
|
||||
@ -65,7 +65,10 @@ import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
@ -547,4 +550,9 @@ public class DecoratorController {
|
||||
decorator.addEventFilter(DragEvent.DRAG_DROPPED, AuthlibInjectorDnD.dragDroppedHandler(
|
||||
url -> Controllers.dialog(new AddAuthlibInjectorServerPane(url))));
|
||||
}
|
||||
|
||||
public void setRootPage(Node n) {
|
||||
navigator.setRootPage(n);
|
||||
navigator.clear();
|
||||
}
|
||||
}
|
||||
|
@ -28,11 +28,14 @@ import org.jackhuang.hmcl.setting.Settings;
|
||||
import org.jackhuang.hmcl.ui.Controllers;
|
||||
import org.jackhuang.hmcl.ui.FXUtils;
|
||||
import org.jackhuang.hmcl.ui.construct.MessageDialogPane.MessageType;
|
||||
import org.jackhuang.hmcl.ui.decorator.Decorator;
|
||||
import org.jackhuang.hmcl.ui.decorator.DecoratorController;
|
||||
import org.jackhuang.hmcl.upgrade.RemoteVersion;
|
||||
import org.jackhuang.hmcl.upgrade.UpdateChannel;
|
||||
import org.jackhuang.hmcl.upgrade.UpdateChecker;
|
||||
import org.jackhuang.hmcl.upgrade.UpdateHandler;
|
||||
import org.jackhuang.hmcl.util.StringUtils;
|
||||
import org.jackhuang.hmcl.util.i18n.I18n;
|
||||
import org.jackhuang.hmcl.util.i18n.Locales;
|
||||
import org.jackhuang.hmcl.util.io.FileUtils;
|
||||
import org.jackhuang.hmcl.util.io.IOUtils;
|
||||
@ -68,6 +71,15 @@ public final class SettingsPage extends SettingsView {
|
||||
// ==== Languages ====
|
||||
cboLanguage.getItems().setAll(Locales.LOCALES);
|
||||
selectedItemPropertyFor(cboLanguage).bindBidirectional(config().localizationProperty());
|
||||
selectedItemPropertyFor(cboLanguage).addListener((observableValue, oldValue, newValue) -> {
|
||||
I18n.setLocale(newValue);
|
||||
|
||||
Controllers.resetAllLazyPage();
|
||||
|
||||
System.gc();
|
||||
|
||||
Controllers.getDecorator().setRootPage(Controllers.getRootPage());
|
||||
});
|
||||
|
||||
disableAutoGameOptionsPane.selectedProperty().bindBidirectional(config().disableAutoGameOptionsProperty());
|
||||
// ====
|
||||
|
@ -26,7 +26,7 @@ import java.util.function.Supplier;
|
||||
* @param <T> value type
|
||||
*/
|
||||
public final class Lazy<T> {
|
||||
private Supplier<T> supplier;
|
||||
private final Supplier<T> supplier;
|
||||
private T value = null;
|
||||
|
||||
public Lazy(Supplier<T> supplier) {
|
||||
@ -34,10 +34,13 @@ public final class Lazy<T> {
|
||||
}
|
||||
|
||||
public T get() {
|
||||
if (supplier != null) {
|
||||
if (value == null) {
|
||||
value = supplier.get();
|
||||
supplier = null;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
value = null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user