From d6a57da73fa0b16d619bd3b085626f7bf09c8d89 Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Mon, 6 May 2013 23:38:59 +0200 Subject: [PATCH] some reconstructions, there is still a lot to do --- Vocaluxe/Base/CConfig.cs | 2 +- Vocaluxe/Base/CProfiles.cs | 24 ++++++++++++------------ Vocaluxe/Screens/CScreenNames.cs | 10 +++++----- VocaluxeLib/Profile/CAvatar.cs | 14 ++++++++++---- VocaluxeLib/Profile/CProfile.cs | 2 +- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index 061664a2..03eb827d 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -807,7 +807,7 @@ namespace Vocaluxe.Base continue; for (int i = 0; i < CProfiles.Profiles.Length; i++) { - if (Path.GetFileName(CProfiles.Profiles[i].ProfileFile) == Players[j] && CProfiles.Profiles[i].Active == EOffOn.TR_CONFIG_ON) + if (Path.GetFileName(CProfiles.Profiles[i].FileName) == Players[j] && CProfiles.Profiles[i].Active == EOffOn.TR_CONFIG_ON) { //Update Game-infos with player CGame.Players[j].ProfileID = i; diff --git a/Vocaluxe/Base/CProfiles.cs b/Vocaluxe/Base/CProfiles.cs index 983791d2..448a378e 100644 --- a/Vocaluxe/Base/CProfiles.cs +++ b/Vocaluxe/Base/CProfiles.cs @@ -83,10 +83,10 @@ namespace Vocaluxe.Base Avatar = new CAvatar(-1), GuestProfile = EOffOn.TR_CONFIG_OFF, Active = EOffOn.TR_CONFIG_ON, - ProfileFile = fileName != "" ? Path.Combine(CSettings.FolderProfiles, fileName) : String.Empty + FileName = fileName != "" ? Path.Combine(CSettings.FolderProfiles, fileName) : String.Empty }; - if (File.Exists(profile.ProfileFile)) + if (File.Exists(profile.FileName)) return -1; _Profiles.Add(profile); @@ -256,20 +256,20 @@ namespace Vocaluxe.Base { if (!ICProfileIDValid(profileID)) return; - if (_Profiles[profileID].ProfileFile == "") + if (_Profiles[profileID].FileName == "") return; try { //Check if profile saved in config for (int i = 0; i < CConfig.Players.Length; i++) { - if (CConfig.Players[i] == _Profiles[profileID].ProfileFile) + if (CConfig.Players[i] == _Profiles[profileID].FileName) { CConfig.Players[i] = string.Empty; CConfig.SaveConfig(); } } - File.Delete(_Profiles[profileID].ProfileFile); + File.Delete(_Profiles[profileID].FileName); _Profiles.RemoveAt(profileID); //Check if profile is selected in game for (int i = 0; i < CGame.Players.Length; i++) @@ -282,7 +282,7 @@ namespace Vocaluxe.Base } catch (Exception) { - CLog.LogError("Can't delete Profile File " + _Profiles[profileID].ProfileFile + ".xml"); + CLog.LogError("Can't delete Profile File " + _Profiles[profileID].FileName + ".xml"); } } @@ -312,7 +312,7 @@ namespace Vocaluxe.Base if (!ICProfileIDValid(profileID)) return; - if (_Profiles[profileID].ProfileFile == "") + if (_Profiles[profileID].FileName == "") { string filename = string.Empty; foreach (char chr in _Profiles[profileID].PlayerName) @@ -333,18 +333,18 @@ namespace Vocaluxe.Base } CProfile profile = _Profiles[profileID]; - profile.ProfileFile = Path.Combine(CSettings.FolderProfiles, filename + ".xml"); + profile.FileName = Path.Combine(CSettings.FolderProfiles, filename + ".xml"); _Profiles[profileID] = profile; } XmlWriter writer; try { - writer = XmlWriter.Create(_Profiles[profileID].ProfileFile, _Settings); + writer = XmlWriter.Create(_Profiles[profileID].FileName, _Settings); } catch (Exception e) { - CLog.LogError("Error creating/opening Profile File " + _Profiles[profileID].ProfileFile + ": " + e.Message); + CLog.LogError("Error creating/opening Profile File " + _Profiles[profileID].FileName + ": " + e.Message); return; } try @@ -373,9 +373,9 @@ namespace Vocaluxe.Base private static void _LoadProfile(string fileName) { - CProfile profile = new CProfile {ProfileFile = Path.Combine(CSettings.FolderProfiles, fileName)}; + CProfile profile = new CProfile {FileName = Path.Combine(CSettings.FolderProfiles, fileName)}; - CXMLReader xmlReader = CXMLReader.OpenFile(profile.ProfileFile); + CXMLReader xmlReader = CXMLReader.OpenFile(profile.FileName); if (xmlReader == null) return; diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs index d96476d1..28efb832 100644 --- a/Vocaluxe/Screens/CScreenNames.cs +++ b/Vocaluxe/Screens/CScreenNames.cs @@ -170,7 +170,7 @@ namespace Vocaluxe.Screens //Update Game-infos with new player CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = _SelectedPlayerNr; //Update config for default players. - CConfig.Players[_SelectingFastPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile; + CConfig.Players[_SelectingFastPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].FileName; CConfig.SaveConfig(); //Update texture and name _Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture; @@ -418,7 +418,7 @@ namespace Vocaluxe.Screens //Update Game-infos with new player CGame.Players[_SelectingSwitchNr].ProfileID = CGame.Players[i].ProfileID; //Update config for default players. - CConfig.Players[_SelectingSwitchNr] = CProfiles.Profiles[i].ProfileFile; + CConfig.Players[_SelectingSwitchNr] = CProfiles.Profiles[i].FileName; //Update texture and name _Statics[_StaticPlayerAvatar[_SelectingSwitchNr]].Texture = CProfiles.Profiles[CGame.Players[i].ProfileID].Avatar.Texture; _Texts[_TextPlayer[_SelectingSwitchNr]].Text = CProfiles.Profiles[CGame.Players[i].ProfileID].PlayerName; @@ -436,7 +436,7 @@ namespace Vocaluxe.Screens //Update Game-infos with new player CGame.Players[i].ProfileID = _SelectedPlayerNr; //Update config for default players. - CConfig.Players[i] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile; + CConfig.Players[i] = CProfiles.Profiles[_SelectedPlayerNr].FileName; CConfig.SaveConfig(); //Update texture and name _Statics[_StaticPlayerAvatar[i]].Texture = _ChooseAvatarStatic.Texture; @@ -476,7 +476,7 @@ namespace Vocaluxe.Screens //Update Game-infos with new player CGame.Players[_SelectingFastPlayerNr - 1].ProfileID = _SelectedPlayerNr; //Update config for default players. - CConfig.Players[_SelectingFastPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile; + CConfig.Players[_SelectingFastPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].FileName; CConfig.SaveConfig(); //Update texture and name _Statics[_StaticPlayerAvatar[_SelectingFastPlayerNr - 1]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture; @@ -519,7 +519,7 @@ namespace Vocaluxe.Screens //Update Game-infos with new player CGame.Players[i].ProfileID = _SelectedPlayerNr; //Update config for default players. - CConfig.Players[i] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile; + CConfig.Players[i] = CProfiles.Profiles[_SelectedPlayerNr].FileName; CConfig.SaveConfig(); //Update texture and name _Statics[_StaticPlayerAvatar[i]].Texture = CProfiles.Profiles[_SelectedPlayerNr].Avatar.Texture; diff --git a/VocaluxeLib/Profile/CAvatar.cs b/VocaluxeLib/Profile/CAvatar.cs index a7f71f82..ae8fc93e 100644 --- a/VocaluxeLib/Profile/CAvatar.cs +++ b/VocaluxeLib/Profile/CAvatar.cs @@ -7,13 +7,19 @@ namespace VocaluxeLib.Profile { public class CAvatar { - public string FileName; + private int _ID; + + public int ID + { + get { return _ID; } + } + + public string FileName { get; set; } public STexture Texture; - // ReSharper disable UnusedParameter.Local - public CAvatar(int dummy) - // ReSharper restore UnusedParameter.Local + public CAvatar(int ID) { + _ID = ID; FileName = String.Empty; Texture = new STexture(-1); } diff --git a/VocaluxeLib/Profile/CProfile.cs b/VocaluxeLib/Profile/CProfile.cs index cfcd80ce..a388eb01 100644 --- a/VocaluxeLib/Profile/CProfile.cs +++ b/VocaluxeLib/Profile/CProfile.cs @@ -8,7 +8,7 @@ namespace VocaluxeLib.Profile public class CProfile { public string PlayerName; - public string ProfileFile; + public string FileName; public EGameDifficulty Difficulty; public CAvatar Avatar;