1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-19 16:36:35 +00:00

Hide Notifications when Combo Counter is Off (#662)

* Hides all notifications

* Working Notification Hiding

* Add and use PauseMenu structure

* Cargo fmt

* Clean-up

* Access Fields instead of magic offsets, use struct ptr instead of retyping
This commit is contained in:
GradualSyrup 2024-01-28 18:04:09 -06:00 committed by GitHub
parent bf94573193
commit 312363d744
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 32 additions and 7 deletions

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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 {