mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-01-24 14:34:15 +08:00
代码清理 (#2072)
* Remove unused methods * newRaisedButton * update * update * update * update * update * toLowerCase and toUpperCase * update * update
This commit is contained in:
parent
3198daa60a
commit
ec6637728a
@ -420,7 +420,7 @@ public class HMCLGameRepository extends DefaultGameRepository {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS &&
|
if (OperatingSystem.CURRENT_OS == OperatingSystem.WINDOWS &&
|
||||||
FORBIDDEN_VERSION_IDS.contains(id.toLowerCase()))
|
FORBIDDEN_VERSION_IDS.contains(id.toLowerCase(Locale.ROOT)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return OperatingSystem.isNameValid(id);
|
return OperatingSystem.isNameValid(id);
|
||||||
|
@ -817,9 +817,12 @@ public final class LauncherHelper {
|
|||||||
Platform.runLater(() -> logWindow.logLine(filteredLog, level));
|
Platform.runLater(() -> logWindow.logLine(filteredLog, level));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lwjgl && (!detectWindow || filteredLog.toLowerCase().contains("lwjgl version") || filteredLog.toLowerCase().contains("lwjgl openal"))) {
|
if (!lwjgl) {
|
||||||
lwjgl = true;
|
String lowerCaseLog = filteredLog.toLowerCase(Locale.ROOT);
|
||||||
finishLaunch();
|
if (!detectWindow || lowerCaseLog.contains("lwjgl version") || lowerCaseLog.contains("lwjgl openal")) {
|
||||||
|
lwjgl = true;
|
||||||
|
finishLaunch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ public class Theme {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getColorDisplayName(Color c) {
|
public static String getColorDisplayName(Color c) {
|
||||||
return c != null ? String.format("#%02x%02x%02x", Math.round(c.getRed() * 255.0D), Math.round(c.getGreen() * 255.0D), Math.round(c.getBlue() * 255.0D)).toUpperCase() : null;
|
return c != null ? String.format("#%02x%02x%02x", Math.round(c.getRed() * 255.0D), Math.round(c.getGreen() * 255.0D), Math.round(c.getBlue() * 255.0D)).toUpperCase(Locale.ROOT) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final ObjectBinding<Color> BLACK_FILL = Bindings.createObjectBinding(() -> BLACK);
|
private static final ObjectBinding<Color> BLACK_FILL = Bindings.createObjectBinding(() -> BLACK);
|
||||||
@ -217,7 +217,7 @@ public class Theme {
|
|||||||
public static class TypeAdapter extends com.google.gson.TypeAdapter<Theme> {
|
public static class TypeAdapter extends com.google.gson.TypeAdapter<Theme> {
|
||||||
@Override
|
@Override
|
||||||
public void write(JsonWriter out, Theme value) throws IOException {
|
public void write(JsonWriter out, Theme value) throws IOException {
|
||||||
out.value(value.getName().toLowerCase());
|
out.value(value.getName().toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -68,7 +68,6 @@ import javax.xml.parsers.DocumentBuilder;
|
|||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
@ -671,6 +670,13 @@ public final class FXUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static JFXButton newRaisedButton(String text) {
|
||||||
|
JFXButton button = new JFXButton(text);
|
||||||
|
button.getStyleClass().add("jfx-button-raised");
|
||||||
|
button.setButtonType(JFXButton.ButtonType.RAISED);
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
public static void applyDragListener(Node node, FileFilter filter, Consumer<List<File>> callback) {
|
public static void applyDragListener(Node node, FileFilter filter, Consumer<List<File>> callback) {
|
||||||
applyDragListener(node, filter, callback, null);
|
applyDragListener(node, filter, callback, null);
|
||||||
}
|
}
|
||||||
@ -775,38 +781,6 @@ public final class FXUtils {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Based on https://stackoverflow.com/a/57552025
|
|
||||||
// Fix #874: Use it instead of SwingFXUtils.toFXImage
|
|
||||||
public static WritableImage toFXImage(BufferedImage image) {
|
|
||||||
final int iw = image.getWidth();
|
|
||||||
final int ih = image.getHeight();
|
|
||||||
|
|
||||||
WritableImage wr = new WritableImage(iw, ih);
|
|
||||||
PixelWriter pw = wr.getPixelWriter();
|
|
||||||
|
|
||||||
for (int x = 0; x < iw; x++) {
|
|
||||||
for (int y = 0; y < ih; y++) {
|
|
||||||
pw.setArgb(x, y, image.getRGB(x, y));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return wr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BufferedImage fromFXImage(Image image) {
|
|
||||||
final int iw = (int) image.getWidth();
|
|
||||||
final int ih = (int) image.getHeight();
|
|
||||||
|
|
||||||
PixelReader pr = image.getPixelReader();
|
|
||||||
BufferedImage bufferedImage = new BufferedImage(iw, ih, BufferedImage.TYPE_INT_ARGB);
|
|
||||||
for (int x = 0; x < iw; x++) {
|
|
||||||
for (int y = 0; y < ih; y++) {
|
|
||||||
bufferedImage.setRGB(x, y, pr.getArgb(x, y));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return bufferedImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void copyText(String text) {
|
public static void copyText(String text) {
|
||||||
ClipboardContent content = new ClipboardContent();
|
ClipboardContent content = new ClipboardContent();
|
||||||
content.putString(text);
|
content.putString(text);
|
||||||
|
@ -354,14 +354,10 @@ public class GameCrashWindow extends Stage {
|
|||||||
|
|
||||||
HBox toolBar = new HBox();
|
HBox toolBar = new HBox();
|
||||||
{
|
{
|
||||||
JFXButton exportGameCrashInfoButton = new JFXButton(i18n("logwindow.export_game_crash_logs"));
|
JFXButton exportGameCrashInfoButton = FXUtils.newRaisedButton(i18n("logwindow.export_game_crash_logs"));
|
||||||
exportGameCrashInfoButton.setButtonType(JFXButton.ButtonType.RAISED);
|
|
||||||
exportGameCrashInfoButton.getStyleClass().add("jfx-button-raised");
|
|
||||||
exportGameCrashInfoButton.setOnMouseClicked(e -> exportGameCrashInfo());
|
exportGameCrashInfoButton.setOnMouseClicked(e -> exportGameCrashInfo());
|
||||||
|
|
||||||
JFXButton logButton = new JFXButton(i18n("logwindow.title"));
|
JFXButton logButton = FXUtils.newRaisedButton(i18n("logwindow.title"));
|
||||||
logButton.setButtonType(JFXButton.ButtonType.RAISED);
|
|
||||||
logButton.getStyleClass().add("jfx-button-raised");
|
|
||||||
logButton.setOnMouseClicked(e -> showLogWindow());
|
logButton.setOnMouseClicked(e -> showLogWindow());
|
||||||
|
|
||||||
toolBar.setPadding(new Insets(8));
|
toolBar.setPadding(new Insets(8));
|
||||||
|
@ -31,6 +31,8 @@ import org.jackhuang.hmcl.ui.Controllers;
|
|||||||
import org.jackhuang.hmcl.ui.FXUtils;
|
import org.jackhuang.hmcl.ui.FXUtils;
|
||||||
import org.jackhuang.hmcl.ui.SVG;
|
import org.jackhuang.hmcl.ui.SVG;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class HintPane extends VBox {
|
public class HintPane extends VBox {
|
||||||
private final Text label = new Text();
|
private final Text label = new Text();
|
||||||
private final StringProperty text = new SimpleStringProperty(this, "text");
|
private final StringProperty text = new SimpleStringProperty(this, "text");
|
||||||
@ -42,7 +44,7 @@ public class HintPane extends VBox {
|
|||||||
|
|
||||||
public HintPane(MessageDialogPane.MessageType type) {
|
public HintPane(MessageDialogPane.MessageType type) {
|
||||||
setFillWidth(true);
|
setFillWidth(true);
|
||||||
getStyleClass().addAll("hint", type.name().toLowerCase());
|
getStyleClass().addAll("hint", type.name().toLowerCase(Locale.ROOT));
|
||||||
HBox hbox = new HBox();
|
HBox hbox = new HBox();
|
||||||
hbox.setAlignment(Pos.CENTER_LEFT);
|
hbox.setAlignment(Pos.CENTER_LEFT);
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@ -197,7 +198,7 @@ public class DecoratorController {
|
|||||||
candidates = stream
|
candidates = stream
|
||||||
.filter(Files::isReadable)
|
.filter(Files::isReadable)
|
||||||
.filter(it -> {
|
.filter(it -> {
|
||||||
String ext = getExtension(it).toLowerCase();
|
String ext = getExtension(it).toLowerCase(Locale.ROOT);
|
||||||
return ext.equals("png") || ext.equals("jpg") || ext.equals("gif");
|
return ext.equals("png") || ext.equals("jpg") || ext.equals("gif");
|
||||||
})
|
})
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
|
@ -82,9 +82,7 @@ public class DownloadPage extends DecoratorAnimatedPage implements DecoratorPage
|
|||||||
modpackTab.setNodeSupplier(loadVersionFor(() -> {
|
modpackTab.setNodeSupplier(loadVersionFor(() -> {
|
||||||
ModpackDownloadListPage page = new ModpackDownloadListPage(Versions::downloadModpackImpl, false);
|
ModpackDownloadListPage page = new ModpackDownloadListPage(Versions::downloadModpackImpl, false);
|
||||||
|
|
||||||
JFXButton installLocalModpackButton = new JFXButton(i18n("install.modpack"));
|
JFXButton installLocalModpackButton = FXUtils.newRaisedButton(i18n("install.modpack"));
|
||||||
installLocalModpackButton.setButtonType(JFXButton.ButtonType.RAISED);
|
|
||||||
installLocalModpackButton.getStyleClass().add("jfx-button-raised");
|
|
||||||
installLocalModpackButton.setOnAction(e -> Versions.importModpack());
|
installLocalModpackButton.setOnAction(e -> Versions.importModpack());
|
||||||
|
|
||||||
page.getActions().add(installLocalModpackButton);
|
page.getActions().add(installLocalModpackButton);
|
||||||
|
@ -34,6 +34,7 @@ import org.jackhuang.hmcl.download.DownloadProvider;
|
|||||||
import org.jackhuang.hmcl.download.RemoteVersion;
|
import org.jackhuang.hmcl.download.RemoteVersion;
|
||||||
import org.jackhuang.hmcl.game.HMCLGameRepository;
|
import org.jackhuang.hmcl.game.HMCLGameRepository;
|
||||||
import org.jackhuang.hmcl.ui.Controllers;
|
import org.jackhuang.hmcl.ui.Controllers;
|
||||||
|
import org.jackhuang.hmcl.ui.FXUtils;
|
||||||
import org.jackhuang.hmcl.ui.InstallerItem;
|
import org.jackhuang.hmcl.ui.InstallerItem;
|
||||||
import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
|
import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
|
||||||
import org.jackhuang.hmcl.ui.construct.RequiredValidator;
|
import org.jackhuang.hmcl.ui.construct.RequiredValidator;
|
||||||
@ -162,10 +163,8 @@ public class InstallersPage extends Control implements WizardPage {
|
|||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
JFXButton installButton = new JFXButton(i18n("button.install"));
|
JFXButton installButton = FXUtils.newRaisedButton(i18n("button.install"));
|
||||||
installButton.disableProperty().bind(control.installable.not());
|
installButton.disableProperty().bind(control.installable.not());
|
||||||
installButton.getStyleClass().add("jfx-button-raised");
|
|
||||||
installButton.setButtonType(JFXButton.ButtonType.RAISED);
|
|
||||||
installButton.setPrefWidth(100);
|
installButton.setPrefWidth(100);
|
||||||
installButton.setPrefHeight(40);
|
installButton.setPrefHeight(40);
|
||||||
installButton.setOnMouseClicked(e -> control.onInstall());
|
installButton.setOnMouseClicked(e -> control.onInstall());
|
||||||
|
@ -92,9 +92,7 @@ public abstract class ModpackPage extends SpinnerPane implements WizardPage {
|
|||||||
btnDescription.setOnAction(e -> onDescribe());
|
btnDescription.setOnAction(e -> onDescribe());
|
||||||
descriptionPane.setLeft(btnDescription);
|
descriptionPane.setLeft(btnDescription);
|
||||||
|
|
||||||
btnInstall = new JFXButton(i18n("button.install"));
|
btnInstall = FXUtils.newRaisedButton(i18n("button.install"));
|
||||||
btnInstall.getStyleClass().add("jfx-button-raised");
|
|
||||||
btnInstall.setButtonType(JFXButton.ButtonType.RAISED);
|
|
||||||
btnInstall.setOnAction(e -> onInstall());
|
btnInstall.setOnAction(e -> onInstall());
|
||||||
btnInstall.disableProperty().bind(createBooleanBinding(() -> !txtModpackName.validate(), txtModpackName.textProperty()));
|
btnInstall.disableProperty().bind(createBooleanBinding(() -> !txtModpackName.validate(), txtModpackName.textProperty()));
|
||||||
descriptionPane.setRight(btnInstall);
|
descriptionPane.setRight(btnInstall);
|
||||||
|
@ -29,6 +29,7 @@ import javafx.scene.layout.BorderPane;
|
|||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import org.jackhuang.hmcl.mod.ModAdviser;
|
import org.jackhuang.hmcl.mod.ModAdviser;
|
||||||
import org.jackhuang.hmcl.setting.Profile;
|
import org.jackhuang.hmcl.setting.Profile;
|
||||||
|
import org.jackhuang.hmcl.ui.FXUtils;
|
||||||
import org.jackhuang.hmcl.ui.construct.NoneMultipleSelectionModel;
|
import org.jackhuang.hmcl.ui.construct.NoneMultipleSelectionModel;
|
||||||
import org.jackhuang.hmcl.ui.wizard.WizardController;
|
import org.jackhuang.hmcl.ui.wizard.WizardController;
|
||||||
import org.jackhuang.hmcl.ui.wizard.WizardPage;
|
import org.jackhuang.hmcl.ui.wizard.WizardPage;
|
||||||
@ -69,10 +70,8 @@ public final class ModpackFileSelectionPage extends BorderPane implements Wizard
|
|||||||
nextPane.setPadding(new Insets(16, 16, 16, 0));
|
nextPane.setPadding(new Insets(16, 16, 16, 0));
|
||||||
nextPane.setAlignment(Pos.CENTER_RIGHT);
|
nextPane.setAlignment(Pos.CENTER_RIGHT);
|
||||||
{
|
{
|
||||||
JFXButton btnNext = new JFXButton(i18n("wizard.next"));
|
JFXButton btnNext = FXUtils.newRaisedButton(i18n("wizard.next"));
|
||||||
btnNext.getStyleClass().add("jfx-button-raised");
|
|
||||||
btnNext.setPrefSize(100, 40);
|
btnNext.setPrefSize(100, 40);
|
||||||
btnNext.setButtonType(JFXButton.ButtonType.RAISED);
|
|
||||||
btnNext.setOnAction(e -> onNext());
|
btnNext.setOnAction(e -> onNext());
|
||||||
|
|
||||||
nextPane.getChildren().setAll(btnNext);
|
nextPane.getChildren().setAll(btnNext);
|
||||||
|
@ -377,13 +377,10 @@ public final class ModpackInfoPage extends Control implements WizardPage {
|
|||||||
hbox.setAlignment(Pos.CENTER_RIGHT);
|
hbox.setAlignment(Pos.CENTER_RIGHT);
|
||||||
borderPane.setBottom(hbox);
|
borderPane.setBottom(hbox);
|
||||||
|
|
||||||
JFXButton nextButton = new JFXButton();
|
JFXButton nextButton = FXUtils.newRaisedButton(i18n("wizard.next"));
|
||||||
nextButton.onMouseClickedProperty().bind(skinnable.next);
|
nextButton.onMouseClickedProperty().bind(skinnable.next);
|
||||||
nextButton.setPrefWidth(100);
|
nextButton.setPrefWidth(100);
|
||||||
nextButton.setPrefHeight(40);
|
nextButton.setPrefHeight(40);
|
||||||
nextButton.setButtonType(JFXButton.ButtonType.RAISED);
|
|
||||||
nextButton.setText(i18n("wizard.next"));
|
|
||||||
nextButton.getStyleClass().add("jfx-button-raised");
|
|
||||||
nextButton.disableProperty().bind(
|
nextButton.disableProperty().bind(
|
||||||
// Disable nextButton if any text of JFXTextFields in validatingFields does not fulfill
|
// Disable nextButton if any text of JFXTextFields in validatingFields does not fulfill
|
||||||
// our requirement.
|
// our requirement.
|
||||||
|
@ -50,6 +50,7 @@ import java.io.File;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.jackhuang.hmcl.ui.FXUtils.runInFX;
|
import static org.jackhuang.hmcl.ui.FXUtils.runInFX;
|
||||||
@ -172,13 +173,13 @@ public class RootPage extends DecoratorAnimatedPage implements DecoratorPage {
|
|||||||
|
|
||||||
// the left sidebar
|
// the left sidebar
|
||||||
AdvancedListBox sideBar = new AdvancedListBox()
|
AdvancedListBox sideBar = new AdvancedListBox()
|
||||||
.startCategory(i18n("account").toUpperCase())
|
.startCategory(i18n("account").toUpperCase(Locale.ROOT))
|
||||||
.add(accountListItem)
|
.add(accountListItem)
|
||||||
.startCategory(i18n("version").toUpperCase())
|
.startCategory(i18n("version").toUpperCase(Locale.ROOT))
|
||||||
.add(gameListItem)
|
.add(gameListItem)
|
||||||
.add(gameItem)
|
.add(gameItem)
|
||||||
.add(downloadItem)
|
.add(downloadItem)
|
||||||
.startCategory(i18n("settings.launcher.general").toUpperCase())
|
.startCategory(i18n("settings.launcher.general").toUpperCase(Locale.ROOT))
|
||||||
.add(multiplayerItem)
|
.add(multiplayerItem)
|
||||||
.add(launcherSettingsItem);
|
.add(launcherSettingsItem);
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ import javafx.scene.layout.StackPane;
|
|||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import org.jackhuang.hmcl.setting.Profile;
|
import org.jackhuang.hmcl.setting.Profile;
|
||||||
import org.jackhuang.hmcl.setting.Profiles;
|
import org.jackhuang.hmcl.setting.Profiles;
|
||||||
|
import org.jackhuang.hmcl.ui.FXUtils;
|
||||||
import org.jackhuang.hmcl.ui.construct.ComponentList;
|
import org.jackhuang.hmcl.ui.construct.ComponentList;
|
||||||
import org.jackhuang.hmcl.ui.construct.FileItem;
|
import org.jackhuang.hmcl.ui.construct.FileItem;
|
||||||
import org.jackhuang.hmcl.ui.construct.OptionToggleButton;
|
import org.jackhuang.hmcl.ui.construct.OptionToggleButton;
|
||||||
@ -133,12 +134,10 @@ public final class ProfilePage extends BorderPane implements DecoratorPage {
|
|||||||
savePane.setStyle("-fx-padding: 20;");
|
savePane.setStyle("-fx-padding: 20;");
|
||||||
StackPane.setAlignment(savePane, Pos.BOTTOM_RIGHT);
|
StackPane.setAlignment(savePane, Pos.BOTTOM_RIGHT);
|
||||||
{
|
{
|
||||||
JFXButton saveButton = new JFXButton(i18n("button.save"));
|
JFXButton saveButton = FXUtils.newRaisedButton(i18n("button.save"));
|
||||||
savePane.setRight(saveButton);
|
savePane.setRight(saveButton);
|
||||||
BorderPane.setAlignment(savePane, Pos.BOTTOM_RIGHT);
|
BorderPane.setAlignment(savePane, Pos.BOTTOM_RIGHT);
|
||||||
StackPane.setAlignment(saveButton, Pos.BOTTOM_RIGHT);
|
StackPane.setAlignment(saveButton, Pos.BOTTOM_RIGHT);
|
||||||
saveButton.getStyleClass().add("jfx-button-raised");
|
|
||||||
saveButton.setButtonType(JFXButton.ButtonType.RAISED);
|
|
||||||
saveButton.setPrefSize(100, 40);
|
saveButton.setPrefSize(100, 40);
|
||||||
saveButton.setOnAction(e -> onSave());
|
saveButton.setOnAction(e -> onSave());
|
||||||
saveButton.disableProperty().bind(Bindings.createBooleanBinding(
|
saveButton.disableProperty().bind(Bindings.createBooleanBinding(
|
||||||
|
@ -334,10 +334,7 @@ public class DownloadListPage extends Control implements DecoratorPage, VersionP
|
|||||||
sortComboBox.getSelectionModel().select(0);
|
sortComboBox.getSelectionModel().select(0);
|
||||||
searchPane.addRow(rowIndex++, new Label(i18n("mods.category")), categoryStackPane, new Label(i18n("search.sort")), sortStackPane);
|
searchPane.addRow(rowIndex++, new Label(i18n("mods.category")), categoryStackPane, new Label(i18n("search.sort")), sortStackPane);
|
||||||
|
|
||||||
JFXButton searchButton = new JFXButton();
|
JFXButton searchButton = FXUtils.newRaisedButton(i18n("search"));
|
||||||
searchButton.setText(i18n("search"));
|
|
||||||
searchButton.getStyleClass().add("jfx-button-raised");
|
|
||||||
searchButton.setButtonType(JFXButton.ButtonType.RAISED);
|
|
||||||
ObservableList<Node> last = FXCollections.observableArrayList(searchButton);
|
ObservableList<Node> last = FXCollections.observableArrayList(searchButton);
|
||||||
HBox searchBox = new HBox(8);
|
HBox searchBox = new HBox(8);
|
||||||
actions.appendList(control.actions);
|
actions.appendList(control.actions);
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
package org.jackhuang.hmcl.ui.versions;
|
package org.jackhuang.hmcl.ui.versions;
|
||||||
|
|
||||||
import com.jfoenix.controls.JFXButton;
|
import com.jfoenix.controls.JFXButton;
|
||||||
import com.jfoenix.controls.JFXListView;
|
|
||||||
import javafx.beans.property.*;
|
import javafx.beans.property.*;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
@ -30,30 +29,24 @@ import javafx.scene.control.TableView;
|
|||||||
import javafx.scene.control.cell.CheckBoxTableCell;
|
import javafx.scene.control.cell.CheckBoxTableCell;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import org.apache.commons.lang3.mutable.MutableObject;
|
|
||||||
import org.jackhuang.hmcl.mod.LocalModFile;
|
import org.jackhuang.hmcl.mod.LocalModFile;
|
||||||
import org.jackhuang.hmcl.mod.ModManager;
|
import org.jackhuang.hmcl.mod.ModManager;
|
||||||
import org.jackhuang.hmcl.mod.RemoteMod;
|
import org.jackhuang.hmcl.mod.RemoteMod;
|
||||||
import org.jackhuang.hmcl.mod.curse.CurseAddon;
|
|
||||||
import org.jackhuang.hmcl.mod.modrinth.ModrinthRemoteModRepository;
|
|
||||||
import org.jackhuang.hmcl.task.FileDownloadTask;
|
import org.jackhuang.hmcl.task.FileDownloadTask;
|
||||||
import org.jackhuang.hmcl.task.Schedulers;
|
import org.jackhuang.hmcl.task.Schedulers;
|
||||||
import org.jackhuang.hmcl.task.Task;
|
import org.jackhuang.hmcl.task.Task;
|
||||||
import org.jackhuang.hmcl.ui.Controllers;
|
import org.jackhuang.hmcl.ui.Controllers;
|
||||||
import org.jackhuang.hmcl.ui.construct.MDListCell;
|
import org.jackhuang.hmcl.ui.FXUtils;
|
||||||
import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
|
import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
|
||||||
import org.jackhuang.hmcl.ui.construct.PageCloseEvent;
|
import org.jackhuang.hmcl.ui.construct.PageCloseEvent;
|
||||||
import org.jackhuang.hmcl.ui.construct.TwoLineListItem;
|
|
||||||
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
|
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
|
||||||
import org.jackhuang.hmcl.util.Pair;
|
import org.jackhuang.hmcl.util.Pair;
|
||||||
import org.jackhuang.hmcl.util.TaskCancellationAction;
|
import org.jackhuang.hmcl.util.TaskCancellationAction;
|
||||||
import org.jackhuang.hmcl.util.i18n.I18n;
|
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -107,14 +100,10 @@ public class ModUpdatesPage extends BorderPane implements DecoratorPage {
|
|||||||
actions.setPadding(new Insets(8));
|
actions.setPadding(new Insets(8));
|
||||||
actions.setAlignment(Pos.CENTER_RIGHT);
|
actions.setAlignment(Pos.CENTER_RIGHT);
|
||||||
|
|
||||||
JFXButton nextButton = new JFXButton(i18n("mods.check_updates.update"));
|
JFXButton nextButton = FXUtils.newRaisedButton(i18n("mods.check_updates.update"));
|
||||||
nextButton.getStyleClass().add("jfx-button-raised");
|
|
||||||
nextButton.setButtonType(JFXButton.ButtonType.RAISED);
|
|
||||||
nextButton.setOnAction(e -> updateMods());
|
nextButton.setOnAction(e -> updateMods());
|
||||||
|
|
||||||
JFXButton cancelButton = new JFXButton(i18n("button.cancel"));
|
JFXButton cancelButton = FXUtils.newRaisedButton(i18n("button.cancel"));
|
||||||
cancelButton.getStyleClass().add("jfx-button-raised");
|
|
||||||
cancelButton.setButtonType(JFXButton.ButtonType.RAISED);
|
|
||||||
cancelButton.setOnAction(e -> fireEvent(new PageCloseEvent()));
|
cancelButton.setOnAction(e -> fireEvent(new PageCloseEvent()));
|
||||||
onEscPressed(this, cancelButton::fire);
|
onEscPressed(this, cancelButton::fire);
|
||||||
|
|
||||||
@ -156,31 +145,6 @@ public class ModUpdatesPage extends BorderPane implements DecoratorPage {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class ModUpdateCell extends MDListCell<LocalModFile.ModUpdate> {
|
|
||||||
TwoLineListItem content = new TwoLineListItem();
|
|
||||||
|
|
||||||
public ModUpdateCell(JFXListView<LocalModFile.ModUpdate> listView, MutableObject<Object> lastCell) {
|
|
||||||
super(listView, lastCell);
|
|
||||||
|
|
||||||
getContainer().getChildren().setAll(content);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void updateControl(LocalModFile.ModUpdate item, boolean empty) {
|
|
||||||
if (empty) return;
|
|
||||||
ModTranslations.Mod mod = ModTranslations.MOD.getModById(item.getLocalMod().getId());
|
|
||||||
content.setTitle(mod != null && I18n.getCurrentLocale().getLocale() == Locale.CHINA ? mod.getDisplayName() : item.getCurrentVersion().getName());
|
|
||||||
content.setSubtitle(item.getLocalMod().getFileName());
|
|
||||||
content.getTags().setAll();
|
|
||||||
|
|
||||||
if (item.getCurrentVersion().getSelf() instanceof CurseAddon.LatestFile) {
|
|
||||||
content.getTags().add("Curseforge");
|
|
||||||
} else if (item.getCurrentVersion().getSelf() instanceof ModrinthRemoteModRepository.ProjectVersion) {
|
|
||||||
content.getTags().add("Modrinth");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final class ModUpdateObject {
|
private static final class ModUpdateObject {
|
||||||
final LocalModFile.ModUpdate data;
|
final LocalModFile.ModUpdate data;
|
||||||
final BooleanProperty enabled = new SimpleBooleanProperty();
|
final BooleanProperty enabled = new SimpleBooleanProperty();
|
||||||
|
@ -53,6 +53,7 @@ import java.nio.file.Path;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -180,11 +181,8 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
|||||||
enableSpecificCheckBox.setText(i18n("settings.type.special.enable"));
|
enableSpecificCheckBox.setText(i18n("settings.type.special.enable"));
|
||||||
BorderPane.setAlignment(enableSpecificCheckBox, Pos.CENTER_RIGHT);
|
BorderPane.setAlignment(enableSpecificCheckBox, Pos.CENTER_RIGHT);
|
||||||
|
|
||||||
JFXButton editGlobalSettingsButton = new JFXButton();
|
JFXButton editGlobalSettingsButton = FXUtils.newRaisedButton(i18n("settings.type.global.edit"));
|
||||||
settingsTypePane.setRight(editGlobalSettingsButton);
|
settingsTypePane.setRight(editGlobalSettingsButton);
|
||||||
editGlobalSettingsButton.setText(i18n("settings.type.global.edit"));
|
|
||||||
editGlobalSettingsButton.getStyleClass().add("jfx-button-raised");
|
|
||||||
editGlobalSettingsButton.setButtonType(JFXButton.ButtonType.RAISED);
|
|
||||||
editGlobalSettingsButton.disableProperty().bind(enableSpecificCheckBox.selectedProperty());
|
editGlobalSettingsButton.disableProperty().bind(enableSpecificCheckBox.selectedProperty());
|
||||||
BorderPane.setAlignment(editGlobalSettingsButton, Pos.CENTER_RIGHT);
|
BorderPane.setAlignment(editGlobalSettingsButton, Pos.CENTER_RIGHT);
|
||||||
editGlobalSettingsButton.setOnMouseClicked(e -> editGlobalSettings());
|
editGlobalSettingsButton.setOnMouseClicked(e -> editGlobalSettings());
|
||||||
@ -546,10 +544,10 @@ public final class VersionSettingsPage extends StackPane implements DecoratorPag
|
|||||||
addEventHandler(Navigator.NavigationEvent.NAVIGATED, this::onDecoratorPageNavigating);
|
addEventHandler(Navigator.NavigationEvent.NAVIGATED, this::onDecoratorPageNavigating);
|
||||||
|
|
||||||
cboLauncherVisibility.getItems().setAll(LauncherVisibility.values());
|
cboLauncherVisibility.getItems().setAll(LauncherVisibility.values());
|
||||||
cboLauncherVisibility.setConverter(stringConverter(e -> i18n("settings.advanced.launcher_visibility." + e.name().toLowerCase())));
|
cboLauncherVisibility.setConverter(stringConverter(e -> i18n("settings.advanced.launcher_visibility." + e.name().toLowerCase(Locale.ROOT))));
|
||||||
|
|
||||||
cboProcessPriority.getItems().setAll(ProcessPriority.values());
|
cboProcessPriority.getItems().setAll(ProcessPriority.values());
|
||||||
cboProcessPriority.setConverter(stringConverter(e -> i18n("settings.advanced.process_priority." + e.name().toLowerCase())));
|
cboProcessPriority.setConverter(stringConverter(e -> i18n("settings.advanced.process_priority." + e.name().toLowerCase(Locale.ROOT))));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
|
@ -80,11 +80,9 @@ public class WorldExportPageSkin extends SkinBase<WorldExportPage> {
|
|||||||
|
|
||||||
container.getChildren().add(list);
|
container.getChildren().add(list);
|
||||||
|
|
||||||
JFXButton btnExport = new JFXButton(i18n("button.export"));
|
JFXButton btnExport = FXUtils.newRaisedButton(i18n("button.export"));
|
||||||
btnExport.disableProperty().bind(Bindings.createBooleanBinding(() -> txtWorldName.getText().isEmpty() || Files.exists(Paths.get(fileItem.getPath())),
|
btnExport.disableProperty().bind(Bindings.createBooleanBinding(() -> txtWorldName.getText().isEmpty() || Files.exists(Paths.get(fileItem.getPath())),
|
||||||
txtWorldName.textProperty().isEmpty(), fileItem.pathProperty()));
|
txtWorldName.textProperty().isEmpty(), fileItem.pathProperty()));
|
||||||
btnExport.setButtonType(JFXButton.ButtonType.RAISED);
|
|
||||||
btnExport.getStyleClass().add("jfx-button-raised");
|
|
||||||
btnExport.setOnMouseClicked(e -> skinnable.export());
|
btnExport.setOnMouseClicked(e -> skinnable.export());
|
||||||
HBox bottom = new HBox();
|
HBox bottom = new HBox();
|
||||||
bottom.setAlignment(Pos.CENTER_RIGHT);
|
bottom.setAlignment(Pos.CENTER_RIGHT);
|
||||||
|
@ -74,7 +74,7 @@ public final class Locales {
|
|||||||
|
|
||||||
public static SupportedLocale getLocaleByName(String name) {
|
public static SupportedLocale getLocaleByName(String name) {
|
||||||
if (name == null) return DEFAULT;
|
if (name == null) return DEFAULT;
|
||||||
switch (name.toLowerCase()) {
|
switch (name.toLowerCase(Locale.ROOT)) {
|
||||||
case "en":
|
case "en":
|
||||||
return EN;
|
return EN;
|
||||||
case "zh":
|
case "zh":
|
||||||
|
@ -187,7 +187,7 @@ public class AuthlibInjectorAccount extends YggdrasilAccount {
|
|||||||
return emptySet();
|
return emptySet();
|
||||||
Set<TextureType> result = EnumSet.noneOf(TextureType.class);
|
Set<TextureType> result = EnumSet.noneOf(TextureType.class);
|
||||||
for (String val : prop.split(",")) {
|
for (String val : prop.split(",")) {
|
||||||
val = val.toUpperCase();
|
val = val.toUpperCase(Locale.ROOT);
|
||||||
TextureType parsed;
|
TextureType parsed;
|
||||||
try {
|
try {
|
||||||
parsed = TextureType.valueOf(val);
|
parsed = TextureType.valueOf(val);
|
||||||
|
@ -29,6 +29,7 @@ import java.lang.reflect.Type;
|
|||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@ -87,7 +88,7 @@ public class AuthlibInjectorServer implements Observable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String addHttpsIfMissing(String url) {
|
private static String addHttpsIfMissing(String url) {
|
||||||
String lowercased = url.toLowerCase();
|
String lowercased = url.toLowerCase(Locale.ROOT);
|
||||||
if (!lowercased.startsWith("http://") && !lowercased.startsWith("https://")) {
|
if (!lowercased.startsWith("http://") && !lowercased.startsWith("https://")) {
|
||||||
url = "https://" + url;
|
url = "https://" + url;
|
||||||
}
|
}
|
||||||
|
@ -266,7 +266,7 @@ public class FileDownloadTask extends FetchTask<Void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final IntegrityCheckHandler ZIP_INTEGRITY_CHECK_HANDLER = (filePath, destinationPath) -> {
|
public static final IntegrityCheckHandler ZIP_INTEGRITY_CHECK_HANDLER = (filePath, destinationPath) -> {
|
||||||
String ext = FileUtils.getExtension(destinationPath).toLowerCase();
|
String ext = FileUtils.getExtension(destinationPath).toLowerCase(Locale.ROOT);
|
||||||
if (ext.equals("zip") || ext.equals("jar")) {
|
if (ext.equals("zip") || ext.equals("jar")) {
|
||||||
try (FileSystem ignored = CompressingUtils.createReadOnlyZipFileSystem(filePath)) {
|
try (FileSystem ignored = CompressingUtils.createReadOnlyZipFileSystem(filePath)) {
|
||||||
// test for zip format
|
// test for zip format
|
||||||
|
@ -181,16 +181,19 @@ public final class StringUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean containsOne(Collection<String> patterns, String... targets) {
|
public static boolean containsOne(Collection<String> patterns, String... targets) {
|
||||||
for (String pattern : patterns)
|
for (String pattern : patterns) {
|
||||||
|
String lowerPattern = pattern.toLowerCase(Locale.ROOT);
|
||||||
for (String target : targets)
|
for (String target : targets)
|
||||||
if (pattern.toLowerCase().contains(target.toLowerCase()))
|
if (lowerPattern.contains(target.toLowerCase(Locale.ROOT)))
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean containsOne(String pattern, String... targets) {
|
public static boolean containsOne(String pattern, String... targets) {
|
||||||
|
String lowerPattern = pattern.toLowerCase(Locale.ROOT);
|
||||||
for (String target : targets)
|
for (String target : targets)
|
||||||
if (pattern.toLowerCase().contains(target.toLowerCase()))
|
if (lowerPattern.contains(target.toLowerCase(Locale.ROOT)))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -63,12 +63,12 @@ public final class LowerCaseEnumTypeAdapterFactory implements TypeAdapterFactory
|
|||||||
reader.nextNull();
|
reader.nextNull();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return lowercaseToConstant.get(reader.nextString().toLowerCase());
|
return lowercaseToConstant.get(reader.nextString().toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String toLowercase(Object o) {
|
private static String toLowercase(Object o) {
|
||||||
return o.toString().toLowerCase(Locale.US);
|
return o.toString().toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,9 +311,9 @@ public enum OperatingSystem {
|
|||||||
int dot = name.indexOf('.');
|
int dot = name.indexOf('.');
|
||||||
// on windows, filename suffixes are not relevant to name validity
|
// on windows, filename suffixes are not relevant to name validity
|
||||||
String basename = dot == -1 ? name : name.substring(0, dot);
|
String basename = dot == -1 ? name : name.substring(0, dot);
|
||||||
if (Arrays.binarySearch(INVALID_RESOURCE_BASENAMES, basename.toLowerCase()) >= 0)
|
if (Arrays.binarySearch(INVALID_RESOURCE_BASENAMES, basename.toLowerCase(Locale.ROOT)) >= 0)
|
||||||
return false;
|
return false;
|
||||||
if (Arrays.binarySearch(INVALID_RESOURCE_FULLNAMES, name.toLowerCase()) >= 0)
|
if (Arrays.binarySearch(INVALID_RESOURCE_FULLNAMES, name.toLowerCase(Locale.ROOT)) >= 0)
|
||||||
return false;
|
return false;
|
||||||
if (INVALID_RESOURCE_CHARACTERS.matcher(name).find())
|
if (INVALID_RESOURCE_CHARACTERS.matcher(name).find())
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user