@@ -30,8 +30,8 @@ use crate::file::FilePickingPlugin;
30
30
use crate :: home:: HomePlugin ;
31
31
use crate :: misc:: MiscPlugin ;
32
32
use crate :: misc:: WorkingDirectory ;
33
- use crate :: notification:: NotificationPlugin ;
34
- use crate :: project:: project_loaded;
33
+ use crate :: notification:: { NotificationPlugin , ToastsExt , ToastsStorage } ;
34
+ use crate :: project:: { Project , project_loaded} ;
35
35
use crate :: project:: LoadProjectEvent ;
36
36
use crate :: project:: ProjectPlugin ;
37
37
use crate :: score:: ScorePlugin ;
@@ -65,7 +65,7 @@ fn main() {
65
65
. add_plugins ( DefaultPickingPlugins )
66
66
. add_plugins ( EguiPlugin )
67
67
. add_plugins ( ProjectPlugin )
68
- . add_plugins ( crate :: selection:: SelectionPlugin )
68
+ . add_plugins ( selection:: SelectionPlugin )
69
69
. add_plugins ( MiscPlugin )
70
70
. add_plugins ( TabPlugin )
71
71
. add_plugins ( EditingPlugin )
@@ -249,10 +249,30 @@ fn ui_system(world: &mut World) {
249
249
250
250
let mut system_state: SystemState < Translator > = SystemState :: new ( world) ;
251
251
let translator = system_state. get ( world) ;
252
+ let file = translator. tr ( "menu_bar.file" ) ;
253
+ let save = translator. tr ( "menu_bar.file.save" ) ;
254
+ let quit = translator. tr ( "menu_bar.file.quit" ) ;
255
+
252
256
egui:: TopBottomPanel :: top ( "phichain.MenuBar" ) . show ( ctx, |ui| {
253
257
egui:: menu:: bar ( ui, |ui| {
254
- ui. menu_button ( translator. tr ( "menu_bar.file" ) , |ui| {
255
- if ui. button ( translator. tr ( "menu_bar.file.quit" ) ) . clicked ( ) {
258
+ ui. menu_button ( file, |ui| {
259
+ if ui. button ( save) . clicked ( ) {
260
+ if let Ok ( chart) = PhiChainExporter :: export ( world) {
261
+ let project = world. resource :: < Project > ( ) ;
262
+ let result = std:: fs:: write ( project. root_dir . join ( "chart.json" ) , chart) ;
263
+ let mut toasts = world. resource_mut :: < ToastsStorage > ( ) ;
264
+ match result {
265
+ Ok ( _) => {
266
+ toasts. success ( "Project saved" ) ;
267
+ }
268
+ Err ( error) => {
269
+ toasts. error ( format ! ( "Failed to save project: {}" , error) ) ;
270
+ }
271
+ }
272
+ }
273
+ }
274
+ ui. separator ( ) ;
275
+ if ui. button ( quit) . clicked ( ) {
256
276
std:: process:: exit ( 0 ) ;
257
277
}
258
278
} ) ;
0 commit comments