1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-24 02:44:17 +00:00

Record Trigger Refactor (#580)

* Initial

* Formatting
This commit is contained in:
jugeeya 2023-08-07 20:11:26 -07:00 committed by GitHub
parent d5b774841a
commit 03cac66d5c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 74 deletions

View file

@ -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();
}

View file

@ -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;

View file

@ -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());

View file

@ -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::<RecordTrigger>(
input_tab.add_submenu_with_toggles::<OnOff>(
"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),
);

View file

@ -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<u32> {
RecordTrigger::iter().map(|i| i as u32).collect()
}
}
// If doing input recording out of hitstun, when does playback begin after?
#[repr(u32)]
#[derive(