Save encoding information
This commit is contained in:
parent
e0a266317e
commit
2345b3da57
|
@ -103,7 +103,7 @@ pub(super) fn on_save_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
|||
if let Some((width, height)) = tim.get_palette_size() {
|
||||
cur_palette = Some(PaletteRect::new(0, 0, width, height));
|
||||
}
|
||||
cur_job = Some(Job::new(file_name, tim.get_path(), (vram.x as u16, vram.y as u16)));
|
||||
cur_job = Some(Job::new(file_name, tim.get_path(), (vram.x as u16, vram.y as u16), Encoding::from_str(vram.encoding_str.as_str())));
|
||||
}
|
||||
prev_job
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use super::tim::types::Encoding;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
@ -61,16 +62,20 @@ pub struct Job {
|
|||
file_path: PathBuf,
|
||||
image_pos: ImagePosition,
|
||||
palette_rect: PaletteRect,
|
||||
encoding: Encoding,
|
||||
}
|
||||
|
||||
impl Job {
|
||||
pub fn new(name: String, file_path: PathBuf, image_pos: (u16, u16)) -> Job {
|
||||
Job{name, file_path, image_pos: ImagePosition{x: image_pos.0, y: image_pos.1}, palette_rect: PaletteRect::default()}
|
||||
pub fn new(name: String, file_path: PathBuf, image_pos: (u16, u16), encoding: Encoding) -> Job {
|
||||
Job{name, file_path, image_pos: ImagePosition{x: image_pos.0, y: image_pos.1}, palette_rect: PaletteRect::default(), encoding}
|
||||
}
|
||||
|
||||
pub fn add_palette(&mut self, palette_rect: PaletteRect) -> &mut Self {
|
||||
pub fn add_encoding(&mut self, encoding: Encoding) {
|
||||
self.encoding = encoding;
|
||||
}
|
||||
|
||||
pub fn add_palette(&mut self, palette_rect: PaletteRect) {
|
||||
self.palette_rect = palette_rect;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#[derive(Clone, Copy)]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Copy, Deserialize, Serialize)]
|
||||
pub enum Encoding {
|
||||
FourBit,
|
||||
EightBit,
|
||||
|
@ -17,4 +19,13 @@ impl Encoding {
|
|||
Encoding::FullColor => Self::FULL_COLOR_NAME,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_str(str: &str) -> Encoding {
|
||||
match str {
|
||||
Self::FOUR_BIT_NAME => Encoding::FourBit,
|
||||
Self::EIGHT_BIT_NAME => Encoding::EightBit,
|
||||
Self::FULL_COLOR_NAME => Encoding::FullColor,
|
||||
_ => Encoding::FullColor,
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue