You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
5.9 KiB
141 lines
5.9 KiB
use eframe::egui;
|
|
use egui::FontFamily::Proportional;
|
|
use egui::FontId;
|
|
use egui::TextStyle::*;
|
|
use crate::player::Player;
|
|
use libtor::Error as libtorError;
|
|
|
|
pub struct App {
|
|
pub player: Player,
|
|
pub tor_started: bool,
|
|
pub tor_connected: bool,
|
|
pub to_data: String,
|
|
pub show_irc: bool,
|
|
pub irc_message: String
|
|
}
|
|
|
|
impl Default for App {
|
|
fn default() -> Self {
|
|
Self {
|
|
tor_started: false,
|
|
tor_connected: false,
|
|
show_irc: false,
|
|
to_data: "".to_owned(),
|
|
player: Player::default(),
|
|
irc_message: "".to_owned()
|
|
}
|
|
}
|
|
}
|
|
|
|
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| {
|
|
let mut t: bool = false;
|
|
if ui.radio_value(&mut t, false, "tor").clicked() {
|
|
self.show_irc = false;
|
|
}
|
|
if self.tor_connected {
|
|
if ui.radio_value(&mut t, 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 {
|
|
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 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(18.0));
|
|
} else {
|
|
ui.label("\n");
|
|
}
|
|
});
|
|
// } else {
|
|
//
|
|
// }
|
|
}
|
|
} |