File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ Menu.MenuMain menuMain
2323 var bikePhysics = ( Bike . BikePhysics ) playerPrefab . Instantiate ( ) ;
2424
2525 menuMain . backgroundImage . Visible = false ;
26- menuMain . SetupOnGameQuit ( bikePhysics . hudMain . workout ) ;
26+ menuMain . SetupOnGameQuitWithWorkout ( bikePhysics . hudMain . workout ) ;
2727
2828 bikePhysics . userMass_kg = userConfig . mass_kg ;
2929 bikePhysics . bikeModel = bikeModel ;
Original file line number Diff line number Diff line change @@ -62,11 +62,17 @@ public override void _Process(double delta) {
6262 }
6363 }
6464
65- public void SetupOnGameQuit ( Workout . Workout workout ) {
66- quitGameButton . Visible = true ;
65+ private void InitialOnGameQuitWithoutWorkout ( ) {
66+ tcpParser . tcp . rustProcess . Kill ( ) ;
67+ GetTree ( ) . Quit ( ) ;
68+ }
69+
70+ public void SetupOnGameQuitWithWorkout ( Workout . Workout workout ) {
71+ quitGameButton . Pressed -= InitialOnGameQuitWithoutWorkout ;
6772 quitGameButton . Pressed += ( ) =>
6873 {
69- GD . Print ( "quitGame" ) ;
74+ GD . Print ( "quitGame & save workout" ) ;
75+
7076 workout . Save ( ) ;
7177 tcpParser . tcp . rustProcess . Kill ( ) ;
7278
@@ -75,12 +81,13 @@ public void SetupOnGameQuit(Workout.Workout workout) {
7581 }
7682
7783 public override void _Ready ( ) {
84+ quitGameButton . Pressed += InitialOnGameQuitWithoutWorkout ;
85+
7886 var rng = new RandomNumberGenerator ( ) ;
7987 backgroundImage . Texture = backgroundTexturesPool [
8088 rng . RandiRange ( 0 , backgroundTexturesPool . Length - 1 )
8189 ] ;
8290
83- quitGameButton . Visible = false ;
8491 Visible = true ;
8592
8693 tabBar . TabChanged += ( _ ) =>
You can’t perform that action at this time.
0 commit comments