public void DeseralizeSkeletonGameConfig(string gameFolder) { var gameConfig = _skeleSerializer .DeserializeSkeletonYaml <GameConfig>(@"TestData/" + gameFolder + "//" + Constants.FILE_CONFIG); Assert.NotNull(gameConfig); }
public Task LoadYamlEntriesAsync() { if (string.IsNullOrWhiteSpace(this.GameFolder)) { throw new System.NullReferenceException("Game folder cannot be an empty string"); } if (!Directory.Exists(GameFolder)) { throw new FileNotFoundException($"Cannot find game folder: {GameFolder}"); } ClearConfigs(); return(Task.Run(async() => { var errored = false; var args = new ProviderUpdatedEventArgs() { Status = 2 }; this.OnProviderFinished(args); try { GameConfig = _skeletonGameSerializer.DeserializeSkeletonYaml <GameConfig>(Path.Combine(GameFolder, YamlFiles[0])); if (GameConfig == null) { throw new NullReferenceException("Config.yaml returned null, please check your config.yaml"); } #region MACHINE CONFIG try { var machineConfig = Path.Combine(GameFolder, YamlFiles[5]); MachineConfig = _skeletonGameSerializer.DeserializeSkeletonYaml <MachineConfig>(machineConfig); } catch (FileNotFoundException ex) { Dispatcher.CurrentDispatcher.Invoke(() => { System.Windows.MessageBox.Show($"{ex.Message}"); }); } catch (System.Exception ex) { var msg = $"Failed loading Game. \r\n {ex.Data["yaml"]} {ex.Message}"; msg += $"\n\r {ex.Data["err"]}"; Log(msg, Category.Exception); try { Dispatcher.CurrentDispatcher.Invoke(() => { ParseMachineConfigWithKeyValues(ex); }); } catch (Exception exee) { msg = $"Failed loading Game. \r\n {exee.Data["yaml"]} {exee.Message}"; msg += $"\n\r {exee.Data["err"]}"; Log(msg); throw; } } #endregion AssetsConfig = null; if (File.Exists(Path.Combine(GameFolder, YamlFiles[1]))) { AssetsConfig = _skeletonGameSerializer.DeserializeSkeletonYaml <AssetsFile>(Path.Combine(GameFolder, YamlFiles[1])); } if (!File.Exists(Path.Combine(GameFolder, YamlFiles[2]))) { throw new FileNotFoundException("attract.yaml not found."); } AttractConfig = GetSequence(Path.Combine(GameFolder, YamlFiles[2])); var newScoreDisplayYaml = Path.Combine(GameFolder, YamlFiles[3]); var scoreDisplayYaml = Path.Combine(GameFolder, YamlFiles[4]); //Deal with the updated score display if (File.Exists(newScoreDisplayYaml)) { ScoreDisplayConfig = _skeletonGameSerializer.DeserializeSkeletonYaml <ScoreDisplay>(newScoreDisplayYaml); } else if (File.Exists(scoreDisplayYaml)) { ScoreDisplayConfig = _skeletonGameSerializer.DeserializeSkeletonYaml <ScoreDisplay>(scoreDisplayYaml); } SequenceYamls.Clear(); //Add the base sequences.yaml found in config var baseSeqFile = Path.Combine(GameFolder, @"config\sequences.yaml"); if (File.Exists(baseSeqFile)) { SequenceYamls.Add(baseSeqFile); } //Get sequence files and add to list var seqDir = Path.Combine(GameFolder, @"config\sequences"); Directory.CreateDirectory(seqDir); var seqFiles = await _skeletonGameFiles.GetFilesAsync(seqDir, AssetTypes.Sequences); foreach (var item in seqFiles) { SequenceYamls.Add(item); } Directory.CreateDirectory(GameFolder + @"\recordings"); RecordingManager.GetPlaybackFiles(GameFolder + @"\recordings"); //Trophy Data var trophydefaultData = Path.Combine(GameFolder, YamlFiles[6]); if (!File.Exists(trophydefaultData)) { string msg = $"Couldn't find default trophy data at {trophydefaultData}"; _eventAggregator.GetEvent <ErrorMessageEvent>().Publish(msg); Log(msg, Category.Warn); } else { TrophyData = _skeletonGameSerializer.DeserializeSkeletonYaml <TrophyData>(trophydefaultData); } } catch (System.Exception) { ClearConfigs(); errored = true; throw; } finally { if (errored) { args.Status = 0; } else { args.Status = -1; } OnProviderFinished(args); } })); }