1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-30 22:00:16 +00:00

Colored icons in 5 slots

This commit is contained in:
jugeeya 2023-08-15 09:39:05 -07:00
parent a30e6a4031
commit 6d56f89aee
7 changed files with 146 additions and 28 deletions

View file

@ -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)]

Binary file not shown.

Binary file not shown.

View file

@ -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::<Vec<(u16, ResColor)>>();
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

View file

@ -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")

View file

@ -15,7 +15,13 @@ mod input_log;
mod menu;
pub mod notifications;
pub unsafe fn set_icon_text(pane: &mut TextBox, icons: Vec<u16>) {
pub unsafe fn set_colored_icon_text(pane: &mut TextBox, icons: &Vec<u16>, 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<u16>) {
pane.set_text_string("");
let it = pane.text_buf as *mut u16;

View file

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