reconstructed CProfiles (preparing for async profile adding)

This commit is contained in:
Alexander Eckart committed 2013-05-07 16:56:23 +02:00
1 parent 967e2eb4b1
commit 19339c6888
11 files changed
+353 -225

No files matched your search

+2
View File
@@ -70,6 +70,8 @@ namespace VocaluxeLib
float GetDefaultMedleyFadeOutTime();
int GetMedleyMinSeriesLength();
float GetMedleyMinDuration();
string GetFolderProfiles();
}
public interface ITheme
+7 -3
View File
@@ -22,6 +22,8 @@ using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml;
using VocaluxeLib.Profile;
namespace VocaluxeLib.Menu
{
struct SThemeNameSelection
@@ -497,16 +499,18 @@ namespace VocaluxeLib.Menu
private void _UpdateVisibleProfiles()
{
_VisibleProfiles.Clear();
for (int i = 0; i < CBase.Profiles.GetProfiles().Length; i++)
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < profiles.Length; i++)
{
bool visible = CBase.Profiles.GetProfiles()[i].Active == EOffOn.TR_CONFIG_ON;
bool visible = profiles[i].Active == EOffOn.TR_CONFIG_ON;
if (visible)
{
//Show profile only if active
for (int p = 0; p < CBase.Game.GetNumPlayer(); p++)
{
//Don't show profile if is selected, but if selected and guest
if (CBase.Game.GetPlayers()[p].ProfileID == i && CBase.Profiles.GetProfiles()[i].GuestProfile == EOffOn.TR_CONFIG_OFF)
if (CBase.Game.GetPlayers()[p].ProfileID == profiles[i].ID && profiles[i].GuestProfile == EOffOn.TR_CONFIG_OFF)
visible = false;
}
}
+9 -9
View File
@@ -9,28 +9,23 @@ namespace VocaluxeLib.Profile
{
public class CAvatar
{
private int _ID;
public int ID
{
get { return _ID; }
}
public int ID;
public string FileName;
public STexture Texture;
public CAvatar(int ID)
{
_ID = ID;
this.ID = ID;
FileName = String.Empty;
Texture = new STexture(-1);
}
public void LoadFromFile(string NewFileName)
public bool LoadFromFile(string NewFileName)
{
FileName = NewFileName;
CBase.Drawing.RemoveTexture(ref Texture);
Texture = CBase.Drawing.AddTexture(FileName);
return (Texture.Index != -1);
}
public void Reload()
@@ -38,5 +33,10 @@ namespace VocaluxeLib.Profile
CBase.Drawing.RemoveTexture(ref Texture);
Texture = CBase.Drawing.AddTexture(FileName);
}
public void Unload()
{
CBase.Drawing.RemoveTexture(ref Texture);
}
}
}
+27 -10
View File
@@ -16,20 +16,14 @@ namespace VocaluxeLib.Profile
ConformanceLevel = ConformanceLevel.Document
};
private int _ID;
private int _AvatarID;
public int ID
{
get { return _ID; }
}
public int ID;
public string PlayerName;
public string FileName;
public string AvatarFileName;
public EGameDifficulty Difficulty;
public CAvatar Avatar; //should be removed! use avatar id
public CAvatar Avatar;
public EOffOn GuestProfile;
public EOffOn Active;
@@ -78,6 +72,29 @@ namespace VocaluxeLib.Profile
public void SaveProfile()
{
if (FileName == String.Empty)
{
string filename = string.Empty;
foreach (char chr in PlayerName)
{
if (char.IsLetter(chr))
filename += chr.ToString();
}
if (filename == "")
filename = "1";
int i = 0;
while (File.Exists(Path.Combine(CBase.Settings.GetFolderProfiles(), filename + ".xml")))
{
i++;
if (!File.Exists(Path.Combine(CBase.Settings.GetFolderProfiles(), filename + i + ".xml")))
filename += i;
}
FileName = Path.Combine(Environment.CurrentDirectory, CBase.Settings.GetFolderProfiles(), filename + ".xml");
}
if (FileName == String.Empty)
return;
@@ -99,7 +116,7 @@ namespace VocaluxeLib.Profile
writer.WriteStartElement("Info");
writer.WriteElementString("PlayerName", PlayerName);
writer.WriteElementString("Difficulty", Enum.GetName(typeof(EGameDifficulty), Difficulty));
writer.WriteElementString("Avatar", Avatar.FileName);
writer.WriteElementString("Avatar", Path.GetFileName(Avatar.FileName));
writer.WriteElementString("GuestProfile", Enum.GetName(typeof(EOffOn), GuestProfile));
writer.WriteElementString("Active", Enum.GetName(typeof(EOffOn), Active));
writer.WriteEndElement();