Example #1
0
        public async Task <bool> SaveGameStateAsync(uint slotID)
        {
            var success = false;

            if (CoreRunner == null)
            {
                return(success);
            }

            SaveStateService.SetGameId(GameID);
            using (var stream = await SaveStateService.GetStreamForSlotAsync(slotID, FileAccess.ReadWrite))
            {
                if (stream == null)
                {
                    return(success);
                }

                success = await CoreRunner.SaveGameStateAsync(stream);

                await stream.FlushAsync();
            }

            if (success)
            {
                var notificationTitle = LocalizationService.GetLocalizedString(StateSavedToSlotMessageTitleKey);
                var notificationBody  = string.Format(LocalizationService.GetLocalizedString(StateSavedToSlotMessageBodyKey), slotID);
                NotificationService.Show(notificationTitle, notificationBody);
            }

            return(success);
        }
Example #2
0
        public async Task <byte[]> SaveGameStateAsync()
        {
            if (CoreRunner == null)
            {
                return(null);
            }

            var output  = new byte[CoreRunner.SerializationSize];
            var success = await CoreRunner.SaveGameStateAsync(output);

            return(success ? output : null);
        }