diff --git a/src/widgets.rs b/src/widgets.rs index 8097d66..5c47fa9 100644 --- a/src/widgets.rs +++ b/src/widgets.rs @@ -167,7 +167,12 @@ impl Widget for RectButton { if self.is_selected { self.was_clicked = true; self.is_selected = false; - self.color_anim.ease_to(Self::HOVER_COLOR); + + if self.is_hovering { + self.color_anim.ease_to(Self::HOVER_COLOR); + } else { + self.color_anim.ease_to(Self::INACTIVE_COLOR); + } } } } @@ -472,7 +477,7 @@ impl Widget for Reveal { pub struct MainMenu { pub menu: ScrollMenu, - pub inventory: Reveal>, + pub inventory: Reveal>, } impl MainMenu { @@ -487,7 +492,7 @@ impl Default for MainMenu { buttons.push(button); } - let inventory = Inventory::new(); + let inventory = TabMenu::new(); let inventory = Offset::new(inventory, Vec2::new(Self::SUBMENU_SPACING, 0.0)); let inventory = Reveal::new(inventory, -0.02, 0.1); @@ -527,21 +532,21 @@ impl Widget for MainMenu { } } -pub struct Inventory { +pub struct TabMenu { tabs: Vec, } -impl Inventory { +impl TabMenu { const HEAD_RADIUS: f32 = 0.025; const HEAD_HEIGHT: f32 = 0.03; const TAB_WIDTH: f32 = 0.04; const TAB_HEIGHT: f32 = 0.06; const TAB_NUM: usize = 6; const SEPARATOR_WIDTH: f32 = 0.015; - const BOX_SIZE: f32 = 0.025; + const BOX_SIZE: f32 = 0.05; const BOX_MARGIN: f32 = 0.01; const BOX_PADDING: f32 = 0.005; - const BOX_GRID_WIDTH: usize = 12; + const BOX_GRID_WIDTH: usize = 8; pub fn new() -> Self { let tab_size = Vec2::new(Self::TAB_WIDTH, Self::TAB_HEIGHT); @@ -557,7 +562,7 @@ impl Inventory { } } -impl Widget for Inventory { +impl Widget for TabMenu { fn update(&mut self, dt: f32) { for tab in self.tabs.iter_mut() { tab.update(dt);