@ -1,3 +1,4 @@
use std ::time ::{ Duration , SystemTime } ;
use eframe ::egui ;
use egui ::FontFamily ::Proportional ;
use egui ::FontId ;
@ -41,73 +42,26 @@ impl eframe::App for App {
] . into ( ) ;
ctx . set_style ( style ) ;
ctx . set_visuals ( egui ::Visuals ::dark ( ) ) ;
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" ) ;
} ) ;
egui ::CentralPanel ::default ( ) . show ( ctx , | ui | {
ui . horizontal ( | ui | {
if ui . radio_value ( & mut self . show_irc , false , "tor" ) . clicked ( ) {
self . show_irc = false ;
}
if ui . radio_value ( & mut ! self . show_irc , false , "irc" ) . clicked ( ) {
self . show_irc = true ;
}
} ) ;
if ! self . show_irc {
ui . heading ( "Tor" ) ;
if self . tor_started {
ui . label ( "Tor started." ) ;
if ui . button ( "Clear Tor logs" ) . clicked ( ) {
let _r : std ::io ::Result < ( ) > = crate ::clear_tor_log ( ) ;
}
if ui . button ( "Check Connection" ) . clicked ( ) {
if self . player . check_radio_stream ( ) {
self . tor_connected = true ;
}
}
ui . collapsing ( "View Tor logs:" , | ui | {
egui ::ScrollArea ::vertical ( ) . stick_to_bottom ( true ) . show ( ui , | ui | {
let contents = std ::fs ::read_to_string ( crate ::TOR_LOG . to_string ( ) ) . unwrap ( ) ;
ui . label ( contents ) ;
} ) ;
} ) ;
} else {
if ui . button ( "Start Tor" ) . clicked ( ) {
let _t : std ::thread ::JoinHandle < Result < u8 , libtorError > > = crate ::start_tor ( ) ;
self . tor_started = true ;
}
}
} else {
ui . heading ( "IRC" ) ;
if self . tor_started {
ui . label ( "Chat wit da braddahs and sistas" ) ;
ui . text_edit_singleline ( & mut self . irc_message ) ;
if ui . button ( "[> Send <]" ) . clicked ( ) {
let _r : std ::io ::Result < ( ) > = crate ::clear_tor_log ( ) ;
}
} else {
ui . label ( "You should connect to Tor network first brah" ) ;
}
}
} ) ;
// if self.tor_connected {
// Show volume controls
if self . tor_connected {
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, \n made 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 . label ( egui ::RichText ::new ( "Your home for the most diabolical playlist of the century, made by the skeevers, scallywags, chupacabras, and whores 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 ( ) ;
// let _ = &self.player.sink.stop();
self . player . playing = false ;
}
ui . add ( egui ::Slider ::new ( & mut self . player . volume , 0. 0 ..= 100.0 ) ) ;
self . player . sink . set_volume ( self . player . volume / 100.0 ) ;
// self.player.sink.stop();
} else {
if ui . button ( "▶" ) . clicked ( ) {
// If stream thread is done, start again
@ -115,12 +69,15 @@ impl eframe::App for App {
self . player . stream_thread = self . player . start_radio_stream ( ) ;
}
if self . player . sink . len ( ) ! = 1 {
// let rs = self.player.get_radio_source();
let _ = self . player . wait_for_source ( ) ;
let f = std ::fs ::File ::open ( & crate ::RADIO_STREAM ) ;
if let Ok ( fo ) = f {
let file = std ::io ::BufReader ::new ( fo ) ;
let source = rodio ::Decoder ::new ( file ) . unwrap ( ) ;
let _ = & self . player . sink . append ( source ) ;
let source = rodio ::Decoder ::new ( file ) ;
if source . is_err ( ) {
return ( )
}
let _ = self . player . sink . append ( source . unwrap ( ) ) ;
} else {
return ( )
}
@ -129,19 +86,70 @@ impl eframe::App for App {
self . player . playing = true ;
}
}
if ! self . player . stream_thread . is_finished ( ) {
ui . spinner ( ) ;
ui . label ( format! ( "{:?}" , self . player . stream_source ) ) ;
}
} ) ;
// Show spinner when downloading, along with file size
if ! self . player . stream_thread . is_finished ( ) {
ui . horizontal ( | ui | {
ui . spinner ( ) ;
let size : u64 ;
let file = std ::fs ::File ::open ( crate ::RADIO_STREAM ) ;
if file . is_ok ( ) {
size = file . unwrap ( ) . metadata ( ) . unwrap ( ) . len ( ) ;
} else {
size = 0 ;
}
ui . label ( format! (
"{:?} -> {} ({} bytes)" ,
self . player . stream_source ,
crate ::RADIO_STREAM ,
size
) ) ;
} ) ;
}
if self . player . playing {
ui . label ( egui ::RichText ::new ( format! ( "\n{:?}" , self . player . get_song_meta ( ) . unwrap ( ) ) ) . color ( egui ::Color32 ::WHITE ) . size ( 18.0 ) ) ;
} else {
ui . label ( "\n" ) ;
let rt = egui ::RichText ::new (
format! ( "\n{:?}" , self . player . stream_exif ) )
. color ( egui ::Color32 ::WHITE )
. size ( 18.0 ) ;
ui . label ( rt ) ;
let dur = self . player . exif_date . elapsed ( ) . unwrap ( ) ;
if dur > Duration ::from_secs ( 10 ) {
self . player . exif_date = SystemTime ::now ( ) ;
self . player . stream_exif = self . player . get_song_meta ( ) . unwrap ( ) ;
}
}
ui . label ( "" ) ;
} ) ;
// } else {
//
// }
}
egui ::CentralPanel ::default ( ) . show ( ctx , | ui | {
if self . tor_started {
ui . label ( "Tor started." ) ;
if ui . button ( "Clear Tor logs" ) . clicked ( ) {
let _r : std ::io ::Result < ( ) > = crate ::clear_tor_log ( ) ;
}
if ui . button ( "Check Proxy" ) . clicked ( ) {
if self . player . check_proxy ( ) {
self . tor_connected = true ;
}
}
ui . collapsing ( "View Tor logs:" , | ui | {
egui ::ScrollArea ::vertical ( ) . stick_to_bottom ( true ) . show ( ui , | ui | {
let contents = std ::fs ::read_to_string ( crate ::TOR_LOG . to_string ( ) ) . unwrap ( ) ;
ui . label ( contents ) ;
} ) ;
} ) ;
} else {
if ui . button ( "Enter the WOW!Verse" ) . clicked ( ) {
let _t : std ::thread ::JoinHandle < Result < u8 , libtorError > > = crate ::start_tor ( ) ;
self . tor_started = true ;
self . tor_connected = true ;
}
}
} ) ;
}
}