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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
gui/src/app.rs

101 lines
4.3 KiB

use eframe::egui;
use egui::FontFamily::Proportional;
use egui::FontId;
use egui::TextStyle::*;
use crate::player::Player;
pub struct App {
pub player: Player,
pub tor_started: bool,
pub to_data: String
}
impl Default for App {
fn default() -> Self {
Self {
tor_started: 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.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");
});
egui::CentralPanel::default().show(ctx, |_ui| {
// ui.separator();
// ui.heading("Tor");
// if self.tor_started {
// ui.label("Tor started.");
// if ui.button("Clear Tor logs").clicked() {
// let _r: std::io::Result<()> = clear_tor_log();
// }
// ui.collapsing("View Tor logs:", |ui| {
// egui::ScrollArea::vertical().stick_to_bottom(true).show(ui, |ui| {
// let contents = std::fs::read_to_string(TOR_LOG.to_string()).unwrap();
// ui.label(contents);
// });
// });
// } else {
// if ui.button("Start Tor").clicked() {
// let _t: std::thread::JoinHandle<Result<u8, libtorError>> = start_tor();
// self.tor_started = true;
// }
// }
});
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");
}
});
}
}