@@ -71,6 +71,7 @@ pub struct AppConfig {
7171 pub rebuild_on_changes : bool ,
7272 pub auto_update_check : bool ,
7373 pub watch_patterns : Vec < Glob > ,
74+ pub recent_projects : Vec < PathBuf > ,
7475
7576 #[ serde( skip) ]
7677 pub objects : Vec < ProjectObject > ,
@@ -102,6 +103,7 @@ impl Default for AppConfig {
102103 rebuild_on_changes : true ,
103104 auto_update_check : true ,
104105 watch_patterns : DEFAULT_WATCH_PATTERNS . iter ( ) . map ( |s| Glob :: new ( s) . unwrap ( ) ) . collect ( ) ,
106+ recent_projects : vec ! [ ] ,
105107 objects : vec ! [ ] ,
106108 object_nodes : vec ! [ ] ,
107109 watcher_change : false ,
@@ -115,6 +117,11 @@ impl Default for AppConfig {
115117
116118impl AppConfig {
117119 pub fn set_project_dir ( & mut self , path : PathBuf ) {
120+ self . recent_projects . retain ( |p| p != & path) ;
121+ if self . recent_projects . len ( ) > 9 {
122+ self . recent_projects . truncate ( 9 ) ;
123+ }
124+ self . recent_projects . insert ( 0 , path. clone ( ) ) ;
118125 self . project_dir = Some ( path) ;
119126 self . target_obj_dir = None ;
120127 self . base_obj_dir = None ;
@@ -351,6 +358,23 @@ impl eframe::App for App {
351358 egui:: TopBottomPanel :: top ( "top_panel" ) . show ( ctx, |ui| {
352359 egui:: menu:: bar ( ui, |ui| {
353360 ui. menu_button ( "File" , |ui| {
361+ let recent_projects = if let Ok ( guard) = config. read ( ) {
362+ guard. recent_projects . clone ( )
363+ } else {
364+ vec ! [ ]
365+ } ;
366+ if recent_projects. is_empty ( ) {
367+ ui. add_enabled ( false , egui:: Button :: new ( "Recent Projects…" ) ) ;
368+ } else {
369+ ui. menu_button ( "Recent Projects…" , |ui| {
370+ for path in recent_projects {
371+ if ui. button ( format ! ( "{}" , path. display( ) ) ) . clicked ( ) {
372+ config. write ( ) . unwrap ( ) . set_project_dir ( path) ;
373+ ui. close_menu ( ) ;
374+ }
375+ }
376+ } ) ;
377+ }
354378 if ui. button ( "Appearance…" ) . clicked ( ) {
355379 * show_appearance_config = !* show_appearance_config;
356380 ui. close_menu ( ) ;
0 commit comments