mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-03-30 02:02:43 +00:00
Update DEFAULTS_MENU
This commit is contained in:
parent
76b38f575e
commit
8a7cc1e4c3
3 changed files with 16 additions and 22 deletions
|
@ -2,7 +2,6 @@ use once_cell::sync::Lazy;
|
|||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::io::BufReader;
|
||||
use std::ptr::addr_of;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use parking_lot::Mutex;
|
||||
|
@ -13,10 +12,10 @@ use crate::common::{DEFAULTS_MENU, MENU};
|
|||
use crate::events::{Event, EVENT_QUEUE};
|
||||
use crate::input::{ButtonBitfield, ControllerStyle, MappedInputs, SomeControllerStruct};
|
||||
use crate::logging::*;
|
||||
use training_mod_sync::*;
|
||||
use crate::training::frame_counter;
|
||||
|
||||
use training_mod_consts::{create_app, InputControl, MenuJsonStruct, MENU_OPTIONS_PATH};
|
||||
use training_mod_sync::*;
|
||||
use training_mod_tui::AppPage;
|
||||
|
||||
pub const MENU_CLOSE_WAIT_FRAMES: u32 = 15;
|
||||
|
@ -36,11 +35,9 @@ pub fn load_from_file() {
|
|||
let reader = BufReader::new(menu_conf);
|
||||
if let Ok(menu_conf_json) = serde_json::from_reader::<BufReader<_>, MenuJsonStruct>(reader)
|
||||
{
|
||||
unsafe {
|
||||
assign_rwlock(&MENU, menu_conf_json.menu);
|
||||
DEFAULTS_MENU = menu_conf_json.defaults_menu;
|
||||
info!("Previous menu found. Loading...");
|
||||
}
|
||||
assign_rwlock(&MENU, menu_conf_json.menu);
|
||||
assign_rwlock(&DEFAULTS_MENU, menu_conf_json.defaults_menu);
|
||||
info!("Previous menu found. Loading...");
|
||||
} else {
|
||||
warn!("Previous menu found but is invalid. Deleting...");
|
||||
let err_msg = format!(
|
||||
|
@ -53,23 +50,21 @@ pub fn load_from_file() {
|
|||
info!("No previous menu file found.");
|
||||
}
|
||||
info!("Setting initial menu selections...");
|
||||
unsafe {
|
||||
let mut app = QUICK_MENU_APP.lock();
|
||||
app.serialized_default_settings = serde_json::to_string(&*addr_of!(DEFAULTS_MENU))
|
||||
.expect("Could not serialize DEFAULTS_MENU");
|
||||
app.update_all_from_json(
|
||||
&serde_json::to_string(&*addr_of!(MENU)).expect("Could not serialize MENU"),
|
||||
);
|
||||
}
|
||||
let mut app = QUICK_MENU_APP.lock();
|
||||
app.serialized_default_settings =
|
||||
serde_json::to_string(&get(&DEFAULTS_MENU)).expect("Could not serialize DEFAULTS_MENU");
|
||||
app.update_all_from_json(
|
||||
&serde_json::to_string(&get(&MENU)).expect("Could not serialize MENU"),
|
||||
);
|
||||
}
|
||||
|
||||
pub unsafe fn set_menu_from_json(message: &str) {
|
||||
pub fn set_menu_from_json(message: &str) {
|
||||
let response = serde_json::from_str::<MenuJsonStruct>(message);
|
||||
info!("Received menu message: {message}");
|
||||
if let Ok(message_json) = response {
|
||||
// Includes both MENU and DEFAULTS_MENU
|
||||
assign_rwlock(&MENU, message_json.menu);
|
||||
DEFAULTS_MENU = message_json.defaults_menu;
|
||||
assign_rwlock(&DEFAULTS_MENU, message_json.defaults_menu);
|
||||
fs::write(
|
||||
MENU_OPTIONS_PATH,
|
||||
serde_json::to_string_pretty(&message_json).unwrap(),
|
||||
|
|
|
@ -6,8 +6,8 @@ use smash::lua2cpp::L2CFighterCommon;
|
|||
pub use crate::common::consts::MENU;
|
||||
use crate::common::consts::*;
|
||||
use crate::common::offsets::OFFSET_GET_BATTLE_OBJECT_FROM_ID;
|
||||
use training_mod_sync::*;
|
||||
use crate::training::character_specific::ptrainer;
|
||||
use training_mod_sync::*;
|
||||
|
||||
pub mod button_config;
|
||||
pub mod consts;
|
||||
|
@ -20,8 +20,6 @@ pub mod offsets;
|
|||
pub mod raygun_printer;
|
||||
pub mod release;
|
||||
|
||||
pub static mut DEFAULTS_MENU: TrainingModpackMenu = consts::DEFAULTS_MENU;
|
||||
pub static mut BASE_MENU: TrainingModpackMenu = unsafe { DEFAULTS_MENU };
|
||||
pub static FIGHTER_MANAGER_ADDR: RwLock<usize> = RwLock::new(0);
|
||||
pub static ITEM_MANAGER_ADDR: RwLock<usize> = RwLock::new(0);
|
||||
pub static STAGE_MANAGER_ADDR: RwLock<usize> = RwLock::new(0);
|
||||
|
|
|
@ -112,7 +112,7 @@ pub enum FighterId {
|
|||
CPU = 1,
|
||||
}
|
||||
|
||||
pub static DEFAULTS_MENU: TrainingModpackMenu = TrainingModpackMenu {
|
||||
pub static BASE_MENU: TrainingModpackMenu = TrainingModpackMenu {
|
||||
aerial_delay: Delay::empty(),
|
||||
air_dodge_dir: Direction::empty(),
|
||||
attack_angle: AttackAngle::empty(),
|
||||
|
@ -206,7 +206,8 @@ pub static DEFAULTS_MENU: TrainingModpackMenu = TrainingModpackMenu {
|
|||
lra_reset: OnOff::ON,
|
||||
};
|
||||
|
||||
pub static MENU: RwLock<TrainingModpackMenu> = RwLock::new(DEFAULTS_MENU);
|
||||
pub static DEFAULTS_MENU: RwLock<TrainingModpackMenu> = RwLock::new(BASE_MENU);
|
||||
pub static MENU: RwLock<TrainingModpackMenu> = RwLock::new(BASE_MENU);
|
||||
|
||||
impl_toggletrait! {
|
||||
OnOff,
|
||||
|
|
Loading…
Add table
Reference in a new issue