From 1ea6f742963f73736b8776c34b40743e8273fc31 Mon Sep 17 00:00:00 2001 From: Jaby Date: Sat, 5 Apr 2025 23:19:06 +0200 Subject: [PATCH] Move primitives around --- src/Tools/tim_tool/src/logic/project/mod.rs | 80 ++++++++++----------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/Tools/tim_tool/src/logic/project/mod.rs b/src/Tools/tim_tool/src/logic/project/mod.rs index 4dc673f6..de122807 100644 --- a/src/Tools/tim_tool/src/logic/project/mod.rs +++ b/src/Tools/tim_tool/src/logic/project/mod.rs @@ -2,6 +2,46 @@ use super::tim::types::Encoding; use serde::{Deserialize, Serialize}; use std::path::PathBuf; +#[derive(Serialize, Deserialize)] +pub struct Job { + pub name: String, + pub file_path: PathBuf, + pub image_pos: ImagePosition, + pub palette_rect: Option, + pub encoding: Encoding, +} + +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: None, encoding} + } + + pub fn create_file_path>(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)] +pub struct Project { + pub jobs: Vec +} + +impl Project { + pub fn new(jobs: Vec) -> Project { + Project{jobs} + } +} + #[derive(Serialize, Deserialize)] pub struct ImagePosition { pub x: u16, @@ -66,44 +106,4 @@ impl std::default::Default for PaletteRect { fn default() -> Self { PaletteRect{pos: ImagePosition::default(), size: ImageSize::default()} } -} - -#[derive(Serialize, Deserialize)] -pub struct Job { - pub name: String, - pub file_path: PathBuf, - pub image_pos: ImagePosition, - pub palette_rect: Option, - pub encoding: Encoding, -} - -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: None, encoding} - } - - pub fn create_file_path>(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)] -pub struct Project { - pub jobs: Vec -} - -impl Project { - pub fn new(jobs: Vec) -> Project { - Project{jobs} - } } \ No newline at end of file