diff --git a/jiji.project b/jiji.project index 0c38548..bd2d7fe 100644 --- a/jiji.project +++ b/jiji.project @@ -1 +1 @@ -{"categories":[{"name":"to do","content":[{"name":"clean up bot code","description":"try to remove unnecessary code\n\nunindent\n\ngive sender to function ?","id":2},{"name":"trayable ?","description":"// Hello there","id":5}]},{"name":"in progress","content":[]},{"name":"done","content":[{"name":"run discord bot","description":"make it so the bot is running","id":1},{"name":"fixed token in github","description":"// Hello there","id":1},{"name":"fetch previous messages","description":"// Hello there","id":4},{"name":"ability to write messages","description":"// Hello there","id":5},{"name":"get incoming messages","description":"read","id":2},{"name":"unread system","description":"add a * when a channel just received a message","id":1},{"name":"remember channel id for dm","description":"and put in config file\n\nmaybe load message ? dm first ?","id":3},{"name":"bug : does not save notification state for dm","description":"// Hello there","id":1},{"name":"handle unknown channel better","description":"when receiving a message from a not yet scanned guild, create the channel and put the message\n\nallow scanning if guild selected\n\ndo not add duplicate channel","id":1},{"name":"guild unread ?","description":"// Hello there","id":2},{"name":"timestamps","description":"// Hello there","id":1},{"name":"better ui error display","description":"handle the error packet for better display","id":1},{"name":"notifications !!!","description":"// Hello there","id":4},{"name":"ability to change token","description":"use a config file to store token so that \n\n1- it is away from github\n\n2- it is configurable if need be","id":1},{"name":"fix timestam (utc+2)","description":"// Hello there","id":1},{"name":"move config","description":"move config from .jiji/save.json\nto .config/jiji/config.json","id":2},{"name":"scroll to bottom when new message","description":"// Hello there","id":1}]},{"name":"bugs","content":[]},{"name":"v1.0","content":[]},{"name":"v1.1","content":[{"name":"proper links","description":"when there is a link, ability to click it","id":3},{"name":"new message marker","description":"perma if too complicated to detect read","id":2},{"name":"text emoji","description":"( ˘ w˘(˘w ˘ )","id":2}]},{"name":"+","content":[]}]} \ No newline at end of file +{"categories":[{"name":"to do","content":[{"name":"clean up bot code","description":"try to remove unnecessary code\n\nunindent\n\ngive sender to function ?","id":2},{"name":"trayable ?","description":"// Hello there","id":5}]},{"name":"in progress","content":[]},{"name":"done","content":[{"name":"run discord bot","description":"make it so the bot is running","id":1},{"name":"fixed token in github","description":"// Hello there","id":1},{"name":"fetch previous messages","description":"// Hello there","id":4},{"name":"ability to write messages","description":"// Hello there","id":5},{"name":"get incoming messages","description":"read","id":2},{"name":"unread system","description":"add a * when a channel just received a message","id":1},{"name":"remember channel id for dm","description":"and put in config file\n\nmaybe load message ? dm first ?","id":3},{"name":"bug : does not save notification state for dm","description":"// Hello there","id":1},{"name":"handle unknown channel better","description":"when receiving a message from a not yet scanned guild, create the channel and put the message\n\nallow scanning if guild selected\n\ndo not add duplicate channel","id":1},{"name":"guild unread ?","description":"// Hello there","id":2},{"name":"timestamps","description":"// Hello there","id":1},{"name":"better ui error display","description":"handle the error packet for better display","id":1},{"name":"notifications !!!","description":"// Hello there","id":4},{"name":"ability to change token","description":"use a config file to store token so that \n\n1- it is away from github\n\n2- it is configurable if need be","id":1},{"name":"fix timestam (utc+2)","description":"// Hello there","id":1},{"name":"move config","description":"move config from .jiji/save.json\nto .config/jiji/config.json","id":2},{"name":"scroll to bottom when new message","description":"// Hello there","id":1},{"name":"proper links","description":"when there is a link, ability to click it","id":3},{"name":"text emoji","description":"( ˘ w˘(˘w ˘ )","id":2}]},{"name":"bugs","content":[]},{"name":"v1.0","content":[]},{"name":"v1.1","content":[]},{"name":"+","content":[]}]} \ No newline at end of file diff --git a/src/emoji_window.rs b/src/emoji_window.rs new file mode 100644 index 0000000..f2a7315 --- /dev/null +++ b/src/emoji_window.rs @@ -0,0 +1,37 @@ +use eframe::egui; + +pub struct EmojiWindow { + pub visible: bool, +} + +impl EmojiWindow { + pub fn new() -> Self { + Self { visible: false } + } + + pub fn show(&mut self, ctx: &egui::Context) { + let mut visible = self.visible; + egui::Window::new("Emojis") + .open(&mut visible) + .vscroll(true) + .hscroll(true) + .show(ctx, |ui| self.ui(ui)); + self.visible = self.visible && visible; + } + + fn ui(&mut self, ui: &mut egui::Ui) { + ui.set_min_width(250.0); + ui.label("\\(°^°)/"); + ui.label("o(`O´)o"); + ui.label("•`_´•"); + ui.label("( ☉ _ ☉ )"); + ui.label("~(o _ o)~"); + ui.label("~(-■_■)~ ♪♬"); + ui.label("☆ (◕w◕) ☆"); + ui.label("\\(^o^)/"); + ui.label("✌(^o^)✌"); + ui.label("(♥u♥)"); + ui.label("(T_T)"); + ui.label("☭ ♥ ✿ ☢ ☠"); + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 8bd6828..dc6862a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,6 +12,8 @@ mod discord_structure; mod state; mod ui; mod app; +mod emoji_window; +use emoji_window::EmojiWindow; const MAX_FPS: f32 = 30.0; const RUNNING_REQUEST_REFRESH_DELAY: f32 = 0.2; @@ -64,6 +66,7 @@ struct Jiji { channels_to_notify: Vec, errors: Vec, redraw: bool, + emoji_window: EmojiWindow, } impl Jiji { @@ -98,6 +101,7 @@ impl Jiji { channels_to_notify: app_state.channels_to_notify.clone(), errors: vec![], redraw: false, + emoji_window: EmojiWindow::new(), } } } @@ -109,6 +113,18 @@ impl eframe::App for Jiji { )); self.next_frame = time::Instant::now(); + //if ctx.input(|i| i.key_pressed(egui::Key::Enter) && i.modifiers.ctrl) { + if ctx.input_mut(|i| i.consume_shortcut(&egui::KeyboardShortcut::new(egui::Modifiers::CTRL, egui::Key::Enter))) { + if let Some(guild_index) = self.selected_guild { + if let Some(channel_index) = self.selected_channel { + if self.current_message != "" { + let _ = self.sender.send(postman::Packet::SendMessage(self.guilds[guild_index].channels[channel_index].id.clone(), self.current_message.clone())); + self.current_message = "".to_string(); + } + } + } + } + self.handle_packets(); self.draw_selection(ctx); @@ -117,6 +133,10 @@ impl eframe::App for Jiji { self.draw_feed(ctx); + if self.emoji_window.visible { + self.emoji_window.show(ctx); + } + self.time_watch = self.next_frame.elapsed().as_micros() as f32 / 1000.0; if self.pending_bot_requests > 0 { diff --git a/src/ui.rs b/src/ui.rs index 75efe6f..050c5fe 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -4,6 +4,8 @@ use chrono::{DateTime, Local}; use crate::postman; use crate::Jiji; +const MESSAGE_EDIT_ROWS : usize = 4; + impl Jiji { pub fn draw_selection(&mut self, ctx: &egui::Context) { egui::TopBottomPanel::top("server_selection") @@ -136,14 +138,20 @@ impl Jiji { if let Some(channel_index) = self.selected_channel { ui.label(""); ui.horizontal(|ui| { - if ui.button(">").clicked() { - let _ = self.sender.send(postman::Packet::SendMessage(self.guilds[guild_index].channels[channel_index].id.clone(), self.current_message.clone())); - self.current_message = "".to_string(); - } + ui.vertical(|ui| { + if ui.button(">").clicked() && self.current_message != "" { + let _ = self.sender.send(postman::Packet::SendMessage(self.guilds[guild_index].channels[channel_index].id.clone(), self.current_message.clone())); + self.current_message = "".to_string(); + } + if ui.button("#").clicked() { + self.emoji_window.visible = !self.emoji_window.visible; + } + }); egui::ScrollArea::vertical() .show(ui, |ui| { let _response = ui.add(egui::TextEdit::multiline(&mut self.current_message) .desired_width(f32::INFINITY) + .desired_rows(MESSAGE_EDIT_ROWS) .lock_focus(true)); }); });