Slowly introducing file settings
This commit is contained in:
parent
751533dcf6
commit
9501954587
|
@ -4,7 +4,7 @@ use crate::{gui::{self, main_tab::{MainTab, NewVRAMImageInfo}, MutexTIMManager,
|
||||||
use super::FileTab;
|
use super::FileTab;
|
||||||
use rfd::FileDialog;
|
use rfd::FileDialog;
|
||||||
use slint::SharedString;
|
use slint::SharedString;
|
||||||
use tim_tool::logic::{project::{ImagePosition, Job, PaletteRect, Project}, tim::types::Encoding, TIMManager};
|
use tim_tool::logic::{project::{FileSettings, ImagePosition, Job, PaletteRect, Project}, tim::types::Encoding, TIMManager};
|
||||||
use tool_helper::Error;
|
use tool_helper::Error;
|
||||||
|
|
||||||
pub(super) fn on_browse_file(tim_manager: MutexTIMManager) -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static {
|
pub(super) fn on_browse_file(tim_manager: MutexTIMManager) -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static {
|
||||||
|
@ -88,7 +88,7 @@ pub(super) fn on_load_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
||||||
image_y: job.image_pos.y,
|
image_y: job.image_pos.y,
|
||||||
palette_x: pal_x,
|
palette_x: pal_x,
|
||||||
palette_y: pal_y,
|
palette_y: pal_y,
|
||||||
encoding: job.encoding
|
encoding: job.settings.encoding
|
||||||
};
|
};
|
||||||
add_unadded_tim(main_tab, &mut tim_manager, unadded_tim)?;
|
add_unadded_tim(main_tab, &mut tim_manager, unadded_tim)?;
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ pub(super) fn on_save_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {tim.get_path()};
|
} else {tim.get_path()};
|
||||||
cur_job = Some(Job::new(name, file_path, (vram.x as u16, vram.y as u16), Encoding::from_str(vram.encoding_str.as_str())));
|
cur_job = Some(Job::new(name, file_path, (vram.x as u16, vram.y as u16), FileSettings::compatible(Encoding::from_str(vram.encoding_str.as_str()))));
|
||||||
}
|
}
|
||||||
prev_job
|
prev_job
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,18 +2,40 @@ use super::tim::types::Encoding;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub struct FileSettings {
|
||||||
|
pub compress: bool,
|
||||||
|
pub transparency: Transparency,
|
||||||
|
pub encoding: Encoding,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FileSettings {
|
||||||
|
pub fn compatible(encoding: Encoding) -> FileSettings {
|
||||||
|
let mut new_type = FileSettings::default();
|
||||||
|
|
||||||
|
new_type.encoding = encoding;
|
||||||
|
new_type
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::default::Default for FileSettings {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self{compress: Default::default(), transparency: Transparency::None, encoding: Encoding::FullColor}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize)]
|
#[derive(Serialize, Deserialize)]
|
||||||
pub struct Job {
|
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: Option<PaletteRect>,
|
pub palette_rect: Option<PaletteRect>,
|
||||||
pub encoding: Encoding,
|
pub settings: FileSettings,
|
||||||
}
|
}
|
||||||
|
|
||||||
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), settings: FileSettings) -> Job {
|
||||||
Job{name, file_path, image_pos: ImagePosition{x: image_pos.0, y: image_pos.1}, palette_rect: None, encoding}
|
Job{name, file_path, image_pos: ImagePosition{x: image_pos.0, y: image_pos.1}, palette_rect: None, settings}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
||||||
|
@ -106,4 +128,12 @@ 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()}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
pub enum Transparency {
|
||||||
|
None,
|
||||||
|
FirstColor,
|
||||||
|
PSXSemi,
|
||||||
|
Both,
|
||||||
}
|
}
|
Loading…
Reference in New Issue