build mode ui improvements
parent
b12c321488
commit
2527a40231
|
@ -47,7 +47,7 @@ void buildmode_draw(void) {
|
|||
|
||||
Item *item = &e->items[e->selected_item];
|
||||
|
||||
if (e->has_items && !e->inside_vehicle && item->quantity > 0 && (!is_outside_range || build_is_deletion_mode)) {
|
||||
if (e->has_items && !e->inside_vehicle && (build_is_deletion_mode || (item->quantity > 0 && !is_outside_range))) {
|
||||
item_usage usage = 0;
|
||||
uint16_t item_id = 0;
|
||||
if (!build_is_deletion_mode){
|
||||
|
@ -71,6 +71,7 @@ void buildmode_draw(void) {
|
|||
|
||||
world_block_lookup l = world_block_from_realpos((float)cam.x, (float)cam.y);
|
||||
if (build_is_deletion_mode && !l.is_outer){
|
||||
renderer_draw_single((float)cam.x, (float)cam.y, ASSET_BUILDMODE_HIGHLIGHT, ColorAlpha(RED, 0.4f));
|
||||
goto build_skip_placements;
|
||||
}
|
||||
|
||||
|
@ -104,8 +105,12 @@ void buildmode_draw(void) {
|
|||
}
|
||||
|
||||
|
||||
if (!is_outside_range)
|
||||
renderer_draw_single((float)cam.x, (float)cam.y, ASSET_BUILDMODE_HIGHLIGHT, ColorAlpha(build_is_deletion_mode ? RED : WHITE, 0.2f));
|
||||
if (!is_outside_range) {
|
||||
if (build_is_deletion_mode)
|
||||
renderer_draw_single((float)cam.x, (float)cam.y, ASSET_BUILDMODE_HIGHLIGHT, ColorAlpha(RED, 0.2f));
|
||||
else
|
||||
renderer_draw_single((float)cam.x, (float)cam.y, item->kind, ColorAlpha(WHITE, 0.2f));
|
||||
}
|
||||
|
||||
build_skip_placements:
|
||||
build_num_placements = zpl_min(build_num_placements, qty);
|
||||
|
@ -114,7 +119,7 @@ void buildmode_draw(void) {
|
|||
|
||||
for (size_t i = 0; i < build_num_placements; i++) {
|
||||
item_placement *it = &build_placements[i];
|
||||
renderer_draw_single(it->x, it->y, !build_is_deletion_mode ? item->kind : ASSET_BUILDMODE_HIGHLIGHT, ColorAlpha(build_is_deletion_mode ? RED : WHITE, 0.4f));
|
||||
renderer_draw_single(it->x, it->y, !build_is_deletion_mode ? item->kind : ASSET_BUILDMODE_HIGHLIGHT, ColorAlpha(build_is_deletion_mode ? RED : RAYWHITE, 0.6f));
|
||||
}
|
||||
|
||||
if (build_is_in_draw_mode) {
|
||||
|
|
|
@ -79,8 +79,6 @@ item_id item_find(asset_id kind) {
|
|||
|
||||
Item *item_get_data(uint64_t ent) {
|
||||
if (!world_entity_valid(ent)) return NULL;
|
||||
// if (ecs_get(world_ecs(), ent, ItemAlreadyEdited)) return NULL;
|
||||
// ecs_add(world_ecs(), ent, ItemAlreadyEdited);
|
||||
return ecs_get_mut_if_ex(world_ecs(), ent, Item);
|
||||
}
|
||||
|
||||
|
|
|
@ -267,12 +267,14 @@ void UseItem(ecs_iter_t *it) {
|
|||
continue;
|
||||
}
|
||||
|
||||
ecs_entity_t item_ent = inv[i].items[in[i].selected_item];
|
||||
Item *item = item_get_data(item_ent);
|
||||
ecs_entity_t item_ent = 0;
|
||||
Item *item = NULL;
|
||||
uint16_t item_id = 0;
|
||||
item_usage usage = UKIND_DELETE;
|
||||
|
||||
if (!in[i].deletion_mode){
|
||||
item_ent = inv[i].items[in[i].selected_item];
|
||||
item = item_get_data(item_ent);
|
||||
item_id = item ? item_find(item->kind) : ASSET_EMPTY;
|
||||
usage = item_get_usage(item_id);
|
||||
if (!item || item->quantity <= 0) continue;
|
||||
|
@ -313,7 +315,7 @@ void UseItem(ecs_iter_t *it) {
|
|||
|
||||
entity_wake(it->entities[i]);
|
||||
|
||||
if (item->quantity == 0) {
|
||||
if (usage != UKIND_DELETE && item->quantity == 0) {
|
||||
item_despawn(item_ent);
|
||||
inv[i].items[in[i].selected_item] = 0;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ Texture2D Image2TexEco(Image image) {
|
|||
|
||||
static inline
|
||||
Texture2D GenColorEco(Color color) {
|
||||
Image img = GenImageColor(1, 1, color);
|
||||
Image img = GenImageColor(64, 64, color);
|
||||
return Image2TexEco(img);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue