mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2024-11-28 04:44:06 +00:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/common/button_config.rs
This commit is contained in:
commit
3c3ac301fc
3 changed files with 64 additions and 26 deletions
|
@ -20,17 +20,26 @@ lazy_static! {
|
||||||
("JUMPMINI", 0xA), // *CONTROL_PAD_BUTTON_JUMP_MINI
|
("JUMPMINI", 0xA), // *CONTROL_PAD_BUTTON_JUMP_MINI
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
static mut BUTTON_COMBO_CONFIG: BtnComboConfig = BtnComboConfig{
|
static mut BUTTON_COMBO_CONFIG: BtnComboConfig = BtnComboConfig {
|
||||||
open_menu: BtnList{ hold: vec![], press: vec![] },
|
open_menu: BtnList {
|
||||||
save_state: BtnList{ hold: vec![], press: vec![] },
|
hold: vec![],
|
||||||
load_state: BtnList{ hold: vec![], press: vec![] },
|
press: vec![],
|
||||||
|
},
|
||||||
|
save_state: BtnList {
|
||||||
|
hold: vec![],
|
||||||
|
press: vec![],
|
||||||
|
},
|
||||||
|
load_state: BtnList {
|
||||||
|
hold: vec![],
|
||||||
|
press: vec![],
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum ButtonCombo {
|
pub enum ButtonCombo {
|
||||||
OpenMenu,
|
OpenMenu,
|
||||||
SaveState,
|
SaveState,
|
||||||
LoadState
|
LoadState,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default)]
|
#[derive(Deserialize, Default)]
|
||||||
|
@ -55,11 +64,16 @@ pub fn validate_config(data: &str) -> bool {
|
||||||
let conf: TopLevelBtnComboConfig = toml::from_str(data).unwrap();
|
let conf: TopLevelBtnComboConfig = toml::from_str(data).unwrap();
|
||||||
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.iter().flat_map(|btn_list| {
|
let bad_keys = configs
|
||||||
btn_list.hold.iter()
|
.iter()
|
||||||
.chain(btn_list.press.iter())
|
.flat_map(|btn_list| {
|
||||||
.filter(|x| !BUTTON_MAPPING.contains_key(x.to_uppercase().as_str()))
|
btn_list
|
||||||
}).collect::<Vec<&String>>();
|
.hold
|
||||||
|
.iter()
|
||||||
|
.chain(btn_list.press.iter())
|
||||||
|
.filter(|x| !BUTTON_MAPPING.contains_key(x.to_uppercase().as_str()))
|
||||||
|
})
|
||||||
|
.collect::<Vec<&String>>();
|
||||||
|
|
||||||
if !bad_keys.is_empty() {
|
if !bad_keys.is_empty() {
|
||||||
skyline::error::show_error(
|
skyline::error::show_error(
|
||||||
|
@ -67,7 +81,10 @@ pub fn validate_config(data: &str) -> bool {
|
||||||
"Training Modpack custom button\nconfiguration is invalid!\0",
|
"Training Modpack custom button\nconfiguration is invalid!\0",
|
||||||
&format!(
|
&format!(
|
||||||
"The following keys are invalid in\nsd:/TrainingModpack/training_modpack.toml:\n\
|
"The following keys are invalid in\nsd:/TrainingModpack/training_modpack.toml:\n\
|
||||||
{:?}\n\nPossible Keys: {:#?}\0", &bad_keys, BUTTON_MAPPING.keys())
|
{:?}\n\nPossible Keys: {:#?}\0",
|
||||||
|
&bad_keys,
|
||||||
|
BUTTON_MAPPING.keys()
|
||||||
|
),
|
||||||
);
|
);
|
||||||
false
|
false
|
||||||
} else {
|
} else {
|
||||||
|
@ -78,10 +95,19 @@ pub fn validate_config(data: &str) -> bool {
|
||||||
pub fn save_all_btn_config_from_defaults() {
|
pub fn save_all_btn_config_from_defaults() {
|
||||||
let conf = TopLevelBtnComboConfig {
|
let conf = TopLevelBtnComboConfig {
|
||||||
button_config: BtnComboConfig {
|
button_config: BtnComboConfig {
|
||||||
open_menu: BtnList { hold: vec!["SPECIAL".to_string()], press: vec!["UPTAUNT".to_string()] },
|
open_menu: BtnList {
|
||||||
save_state: BtnList { hold: vec!["GRAB".to_string()], press: vec!["DOWNTAUNT".to_string()] },
|
hold: vec!["SPECIAL".to_string()],
|
||||||
load_state: BtnList { hold: vec!["GRAB".to_string()], press: vec!["UPTAUNT".to_string()] },
|
press: vec!["UPTAUNT".to_string()],
|
||||||
}
|
},
|
||||||
|
save_state: BtnList {
|
||||||
|
hold: vec!["GRAB".to_string()],
|
||||||
|
press: vec!["DOWNTAUNT".to_string()],
|
||||||
|
},
|
||||||
|
load_state: BtnList {
|
||||||
|
hold: vec!["GRAB".to_string()],
|
||||||
|
press: vec!["UPTAUNT".to_string()],
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
unsafe {
|
unsafe {
|
||||||
// This println is necessary. Why?.......
|
// This println is necessary. Why?.......
|
||||||
|
@ -99,19 +125,32 @@ pub fn save_all_btn_config_from_toml(data: &str) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn combo_passes(module_accessor: *mut smash::app::BattleObjectModuleAccessor, combo: ButtonCombo) -> bool{
|
pub fn combo_passes(
|
||||||
|
module_accessor: *mut smash::app::BattleObjectModuleAccessor,
|
||||||
|
combo: ButtonCombo,
|
||||||
|
) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let (hold, press) = match combo {
|
let (hold, press) = match combo {
|
||||||
ButtonCombo::OpenMenu => (&BUTTON_COMBO_CONFIG.open_menu.hold, &BUTTON_COMBO_CONFIG.open_menu.press),
|
ButtonCombo::OpenMenu => (
|
||||||
ButtonCombo::SaveState => (&BUTTON_COMBO_CONFIG.save_state.hold, &BUTTON_COMBO_CONFIG.save_state.press),
|
&BUTTON_COMBO_CONFIG.open_menu.hold,
|
||||||
ButtonCombo::LoadState => (&BUTTON_COMBO_CONFIG.load_state.hold, &BUTTON_COMBO_CONFIG.load_state.press),
|
&BUTTON_COMBO_CONFIG.open_menu.press,
|
||||||
|
),
|
||||||
|
ButtonCombo::SaveState => (
|
||||||
|
&BUTTON_COMBO_CONFIG.save_state.hold,
|
||||||
|
&BUTTON_COMBO_CONFIG.save_state.press,
|
||||||
|
),
|
||||||
|
ButtonCombo::LoadState => (
|
||||||
|
&BUTTON_COMBO_CONFIG.load_state.hold,
|
||||||
|
&BUTTON_COMBO_CONFIG.load_state.press,
|
||||||
|
),
|
||||||
};
|
};
|
||||||
hold.iter()
|
hold.iter()
|
||||||
.map(|hold| *BUTTON_MAPPING.get(&*hold.to_uppercase()).unwrap())
|
.map(|hold| *BUTTON_MAPPING.get(&*hold.to_uppercase()).unwrap())
|
||||||
.all(|hold| ControlModule::check_button_on(module_accessor, hold))
|
.all(|hold| ControlModule::check_button_on(module_accessor, hold))
|
||||||
&& press.iter()
|
&& press
|
||||||
.map(|press| *BUTTON_MAPPING.get(&*press.to_uppercase()).unwrap())
|
.iter()
|
||||||
.all(|press| ControlModule::check_button_trigger(module_accessor, press))
|
.map(|press| *BUTTON_MAPPING.get(&*press.to_uppercase()).unwrap())
|
||||||
|
.all(|press| ControlModule::check_button_trigger(module_accessor, press))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,7 @@ pub unsafe fn menu_condition(module_accessor: &mut smash::app::BattleObjectModul
|
||||||
|
|
||||||
// Only check for button combination if the counter is 0 (not locked out)
|
// Only check for button combination if the counter is 0 (not locked out)
|
||||||
match frame_counter::get_frame_count(FRAME_COUNTER_INDEX) {
|
match frame_counter::get_frame_count(FRAME_COUNTER_INDEX) {
|
||||||
0 => {
|
0 => button_config::combo_passes(module_accessor, button_config::ButtonCombo::OpenMenu),
|
||||||
button_config::combo_passes(module_accessor, button_config::ButtonCombo::OpenMenu)
|
|
||||||
}
|
|
||||||
1..MENU_LOCKOUT_FRAMES => false,
|
1..MENU_LOCKOUT_FRAMES => false,
|
||||||
_ => {
|
_ => {
|
||||||
// Waited longer than the lockout time, reset the counter so the menu can be opened again
|
// Waited longer than the lockout time, reset the counter so the menu can be opened again
|
||||||
|
|
|
@ -237,7 +237,8 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor)
|
||||||
&& is_dead(module_accessor);
|
&& is_dead(module_accessor);
|
||||||
let mut triggered_reset: bool = false;
|
let mut triggered_reset: bool = false;
|
||||||
if !is_operation_cpu(module_accessor) {
|
if !is_operation_cpu(module_accessor) {
|
||||||
triggered_reset = button_config::combo_passes(module_accessor, button_config::ButtonCombo::LoadState);
|
triggered_reset =
|
||||||
|
button_config::combo_passes(module_accessor, button_config::ButtonCombo::LoadState);
|
||||||
}
|
}
|
||||||
if (autoload_reset || triggered_reset) && !fighter_is_nana {
|
if (autoload_reset || triggered_reset) && !fighter_is_nana {
|
||||||
if save_state.state == NoAction {
|
if save_state.state == NoAction {
|
||||||
|
|
Loading…
Reference in a new issue