aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/data/model
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-09-05 00:51:21 +0200
committerGitHub <noreply@github.com>2024-09-05 00:51:21 +0200
commit59eef491fef0d7dd7f4018febe4d91de01369cbe (patch)
treedb9a99de84cc96198db95047eda524737f6a5db1 /src/main/java/at/hannibal2/skyhanni/data/model
parentbf152b4376c453f9eee76a6521377cc4062e9838 (diff)
downloadskyhanni-59eef491fef0d7dd7f4018febe4d91de01369cbe.tar.gz
skyhanni-59eef491fef0d7dd7f4018febe4d91de01369cbe.tar.bz2
skyhanni-59eef491fef0d7dd7f4018febe4d91de01369cbe.zip
Backend: Added Tags to Graph Editor (#2464)
Co-authored-by: Thunderblade73 <85900443+thunderblade73@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/data/model')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/model/Graph.kt35
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/model/GraphNodeTag.kt41
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/model/TextInput.kt7
3 files changed, 75 insertions, 8 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/Graph.kt b/src/main/java/at/hannibal2/skyhanni/data/model/Graph.kt
index ab5d1ca2d..89fd413f5 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/model/Graph.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/model/Graph.kt
@@ -42,17 +42,30 @@ value class Graph(
out.beginObject()
value.forEach {
out.name(it.id.toString()).beginObject()
+
out.name("Position").value(with(it.position) { "$x:$y:$z" })
- if (it.name != null) {
- out.name("Name").value(it.name)
+
+ it.name?.let {
+ out.name("Name").value(it)
+ }
+
+ it.tagNames?.takeIf { it.isNotEmpty() }?.let {
+ out.name("Tags")
+ out.beginArray()
+ for (tagName in it) {
+ out.value(tagName)
+ }
+ out.endArray()
}
+
out.name("Neighbours")
out.beginObject()
- it.neighbours.forEach { (node, weight) ->
+ for ((node, weight) in it.neighbours) {
val id = node.id.toString()
out.name(id).value(weight.round(2))
}
out.endObject()
+
out.endObject()
}
out.endObject()
@@ -66,6 +79,7 @@ value class Graph(
reader.beginObject()
var position: LorenzVec? = null
var name: String? = null
+ var tags: List<String>? = null
var neighbors = mutableListOf<Pair<Int, Double>>()
while (reader.hasNext()) {
when (reader.nextName()) {
@@ -89,9 +103,19 @@ value class Graph(
name = reader.nextString()
}
+ "Tags" -> {
+ tags = mutableListOf()
+ reader.beginArray()
+ while (reader.hasNext()) {
+ val tagName = reader.nextString()
+ tags.add(tagName)
+ }
+ reader.endArray()
+ }
+
}
}
- val node = GraphNode(id, position!!, name)
+ val node = GraphNode(id, position!!, name, tags)
list.add(node)
neighbourMap[node] = neighbors
reader.endObject()
@@ -111,7 +135,8 @@ value class Graph(
}
}
-class GraphNode(val id: Int, val position: LorenzVec, val name: String? = null) {
+// The node object that gets parsed from/to json
+class GraphNode(val id: Int, val position: LorenzVec, val name: String? = null, val tagNames: List<String>? = null) {
/** Keys are the neighbours and value the edge weight (e.g. Distance) */
lateinit var neighbours: Map<GraphNode, Double>
diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/GraphNodeTag.kt b/src/main/java/at/hannibal2/skyhanni/data/model/GraphNodeTag.kt
new file mode 100644
index 000000000..6cfac664b
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/model/GraphNodeTag.kt
@@ -0,0 +1,41 @@
+package at.hannibal2.skyhanni.data.model
+
+enum class GraphNodeTag(val internalName: String?, val displayName: String, val description: String) {
+ DEV("dev", "Dev", "Intentionally marked as dev."), // E.g. Spawn points, todos, etc
+
+ // Everywhere
+ NPC("npc", "§eNPC", "A NPC entity."), // also take from neu repo
+ AREA("area", "§aArea", "A SkyBlock Area."),
+ POI("poi", "PoI", "Point of interest."),
+ LAUNCH_PAD("launch", "Launch Pad", "Slime blocks sending you to another server."),
+
+ // on multiple islands
+ ROMEO("romeo", "Romeo & Juliette Quest", "Blocks related to the Romeo and Juliette/Ring of Love quest line."),
+ RACE("race", "Race Start/Stop", "A race start or stop point."),
+ SLAYER("slayer", "Slayer", "A Slayer area"),
+ // hoppity
+
+ // Hub
+ HUB_12_STARTER("starter_npc", "Starter NPC", "One of the 12 starter NPC's you need to talk to."),
+ // diana
+
+ // Farming Islands: Pelts
+ FARMING_CROP("farming_crop", "Farming Crop", "A spot where you can break crops on farming islands."),
+
+ // Rift
+ RIFT_ENIGMA("rift_enigma", "§5Enigma Soul", "Enigma Souls in the rift."),
+ RIFT_EYE("rift_eye", "§4Eye", "An Eye in the rift to teleport to."),
+
+ // Spider's Den
+ SPIDER_RELIC("SPIDER_RELIC", "§5Relic", "An relic in the Spider's Den."),
+
+ // Dwarven Mines
+ MINES_EMISSARY("mines_emissary", "§6Emissary", "A Emissary from the king."),
+ // commission areas
+
+ ;
+
+ companion object {
+ fun byId(internalName: String?): GraphNodeTag? = values().firstOrNull { it.internalName == internalName }
+ }
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/TextInput.kt b/src/main/java/at/hannibal2/skyhanni/data/model/TextInput.kt
index f1a5001ad..d7e6ff8e1 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/model/TextInput.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/model/TextInput.kt
@@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data.model
import at.hannibal2.skyhanni.utils.KeyboardManager
import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyClicked
+import at.hannibal2.skyhanni.utils.LorenzColor
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.StringUtils.insert
import kotlinx.coroutines.runBlocking
@@ -14,12 +15,12 @@ class TextInput {
var textBox: String = ""
private var carriage: Int? = null
- fun editText() = textBox.let {
+ fun editText(textColor: LorenzColor = LorenzColor.WHITE, carriageColor: LorenzColor = LorenzColor.GREEN) = textBox.let {
with(carriage) {
if (this == null) it
- else it.insert(this, '|')
+ else it.insert(this, "${carriageColor.getChatColor()}|${textColor.getChatColor()}")
}
- }.replace("§", "&&")
+ }.replace("(?<!§.\\|)§(?!.\\|§.)".toRegex(), "&&")
fun finalText() = textBox.replace("&&", "§")