From f72f92d4c2e61d195b801e0056691e0aeecb79c2 Mon Sep 17 00:00:00 2001 From: Jaby Date: Sat, 5 Apr 2025 23:36:58 +0200 Subject: [PATCH] Added storage for settings --- src/Tools/tim_tool/src/gui/main_tab/mod.rs | 8 ++++-- src/Tools/tim_tool/ui/tab/main-tab.slint | 32 ++++++++++++++++------ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/Tools/tim_tool/src/gui/main_tab/mod.rs b/src/Tools/tim_tool/src/gui/main_tab/mod.rs index a4cf8087..3f98d5fe 100644 --- a/src/Tools/tim_tool/src/gui/main_tab/mod.rs +++ b/src/Tools/tim_tool/src/gui/main_tab/mod.rs @@ -91,9 +91,11 @@ impl MainTab { image: vram_image.image, }, info: VRAMInfo { - x: vram_image.x as i32, - y: vram_image.y as i32, - encoding_str: SharedString::from(encoding_str), + x: vram_image.x as i32, + y: vram_image.y as i32, + encoding_str: SharedString::from(encoding_str), + use_compression: false, + trans_setting: 0, palette_count, is_palette, } diff --git a/src/Tools/tim_tool/ui/tab/main-tab.slint b/src/Tools/tim_tool/ui/tab/main-tab.slint index ea84031d..1682ad58 100644 --- a/src/Tools/tim_tool/ui/tab/main-tab.slint +++ b/src/Tools/tim_tool/ui/tab/main-tab.slint @@ -7,11 +7,13 @@ struct VRAMImgData { } struct VRAMInfo { - x: int, - y: int, - encoding_str: string, - palette_count: int, - is_palette: bool, // < Can we combine the palette into this, instead of having it separate? + x: int, + y: int, + encoding_str: string, + use_compression: bool, + trans_setting: int, + palette_count: int, + is_palette: bool, // < Can we combine the palette into this, instead of having it separate? } struct VRAMData { @@ -302,8 +304,14 @@ export component MainTab inherits Rectangle { VerticalLayout { alignment: start; lz4_check_box := CheckBox { - text: "Compress (lz4)"; + text: "Compress (lz4)"; enabled: file_settings_box.enabled; + + toggled => { + if(vram_files_list.current-item != -1) { + root.vram_data[vram_files_list.current-item].info.use_compression = self.checked; + } + } } GroupBox { @@ -314,13 +322,21 @@ export component MainTab inherits Rectangle { trans_combo_box := ComboBox { model: ["No transparency", "First color transparent", "PSX semi-transparency", "Both"]; enabled: file_settings_box.enabled; + + selected(current-value) => { + if(vram_files_list.current-item != -1) { + root.vram_data[vram_files_list.current-item].info.trans_setting = self.current-index; + } + } } } } } - public function set_active(item: int) { - self.enabled = true; + public function set_active(current-item: int) { + lz4_check_box.checked = root.vram_data[current-item].info.use_compression; + trans_combo_box.current-index = root.vram_data[current-item].info.trans_setting; + self.enabled = true; } public function set_inactive() {