Project: Support relative pathes #23
|
@ -77,11 +77,32 @@ 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 (_, _) = tim_manager.load_unadded_tim(&job.file_path)?;
|
let file_path = {
|
||||||
|
if job.file_path.is_file() {
|
||||||
|
job.file_path
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
let mut new_file_path = PathBuf::from(open_location.as_str());
|
||||||
|
|
||||||
|
new_file_path.pop();
|
||||||
|
new_file_path.push(job.file_path);
|
||||||
|
new_file_path
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let (_, _) = tim_manager.load_unadded_tim(&file_path)?;
|
||||||
let (pal_width, pal_height) = job.palette_rect.size.into();
|
let (pal_width, pal_height) = job.palette_rect.size.into();
|
||||||
|
|
||||||
tim_manager.change_unadded_tim_palette_size(pal_width, pal_height)?;
|
tim_manager.change_unadded_tim_palette_size(pal_width, pal_height)?;
|
||||||
add_unadded_tim(main_tab, &mut tim_manager, UnaddedTIM::from_job(&job))?;
|
let unadded_tim = UnaddedTIM{
|
||||||
|
file_name: &job.name,
|
||||||
|
image_x: job.image_pos.x,
|
||||||
|
image_y: job.image_pos.y,
|
||||||
|
palette_x: job.palette_rect.pos.x,
|
||||||
|
palette_y: job.palette_rect.pos.y,
|
||||||
|
encoding: job.encoding
|
||||||
|
};
|
||||||
|
add_unadded_tim(main_tab, &mut tim_manager, unadded_tim)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
main_window.invoke_change_to_main();
|
main_window.invoke_change_to_main();
|
||||||
|
@ -209,10 +230,6 @@ impl<'a> UnaddedTIM<'a> {
|
||||||
pub fn new(file_name: &String, encoding: Encoding,) -> UnaddedTIM {
|
pub fn new(file_name: &String, encoding: Encoding,) -> UnaddedTIM {
|
||||||
UnaddedTIM{file_name, image_x: 0, image_y: 0, palette_x: 0, palette_y: 0, encoding}
|
UnaddedTIM{file_name, image_x: 0, image_y: 0, palette_x: 0, palette_y: 0, encoding}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_job(job: &Job) -> UnaddedTIM {
|
|
||||||
UnaddedTIM{file_name: &job.name, image_x: job.image_pos.x, image_y: job.image_pos.y, palette_x: job.palette_rect.pos.x, palette_y: job.palette_rect.pos.y, encoding: job.encoding }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn add_unadded_tim(main_tab: &mut MainTab, tim_manager: &mut TIMManager, unadded_tim: UnaddedTIM) -> Result<(), Error> {
|
fn add_unadded_tim(main_tab: &mut MainTab, tim_manager: &mut TIMManager, unadded_tim: UnaddedTIM) -> Result<(), Error> {
|
||||||
|
|
Loading…
Reference in New Issue