flecs-hub / explorer

Web-based UI for monitoring Flecs applications, trying out queries & learning ECS
MIT License
64 stars 14 forks source link

Add :first for single value inspector-props and fix handling of is_array #31

Closed ZeroErrors closed 9 months ago

ZeroErrors commented 9 months ago

Fixes the formatting of enum relations in query results.

Before: image

After: image


I also noticed that <template v-if="is_array"> was never getting used because <template v-if="is_object"> never gets executed for an array. I swapped the templates to use <template v-else-if="is_object"> so it correctly switches between the 3 cases of array, object and single value.

There was also another minor mistake with v-for which fixed the formatting of array types. Before: image

After: image

Tested using the following reproduction flecs app and then attempted to edit the singleton state of GameState via the explorer.

#include "flecs.h"

enum struct GameState {
    Init,
    MainMenu,
    Connect,
    InGame,
    Exit
};

struct TestType {
    int test[3];
};

int main(int argc, char** argv) {
    flecs::world ecs{ argc, argv };

    ecs.component<GameState>();

    ecs.set<GameState>(GameState::Init);

    ecs.component<TestType>()
        .array<int>(3);

    ecs.entity("Test")
        .set<TestType>({ { 1, 2, 3 } });

    return ecs.app()
        .enable_monitor()
        .enable_rest()
        .run();
}
SanderMertens commented 9 months ago

Awesome, thanks for the PR!