1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-20 00:46:34 +00:00

Format Rust code using rustfmt

This commit is contained in:
github-actions[bot] 2023-01-27 19:24:09 +00:00 committed by GitHub
parent 77f439a6eb
commit 37360c787a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 87 additions and 77 deletions

View file

@ -61,7 +61,8 @@ struct TopLevelBtnComboConfig {
} }
pub fn validate_config(data: &str) -> bool { pub fn validate_config(data: &str) -> bool {
let conf: TopLevelBtnComboConfig = toml::from_str(data).expect("Custom button config has invalid schema"); let conf: TopLevelBtnComboConfig =
toml::from_str(data).expect("Custom button config has invalid schema");
let conf = conf.button_config; let conf = conf.button_config;
let configs = [conf.open_menu, conf.save_state, conf.load_state]; let configs = [conf.open_menu, conf.save_state, conf.load_state];
let bad_keys = configs let bad_keys = configs

View file

@ -1,7 +1,7 @@
use crate::common::*; use crate::common::*;
use crate::events::{Event, EVENT_QUEUE}; use crate::events::{Event, EVENT_QUEUE};
use crate::training::frame_counter;
use crate::logging::*; use crate::logging::*;
use crate::training::frame_counter;
use ramhorns::Template; use ramhorns::Template;
use skyline::info::get_program_id; use skyline::info::get_program_id;
@ -347,10 +347,7 @@ static mut WEB_MENU_ACTIVE: bool = false;
unsafe fn spawn_web_session(session: WebSession) { unsafe fn spawn_web_session(session: WebSession) {
info!("Opening menu session..."); info!("Opening menu session...");
let loaded_msg = session.recv(); let loaded_msg = session.recv();
info!( info!("Received loaded message from web: {}", &loaded_msg);
"Received loaded message from web: {}",
&loaded_msg
);
let message_send = MenuJsonStruct { let message_send = MenuJsonStruct {
menu: MENU, menu: MENU,
defaults_menu: DEFAULTS_MENU, defaults_menu: DEFAULTS_MENU,

View file

@ -1,6 +1,6 @@
use crate::logging::*;
use skyline_web::DialogOk; use skyline_web::DialogOk;
use std::fs; use std::fs;
use crate::logging::*;
pub const CURRENT_VERSION: &str = env!("CARGO_PKG_VERSION"); pub const CURRENT_VERSION: &str = env!("CARGO_PKG_VERSION");
const VERSION_FILE_PATH: &str = "sd:/TrainingModpack/version.txt"; const VERSION_FILE_PATH: &str = "sd:/TrainingModpack/version.txt";
@ -45,9 +45,12 @@ pub fn version_check() {
) )
); );
// Remove old menu selections, silently ignoring errors (i.e. if the file doesn't exist) // Remove old menu selections, silently ignoring errors (i.e. if the file doesn't exist)
fs::remove_file("sd:/TrainingModpack/training_modpack_menu.conf").unwrap_or_else(|_| error!("Couldn't remove training_modpack_menu.conf")); fs::remove_file("sd:/TrainingModpack/training_modpack_menu.conf")
fs::remove_file("sd:/TrainingModpack/training_modpack_menu.json").unwrap_or_else(|_| error!("Couldn't remove training_modpack_menu.json")); .unwrap_or_else(|_| error!("Couldn't remove training_modpack_menu.conf"));
fs::remove_file("sd:/TrainingModpack/training_modpack_menu_defaults.conf").unwrap_or_else(|_| error!("Couldn't remove training_modpack_menu_defaults.conf")); fs::remove_file("sd:/TrainingModpack/training_modpack_menu.json")
.unwrap_or_else(|_| error!("Couldn't remove training_modpack_menu.json"));
fs::remove_file("sd:/TrainingModpack/training_modpack_menu_defaults.conf")
.unwrap_or_else(|_| error!("Couldn't remove training_modpack_menu_defaults.conf"));
record_current_version(VERSION_FILE_PATH); record_current_version(VERSION_FILE_PATH);
} }
VersionCheck::NoFile => { VersionCheck::NoFile => {

View file

@ -21,9 +21,9 @@ mod hazard_manager;
mod hitbox_visualizer; mod hitbox_visualizer;
mod training; mod training;
mod logging;
#[cfg(test)] #[cfg(test)]
mod test; mod test;
mod logging;
use crate::common::*; use crate::common::*;
use crate::events::{Event, EVENT_QUEUE}; use crate::events::{Event, EVENT_QUEUE};
@ -32,11 +32,11 @@ use skyline::libc::mkdir;
use skyline::nro::{self, NroInfo}; use skyline::nro::{self, NroInfo};
use std::fs; use std::fs;
use crate::logging::*;
use crate::menu::quick_menu_loop; use crate::menu::quick_menu_loop;
#[cfg(feature = "web_session_preload")] #[cfg(feature = "web_session_preload")]
use crate::menu::web_session_loop; use crate::menu::web_session_loop;
use training_mod_consts::{MenuJsonStruct, OnOff}; use training_mod_consts::{MenuJsonStruct, OnOff};
use crate::logging::*;
fn nro_main(nro: &NroInfo<'_>) { fn nro_main(nro: &NroInfo<'_>) {
if nro.module.isLoaded { if nro.module.isLoaded {
@ -108,7 +108,8 @@ pub fn main() {
let menu_conf_path = "sd:/TrainingModpack/training_modpack_menu.json"; let menu_conf_path = "sd:/TrainingModpack/training_modpack_menu.json";
info!("Checking for previous menu in training_modpack_menu.json..."); info!("Checking for previous menu in training_modpack_menu.json...");
if fs::metadata(menu_conf_path).is_ok() { if fs::metadata(menu_conf_path).is_ok() {
let menu_conf = fs::read_to_string(menu_conf_path).expect(&format!("Could not remove {}", menu_conf_path)); let menu_conf = fs::read_to_string(menu_conf_path)
.expect(&format!("Could not remove {}", menu_conf_path));
if let Ok(menu_conf_json) = serde_json::from_str::<MenuJsonStruct>(&menu_conf) { if let Ok(menu_conf_json) = serde_json::from_str::<MenuJsonStruct>(&menu_conf) {
unsafe { unsafe {
MENU = menu_conf_json.menu; MENU = menu_conf_json.menu;
@ -117,7 +118,10 @@ pub fn main() {
} }
} else { } else {
warn!("Previous menu found but is invalid. Deleting..."); warn!("Previous menu found but is invalid. Deleting...");
fs::remove_file(menu_conf_path).expect(&format!("{} has invalid schema but could not be deleted!", menu_conf_path)); fs::remove_file(menu_conf_path).expect(&format!(
"{} has invalid schema but could not be deleted!",
menu_conf_path
));
} }
} else { } else {
info!("No previous menu file found."); info!("No previous menu file found.");
@ -127,7 +131,8 @@ pub fn main() {
info!("Checking for previous button combo settings in training_modpack.toml..."); info!("Checking for previous button combo settings in training_modpack.toml...");
if fs::metadata(combo_path).is_ok() { if fs::metadata(combo_path).is_ok() {
info!("Previous button combo settings found. Loading..."); info!("Previous button combo settings found. Loading...");
let combo_conf = fs::read_to_string(combo_path).expect(&format!("Could not read {}", combo_path)); let combo_conf =
fs::read_to_string(combo_path).expect(&format!("Could not read {}", combo_path));
if button_config::validate_config(&combo_conf) { if button_config::validate_config(&combo_conf) {
button_config::save_all_btn_config_from_toml(&combo_conf); button_config::save_all_btn_config_from_toml(&combo_conf);
} else { } else {
@ -159,7 +164,11 @@ pub fn main() {
); );
let url = format!("{host}{path}"); let url = format!("{host}{path}");
minreq::post(url).with_json(&event).expect("Failed to send info to firebase").send().ok(); minreq::post(url)
.with_json(&event)
.expect("Failed to send info to firebase")
.send()
.ok();
} }
} }
}); });

View file

@ -2,8 +2,8 @@ use crate::common::{
is_training_mode, menu, FIGHTER_MANAGER_ADDR, ITEM_MANAGER_ADDR, STAGE_MANAGER_ADDR, is_training_mode, menu, FIGHTER_MANAGER_ADDR, ITEM_MANAGER_ADDR, STAGE_MANAGER_ADDR,
}; };
use crate::hitbox_visualizer; use crate::hitbox_visualizer;
use crate::training::character_specific::items;
use crate::logging::*; use crate::logging::*;
use crate::training::character_specific::items;
use skyline::hooks::{getRegionAddress, InlineCtx, Region}; use skyline::hooks::{getRegionAddress, InlineCtx, Region};
use skyline::nn::hid::*; use skyline::nn::hid::*;
use skyline::nn::ro::LookupSymbol; use skyline::nn::ro::LookupSymbol;