mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix rot_imgs and tooltip manager
This commit is contained in:
parent
931e53ebbe
commit
1fc7c9b67b
@ -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 client::Client;
|
||||||
use conrod_core::{
|
use conrod_core::{
|
||||||
color,
|
color,
|
||||||
@ -6,12 +10,6 @@ use conrod_core::{
|
|||||||
widget::{self, Button, Image, Rectangle /*, Scrollbar*/},
|
widget::{self, Button, Image, Rectangle /*, Scrollbar*/},
|
||||||
widget_ids, Color, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
|
widget_ids, Color, Labelable, Positionable, Sizeable, Widget, WidgetCommon,
|
||||||
};
|
};
|
||||||
use crate::{
|
|
||||||
ui::{
|
|
||||||
ImageFrame, Tooltip, Tooltipable, TooltipManager
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
widget_ids! {
|
widget_ids! {
|
||||||
struct Ids {
|
struct Ids {
|
||||||
@ -38,11 +36,17 @@ pub struct Bag<'a> {
|
|||||||
#[conrod(common_builder)]
|
#[conrod(common_builder)]
|
||||||
common: widget::CommonBuilder,
|
common: widget::CommonBuilder,
|
||||||
rot_imgs: &'a ImgsRot,
|
rot_imgs: &'a ImgsRot,
|
||||||
tooltip_manager: &'a TooltipManager,
|
tooltip_manager: &'a mut TooltipManager,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Bag<'a> {
|
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 {
|
Self {
|
||||||
client,
|
client,
|
||||||
imgs,
|
imgs,
|
||||||
@ -205,7 +209,7 @@ impl<'a> Widget for Bag<'a> {
|
|||||||
.label_color(TEXT_COLOR)
|
.label_color(TEXT_COLOR)
|
||||||
.parent(state.ids.inv_slots[i])
|
.parent(state.ids.inv_slots[i])
|
||||||
.graphics_for(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);
|
.set(state.ids.items[i], ui);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
use crate::ui::img_ids::{BlankGraphic, ImageGraphic, VoxelGraphic, VoxelMs9Graphic};
|
use crate::ui::img_ids::{BlankGraphic, ImageGraphic, VoxelGraphic, VoxelMs9Graphic};
|
||||||
|
|
||||||
|
// TODO: Combine with image_ids, see macro definition
|
||||||
rotation_image_ids! {
|
rotation_image_ids! {
|
||||||
pub struct ImgsRot {
|
pub struct ImgsRot {
|
||||||
<VoxelGraphic>
|
<VoxelGraphic>
|
||||||
|
@ -35,7 +35,7 @@ use crate::{
|
|||||||
render::{Consts, Globals, Renderer},
|
render::{Consts, Globals, Renderer},
|
||||||
scene::camera::Camera,
|
scene::camera::Camera,
|
||||||
settings::ControlSettings,
|
settings::ControlSettings,
|
||||||
ui::{Ingameable, ScaleMode, Ui, TooltipManager},
|
ui::{Ingameable, ScaleMode, TooltipManager, Ui},
|
||||||
window::{Event as WinEvent, GameInput},
|
window::{Event as WinEvent, GameInput},
|
||||||
GlobalState,
|
GlobalState,
|
||||||
};
|
};
|
||||||
@ -361,13 +361,12 @@ impl Show {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Hud<'a> {
|
pub struct Hud {
|
||||||
ui: Ui,
|
ui: Ui,
|
||||||
ids: Ids,
|
ids: Ids,
|
||||||
imgs: Imgs,
|
imgs: Imgs,
|
||||||
fonts: Fonts,
|
fonts: Fonts,
|
||||||
rot_imgs: ImgsRot,
|
rot_imgs: ImgsRot,
|
||||||
tooltip_manager: &'a mut TooltipManager,
|
|
||||||
new_messages: VecDeque<ClientEvent>,
|
new_messages: VecDeque<ClientEvent>,
|
||||||
inventory_space: usize,
|
inventory_space: usize,
|
||||||
show: Show,
|
show: Show,
|
||||||
@ -377,7 +376,7 @@ pub struct Hud<'a> {
|
|||||||
force_chat_cursor: Option<Index>,
|
force_chat_cursor: Option<Index>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Hud<'_> {
|
impl Hud {
|
||||||
pub fn new(global_state: &mut GlobalState) -> Self {
|
pub fn new(global_state: &mut GlobalState) -> Self {
|
||||||
let window = &mut global_state.window;
|
let window = &mut global_state.window;
|
||||||
let settings = &global_state.settings;
|
let settings = &global_state.settings;
|
||||||
@ -388,6 +387,8 @@ impl Hud<'_> {
|
|||||||
let ids = Ids::new(ui.id_generator());
|
let ids = Ids::new(ui.id_generator());
|
||||||
// Load images.
|
// Load images.
|
||||||
let imgs = Imgs::load(&mut ui).expect("Failed to 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.
|
// Load fonts.
|
||||||
let fonts = Fonts::load(&mut ui).expect("Failed to load fonts!");
|
let fonts = Fonts::load(&mut ui).expect("Failed to load fonts!");
|
||||||
|
|
||||||
@ -399,7 +400,6 @@ impl Hud<'_> {
|
|||||||
ids,
|
ids,
|
||||||
new_messages: VecDeque::new(),
|
new_messages: VecDeque::new(),
|
||||||
inventory_space: 8,
|
inventory_space: 8,
|
||||||
tooltip_manager,
|
|
||||||
show: Show {
|
show: Show {
|
||||||
help: false,
|
help: false,
|
||||||
debug: true,
|
debug: true,
|
||||||
@ -728,7 +728,15 @@ impl Hud<'_> {
|
|||||||
|
|
||||||
// Bag contents
|
// Bag contents
|
||||||
if self.show.bag {
|
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::HudEvent(event)) => events.push(event),
|
||||||
Some(bag::Event::Close) => {
|
Some(bag::Event::Close) => {
|
||||||
self.show.bag(false);
|
self.show.bag(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user