Skip to content

Commit 3e14c5e

Browse files
committed
Show entity name and parent separately in cmd viewer
1 parent 2ee6d28 commit 3e14c5e

File tree

9 files changed

+238
-177
lines changed

9 files changed

+238
-177
lines changed

deps/flecs.c

+115-115
Large diffs are not rendered by default.

deps/flecs.h

+23-23
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,8 @@ extern "C" {
389389

390390
#define EcsFilterMatchThis (1u << 1u) /* Has terms that match This */
391391
#define EcsFilterMatchOnlyThis (1u << 2u) /* Has only terms that match This */
392-
#define EcsFilterMatchPrefab (1u << 3u) /* Does filter match prefabs */
393-
#define EcsFilterMatchDisabled (1u << 4u) /* Does filter match disabled entities */
392+
#define EcsQueryMatchPrefab (1u << 3u) /* Does filter match prefabs */
393+
#define EcsQueryMatchDisabled (1u << 4u) /* Does filter match disabled entities */
394394
#define EcsFilterMatchEmptyTables (1u << 5u) /* Does filter return empty tables */
395395
#define EcsFilterMatchAnything (1u << 6u) /* False if filter has no/only Not terms */
396396
#define EcsFilterNoData (1u << 7u) /* When true, data fields won't be populated */
@@ -2939,7 +2939,7 @@ typedef enum ecs_oper_kind_t {
29392939
#define EcsTermMatchPrefab (1u << 8)
29402940

29412941
/** Type that describes a single identifier in a term */
2942-
typedef struct ecs_term_id_t {
2942+
typedef struct ecs_term_ref_t {
29432943
ecs_entity_t id; /**< Entity id. If left to 0 and flags does not
29442944
* specify whether id is an entity or a variable
29452945
* the id will be initialized to EcsThis.
@@ -2957,7 +2957,7 @@ typedef struct ecs_term_id_t {
29572957
* the Traversable property. Default is IsA. */
29582958

29592959
ecs_flags32_t flags; /**< Term flags */
2960-
} ecs_term_id_t;
2960+
} ecs_term_ref_t;
29612961

29622962
/** Type that describes a term (single element in a query) */
29632963
struct ecs_term_t {
@@ -2966,9 +2966,9 @@ struct ecs_term_t {
29662966
* first/second members, which provide more
29672967
* flexibility. */
29682968

2969-
ecs_term_id_t src; /**< Source of term */
2970-
ecs_term_id_t first; /**< Component or first element of pair */
2971-
ecs_term_id_t second; /**< Second element of pair */
2969+
ecs_term_ref_t src; /**< Source of term */
2970+
ecs_term_ref_t first; /**< Component or first element of pair */
2971+
ecs_term_ref_t second; /**< Second element of pair */
29722972

29732973
ecs_inout_kind_t inout; /**< Access to contents matched by term */
29742974
ecs_oper_kind_t oper; /**< Operator of term */
@@ -6771,7 +6771,7 @@ bool ecs_children_next(
67716771
*/
67726772
FLECS_API
67736773
bool ecs_term_id_is_set(
6774-
const ecs_term_id_t *id);
6774+
const ecs_term_ref_t *id);
67756775

67766776
/** Test whether a term is set.
67776777
* This operation can be used to test whether a term has been initialized with
@@ -8777,7 +8777,7 @@ int ecs_value_move_ctor(
87778777
*
87788778
* Example:
87798779
* ecs_query(world, {
8780-
* .filter.terms = {{ ecs_id(Position) }}
8780+
* .terms = {{ ecs_id(Position) }}
87818781
* });
87828782
*/
87838783
#define ecs_query(world, ...)\
@@ -8787,7 +8787,7 @@ int ecs_value_move_ctor(
87878787
*
87888788
* Example:
87898789
* ecs_observer(world, {
8790-
* .filter.terms = {{ ecs_id(Position) }},
8790+
* .terms = {{ ecs_id(Position) }},
87918791
* .events = { EcsOnAdd },
87928792
* .callback = AddPosition
87938793
* });
@@ -11211,7 +11211,7 @@ ecs_entity_t ecs_system_init(
1121111211
* .name = "MyEntity",
1121211212
* .add = { ecs_dependson(EcsOnUpdate) }
1121311213
* }),
11214-
* .query.filter.terms = {
11214+
* .query.terms = {
1121511215
* { ecs_id(Position) },
1121611216
* { ecs_id(Velocity) }
1121711217
* },
@@ -15100,7 +15100,7 @@ bool ecs_rule_next_instanced(
1510015100
* @return The string
1510115101
*/
1510215102
FLECS_API
15103-
char* ecs_rule_str(
15103+
char* ecs_query_plan(
1510415104
const ecs_rule_t *rule);
1510515105

1510615106
/** Convert rule to string with profile.
@@ -15112,7 +15112,7 @@ char* ecs_rule_str(
1511215112
* @return The string
1511315113
*/
1511415114
FLECS_API
15115-
char* ecs_rule_str_w_profile(
15115+
char* ecs_query_plan_w_profile(
1511615116
const ecs_rule_t *rule,
1511715117
const ecs_iter_t *it);
1511815118

@@ -15383,7 +15383,7 @@ char* ecs_parse_term(
1538315383
const char *expr,
1538415384
const char *ptr,
1538515385
ecs_term_t *term_out,
15386-
ecs_term_id_t *extra_args);
15386+
ecs_term_ref_t *extra_args);
1538715387

1538815388
#ifdef __cplusplus
1538915389
}
@@ -27246,7 +27246,7 @@ struct term_id_builder_i {
2724627246
return *this;
2724727247
}
2724827248

27249-
ecs_term_id_t *m_term_id;
27249+
ecs_term_ref_t *m_term_id;
2725027250

2725127251
protected:
2725227252
virtual flecs::world_t* world_v() = 0;
@@ -29022,8 +29022,8 @@ namespace _ {
2902229022
{
2902329023
ecs_observer_desc_t desc = {};
2902429024
desc.events[0] = event;
29025-
desc.filter.terms[0].id = EcsAny;
29026-
desc.filter.terms[0].src.id = entity;
29025+
desc.terms[0].id = EcsAny;
29026+
desc.terms[0].src.id = entity;
2902729027
desc.callback = callback;
2902829028
desc.binding_ctx = binding_ctx;
2902929029
desc.binding_ctx_free = binding_ctx_free;
@@ -29478,8 +29478,8 @@ struct system final : entity
2947829478
m_world = world;
2947929479
m_id = ecs_system_init(world, desc);
2948029480

29481-
if (desc->query.filter.terms_buffer) {
29482-
ecs_os_free(desc->query.filter.terms_buffer);
29481+
if (desc->query.terms_buffer) {
29482+
ecs_os_free(desc->query.terms_buffer);
2948329483
}
2948429484
}
2948529485

@@ -29669,8 +29669,8 @@ struct pipeline : entity {
2966929669
ecs_abort(ECS_INVALID_PARAMETER, NULL);
2967029670
}
2967129671

29672-
if (desc->query.filter.terms_buffer) {
29673-
ecs_os_free(desc->query.filter.terms_buffer);
29672+
if (desc->query.terms_buffer) {
29673+
ecs_os_free(desc->query.terms_buffer);
2967429674
}
2967529675
}
2967629676
};
@@ -30131,10 +30131,10 @@ struct rule_base {
3013130131

3013230132
/** Converts this rule to a string that can be used to aid debugging
3013330133
* the behavior of the rule.
30134-
* @see ecs_rule_str
30134+
* @see ecs_query_plan
3013530135
*/
3013630136
flecs::string rule_str() const {
30137-
char *result = ecs_rule_str(m_rule);
30137+
char *result = ecs_query_plan(m_rule);
3013830138
return flecs::string(result);
3013930139
}
3014030140

etc/query_editor/js/app.js

+2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ let components = [
141141
loadModule('js/components/code-editor.vue', options),
142142
loadModule('js/components/prop-browser.vue', options),
143143
loadModule('js/components/url-bar.vue', options),
144+
loadModule('js/components/entity-path.vue', options),
144145
loadModule('js/components/entity-parent.vue', options),
146+
loadModule('js/components/entity-name.vue', options),
145147

146148
// Queries page
147149
loadModule('js/components/pages/queries/page.vue', options),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<template>
2+
{{ entityName }}
3+
</template>
4+
5+
<script>
6+
export default { name: "entity-name" };
7+
</script>
8+
9+
<script setup>
10+
import { computed, defineProps } from 'vue';
11+
12+
const props = defineProps({
13+
path: {type: String, required: true}
14+
});
15+
16+
const entityName = computed(() => {
17+
const names = props.path.split(".");
18+
return names.pop();
19+
});
20+
21+
</script>
22+
23+
<style>
24+
</style>
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,25 @@
11
<template>
2-
<span class="entity-parent">
3-
<render/>
4-
</span>
2+
<entity-path :path="parent"></entity-path>
53
</template>
64

75
<script>
86
export default { name: "entity-parent" };
97
</script>
108

119
<script setup>
12-
import { computed, defineProps, h } from 'vue';
10+
import { computed, defineProps } from 'vue';
1311
1412
const props = defineProps({
15-
path: {type: String, required: false}
13+
path: {type: String, required: true}
1614
});
1715
18-
const render = () => {
19-
let elems = [];
20-
if (!props.path) {
21-
return h('span', {}, 'root');
22-
}
23-
16+
const parent = computed(() => {
2417
const names = props.path.split(".");
25-
let count = 0;
26-
for (const name of names) {
27-
if (count) {
28-
elems.push(h('span', {class: 'entity-parent-sep'}, ' > '));
29-
}
30-
elems.push(h('span', {}, name));
31-
count ++;
32-
}
33-
34-
return elems;
35-
}
18+
names.pop();
19+
return names.join(".");
20+
});
3621
3722
</script>
3823

3924
<style>
40-
span.entity-parent {
41-
font-size: 0.8em;
42-
color: var(--secondary-text);
43-
white-space: preserve;
44-
}
45-
46-
span.entity-parent-sep {
47-
color: var(--green);
48-
font-weight: 600;
49-
}
5025
</style>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<template>
2+
<span class="entity-path">
3+
<render/>
4+
</span>
5+
</template>
6+
7+
<script>
8+
export default { name: "entity-path" };
9+
</script>
10+
11+
<script setup>
12+
import { computed, defineProps, h } from 'vue';
13+
14+
const props = defineProps({
15+
path: {type: String, required: false}
16+
});
17+
18+
const render = () => {
19+
let elems = [];
20+
if (!props.path) {
21+
return h('span', {}, 'root');
22+
}
23+
24+
const names = props.path.split(".");
25+
let count = 0;
26+
for (const name of names) {
27+
if (count) {
28+
elems.push(h('span', {class: 'entity-path-sep'}, ' > '));
29+
}
30+
elems.push(h('span', {}, name));
31+
count ++;
32+
}
33+
34+
return elems;
35+
}
36+
37+
</script>
38+
39+
<style>
40+
span.entity-path {
41+
font-size: 0.8em;
42+
color: var(--secondary-text);
43+
white-space: preserve;
44+
}
45+
46+
span.entity-path-sep {
47+
color: var(--green);
48+
font-weight: 600;
49+
}
50+
</style>

etc/query_editor/js/components/pages/commands/inspect-cmd.vue

+15-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
</span>
66
<template v-if="cmd.system">
77
<span class="commands-cmd-system">
8-
<entity-parent :path="cmd.system"></entity-parent>
8+
<entity-path :path="cmd.system"></entity-path>
99
</span>
1010
</template>
1111
<template v-else>
12-
<entity-parent path="unknown source"></entity-parent>
12+
<entity-path path="unknown source"></entity-path>
1313
</template>
1414
<span class="commands-cmd-kind">
1515
{{ cmd.kind }}
@@ -20,8 +20,12 @@
2020
</template>
2121
</span>
2222
<template v-if="cmd.entity">
23-
<span class="commands-cmd-entity code-identifier">
24-
{{ cmd.entity }}
23+
<span class="commands-cmd-entity-parent code-identifier">
24+
<entity-parent :path="cmd.entity"></entity-parent>
25+
</span>
26+
<span class="commands-cmd-entity code-identifier">
27+
<entity-name :path="cmd.entity"></entity-name>
28+
</span>
2529
<template v-if="!cmd.is_alive">
2630
<span class="commands-cmd-not-alive">not alive</span>
2731
</template>
@@ -131,9 +135,15 @@ span.commands-cmd-is-alive {
131135
color: var(--secondary-text);
132136
}
133137
138+
span.commands-cmd-entity-parent {
139+
grid-column: 3;
140+
grid-row: 1;
141+
overflow: hidden;
142+
}
143+
134144
span.commands-cmd-entity {
135145
grid-column: 3;
136-
grid-row: 1 / 3;
146+
grid-row: 2;
137147
overflow: hidden;
138148
}
139149

etc/query_editor/js/components/pages/queries/query-inspect.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<icon :src="query_icon" :opacity="0.5" v-if="query_icon"></icon>
88
</div>
99
<div class="query-inspect-content">
10-
<entity-parent :path="query_parent"></entity-parent>
10+
<entity-path :path="query_parent"></entity-path>
1111
<span class="query-inspect-name">{{ query_name }}</span>
1212
</div>
1313
</div>

etc/query_editor/js/components/pages/queries/query-list-item.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<icon :src="img" :opacity="0.5" v-if="img"></icon>
66
</div>
77
<div class="query-list-item-content">
8-
<entity-parent :path="prop.parent"></entity-parent>
8+
<entity-path :path="prop.parent"></entity-path>
99
<prop_name/>
1010
<span class="prop-brief" v-if="description">{{ description }}</span>
1111
<template v-if="show_usage && (isComponent || isRelationship) && !isModule">

0 commit comments

Comments
 (0)