diff --git a/src/common/mod.rs b/src/common/mod.rs index b4e1a38..ab8e4cf 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -24,6 +24,7 @@ pub static mut BASE_MENU: TrainingModpackMenu = unsafe { DEFAULTS_MENU }; pub static mut FIGHTER_MANAGER_ADDR: usize = 0; pub static mut ITEM_MANAGER_ADDR: usize = 0; pub static mut STAGE_MANAGER_ADDR: usize = 0; +pub static mut TRAINING_MENU_ADDR: *mut PauseMenu = core::ptr::null_mut(); #[cfg(not(feature = "outside_training_mode"))] extern "C" { @@ -36,6 +37,17 @@ pub fn is_training_mode() -> bool { true } +#[repr(C)] +// FUN_71013e7be0 sets this up (13.0.1) so look here if more values are needed +// If you need full size use gdb to look at allocator +pub struct PauseMenu { + padding: [u8; 0xb60], // Unknown Values + pub stale_move_toggle: u32, // Handles if Stale Moves are on, 0 for off, 1 for on + unknown1: u32, + unknown2: u32, + pub combo_display_toggle: u32, // Handles if Combo Counter displays, 0 for off, 1 for on +} + #[skyline::from_offset(*OFFSET_GET_BATTLE_OBJECT_FROM_ID as isize)] pub fn get_battle_object_from_id(battle_object_id: u32) -> *mut app::BattleObject; diff --git a/src/training/mod.rs b/src/training/mod.rs index 479d0e1..818d85d 100644 --- a/src/training/mod.rs +++ b/src/training/mod.rs @@ -2,8 +2,8 @@ use crate::common::button_config; use crate::common::consts::{BuffOption, FighterId, MENU}; use crate::common::offsets::*; use crate::common::{ - dev_config, get_module_accessor, is_operation_cpu, is_training_mode, menu, - FIGHTER_MANAGER_ADDR, ITEM_MANAGER_ADDR, STAGE_MANAGER_ADDR, + dev_config, get_module_accessor, is_operation_cpu, is_training_mode, menu, PauseMenu, + FIGHTER_MANAGER_ADDR, ITEM_MANAGER_ADDR, STAGE_MANAGER_ADDR, TRAINING_MENU_ADDR, }; use crate::hitbox_visualizer; use crate::input::*; @@ -423,8 +423,8 @@ pub unsafe fn handle_add_damage( #[skyline::hook(offset = *OFFSET_STALE, inline)] unsafe fn stale_handle(ctx: &mut InlineCtx) { let x22 = ctx.registers[22].x.as_mut(); - let training_structure_address = (*x22 + 0xb60) as *mut u8; - *training_structure_address = 1; + TRAINING_MENU_ADDR = (*x22) as *mut PauseMenu; + (*TRAINING_MENU_ADDR).stale_move_toggle = 1; } // Set Stale Moves to On in the menu text diff --git a/src/training/ui/display.rs b/src/training/ui/display.rs index 05abc3e..95b990e 100644 --- a/src/training/ui/display.rs +++ b/src/training/ui/display.rs @@ -1,8 +1,8 @@ use skyline::nn::ui2d::*; use smash::ui2d::{SmashPane, SmashTextBox}; -use crate::{common::menu::QUICK_MENU_ACTIVE, training::ui}; - +use crate::common::{menu::QUICK_MENU_ACTIVE, TRAINING_MENU_ADDR}; +use crate::training::ui; macro_rules! display_parent_fmt { ($x:ident) => { format!("TrModDisp{}", $x).as_str() @@ -22,6 +22,8 @@ macro_rules! display_txt_fmt { } pub unsafe fn draw(root_pane: &Pane) { + // Make sure the combo counter is being displayed before we draw + let cc_displayed = (*TRAINING_MENU_ADDR).combo_display_toggle != 0; let notification_idx = 0; let queue = &mut ui::notifications::QUEUE; @@ -30,7 +32,7 @@ pub unsafe fn draw(root_pane: &Pane) { root_pane .find_pane_by_name_recursive(display_parent_fmt!(notification_idx)) .unwrap() - .set_visible(notification.is_some() && !QUICK_MENU_ACTIVE); + .set_visible(notification.is_some() && !QUICK_MENU_ACTIVE && cc_displayed); if notification.is_none() { return; } @@ -38,6 +40,12 @@ pub unsafe fn draw(root_pane: &Pane) { let notification = notification.unwrap(); let color = notification.color; + if !cc_displayed { + // Set the notification to drawn so we don't draw it + notification.set_drawn(); + notification.force_complete(); + } + if !notification.has_drawn() { notification.set_drawn(); root_pane diff --git a/src/training/ui/notifications.rs b/src/training/ui/notifications.rs index f137495..c97ba7f 100644 --- a/src/training/ui/notifications.rs +++ b/src/training/ui/notifications.rs @@ -34,6 +34,11 @@ impl Notification { self.length -= 1; } + // Used to force the notification to be removed from queue + pub fn force_complete(&mut self) { + self.length = 0; + } + // Returns: has_completed pub fn check_completed(&mut self) -> bool { if self.length <= 1 {