public static Save_Info get_save_info(int file_id, Save_File file, bool suspend) { Save_Info result = new Save_Info(); result.File_Id = file_id; result.Time = new DateTime(); //@Yeti var mostRecent = file.most_recent_save; if (mostRecent != null) { result.Time = mostRecent.time; } result.Style = file.Style; result.Map_Save_Exists = false; result.Suspend_Exists = suspend; if (file.NoData) { result.Chapter_Id = ""; result.Difficulty = file.Difficulty; } else { Save_Data data = file.most_recent_save; result.Chapter_Id = data.chapter_id; result.Difficulty = data.difficulty; //result.Chapter_Id = file.data[chapter_id][indices[index]].chapter_id; //Debug //result.Difficulty = file.data[chapter_id][indices[index]].difficulty; } result.get_save_info(file); return(result); }
public void update_progress(Save_File file) { foreach (Difficulty_Modes difficulty in Enum_Values.GetEnumValues(typeof(Difficulty_Modes))) { // Completed chapters foreach (string chapter_id in Global.data_chapters.Keys) { if (file.ContainsKey(chapter_id, difficulty)) { Completed_Chapters[(int)difficulty].Add(chapter_id); } } // Available chapters foreach (string chapter_id in Global.data_chapters.Keys) { if (!Available_Chapters.Contains(chapter_id)) { if (file.chapter_available(chapter_id)) { Available_Chapters.Add(chapter_id); } } } } // Supports Dictionary <string, int> supports = file.acquired_supports; foreach (var pair in supports) { AddSupport(pair.Key, pair.Value); } // Recruited RecruitedActors.UnionWith(file.RecruitedActors); }
public static Save_Info get_save_info(int file_id, Save_File file, Suspend_Info suspend_info, bool map_save = false, bool suspend = false) { Save_Info result = new Save_Info(); result.File_Id = file_id; result.Time = suspend_info.time; result.Style = suspend_info.style; result.Map_Save_Exists = map_save; result.Suspend_Exists = suspend; result.Chapter_Id = suspend_info.chapter_id; result.Difficulty = suspend_info.difficulty; result.get_save_info(file); return(result); }
public static Save_File read(BinaryReader reader) { Save_File result = new Save_File(); result.Style = (Mode_Styles)reader.ReadInt32(); if (!Global.LOADED_VERSION.older_than(0, 4, 3, 4)) { result.Difficulty = (Difficulty_Modes)reader.ReadInt32(); } if (!Global.LOADED_VERSION.older_than(0, 5, 7, 0)) { result.Description = reader.ReadString(); } int chapter_count = reader.ReadInt32(); if (Global.LOADED_VERSION.older_than(0, 6, 1, 0)) { var old_data = new Dictionary <string, Dictionary <Difficulty_Modes, Dictionary <string, Save_Data> > >(); if (Global.LOADED_VERSION.older_than(0, 4, 4, 0)) { for (int i = 0; i < chapter_count; i++) { string key = reader.ReadString(); Save_Data value = Save_Data.read(reader); old_data.Add(key, new Dictionary <Difficulty_Modes, Dictionary <string, Save_Data> > { { value.difficulty, new Dictionary <string, Save_Data> { { value.progression_id, value } } } }); } } else { for (int i = 0; i < chapter_count; i++) { string chapter_key = reader.ReadString(); Dictionary <Difficulty_Modes, Dictionary <string, Save_Data> > chapter = new Dictionary <Difficulty_Modes, Dictionary <string, Save_Data> >(); int count = reader.ReadInt32(); for (int j = 0; j < count; j++) { Difficulty_Modes key = (Difficulty_Modes)reader.ReadInt32(); Dictionary <string, Save_Data> value = read_chapter(reader); chapter.Add(key, value); } old_data.Add(chapter_key, chapter); } } // Select the newer save data for each chapter? result.Data = new Dictionary <string, Dictionary <string, Save_Data> >(); foreach (var pair in old_data) { result.Data.Add(pair.Key, new Dictionary <string, Save_Data>()); // Get all progression ids var progression_ids = pair.Value.SelectMany(y => y.Value.Select(x => x.Key)) .Distinct() .ToList(); foreach (string progression in progression_ids) { var chapter_dataset = pair.Value .Where(x => x.Value.ContainsKey(progression)) .Select(x => x.Value[progression]) // Find the newest .OrderByDescending(x => { if (x.difficulty != Difficulty_Modes.Normal) { } // Add 5 minutes if the save is a on hard mode, // to account for hard saving before normal int extra_minutes = x.difficulty == Difficulty_Modes.Normal ? 0 : 5; return(x.time + new TimeSpan(0, extra_minutes, 0)); }) .ToList(); if (chapter_dataset.Count > 1 && !( chapter_dataset[0].time.Date == chapter_dataset[1].time.Date && chapter_dataset[0].time.Hour == chapter_dataset[1].time.Hour && chapter_dataset[0].time.Minute == chapter_dataset[1].time.Minute)) { } result.Data[pair.Key].Add(progression, chapter_dataset.First()); } } } else { for (int i = 0; i < chapter_count; i++) { string chapter_key = reader.ReadString(); Dictionary <string, Save_Data> value = read_chapter(reader); result.Data.Add(chapter_key, value); } } return(result); }
private void get_save_info(Save_File file) { AvailableChapters = file.available_chapters(); }