public LeaderBordViewModel(Config cfg) { if (File.Exists("LeaderBord.ldr")) { try { Scores = MySerializer.DeserializeXml <List <Score> >("LeaderBord.ldr"); } catch (InvalidOperationException) { Scores = Score.GetDeffaultScoreList(); CustomMessageBox messageBox = new CustomMessageBox("File LeaderBord.ldr is damaged. Reset to default leader bord"); messageBox.ShowDialog(); MySerializer.SerializeXml <List <Score> >(Scores, "LeaderBord.ldr"); } } else { Scores = Score.GetDeffaultScoreList(); } Scores.Sort(); Scores.Reverse(); _config = cfg; }
public GameViewModel(Config cfg) { _currWolf = _wolfLT; animator.ReadyToCatch += EggReadyToCatch; animator.LifeActivate += LifeActive; _config = cfg; if (File.Exists("LeaderBord.ldr")) { try { _scores = MySerializer.DeserializeXml <List <Score> >("LeaderBord.ldr"); } catch (InvalidOperationException) { _scores = Score.GetDeffaultScoreList(); CustomMessageBox messageBox = new CustomMessageBox("File LeaderBord.ldr is damaged. Reset to default leader bord"); messageBox.ShowDialog(); MySerializer.SerializeXml <List <Score> >(_scores, "LeaderBord.ldr"); } } else { _scores = Score.GetDeffaultScoreList(); } }
private void LoadSettings() { if (File.Exists($"config.cfg")) { try { _config = MySerializer.DeserializeXml <Config>("config.cfg"); } catch (InvalidOperationException) { _config.SetDeffault(); CustomMessageBox messageBox = new CustomMessageBox("File config.cfg is damaged. Reset to default settings"); messageBox.ShowDialog(); MySerializer.SerializeXml <Config>(_config, "config.cfg"); } } else { _config.SetDeffault(); } }