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