mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-04-13 00:52:42 +00:00
Add lots, but glitchy fade out needs fixing
This commit is contained in:
parent
c14b6cb4e2
commit
f6d49e8256
6 changed files with 106 additions and 18 deletions
9
ryujinx_build.ps1
vendored
9
ryujinx_build.ps1
vendored
|
@ -10,6 +10,9 @@ $LOCAL_LAYOUT_ARC_PATH="C:\Users\Josh\Documents\Games\UltimateTrainingModpack\sr
|
|||
if(-not(Test-path $RYUJINX_LAYOUT_ARC_PATH -PathType leaf))
|
||||
{
|
||||
New-Item -ItemType SymbolicLink -Path $RYUJINX_LAYOUT_ARC_PATH -Target $LOCAL_LAYOUT_ARC_PATH
|
||||
if (($lastexitcode -ne 0)) {
|
||||
exit $lastexitcode
|
||||
}
|
||||
}
|
||||
|
||||
$RYUJINX_PLUGIN_PATH="C:\Users\Josh\AppData\Roaming\Ryujinx\mods\contents\01006a800016e000\romfs\skyline\plugins\libtraining_modpack.nro"
|
||||
|
@ -17,8 +20,10 @@ $LOCAL_PLUGIN_PATH="C:\Users\Josh\Documents\Games\UltimateTrainingModpack\target
|
|||
if(-not(Test-path $RYUJINX_PLUGIN_PATH -PathType leaf))
|
||||
{
|
||||
New-Item -ItemType SymbolicLink -Path $RYUJINX_PLUGIN_PATH -Target $LOCAL_PLUGIN_PATH
|
||||
if (($lastexitcode -ne 0)) {
|
||||
exit $lastexitcode
|
||||
}
|
||||
}
|
||||
|
||||
C:\Users\Josh\Documents\Games\Ryujinx\publish\Ryujinx.exe "C:\Users\Josh\Documents\Games\ROMs\Super Smash Bros Ultimate [Base Game]\Super Smash Bros Ultimate[01006A800016E000][US][v0].nsp"
|
||||
cargo skyline listen --ip=$IP
|
||||
# C:\Users\Jdsam\Documents\Games\Emulators\ryujinx-1.1.299-win_x64\publish\BLAH.exe C:\Users\Jdsam\Documents\Games\Emulators\ryujinx-1.1.299-win_x64\publish\Ryujinx.exe "C:\Users\Jdsam\Documents\Games\SmashRoms\UltimateXCI\ultimate.xci"
|
||||
cargo skyline listen --ip=$IP
|
Binary file not shown.
Binary file not shown.
|
@ -2,21 +2,66 @@ use crate::common::input::*;
|
|||
use lazy_static::lazy_static;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
use super::frame_counter;
|
||||
|
||||
static mut FRAME_COUNTER: usize = 0;
|
||||
|
||||
pub fn init() {
|
||||
unsafe {
|
||||
FRAME_COUNTER = frame_counter::register_counter();
|
||||
frame_counter::start_counting(FRAME_COUNTER);
|
||||
}
|
||||
}
|
||||
|
||||
pub const NUM_LOGS: usize = 10;
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
pub enum DirectionStrength {
|
||||
None,
|
||||
Weak,
|
||||
Strong,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Default)]
|
||||
pub struct InputLog {
|
||||
pub frames: u64,
|
||||
pub ttl: u32,
|
||||
pub frames: u32,
|
||||
pub raw_inputs: Controller,
|
||||
pub smash_inputs: MappedInputs,
|
||||
}
|
||||
|
||||
impl InputLog {
|
||||
pub fn is_different(&self, other: &InputLog) -> bool {
|
||||
// TODO: Vary raw vs smash based on menu option
|
||||
fn bin_stick_values(x: f32, y: f32) -> (DirectionStrength, f32) {
|
||||
let angle = y.atan2(x).to_degrees();
|
||||
let length = (x * x + y * y).sqrt();
|
||||
(
|
||||
match length.abs() {
|
||||
x if x > 0.5 => DirectionStrength::Strong,
|
||||
x if x > 0.2 => DirectionStrength::Weak,
|
||||
_ => DirectionStrength::None,
|
||||
},
|
||||
angle,
|
||||
)
|
||||
}
|
||||
|
||||
// TODO: Include direction binning checks
|
||||
impl InputLog {
|
||||
pub fn is_smash_different(&self, other: &InputLog) -> bool {
|
||||
self.smash_inputs.buttons != other.smash_inputs.buttons
|
||||
|| self.smash_binned_lstick() != other.smash_binned_lstick()
|
||||
|| self.smash_binned_rstick() != other.smash_binned_rstick()
|
||||
}
|
||||
|
||||
pub fn smash_binned_lstick(&self) -> (DirectionStrength, f32) {
|
||||
let x = self.smash_inputs.lstick_x as f32;
|
||||
let y = self.smash_inputs.lstick_y as f32;
|
||||
|
||||
bin_stick_values(x, y)
|
||||
}
|
||||
|
||||
pub fn smash_binned_rstick(&self) -> (DirectionStrength, f32) {
|
||||
let x = self.smash_inputs.rstick_x as f32;
|
||||
let y = self.smash_inputs.rstick_y as f32;
|
||||
|
||||
bin_stick_values(x, y)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,26 +86,32 @@ pub fn handle_final_input_mapping(
|
|||
) {
|
||||
unsafe {
|
||||
if player_idx == 0 {
|
||||
// TODO: Use frame counter to determine frame value
|
||||
let current_frame = frame_counter::get_frame_count(FRAME_COUNTER);
|
||||
|
||||
let potential_input_log = InputLog {
|
||||
ttl: 600,
|
||||
frames: 1,
|
||||
raw_inputs: *controller_struct.controller,
|
||||
smash_inputs: *out,
|
||||
};
|
||||
|
||||
let input_logs = &mut *P1_INPUT_LOGS.lock();
|
||||
let latest_input_log = input_logs.first_mut();
|
||||
if latest_input_log.is_none() {
|
||||
insert_in_front(input_logs, potential_input_log);
|
||||
return;
|
||||
}
|
||||
|
||||
let latest_input_log = latest_input_log.unwrap();
|
||||
if latest_input_log.is_different(&potential_input_log) {
|
||||
let latest_input_log = input_logs.first_mut().unwrap();
|
||||
// Use different "different" function depending on menu option
|
||||
if latest_input_log.is_smash_different(&potential_input_log) {
|
||||
frame_counter::reset_frame_count(FRAME_COUNTER);
|
||||
// We should count this frame already
|
||||
frame_counter::tick_idx(FRAME_COUNTER);
|
||||
insert_in_front(input_logs, potential_input_log);
|
||||
} else {
|
||||
latest_input_log.frames = std::cmp::min(latest_input_log.frames + 1, 99);
|
||||
latest_input_log.frames = std::cmp::min(current_frame, 99);
|
||||
}
|
||||
|
||||
// For the remainder, decrease TTL
|
||||
for input_log in input_logs.iter_mut().take(NUM_LOGS).skip(1) {
|
||||
if input_log.ttl > 0 {
|
||||
input_log.ttl -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -737,6 +737,7 @@ unsafe fn handle_final_input_mapping(
|
|||
// MUTATES controller state
|
||||
input_delay::handle_final_input_mapping(player_idx, out);
|
||||
|
||||
// Read potentially delayed state for loggers
|
||||
input_log::handle_final_input_mapping(player_idx, controller_struct, out);
|
||||
|
||||
// Potentially apply input recording, thus with delay
|
||||
|
@ -834,6 +835,7 @@ pub fn training_mods() {
|
|||
buff::init();
|
||||
items::init();
|
||||
tech::init();
|
||||
input_log::init();
|
||||
input_record::init();
|
||||
ui::init();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use crate::{
|
|||
input::Buttons,
|
||||
menu::{P1_CONTROLLER_STYLE, QUICK_MENU_ACTIVE},
|
||||
},
|
||||
training::input_log::{InputLog, P1_INPUT_LOGS},
|
||||
training::input_log::{DirectionStrength, InputLog, P1_INPUT_LOGS},
|
||||
};
|
||||
|
||||
use super::set_colored_icon_text;
|
||||
|
@ -27,6 +27,15 @@ unsafe fn draw_log(root_pane: &Pane, log_idx: usize, log: &InputLog) {
|
|||
|
||||
// TODO: And menu option for input log is on
|
||||
log_pane.set_visible(!QUICK_MENU_ACTIVE);
|
||||
if log.ttl < 100 {
|
||||
// Fade out
|
||||
let alpha = (log.ttl as f32 / 100.0) as u8 * 255;
|
||||
log_pane.alpha = alpha;
|
||||
log_pane.global_alpha = alpha;
|
||||
} else {
|
||||
log_pane.alpha = 255;
|
||||
log_pane.global_alpha = 255;
|
||||
}
|
||||
|
||||
let p1_style_ptr = P1_CONTROLLER_STYLE.data_ptr();
|
||||
if p1_style_ptr.is_null() {
|
||||
|
@ -154,7 +163,28 @@ unsafe fn draw_log(root_pane: &Pane, log_idx: usize, log: &InputLog) {
|
|||
input_pane.set_text_string("");
|
||||
}
|
||||
|
||||
let lstick_x = match log.smash_binned_lstick() {
|
||||
(DirectionStrength::Strong, angle) if angle > 0.0 => ">>",
|
||||
(DirectionStrength::Weak, angle) if angle > 0.0 => ">",
|
||||
(DirectionStrength::Weak, angle) if angle < 0.0 => "<",
|
||||
(DirectionStrength::Strong, angle) if angle < 0.0 => "<<",
|
||||
_ => "",
|
||||
};
|
||||
|
||||
let lstick_icon_exists = !lstick_x.is_empty();
|
||||
if lstick_icon_exists {
|
||||
let input_pane = log_pane
|
||||
.find_pane_by_name_recursive("InputTxt0")
|
||||
.unwrap()
|
||||
.as_textbox();
|
||||
|
||||
input_pane.set_default_material_colors();
|
||||
input_pane.set_color(255, 255, 255, 255);
|
||||
input_pane.set_text_string(lstick_x);
|
||||
}
|
||||
|
||||
for (idx, icon) in icons.iter().enumerate() {
|
||||
let idx = if lstick_icon_exists { idx + 1 } else { idx };
|
||||
// todo: handle this better
|
||||
if idx >= NUM_ICON_SLOTS {
|
||||
continue;
|
||||
|
|
Loading…
Add table
Reference in a new issue