bypass menu and save filses on android

This commit is contained in:
griffi-gh 2024-12-12 22:04:41 +01:00
parent 28a828430b
commit 31f4e5df6e
3 changed files with 16 additions and 2 deletions

View file

@ -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<String> = 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::<UniqueViewMut<NextState>>().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));

View file

@ -18,7 +18,12 @@ fn intercept_exit(
mut state: UniqueViewMut<NextState>,
cur_state: UniqueView<GameState>,
termination_state: Option<UniqueView<ShutdownState>>,
iota: Option<UniqueView<IOThreadManager>>,
) {
// 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

View file

@ -507,9 +507,13 @@ fn process_completed_tasks(
/// Save all modified chunks to the disk
pub fn save_on_exit(
io: UniqueView<IOThreadManager>,
io: Option<UniqueView<IOThreadManager>>,
world: UniqueView<ChunkStorage>,
) {
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 {