From 9198bd21e458389ddf7a370dee069584b16a916d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Tue, 9 Apr 2024 12:52:12 -0400 Subject: [PATCH] Updated to new icy_engine, icy_sauce + new egui. --- Cargo.toml | 20 ++++----- view_library/Cargo.toml | 19 +++++---- view_library/src/ui/file_view.rs | 52 ++++++++++++------------ view_library/src/ui/mod.rs | 20 ++++----- view_library/src/ui/sauce_dialog.rs | 63 +++++++++++++++-------------- 5 files changed, 91 insertions(+), 83 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d537ecf..6793d9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,10 +10,10 @@ repository = "https://github.com/mkrueger/icy_view" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -eframe = "0.26.0" -egui_extras = { version="0.26.0", features = ["svg", "image"] } -egui_glow = "0.26.0" -glow = "0.13.0" +eframe = "0.27.2" +egui_extras = { version="0.27.2", features = ["svg", "image"] } +egui_glow = "0.27.2" +glow = "0.13.1" memmap = "0.7.0" clap = { version="4.4.0", features = ["derive"] } zip = "0.6.6" @@ -25,15 +25,17 @@ i18n-embed-fl = "0.8.0" once_cell = "1.16.0" rust-embed = "8.0.0" egui-modal = "0.3.3" -egui-notify = "0.13.0" +egui-notify = "0.14.0" lazy_static = "1.4.0" -image = { version = "0.24", features = ["jpeg", "png", "gif", "bmp"] } +image = { version = "0.25.1", features = ["jpeg", "png", "gif", "bmp"] } view_library = { path ="./view_library" } -icy_engine = { git = "https://github.com/mkrueger/icy_engine.git" } -icy_engine_egui = { git ="https://github.com/mkrueger/icy_engine_egui" } + +icy_engine = { git ="https://github.com/mkrueger/icy_engine"} +icy_engine_gui = { git ="https://github.com/mkrueger/icy_engine"} + #icy_engine = { path ="../icy_engine" } -#icy_engine_egui = { path ="../icy_engine_egui" } +#icy_engine_gui = { path ="../icy_engine/icy_engine_gui" } github_release_check = "0.2.1" semver = "1.0.20" diff --git a/view_library/Cargo.toml b/view_library/Cargo.toml index dc45688..d338826 100644 --- a/view_library/Cargo.toml +++ b/view_library/Cargo.toml @@ -6,9 +6,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -eframe = "0.26.0" -egui_extras = { version="0.26.0", features = ["all_loaders"] } -egui_glow = "0.26.0" +eframe = "0.27.2" +egui_extras = { version="0.27.2", features = ["all_loaders"] } +egui_glow = "0.27.2" glow = "0.13.0" memmap = "0.7.0" zip = "0.6.6" @@ -20,14 +20,17 @@ i18n-embed-fl = "0.8.0" once_cell = "1.16.0" rust-embed = "8.0.0" egui-modal = "0.3.3" -egui-notify = "0.13.0" +egui-notify = "0.14.0" thiserror = "1.0" anyhow = "1.0.75" serde = "1.0.197" toml = "0.8.10" -image = { version = "0.24", features = ["jpeg", "png", "gif", "bmp"] } -icy_engine = { git = "https://github.com/mkrueger/icy_engine.git" } -icy_engine_egui = { git ="https://github.com/mkrueger/icy_engine_egui" } +image = { version = "0.25.1", features = ["jpeg", "png", "gif", "bmp"] } + +icy_sauce = { git ="https://github.com/mkrueger/icy_sauce"} +icy_engine = { git ="https://github.com/mkrueger/icy_engine"} +icy_engine_gui = { git ="https://github.com/mkrueger/icy_engine"} + #icy_engine = { path ="../../icy_engine" } -#icy_engine_egui = { path ="../../icy_engine_egui" } +#icy_engine_gui = { path ="../../icy_engine/icy_engine_gui" } \ No newline at end of file diff --git a/view_library/src/ui/file_view.rs b/view_library/src/ui/file_view.rs index 73b5164..b475510 100644 --- a/view_library/src/ui/file_view.rs +++ b/view_library/src/ui/file_view.rs @@ -5,7 +5,7 @@ use eframe::{ }; use egui::{ScrollArea, TextEdit, Ui}; use i18n_embed_fl::fl; -use icy_engine::SauceData; +use icy_sauce::SauceInformation; use std::{ env, @@ -33,7 +33,7 @@ pub struct FileEntry { pub file_info: FileInfo, pub file_data: Option>, pub read_sauce: bool, - pub sauce: Option, + pub sauce: Option, } impl FileEntry { @@ -68,7 +68,7 @@ impl FileEntry { } self.read_sauce = true; - if let Ok(Ok(Some(data))) = self.get_data(|_, data| SauceData::extract(data)) { + if let Ok(Ok(Some(data))) = self.get_data(|_, data| SauceInformation::read(data)) { self.sauce = Some(data); } } @@ -87,7 +87,7 @@ impl FileEntry { self.is_dir() } - pub(crate) fn get_sauce(&self) -> Option { + pub(crate) fn get_sauce(&self) -> Option { if !self.read_sauce { return None; } @@ -263,7 +263,7 @@ impl FileView { return true; } if let Some(sauce) = &p.sauce { - if sauce.title.to_string().to_lowercase().contains(&filter) + if sauce.title().to_string().to_lowercase().contains(&filter) /* || sauce .group .to_string() @@ -322,44 +322,46 @@ impl FileView { ui.with_layout(Layout::right_to_left(egui::Align::Center), |ui| { ui.label(fl!(crate::LANGUAGE_LOADER, "heading-title")); }); - ui.strong(sauce.title.to_string()); + ui.strong(sauce.title().to_string()); ui.end_row(); ui.with_layout(Layout::right_to_left(egui::Align::Center), |ui| { ui.label(fl!(crate::LANGUAGE_LOADER, "heading-author")); }); - ui.strong(sauce.author.to_string()); + ui.strong(sauce.author().to_string()); ui.end_row(); ui.with_layout(Layout::right_to_left(egui::Align::Center), |ui| { ui.label(fl!(crate::LANGUAGE_LOADER, "heading-group")); }); - ui.strong(sauce.group.to_string()); + ui.strong(sauce.group().to_string()); ui.end_row(); ui.with_layout(Layout::right_to_left(egui::Align::Center), |ui| { ui.label(fl!(crate::LANGUAGE_LOADER, "heading-screen-mode")); }); let mut flags: String = String::new(); - if sauce.use_ice { - flags.push_str("ICE"); - } + if let Ok(caps) = sauce.get_character_capabilities() { + if caps.use_ice { + flags.push_str("ICE"); + } - if sauce.use_letter_spacing { - if !flags.is_empty() { - flags.push(','); + if caps.use_letter_spacing { + if !flags.is_empty() { + flags.push(','); + } + flags.push_str("9px"); } - flags.push_str("9px"); - } - if sauce.use_aspect_ratio { - if !flags.is_empty() { - flags.push(','); + if caps.use_aspect_ratio { + if !flags.is_empty() { + flags.push(','); + } + flags.push_str("AR"); } - flags.push_str("AR"); - } - if flags.is_empty() { - ui.strong(RichText::new(format!("{}x{}", sauce.buffer_size.width, sauce.buffer_size.height))); - } else { - ui.strong(RichText::new(format!("{}x{} ({})", sauce.buffer_size.width, sauce.buffer_size.height, flags))); + if flags.is_empty() { + ui.strong(RichText::new(format!("{}x{}", caps.width, caps.height))); + } else { + ui.strong(RichText::new(format!("{}x{} ({})", caps.width, caps.height, flags))); + } } ui.end_row(); }); diff --git a/view_library/src/ui/mod.rs b/view_library/src/ui/mod.rs index 898f6c4..4a51029 100644 --- a/view_library/src/ui/mod.rs +++ b/view_library/src/ui/mod.rs @@ -1,12 +1,12 @@ use eframe::{ - egui::{self, load::SizedTexture, Context, CursorIcon, Image, RichText, ScrollArea, TextureOptions}, + egui::{self, load::SizedTexture, Context, CursorIcon, Image, Margin, RichText, ScrollArea, TextureOptions}, epaint::{Color32, ColorImage, Rect, Vec2}, App, Frame, }; use i18n_embed_fl::fl; use icy_engine::{parse_with_parser, rip, Buffer}; -use icy_engine_egui::{animations::Animator, BufferView, MonitorSettings}; +use icy_engine_gui::{animations::Animator, BufferView, MonitorSettings}; use std::{ env::current_dir, @@ -69,8 +69,8 @@ impl<'a> App for MainWindow<'a> { self.handle_command(command); }); let frame_no_margins = egui::containers::Frame::none() - .outer_margin(egui::style::Margin::same(0.0)) - .inner_margin(egui::style::Margin::same(0.0)) + .outer_margin(Margin::same(0.0)) + .inner_margin(Margin::same(0.0)) .fill(Color32::BLACK); egui::CentralPanel::default().frame(frame_no_margins).show(ctx, |ui| { ui.set_enabled(self.sauce_dialog.is_none() && self.help_dialog.is_none()); @@ -201,8 +201,8 @@ impl<'a> MainWindow<'a> { }); let frame_no_margins = egui::containers::Frame::none() - .outer_margin(egui::style::Margin::same(0.0)) - .inner_margin(egui::style::Margin::same(0.0)) + .outer_margin(Margin::same(0.0)) + .inner_margin(Margin::same(0.0)) .fill(Color32::BLACK); egui::CentralPanel::default().frame(frame_no_margins).show(ctx, |ui| self.paint_main_area(ui)); self.in_scroll &= self.file_view.options.auto_scroll_enabled; @@ -337,7 +337,7 @@ impl<'a> MainWindow<'a> { } } } - if response.drag_released_by(egui::PointerButton::Primary) { + if response.drag_stopped_by(egui::PointerButton::Primary) { self.drag_started = false; } if response.dragged_by(egui::PointerButton::Primary) && self.drag_started { @@ -390,7 +390,7 @@ impl<'a> MainWindow<'a> { } } - fn show_buffer_view(&mut self, ui: &mut egui::Ui, monitor_settings: MonitorSettings) -> (egui::Response, icy_engine_egui::TerminalCalc) { + fn show_buffer_view(&mut self, ui: &mut egui::Ui, monitor_settings: MonitorSettings) -> (egui::Response, icy_engine_gui::TerminalCalc) { let w = (ui.available_width() / 8.0).floor(); let scalex = (w / self.buffer_view.lock().get_width() as f32).min(2.0); let scaley = if self.buffer_view.lock().get_buffer_mut().use_aspect_ratio() { @@ -406,7 +406,7 @@ impl<'a> MainWindow<'a> { self.cur_scroll_pos.round() }; - let mut opt = icy_engine_egui::TerminalOptions { + let mut opt = icy_engine_gui::TerminalOptions { stick_to_bottom: false, scale: Some(Vec2::new(scalex, scaley)), use_terminal_height: false, @@ -431,7 +431,7 @@ impl<'a> MainWindow<'a> { } } - let (response, calc) = icy_engine_egui::show_terminal_area(ui, self.buffer_view.clone(), opt); + let (response, calc) = icy_engine_gui::show_terminal_area(ui, self.buffer_view.clone(), opt); (response, calc) } diff --git a/view_library/src/ui/sauce_dialog.rs b/view_library/src/ui/sauce_dialog.rs index b34e5e9..e6d3c15 100644 --- a/view_library/src/ui/sauce_dialog.rs +++ b/view_library/src/ui/sauce_dialog.rs @@ -1,10 +1,10 @@ use eframe::egui::{self, Layout}; use egui_modal::Modal; use i18n_embed_fl::fl; -use icy_engine::SauceData; +use icy_sauce::SauceInformation; pub struct SauceDialog { - sauce: SauceData, + sauce: SauceInformation, } pub enum Message { @@ -12,7 +12,7 @@ pub enum Message { } impl SauceDialog { - pub fn new(sauce: SauceData) -> Self { + pub fn new(sauce: SauceInformation) -> Self { Self { sauce } } @@ -27,65 +27,66 @@ impl SauceDialog { ui.with_layout(Layout::right_to_left(egui::Align::Center), |ui| { ui.label(fl!(crate::LANGUAGE_LOADER, "sauce-dialog-title-label")); }); - ui.add(egui::TextEdit::singleline(&mut self.sauce.title.to_string().as_str()).char_limit(35)); + ui.add(egui::TextEdit::singleline(&mut self.sauce.title().to_string().as_str()).char_limit(35)); ui.end_row(); ui.with_layout(Layout::right_to_left(egui::Align::Center), |ui| { ui.label(fl!(crate::LANGUAGE_LOADER, "sauce-dialog-author-label")); }); - ui.add(egui::TextEdit::singleline(&mut self.sauce.author.to_string().as_str()).char_limit(20)); + ui.add(egui::TextEdit::singleline(&mut self.sauce.author().to_string().as_str()).char_limit(20)); ui.end_row(); ui.with_layout(Layout::right_to_left(egui::Align::Center), |ui| { ui.label(fl!(crate::LANGUAGE_LOADER, "sauce-dialog-group-label")); }); - ui.add(egui::TextEdit::singleline(&mut self.sauce.group.to_string().as_str()).char_limit(20)); + ui.add(egui::TextEdit::singleline(&mut self.sauce.group().to_string().as_str()).char_limit(20)); ui.end_row(); ui.with_layout(Layout::right_to_left(egui::Align::Center), |ui| { ui.label(fl!(crate::LANGUAGE_LOADER, "sauce-dialog-date-label")); }); - let t = self.sauce.creation_time.format("%Y-%m-%d").to_string(); + let t = self.sauce.get_date().unwrap().format("%Y-%m-%d").to_string(); ui.add(egui::TextEdit::singleline(&mut t.as_str()).char_limit(20)); ui.end_row(); + if let Ok(caps) = self.sauce.get_character_capabilities() { + if let Some(font) = &caps.font_opt { + ui.with_layout(Layout::right_to_left(egui::Align::Center), |ui| { + ui.label(fl!(crate::LANGUAGE_LOADER, "sauce-dialog-font-name")); + }); + ui.add(egui::TextEdit::singleline(&mut font.to_string()).char_limit(20)); + ui.end_row(); + } - if let Some(font) = &self.sauce.font_opt { ui.with_layout(Layout::right_to_left(egui::Align::Center), |ui| { - ui.label(fl!(crate::LANGUAGE_LOADER, "sauce-dialog-font-name")); + ui.label(fl!(crate::LANGUAGE_LOADER, "sauce-dialog-flags-label")); }); - ui.add(egui::TextEdit::singleline(&mut font.as_str()).char_limit(20)); - ui.end_row(); - } - - ui.with_layout(Layout::right_to_left(egui::Align::Center), |ui| { - ui.label(fl!(crate::LANGUAGE_LOADER, "sauce-dialog-flags-label")); - }); - let mut flags: String = String::new(); - if self.sauce.use_ice { - flags.push_str("ice colors"); - } + let mut flags: String = String::new(); + if caps.use_ice { + flags.push_str("ice colors"); + } - if self.sauce.use_letter_spacing { - if !flags.is_empty() { - flags.push_str(", "); + if caps.use_letter_spacing { + if !flags.is_empty() { + flags.push_str(", "); + } + flags.push_str("letter spacing"); } - flags.push_str("letter spacing"); - } - if self.sauce.use_aspect_ratio { - if !flags.is_empty() { - flags.push_str(", "); + if caps.use_aspect_ratio { + if !flags.is_empty() { + flags.push_str(", "); + } + flags.push_str("aspect ratio"); } - flags.push_str("aspect ratio"); + ui.add(egui::TextEdit::singleline(&mut flags.to_string().as_str()).char_limit(20)); } - ui.add(egui::TextEdit::singleline(&mut flags.to_string().as_str()).char_limit(20)); ui.end_row(); }); let mut tmp_str = String::new(); - for s in &self.sauce.comments { + for s in self.sauce.comments() { tmp_str.push_str(&s.to_string()); tmp_str.push('\n'); }