Make palette optional
This commit is contained in:
parent
5cd29460fb
commit
5a1997873d
|
@ -77,17 +77,17 @@ pub(super) fn on_load_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
||||||
}
|
}
|
||||||
|
|
||||||
for job in new_project.jobs {
|
for job in new_project.jobs {
|
||||||
let file_path = Job::create_file_path(job.file_path, open_location.as_str());
|
let file_path = Job::create_file_path(job.file_path, open_location.as_str());
|
||||||
let (_, _) = tim_manager.load_unadded_tim(&file_path)?;
|
let (_, _) = tim_manager.load_unadded_tim(&file_path)?;
|
||||||
let (pal_width, pal_height) = job.palette_rect.size.into();
|
let (pal_x, pal_y, pal_width, pal_height) = if let Some(palette_rect) = job.palette_rect {palette_rect.into()} else {(0, 0, 0, 0)};
|
||||||
|
|
||||||
tim_manager.change_unadded_tim_palette_size(pal_width, pal_height)?;
|
tim_manager.change_unadded_tim_palette_size(pal_width, pal_height)?;
|
||||||
let unadded_tim = UnaddedTIM{
|
let unadded_tim = UnaddedTIM{
|
||||||
file_name: &job.name,
|
file_name: &job.name,
|
||||||
image_x: job.image_pos.x,
|
image_x: job.image_pos.x,
|
||||||
image_y: job.image_pos.y,
|
image_y: job.image_pos.y,
|
||||||
palette_x: job.palette_rect.pos.x,
|
palette_x: pal_x,
|
||||||
palette_y: job.palette_rect.pos.y,
|
palette_y: pal_y,
|
||||||
encoding: job.encoding
|
encoding: job.encoding
|
||||||
};
|
};
|
||||||
add_unadded_tim(main_tab, &mut tim_manager, unadded_tim)?;
|
add_unadded_tim(main_tab, &mut tim_manager, unadded_tim)?;
|
||||||
|
@ -126,7 +126,7 @@ pub(super) fn on_save_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
||||||
if let Some(mut cur_palette) = cur_palette {
|
if let Some(mut cur_palette) = cur_palette {
|
||||||
cur_palette.pos = ImagePosition::new(vram.x as u16, vram.y as u16);
|
cur_palette.pos = ImagePosition::new(vram.x as u16, vram.y as u16);
|
||||||
if let Some(cur_job) = &mut cur_job {
|
if let Some(cur_job) = &mut cur_job {
|
||||||
cur_job.palette_rect = cur_palette;
|
cur_job.palette_rect = Some(cur_palette);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
|
|
@ -56,6 +56,12 @@ impl PaletteRect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<PaletteRect> for (u16, u16, u16, u16) {
|
||||||
|
fn from(value: PaletteRect) -> Self {
|
||||||
|
(value.pos.x, value.pos.y, value.size.width, value.size.height)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl std::default::Default for PaletteRect {
|
impl std::default::Default for PaletteRect {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
PaletteRect{pos: ImagePosition::default(), size: ImageSize::default()}
|
PaletteRect{pos: ImagePosition::default(), size: ImageSize::default()}
|
||||||
|
@ -67,13 +73,13 @@ pub struct Job {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub file_path: PathBuf,
|
pub file_path: PathBuf,
|
||||||
pub image_pos: ImagePosition,
|
pub image_pos: ImagePosition,
|
||||||
pub palette_rect: PaletteRect,
|
pub palette_rect: Option<PaletteRect>,
|
||||||
pub encoding: Encoding,
|
pub encoding: Encoding,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Job {
|
impl Job {
|
||||||
pub fn new(name: String, file_path: PathBuf, image_pos: (u16, u16), encoding: Encoding) -> Job {
|
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}
|
Job{name, file_path, image_pos: ImagePosition{x: image_pos.0, y: image_pos.1}, palette_rect: None, encoding}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_file_path<T:?Sized + std::convert::AsRef<std::ffi::OsStr>>(file_path: PathBuf, location_path: &T) -> PathBuf {
|
pub fn create_file_path<T:?Sized + std::convert::AsRef<std::ffi::OsStr>>(file_path: PathBuf, location_path: &T) -> PathBuf {
|
||||||
|
|
Loading…
Reference in New Issue