Hovering items

main
Cameron Murphy Reikes 2 years ago
parent 311d8d5118
commit b4e2352d0c

@ -3767,6 +3767,7 @@ F cost: G + H
// item grid modal draw item grid
{
static float visible = 0.0f;
static float hovered_state[ARRLEN(player->held_items.data)] = { 0 };
float target = 0.0f;
if(choosing_item_grid) target = 1.0f;
visible = Lerp(visible, unwarped_dt*9.0f, target);
@ -3807,16 +3808,26 @@ F cost: G + H
Vec2 cursor = AddV2(grid_aabb.upper_left, V2(padding, -padding));
BUFF_ITER_I(ItemKind, &player->held_items, i)
{
AABB item_icon = aabb_at(cursor, item_icon_size);
Vec2 real_size = LerpV2(item_icon_size, hovered_state[i], MulV2F(item_icon_size, 1.25f));
Vec2 item_center = AddV2(cursor, MulV2F(V2(item_icon_size.x, -item_icon_size.y), 0.5f));
AABB item_icon = centered_aabb(item_center, real_size);
float target = 0.0f;
if(aabb_is_valid(item_icon))
{
draw_quad((DrawParams){false, quad_aabb(item_icon), IMG(image_white_square), blendalpha(WHITE, Lerp(0.0f, hovered_state[i], 0.4f)), .layer = LAYER_UI_FG });
bool hovered = has_point(item_icon, mouse_pos);
if(hovered) target = 1.0f;
in_screen_space = true;
dbgrect(item_icon);
in_screen_space = false;
draw_item(false, *it, item_icon, clamp01(visible*visible));
}
hovered_state[i] = Lerp(hovered_state[i], dt*12.0f, target);
cursor.x += item_icon_size.x + padding_btwn_items;
if((i + 1) % horizontal_item_count == 0 && i != 0)
{

@ -0,0 +1,285 @@
if(a < b) return a;
if(playing_audio[i].sample == 0)
if(e->facing_left)
if(e->is_character)
else if(e->is_npc)
if(npc_is_knight_sprite(e))
else if(e->npc_kind == NPC_GodRock)
else if(e->npc_kind == NPC_OldMan)
else if(e->npc_kind == NPC_Death)
else if(e->npc_kind == NPC_Skeleton)
else if(e->npc_kind == NPC_MOOSE)
else if(e->npc_kind == NPC_TheGuard)
else if(e->is_bullet)
else if(e->is_prop)
else if(e->is_item)
if(tile_id == collideable[i]+1) return true;
if(e->is_character) // aabb near feet
if(out_of_bounds) return (TileInstance){0};
if(ref.generation == 0) return 0;
if(!to_return->exists || to_return->generation != ref.generation)
if(!gs.entities[i].exists)
if(it->is_character)
if(it->generation == 0) it->generation = 1; // zero value generation means doesn't exist
if(read_data.version != CURRENT_VERSION)
if(player->state != CHARACTER_TALKING)
if(actual_len == 0)
if(c == '\n') break;
if(gete(player->holding_item) != 0)
if(talking->last_seen_holding_kind != player_holding)
if(it->sample != 0)
if(cursor_pcm(it) >= it->sample->pcm_data_length)
if(!it->is_tile && it->e != from)
if(it == looking_for) done_damage = true;
if(!done_damage)
if(!BUFF_HAS_SPACE(&from->done_damage_to_this_swing))
if(memory->active)
if(memory->identifier == ended_identifier)
if(screen_size().x < screen_size().y)
if(screen_size().x < screen_size().y)
if (farthest_to_right - farthest_to_left < total_length)
if(segments_overlapping(a_segment, b_segment))
if(segments_overlapping(a_segment, b_segment))
if(cur_batch_image.id == 0 || cur_batch_data_index == 0) return; // flush called when image changes, image starts out null!
if(aabb_is_valid(d.clip_to) && LenV2(aabb_size(d.clip_to)) > 0.1)
if(d.world_space)
if(d.world_space)
if(d.queue_for_translucent)
if(d.image.id != cur_batch_image.id || memcmp(&params,&cur_batch_params,sizeof(params)) != 0 )
if(!overlapping(cam_aabb, points_bounding_box))
if(cur_batch_data_index + total_size >= ARRLEN(cur_batch_data))
if(col.A < 1.0f)
if(!show_devtools) return;
if(!show_devtools) return;
if(!show_devtools) return;
if(!aabb_is_valid(rect))
if(to == NULL) return;
if(to->is_bullet)
else if(true)
if(to->is_character)
if(from->is_character)
if(t.text[i] == '\n')
if(size.Y > 0.0 && size.X > 0.0)
if(!t.dry_run)
if(t.colors)
if(false) // drop shadow, don't really like it
if(t.world_space)
if(s->no_wrap)
if(index >= s->num_frames) index = s->num_frames - 1;
if(d.flipped)
if(!d.no_shadow) draw_shadow_for(drawn);
if(is_tile_solid(t))
if(!(it->is_character && it->is_rolling) && overlapping(aabb, entity_aabb(it)))
if(is_tile_solid(get_tile_layer(&level_level0, 2, tilecoord_to_check)))
if(!p.dont_collide_with_entities && !(p.from->is_character && p.from->is_rolling))
if(!(it->is_character && it->is_rolling) && it != p.from && !(it->is_npc && it->dead) && !it->is_item)
if(overlapping(at_new, *it))
if(cur_dist < smallest_distance){
if(actually_overlapping.cur_index > 0)
if(i == smallest_aabb_index)
if(dot > closest_dot)
if(p.col_info_out) *p.col_info_out = info;
if(line_bounds.lower_right.X > at_point.X + max_width)
if(chars_from_sentence > sentence_len) chars_from_sentence--;
if(!dry_run) dbgrect(drawn_bounds);
if(chars_from_sentence == 0)
if(is_last_said && it->type == NPCDialog)
if(aabb_is_valid(dialog_panel))
if(aabb_is_valid(dialog_panel))
if(it->type == NPCDialog)
if(last_said == &it->npc_dialog)
else if(it->type == PlayerDialog)
if(dialog.cur_index > 0)
if(it->is_player)
if(!receiving_text_input && in_dialog())
if(screen_size().x < 0.7f*screen_size().y)
if(mobile_controls)
if(LenV2(movement) > 0.0f)
if(LenV2(movement) > 1.0)
if(cur.kind > tileset.first_gid && tileset.first_gid > max_gid)
if(cur.kind != 0)
if(tileset.animated[i].exists && tileset.animated[i].id_from == cur.kind-1)
if(anim)
if(player->in_conversation_mode)
if(fabsf(speed_factor - speed_target) <= 0.05f)
if(it->is_npc)
if(it->gen_request_id != 0)
if(status == 0)
if(status == 1)
if(text_was_well_formatted)
else if(status == 2)
else if(status == -1)
if(fabsf(it->vel.x) > 0.01f)
if(it->dead)
if(player->in_conversation_mode)
if(has_point(entity_aabb(it), screen_to_world(mouse_pos)))
if(mouse_just_clicked)
if(it->is_npc)
if(true)
if(last_said_sentence(it)) length = last_said_sentence(it)->cur_index;
if((int)before < length)
if( (int)it->characters_said > (int)before )
if(it->standing == STANDING_FIGHTING || it->standing == STANDING_JOINED)
if(it->direction_of_spiral_pattern)
if(col.happened)
if(it->standing == STANDING_FIGHTING)
if(it->shotgun_timer >= 1.0f)
if(it->npc_kind == NPC_OldMan)
if(it->shotgun_timer >= 1.0f)
else if(it->npc_kind == NPC_Skeleton)
if(it->dead)
if(fabsf(it->vel.x) > 0.01f)
if(it->swing_timer > 0.0)
if(it->swing_timer >= anim_sprite_duration(ANIM_skeleton_swing_sword))
if(it->swing_timer >= 0.4f)
if(it->walking)
if(it->e && it->e->is_character)
else if(it->npc_kind == NPC_Death)
else if(it->npc_kind == DEATH)
else if(it->npc_kind == MERCHANT)
else if(it->npc_kind == NPC_MOOSE)
else if(it->npc_kind == NPC_GodRock)
else if(it->npc_kind == NPC_Edeline)
else if(it->npc_kind == NPC_TheGuard)
if(it->moved)
if(LenV2(towards) > 1.0f)
if(it->damage >= 1.0)
if(it->npc_kind == NPC_Skeleton)
else if (it->is_item)
if(it->held_by_player)
if(info.happened) it->vel = ReflectV2(it->vel, info.normal);
else if (it->is_bullet)
if(!it->is_tile && !(it->e->is_bullet))
if(destroy_bullet) *from_bullet = (Entity){0};
if(!has_point(level_aabb, it->pos)) *it = (Entity){0};
else if(it->is_character)
else if(it->is_prop)
if(it->destroy)
if(it->perceptions_dirty && !npc_does_dialog(it))
if(it->perceptions_dirty)
if(it->npc_kind == NPC_TheGuard)
if(it->last_seen_holding_kind == ITEM_Tripod && !it->moved)
if(entity_talkable) entity_talkable = entity_talkable && !it->is_tile;
if(entity_talkable) entity_talkable = entity_talkable && it->e->is_npc;
if(entity_talkable) entity_talkable = entity_talkable && !(it->e->npc_kind == NPC_Skeleton);
if(entity_talkable) entity_talkable = entity_talkable && it->e->gen_request_id == 0;
if(entity_talkable || entity_pickupable)
if(dist < closest_interact_with_dist)
if(player->state == CHARACTER_TALKING)
if(player->state == CHARACTER_TALKING)
if(gete(player->talking_to) == 0)
if(interact)
if(player->in_conversation_mode)
else if(closest_interact_with)
if(closest_interact_with->is_npc)
else if(closest_interact_with->is_item)
if(gete(player->holding_item))
if(roll && !player->is_rolling && player->time_not_rolling > 0.3f && (player->state == CHARACTER_IDLE || player->state == CHARACTER_WALKING))
if(attack && (player->state == CHARACTER_IDLE || player->state == CHARACTER_WALKING))
if(player->after_images.data[0].alive_for >= AFTERIMAGE_LIFETIME)
if(player->state != CHARACTER_IDLE && player->state != CHARACTER_WALKING)
if(player->is_rolling)
if(player->roll_progress > anim_sprite_duration(ANIM_knight_rolling))
if(!player->is_rolling) player->time_not_rolling += dt;
if(LenV2(movement) > 0.01f) player->to_throw_direction = NormV2(movement);
if(player->state == CHARACTER_WALKING)
if(player->is_rolling) speed = PLAYER_ROLL_SPEED;
if(gete(player->holding_item) && gete(player->holding_item)->item_kind == ITEM_Boots)
if(LenV2(movement) == 0.0)
else if(player->state == CHARACTER_IDLE)
if(LenV2(movement) > 0.01) player->state = CHARACTER_WALKING;
else if(player->state == CHARACTER_ATTACK)
if(player->swing_progress > anim_sprite_duration(ANIM_knight_attack))
else if(player->state == CHARACTER_TALKING)
if(player->damage >= 1.0)
if(interacting_with)
if(!mobile_controls)
if(player->state == CHARACTER_WALKING)
if(player->is_rolling)
else if(player->state == CHARACTER_IDLE)
if(player->is_rolling)
else if(player->state == CHARACTER_ATTACK)
else if(player->state == CHARACTER_TALKING)
if(player->damage > 0.0)
if(player->anim_change_timer >= 0.05f)
if(progress_through_life > 0.5f)
if(player->is_rolling) to_draw.tint.a = 0.5f;
if(to_draw.anim)
if(player->after_image_timer >= TIME_TO_GEN_AFTERIMAGE)
if(BUFF_HAS_SPACE(&player->after_images))
if(it->gen_request_id != 0)
if(it->is_npc)
if(it->is_npc)
if(gete(player->talking_to) == it && player->state == CHARACTER_TALKING) alpha = 1.0f;
if(it->being_hovered)
if(it->npc_kind == NPC_OldMan)
else if(it->npc_kind == NPC_Skeleton)
if(it->dead)
if(it->swing_timer > 0.0)
if(it->walking)
else if(it->npc_kind == NPC_Death)
else if(it->npc_kind == NPC_GodRock)
else if(npc_is_knight_sprite(it))
if(it->npc_kind == NPC_TheGuard)
else if(it->npc_kind == NPC_Edeline)
else if(it->npc_kind == NPC_MOOSE)
else if (it->is_item)
if(it->item_kind == ITEM_Tripod)
else if(it->item_kind == ITEM_Boots)
else if(it->item_kind == ITEM_WhiteSquare)
else if (it->is_bullet)
else if(it->is_character)
else if(it->is_prop)
if(it->prop_kind == TREE0)
else if(it->prop_kind == TREE1)
else if(it->prop_kind == TREE2)
else if(it->prop_kind == ROCK0)
if(!mobile_controls)
if(mobile_controls)
if(interacting_with || gete(player->holding_item))
if(show_devtools)
if(show_devtools)
if(LenV2(SubV2(target, cam.pos)) <= 0.2)
if(e->key_repeat) return;
if(e->type == SAPP_EVENTTYPE_TOUCHES_BEGAN)
if(!mobile_controls)
if(receiving_text_input)
if(e->type == SAPP_EVENTTYPE_CHAR)
if(BUFF_HAS_SPACE(&text_input_buffer))
if(e->type == SAPP_EVENTTYPE_KEY_DOWN && e->key_code == SAPP_KEYCODE_ENTER)
if(mobile_controls)
if(e->type == SAPP_EVENTTYPE_TOUCHES_BEGAN)
if(touchpoint_screen_pos.x < screen_size().x*0.4f)
if(!movement_touch.active)
if(true)
if(LenV2(SubV2(touchpoint_screen_pos, roll_button_pos())) < mobile_button_size()*0.5f)
if(LenV2(SubV2(touchpoint_screen_pos, interact_button_pos())) < mobile_button_size()*0.5f)
if(LenV2(SubV2(touchpoint_screen_pos, attack_button_pos())) < mobile_button_size()*0.5f)
if(e->type == SAPP_EVENTTYPE_TOUCHES_MOVED)
if(movement_touch.active)
if(e->touches[i].identifier == movement_touch.identifier)
if(LenV2(move_vec) > clampto_size)
if(e->type == SAPP_EVENTTYPE_TOUCHES_ENDED)
if(e->touches[i].changed) // only some of the touch events are released
if(maybe_deactivate(&interact_pressed_by, e->touches[i].identifier))
if(maybe_deactivate(&roll_pressed_by, e->touches[i].identifier))
if(maybe_deactivate(&attack_pressed_by, e->touches[i].identifier))
if(maybe_deactivate(&movement_touch, e->touches[i].identifier))
if(e->type == SAPP_EVENTTYPE_MOUSE_DOWN)
if(e->mouse_button == SAPP_MOUSEBUTTON_LEFT)
if(e->type == SAPP_EVENTTYPE_KEY_DOWN)
if(!receiving_text_input)
if(e->key_code == SAPP_KEYCODE_E)
if(e->key_code == SAPP_KEYCODE_LEFT_SHIFT)
if(e->key_code == SAPP_KEYCODE_SPACE)
if(e->key_code == SAPP_KEYCODE_E)
if(e->key_code == SAPP_KEYCODE_ESCAPE)
if(e->key_code == SAPP_KEYCODE_T)
if(e->key_code == SAPP_KEYCODE_M)
if(e->key_code == SAPP_KEYCODE_P)
if(profiling)
if(e->key_code == SAPP_KEYCODE_7)
if(e->type == SAPP_EVENTTYPE_KEY_UP)
if(e->type == SAPP_EVENTTYPE_MOUSE_MOVE)
if(mouse_frozen) ignore_movement = true;
if(!ignore_movement) mouse_pos = V2(e->mouse_x, (float)sapp_height() - e->mouse_y);
Loading…
Cancel
Save