some more reconstructions on avatars

This commit is contained in:
Alexander Eckart committed 2013-05-07 00:23:44 +02:00
1 parent d6a57da73f
commit bde99ff2aa
7 files changed
+413 -334

No files matched your search

+5
View File
@@ -374,6 +374,11 @@ namespace Vocaluxe.Base
CDraw.DrawTextureReflection(texture, rect, color, bounds, reflectionSpace, reflectionHeight);
}
public STexture AddTexture(string fileName)
{
return CDraw.AddTexture(fileName);
}
public void RemoveTexture(ref STexture texture)
{
CDraw.RemoveTexture(ref texture);
+4 -62
View File
@@ -30,7 +30,6 @@ namespace Vocaluxe.Base
{
static class CProfiles
{
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings();
private static List<CProfile> _Profiles;
private static readonly List<CAvatar> _Avatars = new List<CAvatar>();
@@ -56,11 +55,6 @@ namespace Vocaluxe.Base
public static void Init()
{
_Settings.Indent = true;
_Settings.Encoding = Encoding.UTF8;
_Settings.ConformanceLevel = ConformanceLevel.Document;
LoadAvatars();
LoadProfiles();
}
@@ -102,6 +96,7 @@ namespace Vocaluxe.Base
public static void LoadProfiles()
{
LoadAvatars();
_Profiles = new List<CProfile>();
List<string> files = new List<string>();
files.AddRange(CHelper.ListFiles(CSettings.FolderProfiles, "*.xml", true, true));
@@ -337,70 +332,17 @@ namespace Vocaluxe.Base
_Profiles[profileID] = profile;
}
XmlWriter writer;
try
{
writer = XmlWriter.Create(_Profiles[profileID].FileName, _Settings);
}
catch (Exception e)
{
CLog.LogError("Error creating/opening Profile File " + _Profiles[profileID].FileName + ": " + e.Message);
return;
}
try
{
writer.WriteStartDocument();
writer.WriteStartElement("root");
writer.WriteStartElement("Info");
writer.WriteElementString("PlayerName", _Profiles[profileID].PlayerName);
writer.WriteElementString("Difficulty", Enum.GetName(typeof(EGameDifficulty), _Profiles[profileID].Difficulty));
writer.WriteElementString("Avatar", _Profiles[profileID].Avatar.FileName);
writer.WriteElementString("GuestProfile", Enum.GetName(typeof(EOffOn), _Profiles[profileID].GuestProfile));
writer.WriteElementString("Active", Enum.GetName(typeof(EOffOn), _Profiles[profileID].Active));
writer.WriteEndElement();
writer.WriteEndElement(); //end of root
writer.WriteEndDocument();
writer.Flush();
}
finally
{
writer.Close();
}
_Profiles[profileID].SaveProfile();
}
private static void _LoadProfile(string fileName)
{
CProfile profile = new CProfile {FileName = Path.Combine(CSettings.FolderProfiles, fileName)};
CXMLReader xmlReader = CXMLReader.OpenFile(profile.FileName);
if (xmlReader == null)
return;
string value = String.Empty;
if (xmlReader.GetValue("//root/Info/PlayerName", out value, value))
if (profile.LoadProfile())
{
profile.PlayerName = value;
profile.Difficulty = EGameDifficulty.TR_CONFIG_EASY;
xmlReader.TryGetEnumValue("//root/Info/Difficulty", ref profile.Difficulty);
profile.Avatar = new CAvatar(-1);
if (xmlReader.GetValue("//root/Info/Avatar", out value, value))
profile.Avatar = _GetAvatar(value);
profile.GuestProfile = EOffOn.TR_CONFIG_OFF;
xmlReader.TryGetEnumValue("//root/Info/GuestProfile", ref profile.GuestProfile);
profile.Active = EOffOn.TR_CONFIG_ON;
xmlReader.TryGetEnumValue("//root/Info/Active", ref profile.Active);
profile.Avatar = _GetAvatar(profile.AvatarFileName);
_Profiles.Add(profile);
}
else
CLog.LogError("Can't find PlayerName in Profile File: " + fileName);
}
#endregion private methods
}
+286
View File
@@ -0,0 +1,286 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Linq;
using System.Text;
using VocaluxeLib.Game;
using VocaluxeLib.Menu;
using VocaluxeLib.PartyModes;
using VocaluxeLib.Profile;
using VocaluxeLib.Songs;
namespace VocaluxeLib
{
public interface IMenuParty
{
void SetPartyModeID(int partyModeID);
int GetPartyModeID();
void AssingPartyMode(IPartyMode partyMode);
void DataToScreen(Object data);
}
public interface IConfig
{
void SetBackgroundMusicVolume(int newVolume);
int GetBackgroundMusicVolume();
int GetPreviewMusicVolume();
EOffOn GetVideosToBackground();
EOffOn GetVideoBackgrounds();
EOffOn GetVideoPreview();
ESongMenu GetSongMenuType();
EOffOn GetDrawNoteLines();
EOffOn GetDrawToneHelper();
int GetCoverSize();
IEnumerable<string> GetSongFolder();
ESongSorting GetSongSorting();
EOffOn GetTabs();
EOffOn GetIgnoreArticles();
bool IsMicConfigured(int playerNr);
int GetMaxNumMics();
}
public interface ISettings
{
int GetRenderW();
int GetRenderH();
bool IsTabNavigation();
float GetZFar();
float GetZNear();
EGameState GetGameState();
int GetToneMin();
int GetToneMax();
int GetNumNoteLines();
int GetMaxNumPlayer();
float GetDefaultMedleyFadeInTime();
float GetDefaultMedleyFadeOutTime();
int GetMedleyMinSeriesLength();
float GetMedleyMinDuration();
}
public interface ITheme
{
string GetThemeScreensPath(int partyModeID);
int GetSkinIndex(int partyModeID);
STexture GetSkinTexture(string textureName, int partyModeID);
STexture GetSkinVideoTexture(string videoName, int partyModeID);
void SkinVideoResume(string videoName, int partyModeID);
void SkinVideoPause(string videoName, int partyModeID);
SColorF GetColor(string colorName, int partyModeID);
bool GetColor(string colorName, int skinIndex, out SColorF color);
SColorF GetPlayerColor(int playerNr);
void UnloadSkins();
void ListSkins();
void LoadSkins();
void LoadTheme();
}
public interface IBackgroundMusic
{
bool IsDisabled();
bool IsPlaying();
bool SongHasVideo();
bool VideoEnabled();
void SetStatus(bool disabled);
void Next();
void Previous();
void Pause();
void Play();
void ApplyVolume();
STexture GetVideoTexture();
}
public interface IDrawing
{
RectangleF GetTextBounds(CText text);
void DrawTexture(STexture texture, SRectF rect);
void DrawTexture(STexture texture, SRectF rect, SColorF color);
void DrawTexture(STexture texture, SRectF rect, SColorF color, SRectF bounds);
void DrawTexture(STexture texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored);
void DrawTextureReflection(STexture texture, SRectF rect, SColorF color, SRectF bounds, float reflectionSpace, float reflectionHeight);
STexture AddTexture(string fileName);
void RemoveTexture(ref STexture texture);
void DrawColor(SColorF color, SRectF rect);
void DrawColorReflection(SColorF color, SRectF rect, float space, float height);
}
public interface IGraphics
{
void ReloadTheme();
void SaveTheme();
void FadeTo(EScreens nextScreen);
float GetGlobalAlpha();
}
public interface ILog
{
void LogError(string errorText);
}
public interface IFonts
{
void SetFont(string fontName);
void SetStyle(EStyle fontStyle);
RectangleF GetTextBounds(CText text, float textHeight);
void DrawText(string text, float textHeight, float x, float y, float z, SColorF color);
void DrawTextReflection(string text, float textHeight, float x, float y, float z, SColorF color, float reflectionSpace, float reflectionHeight);
void DrawText(string text, float textHeight, float x, float y, float z, SColorF color, float begin, float end);
}
public interface ILanguage
{
string Translate(string keyWord);
string Translate(string keyWord, int partyModeID);
bool TranslationExists(string keyWord);
}
public interface IGame
{
int GetNumPlayer();
void SetNumPlayer(int numPlayer);
SPlayer[] GetPlayers();
CPoints GetPoints();
float GetMidBeatD();
int GetCurrentBeatD();
int GetRandom(int max);
double GetRandomDouble();
float GetTimeFromBeats(float beat, float bpm);
void AddSong(int songID, EGameMode gameMode);
void Reset();
void ClearSongs();
int GetNumSongs();
}
public interface IRecording
{
int GetToneAbs(int playerNr);
}
public interface IProfiles
{
CProfile[] GetProfiles();
EGameDifficulty GetDifficulty(int profileID);
string GetPlayerName(int profileID, int playerNum = 0);
}
public interface ISongs
{
int GetNumSongs();
int GetNumSongsVisible();
int GetNumCategories();
int NumSongsInCategory(int categoryIndex);
bool IsInCategory();
int GetCurrentCategoryIndex();
EOffOn GetTabs();
string GetSearchFilter();
void SetCategory(int categoryIndex);
void UpdateRandomSongList();
CSong GetVisibleSong(int visibleIndex);
CSong GetSongByID(int songID);
ReadOnlyCollection<CSong> GetVisibleSongs();
CCategory GetCategory(int index);
void AddPartySongSung(int songID);
void ResetSongSung(int catIndex = -1);
void SortSongs(ESongSorting sorting, EOffOn tabs, EOffOn ignoreArticles, String searchString, EDuetOptions duetOptions);
void NextCategory();
void PrevCategory();
}
public interface IVideo
{
int Load(string videoFileName);
bool Skip(int videoStream, float startPosition, float videoGap);
bool GetFrame(int videoStream, ref STexture videoTexture, float time, out float videoTime);
bool IsFinished(int videoStream);
bool Close(int videoStream);
}
public interface ISound
{
int Load(string soundFile, bool prescan);
void SetPosition(int soundStream, float newPosition);
void Play(int soundStream);
void Fade(int soundStream, float targetVolume, float duration);
bool IsFinished(int soundStream);
float GetPosition(int soundStream);
float GetLength(int soundStream);
void FadeAndStop(int soundStream, float targetVolume, float duration);
void SetStreamVolume(int soundStream, float volume);
void SetStreamVolumeMax(int soundStream, float maxVolume);
}
public interface ICover
{
STexture GetNoCover();
}
public interface IDataBase
{
bool GetCover(string fileName, ref STexture texture, int coverSize);
}
public interface IControllers
{
void SetRumble(float duration);
}
public interface IPlaylist
{
string GetPlaylistName(int playlistID);
List<string> GetPlaylistNames();
void SetPlaylistName(int playlistID, string name);
void DeletePlaylist(int playlistID);
void SavePlaylist(int playlistID);
int GetNumPlaylists();
void AddPlaylistSong(int playlistID, int songID);
void AddPlaylistSong(int playlistID, int songID, EGameMode gameMode);
void InsertPlaylistSong(int playlistID, int positionIndex, int songID, EGameMode gameMode);
void MovePlaylistSong(int playlistID, int sourceIndex, int destIndex);
void MovePlaylistSongDown(int playlistID, int songIndex);
void MovePlaylistSongUp(int playlistID, int songIndex);
void DeletePlaylistSong(int playlistID, int songIndex);
int GetPlaylistSongCount(int playlistID);
CPlaylistSong GetPlaylistSong(int playlistID, int songIndex);
}
}
-270
View File
@@ -63,274 +63,4 @@ namespace VocaluxeLib.Menu
void ProcessMouseClick(int x, int y);
void ProcessMouseMove(int x, int y);
}
public interface IMenuParty
{
void SetPartyModeID(int partyModeID);
int GetPartyModeID();
void AssingPartyMode(IPartyMode partyMode);
void DataToScreen(Object data);
}
public interface IConfig
{
void SetBackgroundMusicVolume(int newVolume);
int GetBackgroundMusicVolume();
int GetPreviewMusicVolume();
EOffOn GetVideosToBackground();
EOffOn GetVideoBackgrounds();
EOffOn GetVideoPreview();
ESongMenu GetSongMenuType();
EOffOn GetDrawNoteLines();
EOffOn GetDrawToneHelper();
int GetCoverSize();
IEnumerable<string> GetSongFolder();
ESongSorting GetSongSorting();
EOffOn GetTabs();
EOffOn GetIgnoreArticles();
bool IsMicConfigured(int playerNr);
int GetMaxNumMics();
}
public interface ISettings
{
int GetRenderW();
int GetRenderH();
bool IsTabNavigation();
float GetZFar();
float GetZNear();
EGameState GetGameState();
int GetToneMin();
int GetToneMax();
int GetNumNoteLines();
int GetMaxNumPlayer();
float GetDefaultMedleyFadeInTime();
float GetDefaultMedleyFadeOutTime();
int GetMedleyMinSeriesLength();
float GetMedleyMinDuration();
}
public interface ITheme
{
string GetThemeScreensPath(int partyModeID);
int GetSkinIndex(int partyModeID);
STexture GetSkinTexture(string textureName, int partyModeID);
STexture GetSkinVideoTexture(string videoName, int partyModeID);
void SkinVideoResume(string videoName, int partyModeID);
void SkinVideoPause(string videoName, int partyModeID);
SColorF GetColor(string colorName, int partyModeID);
bool GetColor(string colorName, int skinIndex, out SColorF color);
SColorF GetPlayerColor(int playerNr);
void UnloadSkins();
void ListSkins();
void LoadSkins();
void LoadTheme();
}
public interface IBackgroundMusic
{
bool IsDisabled();
bool IsPlaying();
bool SongHasVideo();
bool VideoEnabled();
void SetStatus(bool disabled);
void Next();
void Previous();
void Pause();
void Play();
void ApplyVolume();
STexture GetVideoTexture();
}
public interface IDrawing
{
RectangleF GetTextBounds(CText text);
void DrawTexture(STexture texture, SRectF rect);
void DrawTexture(STexture texture, SRectF rect, SColorF color);
void DrawTexture(STexture texture, SRectF rect, SColorF color, SRectF bounds);
void DrawTexture(STexture texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored);
void DrawTextureReflection(STexture texture, SRectF rect, SColorF color, SRectF bounds, float reflectionSpace, float reflectionHeight);
void RemoveTexture(ref STexture texture);
void DrawColor(SColorF color, SRectF rect);
void DrawColorReflection(SColorF color, SRectF rect, float space, float height);
}
public interface IGraphics
{
void ReloadTheme();
void SaveTheme();
void FadeTo(EScreens nextScreen);
float GetGlobalAlpha();
}
public interface ILog
{
void LogError(string errorText);
}
public interface IFonts
{
void SetFont(string fontName);
void SetStyle(EStyle fontStyle);
RectangleF GetTextBounds(CText text, float textHeight);
void DrawText(string text, float textHeight, float x, float y, float z, SColorF color);
void DrawTextReflection(string text, float textHeight, float x, float y, float z, SColorF color, float reflectionSpace, float reflectionHeight);
void DrawText(string text, float textHeight, float x, float y, float z, SColorF color, float begin, float end);
}
public interface ILanguage
{
string Translate(string keyWord);
string Translate(string keyWord, int partyModeID);
bool TranslationExists(string keyWord);
}
public interface IGame
{
int GetNumPlayer();
void SetNumPlayer(int numPlayer);
SPlayer[] GetPlayers();
CPoints GetPoints();
float GetMidBeatD();
int GetCurrentBeatD();
int GetRandom(int max);
double GetRandomDouble();
float GetTimeFromBeats(float beat, float bpm);
void AddSong(int songID, EGameMode gameMode);
void Reset();
void ClearSongs();
int GetNumSongs();
}
public interface IRecording
{
int GetToneAbs(int playerNr);
}
public interface IProfiles
{
CProfile[] GetProfiles();
EGameDifficulty GetDifficulty(int profileID);
string GetPlayerName(int profileID, int playerNum = 0);
}
public interface ISongs
{
int GetNumSongs();
int GetNumSongsVisible();
int GetNumCategories();
int NumSongsInCategory(int categoryIndex);
bool IsInCategory();
int GetCurrentCategoryIndex();
EOffOn GetTabs();
string GetSearchFilter();
void SetCategory(int categoryIndex);
void UpdateRandomSongList();
CSong GetVisibleSong(int visibleIndex);
CSong GetSongByID(int songID);
ReadOnlyCollection<CSong> GetVisibleSongs();
CCategory GetCategory(int index);
void AddPartySongSung(int songID);
void ResetSongSung(int catIndex = -1);
void SortSongs(ESongSorting sorting, EOffOn tabs, EOffOn ignoreArticles, String searchString, EDuetOptions duetOptions);
void NextCategory();
void PrevCategory();
}
public interface IVideo
{
int Load(string videoFileName);
bool Skip(int videoStream, float startPosition, float videoGap);
bool GetFrame(int videoStream, ref STexture videoTexture, float time, out float videoTime);
bool IsFinished(int videoStream);
bool Close(int videoStream);
}
public interface ISound
{
int Load(string soundFile, bool prescan);
void SetPosition(int soundStream, float newPosition);
void Play(int soundStream);
void Fade(int soundStream, float targetVolume, float duration);
bool IsFinished(int soundStream);
float GetPosition(int soundStream);
float GetLength(int soundStream);
void FadeAndStop(int soundStream, float targetVolume, float duration);
void SetStreamVolume(int soundStream, float volume);
void SetStreamVolumeMax(int soundStream, float maxVolume);
}
public interface ICover
{
STexture GetNoCover();
}
public interface IDataBase
{
bool GetCover(string fileName, ref STexture texture, int coverSize);
}
public interface IControllers
{
void SetRumble(float duration);
}
public interface IPlaylist
{
string GetPlaylistName(int playlistID);
List<string> GetPlaylistNames();
void SetPlaylistName(int playlistID, string name);
void DeletePlaylist(int playlistID);
void SavePlaylist(int playlistID);
int GetNumPlaylists();
void AddPlaylistSong(int playlistID, int songID);
void AddPlaylistSong(int playlistID, int songID, EGameMode gameMode);
void InsertPlaylistSong(int playlistID, int positionIndex, int songID, EGameMode gameMode);
void MovePlaylistSong(int playlistID, int sourceIndex, int destIndex);
void MovePlaylistSongDown(int playlistID, int songIndex);
void MovePlaylistSongUp(int playlistID, int songIndex);
void DeletePlaylistSong(int playlistID, int songIndex);
int GetPlaylistSongCount(int playlistID);
CPlaylistSong GetPlaylistSong(int playlistID, int songIndex);
}
}
+16 -1
View File
@@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using VocaluxeLib.Menu;
namespace VocaluxeLib.Profile
{
public class CAvatar
@@ -14,7 +16,7 @@ namespace VocaluxeLib.Profile
get { return _ID; }
}
public string FileName { get; set; }
public string FileName;
public STexture Texture;
public CAvatar(int ID)
@@ -23,5 +25,18 @@ namespace VocaluxeLib.Profile
FileName = String.Empty;
Texture = new STexture(-1);
}
public void LoadFromFile(string NewFileName)
{
FileName = NewFileName;
CBase.Drawing.RemoveTexture(ref Texture);
Texture = CBase.Drawing.AddTexture(FileName);
}
public void Reload()
{
CBase.Drawing.RemoveTexture(ref Texture);
Texture = CBase.Drawing.AddTexture(FileName);
}
}
}
+101 -1
View File
@@ -1,18 +1,118 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
namespace VocaluxeLib.Profile
{
public class CProfile
{
private static readonly XmlWriterSettings _Settings = new XmlWriterSettings()
{
Indent = true,
Encoding = Encoding.UTF8,
ConformanceLevel = ConformanceLevel.Document
};
private int _ID;
private int _AvatarID;
public int ID
{
get { return _ID; }
}
public string PlayerName;
public string FileName;
public string AvatarFileName;
public EGameDifficulty Difficulty;
public CAvatar Avatar;
public CAvatar Avatar; //should be removed! use avatar id
public EOffOn GuestProfile;
public EOffOn Active;
public CProfile()
{
PlayerName = String.Empty;
Difficulty = EGameDifficulty.TR_CONFIG_EASY;
Avatar = new CAvatar(-1);
GuestProfile = EOffOn.TR_CONFIG_OFF;
Active = EOffOn.TR_CONFIG_ON;
AvatarFileName = String.Empty;
FileName = String.Empty;
}
public bool LoadProfile()
{
return LoadProfile(FileName);
}
public bool LoadProfile(string NewFileName)
{
FileName = NewFileName;
CXMLReader xmlReader = CXMLReader.OpenFile(FileName);
if (xmlReader == null)
return false;
string value = String.Empty;
if (xmlReader.GetValue("//root/Info/PlayerName", out value, value))
{
PlayerName = value;
xmlReader.TryGetEnumValue("//root/Info/Difficulty", ref Difficulty);
xmlReader.GetValue("//root/Info/Avatar", out AvatarFileName, String.Empty);
xmlReader.TryGetEnumValue("//root/Info/GuestProfile", ref GuestProfile);
xmlReader.TryGetEnumValue("//root/Info/Active", ref Active);
return true;
}
CBase.Log.LogError("Can't find PlayerName in Profile File: " + FileName);
return false;
}
public void SaveProfile()
{
if (FileName == String.Empty)
return;
XmlWriter writer;
try
{
writer = XmlWriter.Create(FileName, _Settings);
}
catch (Exception e)
{
CBase.Log.LogError("Error creating/opening Profile File " + FileName + ": " + e.Message);
return;
}
try
{
writer.WriteStartDocument();
writer.WriteStartElement("root");
writer.WriteStartElement("Info");
writer.WriteElementString("PlayerName", PlayerName);
writer.WriteElementString("Difficulty", Enum.GetName(typeof(EGameDifficulty), Difficulty));
writer.WriteElementString("Avatar", Avatar.FileName);
writer.WriteElementString("GuestProfile", Enum.GetName(typeof(EOffOn), GuestProfile));
writer.WriteElementString("Active", Enum.GetName(typeof(EOffOn), Active));
writer.WriteEndElement();
writer.WriteEndElement(); //end of root
writer.WriteEndDocument();
writer.Flush();
}
finally
{
writer.Close();
}
}
}
}
+1
View File
@@ -111,6 +111,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="IBasic.cs" />
<Compile Include="Menu\CBackground.cs" />
<Compile Include="CBasic.cs" />
<Compile Include="Menu\CButton.cs" />