Merge branch 'hqurve/fix-lootscrller' into 'master'

Fixed loot scroller collisions and cleaned up previous changes

See merge request veloren/veloren!2358
This commit is contained in:
Ben Wallis 2021-06-04 20:00:18 +00:00
commit 059dfd2602
4 changed files with 23 additions and 21 deletions

View File

@ -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)

View File

@ -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()

View File

@ -1472,7 +1472,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,

View File

@ -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)