Skip to content

Commit 0b4002c

Browse files
authored
Merge pull request #80 from FilipRuman/hr-tracking-support
made quiting game work before runing the game
2 parents b6b5b06 + 5360c2c commit 0b4002c

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

godot/Map/GameLoader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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;

godot/Menu/MenuMain.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff 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 += (_) =>

0 commit comments

Comments
 (0)