mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-21 03:18:20 -06:00
bypass menu and save filses on android
This commit is contained in:
parent
28a828430b
commit
31f4e5df6e
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue