Improve styling

This commit is contained in:
mars 2022-07-10 09:58:39 -06:00
parent 9b711af557
commit 977ce92599
1 changed files with 24 additions and 24 deletions

View File

@ -35,9 +35,9 @@ impl Default for RoundButton {
fn default() -> Self {
Self {
pos: Default::default(),
radius: 0.05,
spacing: 0.01,
thickness: 0.005,
radius: 0.02,
spacing: 0.005,
thickness: 0.001,
shrink_anim: Animation::new(EaseOutQuint, 0.1, 1.0, 0.0),
was_clicked: false,
state: ButtonState::Idle,
@ -60,7 +60,7 @@ impl Widget for RoundButton {
fn draw(&mut self, ctx: &DrawContext) {
let color = Color {
r: 1.0,
g: 0.0,
g: 1.0,
b: 1.0,
a: 1.0,
};
@ -122,8 +122,8 @@ impl<T> ScrollMenu<T> {
.enumerate()
.map(|(i, widget)| {
let duration = 0.25;
let in_delay = i as f32 * inter_button_delay;
let out_delay = max_delay - in_delay;
let out_delay = i as f32 * inter_button_delay;
let in_delay = max_delay - out_delay;
let mut slide_anim = Animation::new(EaseOut, duration, 0.25, 0.0);
slide_anim.set_in_delay(in_delay);
@ -171,7 +171,7 @@ impl<T> ScrollMenu<T> {
pub fn for_buttons(&mut self, mut cb: impl FnMut(&mut ScrollMenuButton<T>, usize, f32)) {
for (i, button) in self.buttons.iter_mut().enumerate() {
let y = (i as f32 - self.scroll_anim.get()) * self.spacing + button.slide_anim.get();
let y = -(i as f32 - self.scroll_anim.get()) * self.spacing + button.slide_anim.get();
cb(button, i, y);
}
}
@ -271,7 +271,7 @@ impl Default for MainMenu {
}
Self {
menu: ScrollMenu::new(buttons, 0.2),
menu: ScrollMenu::new(buttons, 0.1),
inventory: Inventory::new(),
}
}
@ -281,7 +281,7 @@ impl Widget for MainMenu {
fn update(&mut self, dt: f32) {
match self.menu.was_clicked() {
None => {}
Some(0) => self.menu.close(),
Some(4) => self.menu.close(),
Some(button) => self.menu.scroll_to(button),
};
@ -291,7 +291,7 @@ impl Widget for MainMenu {
fn draw(&mut self, ctx: &DrawContext) {
self.menu.draw(&ctx);
let inventory_ctx = ctx.with_offset(Vec2::new(0.05, 0.0));
let inventory_ctx = ctx.with_offset(Vec2::new(0.1, 0.0));
self.inventory.draw(&inventory_ctx);
}
@ -313,16 +313,16 @@ impl Widget for Inventory {
fn draw(&mut self, ctx: &DrawContext) {
// style constants
let head_radius = 0.05;
let head_height = 0.1;
let tab_width = 0.2;
let tab_height = 0.1;
let head_radius = 0.025;
let head_height = 0.03;
let tab_width = 0.04;
let tab_height = 0.06;
let tab_num = 6;
let separator_width = 0.05;
let box_size = 0.05;
let box_margin = 0.025;
let box_padding = 0.01;
let box_grid_width = 5;
let separator_width = 0.015;
let box_size = 0.025;
let box_margin = 0.01;
let box_padding = 0.005;
let box_grid_width = 12;
let head_color = Color {
r: 1.0,
@ -333,14 +333,14 @@ impl Widget for Inventory {
// alignment variables
let tab_list_height = tab_num as f32 * tab_height;
let separator_xy = Vec2::new(tab_width, separator_width);
let separator_xy = Vec2::new(tab_width, separator_width - tab_list_height);
let separator_size = Vec2::new(separator_width, tab_list_height - separator_width);
let body_width = box_grid_width as f32 * (box_size + box_padding) + box_margin;
let body_height = tab_list_height - box_margin * 2.0;
let head_width = tab_width + separator_width + body_width;
let head_inner_xy = Vec2::new(0.0, tab_list_height);
let head_inner_xy = Vec2::ZERO;
let head_inner_size = Vec2::new(head_width, head_height - head_radius);
let head_edge_xy = Vec2::new(head_radius, tab_list_height + head_height - head_radius);
let head_edge_xy = Vec2::new(head_radius, head_height - head_radius);
let head_edge_size = Vec2::new(head_width - head_radius * 2.0, head_radius);
let head_tl_xy = head_edge_xy;
let head_tr_xy = head_tl_xy + Vec2::new(head_edge_size.x, 0.0);
@ -365,9 +365,9 @@ impl Widget for Inventory {
let box_rect_size = Vec2::new(box_size, box_size);
let box_grid_xy = Vec2::new(
tab_width + separator_width + box_margin,
tab_list_height - box_margin - box_size,
-box_margin - box_size,
);
let box_radius = 0.01;
let box_radius = 0.005;
for x in 0..box_grid_width {
for y in 0..box_grid_height {