small UI adjustments

isolation_bkp/dynres
Dominik Madarász 2021-09-09 09:54:02 +02:00
parent 98adee996c
commit 347f85063e
4 changed files with 11 additions and 1 deletions

View File

@ -25,6 +25,7 @@ pkt_desc pkt_entity_view_desc[] = {
{ PKT_KEEP_IF(entity_view, kind, EKIND_VEHICLE, 1) }, // NOTE(zaklaus): keep for vehicles { PKT_KEEP_IF(entity_view, kind, EKIND_VEHICLE, 1) }, // NOTE(zaklaus): keep for vehicles
{ PKT_HALF(entity_view, heading) }, { PKT_HALF(entity_view, heading) },
{ PKT_UINT(entity_view, inside_vehicle) },
{ PKT_KEEP_IF(entity_view, kind, EKIND_ITEM, 2) }, { PKT_KEEP_IF(entity_view, kind, EKIND_ITEM, 2) },
{ PKT_UINT(entity_view, asset) }, { PKT_UINT(entity_view, asset) },

View File

@ -57,6 +57,7 @@ typedef struct entity_view {
// NOTE(zaklaus): vehicle // NOTE(zaklaus): vehicle
float heading, theading; float heading, theading;
bool inside_vehicle;
// NOTE(zaklaus): items, ... // NOTE(zaklaus): items, ...
asset_id asset; asset_id asset;

View File

@ -33,6 +33,8 @@ void DEBUG_draw_ground(uint64_t key, entity_view * data) {
} }
} }
extern bool inv_is_open;
void DEBUG_draw_entities(uint64_t key, entity_view * data) { void DEBUG_draw_entities(uint64_t key, entity_view * data) {
uint16_t size = 16; uint16_t size = 16;
uint16_t font_size = (uint16_t)lerp(4.0f, 32.0f, 0.5f/(float)render_camera.zoom); uint16_t font_size = (uint16_t)lerp(4.0f, 32.0f, 0.5f/(float)render_camera.zoom);
@ -57,13 +59,17 @@ void DEBUG_draw_entities(uint64_t key, entity_view * data) {
DrawTextEco(title, x-title_w/2, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(RAYWHITE, data->tran_time), font_spacing); DrawTextEco(title, x-title_w/2, y-size-font_size-fixed_title_offset, font_size, ColorAlpha(RAYWHITE, data->tran_time), font_spacing);
DrawCircleEco(x, y, size, ColorAlpha(YELLOW, data->tran_time)); DrawCircleEco(x, y, size, ColorAlpha(YELLOW, data->tran_time));
if (data->has_items) { if (data->has_items && !data->inside_vehicle) {
float ix = data->x; float ix = data->x;
float iy = data->y; float iy = data->y;
if (data->items[data->selected_item].quantity > 0) { if (data->items[data->selected_item].quantity > 0) {
item_kind it_kind = data->items[data->selected_item].kind; item_kind it_kind = data->items[data->selected_item].kind;
uint32_t qty = data->items[data->selected_item].quantity;
uint16_t it_id = item_find(it_kind); uint16_t it_id = item_find(it_kind);
DrawTexturePro(GetSpriteTexture2D(assets_find(item_get_asset(it_id))), ASSET_SRC_RECT(), ((Rectangle){ix, iy, 32, 32}), (Vector2){0.5f,0.5f}, 0.0f, ALPHA(WHITE)); DrawTexturePro(GetSpriteTexture2D(assets_find(item_get_asset(it_id))), ASSET_SRC_RECT(), ((Rectangle){ix, iy, 32, 32}), (Vector2){0.5f,0.5f}, 0.0f, ALPHA(WHITE));
if (!inv_is_open)
DrawTextEco(zpl_bprintf("%d", qty), ix+24, iy+24, 8, RAYWHITE, 0.0f);
} }
} }
}break; }break;

View File

@ -59,6 +59,8 @@ entity_view world_build_entity_view(int64_t e) {
view.quantity = dr->quantity; view.quantity = dr->quantity;
} }
view.inside_vehicle = ecs_get(world_ecs(), e, IsInVehicle) != 0 ? true : false;
Inventory *inv = 0; Inventory *inv = 0;
if ((inv = ecs_get_mut_if(world_ecs(), e, Inventory))) { if ((inv = ecs_get_mut_if(world_ecs(), e, Inventory))) {
view.has_items = true; view.has_items = true;