Compare commits

..
6 Commits
41 changed files with 248 additions and 237 deletions

No files matched your search

+5 -4
View File
@@ -1,3 +1,6 @@
import org.apache.tools.ant.filters.ReplaceTokens
import proguard.gradle.ProGuardTask
import java.security.MessageDigest
import java.util.jar.JarFile
import java.util.jar.Pack200
@@ -17,9 +20,7 @@ def versionroot = System.getenv("VERSION_ROOT")
if (versionroot == null)
versionroot = "3.0"
String mavenGroupId = 'HMCL'
String mavenVersion = versionroot + '.' + buildnumber
String bundleName = "Hello Minecraft! Launcher"
version = mavenVersion
dependencies {
@@ -30,7 +31,7 @@ dependencies {
task generateSources(type: Sync) {
from 'src/main/java'
into "$buildDir/generated-src"
filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [
filter(ReplaceTokens, tokens: [
'HELLO_MINECRAFT_LAUNCHER_VERSION_FOR_GRADLE_REPLACING': mavenVersion
])
}
@@ -122,7 +123,7 @@ task makePackGZ(dependsOn: jar) doLast {
fileEx.append sha1Hex
}
task proguard(type: proguard.gradle.ProGuardTask, dependsOn: jar) {
task proguard(type: ProGuardTask, dependsOn: jar) {
ext {
def re = jar.classifier
injar = jar.archivePath
@@ -86,6 +86,8 @@ public final class Launcher extends Application {
}
public static void stopWithoutPlatform() {
Logging.LOG.info("Stopping application without JavaFX Toolkit");
JFXUtilities.runInFX(() -> {
if (Controllers.getStage() == null)
return;
@@ -17,9 +17,9 @@
*/
package org.jackhuang.hmcl;
import org.apache.commons.compress.utils.Charsets;
import org.jackhuang.hmcl.util.Logging;
import javax.swing.JOptionPane;
import javax.swing.*;
import java.io.File;
public final class Main {
@@ -17,6 +17,13 @@
*/
package org.jackhuang.hmcl.event;
import org.jackhuang.hmcl.auth.Account;
import org.jackhuang.hmcl.setting.Profile;
import org.jackhuang.hmcl.util.ToStringBuilder;
import java.util.Collection;
import java.util.Collections;
/**
* This event gets fired when loading accounts.
* <br>
@@ -26,14 +33,29 @@ package org.jackhuang.hmcl.event;
*/
public class AccountLoadingEvent extends Event {
private final Collection<Account> accounts;
/**
* Constructor.
*
* @param source {@link org.jackhuang.hmcl.setting.Settings}
*/
public AccountLoadingEvent(Object source) {
public AccountLoadingEvent(Object source, Collection<Account> accounts) {
super(source);
this.accounts = Collections.unmodifiableCollection(accounts);
}
public Collection<Account> getAccounts() {
return accounts;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("source", source)
.append("accounts", accounts)
.toString();
}
}
@@ -17,6 +17,7 @@
*/
package org.jackhuang.hmcl.event;
import org.jackhuang.hmcl.util.ToStringBuilder;
import org.jackhuang.hmcl.util.VersionNumber;
/**
@@ -42,4 +43,11 @@ public final class OutOfDateEvent extends Event {
return true;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("source", getSource())
.append("version", getVersion())
.toString();
}
}
@@ -18,6 +18,7 @@
package org.jackhuang.hmcl.event;
import org.jackhuang.hmcl.setting.Profile;
import org.jackhuang.hmcl.util.ToStringBuilder;
/**
* This event gets fired when the selected profile changed.
@@ -44,4 +45,11 @@ public final class ProfileChangedEvent extends Event {
return profile;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("source", source)
.append("profile", profile)
.toString();
}
}
@@ -17,6 +17,12 @@
*/
package org.jackhuang.hmcl.event;
import org.jackhuang.hmcl.setting.Profile;
import org.jackhuang.hmcl.util.ToStringBuilder;
import java.util.Collection;
import java.util.Collections;
/**
* This event gets fired when loading profiles.
* <br>
@@ -26,14 +32,29 @@ package org.jackhuang.hmcl.event;
*/
public class ProfileLoadingEvent extends Event {
private final Collection<Profile> profiles;
/**
* Constructor.
*
* @param source {@link org.jackhuang.hmcl.setting.Settings}
*/
public ProfileLoadingEvent(Object source) {
public ProfileLoadingEvent(Object source, Collection<Profile> profiles) {
super(source);
this.profiles = Collections.unmodifiableCollection(profiles);
}
public Collection<Profile> getProfiles() {
return profiles;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("source", source)
.append("profiles", profiles)
.toString();
}
}
@@ -42,7 +42,6 @@ public final class HMCLModpackInstallTask extends Task {
private final String name;
private final HMCLGameRepository repository;
private final Modpack modpack;
private final File run;
private final List<Task> dependencies = new LinkedList<>();
private final List<Task> dependents = new LinkedList<>();
@@ -52,8 +51,8 @@ public final class HMCLModpackInstallTask extends Task {
this.zipFile = zipFile;
this.name = name;
this.modpack = modpack;
this.run = repository.getRunDirectory(name);
File run = repository.getRunDirectory(name);
File json = repository.getModpackConfiguration(name);
if (repository.hasVersion(name) && !json.exists())
throw new IllegalArgumentException("Version " + name + " already exists");
@@ -50,7 +50,6 @@ public final class LauncherHelper {
public static final LauncherHelper INSTANCE = new LauncherHelper();
private LauncherHelper(){}
private TaskExecutor executor;
public static final Queue<ManagedProcess> PROCESSES = new ConcurrentLinkedQueue<>();
private final TaskExecutorDialogPane launchingStepsPane = new TaskExecutorDialogPane(() -> {});
@@ -78,7 +77,7 @@ public final class LauncherHelper {
VersionSetting setting = profile.getVersionSetting(selectedVersion);
Optional<String> gameVersion = GameVersion.minecraftVersion(repository.getVersionJar(version));
executor = Task.of(Schedulers.javafx(), () -> Controllers.dialog(launchingStepsPane))
TaskExecutor executor = Task.of(Schedulers.javafx(), () -> Controllers.dialog(launchingStepsPane))
.then(Task.of(Schedulers.javafx(), () -> emitStatus(LoadingState.DEPENDENCIES)))
.then(variables -> {
if (setting.isNotCheckGame())
@@ -162,8 +161,7 @@ public final class LauncherHelper {
Controllers.closeDialog();
});
}
LauncherHelper.this.executor = null;
launchingStepsPane.setExecutor(null);
}
});
@@ -356,7 +354,8 @@ public final class LauncherHelper {
});
break;
case CLOSE:
throw new Error("Never come to here");
// Never come to here.
break;
case KEEP:
// No operations here
break;
@@ -24,6 +24,7 @@ import org.jackhuang.hmcl.game.HMCLGameRepository;
import org.jackhuang.hmcl.mod.ModManager;
import org.jackhuang.hmcl.util.ImmediateObjectProperty;
import org.jackhuang.hmcl.util.ImmediateStringProperty;
import org.jackhuang.hmcl.util.ToStringBuilder;
import java.io.File;
import java.lang.reflect.Type;
@@ -146,6 +147,14 @@ public final class Profile {
vs.setUsesGlobal(true);
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("gameDir", getGameDir())
.append("name", getName())
.toString();
}
public void addPropertyChangedListener(InvalidationListener listener) {
nameProperty.addListener(listener);
globalProperty.addListener(listener);
@@ -63,7 +63,7 @@ public class Settings {
private final Config SETTINGS = initSettings();
private Map<String, Account> accounts = new HashMap<>();
private final Map<String, Account> accounts = new HashMap<>();
{
loadProxy();
@@ -473,7 +473,7 @@ public class Settings {
checkProfileMap();
if (!hasProfile(SETTINGS.getSelectedProfile())) {
SETTINGS.setSelectedProfile(getProfileMap().keySet().stream().findFirst().get());
getProfileMap().keySet().stream().findFirst().ifPresent(SETTINGS::setSelectedProfile);
Schedulers.computation().schedule(this::onProfileChanged);
}
return getProfile(SETTINGS.getSelectedProfile());
@@ -535,7 +535,7 @@ public class Settings {
}
private void onProfileChanged() {
EventBus.EVENT_BUS.fireEvent(new ProfileChangedEvent(SETTINGS, getSelectedProfile()));
EventBus.EVENT_BUS.fireEvent(new ProfileChangedEvent(this, getSelectedProfile()));
getSelectedProfile().getRepository().refreshVersionsAsync().start();
}
@@ -548,11 +548,11 @@ public class Settings {
* Invoked by loading GUI phase.
*/
public void onProfileLoading() {
EventBus.EVENT_BUS.fireEvent(new ProfileLoadingEvent(SETTINGS));
EventBus.EVENT_BUS.fireEvent(new ProfileLoadingEvent(this, getProfiles()));
onProfileChanged();
}
public void onAccountLoading() {
EventBus.EVENT_BUS.fireEvent(new AccountLoadingEvent(SETTINGS));
EventBus.EVENT_BUS.fireEvent(new AccountLoadingEvent(this, getAccounts()));
}
}
@@ -32,8 +32,8 @@ import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilAccount;
import org.jackhuang.hmcl.game.AccountHelper;
import org.jackhuang.hmcl.setting.Accounts;
import org.jackhuang.hmcl.setting.Settings;
import org.jackhuang.hmcl.setting.Theme;
import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.ui.construct.ComponentList;
import org.jackhuang.hmcl.ui.wizard.DecoratorPage;
@@ -53,8 +53,12 @@ public class AccountPage extends StackPane implements DecoratorPage {
@FXML
private BorderPane paneServer;
@FXML
private BorderPane paneEmail;
@FXML
private ComponentList componentList;
@FXML
private JFXButton btnDelete;
@FXML
private JFXButton btnRefresh;
public AccountPage(Account account) {
@@ -63,24 +67,29 @@ public class AccountPage extends StackPane implements DecoratorPage {
FXUtils.loadFXML(this, "/assets/fxml/account.fxml");
FXUtils.setLimitWidth(this, 300);
if (account instanceof AuthlibInjectorAccount) {
Accounts.getAuthlibInjectorServerNameAsync((AuthlibInjectorAccount) account)
.subscribe(Schedulers.javafx(), variables -> lblServer.setText(variables.get("serverName")));
FXUtils.setLimitHeight(this, 182);
} else {
componentList.removeChildren(paneServer);
if (account instanceof OfflineAccount) {
componentList.removeChildren(paneEmail);
FXUtils.setLimitHeight(this, 110);
} else
FXUtils.setLimitHeight(this, 145);
}
btnDelete.setGraphic(SVG.delete(Theme.blackFillBinding(), 15, 15));
btnRefresh.setGraphic(SVG.refresh(Theme.blackFillBinding(), 15, 15));
lblCharacter.setText(account.getCharacter());
lblType.setText(AddAccountPane.accountType(account));
lblEmail.setText(account.getUsername());
btnRefresh.setDisable(account instanceof OfflineAccount);
if (account instanceof YggdrasilAccount) {
btnRefresh.setOnMouseClicked(e -> {
AccountHelper.refreshSkinAsync((YggdrasilAccount) account).start();
});
}
btnRefresh.setVisible(account instanceof YggdrasilAccount);
}
@FXML
@@ -89,6 +98,12 @@ public class AccountPage extends StackPane implements DecoratorPage {
Controllers.navigate(null);
}
@FXML
private void onRefresh() {
if (account instanceof YggdrasilAccount)
AccountHelper.refreshSkinAsync((YggdrasilAccount) account).start();
}
public String getTitle() {
return title.get();
}
@@ -93,6 +93,8 @@ public final class Controllers {
public static void initialize(Stage stage) {
Controllers.stage = stage;
stage.setOnCloseRequest(e -> Launcher.stopApplication());
decorator = new Decorator(stage, getMainPage(), Launcher.TITLE, false, true);
decorator.showPage(null);
leftPaneController = new LeftPaneController(decorator.getLeftPane());
@@ -74,7 +74,7 @@ public final class Decorator extends StackPane implements TaskExecutorDialogWiza
private static final SVGGlyph close = Lang.apply(new SVGGlyph(0, "CLOSE", "M810 274l-238 238 238 238-60 60-238-238-238 238-60-60 238-238-238-238 60-60 238 238 238-238z", Color.WHITE),
glyph -> { glyph.setPrefSize(12, 12); glyph.setSize(12, 12); });
private final ObjectProperty<Runnable> onCloseButtonAction = new SimpleObjectProperty<>(Launcher::stopApplication);
private final ObjectProperty<Runnable> onCloseButtonAction;
private final BooleanProperty customMaximize = new SimpleBooleanProperty(false);
private final Stage primaryStage;
@@ -141,6 +141,8 @@ public final class Decorator extends StackPane implements TaskExecutorDialogWiza
FXUtils.loadFXML(this, "/assets/fxml/decorator.fxml");
onCloseButtonAction = new SimpleObjectProperty<>(this, "onCloseButtonAction", Launcher::stopApplication);
primaryStage.initStyle(StageStyle.UNDECORATED);
btnClose.setGraphic(close);
btnMin.setGraphic(minus);
@@ -19,7 +19,6 @@ package org.jackhuang.hmcl.ui;
import com.jfoenix.concurrency.JFXUtilities;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXListView;
import com.jfoenix.controls.JFXPopup;
import javafx.application.Platform;
import javafx.scene.Node;
@@ -127,7 +126,7 @@ public final class LeftPaneController {
for (Profile profile : Settings.INSTANCE.getProfiles()) {
VersionListItem item = new VersionListItem(Profiles.getProfileDisplayName(profile));
RipplerContainer ripplerContainer = new RipplerContainer(item);
item.setOnSettingsButtonClicked(() -> Controllers.getDecorator().showPage(new ProfilePage(profile)));
item.setOnSettingsButtonClicked(e -> Controllers.getDecorator().showPage(new ProfilePage(profile)));
ripplerContainer.setOnMouseClicked(e -> Settings.INSTANCE.setSelectedProfile(profile));
ripplerContainer.getProperties().put("profile", profile.getName());
ripplerContainer.maxWidthProperty().bind(leftPane.widthProperty());
@@ -148,32 +147,14 @@ public final class LeftPaneController {
for (Account account : Settings.INSTANCE.getAccounts()) {
VersionListItem item = new VersionListItem(account.getCharacter(), accountType(account));
RipplerContainer ripplerContainer = new RipplerContainer(item);
item.setOnSettingsButtonClicked(() -> Controllers.getDecorator().showPage(new AccountPage(account)));
item.setOnSettingsButtonClicked(e -> {
AccountPage accountPage = new AccountPage(account);
JFXPopup popup = new JFXPopup(accountPage);
popup.show((Node) e.getSource(), JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.LEFT, e.getX(), e.getY());
});
ripplerContainer.setOnMouseClicked(e -> {
if (e.getButton() == MouseButton.PRIMARY)
Settings.INSTANCE.setSelectedAccount(account);
else if (e.getButton() == MouseButton.SECONDARY) {
JFXListView<String> listView = new JFXListView<>();
JFXPopup popup = new JFXPopup(listView);
listView.getStyleClass().add("option-list-view");
listView.getItems().add(Launcher.i18n("button.delete"));
if (account instanceof YggdrasilAccount)
listView.getItems().add(Launcher.i18n("button.refresh"));
listView.setOnMouseClicked(e2 ->{
popup.hide();
switch (listView.getSelectionModel().getSelectedIndex()) {
case 0:
Settings.INSTANCE.deleteAccount(account);
break;
case 1:
if (account instanceof YggdrasilAccount)
AccountHelper.refreshSkinAsync((YggdrasilAccount) account).start();
break;
default:
throw new Error();
}});
popup.show(item, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.LEFT, e.getX(), e.getY());
}
});
ripplerContainer.getProperties().put("account", account);
ripplerContainer.maxWidthProperty().bind(leftPane.widthProperty());
@@ -196,7 +177,8 @@ public final class LeftPaneController {
if (Settings.INSTANCE.getAccounts().isEmpty()) {
RipplerContainer container = new RipplerContainer(missingAccountItem);
missingAccountItem.setOnSettingsButtonClicked(this::addNewAccount);
missingAccountItem.setOnSettingsButtonClicked(e -> addNewAccount());
container.setOnMouseClicked(e -> addNewAccount());
list.add(container);
}
@@ -209,7 +209,7 @@ public final class MainPage extends StackPane implements DecoratorPage {
}
private void loadingVersions() {
contentPane.getChildren().setAll(spinner);
getChildren().setAll(spinner);
FXUtils.resetChildren(masonryPane, Collections.emptyList());
}
@@ -220,7 +220,7 @@ public final class MainPage extends StackPane implements DecoratorPage {
}
JFXUtilities.runInFX(() -> {
if (profile == repository.getProfile()) {
contentPane.getChildren().setAll(masonryPane);
getChildren().setAll(contentPane);
FXUtils.resetChildren(masonryPane, children);
}
});
@@ -17,11 +17,14 @@
*/
package org.jackhuang.hmcl.ui;
import com.jfoenix.controls.JFXButton;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.geometry.Rectangle2D;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
public final class VersionListItem extends StackPane {
@@ -33,7 +36,7 @@ public final class VersionListItem extends StackPane {
private Label lblGameVersion;
@FXML
private ImageView imageView;
private Runnable handler;
@FXML private JFXButton btnSettings;
public VersionListItem(String versionName) {
this(versionName, "");
@@ -48,13 +51,8 @@ public final class VersionListItem extends StackPane {
FXUtils.limitSize(imageView, 32, 32);
}
@FXML
private void onSettings() {
handler.run();
}
public void setOnSettingsButtonClicked(Runnable handler) {
this.handler = handler;
public void setOnSettingsButtonClicked(EventHandler<? super MouseEvent> handler) {
btnSettings.setOnMouseClicked(handler);
}
public void setVersionName(String versionName) {
@@ -57,7 +57,9 @@ public class TaskExecutorDialogPane extends StackPane {
public void setExecutor(TaskExecutor executor) {
this.executor = executor;
taskListPane.setExecutor(executor);
if (executor != null)
taskListPane.setExecutor(executor);
}
public StringProperty titleProperty() {
@@ -28,12 +28,10 @@ import org.jackhuang.hmcl.ui.wizard.WizardPage;
import java.util.Map;
public final class InstallTypePage extends StackPane implements WizardPage {
private final WizardController controller;
@FXML private JFXListView<Object> list;
public InstallTypePage(WizardController controller) {
this.controller = controller;
FXUtils.loadFXML(this, "/assets/fxml/download/dltype.fxml");
list.setOnMouseClicked(e -> {
@@ -37,8 +37,6 @@ import java.util.Map;
public class InstallersPage extends StackPane implements WizardPage {
private final WizardController controller;
private final GameRepository repository;
private final DownloadProvider downloadProvider;
@FXML
private VBox list;
@@ -72,8 +70,6 @@ public class InstallersPage extends StackPane implements WizardPage {
public InstallersPage(WizardController controller, GameRepository repository, DownloadProvider downloadProvider) {
this.controller = controller;
this.repository = repository;
this.downloadProvider = downloadProvider;
FXUtils.loadFXML(this, "/assets/fxml/download/installers.fxml");
@@ -44,11 +44,9 @@ import java.util.Objects;
import java.util.stream.Collectors;
public final class VersionsPage extends StackPane implements WizardPage, Refreshable {
private final WizardController controller;
private final String gameVersion;
private final DownloadProvider downloadProvider;
private final String libraryId;
private final Runnable callback;
private final String title;
@FXML
@@ -73,12 +71,10 @@ public final class VersionsPage extends StackPane implements WizardPage, Refresh
private TaskExecutor executor;
public VersionsPage(WizardController controller, String title, String gameVersion, DownloadProvider downloadProvider, String libraryId, Runnable callback) {
this.controller = controller;
this.title = title;
this.gameVersion = gameVersion;
this.downloadProvider = downloadProvider;
this.libraryId = libraryId;
this.callback = callback;
this.versionList = downloadProvider.getVersionListById(libraryId);
FXUtils.loadFXML(this, "/assets/fxml/download/versions.fxml");
@@ -176,7 +176,7 @@ public class AppDataUpgrader extends IUpgrader {
@Override
public Collection<Task> getDependents() {
return Arrays.asList(new FileDownloadTask(downloadLink, tempFile, Proxy.NO_PROXY, hash));
return Collections.singleton(new FileDownloadTask(downloadLink, tempFile, Proxy.NO_PROXY, hash));
}
@Override
@@ -37,6 +37,7 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
private static final HashMap<String, String> SOURCE = new HashMap<String, String>() {
{
put("javafx.fxml.LoadException", Launcher.i18n("crash.NoClassDefFound"));
put("Location is not set", Launcher.i18n("crash.NoClassDefFound"));
put("UnsatisfiedLinkError", Launcher.i18n("crash.user_fault"));
put("java.lang.NoClassDefFoundError", Launcher.i18n("crash.NoClassDefFound"));
put("java.lang.VerifyError", Launcher.i18n("crash.NoClassDefFound"));
@@ -45,6 +46,7 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
put("java.lang.ClassFormatError", Launcher.i18n("crash.NoClassDefFound"));
put("java.lang.OutOfMemoryError", "FUCKING MEMORY LIMIT!");
put("Trampoline", Launcher.i18n("launcher.update_java"));
put("com.sun.javafx.css.StyleManager.findMatchingStyles", Launcher.i18n("launcher.update_java"));
put("NoSuchAlgorithmException", "Has your operating system been installed completely or is a ghost system?");
}
};
@@ -78,18 +80,16 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
THROWABLE_SET.add(stackTrace);
try {
StringBuilder builder = new StringBuilder();
builder.append("---- Hello Minecraft! Crash Report ----\n");
builder.append(" Version: " + Launcher.VERSION + "\n");
builder.append(" Time: ").append(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())).append("\n");
builder.append(" Thread: ").append(t.toString()).append("\n");
builder.append("\n Content: \n ");
builder.append(stackTrace).append("\n\n");
builder.append("-- System Details --\n");
builder.append(" Operating System: ").append(System.getProperty("os.name")).append(' ').append(OperatingSystem.SYSTEM_VERSION).append("\n");
builder.append(" Java Version: ").append(System.getProperty("java.version")).append(", ").append(System.getProperty("java.vendor")).append("\n");
builder.append(" Java VM Version: ").append(System.getProperty("java.vm.name")).append(" (").append(System.getProperty("java.vm.info")).append("), ").append(System.getProperty("java.vm.vendor")).append("\n");
String text = builder.toString();
String text = "---- Hello Minecraft! Crash Report ----\n" +
" Version: " + Launcher.VERSION + "\n" +
" Time: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "\n" +
" Thread: " + t.toString() + "\n" +
"\n Content: \n " +
stackTrace + "\n\n" +
"-- System Details --\n" +
" Operating System: " + System.getProperty("os.name") + ' ' + OperatingSystem.SYSTEM_VERSION + "\n" +
" Java Version: " + System.getProperty("java.version") + ", " + System.getProperty("java.vendor") + "\n" +
" Java VM Version: " + System.getProperty("java.vm.name") + " (" + System.getProperty("java.vm.info") + "), " + System.getProperty("java.vm.vendor") + "\n";
Logging.LOG.log(Level.SEVERE, text);
@@ -1,51 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.JFXButton?>
<?import com.jfoenix.controls.JFXProgressBar?>
<?import com.jfoenix.controls.JFXRadioButton?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<?import org.jackhuang.hmcl.ui.FXUtils?>
<fx:root xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
type="StackPane" FXUtils.limitWidth="160" FXUtils.limitHeight="156">
<VBox fx:id="content">
<StackPane fx:id="header" VBox.vgrow="ALWAYS" style="-fx-background-radius: 2 2 0 0; -fx-background-color: rgb(255,255,255,0.87); -fx-padding: 8;">
<HBox StackPane.alignment="TOP_CENTER" alignment="CENTER_RIGHT">
<JFXProgressBar fx:id="pgsSkin" visible="false" />
</HBox>
<VBox style="-fx-padding: 8 8 0 8;">
<Label fx:id="lblUser" style="-fx-font-size: 15;" wrapText="true" textAlignment="JUSTIFY" />
<Label fx:id="lblEmail" style="-fx-font-size: 11; -fx-text-fill: gray;" />
<Label fx:id="lblServer" style="-fx-font-size: 11; -fx-text-fill: gray;" />
<Label fx:id="lblType" style="-fx-font-size: 11; -fx-text-fill: gray;" />
</VBox>
</StackPane>
<StackPane fx:id="body" style="-fx-background-radius: 0 0 2 2; -fx-background-color: rgb(255,255,255,0.87); -fx-padding: 8;" minHeight="40">
<BorderPane>
<left>
<HBox fx:id="buttonPane" spacing="8">
<JFXButton fx:id="btnRefresh" styleClass="toggle-icon4" maxWidth="30" maxHeight="30" minWidth="30" minHeight="30" prefWidth="30" prefHeight="30" />
<JFXButton fx:id="btnDelete" styleClass="toggle-icon4" maxWidth="30" maxHeight="30" minWidth="30" minHeight="30" prefWidth="30" prefHeight="30" />
</HBox>
</left>
<right>
<HBox alignment="CENTER_RIGHT">
<Label fx:id="lblCurrentAccount" text="%account.current" />
<JFXRadioButton fx:id="chkSelected" BorderPane.alignment="CENTER_RIGHT" />
</HBox>
</right>
</BorderPane>
</StackPane>
</VBox>
<StackPane fx:id="icon" StackPane.alignment="TOP_RIGHT" pickOnBounds="false">
<ImageView fx:id="portraitView" StackPane.alignment="CENTER_RIGHT" smooth="false">
<StackPane.margin>
<Insets right="12" />
</StackPane.margin>
</ImageView>
</StackPane>
</fx:root>
@@ -1,82 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import com.jfoenix.controls.*?>
<?import com.jfoenix.validation.RequiredFieldValidator?>
<?import com.jfoenix.controls.JFXButton?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import org.jackhuang.hmcl.ui.construct.FileItem?>
<?import org.jackhuang.hmcl.ui.construct.ComponentList?>
<fx:root xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
<fx:root xmlns:fx="http://javafx.com/fxml"
xmlns="http://javafx.com/javafx"
type="StackPane">
<ScrollPane fx:id="scroll" fitToHeight="true" fitToWidth="true">
<VBox fx:id="rootPane" style="-fx-padding: 20;">
<VBox fx:id="rootPane">
<ComponentList fx:id="componentList" depth="1">
<ComponentList fx:id="componentList" depth="1">
<BorderPane> <!-- Name -->
<left>
<VBox>
<Label text="%account.methods" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</left>
<right>
<VBox>
<Label fx:id="lblType" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</right>
</BorderPane>
<BorderPane> <!-- Name -->
<left>
<VBox>
<Label text="%account.methods" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</left>
<right>
<VBox>
<Label fx:id="lblType" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</right>
</BorderPane>
<BorderPane> <!-- Name -->
<left>
<VBox>
<Label text="%account.character" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</left>
<right>
<VBox>
<Label fx:id="lblCharacter" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</right>
</BorderPane>
<BorderPane> <!-- Name -->
<left>
<VBox>
<Label text="%account.character" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</left>
<right>
<VBox>
<Label fx:id="lblCharacter" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</right>
</BorderPane>
<BorderPane> <!-- Name -->
<left>
<VBox>
<Label text="%account.email" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</left>
<right>
<VBox>
<Label fx:id="lblEmail" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</right>
</BorderPane>
<BorderPane fx:id="paneEmail"> <!-- Name -->
<left>
<VBox>
<Label text="%account.email" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</left>
<right>
<VBox>
<Label fx:id="lblEmail" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</right>
</BorderPane>
<BorderPane fx:id="paneServer"> <!-- Name -->
<left>
<VBox>
<Label text="%account.injector.server" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</left>
<right>
<VBox>
<Label fx:id="lblServer" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</right>
</BorderPane>
</ComponentList>
<BorderPane fx:id="paneServer"> <!-- Name -->
<left>
<VBox>
<Label text="%account.injector.server" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</left>
<right>
<VBox>
<Label fx:id="lblServer" BorderPane.alignment="CENTER_LEFT"/>
</VBox>
</right>
</BorderPane>
</ComponentList>
</VBox>
</ScrollPane>
<BorderPane pickOnBounds="false" style="-fx-padding: 20;">
</VBox>
<BorderPane pickOnBounds="false" style="-fx-padding: 4;">
<left>
<JFXButton BorderPane.alignment="BOTTOM_LEFT" fx:id="btnDelete" onMouseClicked="#onDelete" prefWidth="100" prefHeight="40"
buttonType="RAISED" text="%button.delete" styleClass="jfx-button-raised" />
<JFXButton BorderPane.alignment="BOTTOM_LEFT" fx:id="btnDelete" onMouseClicked="#onDelete"
styleClass="toggle-icon4" maxWidth="30" maxHeight="30" minWidth="30" minHeight="30"
prefWidth="30" prefHeight="30"/>
</left>
<right>
<JFXButton BorderPane.alignment="BOTTOM_RIGHT" fx:id="btnRefresh" prefWidth="100" prefHeight="40"
buttonType="RAISED" text="%button.refresh" styleClass="jfx-button-raised"/>
<JFXButton BorderPane.alignment="BOTTOM_RIGHT" fx:id="btnRefresh" onMouseClicked="#onRefresh"
styleClass="toggle-icon4" maxWidth="30" maxHeight="30" minWidth="30" minHeight="30"
prefWidth="30" prefHeight="30"/>
</right>
</BorderPane>
</fx:root>
+13 -13
View File
@@ -10,23 +10,23 @@
maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
type="StackPane" pickOnBounds="false"
xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1">
<JFXSpinner fx:id="spinner" styleClass="first-spinner" />
<StackPane fx:id="contentPane">
<JFXSpinner fx:id="spinner" styleClass="first-spinner" />
<ScrollPane fitToHeight="true" fitToWidth="true" fx:id="scrollPane" hbarPolicy="NEVER">
<JFXMasonryPane fx:id="masonryPane" HSpacing="3" VSpacing="3" cellWidth="182" cellHeight="160">
</JFXMasonryPane>
</ScrollPane>
<VBox style="-fx-padding: 15;" spacing="15" pickOnBounds="false" alignment="BOTTOM_RIGHT">
<JFXButton prefWidth="40" prefHeight="40" buttonType="RAISED" fx:id="btnRefresh" styleClass="jfx-button-raised-round">
<graphic>
<fx:include source="/assets/svg/refresh.fxml" />
</graphic>
</JFXButton>
<JFXButton prefWidth="40" prefHeight="40" buttonType="RAISED" fx:id="btnAdd" styleClass="jfx-button-raised-round">
<graphic>
<fx:include source="/assets/svg/plus.fxml" />
</graphic>
</JFXButton>
</VBox>
</StackPane>
<VBox style="-fx-padding: 15;" spacing="15" pickOnBounds="false" alignment="BOTTOM_RIGHT">
<JFXButton prefWidth="40" prefHeight="40" buttonType="RAISED" fx:id="btnRefresh" styleClass="jfx-button-raised-round">
<graphic>
<fx:include source="/assets/svg/refresh.fxml" />
</graphic>
</JFXButton>
<JFXButton prefWidth="40" prefHeight="40" buttonType="RAISED" fx:id="btnAdd" styleClass="jfx-button-raised-round">
<graphic>
<fx:include source="/assets/svg/plus.fxml" />
</graphic>
</JFXButton>
</VBox>
</fx:root>
@@ -31,7 +31,7 @@
</left>
<right>
<HBox alignment="CENTER" pickOnBounds="false">
<JFXButton fx:id="btnSettings" maxWidth="40" minWidth="40" prefWidth="40" styleClass="toggle-icon4" onMouseClicked="#onSettings">
<JFXButton fx:id="btnSettings" maxWidth="40" minWidth="40" prefWidth="40" styleClass="toggle-icon4">
<graphic>
<fx:include source="/assets/svg/gear.fxml" />
</graphic>
@@ -5,7 +5,6 @@
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.*?>
<?import org.jackhuang.hmcl.ui.construct.*?>
<?import org.jackhuang.hmcl.ui.*?>
@@ -17,6 +17,8 @@
*/
package org.jackhuang.hmcl.auth;
import org.jackhuang.hmcl.util.ToStringBuilder;
import java.util.Map;
import java.util.UUID;
@@ -64,4 +66,13 @@ public abstract class Account {
public abstract Map<Object, Object> toStorage();
public abstract void clearCache();
@Override
public String toString() {
return new ToStringBuilder(this)
.append("username", getUsername())
.append("character", getCharacter())
.append("uuid", getUUID())
.toString();
}
}
@@ -28,7 +28,7 @@ import org.jackhuang.hmcl.download.optifine.OptiFineVersionList;
*/
public class MojangDownloadProvider implements DownloadProvider {
private boolean isChina;
private final boolean isChina;
public MojangDownloadProvider(boolean isChina) {
this.isChina = isChina;
@@ -47,7 +47,7 @@ public final class ForgeInstallTask extends TaskResult<Version> {
private final DefaultDependencyManager dependencyManager;
private final Version version;
private final File installer = new File("forge-installer.jar").getAbsoluteFile();
private ForgeRemoteVersion remote;
private final ForgeRemoteVersion remote;
private final List<Task> dependents = new LinkedList<>();
private final List<Task> dependencies = new LinkedList<>();
@@ -41,7 +41,7 @@ public final class LiteLoaderInstallTask extends TaskResult<Version> {
private final DefaultDependencyManager dependencyManager;
private final Version version;
private LiteLoaderRemoteVersion remote;
private final LiteLoaderRemoteVersion remote;
private final List<Task> dependents = new LinkedList<>();
private final List<Task> dependencies = new LinkedList<>();
@@ -38,7 +38,7 @@ public final class OptiFineInstallTask extends TaskResult<Version> {
private final DefaultDependencyManager dependencyManager;
private final Version version;
private OptiFineRemoteVersion remote;
private final OptiFineRemoteVersion remote;
private final List<Task> dependents = new LinkedList<>();
private final List<Task> dependencies = new LinkedList<>();
@@ -30,7 +30,7 @@ public class Event {
/**
* The object on which the Event initially occurred.
*/
protected transient Object source;
protected final transient Object source;
/**
* Constructs a prototypical Event.
@@ -62,7 +62,7 @@ public class DefaultGameRepository implements GameRepository {
@Override
public Version getVersion(String id) {
if (!hasVersion(id))
throw new VersionNotFoundException("Version '" + id + "' does not exist.");
throw new VersionNotFoundException("Version '" + id + "' does not exist in " + versions.keySet() + ".");
return versions.get(id);
}
@@ -39,7 +39,7 @@ public final class LibrariesDownloadInfo {
public LibrariesDownloadInfo(LibraryDownloadInfo artifact, Map<String, LibraryDownloadInfo> classifiers) {
this.artifact = artifact;
this.classifiers = new HashMap<>(classifiers);
this.classifiers = classifiers == null ? null : new HashMap<>(classifiers);
}
public LibraryDownloadInfo getArtifact() {
@@ -45,7 +45,7 @@ public final class StringArgument implements Argument {
@Override
public List<String> toString(Map<String, String> keys, Map<String, Boolean> features) {
String res = argument;
Pattern pattern = Pattern.compile("\\$\\{(.*?)\\}");
Pattern pattern = Pattern.compile("\\$\\{(.*?)}");
Matcher m = pattern.matcher(argument);
while (m.find()) {
String entry = m.group();
@@ -44,23 +44,20 @@ import java.util.Objects;
*/
public final class MultiMCModpackInstallTask extends Task {
private final DefaultDependencyManager dependencyManager;
private final File zipFile;
private final MultiMCInstanceConfiguration manifest;
private final String name;
private final File run;
private final DefaultGameRepository repository;
private final List<Task> dependencies = new LinkedList<>();
private final List<Task> dependents = new LinkedList<>();
public MultiMCModpackInstallTask(DefaultDependencyManager dependencyManager, File zipFile, MultiMCInstanceConfiguration manifest, String name) {
this.dependencyManager = dependencyManager;
this.zipFile = zipFile;
this.manifest = manifest;
this.name = name;
this.repository = dependencyManager.getGameRepository();
this.run = repository.getRunDirectory(name);
File run = repository.getRunDirectory(name);
File json = repository.getModpackConfiguration(name);
if (repository.hasVersion(name) && !json.exists())
throw new IllegalArgumentException("Version " + name + " already exists.");
@@ -35,9 +35,7 @@ public final class Schedulers {
private static synchronized ExecutorService getCachedExecutorService() {
if (CACHED_EXECUTOR == null)
CACHED_EXECUTOR = new ThreadPoolExecutor(0, Integer.MAX_VALUE,
60, TimeUnit.SECONDS, new SynchronousQueue<>(), runnable -> {
return Executors.defaultThreadFactory().newThread(runnable);
});
60, TimeUnit.SECONDS, new SynchronousQueue<>(), Executors.defaultThreadFactory());
return CACHED_EXECUTOR;
}
@@ -54,8 +54,8 @@ public enum Log4jLevel {
public boolean lessOrEqual(Log4jLevel level) {
return this.level <= level.level;
}
public static final Pattern MINECRAFT_LOGGER = Pattern.compile("\\[(?<timestamp>[0-9:]+)\\] \\[[^/]+/(?<level>[^\\]]+)\\]");
public static final Pattern MINECRAFT_LOGGER_CATEGORY = Pattern.compile("\\[(?<timestamp>[0-9:]+)\\] \\[[^/]+/(?<level>[^\\]]+)\\] \\[(?<category>[^\\]]+)\\]");
public static final Pattern MINECRAFT_LOGGER = Pattern.compile("\\[(?<timestamp>[0-9:]+)] \\[[^/]+/(?<level>[^]]+)]");
public static final Pattern MINECRAFT_LOGGER_CATEGORY = Pattern.compile("\\[(?<timestamp>[0-9:]+)] \\[[^/]+/(?<level>[^]]+)] \\[(?<category>[^]]+)]");
public static final String JAVA_SYMBOL = "([a-zA-Z_$][a-zA-Z\\d_$]*\\.)+[a-zA-Z_$][a-zA-Z\\d_$]*";
public static Log4jLevel guessLevel(String line) {
@@ -20,7 +20,6 @@ package org.jackhuang.hmcl.util;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.*;