Skip to content

Commit

Permalink
Continue porting UI and make some needed fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Deftu committed Nov 16, 2024
1 parent 637cb6e commit 365cf97
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/org/polyfrost/crashpatch/CrashPatch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -66,7 +66,7 @@ object CrashPatch {

@Command
fun crash() {
test = true
requestedCrash = true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
33 changes: 25 additions & 8 deletions src/main/kotlin/org/polyfrost/crashpatch/gui/CrashGuiRewrite.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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, "")
Expand All @@ -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<PolyUI> = 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,
Expand All @@ -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<Component>().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)
),
Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/polyfrost/stage0.properties

This file was deleted.

0 comments on commit 365cf97

Please sign in to comment.