feat(ui): support translucent background.
Fix no background when network image url is wrong. Closes #1116.
This commit is contained in:
@@ -21,5 +21,6 @@ public enum EnumBackgroundImage {
|
||||
DEFAULT,
|
||||
CUSTOM,
|
||||
CLASSIC,
|
||||
NETWORK
|
||||
NETWORK,
|
||||
TRANSLUCENT
|
||||
}
|
||||
|
||||
@@ -24,11 +24,13 @@ import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.input.DragEvent;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.stage.Stage;
|
||||
import org.jackhuang.hmcl.Launcher;
|
||||
import org.jackhuang.hmcl.auth.authlibinjector.AuthlibInjectorDnD;
|
||||
@@ -43,6 +45,7 @@ import org.jackhuang.hmcl.ui.construct.Navigator;
|
||||
import org.jackhuang.hmcl.ui.construct.StackContainerPane;
|
||||
import org.jackhuang.hmcl.ui.wizard.Refreshable;
|
||||
import org.jackhuang.hmcl.ui.wizard.WizardProvider;
|
||||
import org.jackhuang.hmcl.util.io.NetworkUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
@@ -140,9 +143,15 @@ public class DecoratorController {
|
||||
.orElse(null);
|
||||
}
|
||||
if (config().getBackgroundImageType() == EnumBackgroundImage.NETWORK) {
|
||||
image = new Image(config().getBackgroundImageUrl(), true);
|
||||
if (!NetworkUtils.isURL(config().getBackgroundImageUrl())) {
|
||||
image = loadDefaultBackgroundImage();
|
||||
} else {
|
||||
image = new Image(config().getBackgroundImageUrl(), true);
|
||||
}
|
||||
} else if (config().getBackgroundImageType() == EnumBackgroundImage.CLASSIC) {
|
||||
image = newImage("/assets/img/background-classic.jpg");
|
||||
} else if (config().getBackgroundImageType() == EnumBackgroundImage.TRANSLUCENT) {
|
||||
return new Background(new BackgroundFill(new Color(1, 1, 1, 0.5), CornerRadii.EMPTY, Insets.EMPTY));
|
||||
}
|
||||
if (image == null) {
|
||||
image = loadDefaultBackgroundImage();
|
||||
|
||||
@@ -102,6 +102,7 @@ public class PersonalizationPage extends StackPane {
|
||||
backgroundItem.loadChildren(Arrays.asList(
|
||||
new MultiFileItem.Option<>(i18n("launcher.background.default"), EnumBackgroundImage.DEFAULT),
|
||||
new MultiFileItem.Option<>(i18n("launcher.background.classic"), EnumBackgroundImage.CLASSIC),
|
||||
new MultiFileItem.Option<>(i18n("launcher.background.translucent"), EnumBackgroundImage.TRANSLUCENT),
|
||||
new MultiFileItem.FileOption<>(i18n("settings.custom"), EnumBackgroundImage.CUSTOM)
|
||||
.setChooserTitle(i18n("launcher.background.choose"))
|
||||
.bindBidirectional(config().backgroundImageProperty()),
|
||||
|
||||
@@ -490,6 +490,7 @@ launcher.background.classic=Classic
|
||||
launcher.background.choose=Choose a background image file
|
||||
launcher.background.default=Standard
|
||||
launcher.background.network=Network
|
||||
launcher.background.translucent=Translucent
|
||||
launcher.cache_directory=Directory for caching
|
||||
launcher.cache_directory.clean=Clear
|
||||
launcher.cache_directory.choose=Choose the directory for caching
|
||||
|
||||
@@ -490,6 +490,7 @@ launcher.background.choose=選擇背景路徑
|
||||
launcher.background.classic=經典
|
||||
launcher.background.default=預設(自動尋找啟動器同目錄下的 background.png/jpg 及 bg 資料夾內的圖片)
|
||||
launcher.background.network=網路
|
||||
launcher.background.translucent=半透明
|
||||
launcher.cache_directory=檔案下載快取目錄
|
||||
launcher.cache_directory.clean=清理
|
||||
launcher.cache_directory.choose=選擇檔案下載快取目錄
|
||||
|
||||
@@ -490,6 +490,7 @@ launcher.background.choose=选择背景路径
|
||||
launcher.background.classic=经典
|
||||
launcher.background.default=默认(自动检索启动器同目录下的 background.png/jpg 及 bg 文件夹内的图片)
|
||||
launcher.background.network=网络
|
||||
launcher.background.translucent=半透明
|
||||
launcher.cache_directory=文件下载缓存目录
|
||||
launcher.cache_directory.clean=清理
|
||||
launcher.cache_directory.choose=选择文件下载缓存目录
|
||||
|
||||
Reference in New Issue
Block a user