use eframe::egui; use egui::FontFamily::Proportional; use egui::FontId; use egui::TextStyle::*; use crate::player::Player; // use crate::irc::IRC; pub struct App { pub player: Player, pub tor_started: bool, pub tor_connected: bool, pub tor_thread: std::thread::JoinHandle<()>, pub to_data: String, pub show_irc: bool } impl Default for App { fn default() -> Self { Self { tor_started: false, tor_connected: false, tor_thread: std::thread::spawn(move|| {}), show_irc: false, to_data: "".to_owned(), player: Player::default() } } } impl eframe::App for App { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { let mut style = (*ctx.style()).clone(); 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(); 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(format!("Tor connected: {}", self.tor_connected)); 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; } } 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 self.tor_thread.is_finished() { let t: Result, std::io::Error> = std::thread::Builder::new().name("tor_thread".to_string()).spawn(move || { let _ = crate::start_tor(); }); self.tor_thread = t.unwrap(); self.tor_started = true; } } } else { if ui.button("connect IRC").clicked() { let _ = std::thread::Builder::new().name("irc_thread".to_string()).spawn(move || async { // }); } ui.heading("IRC"); if self.tor_started { ui.label("Chat wit da braddahs and sistas"); egui::ScrollArea::vertical().stick_to_bottom(true).show(ui, |ui| { // let mut bod = "connecting"; let contents = std::fs::read_to_string(crate::IRC_LOG.to_string()); if contents.is_ok() { let bod = contents.unwrap(); ui.label(bod); } else { ui.label("connecting".to_owned()); } }); // ui.horizontal(|ui| { // ui.text_edit_singleline(&mut self.irc.message); // if ui.button("|> Send <|").clicked() { // let _ = self.irc.send_message(self.irc.message.clone()); // let _ = self.irc.clear_message(); // } // }); } else { ui.label("You should connect to Tor network first brah"); } } }); // 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, \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; } ui.add(egui::Slider::new(&mut self.player.volume, 0.0..=100.0)); self.player.sink.set_volume(self.player.volume / 100.0); } 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 rs = self.player.get_radio_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); } else { return () } } 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().unwrap())).color(egui::Color32::WHITE).size(18.0)); } else { ui.label("\n"); } }); // } else { // // } } }