clippy auto fixes

This commit is contained in:
Crispy 2025-04-23 21:47:23 +02:00
parent f4348599f6
commit 324d16cfc2
3 changed files with 13 additions and 13 deletions

View file

@ -509,8 +509,8 @@ impl Editor {
let mouse_pos = self.mouse.pos(); let mouse_pos = self.mouse.pos();
if (self.active_tool != Tool::Blueprint if (self.active_tool != Tool::Blueprint
|| self.sim_state != SimState::Editing || self.sim_state != SimState::Editing
|| mouse_pos.x > SIDEBAR_WIDTH as f32) || mouse_pos.x > SIDEBAR_WIDTH)
&& mouse_pos.y > HEADER_HEIGHT as f32 && mouse_pos.y > HEADER_HEIGHT
&& (mouse_pos.y) < (screen_height() - FOOTER_HEIGHT) && (mouse_pos.y) < (screen_height() - FOOTER_HEIGHT)
{ {
match self.mouse.scroll() { match self.mouse.scroll() {
@ -732,7 +732,7 @@ impl Editor {
let mut text_selected = is_selected && self.blueprint_name_selected; let mut text_selected = is_selected && self.blueprint_name_selected;
text_input( text_input(
globals, globals,
Rect::new(42., y as f32, 200., 32.), Rect::new(42., y, 200., 32.),
&mut b.name, &mut b.name,
&mut text_selected, &mut text_selected,
32, 32,
@ -1032,7 +1032,7 @@ impl Editor {
fn draw_bottom_bar(&mut self, globals: &mut Globals) { fn draw_bottom_bar(&mut self, globals: &mut Globals) {
let height = screen_height(); let height = screen_height();
let footer_top = (height - FOOTER_HEIGHT) as f32; let footer_top = height - FOOTER_HEIGHT;
// background // background
draw_rectangle( draw_rectangle(
0., 0.,
@ -1341,7 +1341,7 @@ impl Editor {
} }
fn board_overlay(&mut self, globals: &Globals) { fn board_overlay(&mut self, globals: &Globals) {
let footer_top = (screen_height() - FOOTER_HEIGHT) as f32; let footer_top = screen_height() - FOOTER_HEIGHT;
let tile_size = TILE_TEXTURE_SIZE * self.zoom; let tile_size = TILE_TEXTURE_SIZE * self.zoom;
if self.sim_state == SimState::Editing { if self.sim_state == SimState::Editing {
@ -1350,7 +1350,7 @@ impl Editor {
self.pasting_board = None; self.pasting_board = None;
return; return;
} }
if self.mouse.pos().y < footer_top && self.mouse.pos().y > HEADER_HEIGHT as f32 { if self.mouse.pos().y < footer_top && self.mouse.pos().y > HEADER_HEIGHT {
let view_offset = Vec2::new( let view_offset = Vec2::new(
self.view_offset.x.rem(tile_size), self.view_offset.x.rem(tile_size),
self.view_offset.y.rem(tile_size), self.view_offset.y.rem(tile_size),
@ -1399,7 +1399,7 @@ impl Editor {
} }
} }
} }
if self.mouse.pos().y < footer_top && self.mouse.pos().y > HEADER_HEIGHT as f32 { if self.mouse.pos().y < footer_top && self.mouse.pos().y > HEADER_HEIGHT {
let tile_pos = (self.mouse.pos() - self.view_offset) / tile_size; let tile_pos = (self.mouse.pos() - self.view_offset) / tile_size;
let tile_pos = Vec2::new(tile_pos.x.floor(), tile_pos.y.floor()); let tile_pos = Vec2::new(tile_pos.x.floor(), tile_pos.y.floor());
@ -1460,7 +1460,7 @@ impl Editor {
} }
} }
Tool::Blueprint => { Tool::Blueprint => {
if self.mouse.pos().x > SIDEBAR_WIDTH as f32 { if self.mouse.pos().x > SIDEBAR_WIDTH {
if let Some(bp) = self.blueprints.get(self.selected_blueprint) { if let Some(bp) = self.blueprints.get(self.selected_blueprint) {
self.set_area(pos, bp.board.clone()); self.set_area(pos, bp.board.clone());
} }
@ -1502,7 +1502,7 @@ impl Editor {
.draw(&globals.textures, offset, self.zoom, false); .draw(&globals.textures, offset, self.zoom, false);
bp.board.draw_comments(offset, self.zoom); bp.board.draw_comments(offset, self.zoom);
} }
if self.mouse.pos().x < SIDEBAR_WIDTH as f32 { if self.mouse.pos().x < SIDEBAR_WIDTH {
if self.mouse.scroll() == Some(Scroll::Down) if self.mouse.scroll() == Some(Scroll::Down)
&& self.blueprint_scroll < self.blueprints.len().saturating_sub(5) && self.blueprint_scroll < self.blueprints.len().saturating_sub(5)
{ {

View file

@ -147,7 +147,7 @@ impl Game {
.sum::<usize>() .sum::<usize>()
.saturating_sub(fit_on_screen) as f32 .saturating_sub(fit_on_screen) as f32
* ENTRY_SPACING; * ENTRY_SPACING;
if self.globals.mouse.pos().x < level_list_width as f32 { if self.globals.mouse.pos().x < level_list_width {
if self.globals.mouse.scroll() == Some(Scroll::Down) && self.level_scroll < max_scroll { if self.globals.mouse.scroll() == Some(Scroll::Down) && self.level_scroll < max_scroll {
self.level_scroll += ENTRY_SPACING; self.level_scroll += ENTRY_SPACING;
} }
@ -310,7 +310,7 @@ impl Game {
if let Some(solution) = solutions.get_mut(self.selected_solution) { if let Some(solution) = solutions.get_mut(self.selected_solution) {
let column_x = level_list_width + entry_width + 56.; let column_x = level_list_width + entry_width + 56.;
let bounds = Rect::new(column_x as f32, y as f32, 220., 30.); let bounds = Rect::new(column_x, y, 220., 30.);
if text_input( if text_input(
&mut self.globals, &mut self.globals,
bounds, bounds,

View file

@ -86,7 +86,7 @@ impl ShapedText {
// draw_rectangle(x, y, self.max_width, 4, Color::RED); // draw_rectangle(x, y, self.max_width, 4, Color::RED);
for (i, line) in self.lines.iter().enumerate() { for (i, line) in self.lines.iter().enumerate() {
let line = &self.text[line.clone()]; let line = &self.text[line.clone()];
let line_y = y + self.font_size as f32 * i as f32; let line_y = y + self.font_size * i as f32;
draw_text(line, x, line_y, self.font_size, colors::WHITE); draw_text(line, x, line_y, self.font_size, colors::WHITE);
} }
} }
@ -344,7 +344,7 @@ pub fn draw_usize(
while (number != 0 || i == 0) && i < digits { while (number != 0 || i == 0) && i < digits {
let texture = textures.get(&format!("digit_{}", number % 10)); let texture = textures.get(&format!("digit_{}", number % 10));
let x = x + (digits - i - 1) as f32 * 10. * scale; let x = x + (digits - i - 1) as f32 * 10. * scale;
draw_scaled_texture(texture, x, y, scale as f32); draw_scaled_texture(texture, x, y, scale);
number /= 10; number /= 10;
i += 1; i += 1;
} }