//public Game(int gold = 0, GameState state = GameState.Idle, CharacterInfo[] characters = null) //{ // Gold = new ReactiveProperty<int>(gold); // State = new ReactiveProperty<GameState>(state); // CharactersLevels = characters; //} public Game(ISaveService saveService) { GameOptions options = saveService.Load(); if (options == null) { options = new GameOptions(0, new CharacterInfo[] { new CharacterInfo(1, 1), new CharacterInfo(2, 1), new CharacterInfo(3, 1) }); } State = new ReactiveProperty <GameState>(GameState.Idle); Gold = new ReactiveProperty <int>(options.Gold); foreach (var info in options.Characters) { CharactersLevels.Add(info.Type, info.Level); } }
private void openExistingLibrary(string path) { if (!File.Exists(path)) { var details = "The file could not be found."; var actions = MessageBoxButton.OK; if (settingsService.MostRecentLibraries.Any(lib => lib.Path.ToLower() == path.ToLower())) { details += "would you like to remove the library from the list?"; actions = MessageBoxButton.YesNo; } var result = MessageBox.Show("File not found", details, actions); if (result == MessageBoxResult.Yes) { this.settingsService.MostRecentLibraries.RemoveAll(lib => lib.Path.ToLower() == path.ToLower()); } return; } window.Title = $"TableTopCrucible - loading {path}"; var loadProgress = saveService.Load(path); loadingScreen.SetProgressionSource(loadProgress); window.Content = loadingScreen; window.MaxWidth = window.MinWidth = window.Width = 700; window.MaxHeight = window.MinHeight = window.Height = 400; window.WindowState = WindowState.Normal; loadProgress.MainTaskProgression.DoneChanges .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => { if (x == TaskState.Done) { window.MinWidth = 400; window.MinHeight = 400; window.MaxWidth = window.MaxHeight = int.MaxValue; window.WindowState = WindowState.Maximized; window.Title = $"Table Top Crucible - {path}"; window.Content = libraryViewModel; } if (x == TaskState.Failed) { window.Content = string.Join(Environment.NewLine, "Loading failed", loadProgress.MainTaskProgression.Details, loadProgress.MainTaskProgression.Error?.ToString() ); } }); if (settingsService.MostRecentLibraries == null) { settingsService.MostRecentLibraries = new List <LibraryLocation>(); } settingsService.MostRecentLibraries.RemoveAll(library => library.Path == path); settingsService.MostRecentLibraries.Insert(0, new LibraryLocation(false, path, DateTime.Now)); settingsService.Save(); }
private void LoadValue(DebuggableValueModel debuggableValue) { SaveService.Load(debuggableValue); }