Inspection for Animation component
This commit is contained in:
67
game/main.c
67
game/main.c
@@ -686,24 +686,29 @@ void render(float dt, void *userData) {
|
||||
|
||||
void igInspectComp(const char *label, ecs_entity_t entity, ecs_entity_t comp, ImGuiCompFn fn) {
|
||||
igPushID_Int(comp);
|
||||
igSeparatorText(label);
|
||||
bool isAttached = ecs_has_id(ECS, entity, comp);
|
||||
igCheckbox("Attached", &isAttached);
|
||||
if (igTreeNode_Str(label)) {
|
||||
bool isAttached = ecs_has_id(ECS, entity, comp);
|
||||
igCheckbox("Attached", &isAttached);
|
||||
|
||||
if (isAttached)
|
||||
fn(ECS, entity, comp);
|
||||
if (isAttached)
|
||||
fn(ECS, entity, comp);
|
||||
|
||||
if (isAttached != ecs_has_id(ECS, entity, comp)) {
|
||||
if (!isAttached) {
|
||||
ecs_remove_id(ECS, entity, comp);
|
||||
} else {
|
||||
ecs_set_id(ECS, entity, comp, 0, NULL);
|
||||
if (isAttached != ecs_has_id(ECS, entity, comp)) {
|
||||
if (!isAttached) {
|
||||
ecs_remove_id(ECS, entity, comp);
|
||||
} else {
|
||||
ecs_set_id(ECS, entity, comp, 0, NULL);
|
||||
}
|
||||
}
|
||||
igTreePop();
|
||||
}
|
||||
|
||||
igPopID();
|
||||
}
|
||||
void igInspectWindow(ecs_entity_t entity, bool *open) {
|
||||
if (!ecs_is_alive(ECS, entity)) {
|
||||
*open = false;
|
||||
return;
|
||||
}
|
||||
igSetNextWindowSize((ImVec2) {300, 440}, ImGuiCond_FirstUseEver);
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof(buf), "Entity: %ld", entity);
|
||||
@@ -731,25 +736,27 @@ void igInspectWindow(ecs_entity_t entity, bool *open) {
|
||||
else
|
||||
igTextColored((ImVec4) {1, 0, 0, 1}, "NONE");
|
||||
}
|
||||
igInspectComp("Resource", entity, ecs_id(Resource), igResource);
|
||||
igInspectComp("Owner", entity, ecs_id(Owner), igOwner);
|
||||
igInspectComp("SpatialGridID", entity, ecs_id(SpatialGridID), igSpatialGridID);
|
||||
igInspectComp("Position", entity, ecs_id(Position), igVec2Comp);
|
||||
igInspectComp("Size", entity, ecs_id(Size), igVec2Comp);
|
||||
igInspectComp("Velocity", entity, ecs_id(Velocity), igVec2Comp);
|
||||
igInspectComp("TargetPosition", entity, ecs_id(TargetPosition), igVec2Comp);
|
||||
igInspectComp("Steering", entity, ecs_id(Steering), igVec2Comp);
|
||||
igInspectComp("Rotation", entity, ecs_id(Rotation), igFloat);
|
||||
igInspectComp("Path", entity, ecs_id(Path), igPath);
|
||||
igInspectComp("TextureRegion", entity, ecs_id(TextureRegion), igTextureRegion);
|
||||
igInspectComp("Animation", entity, ecs_id(Animation), igAnimation);
|
||||
igInspectComp("Easing", entity, ecs_id(Easing), igEasing);
|
||||
igInspectComp("Arms", entity, ecs_id(Arms), igArms);
|
||||
igInspectComp("Arm", entity, ecs_id(Arm), igArm);
|
||||
igInspectComp("BzBTState", entity, ecs_id(BzBTState), igBzBTState);
|
||||
igInspectComp("AIBlackboard", entity, ecs_id(AIBlackboard), igAIBlackboard);
|
||||
igInspectComp("Worker", entity, ecs_id(Worker), igWorker);
|
||||
igInspectComp("Unit", entity, ecs_id(Unit), igUnit);
|
||||
if (igCollapsingHeader_TreeNodeFlags("Components", 0)) {
|
||||
igInspectComp("Resource", entity, ecs_id(Resource), igResource);
|
||||
igInspectComp("Owner", entity, ecs_id(Owner), igOwner);
|
||||
igInspectComp("SpatialGridID", entity, ecs_id(SpatialGridID), igSpatialGridID);
|
||||
igInspectComp("Position", entity, ecs_id(Position), igVec2Comp);
|
||||
igInspectComp("Size", entity, ecs_id(Size), igVec2Comp);
|
||||
igInspectComp("Velocity", entity, ecs_id(Velocity), igVec2Comp);
|
||||
igInspectComp("TargetPosition", entity, ecs_id(TargetPosition), igVec2Comp);
|
||||
igInspectComp("Steering", entity, ecs_id(Steering), igVec2Comp);
|
||||
igInspectComp("Rotation", entity, ecs_id(Rotation), igFloat);
|
||||
igInspectComp("Path", entity, ecs_id(Path), igPath);
|
||||
igInspectComp("TextureRegion", entity, ecs_id(TextureRegion), igTextureRegion);
|
||||
igInspectComp("Animation", entity, ecs_id(Animation), igAnimation);
|
||||
igInspectComp("Easing", entity, ecs_id(Easing), igEasing);
|
||||
igInspectComp("Arms", entity, ecs_id(Arms), igArms);
|
||||
igInspectComp("Arm", entity, ecs_id(Arm), igArm);
|
||||
igInspectComp("BzBTState", entity, ecs_id(BzBTState), igBzBTState);
|
||||
igInspectComp("AIBlackboard", entity, ecs_id(AIBlackboard), igAIBlackboard);
|
||||
igInspectComp("Worker", entity, ecs_id(Worker), igWorker);
|
||||
igInspectComp("Unit", entity, ecs_id(Unit), igUnit);
|
||||
}
|
||||
}
|
||||
igEnd();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user