1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2025-03-25 07:46:11 +00:00

Small adjustment to notifications

This commit is contained in:
asimon-1 2024-11-14 19:29:20 -05:00
parent a685a446d7
commit 6629c6f456
4 changed files with 16 additions and 13 deletions

View file

@ -55,8 +55,8 @@ unsafe fn is_actionable(module_accessor: *mut BattleObjectModuleAccessor) -> boo
fn update_frame_advantage(frame_advantage: i32) {
if get(&MENU).frame_advantage == OnOff::ON {
// Prioritize Frame Advantage over Input Recording Playback
notifications::clear_notifications_except("Input Recording");
notifications::clear_notifications_except("Frame Advantage");
notifications::clear_notification("Input Recording");
notifications::clear_notification("Frame Advantage");
notifications::color_notification(
"Frame Advantage".to_string(),
format!("{frame_advantage}"),

View file

@ -15,7 +15,7 @@ use crate::common::{
get_module_accessor, is_in_hitstun, is_in_shieldstun, try_get_module_accessor, MENU,
};
use crate::training::mash;
use crate::training::ui::notifications::{clear_notifications_except, color_notification};
use crate::training::ui::notifications::{clear_notification, color_notification};
use crate::{error, warn};
use training_mod_sync::*;
@ -205,7 +205,7 @@ unsafe fn handle_recording_for_fighter(module_accessor: &mut BattleObjectModuleA
}
let input_record = read_rwlock(&INPUT_RECORD);
if input_record == None {
clear_notifications_except("Input Recording");
clear_notification("Input Recording");
}
// Handle recording end
let mut input_record_frame = lock_write_rwlock(&INPUT_RECORD_FRAME);
@ -248,7 +248,7 @@ unsafe fn handle_recording_for_fighter(module_accessor: &mut BattleObjectModuleA
// Handle Possession Coloring
let possession = read_rwlock(&POSSESSION);
if entry_id_int == 1 && possession == Lockout {
clear_notifications_except("Input Recording");
clear_notification("Input Recording");
color_notification(
"Input Recording".to_string(),
"Lockout".to_owned(),
@ -268,7 +268,7 @@ unsafe fn handle_recording_for_fighter(module_accessor: &mut BattleObjectModuleA
*MODEL_COLOR_TYPE_COLOR_BLEND,
);
} else if entry_id_int == 1 && possession == Standby {
clear_notifications_except("Input Recording");
clear_notification("Input Recording");
color_notification(
"Input Recording".to_string(),
"Standby".to_owned(),
@ -288,7 +288,7 @@ unsafe fn handle_recording_for_fighter(module_accessor: &mut BattleObjectModuleA
*MODEL_COLOR_TYPE_COLOR_BLEND,
);
} else if entry_id_int == 1 && possession == Cpu {
clear_notifications_except("Input Recording");
clear_notification("Input Recording");
color_notification(
"Input Recording".to_string(),
"Recording".to_owned(),
@ -313,7 +313,7 @@ unsafe fn handle_recording_for_fighter(module_accessor: &mut BattleObjectModuleA
let input_record_frame = read_rwlock(&INPUT_RECORD_FRAME);
if input_record_frame == 0 || input_record_frame == 1 {
// can be either, seems like a thread issue
clear_notifications_except("Input Recording");
clear_notification("Input Recording");
color_notification(
"Input Recording".to_string(),
"Playback".to_owned(),

View file

@ -712,7 +712,7 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
MIRROR_STATE = 1.0;
save_state_player(get(&MENU).save_state_slot.into_idx().unwrap_or(0)).state = Save;
save_state_cpu(get(&MENU).save_state_slot.into_idx().unwrap_or(0)).state = Save;
notifications::clear_notifications_except("Save State");
notifications::clear_notification("Save State");
notifications::notification(
"Save State".to_string(),
format!("Saved Slot {}", get(&MENU).save_state_slot),

View file

@ -63,9 +63,12 @@ pub fn color_notification(header: String, message: String, len: u32, color: ResC
drop(queue_guard);
}
pub fn clear_notifications_except(header: &'static str) {
if (*lock_read_rwlock(&NOTIFICATIONS_QUEUE)).is_empty() {
// Before acquiring an exclusive write lock, check if there are even any notificatiosn to clear out
pub fn clear_notification(header: &'static str) {
if !read_rwlock(&NOTIFICATIONS_QUEUE)
.iter()
.any(|notif| notif.header == header)
{
// Before acquiring an exclusive write lock, check if there are even any relevant notifications to clear out
return;
}
let mut queue_guard = lock_write_rwlock(&NOTIFICATIONS_QUEUE);
@ -74,7 +77,7 @@ pub fn clear_notifications_except(header: &'static str) {
}
pub fn clear_all_notifications() {
if (*lock_read_rwlock(&NOTIFICATIONS_QUEUE)).is_empty() {
if read_rwlock(&NOTIFICATIONS_QUEUE).is_empty() {
// Before acquiring an exclusive write lock, check if there are even any notificatiosn to clear out
return;
}