Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
Updated to new icy_engine, icy_sauce
Browse files Browse the repository at this point in the history
+ new egui.
  • Loading branch information
mkrueger committed Apr 9, 2024
1 parent 1e65f63 commit 9198bd2
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 83 deletions.
20 changes: 11 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down
19 changes: 11 additions & 8 deletions view_library/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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" }
52 changes: 27 additions & 25 deletions view_library/src/ui/file_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -33,7 +33,7 @@ pub struct FileEntry {
pub file_info: FileInfo,
pub file_data: Option<Vec<u8>>,
pub read_sauce: bool,
pub sauce: Option<SauceData>,
pub sauce: Option<SauceInformation>,
}

impl FileEntry {
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -87,7 +87,7 @@ impl FileEntry {
self.is_dir()
}

pub(crate) fn get_sauce(&self) -> Option<SauceData> {
pub(crate) fn get_sauce(&self) -> Option<SauceInformation> {
if !self.read_sauce {
return None;
}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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();
});
Expand Down
20 changes: 10 additions & 10 deletions view_library/src/ui/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand All @@ -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,
Expand All @@ -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)
}

Expand Down
63 changes: 32 additions & 31 deletions view_library/src/ui/sauce_dialog.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
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 {
CloseDialog,
}

impl SauceDialog {
pub fn new(sauce: SauceData) -> Self {
pub fn new(sauce: SauceInformation) -> Self {
Self { sauce }
}

Expand All @@ -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');
}
Expand Down

0 comments on commit 9198bd2

Please sign in to comment.