Compare commits
2 commits
ab61924e5f
...
3e1bc8c6ac
Author | SHA1 | Date | |
---|---|---|---|
3e1bc8c6ac | |||
47db86ba59 |
5 changed files with 43 additions and 8 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1813,7 +1813,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "mpd_info_screen"
|
||||
version = "0.4.16"
|
||||
version = "0.4.17"
|
||||
dependencies = [
|
||||
"bindgen 0.69.4",
|
||||
"clap",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "mpd_info_screen"
|
||||
version = "0.4.16"
|
||||
version = "0.4.17"
|
||||
edition = "2021"
|
||||
description = "Displays info on currently playing music from an MPD daemon"
|
||||
license = "MIT"
|
||||
|
|
|
@ -56,6 +56,8 @@ or through crates.io:
|
|||
disable filename display
|
||||
--disable-show-percentage
|
||||
disable percentage display
|
||||
--force-text-height-scale <FORCE_TEXT_HEIGHT_SCALE>
|
||||
force-set text height relative to window height as a ratio (default 0.12)
|
||||
--pprompt
|
||||
input password via prompt
|
||||
--pfile <PASSWORD_FILE>
|
||||
|
|
|
@ -19,14 +19,16 @@ use std::thread;
|
|||
use std::time::{Duration, Instant};
|
||||
|
||||
const POLL_TIME: Duration = Duration::from_millis(333);
|
||||
const INIT_FONT_SIZE_RATIO: f32 = 1.4167;
|
||||
const INIT_FONT_SIZE_X: f32 = 36.0;
|
||||
const INIT_FONT_SIZE_Y: f32 = 51.0;
|
||||
const INIT_FONT_SIZE_Y: f32 = INIT_FONT_SIZE_X * INIT_FONT_SIZE_RATIO;
|
||||
const TEXT_X_OFFSET: f32 = 0.3;
|
||||
const TEXT_OFFSET_Y_SPACING: f32 = 0.4;
|
||||
const TEXT_HEIGHT_SCALE: f32 = 0.12;
|
||||
const ARTIST_HEIGHT_SCALE: f32 = 0.12;
|
||||
const ALBUM_HEIGHT_SCALE: f32 = 0.12;
|
||||
const TIMER_HEIGHT_SCALE: f32 = 0.105;
|
||||
const TIMER_HEIGHT_SCALE_RATIO: f32 = 0.875;
|
||||
const TIMER_HEIGHT_SCALE: f32 = TEXT_HEIGHT_SCALE * TIMER_HEIGHT_SCALE_RATIO;
|
||||
const MIN_WIDTH_RATIO: f32 = 4.0 / 5.0;
|
||||
const INCREASE_AMT: f32 = 6.0 / 5.0;
|
||||
const DECREASE_AMT: f32 = 5.0 / 6.0;
|
||||
|
@ -470,10 +472,27 @@ impl MPDDisplay {
|
|||
fn refresh_text_transforms(&mut self, ctx: &mut Context) -> GameResult<()> {
|
||||
let drawable_size = ctx.gfx.drawable_size();
|
||||
|
||||
let text_height_limit = TEXT_HEIGHT_SCALE * drawable_size.1.abs();
|
||||
let album_height_limit = ALBUM_HEIGHT_SCALE * drawable_size.1.abs();
|
||||
let artist_height_limit = ARTIST_HEIGHT_SCALE * drawable_size.1.abs();
|
||||
let timer_height = TIMER_HEIGHT_SCALE * drawable_size.1.abs();
|
||||
let text_height_scale: f32;
|
||||
let album_height_scale: f32;
|
||||
let artist_height_scale: f32;
|
||||
let timer_height_scale: f32;
|
||||
|
||||
if let Some(forced_scale) = &self.opts.force_text_height_scale {
|
||||
text_height_scale = *forced_scale;
|
||||
album_height_scale = *forced_scale;
|
||||
artist_height_scale = *forced_scale;
|
||||
timer_height_scale = *forced_scale * TIMER_HEIGHT_SCALE_RATIO;
|
||||
} else {
|
||||
text_height_scale = TEXT_HEIGHT_SCALE;
|
||||
album_height_scale = ALBUM_HEIGHT_SCALE;
|
||||
artist_height_scale = ARTIST_HEIGHT_SCALE;
|
||||
timer_height_scale = TIMER_HEIGHT_SCALE;
|
||||
}
|
||||
|
||||
let text_height_limit = text_height_scale * drawable_size.1.abs();
|
||||
let album_height_limit = album_height_scale * drawable_size.1.abs();
|
||||
let artist_height_limit = artist_height_scale * drawable_size.1.abs();
|
||||
let timer_height = timer_height_scale * drawable_size.1.abs();
|
||||
|
||||
let mut offset_y: f32 = drawable_size.1;
|
||||
|
||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -37,6 +37,11 @@ pub struct Opt {
|
|||
disable_show_filename: bool,
|
||||
#[arg(long = "disable-show-percentage", help = "disable percentage display")]
|
||||
disable_show_percentage: bool,
|
||||
#[arg(
|
||||
long = "force-text-height-scale",
|
||||
help = "force-set text height relative to window height as a ratio (default 0.12)"
|
||||
)]
|
||||
force_text_height_scale: Option<f32>,
|
||||
#[arg(long = "pprompt", help = "input password via prompt")]
|
||||
enable_prompt_password: bool,
|
||||
#[arg(long = "pfile", help = "read password from file")]
|
||||
|
@ -59,6 +64,15 @@ pub struct Opt {
|
|||
|
||||
fn main() -> Result<(), String> {
|
||||
let mut opt = Opt::parse();
|
||||
if let Some(forced_scale) = &mut opt.force_text_height_scale {
|
||||
if *forced_scale < 0.01 {
|
||||
*forced_scale = 0.01;
|
||||
println!("WARNING: Clamped \"force-text-height-scale\" to minimum of 0.01!");
|
||||
} else if *forced_scale > 0.5 {
|
||||
*forced_scale = 0.5;
|
||||
println!("WARNING: Clamped \"force-text-height-scale\" to maximum of 0.5!");
|
||||
}
|
||||
}
|
||||
println!("Got host addr == {}, port == {}", opt.host, opt.port);
|
||||
|
||||
// Read password from file if exists, error otherwise.
|
||||
|
|
Loading…
Reference in a new issue