Skip to content

Commit

Permalink
Window: rename cancelDrawing to hasErrored and expose
Browse files Browse the repository at this point in the history
  • Loading branch information
CallumBugajski committed Feb 2, 2024
1 parent 67010f8 commit db9fb76
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/main/kotlin/gg/essential/elementa/components/Window.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class Window @JvmOverloads constructor(
private set
private var componentRequestingFocus: UIComponent? = null

private var cancelDrawing = false
var hasErrored = false
private set

internal var clickInterceptor: ((mouseX: Double, mouseY: Double, button: Int) -> Boolean)? = null

Expand All @@ -57,7 +58,7 @@ class Window @JvmOverloads constructor(
version.enableFor { doDraw(matrixStack) }

private fun doDraw(matrixStack: UMatrixStack) {
if (cancelDrawing)
if (hasErrored)
return

requireMainThread()
Expand Down Expand Up @@ -107,7 +108,7 @@ class Window @JvmOverloads constructor(
beforeDraw(matrixStack)
super.draw(matrixStack)
} catch (e: Throwable) {
cancelDrawing = true
hasErrored = true

val guiName = platform.currentScreen?.javaClass?.simpleName ?: "<unknown>"
when (e) {
Expand Down Expand Up @@ -169,7 +170,7 @@ class Window @JvmOverloads constructor(
}

override fun mouseScroll(delta: Double) {
if (cancelDrawing) {
if (hasErrored) {
return
}

Expand All @@ -187,7 +188,7 @@ class Window @JvmOverloads constructor(
}

override fun mouseClick(mouseX: Double, mouseY: Double, button: Int) {
if (cancelDrawing) {
if (hasErrored) {
return
}

Expand Down Expand Up @@ -236,7 +237,7 @@ class Window @JvmOverloads constructor(
}

override fun mouseRelease() {
if (cancelDrawing) {
if (hasErrored) {
return
}

Expand All @@ -248,7 +249,7 @@ class Window @JvmOverloads constructor(
}

override fun keyType(typedChar: Char, keyCode: Int) {
if (cancelDrawing) {
if (hasErrored) {
return
}

Expand Down

0 comments on commit db9fb76

Please sign in to comment.