/// <summary> /// Adds a profile to the profile manager. /// </summary> /// <remarks> /// Adding a profile to the profile manager assigns it a unique key. /// </remarks> /// <param name="p_mctCategory">The <see cref="IModCategory"/> being added.</param> public IModProfile AddProfile(byte[] p_bteModList, byte[] p_bteIniList, byte[] p_bteLoadOrder, string p_strGameModeId, Int32 p_intModCount, string[] p_strOptionalFiles) { string strId = GetNextId; int intNewProfile = 1; if (m_tslProfiles.Count > 0) { List <IModProfile> lstNewProfile = m_tslProfiles.Where(x => x.Name.IndexOf("Profile") == 0).ToList(); if ((lstNewProfile != null) && (lstNewProfile.Count > 0)) { List <Int32> lstID = new List <Int32>(); foreach (IModProfile imp in lstNewProfile) { string n = imp.Name.Substring(8); int i = 0; if (int.TryParse(n, out i)) { lstID.Add(Convert.ToInt32(i)); } } if (lstID.Count > 0) { intNewProfile = Enumerable.Range(1, lstID.Max() + 1).Except(lstID).Min(); } } } ModProfile mprModProfile = new ModProfile(strId, "Profile " + intNewProfile.ToString(), p_strGameModeId, (p_intModCount < 0 ? VirtualModActivator.ModCount : p_intModCount)); mprModProfile.IsDefault = true; SaveProfile(mprModProfile, p_bteModList, p_bteIniList, p_bteLoadOrder, p_strOptionalFiles); m_tslProfiles.Add(mprModProfile); m_strCurrentProfileId = mprModProfile.Id; SetDefaultProfile(mprModProfile); SaveConfig(); string strLogPath = Path.Combine(ModManager.GameMode.GameModeEnvironmentInfo.InstallInfoDirectory, "Scripted"); if (Directory.Exists(strLogPath)) { lock (m_objLock) DirectoryCopy(strLogPath, Path.Combine(m_strProfileManagerPath, mprModProfile.Id, "Scripted"), true); } return(mprModProfile); }