1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-10-02 17:24:28 +00:00

Small fixes to Quick Menu

This commit is contained in:
jugeeya 2022-03-20 11:23:45 -07:00
parent e4e2de0a79
commit 6976c53172
5 changed files with 15 additions and 14 deletions

10
.gitignore vendored
View file

@ -1,15 +1,5 @@
**/target **/target
**/*.py
**/*.pyc
Cargo.lock Cargo.lock
.idea/ .idea/
*.ovl
*.elf
*.nacp
*.nro
release/ release/

Binary file not shown.

View file

@ -73,12 +73,11 @@ pub fn set_menu_from_url(orig_last_url: &str) {
MENU = get_menu_from_url(MENU, last_url); MENU = get_menu_from_url(MENU, last_url);
if MENU.quick_menu == OnOff::Off { if MENU.quick_menu == OnOff::Off {
let is_emulator = skyline::hooks::getRegionAddress(skyline::hooks::Region::Text) as u64 == 0x8004000; if is_emulator() {
if is_emulator {
skyline::error::show_error( skyline::error::show_error(
0x69, 0x69,
"Cannot use web menu on emulator.\n", "Cannot use web menu on emulator.\n\0",
"Only the quick menu is runnable via emulator currently.", "Only the quick menu is runnable via emulator currently.\n\0",
); );
} }

View file

@ -29,6 +29,11 @@ pub fn get_category(module_accessor: &mut app::BattleObjectModuleAccessor) -> i3
(module_accessor.info >> 28) as u8 as i32 (module_accessor.info >> 28) as u8 as i32
} }
pub fn is_emulator() -> bool {
unsafe { skyline::hooks::getRegionAddress(skyline::hooks::Region::Text) as u64 == 0x8004000 }
}
pub fn get_module_accessor(fighter_id: FighterId) -> *mut app::BattleObjectModuleAccessor { pub fn get_module_accessor(fighter_id: FighterId) -> *mut app::BattleObjectModuleAccessor {
let entry_id_int = fighter_id as i32; let entry_id_int = fighter_id as i32;
let entry_id = app::FighterEntryID(entry_id_int); let entry_id = app::FighterEntryID(entry_id_int);

View file

@ -27,6 +27,7 @@ use skyline::nro::{self, NroInfo};
use std::fs; use std::fs;
use owo_colors::OwoColorize; use owo_colors::OwoColorize;
use training_mod_consts::OnOff;
fn nro_main(nro: &NroInfo<'_>) { fn nro_main(nro: &NroInfo<'_>) {
if nro.module.isLoaded { if nro.module.isLoaded {
@ -104,6 +105,9 @@ pub fn main() {
log!("Previous menu found, loading from training_modpack_menu.conf"); log!("Previous menu found, loading from training_modpack_menu.conf");
unsafe { unsafe {
MENU = get_menu_from_url(MENU, std::str::from_utf8(&menu_conf).unwrap()); MENU = get_menu_from_url(MENU, std::str::from_utf8(&menu_conf).unwrap());
if is_emulator() {
MENU.quick_menu = OnOff::On;
}
} }
} else { } else {
log!("Previous menu found but is invalid."); log!("Previous menu found but is invalid.");
@ -123,6 +127,9 @@ pub fn main() {
DEFAULT_MENU, DEFAULT_MENU,
std::str::from_utf8(&menu_defaults_conf).unwrap(), std::str::from_utf8(&menu_defaults_conf).unwrap(),
); );
if is_emulator() {
DEFAULT_MENU.quick_menu = OnOff::On;
}
crate::menu::write_menu(); crate::menu::write_menu();
} }
} else { } else {