导出整合包时将启动器配置集中存放在 .hmcl 文件夹中 (#3930)
This commit is contained in:
@@ -40,6 +40,10 @@ import static org.jackhuang.hmcl.util.logging.Logger.LOG;
|
|||||||
*/
|
*/
|
||||||
public final class FontManager {
|
public final class FontManager {
|
||||||
|
|
||||||
|
public static final String[] FONT_EXTENSIONS = {
|
||||||
|
"ttf", "otf", "woff"
|
||||||
|
};
|
||||||
|
|
||||||
public static final double DEFAULT_FONT_SIZE = 12.0f;
|
public static final double DEFAULT_FONT_SIZE = 12.0f;
|
||||||
|
|
||||||
private static final Lazy<Font> DEFAULT_FONT = new Lazy<>(() -> {
|
private static final Lazy<Font> DEFAULT_FONT = new Lazy<>(() -> {
|
||||||
@@ -92,10 +96,8 @@ public final class FontManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Font tryLoadDefaultFont(Path dir) {
|
private static Font tryLoadDefaultFont(Path dir) {
|
||||||
String[] fileNames = {"font.ttf", "font.otf", "font.woff"};
|
for (String extension : FONT_EXTENSIONS) {
|
||||||
|
Path path = dir.resolve("font." + extension);
|
||||||
for (String fileName : fileNames) {
|
|
||||||
Path path = dir.resolve(fileName);
|
|
||||||
if (Files.isRegularFile(path)) {
|
if (Files.isRegularFile(path)) {
|
||||||
try {
|
try {
|
||||||
Font font = Font.loadFont(path.toUri().toURL().toExternalForm(), DEFAULT_FONT_SIZE);
|
Font font = Font.loadFont(path.toUri().toURL().toExternalForm(), DEFAULT_FONT_SIZE);
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
package org.jackhuang.hmcl.ui.export;
|
package org.jackhuang.hmcl.ui.export;
|
||||||
|
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
|
import org.jackhuang.hmcl.Metadata;
|
||||||
import org.jackhuang.hmcl.mod.ModAdviser;
|
import org.jackhuang.hmcl.mod.ModAdviser;
|
||||||
import org.jackhuang.hmcl.mod.ModpackExportInfo;
|
import org.jackhuang.hmcl.mod.ModpackExportInfo;
|
||||||
import org.jackhuang.hmcl.mod.mcbbs.McbbsModpackExportTask;
|
import org.jackhuang.hmcl.mod.mcbbs.McbbsModpackExportTask;
|
||||||
@@ -25,7 +26,7 @@ import org.jackhuang.hmcl.mod.multimc.MultiMCInstanceConfiguration;
|
|||||||
import org.jackhuang.hmcl.mod.multimc.MultiMCModpackExportTask;
|
import org.jackhuang.hmcl.mod.multimc.MultiMCModpackExportTask;
|
||||||
import org.jackhuang.hmcl.mod.server.ServerModpackExportTask;
|
import org.jackhuang.hmcl.mod.server.ServerModpackExportTask;
|
||||||
import org.jackhuang.hmcl.setting.Config;
|
import org.jackhuang.hmcl.setting.Config;
|
||||||
import org.jackhuang.hmcl.setting.ConfigHolder;
|
import org.jackhuang.hmcl.setting.FontManager;
|
||||||
import org.jackhuang.hmcl.setting.Profile;
|
import org.jackhuang.hmcl.setting.Profile;
|
||||||
import org.jackhuang.hmcl.setting.VersionSetting;
|
import org.jackhuang.hmcl.setting.VersionSetting;
|
||||||
import org.jackhuang.hmcl.task.Task;
|
import org.jackhuang.hmcl.task.Task;
|
||||||
@@ -123,19 +124,31 @@ public final class ExportWizardProvider implements WizardProvider {
|
|||||||
exported.setPreferredLoginType(config().getPreferredLoginType());
|
exported.setPreferredLoginType(config().getPreferredLoginType());
|
||||||
exported.getAuthlibInjectorServers().setAll(config().getAuthlibInjectorServers());
|
exported.getAuthlibInjectorServers().setAll(config().getAuthlibInjectorServers());
|
||||||
|
|
||||||
zip.putTextFile(exported.toJson(), ConfigHolder.CONFIG_FILENAME);
|
zip.putTextFile(exported.toJson(), ".hmcl/hmcl.json");
|
||||||
zip.putFile(tempModpack, "modpack.zip");
|
zip.putFile(tempModpack, "modpack.zip");
|
||||||
|
|
||||||
File bg = new File("bg").getAbsoluteFile();
|
Path bg = Metadata.HMCL_CURRENT_DIRECTORY.resolve("bg");
|
||||||
if (bg.isDirectory())
|
if (!Files.isDirectory(bg))
|
||||||
zip.putDirectory(bg.toPath(), "bg");
|
bg = Metadata.CURRENT_DIRECTORY.resolve("bg");
|
||||||
|
if (Files.isDirectory(bg))
|
||||||
|
zip.putDirectory(bg, ".hmcl/bg");
|
||||||
|
|
||||||
for (String extension : FXUtils.IMAGE_EXTENSIONS) {
|
for (String extension : FXUtils.IMAGE_EXTENSIONS) {
|
||||||
String fileName = "background." + extension;
|
String fileName = "background." + extension;
|
||||||
|
Path background = Metadata.HMCL_CURRENT_DIRECTORY.resolve(fileName);
|
||||||
|
if (!Files.isRegularFile(background))
|
||||||
|
background = Metadata.CURRENT_DIRECTORY.resolve(fileName);
|
||||||
|
if (Files.isRegularFile(background))
|
||||||
|
zip.putFile(background, ".hmcl/" + fileName);
|
||||||
|
}
|
||||||
|
|
||||||
File background = new File(fileName).getAbsoluteFile();
|
for (String extension : FontManager.FONT_EXTENSIONS) {
|
||||||
if (background.isFile())
|
String fileName = "font." + extension;
|
||||||
zip.putFile(background, "background.png");
|
Path font = Metadata.HMCL_CURRENT_DIRECTORY.resolve(fileName);
|
||||||
|
if (!Files.isRegularFile(font))
|
||||||
|
font = Metadata.CURRENT_DIRECTORY.resolve(fileName);
|
||||||
|
if (Files.isRegularFile(font))
|
||||||
|
zip.putFile(font, ".hmcl/" + fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
zip.putFile(launcherJar, launcherJar.getFileName().toString());
|
zip.putFile(launcherJar, launcherJar.getFileName().toString());
|
||||||
|
|||||||
Reference in New Issue
Block a user