Partial entity inspector

This commit is contained in:
2024-01-07 13:49:13 +01:00
parent 5dbc5ba15e
commit 9c745d2857
9 changed files with 276 additions and 56 deletions

View File

@@ -94,10 +94,8 @@ void igTagCheckbox(const char *label, ecs_world_t *ecs,
else
ecs_remove_id(ecs, entity, tag);
}
void igResource(const char *label, ecs_world_t *ecs,
void igResource(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
if (!ecs_has_id(ecs, entity, comp)) return;
igSeparatorText(label);
Resource *res = ecs_get_mut_id(ecs, entity, comp);
const char *resStrings[RES_COUNT];
for (i32 i = 0; i < RES_COUNT; i++) {
@@ -108,13 +106,118 @@ void igResource(const char *label, ecs_world_t *ecs,
res->type = curType;
igInputInt("Amount", &res->amount, 1, 10, 0);
}
void igVec2(const char *label, ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
if (!ecs_has_id(ecs, entity, comp)) return;
igSeparatorText(label);
Vector2 *vec = ecs_get_mut_id(ecs, entity, comp);
igPushID_Str(label);
void igTilePosition(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
TilePosition *tilePos = ecs_get_mut_id(ecs, entity, comp);
igInputInt("X", &tilePos->x, 1, 4, 0);
igInputInt("Y", &tilePos->y, 1, 4, 0);
}
void igTileSize(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
TileSize *tileSize = ecs_get_mut_id(ecs, entity, comp);
igInputInt("X", &tileSize->sizeX, 1, 1, 0);
igInputInt("Y", &tileSize->sizeY, 1, 1, 0);
}
void igOwner(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
Owner *owner = ecs_get_mut_id(ecs, entity, comp);
igInputInt("PlayerID", &owner->playerID, 0, 0, 0);
}
void igSpatialGridID(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
SpatialGridID *id = ecs_get_mut_id(ecs, entity, comp);
igText("SpatialID", *id);
}
void igVec2(Vector2 *vec) {
igInputFloat("X", &vec->x, 1.0f, 10.0f, "%.2f", 0);
igInputFloat("Y", &vec->y, 1.0f, 10.0f, "%.2f", 0);
igPopID();
}
void igVec2Comp(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
Vector2 *vec = ecs_get_mut_id(ecs, entity, comp);
igVec2(vec);
}
void igFloat(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
f32 *f = ecs_get_mut_id(ecs, entity, comp);
igInputFloat("", f, 0.1f, 1.0f, "%.2f", 0);
}
void igPath(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
Path path = *(Path *) ecs_get_mut_id(ecs, entity, comp);
i32 idx = 0;
while (path.paths) {
for (int32_t i = path.curWaypoint; i < path.paths->numWaypoints; i++) {
igPushID_Int(idx);
igText("Waypoint %d:", idx);
igInputFloat("X", &path.paths->waypoints[i].x, 1, 16, "%.2f", 0);
igInputFloat("Y", &path.paths->waypoints[i].y, 1, 16, "%.2f", 0);
igPopID();
idx++;
}
path.paths = path.paths->next;
path.curWaypoint = 0;
}
}
void igRect(Rectangle *rect) {
igInputFloat("X", &rect->x, 1, 16, "%.2f", 0);
igInputFloat("Y", &rect->y, 1, 16, "%.2f", 0);
igInputFloat("Width", &rect->width, 1, 16, "%.2f", 0);
igInputFloat("Height", &rect->height, 1, 16, "%.2f", 0);
}
void igTextureRegion(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
TextureRegion *tex = ecs_get_mut_id(ecs, entity, comp);
igText("Texture: %d", tex->texture.id);
igRect(&tex->rec);
bool flipX = tex->flipX;
bool flipY = tex->flipY;
igCheckbox("flipX", &flipX);
igCheckbox("flipY", &flipY);
tex->flipX = flipX;
tex->flipY = flipY;
}
void igAnimation(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
//Animation *anim = ecs_get_mut_id(ecs, entity, comp);
}
void igEasing(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
Easing *easing = ecs_get_mut_id(ecs, entity, comp);
igText("Component: %d, offset: %d", easing->compID, easing->offset);
igText("x = %.2f + %.2f * (%.2f + (%.2f * %.2f) + %.2f) + %.2f",
easing->start, easing->target, easing->easeStart, easing->easeTarget,
easing->x, easing->easeOffset, easing->offset);
}
void igArms(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
}
void igArm(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
}
void igUnitAction(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
}
void igUnitAI(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
}
void igWorker(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
}
void igUnit(ecs_world_t *ecs,
ecs_entity_t entity, ecs_entity_t comp) {
}