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

View file

@ -4,11 +4,11 @@ use lazy_static::lazy_static;
use skyline::nn::ui2d::*;
use smash::ui2d::{SmashPane, SmashTextBox};
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::*};
pub static NUM_MENU_TEXT_OPTIONS: usize = 33;
pub static NUM_MENU_TEXT_OPTIONS: usize = 32;
pub static _NUM_MENU_TABS: usize = 3;
const BG_LEFT_ON_WHITE_COLOR: ResColor = ResColor {
@ -367,8 +367,8 @@ pub unsafe fn draw(root_pane: &Pane) {
// Make all invisible first
(0..NUM_MENU_TEXT_OPTIONS).for_each(|idx| {
let col_idx = idx % 3;
let row_idx = idx / 3;
let col_idx = idx % NUM_LISTS;
let row_idx = idx / NUM_LISTS;
let menu_button_row = root_pane
.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);
});
// 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
.find_pane_by_name_recursive("TrModSlider")
.unwrap()

View file

@ -4,7 +4,7 @@ use sarc::SarcFile;
use skyline::nn::ui2d::*;
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")]
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?"
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);
@ -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
// version of the file in between loads of training mode.
#[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")]
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::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)]
pub enum AppPage {
@ -44,13 +46,11 @@ pub struct App<'a> {
impl<'a> 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();
menu.tabs.iter().for_each(|tab| {
menu_items_stateful.insert(
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 => {
self.selected_sub_menu_toggles = MultiStatefulList::with_items(
toggles,
if selected_sub_menu.toggles.len() >= 3 {
3
if selected_sub_menu.toggles.len() >= NUM_LISTS {
NUM_LISTS
} else {
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()
.direction(Direction::Horizontal)
.constraints(
[
Constraint::Percentage(33),
Constraint::Percentage(33),
Constraint::Percentage(33),
]
.as_ref(),
(0..NUM_LISTS)
.into_iter()
.map(|_idx| Constraint::Percentage((100.0 / NUM_LISTS as f32) as u16))
.collect::<Vec<Constraint>>()
.as_ref(),
)
.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> {
let lists = (0..num_lists)
.map(|list_section| {
let list_section_min_idx =
(items.len() as f32 / num_lists as f32).ceil() as usize * list_section;
let list_section_max_idx = std::cmp::min(
(items.len() as f32 / num_lists as f32).ceil() as usize * (list_section + 1),
items.len(),
);
// Try to evenly chunk
let list_size = (items.len() as f32 / num_lists as f32).ceil() as usize;
let list_section_min_idx = std::cmp::min(list_size * list_section, items.len());
let list_section_max_idx =
std::cmp::min(list_size * (list_section + 1), items.len());
let mut state = ListState::default();
if list_section == 0 {
// Enforce state as first of list
@ -89,10 +88,15 @@ impl<T: Clone> MultiStatefulList<T> {
pub fn previous(&mut self) {
let (list_section, _) = self.idx_to_list_idx(self.state);
let (last_list_section, last_list_idx) = (
self.lists.len() - 1,
self.lists[self.lists.len() - 1].items.len() - 1,
);
let mut last_list_section = self.lists.len() - 1;
let mut last_list_size = self.lists[last_list_section].items.len();
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();
let state = if self.state == 0 {
@ -108,9 +112,14 @@ impl<T: Clone> MultiStatefulList<T> {
pub fn next_list(&mut self) {
let (list_section, list_idx) = self.idx_to_list_idx(self.state);
let next_list_section = (list_section + 1) % self.lists.len();
let next_list_idx = if list_idx > self.lists[next_list_section].items.len() - 1 {
self.lists[next_list_section].items.len() - 1
let mut next_list_section = (list_section + 1) % self.lists.len();
let mut next_list_len = self.lists[next_list_section].items.len();
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 {
list_idx
};
@ -126,14 +135,19 @@ impl<T: Clone> MultiStatefulList<T> {
pub fn previous_list(&mut self) {
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
} else {
list_section - 1
};
let prev_list_idx = if list_idx > self.lists[prev_list_section].items.len() - 1 {
self.lists[prev_list_section].items.len() - 1
let mut prev_list_len = self.lists[prev_list_section].items.len();
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 {
list_idx
};

View file

@ -28,7 +28,7 @@ fn test_backend_setup<'a>(
Box<dyn Error>,
> {
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 mut state = tui::widgets::ListState::default();
state.select(Some(1));