File tree 1 file changed +14
-4
lines changed
1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,7 @@ pub struct AppState {
121
121
show_cursor : bool ,
122
122
extra : bool ,
123
123
text_channel : ( Sender < String > , Receiver < String > ) ,
124
+ hyperspeed : bool ,
124
125
}
125
126
126
127
impl AppState {
@@ -139,6 +140,7 @@ impl AppState {
139
140
show_cursor : true ,
140
141
extra : false ,
141
142
speed : 5.0 ,
143
+ hyperspeed : false ,
142
144
}
143
145
}
144
146
@@ -303,12 +305,17 @@ impl eframe::App for AppState {
303
305
let time_per_step = Duration :: from_millis ( ( 500.0 - 49.0 * self . speed ) as u64 ) ;
304
306
let elapsed = self . time_since_step . elapsed ( ) ;
305
307
if !self . paused {
306
- if elapsed >= time_per_step {
308
+ if self . hyperspeed {
307
309
self . step ( ) ;
308
- self . time_since_step = Instant :: now ( ) ;
309
- }
310
+ ui. ctx ( ) . request_repaint ( ) ;
311
+ } else {
312
+ if elapsed >= time_per_step {
313
+ self . step ( ) ;
314
+ self . time_since_step = Instant :: now ( ) ;
315
+ }
310
316
311
- ui. ctx ( ) . request_repaint_after ( time_per_step) ;
317
+ ui. ctx ( ) . request_repaint_after ( time_per_step) ;
318
+ }
312
319
}
313
320
314
321
// The central panel the region left after adding TopPanel's and SidePanel's
@@ -359,6 +366,9 @@ impl eframe::App for AppState {
359
366
self . paused = true ;
360
367
}
361
368
ui. add ( egui:: Slider :: new ( & mut self . speed , 1.0 ..=10.0 ) . text ( "speed" ) ) ;
369
+ if ui. button ( "max speed" ) . clicked ( ) {
370
+ self . hyperspeed = !self . hyperspeed ;
371
+ }
362
372
} ) ;
363
373
364
374
ui. separator ( ) ;
You can’t perform that action at this time.
0 commit comments