2022-03-20 11:09:25 -07:00
|
|
|
#![feature(proc_macro_hygiene)]
|
|
|
|
#![feature(const_mut_refs)]
|
|
|
|
#![feature(exclusive_range_pattern)]
|
|
|
|
#![feature(once_cell)]
|
2022-12-22 14:22:37 -08:00
|
|
|
#![feature(c_variadic)]
|
2022-03-20 11:09:25 -07:00
|
|
|
#![allow(
|
|
|
|
clippy::borrow_interior_mutable_const,
|
Add UI backing to text options in menu, always do new damage display (#451)
* A bunch of things
* Current progress
* Fix for ResAnimationContent
* Figure out Parts*
* Cleanup, just because
* New pane working!!!
* New null pane for hierarchy
* Success with parent pane
* Generate multiple panes
* Multiple panes, almost working text color
* MaterialColor test, but fails
* Forgot bitfield-struct
* Vtable for material. Fixes SetWhiteColor!
* Refactor color changing, change naming scheme
* Just Frame Advantage
* Merge
* Delete T_test.txt
* Delete set_txt_num_01.txt
* Delete libtraining_modpack.nro
* Format Rust code using rustfmt
* Ignore shell scripts in repo languages
* General refactor, add basis for quick menu
* Small refactor, fix ordering of submenu options
* Toggles, sliders
* Tons of progress...
* Correct dmg updater, remove old quick menu backend
* Fix damage percentage display
* Small QoL
* Format Rust code using rustfmt
* More edits. Use Quit Training button as Modpack Menu header
* Finish merge
* Format Rust code using rustfmt
* Use vanilla backgrounds for text options
* Format ui_hacks, also always do new percent display
* Fix merge
* That was the most awful merge ever
* Address clippy warnings
* Format Rust code using rustfmt
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-12-30 11:33:17 -08:00
|
|
|
clippy::declare_interior_mutable_const,
|
2022-03-20 11:09:25 -07:00
|
|
|
clippy::not_unsafe_ptr_arg_deref,
|
|
|
|
clippy::missing_safety_doc,
|
2022-03-24 23:48:50 -07:00
|
|
|
clippy::wrong_self_convention,
|
|
|
|
clippy::option_map_unit_fn,
|
Add UI backing to text options in menu, always do new damage display (#451)
* A bunch of things
* Current progress
* Fix for ResAnimationContent
* Figure out Parts*
* Cleanup, just because
* New pane working!!!
* New null pane for hierarchy
* Success with parent pane
* Generate multiple panes
* Multiple panes, almost working text color
* MaterialColor test, but fails
* Forgot bitfield-struct
* Vtable for material. Fixes SetWhiteColor!
* Refactor color changing, change naming scheme
* Just Frame Advantage
* Merge
* Delete T_test.txt
* Delete set_txt_num_01.txt
* Delete libtraining_modpack.nro
* Format Rust code using rustfmt
* Ignore shell scripts in repo languages
* General refactor, add basis for quick menu
* Small refactor, fix ordering of submenu options
* Toggles, sliders
* Tons of progress...
* Correct dmg updater, remove old quick menu backend
* Fix damage percentage display
* Small QoL
* Format Rust code using rustfmt
* More edits. Use Quit Training button as Modpack Menu header
* Finish merge
* Format Rust code using rustfmt
* Use vanilla backgrounds for text options
* Format ui_hacks, also always do new percent display
* Fix merge
* That was the most awful merge ever
* Address clippy warnings
* Format Rust code using rustfmt
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-12-30 11:33:17 -08:00
|
|
|
clippy::fn_null_check,
|
|
|
|
// Look into why for this one
|
|
|
|
clippy::transmute_num_to_bytes
|
2022-03-20 11:09:25 -07:00
|
|
|
)]
|
|
|
|
|
|
|
|
pub mod common;
|
|
|
|
mod hazard_manager;
|
|
|
|
mod hitbox_visualizer;
|
|
|
|
mod training;
|
|
|
|
|
2023-01-27 19:24:09 +00:00
|
|
|
mod logging;
|
2022-03-20 11:09:25 -07:00
|
|
|
|
|
|
|
use crate::common::*;
|
|
|
|
use crate::events::{Event, EVENT_QUEUE};
|
|
|
|
|
2022-09-07 22:34:39 -04:00
|
|
|
use skyline::libc::mkdir;
|
2022-03-20 11:09:25 -07:00
|
|
|
use skyline::nro::{self, NroInfo};
|
|
|
|
use std::fs;
|
|
|
|
|
2023-01-27 19:24:09 +00:00
|
|
|
use crate::logging::*;
|
2022-10-16 16:32:24 -07:00
|
|
|
use crate::menu::quick_menu_loop;
|
2023-02-02 15:01:11 -08:00
|
|
|
use crate::training::ui::notifications::notification;
|
2022-03-20 11:09:25 -07:00
|
|
|
|
|
|
|
fn nro_main(nro: &NroInfo<'_>) {
|
|
|
|
if nro.module.isLoaded {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if nro.name == "common" {
|
|
|
|
skyline::install_hooks!(
|
|
|
|
training::shield::handle_sub_guard_cont,
|
|
|
|
training::directional_influence::handle_correct_damage_vector_common,
|
|
|
|
training::tech::handle_change_status,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! c_str {
|
|
|
|
($l:tt) => {
|
2022-05-25 15:07:56 -07:00
|
|
|
[$l.as_bytes(), "\u{0}".as_bytes()].concat().as_ptr()
|
2022-03-20 11:09:25 -07:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#[skyline::main(name = "training_modpack")]
|
|
|
|
pub fn main() {
|
2022-11-01 13:52:38 -07:00
|
|
|
std::panic::set_hook(Box::new(|info| {
|
|
|
|
let location = info.location().unwrap();
|
|
|
|
|
|
|
|
let msg = match info.payload().downcast_ref::<&'static str>() {
|
|
|
|
Some(s) => *s,
|
2022-11-01 20:58:36 +00:00
|
|
|
None => match info.payload().downcast_ref::<String>() {
|
|
|
|
Some(s) => &s[..],
|
|
|
|
None => "Box<Any>",
|
2022-11-01 13:52:38 -07:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2023-01-27 11:19:18 -08:00
|
|
|
let err_msg = format!("SSBU Training Modpack has panicked at '{msg}', {location}");
|
2022-11-01 13:52:38 -07:00
|
|
|
skyline::error::show_error(
|
|
|
|
69,
|
2023-01-27 11:19:18 -08:00
|
|
|
"SSBU Training Modpack has panicked! Please open the details and send a screenshot to the developer, then close the game.\n",
|
2022-11-01 13:52:38 -07:00
|
|
|
err_msg.as_str(),
|
|
|
|
);
|
|
|
|
}));
|
2023-01-27 11:19:18 -08:00
|
|
|
init_logger().unwrap();
|
2022-11-01 13:52:38 -07:00
|
|
|
|
2023-01-27 11:19:18 -08:00
|
|
|
info!("Initialized.");
|
2022-03-20 11:09:25 -07:00
|
|
|
unsafe {
|
|
|
|
EVENT_QUEUE.push(Event::smash_open());
|
2023-02-10 22:02:56 -08:00
|
|
|
notification("Training Modpack".to_string(), "Welcome!".to_string(), 60);
|
|
|
|
notification("Open Menu".to_string(), "Special + Uptaunt".to_string(), 120);
|
|
|
|
notification("Save State".to_string(), "Grab + Downtaunt".to_string(), 120);
|
|
|
|
notification("Load State".to_string(), "Grab + Uptaunt".to_string(), 120);
|
2022-03-20 11:09:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
hitbox_visualizer::hitbox_visualization();
|
|
|
|
hazard_manager::hazard_manager();
|
|
|
|
training::training_mods();
|
|
|
|
nro::add_hook(nro_main).unwrap();
|
|
|
|
|
|
|
|
unsafe {
|
|
|
|
mkdir(c_str!("sd:/TrainingModpack/"), 777);
|
|
|
|
}
|
|
|
|
|
|
|
|
let ovl_path = "sd:/switch/.overlays/ovlTrainingModpack.ovl";
|
|
|
|
if fs::metadata(ovl_path).is_ok() {
|
2023-01-27 11:19:18 -08:00
|
|
|
warn!("Removing ovlTrainingModpack.ovl...");
|
2023-01-31 15:17:00 -08:00
|
|
|
fs::remove_file(ovl_path).unwrap_or_else(|_| panic!("Could not remove {}", ovl_path))
|
2022-03-20 11:09:25 -07:00
|
|
|
}
|
|
|
|
|
2023-01-27 11:19:18 -08:00
|
|
|
info!("Performing version check...");
|
2022-03-20 11:09:25 -07:00
|
|
|
release::version_check();
|
|
|
|
|
2023-02-11 16:49:05 -08:00
|
|
|
menu::load_from_file();
|
|
|
|
button_config::load_from_file();
|
2022-10-09 14:09:47 -07:00
|
|
|
|
2022-03-20 11:09:25 -07:00
|
|
|
std::thread::spawn(|| loop {
|
|
|
|
std::thread::sleep(std::time::Duration::from_secs(10));
|
|
|
|
unsafe {
|
|
|
|
while let Some(event) = EVENT_QUEUE.pop() {
|
|
|
|
let host = "https://my-project-1511972643240-default-rtdb.firebaseio.com";
|
|
|
|
let path = format!(
|
|
|
|
"/event/{}/device/{}/{}.json",
|
|
|
|
event.event_name, event.device_id, event.event_time
|
|
|
|
);
|
|
|
|
|
Add UI backing to text options in menu, always do new damage display (#451)
* A bunch of things
* Current progress
* Fix for ResAnimationContent
* Figure out Parts*
* Cleanup, just because
* New pane working!!!
* New null pane for hierarchy
* Success with parent pane
* Generate multiple panes
* Multiple panes, almost working text color
* MaterialColor test, but fails
* Forgot bitfield-struct
* Vtable for material. Fixes SetWhiteColor!
* Refactor color changing, change naming scheme
* Just Frame Advantage
* Merge
* Delete T_test.txt
* Delete set_txt_num_01.txt
* Delete libtraining_modpack.nro
* Format Rust code using rustfmt
* Ignore shell scripts in repo languages
* General refactor, add basis for quick menu
* Small refactor, fix ordering of submenu options
* Toggles, sliders
* Tons of progress...
* Correct dmg updater, remove old quick menu backend
* Fix damage percentage display
* Small QoL
* Format Rust code using rustfmt
* More edits. Use Quit Training button as Modpack Menu header
* Finish merge
* Format Rust code using rustfmt
* Use vanilla backgrounds for text options
* Format ui_hacks, also always do new percent display
* Fix merge
* That was the most awful merge ever
* Address clippy warnings
* Format Rust code using rustfmt
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2022-12-30 11:33:17 -08:00
|
|
|
let url = format!("{host}{path}");
|
2023-01-27 19:24:09 +00:00
|
|
|
minreq::post(url)
|
|
|
|
.with_json(&event)
|
|
|
|
.expect("Failed to send info to firebase")
|
|
|
|
.send()
|
|
|
|
.ok();
|
2022-03-20 11:09:25 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2022-09-07 22:34:39 -04:00
|
|
|
std::thread::spawn(|| unsafe { quick_menu_loop() });
|
2022-03-20 11:09:25 -07:00
|
|
|
}
|