mirror of
https://github.com/jugeeya/UltimateTrainingModpack.git
synced 2024-11-24 10:54:16 +00:00
Initial
This commit is contained in:
parent
7c522c02bc
commit
5542279921
7 changed files with 71 additions and 37 deletions
18
ryujinx_build.ps1
vendored
18
ryujinx_build.ps1
vendored
|
@ -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.
|
@ -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,17 +367,17 @@ 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())
|
||||
.unwrap();
|
||||
.expect(format!("Unable to find TrModMenuButtonRow{row_idx}").as_str());
|
||||
menu_button_row.set_visible(false);
|
||||
|
||||
let menu_button = menu_button_row
|
||||
.find_pane_by_name_recursive(format!("Button{col_idx}").as_str())
|
||||
.unwrap();
|
||||
.expect(format!("Unable to find Button{col_idx}").as_str());
|
||||
menu_button.set_visible(false);
|
||||
|
||||
menu_button
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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,16 @@ 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>>()
|
||||
// [
|
||||
// Constraint::Percentage(33),
|
||||
// Constraint::Percentage(33),
|
||||
// Constraint::Percentage(33),
|
||||
// ]
|
||||
.as_ref(),
|
||||
)
|
||||
.split(vertical_chunks[1]);
|
||||
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in a new issue