Support saving palette information
This commit is contained in:
@@ -4,7 +4,7 @@ use crate::{gui::{self, main_tab::MainTab, MutexTIMManager, VRAM_HEIGHT, VRAM_WI
|
||||
use super::FileTab;
|
||||
use rfd::FileDialog;
|
||||
use slint::SharedString;
|
||||
use tim_tool::logic::{project::{Job, PaletteRect, Project}, tim::types::Encoding};
|
||||
use tim_tool::logic::{project::{ImagePosition, Job, PaletteRect, Project}, tim::types::Encoding};
|
||||
use tool_helper::Error;
|
||||
|
||||
pub(super) fn on_browse_file(tim_manager: MutexTIMManager) -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static {
|
||||
@@ -81,10 +81,17 @@ pub(super) fn on_save_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
||||
return Err(Error::from_str("TIM and VRAM info not in sync! Please close program"));
|
||||
}
|
||||
|
||||
let mut cur_job = None;
|
||||
let mut project = Project::new(tim_info.into_iter().zip(vram_info.into_iter()).filter_map(|(tim, (file_name, vram))| {
|
||||
let mut cur_job:Option<Job> = None;
|
||||
let mut cur_palette:Option<PaletteRect> = None;
|
||||
let mut project = Project::new(tim_info.into_iter().zip(vram_info.into_iter()).filter_map(|(tim, (file_name, vram))| {
|
||||
if vram.is_palette {
|
||||
// Add palette to cur_job
|
||||
let cur_palette = std::mem::replace(&mut cur_palette, None);
|
||||
if let Some(mut cur_palette) = cur_palette {
|
||||
cur_palette.pos = ImagePosition::new(vram.x as u16, vram.y as u16);
|
||||
if let Some(cur_job) = &mut cur_job {
|
||||
cur_job.add_palette(cur_palette);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
@@ -93,12 +100,10 @@ pub(super) fn on_save_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
||||
let prev_job = std::mem::replace(&mut cur_job, None);
|
||||
|
||||
if let Some(tim) = tim {
|
||||
let mut job = Job::new(file_name, tim.get_path(), (vram.x as u16, vram.y as u16));
|
||||
|
||||
if let Some((width, height)) = tim.get_palette_size() {
|
||||
job.add_palette(PaletteRect::new(0, 0, width, height));
|
||||
cur_palette = Some(PaletteRect::new(0, 0, width, height));
|
||||
}
|
||||
cur_job = Some(job);
|
||||
cur_job = Some(Job::new(file_name, tim.get_path(), (vram.x as u16, vram.y as u16)));
|
||||
}
|
||||
prev_job
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user