Project: Support relative pathes #23

Merged
cody merged 5 commits from topic/jb/project-files_rel-path into main 2025-04-05 19:59:19 +00:00
2 changed files with 15 additions and 13 deletions
Showing only changes of commit a8ca3bf859 - Show all commits

View File

@ -77,19 +77,7 @@ pub(super) fn on_load_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
}
for job in new_project.jobs {
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 file_path = Job::create_file_path(job.file_path, open_location.as_str());
let (_, _) = tim_manager.load_unadded_tim(&file_path)?;
let (pal_width, pal_height) = job.palette_rect.size.into();

View File

@ -75,6 +75,20 @@ impl 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}
}
pub fn create_file_path<T:?Sized + std::convert::AsRef<std::ffi::OsStr>>(file_path: PathBuf, location_path: &T) -> PathBuf {
if file_path.is_file() {
file_path
}
else {
let mut new_file_path = PathBuf::from(location_path);
new_file_path.pop();
new_file_path.push(file_path);
new_file_path
}
}
}
#[derive(Serialize, Deserialize)]