Commit 79d58be
authored
# Objective
- Fixes #25571
## Solution
- Made the change as described in the title.
- This ensures the delayed save timer ticks using real elapsed time
rather than virtual game time, allowing settings to save even when the
game is paused.
## Testing
- Verified that it works correctly through manual testing using the
reproduction code below.
### Reproduction code
```rust
//! issue_25571
use std::time::Duration;
use bevy::{
prelude::*,
settings::{ReflectSettingsGroup, SaveSettingsDeferred, SettingsGroup, SettingsPlugin},
};
fn main() {
App::new()
.add_plugins((DefaultPlugins, SettingsPlugin::new("issue_25571")))
.add_systems(Startup, setup)
.add_systems(Update, trigger_save)
.run();
}
#[derive(Resource, SettingsGroup, Reflect, Default)]
#[reflect(Resource, SettingsGroup, Default)]
struct MySettings {
volume: f32,
}
fn setup(mut settings: ResMut<MySettings>, mut time: ResMut<Time<Virtual>>) {
settings.volume = 0.5;
time.pause();
}
fn trigger_save(mut commands: Commands, mut executed: Local<bool>) {
if !*executed {
commands.queue(SaveSettingsDeferred(Duration::from_secs(1)));
*executed = true;
}
}
```
### Output
```toml
[my_settings]
volume = 0.5
```
1 parent c2b98c8 commit 79d58be
1 file changed
Lines changed: 36 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
615 | | - | |
| 615 | + | |
616 | 616 | | |
617 | 617 | | |
618 | 618 | | |
| |||
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
627 | | - | |
| 627 | + | |
628 | 628 | | |
| 629 | + | |
629 | 630 | | |
630 | 631 | | |
631 | 632 | | |
| |||
1078 | 1079 | | |
1079 | 1080 | | |
1080 | 1081 | | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
1081 | 1114 | | |
0 commit comments