Rename Inventory to TabMenu

This commit is contained in:
mars 2022-07-12 15:30:22 -06:00
parent 3e4be0ea0b
commit bfe8ca07a0
1 changed files with 13 additions and 8 deletions

View File

@ -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<T: Widget> Widget for Reveal<T> {
pub struct MainMenu {
pub menu: ScrollMenu<RoundButton>,
pub inventory: Reveal<Offset<Inventory>>,
pub inventory: Reveal<Offset<TabMenu>>,
}
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<RectButton>,
}
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);