Skip to content

Commit

Permalink
Puzzle 1.3.3 - Better Splashscreen
Browse files Browse the repository at this point in the history
- Only apply puzzle-splashscreen when needed (fixes #34, fixes #8)
  • Loading branch information
Motschen committed Jun 12, 2022
1 parent e8e563a commit 87ebfdd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.gradle.jvmargs=-Xmx1G
loader_version=0.14.6

# Mod Properties
mod_version = 1.3.2
mod_version = 1.3.3
maven_group = net.puzzlemc
archives_base_name = puzzle

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public class PuzzleConfig extends MidnightConfig {
@Entry public static boolean checkUpdates = true;
@Entry public static boolean showPuzzleInfo = true;
@Entry public static boolean resourcepackSplashScreen = true;
@Entry public static boolean betterSplashScreenBlend = true;
@Entry public static boolean unlimitedRotations = true;
@Entry public static boolean biggerModels = true;

@Entry public static int backgroundColor = 15675965;
@Entry public static int progressBarColor = 16777215;
@Entry public static int progressBarBackgroundColor = 15675965;
@Entry public static int progressFrameColor = 16777215;
@Entry public static boolean disableBlend = false;
}
4 changes: 0 additions & 4 deletions puzzle-gui/src/main/java/net/puzzlemc/gui/PuzzleClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ public void onInitializeClient() {
PuzzleSplashScreen.resetColors();
MinecraftClient.getInstance().getTextureManager().registerTexture(PuzzleSplashScreen.LOGO, new PuzzleSplashScreen.LogoTexture());
}));
PuzzleApi.addToResourceOptions(new PuzzleWidget(Text.translatable("puzzle.option.better_splash_screen_blend"), (button) -> button.setMessage(PuzzleConfig.betterSplashScreenBlend ? YES : NO), (button) -> {
PuzzleConfig.betterSplashScreenBlend = !PuzzleConfig.betterSplashScreenBlend;
PuzzleConfig.write(id);
}));
}
if (FabricLoader.getInstance().isModLoaded("puzzle-models") && !PuzzleConfig.disabledIntegrations.contains("puzzle-models")) {
PuzzleApi.addToResourceOptions(new PuzzleWidget(Text.translatable("puzzle.option.unlimited_model_rotations"), (button) -> button.setMessage(PuzzleConfig.unlimitedRotations ? YES : NO), (button) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static void resetColors() {
PuzzleConfig.progressBarColor = 16777215;
PuzzleConfig.progressBarBackgroundColor = 15675965;
PuzzleConfig.progressFrameColor = 16777215;
PuzzleConfig.disableBlend = false;
PuzzleConfig.write("puzzle");
}

Expand Down Expand Up @@ -89,9 +90,11 @@ public void reload(ResourceManager manager) {
if (properties.get("screen.loading.outline") != null) {
PuzzleConfig.progressFrameColor = MidnightColorUtil.hex2Rgb(properties.get("screen.loading.outline").toString()).getRGB();
}
if (properties.get("screen.loading") != null) {
PuzzleConfig.write("puzzle");
if (properties.get("screen.loading.blend") != null) {
PuzzleConfig.disableBlend = properties.get("screen.loading.blend").toString().equals("off");
PuzzleConfig.progressFrameColor = MidnightColorUtil.hex2Rgb(properties.get("screen.loading.outline").toString()).getRGB();
}
PuzzleConfig.write("puzzle");
} catch (Exception e) {
LogManager.getLogger("Puzzle").error("Error occurred while loading color.properties " + id.toString(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public abstract class MixinSplashScreen extends Overlay {
@Shadow @Final static Identifier LOGO;
@Shadow private long reloadCompleteTime;

@Shadow
private static int withAlpha(int color, int alpha) {
return 0;
}

@Inject(method = "init(Lnet/minecraft/client/MinecraftClient;)V", at = @At("TAIL"))
private static void puzzle$initSplashscreen(MinecraftClient client, CallbackInfo ci) { // Load our custom textures at game start //
if (PuzzleConfig.resourcepackSplashScreen && PuzzleSplashScreen.LOGO_TEXTURE.toFile().exists()) {
Expand All @@ -39,11 +44,11 @@ public abstract class MixinSplashScreen extends Overlay {
}
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/function/IntSupplier;getAsInt()I"))
private int puzzle$modifyBackground(IntSupplier instance) { // Set the Progress Bar Frame Color to our configured value //
return PuzzleConfig.backgroundColor | 255 << 24;
return (!PuzzleConfig.resourcepackSplashScreen || PuzzleConfig.progressBarBackgroundColor == 15675965) ? instance.getAsInt() : PuzzleConfig.backgroundColor | 255 << 24;
}
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;blendFunc(II)V", shift = At.Shift.AFTER), remap = false)
private void puzzle$betterBlend(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (PuzzleConfig.betterSplashScreenBlend) RenderSystem.defaultBlendFunc();
if (PuzzleConfig.disableBlend) RenderSystem.defaultBlendFunc();
}
@Inject(method = "renderProgressBar", at = @At("HEAD"))
private void puzzle$addProgressBarBackground(MatrixStack matrices, int minX, int minY, int maxX, int maxY, float opacity, CallbackInfo ci) {
Expand All @@ -65,14 +70,10 @@ public abstract class MixinSplashScreen extends Overlay {

@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 puzzle$modifyProgressFrame(int color) { // Set the Progress Bar Frame Color to our configured value //
return PuzzleConfig.progressFrameColor | 255 << 24;
return (!PuzzleConfig.resourcepackSplashScreen || PuzzleConfig.progressFrameColor == 16777215) ? color : PuzzleConfig.progressFrameColor | 255 << 24;
}
@ModifyArg(method = "renderProgressBar", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/SplashOverlay;fill(Lnet/minecraft/client/util/math/MatrixStack;IIIII)V", ordinal = 4), index = 5)
private int puzzle$modifyProgressColor(int color) { // Set the Progress Bar Color to our configured value //
return PuzzleConfig.progressBarColor | 255 << 24;
return (!PuzzleConfig.resourcepackSplashScreen || PuzzleConfig.progressBarColor == 16777215) ? color : PuzzleConfig.progressBarColor | 255 << 24;
}
private static int withAlpha(int color, int alpha) {
return color & 0xFFFFFF | alpha << 24;
}

}

0 comments on commit 87ebfdd

Please sign in to comment.