Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
d576a0ff8c | |||
6bf05623d8 | |||
675df211cd | |||
c782a3048d | |||
27c3d8c5cd | |||
cd4d4f60e4 |
5 changed files with 60 additions and 22 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1668,7 +1668,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "mpd_info_screen"
|
||||
version = "0.3.7"
|
||||
version = "0.4.4"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"freetype",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "mpd_info_screen"
|
||||
version = "0.3.7"
|
||||
version = "0.4.4"
|
||||
edition = "2018"
|
||||
description = "Displays info on currently playing music from an MPD daemon"
|
||||
license = "MIT"
|
||||
|
|
25
README.md
25
README.md
|
@ -12,6 +12,23 @@ A Rust program that displays info about the currently running MPD server.
|
|||
The window shows albumart (may be embedded in the audio file, or is a "cover.jpg" in the same directory as the song file), a "time-remaining"
|
||||
counter, and the filename currently being played
|
||||
|
||||
## Known Bugs ❗❗
|
||||
|
||||
Version `0.4.4` is a "workaround" release that is branched off of version
|
||||
`0.3.7`. Once a new release of `ggez` is released that fixes the known bugs,
|
||||
a new version will be released with the fixes. Because this is based on
|
||||
`0.3.7` of `mpd_info_screen`, Wayland support may not work. Try using `xwayland`
|
||||
with the environment variable `WINIT_UNIX_BACKEND=x11` set. A future release
|
||||
using the latest version of `ggez` should work with Wayland.
|
||||
|
||||
Currently, the dependency "ggez 0.8.1"
|
||||
[fails to render album art](https://github.com/Stephen-Seo/mpd_info_screen/issues/1)
|
||||
on my machines using the latest version of this program (`main` branch). A
|
||||
version with this fix cannot be published to https://crates.io due to this
|
||||
version referring to a git commit as a dependency. Once ggez has released a new
|
||||
version with the commit that fixes this bug, this repository will be updated to
|
||||
use that version.
|
||||
|
||||
## Unicode Support
|
||||
|
||||
By default, unicode characters will not display properly. Build the project with
|
||||
|
@ -23,10 +40,14 @@ installed already).
|
|||
|
||||
cargo build --release --features unicode_support
|
||||
|
||||
or through crates.io:
|
||||
|
||||
cargo install --features unicode_support mpd_info_screen
|
||||
|
||||
# Usage
|
||||
|
||||
|
||||
mpd_info_screen 0.3.7
|
||||
mpd_info_screen 0.4.4
|
||||
|
||||
USAGE:
|
||||
mpd_info_screen [FLAGS] [OPTIONS] <host> [port]
|
||||
|
@ -47,7 +68,7 @@ installed already).
|
|||
-t, --text-bg-opacity <text-bg-opacity> sets the opacity of the text background (0-255) [default: 190]
|
||||
|
||||
ARGS:
|
||||
<host>
|
||||
<host>
|
||||
<port> [default: 6600]
|
||||
|
||||
|
||||
|
|
|
@ -203,11 +203,17 @@ pub struct MPDDisplay {
|
|||
album_string_cache: String,
|
||||
album_transform: Transform,
|
||||
timer_text: Text,
|
||||
timer_text_len: usize,
|
||||
timer_transform: Transform,
|
||||
timer_x: f32,
|
||||
timer_y: f32,
|
||||
timer: f64,
|
||||
length: f64,
|
||||
cached_filename_y: f32,
|
||||
cached_album_y: f32,
|
||||
cached_artist_y: f32,
|
||||
cached_title_y: f32,
|
||||
cached_timer_y: f32,
|
||||
text_bg_mesh: Option<Mesh>,
|
||||
hide_text: bool,
|
||||
tried_album_art_in_dir: bool,
|
||||
|
@ -237,11 +243,17 @@ impl MPDDisplay {
|
|||
title_text: Text::default(),
|
||||
title_transform: Transform::default(),
|
||||
timer_text: Text::new("0"),
|
||||
timer_text_len: 0,
|
||||
timer_transform: Transform::default(),
|
||||
timer_x: INIT_FONT_SIZE_X,
|
||||
timer_y: INIT_FONT_SIZE_Y,
|
||||
timer: 0.0,
|
||||
length: 0.0,
|
||||
cached_filename_y: 0.0f32,
|
||||
cached_album_y: 0.0f32,
|
||||
cached_artist_y: 0.0f32,
|
||||
cached_title_y: 0.0f32,
|
||||
cached_timer_y: 0.0f32,
|
||||
text_bg_mesh: None,
|
||||
hide_text: false,
|
||||
tried_album_art_in_dir: false,
|
||||
|
@ -446,12 +458,6 @@ impl MPDDisplay {
|
|||
|
||||
let mut offset_y: f32 = screen_coords.h;
|
||||
|
||||
let mut filename_y: f32 = 0.0;
|
||||
let mut album_y: f32 = 0.0;
|
||||
let mut artist_y: f32 = 0.0;
|
||||
let mut title_y: f32 = 0.0;
|
||||
let mut timer_y: f32 = 0.0;
|
||||
|
||||
let set_transform = |text: &mut Text,
|
||||
transform: &mut Transform,
|
||||
offset_y: &mut f32,
|
||||
|
@ -535,7 +541,7 @@ impl MPDDisplay {
|
|||
&mut self.filename_text,
|
||||
&mut self.filename_transform,
|
||||
&mut offset_y,
|
||||
&mut filename_y,
|
||||
&mut self.cached_filename_y,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
|
@ -555,7 +561,7 @@ impl MPDDisplay {
|
|||
&mut self.album_text,
|
||||
&mut self.album_transform,
|
||||
&mut offset_y,
|
||||
&mut album_y,
|
||||
&mut self.cached_album_y,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
|
@ -569,7 +575,7 @@ impl MPDDisplay {
|
|||
&mut self.artist_text,
|
||||
&mut self.artist_transform,
|
||||
&mut offset_y,
|
||||
&mut artist_y,
|
||||
&mut self.cached_artist_y,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
|
@ -589,7 +595,7 @@ impl MPDDisplay {
|
|||
&mut self.title_text,
|
||||
&mut self.title_transform,
|
||||
&mut offset_y,
|
||||
&mut title_y,
|
||||
&mut self.cached_title_y,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
|
@ -608,7 +614,7 @@ impl MPDDisplay {
|
|||
&mut self.timer_text,
|
||||
&mut self.timer_transform,
|
||||
&mut offset_y,
|
||||
&mut timer_y,
|
||||
&mut self.cached_timer_y,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
|
@ -616,6 +622,12 @@ impl MPDDisplay {
|
|||
&mut self.timer_y,
|
||||
);
|
||||
|
||||
self.update_bg_mesh(ctx)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update_bg_mesh(&mut self, ctx: &mut Context) -> GameResult<()> {
|
||||
let filename_dimensions = self.filename_text.dimensions(ctx);
|
||||
let album_dimensions = self.album_text.dimensions(ctx);
|
||||
let artist_dimensions = self.artist_text.dimensions(ctx);
|
||||
|
@ -628,7 +640,7 @@ impl MPDDisplay {
|
|||
DrawMode::fill(),
|
||||
Rect {
|
||||
x: TEXT_X_OFFSET,
|
||||
y: filename_y,
|
||||
y: self.cached_filename_y,
|
||||
w: filename_dimensions.w,
|
||||
h: filename_dimensions.h,
|
||||
},
|
||||
|
@ -640,7 +652,7 @@ impl MPDDisplay {
|
|||
DrawMode::fill(),
|
||||
Rect {
|
||||
x: TEXT_X_OFFSET,
|
||||
y: album_y,
|
||||
y: self.cached_album_y,
|
||||
w: album_dimensions.w,
|
||||
h: album_dimensions.h,
|
||||
},
|
||||
|
@ -652,7 +664,7 @@ impl MPDDisplay {
|
|||
DrawMode::fill(),
|
||||
Rect {
|
||||
x: TEXT_X_OFFSET,
|
||||
y: artist_y,
|
||||
y: self.cached_artist_y,
|
||||
w: artist_dimensions.w,
|
||||
h: artist_dimensions.h,
|
||||
},
|
||||
|
@ -664,7 +676,7 @@ impl MPDDisplay {
|
|||
DrawMode::fill(),
|
||||
Rect {
|
||||
x: TEXT_X_OFFSET,
|
||||
y: title_y,
|
||||
y: self.cached_title_y,
|
||||
w: title_dimensions.w,
|
||||
h: title_dimensions.h,
|
||||
},
|
||||
|
@ -676,7 +688,7 @@ impl MPDDisplay {
|
|||
DrawMode::fill(),
|
||||
Rect {
|
||||
x: TEXT_X_OFFSET,
|
||||
y: timer_y,
|
||||
y: self.cached_timer_y,
|
||||
w: timer_dimensions.w,
|
||||
h: timer_dimensions.h,
|
||||
},
|
||||
|
@ -885,6 +897,7 @@ impl EventHandler for MPDDisplay {
|
|||
let delta = timer::delta(ctx);
|
||||
self.timer += delta.as_secs_f64();
|
||||
let timer_diff = seconds_to_time(self.length - self.timer);
|
||||
let timer_diff_len = timer_diff.len();
|
||||
self.timer_text = Text::new(timer_diff);
|
||||
self.timer_text.set_font(
|
||||
Font::default(),
|
||||
|
@ -893,6 +906,10 @@ impl EventHandler for MPDDisplay {
|
|||
y: self.timer_y,
|
||||
},
|
||||
);
|
||||
if timer_diff_len != self.timer_text_len {
|
||||
self.timer_text_len = timer_diff_len;
|
||||
self.update_bg_mesh(ctx)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -263,10 +263,10 @@ impl MPDHandler {
|
|||
current_binary_size: 0,
|
||||
poll_state: PollState::None,
|
||||
stream,
|
||||
password,
|
||||
password: password.clone(),
|
||||
error_text: String::new(),
|
||||
can_authenticate: true,
|
||||
is_authenticated: false,
|
||||
is_authenticated: password.is_empty(),
|
||||
can_get_album_art: true,
|
||||
can_get_album_art_in_dir: true,
|
||||
can_get_status: true,
|
||||
|
|
Loading…
Reference in a new issue