diff --git a/src/Tools/tim_tool/src/gui/file_tab/callbacks.rs b/src/Tools/tim_tool/src/gui/file_tab/callbacks.rs index 5c44bbd0..2f3d1608 100644 --- a/src/Tools/tim_tool/src/gui/file_tab/callbacks.rs +++ b/src/Tools/tim_tool/src/gui/file_tab/callbacks.rs @@ -1,4 +1,4 @@ -use std::{fs::File, io::Write}; +use std::{fs::File, io::Write, path::PathBuf}; use crate::{gui::{self, main_tab::MainTab, MutexTIMManager, VRAM_HEIGHT, VRAM_WIDTH}, MainWindow}; use super::FileTab; @@ -62,8 +62,21 @@ pub(super) fn on_add_image(tim_manager: MutexTIMManager) -> impl FnMut(&mut File } pub(super) fn on_load_project_clicked() -> impl FnMut(&mut FileTab, &MainWindow) -> Result<(), Error> + 'static { - move |_file_tab, _main_window| { - Err(Error::not_implemented("on_load_project_clicked")) + move |_file_tab, main_window| { + let open_location = main_window.get_project_widget_open_project_path(); + if open_location.is_empty() { + return Err(Error::from_str("Please specify location for project file to open")); + } + + let file_content = tool_helper::read_file_to_string(&PathBuf::from(open_location.as_str()))?; + let _new_project = match serde_json::from_str::(&file_content) { + Ok(project) => project, + Err(error) => { + return Err(Error::from_error(error)); + } + }; + + Ok(()) } }