1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-11-20 00:46:34 +00:00

Upscale size of menu items for better visibility, hide non-menu UI elements (#589)

* Initial

* Last changes

* Update menu.rs

* Update menu.rs

* Update menu.rs
This commit is contained in:
jugeeya 2023-08-13 17:20:14 -07:00 committed by GitHub
parent 7c522c02bc
commit 2b241dcb19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 76 additions and 39 deletions

18
ryujinx_build.ps1 vendored
View file

@ -1,5 +1,21 @@
$IP=(Test-Connection -ComputerName (hostname) -Count 1 | Select -ExpandProperty IPV4Address).IPAddressToString $IP=(Test-Connection -ComputerName (hostname) -Count 1 | Select -ExpandProperty IPV4Address).IPAddressToString
cargo skyline build --release --features layout_arc_from_file cargo skyline build --release --features layout_arc_from_file
Copy-Item target/aarch64-skyline-switch/release/libtraining_modpack.nro 'C:\Users\Jdsam\AppData\Roaming\Ryujinx\mods\contents\01006A800016E000\romfs\skyline\plugins\'
# Set up symlinks
$RYUJINX_LAYOUT_ARC_PATH="C:\Users\Josh\AppData\Roaming\Ryujinx\sdcard\ultimate\TrainingModpack\layout.arc"
$LOCAL_LAYOUT_ARC_PATH="C:\Users\Josh\Documents\Games\UltimateTrainingModpack\src\static\layout.arc"
if(-not(Test-path $RYUJINX_LAYOUT_ARC_PATH -PathType leaf))
{
New-Item -ItemType SymbolicLink -Path $RYUJINX_LAYOUT_ARC_PATH -Target $LOCAL_LAYOUT_ARC_PATH
}
$RYUJINX_PLUGIN_PATH="C:\Users\Josh\AppData\Roaming\Ryujinx\mods\contents\01006a800016e000\romfs\skyline\plugins\libtraining_modpack.nro"
$LOCAL_PLUGIN_PATH="C:\Users\Josh\Documents\Games\UltimateTrainingModpack\target\aarch64-skyline-switch\release\libtraining_modpack.nro"
if(-not(Test-path $RYUJINX_PLUGIN_PATH -PathType leaf))
{
New-Item -ItemType SymbolicLink -Path $RYUJINX_PLUGIN_PATH -Target $LOCAL_PLUGIN_PATH
}
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 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" # 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"

Binary file not shown.

View file

@ -1,7 +1,7 @@
use skyline::nn::ui2d::*; use skyline::nn::ui2d::*;
use smash::ui2d::{SmashPane, SmashTextBox}; use smash::ui2d::{SmashPane, SmashTextBox};
use crate::training::ui; use crate::{common::menu::QUICK_MENU_ACTIVE, training::ui};
macro_rules! display_parent_fmt { macro_rules! display_parent_fmt {
($x:ident) => { ($x:ident) => {
@ -30,7 +30,7 @@ pub unsafe fn draw(root_pane: &Pane) {
root_pane root_pane
.find_pane_by_name_recursive(display_parent_fmt!(notification_idx)) .find_pane_by_name_recursive(display_parent_fmt!(notification_idx))
.unwrap() .unwrap()
.set_visible(notification.is_some()); .set_visible(notification.is_some() && !QUICK_MENU_ACTIVE);
if notification.is_none() { if notification.is_none() {
return; return;
} }

View file

@ -4,11 +4,11 @@ use lazy_static::lazy_static;
use skyline::nn::ui2d::*; use skyline::nn::ui2d::*;
use smash::ui2d::{SmashPane, SmashTextBox}; use smash::ui2d::{SmashPane, SmashTextBox};
use training_mod_tui::gauge::GaugeState; use training_mod_tui::gauge::GaugeState;
use training_mod_tui::{App, AppPage}; use training_mod_tui::{App, AppPage, NUM_LISTS};
use crate::{common, common::menu::QUICK_MENU_ACTIVE, input::*}; use crate::{common, common::menu::QUICK_MENU_ACTIVE, input::*};
pub static NUM_MENU_TEXT_OPTIONS: usize = 33; pub static NUM_MENU_TEXT_OPTIONS: usize = 32;
pub static _NUM_MENU_TABS: usize = 3; pub static _NUM_MENU_TABS: usize = 3;
const BG_LEFT_ON_WHITE_COLOR: ResColor = ResColor { const BG_LEFT_ON_WHITE_COLOR: ResColor = ResColor {
@ -367,8 +367,8 @@ pub unsafe fn draw(root_pane: &Pane) {
// Make all invisible first // Make all invisible first
(0..NUM_MENU_TEXT_OPTIONS).for_each(|idx| { (0..NUM_MENU_TEXT_OPTIONS).for_each(|idx| {
let col_idx = idx % 3; let col_idx = idx % NUM_LISTS;
let row_idx = idx / 3; let row_idx = idx / NUM_LISTS;
let menu_button_row = root_pane let menu_button_row = root_pane
.find_pane_by_name_recursive(format!("TrModMenuButtonRow{row_idx}").as_str()) .find_pane_by_name_recursive(format!("TrModMenuButtonRow{row_idx}").as_str())
@ -386,6 +386,14 @@ pub unsafe fn draw(root_pane: &Pane) {
.set_visible(false); .set_visible(false);
}); });
// Make normal training panes invisible if we're active
// InfluencedAlpha means "Should my children panes' alpha be influenced by mine, as the parent?"
let status_r_pane = root_pane
.find_pane_by_name_recursive("status_R")
.expect("Unable to find status_R pane");
// status_r_pane.flags |= 1 << PaneFlag::InfluencedAlpha as u8;
status_r_pane.set_visible(!QUICK_MENU_ACTIVE);
root_pane root_pane
.find_pane_by_name_recursive("TrModSlider") .find_pane_by_name_recursive("TrModSlider")
.unwrap() .unwrap()

View file

@ -4,7 +4,7 @@ use sarc::SarcFile;
use skyline::nn::ui2d::*; use skyline::nn::ui2d::*;
use training_mod_consts::{OnOff, MENU}; use training_mod_consts::{OnOff, MENU};
use crate::common::{is_ready_go, is_training_mode}; use crate::common::{is_ready_go, is_training_mode, menu::QUICK_MENU_ACTIVE};
#[cfg(feature = "layout_arc_from_file")] #[cfg(feature = "layout_arc_from_file")]
use crate::consts::LAYOUT_ARC_PATH; use crate::consts::LAYOUT_ARC_PATH;
@ -32,7 +32,7 @@ pub unsafe fn handle_draw(layout: *mut Layout, draw_info: u64, cmd_buffer: u64)
{ {
// InfluencedAlpha means "Should my children panes' alpha be influenced by mine, as the parent?" // InfluencedAlpha means "Should my children panes' alpha be influenced by mine, as the parent?"
root_pane.flags |= 1 << PaneFlag::InfluencedAlpha as u8; root_pane.flags |= 1 << PaneFlag::InfluencedAlpha as u8;
root_pane.set_visible(MENU.hud == OnOff::On); root_pane.set_visible(MENU.hud == OnOff::On && !QUICK_MENU_ACTIVE);
} }
damage::draw(root_pane, &layout_name); damage::draw(root_pane, &layout_name);
@ -49,7 +49,7 @@ pub unsafe fn handle_draw(layout: *mut Layout, draw_info: u64, cmd_buffer: u64)
// in order for us to be able to swap the 'layout.arc' with the current // in order for us to be able to swap the 'layout.arc' with the current
// version of the file in between loads of training mode. // version of the file in between loads of training mode.
#[cfg(feature = "layout_arc_from_file")] #[cfg(feature = "layout_arc_from_file")]
const LAYOUT_ARC_SIZE: usize = (2 * MEBIBYTE) as usize; const LAYOUT_ARC_SIZE: usize = (3 * MEBIBYTE) as usize;
#[cfg(feature = "layout_arc_from_file")] #[cfg(feature = "layout_arc_from_file")]
static mut LAYOUT_ARC: &mut [u8; LAYOUT_ARC_SIZE] = &mut [0u8; LAYOUT_ARC_SIZE]; static mut LAYOUT_ARC: &mut [u8; LAYOUT_ARC_SIZE] = &mut [0u8; LAYOUT_ARC_SIZE];

View file

@ -20,7 +20,9 @@ mod list;
use crate::gauge::{DoubleEndedGauge, GaugeState}; use crate::gauge::{DoubleEndedGauge, GaugeState};
use crate::list::{MultiStatefulList, StatefulList}; use crate::list::{MultiStatefulList, StatefulList};
static NX_TUI_WIDTH: u16 = 66; static NX_TUI_WIDTH: u16 = 240;
// Number of lists per page
pub const NUM_LISTS: usize = 4;
#[derive(PartialEq)] #[derive(PartialEq)]
pub enum AppPage { pub enum AppPage {
@ -44,13 +46,11 @@ pub struct App<'a> {
impl<'a> App<'a> { impl<'a> App<'a> {
pub fn new(menu: UiMenu<'a>, default_menu: (UiMenu<'a>, String)) -> App<'a> { pub fn new(menu: UiMenu<'a>, default_menu: (UiMenu<'a>, String)) -> App<'a> {
let num_lists = 3;
let mut menu_items_stateful = HashMap::new(); let mut menu_items_stateful = HashMap::new();
menu.tabs.iter().for_each(|tab| { menu.tabs.iter().for_each(|tab| {
menu_items_stateful.insert( menu_items_stateful.insert(
tab.tab_title, tab.tab_title,
MultiStatefulList::with_items(tab.tab_submenus.clone(), num_lists), MultiStatefulList::with_items(tab.tab_submenus.clone(), NUM_LISTS),
); );
}); });
@ -86,8 +86,8 @@ impl<'a> App<'a> {
SubMenuType::TOGGLE => { SubMenuType::TOGGLE => {
self.selected_sub_menu_toggles = MultiStatefulList::with_items( self.selected_sub_menu_toggles = MultiStatefulList::with_items(
toggles, toggles,
if selected_sub_menu.toggles.len() >= 3 { if selected_sub_menu.toggles.len() >= NUM_LISTS {
3 NUM_LISTS
} else { } else {
selected_sub_menu.toggles.len() selected_sub_menu.toggles.len()
}, },
@ -877,12 +877,11 @@ pub fn ui<B: Backend>(f: &mut Frame<B>, app: &mut App) {
let list_chunks = Layout::default() let list_chunks = Layout::default()
.direction(Direction::Horizontal) .direction(Direction::Horizontal)
.constraints( .constraints(
[ (0..NUM_LISTS)
Constraint::Percentage(33), .into_iter()
Constraint::Percentage(33), .map(|_idx| Constraint::Percentage((100.0 / NUM_LISTS as f32) as u16))
Constraint::Percentage(33), .collect::<Vec<Constraint>>()
] .as_ref(),
.as_ref(),
) )
.split(vertical_chunks[1]); .split(vertical_chunks[1]);

View file

@ -45,12 +45,11 @@ impl<T: Clone> MultiStatefulList<T> {
pub fn with_items(items: Vec<T>, num_lists: usize) -> MultiStatefulList<T> { pub fn with_items(items: Vec<T>, num_lists: usize) -> MultiStatefulList<T> {
let lists = (0..num_lists) let lists = (0..num_lists)
.map(|list_section| { .map(|list_section| {
let list_section_min_idx = // Try to evenly chunk
(items.len() as f32 / num_lists as f32).ceil() as usize * list_section; let list_size = (items.len() as f32 / num_lists as f32).ceil() as usize;
let list_section_max_idx = std::cmp::min( let list_section_min_idx = std::cmp::min(list_size * list_section, items.len());
(items.len() as f32 / num_lists as f32).ceil() as usize * (list_section + 1), let list_section_max_idx =
items.len(), std::cmp::min(list_size * (list_section + 1), items.len());
);
let mut state = ListState::default(); let mut state = ListState::default();
if list_section == 0 { if list_section == 0 {
// Enforce state as first of list // Enforce state as first of list
@ -89,10 +88,15 @@ impl<T: Clone> MultiStatefulList<T> {
pub fn previous(&mut self) { pub fn previous(&mut self) {
let (list_section, _) = self.idx_to_list_idx(self.state); let (list_section, _) = self.idx_to_list_idx(self.state);
let (last_list_section, last_list_idx) = ( let mut last_list_section = self.lists.len() - 1;
self.lists.len() - 1, let mut last_list_size = self.lists[last_list_section].items.len();
self.lists[self.lists.len() - 1].items.len() - 1,
); while last_list_size == 0 {
last_list_section -= 1;
last_list_size = self.lists[last_list_section].items.len();
}
let last_list_idx = last_list_size - 1;
self.lists[list_section].unselect(); self.lists[list_section].unselect();
let state = if self.state == 0 { let state = if self.state == 0 {
@ -108,9 +112,14 @@ impl<T: Clone> MultiStatefulList<T> {
pub fn next_list(&mut self) { pub fn next_list(&mut self) {
let (list_section, list_idx) = self.idx_to_list_idx(self.state); let (list_section, list_idx) = self.idx_to_list_idx(self.state);
let next_list_section = (list_section + 1) % self.lists.len(); let mut next_list_section = (list_section + 1) % self.lists.len();
let next_list_idx = if list_idx > self.lists[next_list_section].items.len() - 1 { let mut next_list_len = self.lists[next_list_section].items.len();
self.lists[next_list_section].items.len() - 1 while next_list_len == 0 {
next_list_section = (next_list_section + 1) % self.lists.len();
next_list_len = self.lists[next_list_section].items.len();
}
let next_list_idx = if list_idx > next_list_len - 1 {
next_list_len - 1
} else { } else {
list_idx list_idx
}; };
@ -126,14 +135,19 @@ impl<T: Clone> MultiStatefulList<T> {
pub fn previous_list(&mut self) { pub fn previous_list(&mut self) {
let (list_section, list_idx) = self.idx_to_list_idx(self.state); let (list_section, list_idx) = self.idx_to_list_idx(self.state);
let prev_list_section = if list_section == 0 { let mut prev_list_section = if list_section == 0 {
self.lists.len() - 1 self.lists.len() - 1
} else { } else {
list_section - 1 list_section - 1
}; };
let prev_list_idx = if list_idx > self.lists[prev_list_section].items.len() - 1 { let mut prev_list_len = self.lists[prev_list_section].items.len();
self.lists[prev_list_section].items.len() - 1 while prev_list_len == 0 {
prev_list_section -= 1;
prev_list_len = self.lists[prev_list_section].items.len();
}
let prev_list_idx = if list_idx > prev_list_len - 1 {
prev_list_len - 1
} else { } else {
list_idx list_idx
}; };

View file

@ -28,7 +28,7 @@ fn test_backend_setup<'a>(
Box<dyn Error>, Box<dyn Error>,
> { > {
let app = training_mod_tui::App::<'a>::new(ui_menu, menu_defaults); let app = training_mod_tui::App::<'a>::new(ui_menu, menu_defaults);
let backend = tui::backend::TestBackend::new(75, 15); let backend = tui::backend::TestBackend::new(120, 15);
let terminal = Terminal::new(backend)?; let terminal = Terminal::new(backend)?;
let mut state = tui::widgets::ListState::default(); let mut state = tui::widgets::ListState::default();
state.select(Some(1)); state.select(Some(1));