diff --git a/src/common/input.rs b/src/common/input.rs index 21cbf69..ecc34bf 100644 --- a/src/common/input.rs +++ b/src/common/input.rs @@ -1,6 +1,7 @@ #![allow(dead_code)] // TODO: Yeah don't do this use bitflags::bitflags; use modular_bitfield::{bitfield, specifiers::*}; +use training_mod_consts::extra_bitflag_impls; // Need to define necesary structures here. Probably should move to consts or something. Realistically, should be in skyline smash prob tho. @@ -212,6 +213,16 @@ bitflags! { } } +// This requires some imports to work +use training_mod_consts::{random_option, ToggleTrait}; +impl Buttons { + fn as_str(self) -> Option<&'static str> { + todo!(); + } +} + +extra_bitflag_impls!(Buttons); + // Controller class used internally by the game #[derive(Debug, Default, Copy, Clone)] #[repr(C)] diff --git a/src/static/layout.arc b/src/static/layout.arc index 130ff5d..e64e08a 100644 Binary files a/src/static/layout.arc and b/src/static/layout.arc differ diff --git a/src/static/training_mod_menu_input_log.bflyt b/src/static/training_mod_menu_input_log.bflyt new file mode 100644 index 0000000..6ad596f Binary files /dev/null and b/src/static/training_mod_menu_input_log.bflyt differ diff --git a/src/training/ui/input_log.rs b/src/training/ui/input_log.rs index 8b66827..87cdd6d 100644 --- a/src/training/ui/input_log.rs +++ b/src/training/ui/input_log.rs @@ -11,7 +11,7 @@ use crate::{ training::input_log::P1_INPUT_MAPPINGS, }; -use super::set_icon_text; +use super::set_colored_icon_text; macro_rules! log_parent_fmt { ($x:ident) => { @@ -44,37 +44,137 @@ pub unsafe fn draw(root_pane: &Pane) { return; } - let input_pane = log_pane - .find_pane_by_name_recursive("InputTxt") - .unwrap() - .as_textbox(); + let icons = first_log + .buttons + .to_vec() + .iter() + .filter_map(|button| { + Some(match *button { + Buttons::ATTACK | Buttons::ATTACK_RAW => ( + name_to_font_glyph(ButtonConfig::A, *p1_style_ptr), + ResColor { + r: 0, + g: 255, + b: 0, + a: 255, + }, + ), + Buttons::SPECIAL | Buttons::SPECIAL_RAW | Buttons::SPECIAL_RAW2 => ( + name_to_font_glyph(ButtonConfig::B, *p1_style_ptr), + ResColor { + r: 0, + g: 255, + b: 0, + a: 255, + }, + ), + Buttons::JUMP | Buttons::FLICK_JUMP => ( + name_to_font_glyph(ButtonConfig::X, *p1_style_ptr), + ResColor { + r: 255, + g: 255, + b: 255, + a: 255, + }, + ), + Buttons::GUARD | Buttons::GUARD_HOLD => ( + name_to_font_glyph(ButtonConfig::L, *p1_style_ptr), + ResColor { + r: 0, + g: 0, + b: 255, + a: 255, + }, + ), + Buttons::CATCH => ( + name_to_font_glyph(ButtonConfig::ZR, *p1_style_ptr), + ResColor { + r: 255, + g: 0, + b: 255, + a: 255, + }, + ), + Buttons::STOCK_SHARE => ( + name_to_font_glyph(ButtonConfig::PLUS, *p1_style_ptr), + ResColor { + r: 255, + g: 255, + b: 255, + a: 255, + }, + ), + Buttons::APPEAL_HI => ( + name_to_font_glyph(ButtonConfig::DPAD_UP, *p1_style_ptr), + ResColor { + r: 255, + g: 255, + b: 255, + a: 255, + }, + ), + Buttons::APPEAL_LW => ( + name_to_font_glyph(ButtonConfig::DPAD_DOWN, *p1_style_ptr), + ResColor { + r: 255, + g: 255, + b: 255, + a: 255, + }, + ), + Buttons::APPEAL_SL => ( + name_to_font_glyph(ButtonConfig::DPAD_LEFT, *p1_style_ptr), + ResColor { + r: 255, + g: 255, + b: 255, + a: 255, + }, + ), + Buttons::APPEAL_SR => ( + name_to_font_glyph(ButtonConfig::DPAD_RIGHT, *p1_style_ptr), + ResColor { + r: 255, + g: 255, + b: 255, + a: 255, + }, + ), + _ => return None, + }) + }) + .filter_map(|(icon_opt, color)| { + if let Some(icon) = icon_opt { + return Some((icon, color)); + } - input_pane.set_text_string("NONE"); + None + }) + .collect::>(); - let mut glyphs = vec![]; - if first_log.buttons.contains(Buttons::ATTACK) { - let potential_font_glyph = name_to_font_glyph(ButtonConfig::A, *p1_style_ptr); - if let Some(font_glyph) = potential_font_glyph { - glyphs.push(font_glyph); - } + // Empty them first + const NUM_ICON_SLOTS: usize = 5; + for idx in 0..NUM_ICON_SLOTS { + let input_pane = log_pane + .find_pane_by_name_recursive(format!("InputTxt{}", idx).as_str()) + .unwrap() + .as_textbox(); + + input_pane.set_text_string(""); } - if first_log.buttons.contains(Buttons::SPECIAL) { - let potential_font_glyph = name_to_font_glyph(ButtonConfig::B, *p1_style_ptr); - if let Some(font_glyph) = potential_font_glyph { - glyphs.push(font_glyph); + for (idx, icon) in icons.iter().enumerate() { + // todo: handle this better + if idx >= NUM_ICON_SLOTS { + continue; } - } - if first_log.buttons.contains(Buttons::JUMP) { - let potential_font_glyph = name_to_font_glyph(ButtonConfig::X, *p1_style_ptr); - if let Some(font_glyph) = potential_font_glyph { - glyphs.push(font_glyph); - } - } + let input_pane = log_pane + .find_pane_by_name_recursive(format!("InputTxt{}", idx).as_str()) + .unwrap() + .as_textbox(); - if !glyphs.is_empty() { - set_icon_text(input_pane, glyphs); + set_colored_icon_text(input_pane, &vec![icon.0], icon.1); } log_pane diff --git a/src/training/ui/menu.rs b/src/training/ui/menu.rs index 3965cda..b7b9cd8 100644 --- a/src/training/ui/menu.rs +++ b/src/training/ui/menu.rs @@ -461,7 +461,7 @@ pub unsafe fn draw(root_pane: &Pane) { // Left/Right tabs have keys if let Some(key) = key { - set_icon_text(icon_pane, vec![**key]); + set_icon_text(icon_pane, &vec![**key]); } if *name == "CurrentTab" { @@ -485,7 +485,7 @@ pub unsafe fn draw(root_pane: &Pane) { .find_pane_by_name_recursive("set_txt_icon") .unwrap() .as_textbox(); - set_icon_text(icon_pane, vec![*key.unwrap()]); + set_icon_text(icon_pane, &vec![*key.unwrap()]); key_help_pane .find_pane_by_name_recursive("set_txt_help") diff --git a/src/training/ui/mod.rs b/src/training/ui/mod.rs index 159fceb..2dd2e06 100644 --- a/src/training/ui/mod.rs +++ b/src/training/ui/mod.rs @@ -15,7 +15,13 @@ mod input_log; mod menu; pub mod notifications; -pub unsafe fn set_icon_text(pane: &mut TextBox, icons: Vec) { +pub unsafe fn set_colored_icon_text(pane: &mut TextBox, icons: &Vec, color: ResColor) { + pane.set_default_material_colors(); + pane.set_color(color.r, color.g, color.b, color.a); + set_icon_text(pane, icons); +} + +pub unsafe fn set_icon_text(pane: &mut TextBox, icons: &Vec) { pane.set_text_string(""); let it = pane.text_buf as *mut u16; diff --git a/training_mod_consts/src/options.rs b/training_mod_consts/src/options.rs index ce7df62..2083fbd 100644 --- a/training_mod_consts/src/options.rs +++ b/training_mod_consts/src/options.rs @@ -28,6 +28,7 @@ pub trait SliderTrait { } // bitflag helper function macro +#[macro_export] macro_rules! extra_bitflag_impls { ($e:ty) => { impl core::fmt::Display for $e {