Skip to content

Commit

Permalink
Puzzle 1.5.0 - 1.19.4, Options overhaul, Fixed splash screen
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Motschen committed Mar 15, 2023
1 parent 12cdcba commit b979d5a
Show file tree
Hide file tree
Showing 24 changed files with 227 additions and 245 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Based on https://github.com/OnyxStudios/Cardinal-Components-API/blob/1.17/build.gradle
plugins {
id "fabric-loom" version "0.12-SNAPSHOT" apply false
id "fabric-loom" version "1.1-SNAPSHOT" apply false
id "com.matthewprenger.cursegradle" version "1.4.0"
id "maven-publish"
id "java-library"
Expand Down Expand Up @@ -134,6 +134,7 @@ dependencies {
modImplementation ("maven.modrinth:entitytexturefeatures:${project.entitytexturefeatures_version}")
modImplementation ("maven.modrinth:cem:${project.cem_version}")
modImplementation "com.github.Lortseam.completeconfig:base:${project.complete_config_version}"
modImplementation ("maven.modrinth:exordium:${project.exordium_version}")

modImplementation("org.aperlambda:lambdajcommon:1.8.1") {
exclude group: 'com.google.code.gson'
Expand Down
19 changes: 10 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,34 @@ org.gradle.jvmargs=-Xmx4G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.5
loader_version=0.14.12
minecraft_version=1.19.4-rc2
yarn_mappings=1.19.4-rc2+build.1
loader_version=0.14.17

# Mod Properties
mod_version = 1.4.2-1.19.3
mod_version = 1.5.0+1.19.4
maven_group = net.puzzlemc
archives_base_name = puzzle

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.70.0+1.19.3
mod_menu_version = 5.0.2
fabric_version=0.75.3+1.19.4
mod_menu_version = 6.1.0-beta.3
midnightlib_version=1.2.1-fabric

cull_leaves_version = 3.0.2-fabric
ldl_version = 2.2.0+1.19.3
lbg_version = 1.3.0+1.19
iris_version = 1.19.3-v1.4.6
iris_version = 1.5.2+1.19.3
continuity_version = 2.0.0+1.19
animatica_version = 0.5+1.19
colormatic_version = 3.1.2
borderless_mining_version = 1.1.6+1.19.3
dynamic_fps_version = 2.2.0
dynamic_fps_version = v2.2.0
toml4j_version = 0.7.2
cit_resewn_version = 1.1.1+1.19
cem_version = 0.7.1-1.19.3
complete_config_version = 2.2.0
spruceui_version=4.1.0+1.19.3
midnightlib_version=1.1.0-fabric
entitytexturefeatures_version=4.2.0.1.fabric.1.19.3
exordium_version=1.0.3-1.19.4
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
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;
}
Original file line number Diff line number Diff line change
@@ -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;
}
}

Expand All @@ -63,16 +49,4 @@ private void confirmLink(boolean open) {
}
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

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();
Expand Down
1 change: 1 addition & 0 deletions puzzle-gui/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ dependencies {
modImplementation ("maven.modrinth:entitytexturefeatures:${project.entitytexturefeatures_version}")
modImplementation ("maven.modrinth:cem:${project.cem_version}")
modImplementation "com.github.Lortseam.completeconfig:base:${project.complete_config_version}"
modImplementation ("maven.modrinth:exordium:${project.exordium_version}")

modImplementation("org.aperlambda:lambdajcommon:1.8.1") {
exclude group: 'com.google.code.gson'
Expand Down
Loading

0 comments on commit b979d5a

Please sign in to comment.