mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-01-20 01:10:13 +00:00
Restrict menu opening multiple times in rapid succession (#245)
Co-authored-by: asimon-1 <asimon1@protonmail.com>
This commit is contained in:
parent
cd01730af3
commit
3fef1a78df
2 changed files with 27 additions and 3 deletions
|
@ -6,6 +6,17 @@ use smash::lib::lua_const::*;
|
|||
use skyline_web::{Background, BootDisplay, Webpage};
|
||||
use ramhorns::{Template, Content};
|
||||
use strum::IntoEnumIterator;
|
||||
use crate::training::frame_counter;
|
||||
|
||||
static mut FRAME_COUNTER_INDEX: usize = 0;
|
||||
const MENU_LOCKOUT_FRAMES: u32 = 5;
|
||||
|
||||
pub fn init() {
|
||||
unsafe {
|
||||
FRAME_COUNTER_INDEX = frame_counter::register_counter();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[derive(Content)]
|
||||
struct Slider {
|
||||
|
@ -245,8 +256,19 @@ pub fn set_menu_from_url(s: &str) {
|
|||
}
|
||||
|
||||
pub unsafe fn menu_condition(module_accessor: &mut smash::app::BattleObjectModuleAccessor) -> bool {
|
||||
ControlModule::check_button_on(module_accessor, *CONTROL_PAD_BUTTON_SPECIAL) &&
|
||||
ControlModule::check_button_on_trriger(module_accessor, *CONTROL_PAD_BUTTON_APPEAL_HI)
|
||||
// Only check for button combination if the counter is 0 (not locked out)
|
||||
match frame_counter::get_frame_count(FRAME_COUNTER_INDEX) {
|
||||
0 => {
|
||||
ControlModule::check_button_on(module_accessor, *CONTROL_PAD_BUTTON_SPECIAL) &&
|
||||
ControlModule::check_button_on_trriger(module_accessor, *CONTROL_PAD_BUTTON_APPEAL_HI)
|
||||
},
|
||||
1..MENU_LOCKOUT_FRAMES => false,
|
||||
_ => {
|
||||
// Waited longer than the lockout time, reset the counter so the menu can be opened again
|
||||
frame_counter::full_reset(FRAME_COUNTER_INDEX);
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn write_menu() {
|
||||
|
@ -318,6 +340,8 @@ pub unsafe fn write_menu() {
|
|||
}
|
||||
|
||||
pub unsafe fn spawn_menu() {
|
||||
frame_counter::reset_frame_count(FRAME_COUNTER_INDEX);
|
||||
frame_counter::start_counting(FRAME_COUNTER_INDEX);
|
||||
let fname = "training_menu.html";
|
||||
let params = MENU.to_url_params();
|
||||
let page_response = Webpage::new()
|
||||
|
|
|
@ -12,12 +12,12 @@ pub mod sdi;
|
|||
pub mod shield;
|
||||
pub mod tech;
|
||||
pub mod ledge;
|
||||
pub mod frame_counter;
|
||||
|
||||
mod air_dodge_direction;
|
||||
mod attack_angle;
|
||||
mod character_specific;
|
||||
mod fast_fall;
|
||||
mod frame_counter;
|
||||
mod full_hop;
|
||||
mod input_delay;
|
||||
mod input_record;
|
||||
|
|
Loading…
Reference in a new issue