From cd13db3f5fa0e6bb4b08149b1aa3cde206ca41ec Mon Sep 17 00:00:00 2001 From: hqurve Date: Mon, 31 May 2021 15:29:35 -0400 Subject: [PATCH] Fixed loot scroller collisions and moved/cleaned up previous changes --- voxygen/src/hud/crafting.rs | 16 ++++++---------- voxygen/src/hud/loot_scroller.rs | 13 +++++++++++-- voxygen/src/hud/mod.rs | 1 - voxygen/src/hud/social.rs | 14 ++++++-------- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/voxygen/src/hud/crafting.rs b/voxygen/src/hud/crafting.rs index ee616e822d..3baeb66e60 100644 --- a/voxygen/src/hud/crafting.rs +++ b/voxygen/src/hud/crafting.rs @@ -276,16 +276,6 @@ impl<'a> Widget for Crafting<'a> { .color(Some(UI_MAIN)) .w_h(422.0, 460.0) .set(state.ids.window, ui); - // Search Background - // I couldn't find a way to manually set they layer of a widget - // If it is possible, please move this code (for rectangle) down to the code for - // search input - if self.show.crafting_search_key.is_some() { - Rectangle::fill([114.0, 20.0]) - .top_left_with_margins_on(state.ids.window, 52.0, 26.0) - .hsla(0.0, 0.0, 0.0, 0.7) - .set(state.ids.input_bg_search, ui); - } // Window Image::new(self.imgs.crafting_frame) .middle_of(state.ids.window) @@ -887,6 +877,12 @@ impl<'a> Widget for Crafting<'a> { { events.push(Event::SearchRecipe(None)); } + Rectangle::fill([114.0, 20.0]) + .top_left_with_margins_on(state.ids.btn_close_search, -2.0, 16.0) + .hsla(0.0, 0.0, 0.0, 0.7) + .depth(1.0) + .parent(state.ids.window) + .set(state.ids.input_bg_search, ui); if let Some(string) = TextEdit::new(key.as_str()) .top_left_with_margins_on(state.ids.btn_close_search, -2.0, 18.0) .w_h(90.0, 20.0) diff --git a/voxygen/src/hud/loot_scroller.rs b/voxygen/src/hud/loot_scroller.rs index 1ec03ea6d1..dc80e58182 100644 --- a/voxygen/src/hud/loot_scroller.rs +++ b/voxygen/src/hud/loot_scroller.rs @@ -2,7 +2,7 @@ use super::{ animate_by_pulse, get_quality_col, img_ids::{Imgs, ImgsRot}, item_imgs::ItemImgs, - Show, TEXT_COLOR, + Show, Windows, TEXT_COLOR, }; use crate::{ i18n::Localization, @@ -189,7 +189,13 @@ impl<'a> Widget for LootScroller<'a> { ui.scroll_widget(state.ids.message_box, [0.0, std::f64::MAX]); } - if self.show.social || self.show.trade { + // check if it collides with other windows + if self.show.diary + || self.show.map + || self.show.open_windows != Windows::None + || self.show.social + || self.show.trade + { if state.last_hover_pulse.is_some() || state.last_auto_show_pulse.is_some() { state.update(|s| { s.last_hover_pulse = None; @@ -197,8 +203,10 @@ impl<'a> Widget for LootScroller<'a> { }); } } else { + //check if hovered if ui .rect_of(state.ids.message_box) + .map(|r| r.pad_left(-6.0)) .map_or(false, |r| r.is_over(ui.global_input().current.mouse.xy)) { state.update(|s| s.last_hover_pulse = Some(self.pulse)); @@ -266,6 +274,7 @@ impl<'a> Widget for LootScroller<'a> { .bottom_left_with_margins_on(ui.window, 308.0, 20.0) .set(state.ids.message_box, ui); + //only show scrollbar if it is being hovered and needed if show_all_age < 1.0 && ui .widget_graph() diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index bc8b194fc0..ecf652f568 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -1465,7 +1465,6 @@ impl Hud { fonts, &i18n, &global_state.settings.controls, - // If we're currently set to interact with the item... properties, pulse, &global_state.window.key_layout, diff --git a/voxygen/src/hud/social.rs b/voxygen/src/hud/social.rs index 2fa67f27b5..6e90ee40ee 100644 --- a/voxygen/src/hud/social.rs +++ b/voxygen/src/hud/social.rs @@ -135,14 +135,6 @@ impl<'a> Widget for Social<'a> { .color(Some(UI_MAIN)) .w_h(280.0, 460.0) .set(state.ids.bg, ui); - // Search Background - // I couldn't find a way to manually set they layer of a widget - // If it is possible, please move this code (for rectangle) down to the code for - // search input - Rectangle::fill([248.0, 20.0]) - .top_left_with_margins_on(state.ids.bg, 52.0, 27.0) - .hsla(0.0, 0.0, 0.0, 0.7) - .set(state.ids.player_search_input_bg, ui); // Window frame Image::new(self.imgs.social_frame_on) .middle_of(state.ids.bg) @@ -426,6 +418,12 @@ impl<'a> Widget for Social<'a> { { events.push(Event::Focus(state.ids.player_search_input)); } + Rectangle::fill([248.0, 20.0]) + .top_left_with_margins_on(state.ids.player_search_icon, -2.0, 18.0) + .hsla(0.0, 0.0, 0.0, 0.7) + .depth(1.0) + .parent(state.ids.bg) + .set(state.ids.player_search_input_bg, ui); if let Some(string) = TextEdit::new(self.show.social_search_key.as_deref().unwrap_or_default()) .top_left_with_margins_on(state.ids.player_search_icon, -1.0, 22.0)