Skip to content

Commit

Permalink
Add ability to search by entity id to tree
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderMertens committed Jun 22, 2024
1 parent a3ce899 commit b204e04
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
8 changes: 4 additions & 4 deletions deps/flecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ typedef enum {
EcsQueryAnd, /* And operator: find or match id against variable source */
EcsQueryAndId, /* And operator for fixed id (no wildcards/variables) */
EcsQueryAndAny, /* And operator with support for matching Any src/id */
EcsQuerySelectAny, /* Dedicated instruction for _ queries where the src is unknown */
EcsQueryOnlyAny, /* Dedicated instruction for _ queries where the src is unknown */
EcsQueryTriv, /* Trivial search (batches multiple terms) */
EcsQueryTrivData, /* Trivial search with setting data fields */
EcsQueryTrivWildcard, /* Trivial search with (exclusive) wildcard ids */
Expand Down Expand Up @@ -32260,7 +32260,7 @@ const char* flecs_query_op_str(
case EcsQueryCacheData: return "cachepop ";
case EcsQueryIsCache: return "xcache ";
case EcsQueryIsCacheData: return "xcachepop ";
case EcsQuerySelectAny: return "any ";
case EcsQueryOnlyAny: return "any ";
case EcsQueryUp: return "up ";
case EcsQueryUpId: return "upid ";
case EcsQuerySelfUp: return "selfup ";
Expand Down Expand Up @@ -64947,7 +64947,7 @@ int flecs_query_compile_term(
} else if (!src_written && term->id == EcsAny && op.kind == EcsQueryAndAny) {
/* Lookup variables ($var.child_name) are always written */
if (!src_is_lookup) {
op.kind = EcsQuerySelectAny; /* Uses Any (_) id record */
op.kind = EcsQueryOnlyAny; /* Uses Any (_) id record */
}
}

Expand Down Expand Up @@ -69609,7 +69609,7 @@ bool flecs_query_dispatch(
case EcsQueryIsCache: return flecs_query_is_cache(op, redo, ctx);
case EcsQueryCacheData: return flecs_query_cache_data(op, redo, ctx);
case EcsQueryIsCacheData: return flecs_query_is_cache_data(op, redo, ctx);
case EcsQuerySelectAny: return flecs_query_select_any(op, redo, ctx);
case EcsQueryOnlyAny: return flecs_query_select_any(op, redo, ctx);
case EcsQueryUp: return flecs_query_up(op, redo, ctx);
case EcsQueryUpId: return flecs_query_up_id(op, redo, ctx);
case EcsQuerySelfUp: return flecs_query_self_up(op, redo, ctx);
Expand Down
2 changes: 1 addition & 1 deletion etc/v4/js/components/pages/entities/pane-tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default { name: "pane-tree" }
</script>

<script setup>
import { computed, defineProps, defineModel, emits, ref } from 'vue';
import { computed, defineProps, defineModel, ref } from 'vue';
const props = defineProps({
conn: {type: Object, required: true},
Expand Down
17 changes: 15 additions & 2 deletions etc/v4/js/components/widgets/inspector/entity-inspector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
</div>
<entity-path :path="entityQueryResult.parent"></entity-path>
<template v-if="entityLabel">
<span class="entity-inspector-name">{{ entityLabel }}</span>
<span class="entity-inspector-name">{{ entityLabel }}
<span class="entity-inspector-id">{{ entityId }}</span>
</span>
<template v-if="expand">
<span class="entity-inspector-actual-name">{{ entityQueryResult.name }}</span>
</template>
</template>
<template v-else>
<span class="entity-inspector-name">{{ entityQueryResult.name }}</span>
<span class="entity-inspector-name">{{ entityQueryResult.name }}
<span class="entity-inspector-id">{{ entityId }}</span>
</span>
</template>

<template v-if="expand">
Expand Down Expand Up @@ -99,6 +103,7 @@ const entityQuery = ref();
const entityQueryResult = ref();
const entityModules = ref([]);
const entityLabel = ref();
const entityId = ref();
const expand = ref(false);
const isDisabled = ref(false);
const isScript = ref(false);
Expand Down Expand Up @@ -183,6 +188,7 @@ function updateQuery() {
try: true,
managed: true,
values: inspectorMode.value == "Components",
entity_id: true,
full_paths: true,
type_info: true,
private: true,
Expand Down Expand Up @@ -216,6 +222,8 @@ function updateQuery() {
loadTypeFromReply(moduleMap, reply);
entityId.value = '#' + reply.id;
// Extract entity label
entityLabel.value = undefined;
if (reply.components) {
Expand Down Expand Up @@ -311,6 +319,11 @@ div.entity-inspector {
padding: 8px;
}
span.entity-inspector-id {
font-size: 0.9rem;
color: var(--secondary-text);
}
span.entity-inspector-name {
font-size: 1.1em;
font-weight: 300;
Expand Down
6 changes: 5 additions & 1 deletion etc/v4/js/components/widgets/tree/entity-subtree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ function updateQuery() {
}
if (nf) {
q += `, $this ~= "${nf}"`;
if (nf[0] == '#') {
q += `, $this == "${nf}"`;
} else {
q += `, $this ~= "${nf}"`;
}
}
treeQuery.value =
Expand Down

0 comments on commit b204e04

Please sign in to comment.