mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-06-07 20:10:35 +00:00
fix (#475)
This commit is contained in:
parent
c932961566
commit
e10092b766
3 changed files with 7 additions and 17 deletions
|
@ -1,24 +1,17 @@
|
||||||
use crate::common::*;
|
use crate::common::*;
|
||||||
use crate::events::{Event, EVENT_QUEUE};
|
use crate::events::{Event, EVENT_QUEUE};
|
||||||
use crate::logging::*;
|
use crate::logging::*;
|
||||||
use crate::training::frame_counter;
|
|
||||||
|
|
||||||
use skyline::nn::hid::{GetNpadStyleSet, NpadGcState};
|
use skyline::nn::hid::{GetNpadStyleSet, NpadGcState};
|
||||||
use training_mod_consts::MenuJsonStruct;
|
use training_mod_consts::MenuJsonStruct;
|
||||||
|
|
||||||
// This is a special frame counter that will tick on draw()
|
// This is a special frame counter that will tick on draw()
|
||||||
// We'll count how long the menu has been open
|
// We'll count how long the menu has been open
|
||||||
pub static mut FRAME_COUNTER_INDEX: usize = 0;
|
pub static mut FRAME_COUNTER : u32 = 0;
|
||||||
const MENU_INPUT_WAIT_FRAMES : u32 = 30;
|
const MENU_INPUT_WAIT_FRAMES : u32 = 30;
|
||||||
const MENU_CLOSE_WAIT_FRAMES : u32 = 60;
|
const MENU_CLOSE_WAIT_FRAMES : u32 = 60;
|
||||||
pub static mut QUICK_MENU_ACTIVE: bool = false;
|
pub static mut QUICK_MENU_ACTIVE: bool = false;
|
||||||
|
|
||||||
pub fn init() {
|
|
||||||
unsafe {
|
|
||||||
FRAME_COUNTER_INDEX = frame_counter::register_counter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe fn menu_condition(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
|
pub unsafe fn menu_condition(module_accessor: &mut app::BattleObjectModuleAccessor) -> bool {
|
||||||
button_config::combo_passes(module_accessor, button_config::ButtonCombo::OpenMenu)
|
button_config::combo_passes(module_accessor, button_config::ButtonCombo::OpenMenu)
|
||||||
}
|
}
|
||||||
|
@ -48,8 +41,7 @@ pub unsafe fn set_menu_from_json(message: &str) {
|
||||||
|
|
||||||
pub fn spawn_menu() {
|
pub fn spawn_menu() {
|
||||||
unsafe {
|
unsafe {
|
||||||
frame_counter::reset_frame_count(FRAME_COUNTER_INDEX);
|
FRAME_COUNTER = 0;
|
||||||
|
|
||||||
QUICK_MENU_ACTIVE = true;
|
QUICK_MENU_ACTIVE = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,7 +160,7 @@ pub fn handle_get_npad_state(state: *mut NpadGcState, _controller_id: *const u32
|
||||||
// BUTTON_PRESSES.down.is_pressed = (*state).Buttons & ((1 << 15) | (1 << 19)) > 0;
|
// BUTTON_PRESSES.down.is_pressed = (*state).Buttons & ((1 << 15) | (1 << 19)) > 0;
|
||||||
// BUTTON_PRESSES.up.is_pressed = (*state).Buttons & ((1 << 13) | (1 << 17)) > 0;
|
// BUTTON_PRESSES.up.is_pressed = (*state).Buttons & ((1 << 13) | (1 << 17)) > 0;
|
||||||
|
|
||||||
if frame_counter::get_frame_count(FRAME_COUNTER_INDEX) < MENU_INPUT_WAIT_FRAMES {
|
if FRAME_COUNTER < MENU_INPUT_WAIT_FRAMES {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,10 +252,10 @@ pub unsafe fn quick_menu_loop() {
|
||||||
received_input = true;
|
received_input = true;
|
||||||
if app.page != AppPage::SUBMENU {
|
if app.page != AppPage::SUBMENU {
|
||||||
app.on_b()
|
app.on_b()
|
||||||
} else if frame_counter::get_frame_count(FRAME_COUNTER_INDEX) > MENU_CLOSE_WAIT_FRAMES {
|
} else if FRAME_COUNTER > MENU_CLOSE_WAIT_FRAMES {
|
||||||
// Leave menu.
|
// Leave menu.
|
||||||
QUICK_MENU_ACTIVE = false;
|
QUICK_MENU_ACTIVE = false;
|
||||||
frame_counter::reset_frame_count(FRAME_COUNTER_INDEX);
|
FRAME_COUNTER = 0;
|
||||||
let menu_json = app.get_menu_selections();
|
let menu_json = app.get_menu_selections();
|
||||||
set_menu_from_json(&menu_json);
|
set_menu_from_json(&menu_json);
|
||||||
EVENT_QUEUE.push(Event::menu_open(menu_json));
|
EVENT_QUEUE.push(Event::menu_open(menu_json));
|
||||||
|
|
|
@ -565,7 +565,6 @@ pub fn training_mods() {
|
||||||
mash::init();
|
mash::init();
|
||||||
ledge::init();
|
ledge::init();
|
||||||
throw::init();
|
throw::init();
|
||||||
menu::init();
|
|
||||||
buff::init();
|
buff::init();
|
||||||
items::init();
|
items::init();
|
||||||
tech::init();
|
tech::init();
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
use crate::{common::menu::QUICK_MENU_ACTIVE};
|
use crate::{common, common::menu::QUICK_MENU_ACTIVE};
|
||||||
use skyline::nn::ui2d::*;
|
use skyline::nn::ui2d::*;
|
||||||
use smash::ui2d::{SmashPane, SmashTextBox};
|
use smash::ui2d::{SmashPane, SmashTextBox};
|
||||||
use training_mod_tui::{App, AppPage};
|
use training_mod_tui::{App, AppPage};
|
||||||
use training_mod_tui::gauge::GaugeState;
|
use training_mod_tui::gauge::GaugeState;
|
||||||
use crate::training::frame_counter;
|
|
||||||
|
|
||||||
pub static NUM_MENU_TEXT_OPTIONS: usize = 33;
|
pub static NUM_MENU_TEXT_OPTIONS: usize = 33;
|
||||||
pub static _NUM_MENU_TABS: usize = 3;
|
pub static _NUM_MENU_TABS: usize = 3;
|
||||||
|
@ -258,7 +257,7 @@ pub unsafe fn draw(root_pane: &mut Pane) {
|
||||||
|
|
||||||
root_pane.find_pane_by_name_recursive("TrModMenu").unwrap().set_visible(QUICK_MENU_ACTIVE);
|
root_pane.find_pane_by_name_recursive("TrModMenu").unwrap().set_visible(QUICK_MENU_ACTIVE);
|
||||||
if QUICK_MENU_ACTIVE {
|
if QUICK_MENU_ACTIVE {
|
||||||
frame_counter::tick_idx(crate::common::menu::FRAME_COUNTER_INDEX);
|
common::menu::FRAME_COUNTER += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make all invisible first
|
// Make all invisible first
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue