1
0
Fork 0
mirror of https://github.com/jugeeya/UltimateTrainingModpack.git synced 2024-10-03 09:44:26 +00:00

Don't preload session by default (#392)

This commit is contained in:
asimon-1 2022-10-16 16:32:24 -07:00 committed by GitHub
parent 0e2500c77f
commit 4314251664
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View file

@ -7,7 +7,7 @@ use ramhorns::Template;
use skyline::info::get_program_id; use skyline::info::get_program_id;
use skyline::nn::hid::NpadGcState; use skyline::nn::hid::NpadGcState;
use skyline::nn::web::WebSessionBootMode; use skyline::nn::web::WebSessionBootMode;
use skyline_web::{Background, WebSession, Webpage}; use skyline_web::{Background, BootDisplay, WebSession, Webpage};
use std::fs; use std::fs;
use std::path::Path; use std::path::Path;
use training_mod_consts::{MenuJsonStruct, TrainingModpackMenu}; use training_mod_consts::{MenuJsonStruct, TrainingModpackMenu};
@ -120,12 +120,12 @@ pub fn spawn_menu() {
frame_counter::start_counting(QUICK_MENU_FRAME_COUNTER_INDEX); frame_counter::start_counting(QUICK_MENU_FRAME_COUNTER_INDEX);
if MENU.quick_menu == OnOff::Off { if MENU.quick_menu == OnOff::Off {
#[cfg(not(feature = "web_session_single_thread"))] #[cfg(feature = "web_session_preload")]
{ {
WEB_MENU_ACTIVE = true; WEB_MENU_ACTIVE = true;
} }
#[cfg(feature = "web_session_single_thread")] #[cfg(not(feature = "web_session_preload"))]
{ {
spawn_web_session(new_web_session(false)); spawn_web_session(new_web_session(false));
} }
@ -407,6 +407,11 @@ static mut WEB_MENU_ACTIVE: bool = false;
unsafe fn spawn_web_session(session: WebSession) { unsafe fn spawn_web_session(session: WebSession) {
println!("[Training Modpack] Opening menu session..."); println!("[Training Modpack] Opening menu session...");
let loaded_msg = session.recv();
println!(
"[Training Modpack] Received loaded message from web: {}",
&loaded_msg
);
let message_send = MenuJsonStruct { let message_send = MenuJsonStruct {
menu: MENU, menu: MENU,
defaults_menu: DEFAULTS_MENU, defaults_menu: DEFAULTS_MENU,
@ -416,12 +421,6 @@ unsafe fn spawn_web_session(session: WebSession) {
"[Training Modpack] Sending message:\n{}", "[Training Modpack] Sending message:\n{}",
serde_json::to_string_pretty(&message_send).unwrap() serde_json::to_string_pretty(&message_send).unwrap()
); );
session.show();
let loaded_msg = session.recv();
println!(
"[Training Modpack] Received loaded message from web:\n{}",
&loaded_msg
);
let message_recv = session.recv(); let message_recv = session.recv();
println!( println!(
"[Training Modpack] Received menu from web:\n{}", "[Training Modpack] Received menu from web:\n{}",
@ -436,6 +435,8 @@ unsafe fn spawn_web_session(session: WebSession) {
unsafe fn new_web_session(hidden: bool) -> WebSession { unsafe fn new_web_session(hidden: bool) -> WebSession {
Webpage::new() Webpage::new()
.background(Background::BlurredScreenshot) .background(Background::BlurredScreenshot)
.boot_icon(true)
.boot_display(BootDisplay::BlurredScreenshot)
.htdocs_dir("training_modpack") .htdocs_dir("training_modpack")
.start_page("training_menu.html") .start_page("training_menu.html")
.open_session(if hidden { .open_session(if hidden {

View file

@ -26,7 +26,9 @@ use skyline::libc::mkdir;
use skyline::nro::{self, NroInfo}; use skyline::nro::{self, NroInfo};
use std::fs; use std::fs;
use crate::menu::{quick_menu_loop, web_session_loop}; use crate::menu::quick_menu_loop;
#[cfg(feature = "web_session_preload")]
use crate::menu::web_session_loop;
use owo_colors::OwoColorize; use owo_colors::OwoColorize;
use training_mod_consts::{MenuJsonStruct, OnOff}; use training_mod_consts::{MenuJsonStruct, OnOff};
@ -145,7 +147,7 @@ pub fn main() {
std::thread::spawn(|| unsafe { quick_menu_loop() }); std::thread::spawn(|| unsafe { quick_menu_loop() });
#[cfg(not(feature = "web_session_single_thread"))] #[cfg(feature = "web_session_preload")]
if !is_emulator() { if !is_emulator() {
std::thread::spawn(|| unsafe { web_session_loop() }); std::thread::spawn(|| unsafe { web_session_loop() });
} }