From 03cac66d5cbc880c96d9f4b247db5035f3a29a20 Mon Sep 17 00:00:00 2001 From: jugeeya Date: Mon, 7 Aug 2023 20:11:26 -0700 Subject: [PATCH] Record Trigger Refactor (#580) * Initial * Formatting --- src/training/input_record.rs | 12 +++++----- src/training/ledge.rs | 24 +------------------- src/training/save_states.rs | 6 ----- training_mod_consts/src/lib.rs | 8 +++---- training_mod_consts/src/options.rs | 35 ------------------------------ 5 files changed, 11 insertions(+), 74 deletions(-) diff --git a/src/training/input_record.rs b/src/training/input_record.rs index 7790079..44558a9 100644 --- a/src/training/input_record.rs +++ b/src/training/input_record.rs @@ -185,12 +185,12 @@ pub unsafe fn get_command_flag_cat(module_accessor: &mut BattleObjectModuleAcces button_config::ButtonCombo::InputPlayback, ) { playback(MENU.playback_button_combination.get_random().into_idx()); - } - // Attack + Dpad Left: Record - else if button_config::combo_passes_exclusive( - module_accessor, - button_config::ButtonCombo::InputRecord, - ) { + } else if MENU.record_trigger == OnOff::On + && button_config::combo_passes_exclusive( + module_accessor, + button_config::ButtonCombo::InputRecord, + ) + { lockout_record(); } diff --git a/src/training/ledge.rs b/src/training/ledge.rs index 6af0312..e5b5939 100644 --- a/src/training/ledge.rs +++ b/src/training/ledge.rs @@ -139,7 +139,6 @@ pub unsafe fn force_option(module_accessor: &mut app::BattleObjectModuleAccessor // We buffer playback on frame 18 because we don't change status this frame from inputting on next frame; do we need to do one earlier for lasso? if should_buffer_playback && LEDGE_CASE.is_playback() - && MENU.record_trigger != RecordTrigger::Ledge && MENU.ledge_delay != LongDelay::empty() { input_record::playback_ledge(LEDGE_CASE.playback_slot()); @@ -164,9 +163,7 @@ pub unsafe fn force_option(module_accessor: &mut app::BattleObjectModuleAccessor let status = LEDGE_CASE.into_status().unwrap_or(0); if LEDGE_CASE.is_playback() { - if MENU.record_trigger != RecordTrigger::Ledge { - input_record::playback(LEDGE_CASE.playback_slot()); - } + input_record::playback(LEDGE_CASE.playback_slot()); } else { StatusModule::change_status_request_from_script(module_accessor, status, true); } @@ -208,25 +205,6 @@ pub fn get_command_flag_cat(module_accessor: &mut app::BattleObjectModuleAccesso // Set up check for beginning of ledge grab unsafe { - let current_frame = MotionModule::frame(module_accessor) as i32; - // Frame 18 is right before actionability for cliff catch - #[allow(clippy::unnecessary_cast)] - let just_grabbed_ledge = (StatusModule::status_kind(module_accessor) as i32 - == *FIGHTER_STATUS_KIND_CLIFF_CATCH) - && current_frame == 18; - // Needs to be a frame earlier for lasso grabs - #[allow(clippy::unnecessary_cast)] - let just_lassoed_ledge = (StatusModule::status_kind(module_accessor) as i32 - == *FIGHTER_STATUS_KIND_CLIFF_WAIT) - && current_frame == 17; - // Begin recording on ledge if this is the recording trigger - if (just_grabbed_ledge || just_lassoed_ledge) - && MENU.record_trigger == RecordTrigger::Ledge - && !input_record::is_standby() - { - input_record::lockout_record(); - return; - } // Behave normally if we're playing back recorded inputs or controlling the cpu if input_record::is_playback() { return; diff --git a/src/training/save_states.rs b/src/training/save_states.rs index 2ca2e20..48a5717 100644 --- a/src/training/save_states.rs +++ b/src/training/save_states.rs @@ -17,7 +17,6 @@ use crate::common::consts::get_random_float; use crate::common::consts::get_random_int; use crate::common::consts::FighterId; use crate::common::consts::OnOff; -use crate::common::consts::RecordTrigger; use crate::common::consts::SaveStateMirroring; //TODO: Cleanup above use crate::common::consts::SAVE_STATES_TOML_PATH; @@ -608,11 +607,6 @@ pub unsafe fn save_states(module_accessor: &mut app::BattleObjectModuleAccessor) if prev_status_kind == FIGHTER_STATUS_KIND_REBIRTH && fighter_is_popo { save_state.state = NanaPosMove; } - - // if we're recording on state load, record - if MENU.record_trigger == RecordTrigger::SaveState { - input_record::lockout_record(); - } // otherwise, begin input recording playback if selected else if !MENU.save_state_playback.is_empty() { input_record::playback(MENU.save_state_playback.get_random().into_idx()); diff --git a/training_mod_consts/src/lib.rs b/training_mod_consts/src/lib.rs index accbcbb..e21523c 100644 --- a/training_mod_consts/src/lib.rs +++ b/training_mod_consts/src/lib.rs @@ -74,7 +74,7 @@ pub struct TrainingModpackMenu { pub landing_override: Action, pub trump_override: Action, pub recording_slot: RecordSlot, - pub record_trigger: RecordTrigger, + pub record_trigger: OnOff, pub recording_frames: RecordingFrames, pub playback_button_combination: PlaybackSlot, pub hitstun_playback: HitstunPlayback, @@ -173,7 +173,7 @@ pub static DEFAULTS_MENU: TrainingModpackMenu = TrainingModpackMenu { trump_override: Action::empty(), recording_slot: RecordSlot::S1, recording_frames: RecordingFrames::F150, - record_trigger: RecordTrigger::None, + record_trigger: OnOff::On, playback_button_combination: PlaybackSlot::S1, hitstun_playback: HitstunPlayback::Hitstun, playback_mash: OnOff::On, @@ -762,10 +762,10 @@ pub unsafe fn ui_menu(menu: TrainingModpackMenu) -> UiMenu<'static> { true, &(menu.recording_slot as u32), ); - input_tab.add_submenu_with_toggles::( + input_tab.add_submenu_with_toggles::( "Recording Trigger", "record_trigger", - "Recording Trigger: What condition is required to begin recording input", + "Recording Trigger: Whether to begin recording via button combination (Default: Attack+Left Taunt)", true, &(menu.record_trigger as u32), ); diff --git a/training_mod_consts/src/options.rs b/training_mod_consts/src/options.rs index a47e0af..9e355fa 100644 --- a/training_mod_consts/src/options.rs +++ b/training_mod_consts/src/options.rs @@ -1339,41 +1339,6 @@ impl PlaybackSlot { extra_bitflag_impls! {PlaybackSlot} impl_serde_for_bitflags!(PlaybackSlot); -// Input Recording Trigger Type -#[repr(u32)] -#[derive( - Debug, Clone, Copy, PartialEq, FromPrimitive, EnumIter, Serialize_repr, Deserialize_repr, -)] -pub enum RecordTrigger { - None = 0, - Command = 0x1, - SaveState = 0x2, - Ledge = 0x4, -} - -impl RecordTrigger { - pub fn as_str(self) -> Option<&'static str> { - Some(match self { - RecordTrigger::None => "None", - RecordTrigger::Command => "Button Combination", - RecordTrigger::SaveState => "Save State Load", - RecordTrigger::Ledge => "Ledge Grab", - }) - } -} - -impl ToggleTrait for RecordTrigger { - fn to_toggle_strs() -> Vec<&'static str> { - RecordTrigger::iter() - .map(|i| i.as_str().unwrap_or("")) - .collect() - } - - fn to_toggle_vals() -> Vec { - RecordTrigger::iter().map(|i| i as u32).collect() - } -} - // If doing input recording out of hitstun, when does playback begin after? #[repr(u32)] #[derive(