From 0d288498a60718e2a165666ebd69b10aef658833 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Mon, 3 Jun 2024 19:38:55 +0200 Subject: Backend: Widget abstractions (#1150) Co-authored-by: Cal --- .../at/hannibal2/skyhanni/data/model/TabWidget.kt | 438 +++++++++++++++++++++ 1 file changed, 438 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt (limited to 'src/main/java/at/hannibal2/skyhanni/data/model') diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt b/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt new file mode 100644 index 000000000..d459e2a9e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt @@ -0,0 +1,438 @@ +package at.hannibal2.skyhanni.data.model + +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.events.WidgetUpdateEvent +import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy +import at.hannibal2.skyhanni.utils.CollectionUtils.getOrNull +import at.hannibal2.skyhanni.utils.ConditionalUtils.transformIf +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.regex.Matcher +import java.util.regex.Pattern + +private val repoGroup by RepoPattern.exclusiveGroup("tab.widget.enum") + +/** + * This class defines various widgets within the tab list, specifically focusing on the reading of the values. + * Each enum value corresponds to a distinct widget in the tab list, ensuring no overlap between them. + * The general info widget is broken up into multiple smaller ones. + * The class facilitates access to the lines associated with each widget and triggers events when a widget undergoes changes or becomes invisible. + */ +enum class TabWidget( + pattern0: String, +) { + PLAYER_LIST( + // language=RegExp + "(?:§.)*Players (?:§.)*\\(\\d+\\)" + ), + + /** This line holds no information, only here because every widget must be present */ + INFO( + // language=RegExp + "(?:§.)*Info" + ), + AREA( + // language=RegExp + "(?:§.)*(Area|Dungeon): (?:§.)*(?.*)" + ), + SERVER( + // language=RegExp + "Server: (?:§.)*(?.*)" + ), + GEMS( + // language=RegExp + "Gems: (?:§.)*(?.*)" + ), + FAIRY_SOULS( + // language=RegExp + "Fairy Souls: (?:§.)*(?\\d+)(?:§.)*\\/(?:§.)*(?\\d+)" + ), + PROFILE( + // language=RegExp + "(?:§.)*Profile: (?:§.)*(?\\S+).*" + ), + SB_LEVEL( + // language=RegExp + "SB Level(?:§.)*: (?:§.)*\\[(?:§.)*(?\\d+)(?:§.)*\\] (?:§.)*(?\\d+).*" + ), + BANK( + // language=RegExp + "Bank: (?:§.)*(?[^§]+)(?:(?:§.)* \\/ (?:§.)*(?.*))?" + ), + INTEREST( + // language=RegExp + "Interest: (?:§.)*(?