From aeaa38cf2293cde436df3de27458fd3d56e7b6eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Thu, 18 Apr 2013 13:22:10 +0200 Subject: [PATCH] Improved handling of adding new profiles. --- Vocaluxe/Base/CProfiles.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Vocaluxe/Base/CProfiles.cs b/Vocaluxe/Base/CProfiles.cs index fe80eafa..93623d5f 100644 --- a/Vocaluxe/Base/CProfiles.cs +++ b/Vocaluxe/Base/CProfiles.cs @@ -79,6 +79,9 @@ namespace Vocaluxe.Base public static void LoadProfiles() { + List _OldProfiles = null; + if (_Profiles != null) + _OldProfiles = _Profiles; _Profiles = new List(); List files = new List(); files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.xml", true, true)); @@ -87,6 +90,28 @@ namespace Vocaluxe.Base _LoadProfile(file); _SortProfilesByName(); + + //Find profile-id if new profile is created + if (_OldProfiles != null) + { + int _NewProfileId = -1; + for (int i = 0; i < _OldProfiles.Count; i++) + { + if (_Profiles[i].ProfileFile != _OldProfiles[i].ProfileFile) + { + _NewProfileId = i; + break; + } + } + if (_NewProfileId != -1) + { + for (int i = 0; i < CGame.Player.Length; i++) + { + if (CGame.Player[i].ProfileID >= _NewProfileId) + CGame.Player[i].ProfileID++; + } + } + } } public static void LoadAvatars()