feat: clear screen & redraw

New keymap key to clear the screen & redraw. Useful if gui shows any glitches
This commit is contained in:
Jack Wills
2025-08-15 01:07:34 +00:00
parent eb686e2c95
commit 50edbc0cc0
19 changed files with 294 additions and 230 deletions
+26 -7
View File
@@ -1,21 +1,40 @@
use std::sync::atomic::{AtomicBool, Ordering};
#[derive(Debug)]
pub struct Rerender(AtomicBool);
pub struct Rerender {
draw: AtomicBool,
clear: AtomicBool,
}
impl Rerender {
pub const fn new() -> Self {
Self(AtomicBool::new(true))
Self {
draw: AtomicBool::new(true),
clear: AtomicBool::new(false),
}
}
pub fn update(&self) {
self.0.store(true, Ordering::SeqCst);
pub fn update_draw(&self) {
self.draw.store(true, Ordering::SeqCst);
}
/// Return the value of the self, and set to false
pub fn swap(&self) -> bool {
pub fn get_clear(&self) -> bool {
if self.clear.load(Ordering::SeqCst) {
self.clear.store(false, Ordering::SeqCst);
true
} else {
false
}
}
pub fn set_clear(&self) {
self.clear.store(true, Ordering::SeqCst);
}
/// Return the value of the draw, and set to false
pub fn swap_draw(&self) -> bool {
match self
.0
.draw
.compare_exchange(true, false, Ordering::SeqCst, Ordering::SeqCst)
{
Ok(previous_value) => previous_value,