* Fix #2281 * Use switch instead of Enum.name().toLowerCase(Locale.ENGLISH)
This commit is contained in:
@@ -25,6 +25,7 @@ import javafx.scene.control.ButtonType;
|
|||||||
import javafx.scene.input.Clipboard;
|
import javafx.scene.input.Clipboard;
|
||||||
import javafx.scene.input.DataFormat;
|
import javafx.scene.input.DataFormat;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import org.jackhuang.hmcl.auth.offline.Skin;
|
||||||
import org.jackhuang.hmcl.setting.ConfigHolder;
|
import org.jackhuang.hmcl.setting.ConfigHolder;
|
||||||
import org.jackhuang.hmcl.setting.SambaException;
|
import org.jackhuang.hmcl.setting.SambaException;
|
||||||
import org.jackhuang.hmcl.task.AsyncTaskExecutor;
|
import org.jackhuang.hmcl.task.AsyncTaskExecutor;
|
||||||
@@ -66,6 +67,31 @@ public final class Launcher extends Application {
|
|||||||
|
|
||||||
CookieHandler.setDefault(COOKIE_MANAGER);
|
CookieHandler.setDefault(COOKIE_MANAGER);
|
||||||
|
|
||||||
|
Skin.registerDefaultSkinLoader((type) -> {
|
||||||
|
switch (type) {
|
||||||
|
case ALEX:
|
||||||
|
return Skin.class.getResourceAsStream("/assets/img/skin/alex.png");
|
||||||
|
case ARI:
|
||||||
|
return Skin.class.getResourceAsStream("/assets/img/skin/ari.png");
|
||||||
|
case EFE:
|
||||||
|
return Skin.class.getResourceAsStream("/assets/img/skin/efe.png");
|
||||||
|
case KAI:
|
||||||
|
return Skin.class.getResourceAsStream("/assets/img/skin/kai.png");
|
||||||
|
case MAKENA:
|
||||||
|
return Skin.class.getResourceAsStream("/assets/img/skin/makena.png");
|
||||||
|
case NOOR:
|
||||||
|
return Skin.class.getResourceAsStream("/assets/img/skin/noor.png");
|
||||||
|
case STEVE:
|
||||||
|
return Skin.class.getResourceAsStream("/assets/img/skin/steve.png");
|
||||||
|
case SUNNY:
|
||||||
|
return Skin.class.getResourceAsStream("/assets/img/skin/sunny.png");
|
||||||
|
case ZURI:
|
||||||
|
return Skin.class.getResourceAsStream("/assets/img/skin/zuri.png");
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
LOG.info("JavaFX Version: " + System.getProperty("javafx.runtime.version"));
|
LOG.info("JavaFX Version: " + System.getProperty("javafx.runtime.version"));
|
||||||
try {
|
try {
|
||||||
Object pipeline = Class.forName("com.sun.prism.GraphicsPipeline").getMethod("getPipeline").invoke(null);
|
Object pipeline = Class.forName("com.sun.prism.GraphicsPipeline").getMethod("getPipeline").invoke(null);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import java.util.Collections;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
import static org.jackhuang.hmcl.util.Lang.mapOf;
|
import static org.jackhuang.hmcl.util.Lang.mapOf;
|
||||||
import static org.jackhuang.hmcl.util.Lang.tryCast;
|
import static org.jackhuang.hmcl.util.Lang.tryCast;
|
||||||
@@ -98,6 +99,12 @@ public class Skin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Function<Type, InputStream> defaultSkinLoader = null;
|
||||||
|
|
||||||
|
public static void registerDefaultSkinLoader(Function<Type, InputStream> defaultSkinLoader0) {
|
||||||
|
defaultSkinLoader = defaultSkinLoader0;
|
||||||
|
}
|
||||||
|
|
||||||
private final Type type;
|
private final Type type;
|
||||||
private final String cslApi;
|
private final String cslApi;
|
||||||
private final TextureModel textureModel;
|
private final TextureModel textureModel;
|
||||||
@@ -137,23 +144,18 @@ public class Skin {
|
|||||||
case DEFAULT:
|
case DEFAULT:
|
||||||
return Task.supplyAsync(() -> null);
|
return Task.supplyAsync(() -> null);
|
||||||
case ALEX:
|
case ALEX:
|
||||||
return Task.supplyAsync(() -> new LoadedSkin(TextureModel.ALEX, Texture.loadTexture(Skin.class.getResourceAsStream("/assets/img/skin/alex.png")), null));
|
|
||||||
case ARI:
|
case ARI:
|
||||||
return Task.supplyAsync(() -> new LoadedSkin(TextureModel.STEVE, Texture.loadTexture(Skin.class.getResourceAsStream("/assets/img/skin/ari.png")), null));
|
|
||||||
case EFE:
|
case EFE:
|
||||||
return Task.supplyAsync(() -> new LoadedSkin(TextureModel.ALEX, Texture.loadTexture(Skin.class.getResourceAsStream("/assets/img/skin/efe.png")), null));
|
|
||||||
case KAI:
|
case KAI:
|
||||||
return Task.supplyAsync(() -> new LoadedSkin(TextureModel.STEVE, Texture.loadTexture(Skin.class.getResourceAsStream("/assets/img/skin/kai.png")), null));
|
|
||||||
case MAKENA:
|
case MAKENA:
|
||||||
return Task.supplyAsync(() -> new LoadedSkin(TextureModel.ALEX, Texture.loadTexture(Skin.class.getResourceAsStream("/assets/img/skin/makena.png")), null));
|
|
||||||
case NOOR:
|
case NOOR:
|
||||||
return Task.supplyAsync(() -> new LoadedSkin(TextureModel.ALEX, Texture.loadTexture(Skin.class.getResourceAsStream("/assets/img/skin/noor.png")), null));
|
|
||||||
case STEVE:
|
case STEVE:
|
||||||
return Task.supplyAsync(() -> new LoadedSkin(TextureModel.STEVE, Texture.loadTexture(Skin.class.getResourceAsStream("/assets/img/skin/steve.png")), null));
|
|
||||||
case SUNNY:
|
case SUNNY:
|
||||||
return Task.supplyAsync(() -> new LoadedSkin(TextureModel.STEVE, Texture.loadTexture(Skin.class.getResourceAsStream("/assets/img/skin/sunny.png")), null));
|
|
||||||
case ZURI:
|
case ZURI:
|
||||||
return Task.supplyAsync(() -> new LoadedSkin(TextureModel.STEVE, Texture.loadTexture(Skin.class.getResourceAsStream("/assets/img/skin/zuri.png")), null));
|
if (defaultSkinLoader == null) {
|
||||||
|
return Task.supplyAsync(() -> null);
|
||||||
|
}
|
||||||
|
return Task.supplyAsync(() -> new LoadedSkin(TextureModel.STEVE, Texture.loadTexture(defaultSkinLoader.apply(type)), null));
|
||||||
case LOCAL_FILE:
|
case LOCAL_FILE:
|
||||||
return Task.supplyAsync(() -> {
|
return Task.supplyAsync(() -> {
|
||||||
Texture skin = null, cape = null;
|
Texture skin = null, cape = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user