Basic property editor
This commit is contained in:
@@ -77,3 +77,38 @@ void initComponentIDs(ecs_world_t *ecs) {
|
||||
ECS_TAG_DEFINE(ecs, Attackable);
|
||||
|
||||
}
|
||||
|
||||
#include <rlImGui.h>
|
||||
void igTagCheckbox(const char *label, ecs_world_t *ecs,
|
||||
ecs_entity_t entity, ecs_entity_t tag) {
|
||||
bool hasTag = ecs_has_id(ecs, entity, tag);
|
||||
igCheckbox(label, &hasTag);
|
||||
if (hasTag)
|
||||
ecs_add_id(ecs, entity, tag);
|
||||
else
|
||||
ecs_remove_id(ecs, entity, tag);
|
||||
}
|
||||
void igResource(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);
|
||||
Resource *res = ecs_get_mut_id(ecs, entity, comp);
|
||||
const char *resStrings[RES_COUNT];
|
||||
for (i32 i = 0; i < RES_COUNT; i++) {
|
||||
resStrings[i] = getResourceTypePrettyName(i);
|
||||
}
|
||||
int curType = res->type;
|
||||
igCombo_Str_arr("Type", &curType, resStrings, RES_COUNT, -1);
|
||||
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);
|
||||
igInputFloat("X", &vec->x, 1.0f, 10.0f, "%.2f", 0);
|
||||
igInputFloat("Y", &vec->y, 1.0f, 10.0f, "%.2f", 0);
|
||||
igPopID();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user