From 365cf97770ea7066ca0914cc05e63098b434fa20 Mon Sep 17 00:00:00 2001 From: Deftu Date: Sat, 16 Nov 2024 17:14:11 +0200 Subject: [PATCH] Continue porting UI and make some needed fixes --- build.gradle.kts | 2 +- settings.gradle.kts | 2 +- .../crashpatch/mixin/MixinMinecraft.java | 5 +-- .../org/polyfrost/crashpatch/CrashPatch.kt | 4 +-- .../crashes/DeobfuscatingRewritePolicy.kt | 6 ++-- .../crashpatch/gui/CrashGuiRewrite.kt | 33 ++++++++++++++----- .../resources/polyfrost/stage0.properties | 3 -- 7 files changed, 35 insertions(+), 20 deletions(-) delete mode 100644 src/main/resources/polyfrost/stage0.properties diff --git a/build.gradle.kts b/build.gradle.kts index 692a3cf..713909d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,7 +15,7 @@ plugins { toolkitLoomHelper { // Adds OneConfig to our project - useOneConfig(mcData.version, mcData.loader, "commands", "config-impl", "events", "internal", "ui") + useOneConfig(mcData, "commands", "config", "config-impl", "events", "internal", "ui") // Removes the server configs from IntelliJ IDEA, leaving only client runs. // If you're developing a server-side mod, you can remove this line. diff --git a/settings.gradle.kts b/settings.gradle.kts index 70cb3f4..37b8a30 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -22,7 +22,7 @@ pluginManagement { plugins { kotlin("jvm") version("2.0.0") - id("dev.deftu.gradle.multiversion-root") version("2.11.2") + id("dev.deftu.gradle.multiversion-root") version("2.12.0") } } diff --git a/src/main/java/org/polyfrost/crashpatch/mixin/MixinMinecraft.java b/src/main/java/org/polyfrost/crashpatch/mixin/MixinMinecraft.java index 3c6f8af..1b3fa44 100644 --- a/src/main/java/org/polyfrost/crashpatch/mixin/MixinMinecraft.java +++ b/src/main/java/org/polyfrost/crashpatch/mixin/MixinMinecraft.java @@ -163,8 +163,9 @@ public void run(CallbackInfo ci) { while (running) { if (!hasCrashed || crashReporter == null) { try { - if (CrashPatch.INSTANCE.getTest()) { - throw new RuntimeException("Test crash"); + if (CrashPatch.INSTANCE.getRequestedCrash()) { + CrashPatch.INSTANCE.setRequestedCrash(false); + throw new RuntimeException("Crash requested by CrashPatch"); } runGameLoop(); diff --git a/src/main/kotlin/org/polyfrost/crashpatch/CrashPatch.kt b/src/main/kotlin/org/polyfrost/crashpatch/CrashPatch.kt index efe545d..ce380b2 100644 --- a/src/main/kotlin/org/polyfrost/crashpatch/CrashPatch.kt +++ b/src/main/kotlin/org/polyfrost/crashpatch/CrashPatch.kt @@ -26,7 +26,7 @@ object CrashPatch { val isSkyclient by lazy(LazyThreadSafetyMode.PUBLICATION) { File(mcDir, "OneConfig/CrashPatch/SKYCLIENT").exists() || File( mcDir, "W-OVERFLOW/CrashPatch/SKYCLIENT").exists() } - var test = false + var requestedCrash = false @Mod.EventHandler fun onPreInit(e: FMLPreInitializationEvent) { @@ -66,7 +66,7 @@ object CrashPatch { @Command fun crash() { - test = true + requestedCrash = true } } } diff --git a/src/main/kotlin/org/polyfrost/crashpatch/crashes/DeobfuscatingRewritePolicy.kt b/src/main/kotlin/org/polyfrost/crashpatch/crashes/DeobfuscatingRewritePolicy.kt index d178d49..cb615f3 100644 --- a/src/main/kotlin/org/polyfrost/crashpatch/crashes/DeobfuscatingRewritePolicy.kt +++ b/src/main/kotlin/org/polyfrost/crashpatch/crashes/DeobfuscatingRewritePolicy.kt @@ -12,9 +12,9 @@ import org.apache.logging.log4j.core.config.LoggerConfig class DeobfuscatingRewritePolicy : RewritePolicy { override fun rewrite(source: LogEvent): LogEvent { - if (CrashPatchConfig.deobfuscateCrashLog) { - source.thrown?.let { StacktraceDeobfuscator.INSTANCE.deobfuscateThrowable(it) } - } +// if (CrashPatchConfig.deobfuscateCrashLog) { +// source.thrown?.let { StacktraceDeobfuscator.INSTANCE.deobfuscateThrowable(it) } +// } return source } diff --git a/src/main/kotlin/org/polyfrost/crashpatch/gui/CrashGuiRewrite.kt b/src/main/kotlin/org/polyfrost/crashpatch/gui/CrashGuiRewrite.kt index bdb536f..db7352d 100644 --- a/src/main/kotlin/org/polyfrost/crashpatch/gui/CrashGuiRewrite.kt +++ b/src/main/kotlin/org/polyfrost/crashpatch/gui/CrashGuiRewrite.kt @@ -9,12 +9,16 @@ import org.polyfrost.oneconfig.api.ui.v1.OCPolyUIBuilder import org.polyfrost.oneconfig.api.ui.v1.UIManager import org.polyfrost.polyui.PolyUI import org.polyfrost.polyui.color.rgba +import org.polyfrost.polyui.component.Component import org.polyfrost.polyui.component.extensions.named +import org.polyfrost.polyui.component.extensions.onClick import org.polyfrost.polyui.component.extensions.padded import org.polyfrost.polyui.component.extensions.setPalette +import org.polyfrost.polyui.component.impl.Block import org.polyfrost.polyui.component.impl.Group import org.polyfrost.polyui.component.impl.Image import org.polyfrost.polyui.component.impl.Text +import org.polyfrost.polyui.data.PolyImage import org.polyfrost.polyui.unit.Align import org.polyfrost.polyui.unit.Vec2 import org.polyfrost.polyui.utils.image @@ -48,6 +52,8 @@ class CrashGuiRewrite @JvmOverloads constructor( } var shouldCrash = false + private var selectedSolution: CrashScan.Solution? = null + private val subtitle by lazy { when (type) { GuiType.INIT -> listOf(SUBTITLE_INIT_1 + (if (crashScan != null) SUBTITLE_INIT_2 else "") + SUBTITLE_INIT_3, "") @@ -58,20 +64,22 @@ class CrashGuiRewrite @JvmOverloads constructor( fun create(): GuiScreen { val builder = OCPolyUIBuilder.create() - .atResolution(1920f, 1080f) .blurs() + .atResolution(1920f, 1080f) .backgroundColor(rgba(21, 21, 21)) .size(650f, 600f) + .renderer(UIManager.INSTANCE.renderer) val onClose: Consumer = Consumer { _: PolyUI -> leaveWorldCrash = false } - // builder.onClose(onClose) +// builder.onClose(onClose) + println("sigh.") val polyUI = builder.make( Group( - Image("/assets/crashpatch/WarningTriangle.svg".image(Vec2(20F, 20F))).named("WarningTriangle").padded( + Image("/assets/crashpatch/WarningTriangle.svg".image().also { PolyImage.setImageSize(it, Vec2(20F, 20F)) }).named("WarningTriangle").padded( 0F, 34F, 0F, @@ -82,11 +90,20 @@ class CrashGuiRewrite @JvmOverloads constructor( Text(subtitle[1], fontSize = 14F, font = PolyUI.defaultFonts.regular).setPalette { text.secondary }.padded(0f, 0F, 0f, 0f), Text(if (type == GuiType.DISCONNECT) CAUSE_TEXT_DISCONNECTED else CAUSE_TEXT, fontSize = 16F, font = PolyUI.defaultFonts.regular).setPalette { text.primary }.padded(0f, 24F, 0f, 0f), Text(susThing, fontSize = 18F, font = PolyUI.defaultFonts.semiBold).setPalette { brand.fg }.padded(0f, 8f, 0f, 0f), - //Group( - // Block( -// - // ) - //).padded(0f, 40f, 0f, 0f), + Block( + children = mutableListOf().apply { + crashScan?.solutions?.forEach { scanSolution -> + add(Group( + Text(scanSolution.name, fontSize = 12F, font = PolyUI.defaultFonts.medium).setPalette { text.primary }.onClick { + selectedSolution = scanSolution + } + )) + } + }.toTypedArray(), + alignment = Align(mode = Align.Mode.Vertical), + size = Vec2(550f, 158f), + color = GRAY_700 + ).padded(0f, 40f, 0f, 0f), size = Vec2(650f, 600f), alignment = Align(mode = Align.Mode.Vertical) ), diff --git a/src/main/resources/polyfrost/stage0.properties b/src/main/resources/polyfrost/stage0.properties deleted file mode 100644 index 2996839..0000000 --- a/src/main/resources/polyfrost/stage0.properties +++ /dev/null @@ -1,3 +0,0 @@ -oneconfig-stage1-class=org.polyfrost.oneconfig.loader.stage1.Stage1Loader -oneconfig-stage1-version=1.1.0-alpha.32 -oneconfig-maven-uri=https://repo.polyfrost.org/mirror/