random lockscreen message, remove rand dep for audio player, add version to about window, add o/O to malvim, add circles to draw, bug fixes, minor byte savings for font .alpha format
This commit is contained in:
stjet
2025-08-18 17:27:16 +00:00
parent 2c4455f623
commit 08c2358bdc
20 changed files with 135 additions and 70 deletions

View File

@@ -13,6 +13,7 @@ use ming_wm_lib::components::paragraph::Paragraph;
pub struct About {
dimensions: Dimensions,
components: Vec<Box<dyn Component<()> + Send>>,
version: String,
}
impl WindowLike for About {
@@ -40,7 +41,7 @@ impl WindowLike for About {
//properties
fn title(&self) -> String {
"About".to_string()
"About".to_string() + " - v" + &self.version
}
fn subtype(&self) -> WindowLikeType {
@@ -53,10 +54,11 @@ impl WindowLike for About {
}
impl About {
pub fn new() -> Self {
pub fn new(version: String) -> Self {
Self {
dimensions: [0, 0],
components: Vec::new(),
version,
}
}
}

View File

@@ -1,5 +1,6 @@
use std::vec;
use std::vec::Vec;
use std::time::{ SystemTime, UNIX_EPOCH }; //for psuedo-randomness
use ming_wm_lib::framebuffer_types::Dimensions;
use ming_wm_lib::themes::ThemeInfo;
@@ -7,12 +8,11 @@ use ming_wm_lib::messages::{ WindowMessage, WindowMessageResponse, WindowManager
use ming_wm_lib::window_manager_types::{ DrawInstructions, WindowLike, WindowLikeType };
use bitcoin_hashes::Sha512;
//const PASSWORD_HASH: [u8; 64] = [220, 88, 183, 188, 240, 27, 107, 181, 58, 191, 198, 170, 114, 38, 7, 148, 6, 179, 75, 128, 231, 171, 172, 220, 85, 38, 36, 113, 116, 146, 70, 197, 163, 179, 158, 192, 130, 53, 247, 48, 47, 209, 95, 96, 179, 211, 4, 122, 254, 127, 21, 165, 139, 199, 151, 226, 216, 176, 123, 41, 194, 221, 58, 69];
pub struct LockScreen {
dimensions: Dimensions,
input_password: String,
password_hash: [u8; 64],
lines: [String; 3],
}
impl WindowLike for LockScreen {
@@ -51,9 +51,11 @@ impl WindowLike for LockScreen {
fn draw(&self, _theme_info: &ThemeInfo) -> Vec<DrawInstructions> {
vec![
DrawInstructions::Rect([0, 0], self.dimensions, [0, 0, 0]),
DrawInstructions::Text([4, 4], vec!["nimbus-roman".to_string()], "The bulldozer outside the kitchen window was quite a big one.".to_string(), [255, 255, 255], [0, 0, 0], None, None),
DrawInstructions::Text([4, 4 + 16], vec!["nimbus-roman".to_string()], "\"Yellow,\" he thought, and stomped off back to his bedroom to get dressed.".to_string(), [255, 255, 255], [0, 0, 0], None, None),
DrawInstructions::Text([4, 4 + 16 * 2], vec!["nimbus-roman".to_string()], "He stared at it.".to_string(), [255, 255, 255], [0, 0, 0], None, None),
DrawInstructions::Text([4, 4], vec!["nimbus-roman".to_string()], self.lines[0].clone(), [255, 255, 255], [0, 0, 0], None, None),
//He is my brother.
DrawInstructions::Text([4, 4 + 16], vec!["nimbus-roman".to_string()], self.lines[1].clone(), [255, 255, 255], [0, 0, 0], None, None),
//But I must kill him and keep strong to do it.
DrawInstructions::Text([4, 4 + 16 * 2], vec!["nimbus-roman".to_string()], self.lines[2].clone(), [255, 255, 255], [0, 0, 0], None, None),
DrawInstructions::Text([4, 4 + 16 * 3], vec!["nimbus-roman".to_string()], "Password: ".to_string(), [255, 255, 255], [0, 0, 0], None, None),
DrawInstructions::Text([80, 4 + 16 * 3], vec!["nimbus-roman".to_string()], "*".repeat(self.input_password.len()), [255, 255, 255], [0, 0, 0], None, None),
]
@@ -71,10 +73,24 @@ impl WindowLike for LockScreen {
impl LockScreen {
pub fn new(password_hash: [u8; 64]) -> Self {
let possible_lines = [
[
"\"He took about forty pounds,\" the old man said aloud.".to_string(),
"He took my harpoon too and all the rope, he thought, and now my fish bleeds again and there will be others.".to_string(),
"He did not like to look at the fish anymore since it had been mutilated.".to_string()
],
[
"The bulldozer outside the kitchen window was quite a big one.".to_string(),
"\"Yellow,\" he thought, and stomped off back to his bedroom to get dressed.".to_string(),
"He stared at it.".to_string()
],
];
let rand_index = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs() as usize % possible_lines.len();
Self {
dimensions: [0, 0],
input_password: String::new(),
password_hash,
lines: possible_lines[rand_index].clone(),
}
}
}

View File

@@ -148,7 +148,9 @@ impl FramebufferWriter {
pub fn draw_pixel(&mut self, point: Point, color: RGBColor) {
let start_pos = (point[1] * self.info.stride + point[0]) * self.info.bytes_per_pixel;
self._draw_pixel(start_pos, color);
if self.info.byte_len > start_pos {
self._draw_pixel(start_pos, color);
}
}
//shapes

View File

@@ -12,9 +12,9 @@ fn get_font_char(dir: &str, c: char) -> Option<(char, Vec<Vec<u8>>, u8)> {
let mut contents = String::new();
file.read_to_string(&mut contents).unwrap();
let lines: Vec<&str> = contents.split("\n").collect();
for l in 1..lines.len() {
for ln in 1..lines.len() {
//.unwrap_or(0) is important because zeroes are just empty
ch.push(lines[l].split(",").map(|n| n.parse().unwrap_or(0)).collect());
ch.push(lines[ln].replace(":", ",,,,").replace(";", ",,,").replace(".", ",,").split(",").map(|n| n.parse().unwrap_or(0)).collect());
}
return Some((c, ch, lines[0].parse().unwrap()));
}

View File

@@ -51,6 +51,7 @@ impl fmt::Debug for WindowLikeInfo {
}
}
pub struct WindowManager {
writer: RefCell<FramebufferWriter>,
rotate: bool,
@@ -65,13 +66,14 @@ pub struct WindowManager {
current_workspace: u8,
framebuffer: Framebuffer,
clipboard: Option<String>,
version: String,
password_hash: [u8; 64],
}
//1 is up, 2 is down
impl WindowManager {
pub fn new(writer: FramebufferWriter, framebuffer: Framebuffer, dimensions: Dimensions, rotate: bool, grayscale: bool, password_hash: [u8; 64]) -> Self {
pub fn new(writer: FramebufferWriter, framebuffer: Framebuffer, dimensions: Dimensions, rotate: bool, grayscale: bool, version: String, password_hash: [u8; 64]) -> Self {
//println!("bg: {}x{}", dimensions[0], dimensions[1] - TASKBAR_HEIGHT - INDICATOR_HEIGHT);
let mut wm = WindowManager {
writer: RefCell::new(writer),
@@ -87,6 +89,7 @@ impl WindowManager {
current_workspace: 0,
framebuffer,
clipboard: None,
version,
password_hash,
};
wm.lock();
@@ -594,7 +597,7 @@ impl WindowManager {
}
let w: Option<WindowBox> = match w.as_str() {
"StartMenu" => Some(Box::new(StartMenu::new())),
"About" => Some(Box::new(About::new())),
"About" => Some(Box::new(About::new(self.version.clone()))),
"Help" => Some(Box::new(Help::new())),
_ => Some(Box::new(ProxyWindowLike::new(&w))),
};