diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-01-18 20:20:12 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2024-01-18 20:20:12 +0100 |
commit | e1ee9ac488dbba5e6898e92bc9ebf93096e671b1 (patch) | |
tree | 24387b87d3847fb8fc2b38fe7d6699283f94d9da /src/main/java/at/hannibal2/skyhanni/events | |
parent | fc19b7274edc318de60bc9628f1e87d36f285c63 (diff) | |
download | skyhanni-e1ee9ac488dbba5e6898e92bc9ebf93096e671b1.tar.gz skyhanni-e1ee9ac488dbba5e6898e92bc9ebf93096e671b1.tar.bz2 skyhanni-e1ee9ac488dbba5e6898e92bc9ebf93096e671b1.zip |
moved all shdebug stuff into categories
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/events')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/events/DebugDataCollectEvent.kt | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/events/DebugDataCollectEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/DebugDataCollectEvent.kt index a53a144cf..1a4eabb92 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/DebugDataCollectEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/DebugDataCollectEvent.kt @@ -2,10 +2,11 @@ package at.hannibal2.skyhanni.events import at.hannibal2.skyhanni.utils.StringUtils.equalsIgnoreColor -class DebugDataCollectEvent(private val builder: StringBuilder, private val search: String?) : LorenzEvent() { +class DebugDataCollectEvent(private val list: MutableList<String>, private val search: String?) : LorenzEvent() { + var empty = true private var currentTitle = "" - private var exit = false + private var ignore = false fun title(title: String) { if (currentTitle != "") error("Title already set: '$currentTitle'") @@ -13,8 +14,28 @@ class DebugDataCollectEvent(private val builder: StringBuilder, private val sear currentTitle = title } - fun exit(text: String) { - exit = true + fun ignore(block: MutableList<String>.() -> Unit) { + val list = mutableListOf<String>() + block(list) + ignore(list) + } + + fun ignore(text: String) { + ignore(listOf(text)) + } + + private fun ignore(text: List<String>) { + ignore = true + addData(text) + } + + fun addData(block: MutableList<String>.() -> Unit) { + val list = mutableListOf<String>() + block(list) + addData(list) + } + + fun addData(text: String) { addData(listOf(text)) } @@ -22,11 +43,11 @@ class DebugDataCollectEvent(private val builder: StringBuilder, private val sear if (currentTitle == "") error("Title not set") writeData(text) currentTitle = "" - exit = false + ignore = false } private fun writeData(text: List<String>) { - if (exit && search == null) return + if (ignore && search == null) return search?.let { if (!search.equalsIgnoreColor("all")) { if (!currentTitle.contains(search, ignoreCase = true)) { @@ -34,9 +55,11 @@ class DebugDataCollectEvent(private val builder: StringBuilder, private val sear } } } - builder.append("\n== $currentTitle ==\n") + empty = false + list.add("") + list.add("== $currentTitle ==") for (line in text) { - builder.append(" $line\n") + list.add(" $line") } } } |