mirror of
https://github.com/PuzzleMC/Puzzle.git
synced 2025-12-16 20:05:09 +01:00
Puzzle 1.5.0 - 1.19.4, Options overhaul, Fixed splash screen
- Port to 1.19.4 - Overhaul the Puzzle Options screen - Categories are now displayed via tabs - Fix #50 (Splash screen logo being pixelated) - Add compatibility with Exordium
This commit is contained in:
@@ -6,19 +6,19 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PuzzleConfig extends MidnightConfig {
|
||||
@Entry public static List<String> disabledIntegrations = new ArrayList<>();
|
||||
@Entry public static boolean enablePuzzleButton = true;
|
||||
@Entry public static boolean debugMessages = false;
|
||||
@Entry(category = "gui", name = "Disabled integrations") public static List<String> disabledIntegrations = new ArrayList<>();
|
||||
@Entry(category = "gui", name = "Enable Puzzle button") public static boolean enablePuzzleButton = true;
|
||||
@Entry(category = "debug", name = "Enable debug messages") public static boolean debugMessages = false;
|
||||
|
||||
@Entry public static boolean checkUpdates = true;
|
||||
@Entry public static boolean showPuzzleInfo = true;
|
||||
@Entry public static boolean resourcepackSplashScreen = true;
|
||||
@Entry public static boolean unlimitedRotations = true;
|
||||
@Entry public static boolean biggerModels = true;
|
||||
@Entry(category = "debug", name = "puzzle.option.check_for_updates") public static boolean checkUpdates = true;
|
||||
@Entry(category = "gui", name = "puzzle.option.show_version_info") public static boolean showPuzzleInfo = true;
|
||||
@Entry(category = "features", name = "puzzle.option.resourcepack_splash_screen") public static boolean resourcepackSplashScreen = true;
|
||||
@Entry(category = "features", name = "puzzle.option.unlimited_model_rotations") public static boolean unlimitedRotations = true;
|
||||
@Entry(category = "features", name = "puzzle.option.bigger_custom_models") 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;
|
||||
@Entry(category = "features", name = "Splash Background Color") public static int backgroundColor = 15675965;
|
||||
@Entry(category = "features", name = "Splash Progress Bar Color") public static int progressBarColor = 16777215;
|
||||
@Entry(category = "features", name = "Splash Progress Bar Background Color") public static int progressBarBackgroundColor = 15675965;
|
||||
@Entry(category = "features", name = "Splash Progress Bar Frame Color") public static int progressFrameColor = 16777215;
|
||||
@Entry(category = "features", name = "puzzle.option.better_splash_screen_blend") public static boolean disableBlend = false;
|
||||
}
|
||||
|
||||
@@ -1,59 +1,45 @@
|
||||
package net.puzzlemc.core.mixin;
|
||||
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.gui.widget.PressableTextWidget;
|
||||
import net.puzzlemc.core.PuzzleCore;
|
||||
import net.puzzlemc.core.config.PuzzleConfig;
|
||||
import net.puzzlemc.core.util.UpdateChecker;
|
||||
import net.minecraft.client.gui.screen.*;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Mixin(TitleScreen.class)
|
||||
public abstract class MixinTitleScreen extends Screen {
|
||||
|
||||
@Shadow @Final private boolean doBackgroundFade;
|
||||
@Shadow private long backgroundFadeStart;
|
||||
private Text puzzleText;
|
||||
private int puzzleTextWidth;
|
||||
private int yOffset;
|
||||
private final String versionText = PuzzleCore.version.replace("+", " for ");
|
||||
|
||||
protected MixinTitleScreen(Text title) {
|
||||
super(title);
|
||||
}
|
||||
@Inject(at = @At("TAIL"), method = "init")
|
||||
private void puzzle$init(CallbackInfo ci) {
|
||||
yOffset = 20;
|
||||
if (FabricLoader.getInstance().isModLoaded("dashloader")) yOffset = yOffset + 10;
|
||||
int yOffset = 20;
|
||||
Text puzzleText;
|
||||
if (UpdateChecker.isUpToDate) {
|
||||
puzzleText = Text.of(PuzzleCore.version);
|
||||
puzzleText = Text.literal(versionText);
|
||||
}
|
||||
else {
|
||||
puzzleText = Text.translatable("").append(Text.of(PuzzleCore.version + " | ")).append(Text.translatable("puzzle.text.update_available"));
|
||||
this.puzzleTextWidth = this.textRenderer.getWidth(puzzleText);
|
||||
puzzleText = Text.literal("").append(Text.of(versionText+" | ")).append(Text.translatable("puzzle.text.update_available"));
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(at = @At("TAIL"), method = "render")
|
||||
private void puzzle$render(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
|
||||
if (PuzzleConfig.showPuzzleInfo) {
|
||||
float f = this.doBackgroundFade ? (float) (Util.getMeasuringTimeMs() - this.backgroundFadeStart) / 1000.0F : 1.0F;
|
||||
float g = this.doBackgroundFade ? MathHelper.clamp(f - 1.0F, 0.0F, 1.0F) : 1.0F;
|
||||
int l = MathHelper.ceil(g * 255.0F) << 24;
|
||||
textRenderer.drawWithShadow(matrices, puzzleText,2,this.height - yOffset, 16777215 | l);
|
||||
if (mouseX > 2 && mouseX < 2 + this.puzzleTextWidth && mouseY > this.height - yOffset && mouseY < this.height - yOffset + 10) {
|
||||
fill(matrices, 2, this.height - yOffset + 9, 2 + this.puzzleTextWidth, this.height - yOffset + 10, 16777215 | l);
|
||||
}
|
||||
PressableTextWidget text = this.addDrawableChild(new PressableTextWidget(2, this.height - 12 - yOffset, this.textRenderer.getWidth(puzzleText), 10, puzzleText, (button) -> {
|
||||
if (Objects.requireNonNull(this.client).options.getChatLinksPrompt().getValue()) {
|
||||
this.client.setScreen(new ConfirmLinkScreen(this::confirmLink, PuzzleCore.updateURL, true));
|
||||
} else {
|
||||
Util.getOperatingSystem().open(PuzzleCore.updateURL);
|
||||
}
|
||||
}, this.textRenderer));
|
||||
if (UpdateChecker.isUpToDate) text.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,16 +49,4 @@ public abstract class MixinTitleScreen extends Screen {
|
||||
}
|
||||
Objects.requireNonNull(this.client).setScreen(this);
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "mouseClicked",cancellable = true)
|
||||
private void puzzle$mouseClicked(double mouseX, double mouseY, int button, CallbackInfoReturnable<Boolean> cir) {
|
||||
if (mouseX > 2 && mouseX < (double)(2 + this.puzzleTextWidth) && mouseY > (double)(this.height - yOffset) && mouseY < (double)this.height - yOffset + 10) {
|
||||
if (Objects.requireNonNull(this.client).options.getChatLinksPrompt().getValue()) {
|
||||
this.client.setScreen(new ConfirmLinkScreen(this::confirmLink, PuzzleCore.updateURL, true));
|
||||
} else {
|
||||
Util.getOperatingSystem().open(PuzzleCore.updateURL);
|
||||
}
|
||||
cir.setReturnValue(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class UpdateChecker {
|
||||
private static final Gson GSON = new Gson();
|
||||
private static final String minecraftVersion = MinecraftClient.getInstance().getGame().getVersion().getId();
|
||||
private static final String minecraftVersion = MinecraftClient.getInstance().getGameVersion();
|
||||
public static final Logger logger = LogManager.getLogger(PuzzleCore.name);
|
||||
|
||||
public static final Type UPDATE_TYPE_TOKEN = new TypeToken<Map<String, String>>(){}.getType();
|
||||
|
||||
Reference in New Issue
Block a user