mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2025-03-16 03:16:12 +00:00
Begin to use font glyphs, small refactor
This commit is contained in:
parent
ddd5f16b87
commit
a30e6a4031
3 changed files with 40 additions and 15 deletions
|
@ -11,6 +11,8 @@ use crate::{
|
|||
training::input_log::P1_INPUT_MAPPINGS,
|
||||
};
|
||||
|
||||
use super::set_icon_text;
|
||||
|
||||
macro_rules! log_parent_fmt {
|
||||
($x:ident) => {
|
||||
format!("TrModInputLog{}", $x).as_str()
|
||||
|
@ -49,18 +51,32 @@ pub unsafe fn draw(root_pane: &Pane) {
|
|||
|
||||
input_pane.set_text_string("NONE");
|
||||
|
||||
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 {
|
||||
input_pane.set_text_string("");
|
||||
|
||||
let it = input_pane.text_buf as *mut u16;
|
||||
input_pane.text_len = 1;
|
||||
*it = font_glyph;
|
||||
*(it.add(1)) = 0x0;
|
||||
glyphs.push(font_glyph);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if !glyphs.is_empty() {
|
||||
set_icon_text(input_pane, glyphs);
|
||||
}
|
||||
|
||||
log_pane
|
||||
.find_pane_by_name_recursive("FrameTxt")
|
||||
.unwrap()
|
||||
|
|
|
@ -8,6 +8,8 @@ use training_mod_tui::{App, AppPage, NUM_LISTS};
|
|||
|
||||
use crate::{common, common::menu::QUICK_MENU_ACTIVE, input::*};
|
||||
|
||||
use super::set_icon_text;
|
||||
|
||||
pub static NUM_MENU_TEXT_OPTIONS: usize = 32;
|
||||
pub static _NUM_MENU_TABS: usize = 3;
|
||||
|
||||
|
@ -459,10 +461,7 @@ pub unsafe fn draw(root_pane: &Pane) {
|
|||
|
||||
// Left/Right tabs have keys
|
||||
if let Some(key) = key {
|
||||
let it = icon_pane.text_buf as *mut u16;
|
||||
icon_pane.text_len = 1;
|
||||
*it = **key;
|
||||
*(it.add(1)) = 0x0;
|
||||
set_icon_text(icon_pane, vec![**key]);
|
||||
}
|
||||
|
||||
if *name == "CurrentTab" {
|
||||
|
@ -486,11 +485,7 @@ pub unsafe fn draw(root_pane: &Pane) {
|
|||
.find_pane_by_name_recursive("set_txt_icon")
|
||||
.unwrap()
|
||||
.as_textbox();
|
||||
icon_pane.set_text_string("");
|
||||
let it = icon_pane.text_buf as *mut u16;
|
||||
icon_pane.text_len = 1;
|
||||
*it = *key.unwrap();
|
||||
*(it.add(1)) = 0x0;
|
||||
set_icon_text(icon_pane, vec![*key.unwrap()]);
|
||||
|
||||
key_help_pane
|
||||
.find_pane_by_name_recursive("set_txt_help")
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
use byte_unit::MEBIBYTE;
|
||||
use sarc::SarcFile;
|
||||
use skyline::nn::ui2d::*;
|
||||
use smash::ui2d::SmashTextBox;
|
||||
use training_mod_consts::{OnOff, MENU};
|
||||
|
||||
use crate::common::{is_ready_go, is_training_mode, menu::QUICK_MENU_ACTIVE};
|
||||
|
@ -14,6 +15,19 @@ mod input_log;
|
|||
mod menu;
|
||||
pub mod notifications;
|
||||
|
||||
pub unsafe fn set_icon_text(pane: &mut TextBox, icons: Vec<u16>) {
|
||||
pane.set_text_string("");
|
||||
|
||||
let it = pane.text_buf as *mut u16;
|
||||
pane.text_len = icons.len() as u16;
|
||||
for (idx, icon) in icons.iter().enumerate() {
|
||||
*(it.add(idx)) = *icon;
|
||||
}
|
||||
|
||||
// Add nullptr at end to be sure
|
||||
*(it.add(icons.len())) = 0x0;
|
||||
}
|
||||
|
||||
#[skyline::hook(offset = 0x4b620)]
|
||||
pub unsafe fn handle_draw(layout: *mut Layout, draw_info: u64, cmd_buffer: u64) {
|
||||
let layout_name = skyline::from_c_str((*layout).layout_name);
|
||||
|
|
Loading…
Add table
Reference in a new issue