Load gif background (#1877)

This commit is contained in:
Glavo 2022-11-26 20:33:46 +08:00 committed by GitHub
parent fda6f75333
commit 8e28c2487f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 9 deletions

View File

@ -163,10 +163,10 @@ public class DecoratorController {
config().backgroundImageUrlProperty()));
}
private final Image defaultBackground = newImage("/assets/img/background.jpg");
private Image defaultBackground;
/**
* Load background image from bg/, background.png, background.jpg
* Load background image from bg/, background.png, background.jpg, background.gif
*/
private Image loadDefaultBackgroundImage() {
Optional<Image> image = randomImageIn(Paths.get("bg"));
@ -176,7 +176,15 @@ public class DecoratorController {
if (!image.isPresent()) {
image = tryLoadImage(Paths.get("background.jpg"));
}
return image.orElse(defaultBackground);
if (!image.isPresent()) {
image = tryLoadImage(Paths.get("background.gif"));
}
return image.orElseGet(() -> {
if (defaultBackground == null)
defaultBackground = newImage("/assets/img/background.jpg");
return defaultBackground;
});
}
private Optional<Image> randomImageIn(Path imageDir) {
@ -190,7 +198,7 @@ public class DecoratorController {
.filter(Files::isReadable)
.filter(it -> {
String ext = getExtension(it).toLowerCase();
return ext.equals("png") || ext.equals("jpg");
return ext.equals("png") || ext.equals("jpg") || ext.equals("gif");
})
.collect(toList());
} catch (IOException e) {

View File

@ -137,6 +137,10 @@ public final class ExportWizardProvider implements WizardProvider {
if (background_jpg.isFile())
zip.putFile(background_jpg, "background.jpg");
File background_gif = new File("background.gif").getAbsoluteFile();
if (background_gif.isFile())
zip.putFile(background_gif, "background.gif");
zip.putFile(launcherJar.get(), launcherJar.get().getFileName().toString());
}
}

View File

@ -687,7 +687,7 @@ launcher.agreement.hint=You must agree to the EULA to use this software.
launcher.background=Background Image
launcher.background.choose=Choose a Background Image
launcher.background.classic=Classic
launcher.background.default=Default (or background.png/jpg, or images under bg folder)
launcher.background.default=Default (or background.png/jpg/gif, or images under bg folder)
launcher.background.network=From URL
launcher.background.translucent=Translucent
launcher.cache_directory=Cache Directory

View File

@ -659,7 +659,7 @@ launcher.agreement.hint=Debe aceptar el EULA para utilizar este software.
launcher.background=Imagen de fondo
launcher.background.choose=Elige una imagen de fondo
launcher.background.classic=Clásico
launcher.background.default=Por defecto (o background.png/jpg, o imágenes en la carpeta bg)
launcher.background.default=Por defecto (o background.png/jpg/gif, o imágenes en la carpeta bg)
launcher.background.network=Desde la URL
launcher.background.translucent=Translúcido
launcher.cache_directory=Directorio de la caché

View File

@ -504,7 +504,7 @@ launcher.agreement.hint=このソフトウェアを使用するには、EULAに
launcher.background=背景画像
launcher.background.classic=クラシック
launcher.background.choose=背景画像ファイルを選択してください
launcher.background.default=標準(ランチャーと同じディレクトリにある background.png/jpg と bg フォルダから自動的に画像を取得します。)
launcher.background.default=標準(ランチャーと同じディレクトリにある background.png/jpg/gif と bg フォルダから自動的に画像を取得します。)
launcher.background.network=ネットワーク
launcher.background.translucent=半透明
launcher.cache_directory=キャッシュ用のディレクトリ

View File

@ -534,7 +534,7 @@ launcher.agreement.hint=同意本軟體的用戶協議與免責聲明以使用
launcher.background=背景位址
launcher.background.choose=選擇背景路徑
launcher.background.classic=經典
launcher.background.default=預設(自動尋找啟動器同目錄下的 background.png/jpg 及 bg 資料夾內的圖片)
launcher.background.default=預設(自動尋找啟動器同目錄下的 background.png/jpg/gif 及 bg 資料夾內的圖片)
launcher.background.network=網路
launcher.background.translucent=半透明
launcher.cache_directory=檔案下載快取目錄

View File

@ -536,7 +536,7 @@ launcher.agreement.hint=同意本软件的用户协议与免责声明以使用
launcher.background=背景地址
launcher.background.choose=选择背景路径
launcher.background.classic=经典
launcher.background.default=默认(自动检索启动器同目录下的 background.png/jpg 及 bg 文件夹内的图片)
launcher.background.default=默认(自动检索启动器同目录下的 background.png/jpg/gif 及 bg 文件夹内的图片)
launcher.background.network=网络
launcher.background.translucent=半透明
launcher.cache_directory=文件下载缓存目录