added emoji help

This commit is contained in:
WanderingPenwing 2024-07-21 19:06:50 +02:00
parent 815764bafb
commit 2ea242c5cf
4 changed files with 70 additions and 5 deletions

View file

@ -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":[]}]} {"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":[]}]}

37
src/emoji_window.rs Normal file
View file

@ -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("☭ ♥ ✿ ☢ ☠");
}
}

View file

@ -12,6 +12,8 @@ mod discord_structure;
mod state; mod state;
mod ui; mod ui;
mod app; mod app;
mod emoji_window;
use emoji_window::EmojiWindow;
const MAX_FPS: f32 = 30.0; const MAX_FPS: f32 = 30.0;
const RUNNING_REQUEST_REFRESH_DELAY: f32 = 0.2; const RUNNING_REQUEST_REFRESH_DELAY: f32 = 0.2;
@ -64,6 +66,7 @@ struct Jiji {
channels_to_notify: Vec<String>, channels_to_notify: Vec<String>,
errors: Vec<String>, errors: Vec<String>,
redraw: bool, redraw: bool,
emoji_window: EmojiWindow,
} }
impl Jiji { impl Jiji {
@ -98,6 +101,7 @@ impl Jiji {
channels_to_notify: app_state.channels_to_notify.clone(), channels_to_notify: app_state.channels_to_notify.clone(),
errors: vec![], errors: vec![],
redraw: false, redraw: false,
emoji_window: EmojiWindow::new(),
} }
} }
} }
@ -109,6 +113,18 @@ impl eframe::App for Jiji {
)); ));
self.next_frame = time::Instant::now(); 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.handle_packets();
self.draw_selection(ctx); self.draw_selection(ctx);
@ -117,6 +133,10 @@ impl eframe::App for Jiji {
self.draw_feed(ctx); 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; self.time_watch = self.next_frame.elapsed().as_micros() as f32 / 1000.0;
if self.pending_bot_requests > 0 { if self.pending_bot_requests > 0 {

View file

@ -4,6 +4,8 @@ use chrono::{DateTime, Local};
use crate::postman; use crate::postman;
use crate::Jiji; use crate::Jiji;
const MESSAGE_EDIT_ROWS : usize = 4;
impl Jiji { impl Jiji {
pub fn draw_selection(&mut self, ctx: &egui::Context) { pub fn draw_selection(&mut self, ctx: &egui::Context) {
egui::TopBottomPanel::top("server_selection") egui::TopBottomPanel::top("server_selection")
@ -136,14 +138,20 @@ impl Jiji {
if let Some(channel_index) = self.selected_channel { if let Some(channel_index) = self.selected_channel {
ui.label(""); ui.label("");
ui.horizontal(|ui| { ui.horizontal(|ui| {
if ui.button(">").clicked() { 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())); 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.current_message = "".to_string();
} }
if ui.button("#").clicked() {
self.emoji_window.visible = !self.emoji_window.visible;
}
});
egui::ScrollArea::vertical() egui::ScrollArea::vertical()
.show(ui, |ui| { .show(ui, |ui| {
let _response = ui.add(egui::TextEdit::multiline(&mut self.current_message) let _response = ui.add(egui::TextEdit::multiline(&mut self.current_message)
.desired_width(f32::INFINITY) .desired_width(f32::INFINITY)
.desired_rows(MESSAGE_EDIT_ROWS)
.lock_focus(true)); .lock_focus(true));
}); });
}); });