From 31f4e5df6e66d9ae9abe2eb1feee1e0efca568a9 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Thu, 12 Dec 2024 22:04:41 +0100 Subject: [PATCH] bypass menu and save filses on android --- kubi/src/init.rs | 7 ++++++- kubi/src/ui/shutdown_screen.rs | 5 +++++ kubi/src/world/loading.rs | 6 +++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/kubi/src/init.rs b/kubi/src/init.rs index 06484c3..56fcbf0 100644 --- a/kubi/src/init.rs +++ b/kubi/src/init.rs @@ -12,7 +12,12 @@ pub fn initialize_from_args( // If an address is provided, we're in multiplayer mode (the first argument is the address) // Otherwise, we're in singleplayer mode and working with local stuff let args: Vec = env::args().collect(); - if args.get(1) == Some(&"play".into()) { + if cfg!(target_os = "android") || (args.get(1) == Some(&"android".into())) { + // TODO REMOVE: temporarily bypass menu on Android as hUI (0.1.0-alpha.5) doesnt play well with touchscreens (yet? :3) + // TODO REMOVE: disable save files on Android as they're stored in relative path rn + all_storages.add_unique(GameType::Singleplayer); + all_storages.borrow::>().unwrap().0 = Some(GameState::LoadingWorld); + } else if args.get(1) == Some(&"play".into()) { // Open the local save file let save_file = open_local_save_file(Path::new("./world.kubi")).expect("failed to open save file"); all_storages.add_unique(IOThreadManager::new(save_file)); diff --git a/kubi/src/ui/shutdown_screen.rs b/kubi/src/ui/shutdown_screen.rs index 5fb6f0c..5e07030 100644 --- a/kubi/src/ui/shutdown_screen.rs +++ b/kubi/src/ui/shutdown_screen.rs @@ -18,7 +18,12 @@ fn intercept_exit( mut state: UniqueViewMut, cur_state: UniqueView, termination_state: Option>, + iota: Option>, ) { + // If iota is missing, don't bother with shutdown state (likely running without a save file) + if iota.is_none() { + return; + } if exit.0 { if *cur_state == GameState::ShuttingDown { // If we're already shutting down, check if we're done diff --git a/kubi/src/world/loading.rs b/kubi/src/world/loading.rs index 5963be1..88b2d33 100644 --- a/kubi/src/world/loading.rs +++ b/kubi/src/world/loading.rs @@ -507,9 +507,13 @@ fn process_completed_tasks( /// Save all modified chunks to the disk pub fn save_on_exit( - io: UniqueView, + io: Option>, world: UniqueView, ) { + let Some(io) = io else { + log::warn!("no IO thread manager, skipping save on exit"); + return + }; for (&position, chunk) in &world.chunks { if let Some(block_data) = &chunk.block_data { if chunk.data_modified {