mirror of
https://github.com/TeamMidnightDust/CustomSplashScreen.git
synced 2025-12-15 23:35:09 +01:00
CustomSplashScreen 2.1.0 - Fix crashes
- Fix crash on game start - Fix compatibility with Puzzle - Further improve boss bar loading bar - Fix custom progress bar (closes #16)
This commit is contained in:
@@ -25,15 +25,15 @@ public class CustomSplashScreenConfig extends MidnightConfig {
|
||||
|
||||
//"Change the color of the background")
|
||||
@Entry(category = colors, isColor = true)
|
||||
public static String backgroundColor = "#EF323D";
|
||||
public static String splashBackgroundColor = "#EF323D";
|
||||
//"Change the color of the progress bar")
|
||||
@Entry(category = colors, isColor = true)
|
||||
public static String progressBarColor = "#FFFFFF";
|
||||
public static String splashProgressBarColor = "#FFFFFF";
|
||||
//"Change the color of the progress bar frame")
|
||||
@Entry(category = colors, isColor = true)
|
||||
public static String progressFrameColor = "#FFFFFF";
|
||||
public static String splashProgressFrameColor = "#FFFFFF";
|
||||
@Entry(category = colors, isColor = true)
|
||||
public static String progressBackgroundColor = "#000000";
|
||||
public static String splashProgressBackgroundColor = "#000000";
|
||||
|
||||
//"Enable/Disable the progress bar background")
|
||||
@Entry(category = loading)
|
||||
@@ -49,6 +49,8 @@ public class CustomSplashScreenConfig extends MidnightConfig {
|
||||
//"Change the style of the boss loading bar")
|
||||
@Entry(category = loading)
|
||||
public static BossBarType bossBarType = BossBarType.NOTCHED_6;
|
||||
@Entry(category = loading, isSlider = true, min = 15, max = 100)
|
||||
public static int bossBarSize = 85;
|
||||
@Entry(category = loading, isSlider = true, min = 1, max = 10)
|
||||
public static int spinningCircleSize = 2;
|
||||
@Entry(category = loading, isSlider = true, min = 1, max = 10)
|
||||
@@ -63,7 +65,7 @@ public class CustomSplashScreenConfig extends MidnightConfig {
|
||||
Mojang, Aspect1to1, Hidden;
|
||||
}
|
||||
public enum ProgressBarMode {
|
||||
Linear, Stretch;
|
||||
Linear, Stretch, Slide;
|
||||
}
|
||||
public enum BossBarColor {
|
||||
MAGENTA, CYAN, RED, LIME, YELLOW, PURPLE, WHITE;
|
||||
|
||||
@@ -18,16 +18,16 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Mixin(value = MidnightConfig.MidnightConfigScreen.class, remap = false)
|
||||
@Mixin(value = MidnightConfig.MidnightConfigScreen.class)
|
||||
public class MixinMidnightConfig extends Screen {
|
||||
@Shadow @Final
|
||||
@Shadow(remap = false) @Final
|
||||
public String modid;
|
||||
|
||||
protected MixinMidnightConfig(Text title) {
|
||||
super(title);
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"),method = "init")
|
||||
@Inject(at = @At("HEAD"), method = "init")
|
||||
protected void init(CallbackInfo ci) {
|
||||
if(this.modid.equals("customsplashscreen")) {
|
||||
this.addDrawableChild(ButtonWidget.builder(Text.literal("Preview"), (button) -> {
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
@@ -34,7 +35,7 @@ import java.util.function.IntSupplier;
|
||||
import static net.minecraft.client.gui.DrawableHelper.drawTexture;
|
||||
import static net.minecraft.client.gui.DrawableHelper.fill;
|
||||
|
||||
@Mixin(SplashOverlay.class)
|
||||
@Mixin(value = SplashOverlay.class, priority = 3000)
|
||||
public abstract class MixinSplashScreen {
|
||||
|
||||
@Shadow @Final static Identifier LOGO;
|
||||
@@ -49,6 +50,7 @@ public abstract class MixinSplashScreen {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Shadow @Final private static IntSupplier BRAND_ARGB;
|
||||
private static final Identifier EMPTY_TEXTURE = new Identifier("customsplashscreen","empty.png");
|
||||
private static final Identifier MOJANG_TEXTURE = new Identifier("customsplashscreen", "wide_logo.png");
|
||||
private static final Identifier ASPECT_1to1_TEXTURE = new Identifier("customsplashscreen", "square_logo.png");
|
||||
@@ -128,28 +130,33 @@ public abstract class MixinSplashScreen {
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
|
||||
|
||||
int overlay = 70 + CustomSplashScreenConfig.bossBarType.ordinal()*10;
|
||||
int width = (int) ((x2 - x1) * (CustomSplashScreenConfig.bossBarSize * 0.01f));
|
||||
int offset = ((x2 - x1) - width) / 2;
|
||||
i = MathHelper.ceil((float)(width - 2) * this.progress);
|
||||
|
||||
drawTexture(matrices, x1, y1 + 1, x2 - x1, (int) ((y2-y1) / 1.4f), 0, color, 182, 5,256, 256);
|
||||
drawTexture(matrices, x1, y1 + 1, i, (int) ((y2-y1) / 1.4f), 0, color+5, (int) (180 * this.progress), 5, 256, 256);
|
||||
drawTexture(matrices, x1 + offset, y1 + 1, width, (int) ((width / 182f) * 5), 0, color, 182, 5,256, 256);
|
||||
drawTexture(matrices, x1 + offset, y1 + 1, i, (int) ((width / 182f) * 5), 0, color+5, (int) (180 * this.progress), 5, 256, 256);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
if (overlay != 120) {
|
||||
drawTexture(matrices, x1, y1 + 1, x2 - x1, (int) ((y2-y1) / 1.4f), 0, overlay, 182, 5,256, 256);
|
||||
drawTexture(matrices, x1 + offset, y1 + 1, width, (int) ((width / 182f) * 5), 0, overlay, 182, 5,256, 256);
|
||||
}
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
// Custom Progress Bar
|
||||
if (CustomSplashScreenConfig.progressBarType == CustomSplashScreenConfig.ProgressBarType.Custom) {
|
||||
int customWidth = CustomSplashScreenConfig.customProgressBarMode == CustomSplashScreenConfig.ProgressBarMode.Linear ? x2 - x1 : i;
|
||||
int regionWidth = CustomSplashScreenConfig.customProgressBarMode == CustomSplashScreenConfig.ProgressBarMode.Stretch ? x2 - x1 : i;
|
||||
int height = (int) (((x2 - x1) / 400f) * 10);
|
||||
int u = CustomSplashScreenConfig.customProgressBarMode.equals(CustomSplashScreenConfig.ProgressBarMode.Slide) ? x2 - x1 - i : 0;
|
||||
if (CustomSplashScreenConfig.progressBarBackground) {
|
||||
RenderSystem.setShaderTexture(0, CUSTOM_PROGRESS_BAR_BACKGROUND_TEXTURE);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
|
||||
drawTexture(matrices, x1, y1, 0, 0, 6, x2 - x1, y2 - y1, 10, x2-x1);
|
||||
drawTexture(matrices, x1, y1, x2 - x1, height, 0, 0, x2 - x1, height, x2 - x1, height);
|
||||
}
|
||||
RenderSystem.setShaderTexture(0, CUSTOM_PROGRESS_BAR_TEXTURE);
|
||||
RenderSystem.setShader(GameRenderer::getPositionTexProgram);
|
||||
drawTexture(matrices, x1, y1, 0, 0, 6, i, y2 - y1, customWidth, 10);
|
||||
drawTexture(matrices, x1, y1, i, height, u, 0, regionWidth, height, x2 - x1, height);
|
||||
}
|
||||
// Spinning Circle Progress Indicator
|
||||
if (CustomSplashScreenConfig.progressBarType == CustomSplashScreenConfig.ProgressBarType.SpinningCircle) {
|
||||
@@ -160,7 +167,7 @@ public abstract class MixinSplashScreen {
|
||||
int m = MathHelper.ceil((1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F)) * 255.0F);
|
||||
int time = (((int) (MidnightColorUtil.hue * 24 * CustomSplashScreenConfig.spinningCircleSpeed))%24)-1;
|
||||
|
||||
int color = withAlpha(MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.progressBarColor).getRGB(), m);
|
||||
int color = withAlpha(MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashProgressBarColor).getRGB(), m);
|
||||
for (int j = 0; j<=CustomSplashScreenConfig.spinningCircleTrail; j++) {
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
@@ -205,11 +212,27 @@ public abstract class MixinSplashScreen {
|
||||
case 23 -> DrawableHelper.fill(matrices, left + 3*blockSize, top + blockSize, left + 2 * blockSize, top + 2*blockSize, color);
|
||||
}
|
||||
}
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/function/IntSupplier;getAsInt()I"))
|
||||
private int css$modifyBackground(IntSupplier instance) { // Set the Background Color to our configured value //
|
||||
return !CustomSplashScreenConfig.backgroundImage ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.backgroundColor).getRGB() | 255 << 24 : 0;
|
||||
// Replaced by the methods below for compatibility with Puzzle
|
||||
// @Redirect(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/function/IntSupplier;getAsInt()I"))
|
||||
// private int css$modifyBackground(IntSupplier instance) { // Set the Background Color to our configured value //
|
||||
// return !CustomSplashScreenConfig.backgroundImage ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.backgroundColor).getRGB() | 255 << 24 : 0;
|
||||
// }
|
||||
@Inject(method = "withAlpha", at = @At("RETURN"), cancellable = true)
|
||||
private static void css$modifyBackgroundColor(int color, int alpha, CallbackInfoReturnable<Integer> cir) {
|
||||
if (color == BRAND_ARGB.getAsInt()) {
|
||||
int configColor = !CustomSplashScreenConfig.backgroundImage ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashBackgroundColor).getRGB() | 255 << 24 : 0;
|
||||
cir.setReturnValue(configColor & 16777215 | alpha << 24);
|
||||
}
|
||||
}
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;blendFunc(II)V", shift = At.Shift.AFTER), remap = false)
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/platform/GlStateManager;_clearColor(FFFF)V"))
|
||||
private void css$clearModifiedColor(float red, float green, float blue, float alpha) {
|
||||
int k = !CustomSplashScreenConfig.backgroundImage ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashBackgroundColor).getRGB() : 0;
|
||||
float m = (float)(k >> 16 & 255) / 255.0F;
|
||||
float n = (float)(k >> 8 & 255) / 255.0F;
|
||||
float o = (float)(k & 255) / 255.0F;
|
||||
GlStateManager._clearColor(m, n, o, 1.0F);
|
||||
}
|
||||
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;blendFunc(II)V", shift = At.Shift.AFTER))
|
||||
private void css$betterBlend(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (!CustomSplashScreenConfig.logoBlend) RenderSystem.defaultBlendFunc();
|
||||
}
|
||||
@@ -219,16 +242,16 @@ public abstract class MixinSplashScreen {
|
||||
float f = this.reloadCompleteTime > -1L ? (float) (Util.getMeasuringTimeMs() - this.reloadCompleteTime) / 1000.0F : -1.0F;
|
||||
int m = MathHelper.ceil((1.0F - MathHelper.clamp(f - 1.0F, 0.0F, 1.0F)) * 255.0F);
|
||||
RenderSystem.disableBlend();
|
||||
fill(matrices, minX, minY, maxX, maxY, withAlpha(MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.progressBackgroundColor).getRGB(), m));
|
||||
fill(matrices, minX, minY, maxX, maxY, withAlpha(MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashProgressBackgroundColor).getRGB(), m));
|
||||
}
|
||||
}
|
||||
|
||||
@ModifyArg(method = "renderProgressBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/SplashOverlay;fill(Lnet/minecraft/client/util/math/MatrixStack;IIIII)V"), index = 5)
|
||||
private int css$modifyProgressFrame(int color) { // Set the Progress Bar Frame Color to our configured value //
|
||||
return CustomSplashScreenConfig.progressBarType.equals(CustomSplashScreenConfig.ProgressBarType.Vanilla) ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.progressFrameColor).getRGB() | 255 << 24 : 0;
|
||||
return CustomSplashScreenConfig.progressBarType.equals(CustomSplashScreenConfig.ProgressBarType.Vanilla) ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashProgressFrameColor).getRGB() | 255 << 24 : 0;
|
||||
}
|
||||
@ModifyArg(method = "renderProgressBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/SplashOverlay;fill(Lnet/minecraft/client/util/math/MatrixStack;IIIII)V", ordinal = 0), index = 5)
|
||||
private int css$modifyProgressColor(int color) { // Set the Progress Bar Color to our configured value //
|
||||
return CustomSplashScreenConfig.progressBarType.equals(CustomSplashScreenConfig.ProgressBarType.Vanilla) ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.progressBarColor).getRGB() | 255 << 24 : 0;
|
||||
return CustomSplashScreenConfig.progressBarType.equals(CustomSplashScreenConfig.ProgressBarType.Vanilla) ? MidnightColorUtil.hex2Rgb(CustomSplashScreenConfig.splashProgressBarColor).getRGB() | 255 << 24 : 0;
|
||||
}
|
||||
}
|
||||
@@ -16,10 +16,10 @@
|
||||
"customsplashscreen.midnightconfig.enum.LogoStyle.Hidden":"Hidden",
|
||||
"customsplashscreen.midnightconfig.logoBlend":"Use Blending on Logo",
|
||||
"customsplashscreen.midnightconfig.backgroundImage":"Background Image",
|
||||
"customsplashscreen.midnightconfig.backgroundColor":"Background Color",
|
||||
"customsplashscreen.midnightconfig.progressBarColor":"Progress Bar Color",
|
||||
"customsplashscreen.midnightconfig.progressFrameColor":"Progress Bar Frame Color",
|
||||
"customsplashscreen.midnightconfig.progressBackgroundColor":"Progress Bar Background Color",
|
||||
"customsplashscreen.midnightconfig.splashBackgroundColor":"Background Color",
|
||||
"customsplashscreen.midnightconfig.splashProgressBarColor":"Progress Bar Color",
|
||||
"customsplashscreen.midnightconfig.splashProgressFrameColor":"Progress Bar Frame Color",
|
||||
"customsplashscreen.midnightconfig.splashProgressBackgroundColor":"Progress Bar Background Color",
|
||||
"customsplashscreen.midnightconfig.customProgressBarMode":"Custom Progress Bar Mode",
|
||||
"customsplashscreen.midnightconfig.enum.ProgressBarMode.Linear":"Linear",
|
||||
"customsplashscreen.midnightconfig.enum.ProgressBarMode.Stretch":"Stretch",
|
||||
@@ -39,5 +39,6 @@
|
||||
"customsplashscreen.midnightconfig.enum.BossBarType.NOTCHED_6":"6 Notches",
|
||||
"customsplashscreen.midnightconfig.enum.BossBarType.NOTCHED_10":"10 Notches",
|
||||
"customsplashscreen.midnightconfig.enum.BossBarType.NOTCHED_12":"12 Notches",
|
||||
"customsplashscreen.midnightconfig.enum.BossBarType.NOTCHED_20":"20 Notches"
|
||||
"customsplashscreen.midnightconfig.enum.BossBarType.NOTCHED_20":"20 Notches",
|
||||
"customsplashscreen.midnightconfig.bossBarSize":"Boss Bar Size"
|
||||
}
|
||||
Reference in New Issue
Block a user