diff --git a/voxygen/src/hud/bag.rs b/voxygen/src/hud/bag.rs index 80b54bee99..d330e1d6f7 100644 --- a/voxygen/src/hud/bag.rs +++ b/voxygen/src/hud/bag.rs @@ -1,4 +1,8 @@ -use super::{img_ids::{Imgs, ImgsRot}, Event as HudEvent, Fonts, TEXT_COLOR, TEXT_COLOR_2}; +use super::{ + img_ids::{Imgs, ImgsRot}, + Event as HudEvent, Fonts, TEXT_COLOR, TEXT_COLOR_2, +}; +use crate::ui::{ImageFrame, Tooltip, TooltipManager, Tooltipable}; use client::Client; use conrod_core::{ color, @@ -6,12 +10,6 @@ use conrod_core::{ widget::{self, Button, Image, Rectangle /*, Scrollbar*/}, widget_ids, Color, Labelable, Positionable, Sizeable, Widget, WidgetCommon, }; -use crate::{ - ui::{ - ImageFrame, Tooltip, Tooltipable, TooltipManager - } -}; - widget_ids! { struct Ids { @@ -38,11 +36,17 @@ pub struct Bag<'a> { #[conrod(common_builder)] common: widget::CommonBuilder, rot_imgs: &'a ImgsRot, - tooltip_manager: &'a TooltipManager, + tooltip_manager: &'a mut TooltipManager, } impl<'a> Bag<'a> { - pub fn new(client: &'a Client, imgs: &'a Imgs, fonts: &'a Fonts, tooltip_manager: &'a TooltipManager, rot_imgs: &'a ImgsRot,) -> Self { + pub fn new( + client: &'a Client, + imgs: &'a Imgs, + fonts: &'a Fonts, + rot_imgs: &'a ImgsRot, + tooltip_manager: &'a mut TooltipManager, + ) -> Self { Self { client, imgs, @@ -85,7 +89,7 @@ impl<'a> Widget for Bag<'a> { fn update(self, args: widget::UpdateArgs) -> Self::Event { let widget::UpdateArgs { state, ui, .. } = args; - let mut event = None; + let mut event = None; let invs = self.client.inventories(); let inventory = match invs.get(self.client.entity()) { @@ -205,7 +209,7 @@ impl<'a> Widget for Bag<'a> { .label_color(TEXT_COLOR) .parent(state.ids.inv_slots[i]) .graphics_for(state.ids.inv_slots[i]) - .with_tooltip(&mut self.tooltip_manager, "Test", "", &item_tooltip) + .with_tooltip(self.tooltip_manager, "Test", "", &item_tooltip) .set(state.ids.items[i], ui); } } diff --git a/voxygen/src/hud/img_ids.rs b/voxygen/src/hud/img_ids.rs index 1c9d27101a..bae00ef2fd 100644 --- a/voxygen/src/hud/img_ids.rs +++ b/voxygen/src/hud/img_ids.rs @@ -1,4 +1,6 @@ use crate::ui::img_ids::{BlankGraphic, ImageGraphic, VoxelGraphic, VoxelMs9Graphic}; + +// TODO: Combine with image_ids, see macro definition rotation_image_ids! { pub struct ImgsRot { diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index ebaee4a254..2094d683ed 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -35,7 +35,7 @@ use crate::{ render::{Consts, Globals, Renderer}, scene::camera::Camera, settings::ControlSettings, - ui::{Ingameable, ScaleMode, Ui, TooltipManager}, + ui::{Ingameable, ScaleMode, TooltipManager, Ui}, window::{Event as WinEvent, GameInput}, GlobalState, }; @@ -361,13 +361,12 @@ impl Show { } } -pub struct Hud<'a> { +pub struct Hud { ui: Ui, ids: Ids, imgs: Imgs, fonts: Fonts, rot_imgs: ImgsRot, - tooltip_manager: &'a mut TooltipManager, new_messages: VecDeque, inventory_space: usize, show: Show, @@ -377,7 +376,7 @@ pub struct Hud<'a> { force_chat_cursor: Option, } -impl Hud<'_> { +impl Hud { pub fn new(global_state: &mut GlobalState) -> Self { let window = &mut global_state.window; let settings = &global_state.settings; @@ -388,6 +387,8 @@ impl Hud<'_> { let ids = Ids::new(ui.id_generator()); // Load images. let imgs = Imgs::load(&mut ui).expect("Failed to load images!"); + // Load rotation images. + let rot_imgs = ImgsRot::load(&mut ui).expect("Failed to load rot images!"); // Load fonts. let fonts = Fonts::load(&mut ui).expect("Failed to load fonts!"); @@ -399,7 +400,6 @@ impl Hud<'_> { ids, new_messages: VecDeque::new(), inventory_space: 8, - tooltip_manager, show: Show { help: false, debug: true, @@ -728,7 +728,15 @@ impl Hud<'_> { // Bag contents if self.show.bag { - match Bag::new(client, &self.imgs, &self.rot_imgs, &self.fonts, &self.tooltip_manager).set(self.ids.bag, ui_widgets) { + match Bag::new( + client, + &self.imgs, + &self.fonts, + &self.rot_imgs, + tooltip_manager, + ) + .set(self.ids.bag, ui_widgets) + { Some(bag::Event::HudEvent(event)) => events.push(event), Some(bag::Event::Close) => { self.show.bag(false);