From ccfcfeee936cbed36dcf7fed4a016b251762ab0a Mon Sep 17 00:00:00 2001 From: onsdagens Date: Thu, 12 Oct 2023 15:21:02 +0200 Subject: [PATCH] hacky autosave on each change, for now just dump it all in autosave.json --- src/gui_egui/library.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui_egui/library.rs b/src/gui_egui/library.rs index 7a00343f..5b172bee 100644 --- a/src/gui_egui/library.rs +++ b/src/gui_egui/library.rs @@ -1,4 +1,4 @@ -use crate::common::EguiComponent; +use crate::common::{EguiComponent, ComponentStore}; use crate::gui_egui::gui::EguiExtra; use crate::gui_egui::{ editor::{Editor, EditorMode}, @@ -6,7 +6,7 @@ use crate::gui_egui::{ helper::{id_ports_of_all_components, offset_reverse_helper_pos2, unique_component_name}, }; use egui::{Context, CursorIcon, LayerId, PointerButton, Pos2, Rect, Response, Ui, Vec2}; -use std::{collections::HashMap, rc::Rc}; +use std::{collections::HashMap, rc::Rc, path::PathBuf}; pub struct InputMode { pub comp: Option>, @@ -153,4 +153,6 @@ pub fn add_comp_to_editor(e: &mut Editor) { }, ); e.components.push(*instance); + let path = PathBuf::from("autosave.json"); + ComponentStore{store:e.components.clone()}.save_file(&path); }