From bf2fb1c7d06b5dfcf44be5250bf041b208cb0efc Mon Sep 17 00:00:00 2001 From: Dosier Date: Fri, 20 Oct 2023 09:35:12 +0200 Subject: [PATCH] Added support for searching by id instead of just name --- src/main/kotlin/stan/qodat/util/Extensions.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/stan/qodat/util/Extensions.kt b/src/main/kotlin/stan/qodat/util/Extensions.kt index fb915b7..50bb1ef 100644 --- a/src/main/kotlin/stan/qodat/util/Extensions.kt +++ b/src/main/kotlin/stan/qodat/util/Extensions.kt @@ -19,6 +19,7 @@ import stan.qodat.scene.control.SplitSceneDividerDragRegion import stan.qodat.scene.paint.ColorMaterial import stan.qodat.scene.paint.TextureMaterial import stan.qodat.scene.provider.TreeItemProvider +import stan.qodat.scene.runescape.entity.Entity import stan.qodat.scene.shape.PolygonMeshView //fun Qodat.Companion.addTo3DScene(node: Node) { @@ -72,10 +73,14 @@ fun TextField.configureSearchFilter(filteredList: FilteredList(it, newValue) || (containsId(it, id, newValue)) } } } } +private fun containsName(it: S, newValue: String) = it.getName().contains(newValue, ignoreCase = true) +private fun containsId(it: S, id: Int?, newValue: String) = + it is Entity<*> && id != null && it.definition.getOptionalId().orElse(-1).toString().contains(newValue) fun PolygonMeshView.setAndBindMaterial(materialProperty: ObjectProperty){