Ejemplo n.º 1
0
        public async void GameSystemSelected(GameSystemVM system)
        {
            var extensions = system.SupportedExtensions.Concat(EmulationService.ArchiveExtensions).ToArray();
            var file       = await PlatformService.SelectFileAsync(extensions);

            if (file == null)
            {
                return;
            }

            await StartGameAsync(system, file);
        }
        public async void GameSystemSelected(GameSystemVM system)
        {
            if (SelectedGameFile == null)
            {
                var extensions = system.SupportedExtensions.Concat(EmulationService.ArchiveExtensions).ToArray();
                SelectedGameFile = await FileSystem.PickFileAsync(extensions);
            }
            if (SelectedGameFile == null)
            {
                return;
            }

            await StartGameAsync(system, SelectedGameFile);
        }
        private async Task StartGameAsync(GameSystemVM system, IFileInfo file)
        {
            var dependenciesMet = await system.CheckDependenciesMetAsync();

            if (!dependenciesMet)
            {
                ResetSystemsSelection();
                await DisplayNotification(SystemUnmetDependenciesAlertTitleKey, SystemUnmetDependenciesAlertMessageKey);

                return;
            }

            var            folderNeeded = system.CheckRootFolderRequired(file);
            IDirectoryInfo folder       = null;

            if (folderNeeded)
            {
                await DisplayNotification(SelectFolderRequestAlertTitleKey, SelectFolderRequestAlertMessageKey);

                folder = await FileSystem.PickDirectoryAsync();

                if (folder == null)
                {
                    ResetSystemsSelection();
                    return;
                }

                if (!Path.GetDirectoryName(file.FullName).StartsWith(folder.FullName))
                {
                    ResetSystemsSelection();
                    await DisplayNotification(SelectFolderInvalidAlertTitleKey, SelectFolderInvalidAlertMessageKey);

                    return;
                }
            }

            var startSuccess = await EmulationService.StartGameAsync(system, file, folder);

            if (!startSuccess)
            {
                ResetSystemsSelection();
                await DisplayNotification(GameLoadingFailAlertTitleKey, GameLoadingFailAlertMessageKey);
            }
        }