master
lza_menace 2 years ago
parent 98da1fa23d
commit 6843d15385

@ -1,4 +1,6 @@
use std::time::{Duration, SystemTime};
use std::io::Write;
use std::net::TcpStream;
use eframe::egui;
use egui::FontFamily::Proportional;
use egui::FontId;
@ -20,7 +22,9 @@ pub struct App {
pub show_irc: bool,
pub irc_message: String,
pub irc_connected: bool,
pub show_market_data: bool
pub show_market_data: bool,
pub show_radio: bool,
pub irc_stream: Result<TcpStream, std::io::Error>,
}
impl Default for App {
@ -36,7 +40,9 @@ impl Default for App {
show_irc: false,
irc_connected: false,
to_data: "".to_owned(),
irc_message: "".to_owned()
irc_message: "".to_owned(),
show_radio: true,
irc_stream: TcpStream::connect("0.0.0.0:0")
}
}
}
@ -73,10 +79,14 @@ impl eframe::App for App {
if (self.tor_connected && self.tor_required) || (! self.tor_required) {
ui.checkbox(&mut self.show_market_data, "Show Market Data");
ui.checkbox(&mut self.show_irc, "Show IRC");
ui.checkbox(&mut self.show_radio, "Show Radio");
}
});
ui.separator();
// WOW!Radio
if self.show_radio {
ui.heading(egui::RichText::new("WOW!Radio").color(egui::Color32::WHITE));
ui.label(egui::RichText::new("Your home for the most diabolical playlist of the century, made by the skeevers, scallywags, chupacabras, snails, and whores of the Wownero community. Join da chat to peep da scoop.\n").color(egui::Color32::WHITE));
ui.horizontal(|ui| {
@ -123,6 +133,7 @@ impl eframe::App for App {
}
});
// Show spinner when downloading, along with file size
if ! self.player.stream_thread.is_finished() {
ui.horizontal(|ui| {
@ -149,11 +160,12 @@ impl eframe::App for App {
self.player.exif_date = SystemTime::now();
self.player.stream_exif = self.player.get_song_meta().unwrap();
}
if ui.button("!tune - i love this song!").clicked() {
if ui.button("| +1 |").clicked() {
let _ = self.irc.send_tune();
}
}
ui.separator();
}
// Tor
if self.tor_required {
@ -161,7 +173,7 @@ impl eframe::App for App {
ui.label(
egui::RichText::new(
format!(
"Tor Started: {}\nTor Connected: {}\nProxy Up: {}",
"Tor Started: {} Tor Connected: {} Proxy Up: {}",
show_boolmoji(self.tor_started),
show_boolmoji(self.tor_connected),
show_boolmoji(self.tor_connected)
@ -179,17 +191,20 @@ impl eframe::App for App {
// IRC
if self.show_irc && ! self.irc_connected {
self.irc.run().expect("wtf mate");
self.irc_stream = self.irc.run();
self.irc_connected = true;
} else if self.show_irc {
egui::ScrollArea::vertical().stick_to_bottom(true).show(ui, |ui| {
ui.label(self.irc.read_irc_log());
ui.horizontal(|ui| {
ui.text_edit_singleline(&mut self.irc_message);
if ui.button("> Send <").clicked() {
// send_cmd(self.irc.)
let _ = self.irc_stream.as_ref().unwrap().write(self.irc_message.as_bytes());
// let _ = crate::irc::send_cmd(&self.irc_stream.as_ref(), cmd, "");
self.irc_message = "".to_owned();
}
});
});
}
// Market

@ -34,8 +34,8 @@ fn connect(nick: String) -> std::io::Result<TcpStream> {
send_cmd(&send_stream, "USER", user_string)?;
send_cmd(&send_stream, "NICK", nick_string)?;
send_cmd(&send_stream, "JOIN", format!("#wownero\r\n"))?;
send_cmd(&send_stream, "JOIN", format!("#wownero-music\r\n"))?;
send_cmd(&send_stream, "JOIN", format!("#wownero"))?;
send_cmd(&send_stream, "JOIN", format!("#wownero-music"))?;
Ok(send_stream)
}
@ -213,12 +213,12 @@ impl Client {
/// main thread takes user input and matches it to commands
/// after commands and processed and messages verified,
/// the send stream is used to send command/message combinations.
pub fn run(&self) -> std::io::Result<()> {
pub fn run(&self) -> Result<TcpStream, std::io::Error> {
let send_stream = connect(self.nick.to_owned())?;
let recv_stream = send_stream.try_clone()?;
// https://doc.rust-lang.org/nightly/std/thread/
thread::spawn(move || receive(&recv_stream).expect("error setting up recv_stream"));
Ok(())
Ok(send_stream)
// Read the input.
// loop {