@ -1,4 +1,7 @@
use eframe ::egui ;
use egui ::FontFamily ::Proportional ;
use egui ::FontId ;
use egui ::TextStyle ::* ;
use crate ::player ::Player ;
pub struct App {
@ -19,40 +22,27 @@ impl Default for App {
impl eframe ::App for App {
fn update ( & mut self , ctx : & egui ::Context , _frame : & mut eframe ::Frame ) {
egui ::CentralPanel ::default ( ) . show ( ctx , | ui | {
ui . heading ( "lza gui" ) ;
let mut style = ( * ctx . style ( ) ) . clone ( ) ;
// style.visuals come to SD
style . text_styles = [
( Heading , FontId ::new ( 30.0 , Proportional ) ) ,
( Name ( "Heading2" . into ( ) ) , FontId ::new ( 25.0 , Proportional ) ) ,
( Name ( "Context" . into ( ) ) , FontId ::new ( 23.0 , Proportional ) ) ,
( Body , FontId ::new ( 18.0 , Proportional ) ) ,
( Monospace , FontId ::new ( 14.0 , Proportional ) ) ,
( Button , FontId ::new ( 14.0 , Proportional ) ) ,
( Small , FontId ::new ( 10.0 , Proportional ) ) ,
] . into ( ) ;
// style.spacing.item_spacing = egui::vec2(10.0, 20.0);
ctx . set_style ( style ) ;
ctx . set_visuals ( egui ::Visuals ::dark ( ) ) ;
// ctx.set_visuals(egui::Visuals::noninteractive(egui::style::WidgetVisuals::));
egui ::TopBottomPanel ::top ( "top" ) . show ( ctx , | ui | {
ui . heading ( "Wownero Operations Center" ) ;
ui . label ( "Made by ya boi, lza_menace" ) ;
ui . hyperlink ( "https://lzahq.tech" ) ;
ui . separator ( ) ;
ui . horizontal ( | ui | {
if ui . button ( "▶" ) . clicked ( ) {
// If stream thread is done, start again
if self . player . stream_thread . is_finished ( ) {
self . player . stream_thread = self . player . start_radio_stream ( ) ;
}
if self . player . sink . len ( ) ! = 1 {
let source : rodio ::Decoder < std ::io ::BufReader < std ::fs ::File > > = self . player . get_radio_source ( ) ;
let _ = & self . player . sink . append ( source ) ;
}
let _ = & self . player . sink . play ( ) ;
self . player . playing = true ;
}
if ui . button ( "■" ) . clicked ( ) {
let _ = & self . player . sink . pause ( ) ;
self . player . playing = false ;
}
} ) ;
ui . add ( egui ::Slider ::new ( & mut self . player . volume , 0. 0 ..= 100.0 ) . text ( "Volume" ) ) ;
self . player . sink . set_volume ( self . player . volume / 100.0 ) ;
if self . player . playing {
ui . label ( format! ( "Now Playing: {:?}" , self . player . get_song_meta ( ) ) ) ;
ui . label ( format! ( "Stream URL: {:?}" , self . player . stream_source ) ) ;
}
} ) ;
egui ::CentralPanel ::default ( ) . show ( ctx , | _ui | {
// ui.separator();
// ui.heading("Tor");
// if self.tor_started {
@ -73,5 +63,39 @@ impl eframe::App for App {
// }
// }
} ) ;
egui ::TopBottomPanel ::bottom ( "radio_player" ) . show ( ctx , | ui | {
ui . heading ( egui ::RichText ::new ( "WOW!Radio" ) . color ( egui ::Color32 ::GREEN ) ) ;
ui . label ( egui ::RichText ::new ( "Your home for the most diabolical playlist of the century, \nmade by the skeevers, scallywags, chupacabras, and whores\n of the Wownero community. Join da chat to peep da scoop.\n" ) . color ( egui ::Color32 ::GREEN ) ) ;
ui . horizontal ( | ui | {
if self . player . playing {
if ui . button ( "⏸" ) . clicked ( ) {
let _ = & self . player . sink . pause ( ) ;
self . player . playing = false ;
}
} else {
if ui . button ( "▶" ) . clicked ( ) {
// If stream thread is done, start again
if self . player . stream_thread . is_finished ( ) {
self . player . stream_thread = self . player . start_radio_stream ( ) ;
}
if self . player . sink . len ( ) ! = 1 {
let source : rodio ::Decoder < std ::io ::BufReader < std ::fs ::File > > = self . player . get_radio_source ( ) ;
let _ = & self . player . sink . append ( source ) ;
}
let _ = & self . player . sink . play ( ) ;
self . player . playing = true ;
}
}
if ! self . player . stream_thread . is_finished ( ) {
ui . spinner ( ) ;
ui . label ( format! ( "{:?}" , self . player . stream_source ) ) ;
}
} ) ;
if self . player . playing {
ui . label ( egui ::RichText ::new ( format! ( "\n{:?}" , self . player . get_song_meta ( ) ) ) . color ( egui ::Color32 ::WHITE ) . size ( 24.0 ) ) ;
} else {
ui . label ( "\n" ) ;
}
} ) ;
}
}