Skip to content

Commit

Permalink
refactor: simplify pausedness check
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeromos Kovács committed Jan 15, 2025
1 parent 4590b23 commit e925f1e
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pub struct App {
universe: Universe,
i: usize,
pub poll_t: Duration,
pub paused: bool,
pub area: Area,
}
impl Default for App {
Expand All @@ -38,7 +37,6 @@ impl Default for App {
universe: Universe::default(),
i: 0,
poll_t: DEF_DUR,
paused: false,
available_universes: shapes::all(),
}
}
Expand All @@ -56,10 +54,12 @@ impl App {
universe: available_universes[0].clone(),
i: 0,
poll_t,
paused: false,
available_universes,
}
}
pub fn paused(&self) -> bool {
self.poll_t == PAUSE
}
pub fn len(&self) -> usize {
self.available_universes.len() + shapes::N
}
Expand All @@ -84,13 +84,12 @@ impl App {
// }

pub fn play_pause(&mut self, prev_poll_t: &mut Duration) {
if self.paused {
if self.paused() {
self.poll_t = *prev_poll_t;
} else {
*prev_poll_t = self.poll_t;
self.poll_t = PAUSE;
}
self.paused = !self.paused;
}
pub fn restart(&mut self) {
let univ = self.get();
Expand All @@ -102,7 +101,7 @@ impl App {
}

pub fn faster(&mut self, big: bool) {
if !self.paused {
if !self.paused() {
let div = if big { 2 } else { 5 };
self.poll_t = self
.poll_t
Expand All @@ -111,7 +110,7 @@ impl App {
}
}
pub fn slower(&mut self, big: bool) {
if !self.paused {
if !self.paused() {
let div = if big { 2 } else { 5 };
self.poll_t = self
.poll_t
Expand Down

0 comments on commit e925f1e

Please sign in to comment.