This commit is contained in:
huanghongxun 2018-10-02 12:15:52 +08:00
parent c8f74ee8e3
commit 83516ba679
4 changed files with 30 additions and 3 deletions

View File

@ -23,6 +23,8 @@ if (System.getenv("BUILD_NUMBER") != null && System.getenv("BUILD_NUMBER_OFFSET"
def versionroot = System.getenv("VERSION_ROOT") ?: "3.2"
version = versionroot + '.' + buildnumber
mainClassName = 'org.jackhuang.hmcl.Main'
dependencies {
compile project(":HMCLCore")
compile rootProject.files("lib/JFoenix.jar")
@ -75,7 +77,7 @@ def repack(File file) {
jar {
manifest {
attributes 'Created-By': 'Copyright(c) 2013-2018 huangyuhui.',
'Main-Class': 'org.jackhuang.hmcl.Main',
'Main-Class': mainClassName,
'Multi-Release': 'true',
'Implementation-Version': version
}

View File

@ -83,9 +83,13 @@ public class Navigator extends StackPane {
throw new IllegalStateException();
stack.pop();
Node node = stack.peek();
fireEvent(new NavigationEvent(this, from, NavigationEvent.NAVIGATING));
NavigationEvent navigating = new NavigationEvent(this, from, NavigationEvent.NAVIGATING);
fireEvent(navigating);
node.fireEvent(navigating);
setContent(node);
fireEvent(new NavigationEvent(this, node, NavigationEvent.NAVIGATED));
NavigationEvent navigated = new NavigationEvent(this, node, NavigationEvent.NAVIGATED);
fireEvent(navigated);
node.fireEvent(navigated);
Optional.ofNullable(from.getProperties().get(PROPERTY_DIALOG_CLOSE_HANDLER))
.ifPresent(handler -> from.removeEventHandler(PageCloseEvent.CLOSE, (EventHandler<PageCloseEvent>) handler));

View File

@ -20,6 +20,7 @@ package org.jackhuang.hmcl.ui.versions;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXPopup;
import com.jfoenix.controls.JFXTabPane;
import javafx.application.Platform;
import javafx.beans.property.ReadOnlyStringProperty;
import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.fxml.FXML;
@ -30,6 +31,8 @@ import org.jackhuang.hmcl.download.game.GameAssetIndexDownloadTask;
import org.jackhuang.hmcl.setting.Profile;
import org.jackhuang.hmcl.ui.FXUtils;
import org.jackhuang.hmcl.ui.construct.IconedMenuItem;
import org.jackhuang.hmcl.ui.construct.Navigator;
import org.jackhuang.hmcl.ui.construct.PageCloseEvent;
import org.jackhuang.hmcl.ui.construct.PopupMenu;
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
import org.jackhuang.hmcl.util.io.FileUtils;
@ -99,6 +102,8 @@ public final class VersionPage extends StackPane implements DecoratorPage {
FXUtils.installTooltip(btnBrowseMenu, i18n("settings.game.exploration"));
FXUtils.installTooltip(btnManagementMenu, i18n("settings.game.management"));
FXUtils.installTooltip(btnExport, i18n("modpack.export"));
setEventHandler(Navigator.NavigationEvent.NAVIGATED, this::onNavigated);
}
public void load(String id, Profile profile) {
@ -115,6 +120,21 @@ public final class VersionPage extends StackPane implements DecoratorPage {
world.loadVersion(profile, id);
}
private void onNavigated(Navigator.NavigationEvent event) {
if (this.version == null || this.profile == null)
throw new IllegalStateException();
// If we jumped to game list page and deleted this version
// and back to this page, we should return to main page.
if (!this.profile.getRepository().isLoaded() ||
!this.profile.getRepository().hasVersion(version)) {
Platform.runLater(() -> fireEvent(new PageCloseEvent()));
return;
}
load(this.version, this.profile);
}
@FXML
private void onBrowseMenu() {
browsePopup.show(btnBrowseMenu, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.RIGHT, 0, btnBrowseMenu.getHeight());

View File

@ -32,6 +32,7 @@ buildscript {
subprojects {
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'application'
repositories {
mavenCentral()