Impl hiding drawn text with "H" key

This commit is contained in:
Stephen Seo 2021-09-17 20:51:39 +09:00
parent 78c18afe5e
commit ca714f6de2

View file

@ -10,6 +10,7 @@ use std::thread;
use std::time::{Duration, Instant};
use structopt::StructOpt;
const BUF_SIZE: usize = 1024 * 4;
const POLL_DURATION: Duration = Duration::from_secs(2);
const TEXT_X_OFFSET: f32 = 16.0f32;
const TEXT_Y_OFFSET: f32 = 16.0f32;
@ -267,7 +268,7 @@ fn read_line(
//}
fn info_loop(shared_data: Arc<Mutex<Shared>>) -> Result<(), String> {
let mut buf: [u8; 4192] = [0; 4192];
let mut buf: [u8; BUF_SIZE] = [0; BUF_SIZE];
let mut init: bool = true;
let mut saved: Vec<u8> = Vec::new();
let mut saved_str: String = String::new();
@ -292,8 +293,7 @@ fn info_loop(shared_data: Arc<Mutex<Shared>>) -> Result<(), String> {
if let Ok(mut lock) = lock_result {
let read_result = lock.stream.read(&mut buf);
if let Ok(count) = read_result {
let mut read_vec: Vec<u8> = Vec::from(buf);
read_vec.resize(count, 0);
let mut read_vec: Vec<u8> = Vec::from(&buf[0..count]);
loop {
let mut count = read_vec.len();
if current_binary_size > 0 {
@ -784,6 +784,7 @@ async fn main() -> Result<(), String> {
}
}
if !is_key_down(KeyCode::H) {
temp_offset_y = 0.0;
if !filename.is_empty() && !opt.disable_show_filename {
if filename_font_size.is_none() {
@ -840,7 +841,8 @@ async fn main() -> Result<(), String> {
title_font_size -= 4;
if title_font_size < 4 {
title_font_size = 4;
title_dim_opt = Some(measure_text(&title, None, title_font_size, 1.0f32));
title_dim_opt =
Some(measure_text(&title, None, title_font_size, 1.0f32));
break;
}
} else {
@ -857,7 +859,8 @@ async fn main() -> Result<(), String> {
artist_font_size = ARTIST_INITIAL_FONT_SIZE;
}
loop {
artist_dim_opt = Some(measure_text(&artist, None, artist_font_size, 1.0f32));
artist_dim_opt =
Some(measure_text(&artist, None, artist_font_size, 1.0f32));
if artist_dim_opt.as_ref().unwrap().width + TEXT_X_OFFSET > prev_width {
artist_font_size -= 4;
if artist_font_size < 4 {
@ -935,6 +938,7 @@ async fn main() -> Result<(), String> {
if !error_text.is_empty() {
draw_text(&error_text, 0.0, 32.0f32, 32.0f32, WHITE);
}
}
next_frame().await
}