thk U clippy

This commit is contained in:
Michael Zhang 2021-01-10 03:15:55 -06:00
parent 961e141bfc
commit 695fcd5d85
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B
4 changed files with 23 additions and 24 deletions

View file

@ -25,3 +25,6 @@ structopt = "0.3.21"
[dependencies.libosu] [dependencies.libosu]
git = "https://github.com/iptq/libosu" git = "https://github.com/iptq/libosu"
rev = "557d0a321405516f12c3939c1207c7341f796f35" rev = "557d0a321405516f12c3939c1207c7341f796f35"
[features]
clippy = []

View file

@ -90,7 +90,7 @@ impl Game {
self.beatmap = BeatmapExt::new(beatmap); self.beatmap = BeatmapExt::new(beatmap);
self.beatmap.compute_stacking(); self.beatmap.compute_stacking();
if self.beatmap.inner.colors.len() > 0 { if !self.beatmap.inner.colors.is_empty() {
self.combo_colors.clear(); self.combo_colors.clear();
self.combo_colors = self self.combo_colors = self
.beatmap .beatmap
@ -224,7 +224,7 @@ impl Game {
let mut control_points = vec![ho.inner.pos]; let mut control_points = vec![ho.inner.pos];
control_points.extend(&info.control_points); control_points.extend(&info.control_points);
let mut color = color.clone(); let mut color = color;
color.a = 0.6 * draw_info.opacity as f32; color.a = 0.6 * draw_info.opacity as f32;
let spline = Game::render_slider( let spline = Game::render_slider(
&mut self.slider_cache, &mut self.slider_cache,
@ -372,12 +372,10 @@ impl Game {
let frac = diff - beats * tick; let frac = diff - beats * tick;
if frac.abs() < 0.0001 { if frac.abs() < 0.0001 {
delta = Some(n as f64 * tick); delta = Some(n as f64 * tick);
} else if n > 0 {
delta = Some((n - 1) as f64 * tick + (tick - frac));
} else { } else {
if n > 0 { delta = Some((n - 1) as f64 * tick - frac);
delta = Some((n - 1) as f64 * tick + (tick - frac));
} else {
delta = Some((n - 1) as f64 * tick - frac);
}
} }
} }
if let Some(delta) = delta { if let Some(delta) = delta {
@ -416,13 +414,12 @@ impl EventHandler for Game {
.. ..
}) = &self.current_uninherited_timing_point }) = &self.current_uninherited_timing_point
{ {
let steps = -1 let steps = -if mods.contains(KeyMods::SHIFT) {
* if mods.contains(KeyMods::SHIFT) { info.meter as i32
info.meter as i32 } else {
} else { 1
1 };
}; self.seek_by_steps(steps).unwrap();
self.seek_by_steps(steps);
} }
} }
Right => { Right => {
@ -436,7 +433,7 @@ impl EventHandler for Game {
} else { } else {
1 1
}; };
self.seek_by_steps(steps); self.seek_by_steps(steps).unwrap();
} }
} }
_ => {} _ => {}

View file

@ -95,13 +95,16 @@ impl Game {
} }
'outer: loop { 'outer: loop {
for i in 0..last_uninherited.meter as usize { for (i, (color, height)) in ticks
.iter()
.enumerate()
.take(last_uninherited.meter as usize)
{
let tick_time = time + beat * i as f64 / last_uninherited.meter as f64; let tick_time = time + beat * i as f64 / last_uninherited.meter as f64;
if tick_time > right_limit { if tick_time > right_limit {
break 'outer; break 'outer;
} }
let (color, height) = ticks[i];
let percent = let percent =
(tick_time - timeline_left) / (timeline_right - timeline_left); (tick_time - timeline_left) / (timeline_right - timeline_left);
let x = percent as f32 * BOUNDS.w + BOUNDS.x; let x = percent as f32 * BOUNDS.w + BOUNDS.x;
@ -111,7 +114,7 @@ impl Game {
ctx, ctx,
&[Point2::new(x, y1), Point2::new(x, y2)], &[Point2::new(x, y1), Point2::new(x, y2)],
1.0, 1.0,
color, *color,
)?; )?;
graphics::draw(ctx, &tick, DrawParam::default())?; graphics::draw(ctx, &tick, DrawParam::default())?;
} }

View file

@ -64,12 +64,8 @@ impl Texture {
self.animation.clear(); self.animation.clear();
let mut curr = 0; let mut curr = 0;
loop { while let Ok(image) = Image::new(ctx, &format!("/{}{}{}.png", self.name, hyphen, curr))
let image = match Image::new(ctx, &format!("/{}{}{}.png", self.name, hyphen, curr)) {
{
Ok(v) => v,
Err(_) => break,
};
self.animation.push(image); self.animation.push(image);
found = true; found = true;
curr += 1; curr += 1;