Create a simple Job
This commit is contained in:
parent
b394330405
commit
7a197d9b71
|
@ -1,10 +1,8 @@
|
|||
use std::fmt::format;
|
||||
|
||||
use crate::{gui::{main_tab::MainTab, MutexTIMManager, VRAM_HEIGHT, VRAM_WIDTH}, MainWindow, VRAMInfo};
|
||||
use crate::{gui::{main_tab::MainTab, MutexTIMManager, VRAM_HEIGHT, VRAM_WIDTH}, MainWindow};
|
||||
use super::FileTab;
|
||||
use rfd::FileDialog;
|
||||
use slint::SharedString;
|
||||
use tim_tool::logic::{project::{Job, Project}, tim::{self, types::Encoding}};
|
||||
use tim_tool::logic::{project::{Job, 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 {
|
||||
|
@ -77,7 +75,7 @@ pub(super) fn on_save_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
|||
}
|
||||
|
||||
let mut cur_job = None;
|
||||
let mut project = Project::new(tim_info.into_iter().zip(vram_info.into_iter()).filter_map(|(tim, vram)| {
|
||||
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
|
||||
None
|
||||
|
@ -85,9 +83,11 @@ pub(super) fn on_save_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
|||
|
||||
else {
|
||||
// We are done with the old job
|
||||
let prev_job = std::mem::replace(&mut cur_job, None);
|
||||
let prev_job = std::mem::replace(&mut cur_job, None);
|
||||
|
||||
cur_job = Some(Job::new("Planschi".to_owned(), std::path::PathBuf::from("value")));
|
||||
if let Some(tim) = tim {
|
||||
cur_job = Some(Job::new(file_name, tim.get_path()));
|
||||
}
|
||||
prev_job
|
||||
}
|
||||
}).collect());
|
||||
|
@ -95,7 +95,7 @@ pub(super) fn on_save_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
|||
project.push(cur_job);
|
||||
}
|
||||
|
||||
Err(Error::from_text(format!("Adding {} jobs", project.len())))
|
||||
Err(Error::from_text(format!("Adding {:?} jobs", project)))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -155,13 +155,11 @@ impl MainTab {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn clone_vram_info(&self) -> Vec<VRAMInfo> {
|
||||
let vram_data = self.vram.lock().expect("VRAM already locked");
|
||||
let mut infos = Vec::new();
|
||||
pub fn clone_vram_info(&self) -> Vec<(String, VRAMInfo)> {
|
||||
let vram_data = self.vram.lock().expect("VRAM already locked");
|
||||
|
||||
for vram_data in vram_data.info.iter() {
|
||||
infos.push(vram_data.info.clone());
|
||||
}
|
||||
infos
|
||||
vram_data.info.iter().zip(vram_data.file_list.iter()).map(|(vram_data, file_name)| {
|
||||
(file_name.text.to_string(), vram_data.info.clone())
|
||||
}).collect()
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Job {
|
||||
name: String,
|
||||
file_path: PathBuf,
|
||||
|
@ -11,6 +12,7 @@ impl Job {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Project {
|
||||
jobs: Vec<Job>
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use types::Encoding;
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct TIMInfo {
|
||||
_path: PathBuf,
|
||||
path: PathBuf,
|
||||
image_data: SharedPixelBuffer<Rgba8Pixel>,
|
||||
palette: Option<PaletteInfo>,
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ impl TIMInfo {
|
|||
_ => {return Err(Error::from_str("Only 4 and 8bit color depth are supported for indexed color images"));}
|
||||
}
|
||||
}
|
||||
Ok(TIMInfo{_path: path.clone(), image_data, palette: Some(PaletteInfo::new(palette_colors))})
|
||||
Ok(TIMInfo{path: path.clone(), image_data, palette: Some(PaletteInfo::new(palette_colors))})
|
||||
}
|
||||
|
||||
else {
|
||||
|
@ -71,7 +71,7 @@ impl TIMInfo {
|
|||
_ => {return Err(Error::from_str("Only 8bit color depth are supported for direct color images"));}
|
||||
}
|
||||
}
|
||||
Ok(TIMInfo{_path: path.clone(), image_data, palette: None})
|
||||
Ok(TIMInfo{path: path.clone(), image_data, palette: None})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,6 +118,10 @@ impl TIMInfo {
|
|||
None
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_path(&self) -> std::path::PathBuf {
|
||||
self.path.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
|
|
Loading…
Reference in New Issue