Projects: Inital support for saving and loading projects #22
|
@ -69,9 +69,11 @@ pub(super) fn on_load_project_clicked(tim_manager: MutexTIMManager) -> impl FnMu
|
|||
}
|
||||
};
|
||||
|
||||
for job in new_project.jobs {
|
||||
let mut tim_manager = tim_manager.lock().expect("VRAM already locked");
|
||||
|
||||
let mut tim_manager = tim_manager.lock().expect("VRAM already locked");
|
||||
clear_all_vram_images(main_tab, &mut tim_manager);
|
||||
main_window.invoke_clear_file_tab_current_selected_file();
|
||||
|
||||
for job in new_project.jobs {
|
||||
let (_, _) = tim_manager.load_unadded_tim(&job.file_path)?;
|
||||
let (pal_width, pal_height) = job.palette_rect.size.into();
|
||||
|
||||
|
@ -208,6 +210,11 @@ fn add_unadded_tim(main_tab: &mut MainTab, tim_manager: &mut TIMManager, unadded
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn clear_all_vram_images(main_tab: &mut MainTab, tim_manager: &mut TIMManager) {
|
||||
tim_manager.clear();
|
||||
main_tab.clear();
|
||||
}
|
||||
|
||||
fn create_project_file_dialog() -> FileDialog {
|
||||
FileDialog::new()
|
||||
.add_filter("TIM project file (.tim_project)", &["tim_project"])
|
||||
|
|
|
@ -72,6 +72,15 @@ impl MainTab {
|
|||
object
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
let mut vram_data = self.vram.lock().expect("VRAM already locked");
|
||||
let count = vram_data.count;
|
||||
|
||||
for _ in 0..count {
|
||||
vram_data.pop();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_new_vram_file(&mut self, file_name: &String, full_image: slint::Image, texture: NewVRAMImageInfo, image_palette: Option<NewVRAMImageInfo>) -> usize {
|
||||
let mut vram_data = self.vram.lock().expect("VRAM already locked");
|
||||
let mut add_new_image = |file_name: &String, full_image: slint::Image, vram_image: NewVRAMImageInfo, palette_count: i32, is_palette: bool| {
|
||||
|
|
|
@ -13,6 +13,10 @@ impl TIMManager {
|
|||
TIMManager{added_tims: Default::default(), unadded_tim: None}
|
||||
}
|
||||
|
||||
pub fn clear(&mut self) {
|
||||
self.added_tims.clear();
|
||||
}
|
||||
|
||||
pub fn remove_added_tim(&mut self, range: RangeInclusive<usize>) {
|
||||
let idx = *range.start();
|
||||
for _ in range {
|
||||
|
|
|
@ -80,4 +80,8 @@ export component MainWindow inherits Window {
|
|||
public function change_to_main() {
|
||||
tab_widget.current-index = 1;
|
||||
}
|
||||
|
||||
public function clear_file_tab-current_selected_file() {
|
||||
main_tab.clear_current_selection();
|
||||
}
|
||||
}
|
|
@ -179,10 +179,7 @@ export component MainTab inherits Rectangle {
|
|||
text: "Remove file";
|
||||
clicked => {
|
||||
root.remove_file_clicked(vram_files_list.current_item);
|
||||
vram_files_list.current-item = -1;
|
||||
cur_sel_x.text = 0;
|
||||
cur_sel_y.text = 0;
|
||||
cur_sel_img.visible = false;
|
||||
root.clear_current_selection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -285,4 +282,11 @@ export component MainTab inherits Rectangle {
|
|||
function get_border_width() -> int {
|
||||
return 4;
|
||||
}
|
||||
|
||||
public function clear_current_selection() {
|
||||
vram_files_list.current-item = -1;
|
||||
cur_sel_x.text = 0;
|
||||
cur_sel_y.text = 0;
|
||||
cur_sel_img.visible = false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue