1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-24 10:54:16 +00:00

Quick Menu: fix speed, potential to deadlock

This commit is contained in:
jugeeya 2023-01-17 16:02:19 -08:00
parent e174daeb6f
commit 84fbe98d0d

View file

@ -282,24 +282,17 @@ pub unsafe fn quick_menu_loop() {
std::thread::sleep(std::time::Duration::from_secs(10)); std::thread::sleep(std::time::Duration::from_secs(10));
let backend = training_mod_tui::TestBackend::new(75, 15); let backend = training_mod_tui::TestBackend::new(75, 15);
let mut terminal = training_mod_tui::Terminal::new(backend).unwrap(); let mut terminal = training_mod_tui::Terminal::new(backend).unwrap();
let mut has_slept_millis = 0;
let render_frames = 5;
let mut json_response = String::new(); let mut json_response = String::new();
let button_presses = &mut BUTTON_PRESSES; let button_presses = &mut BUTTON_PRESSES;
let mut received_input = true; let mut received_input = true;
loop { loop {
std::thread::sleep(std::time::Duration::from_millis(16)); std::thread::sleep(std::time::Duration::from_millis(16));
has_slept_millis += 16;
if has_slept_millis < 16 * render_frames {
continue;
}
has_slept_millis = 0;
if !QUICK_MENU_ACTIVE { if !QUICK_MENU_ACTIVE {
continue; continue;
} }
let mut app = QUICK_MENU_APP.lock(); let mut app = &mut *QUICK_MENU_APP.data_ptr();
button_presses.a.read_press().then(|| { button_presses.a.read_press().then(|| {
app.on_a(); app.on_a();
received_input = true; received_input = true;