Merge remote-tracking branch 'refs/remotes/Vocaluxe/develop' into NamesScroll
# Conflicts: # VocaluxeLib/Menu/CNameSelection.cs
This commit is contained in:
commit
2dbc84710b
45 files changed
+765
-336
No files matched your search
@@ -219,12 +219,13 @@ namespace VocaluxeLib
|
||||
public interface IProfiles
|
||||
{
|
||||
CProfile[] GetProfiles();
|
||||
EGameDifficulty GetDifficulty(int profileID);
|
||||
string GetPlayerName(int profileID, int playerNum = 0);
|
||||
CTextureRef GetAvatar(int profileID);
|
||||
int GetNum();
|
||||
EGameDifficulty GetDifficulty(Guid profileID);
|
||||
string GetPlayerName(Guid profileID, int playerNum = 0);
|
||||
CTextureRef GetAvatar(Guid profileID);
|
||||
CAvatar GetAvatarByFilename(string fileName);
|
||||
bool IsProfileIDValid(int profileID);
|
||||
bool IsGuest(int profileID);
|
||||
bool IsProfileIDValid(Guid profileID);
|
||||
bool IsGuest(Guid profileID);
|
||||
void AddProfileChangedCallback(ProfileChangedCallback notification);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using VocaluxeLib.Draw;
|
||||
@@ -53,7 +54,7 @@ namespace VocaluxeLib.Menu
|
||||
private bool _SelectingKeyboardActive;
|
||||
private bool _SelectingFast;
|
||||
private int _SelectingFastPlayerNr;
|
||||
private int _SelectedProfileID = -1;
|
||||
private Guid _SelectedProfileID = Guid.Empty;
|
||||
|
||||
private CStatic _ChooseAvatarStatic;
|
||||
private int _OldMouseX;
|
||||
@@ -70,7 +71,7 @@ namespace VocaluxeLib.Menu
|
||||
private const string _SelectSlidePlayer = "SelectSlidePlayer";
|
||||
private const string _NameSelection = "NameSelection";
|
||||
|
||||
protected List<int>[] _TeamList;
|
||||
protected List<Guid>[] _TeamList;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
@@ -98,13 +99,13 @@ namespace VocaluxeLib.Menu
|
||||
_NumPlayer = numPlayer;
|
||||
_NumPlayerTeams = numPlayerTeams;
|
||||
|
||||
_TeamList = new List<int>[_NumTeams > 0 ? _NumTeams : 1];
|
||||
_TeamList = new List<Guid>[_NumTeams > 0 ? _NumTeams : 1];
|
||||
|
||||
if (_NumTeams != _NumPlayerTeams.Length)
|
||||
_NumPlayerTeams = new int[_NumTeams];
|
||||
|
||||
for (int i = 0; i < _TeamList.Length; i++)
|
||||
_TeamList[i] = new List<int>();
|
||||
_TeamList[i] = new List<Guid>();
|
||||
|
||||
_UpdateSlides();
|
||||
_LoadProfiles();
|
||||
@@ -113,7 +114,7 @@ namespace VocaluxeLib.Menu
|
||||
_UpdateNextButtonVisibility();
|
||||
}
|
||||
|
||||
public void SetPartyModeProfiles(List<int>[] teamProfiles)
|
||||
public void SetPartyModeProfiles(List<Guid>[] teamProfiles)
|
||||
{
|
||||
_TeamList = teamProfiles;
|
||||
_UpdateSlides();
|
||||
@@ -133,9 +134,9 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
case Keys.Enter:
|
||||
//Check, if a player is selected
|
||||
if (_NameSelections[_NameSelection].Selection > -1)
|
||||
if (_NameSelections[_NameSelection].SelectedID != Guid.Empty)
|
||||
{
|
||||
_SelectedProfileID = _NameSelections[_NameSelection].Selection;
|
||||
_SelectedProfileID = _NameSelections[_NameSelection].SelectedID;
|
||||
|
||||
if (!CBase.Profiles.IsProfileIDValid(_SelectedProfileID))
|
||||
return true;
|
||||
@@ -371,7 +372,7 @@ namespace VocaluxeLib.Menu
|
||||
base.HandleMouse(mouseEvent);
|
||||
|
||||
//Check if LeftButton is hold and Select-Mode inactive
|
||||
if (mouseEvent.LBH && _SelectedProfileID < 0 && !_SelectingFast)
|
||||
if (mouseEvent.LBH && _SelectedProfileID == Guid.Empty && !_SelectingFast)
|
||||
{
|
||||
//Save mouse-coords
|
||||
_OldMouseX = mouseEvent.X;
|
||||
@@ -380,8 +381,8 @@ namespace VocaluxeLib.Menu
|
||||
if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
|
||||
{
|
||||
//Get player-number of tile
|
||||
_SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
|
||||
if (_SelectedProfileID != -1)
|
||||
_SelectedProfileID = _NameSelections[_NameSelection].TilePlayerID(mouseEvent);
|
||||
if (_SelectedProfileID != Guid.Empty)
|
||||
{
|
||||
//Update of Drag/Drop-Texture
|
||||
CStatic selectedPlayer = _NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent);
|
||||
@@ -394,7 +395,7 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
}
|
||||
//Check if LeftButton is hold and Select-Mode active
|
||||
if (mouseEvent.LBH && _SelectedProfileID >= 0 && !_SelectingFast)
|
||||
if (mouseEvent.LBH && _SelectedProfileID != Guid.Empty && !_SelectingFast)
|
||||
{
|
||||
//Update coords for Drag/Drop-Texture
|
||||
_ChooseAvatarStatic.X += mouseEvent.X - _OldMouseX;
|
||||
@@ -403,7 +404,7 @@ namespace VocaluxeLib.Menu
|
||||
_OldMouseY = mouseEvent.Y;
|
||||
}
|
||||
// LeftButton isn't hold anymore, but Select-Mode is still active -> "Drop" of Avatar
|
||||
else if (_SelectedProfileID >= 0 && !_SelectingFast)
|
||||
else if (_SelectedProfileID != Guid.Empty && !_SelectingFast)
|
||||
{
|
||||
//Check if mouse is in drop-area
|
||||
if (CHelper.IsInBounds(_SelectSlides[_SelectSlidePlayer].Rect, mouseEvent))
|
||||
@@ -415,7 +416,7 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
|
||||
//Reset variables
|
||||
_SelectedProfileID = -1;
|
||||
_SelectedProfileID = Guid.Empty;
|
||||
_ChooseAvatarStatic.Visible = false;
|
||||
}
|
||||
if (mouseEvent.LB && _SelectingFast)
|
||||
@@ -423,8 +424,8 @@ namespace VocaluxeLib.Menu
|
||||
if (_NameSelections[_NameSelection].IsOverTile(mouseEvent))
|
||||
{
|
||||
//Get player-number of tile
|
||||
_SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
|
||||
if (_SelectedProfileID != -1)
|
||||
_SelectedProfileID = _NameSelections[_NameSelection].TilePlayerID(mouseEvent);
|
||||
if (_SelectedProfileID != Guid.Empty)
|
||||
{
|
||||
if (!CBase.Profiles.IsProfileIDValid(_SelectedProfileID))
|
||||
return true;
|
||||
@@ -473,8 +474,8 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
if (mouseEvent.LD && _NameSelections[_NameSelection].IsOverTile(mouseEvent) && !_SelectingFast)
|
||||
{
|
||||
_SelectedProfileID = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent);
|
||||
if (_SelectedProfileID > -1)
|
||||
_SelectedProfileID = _NameSelections[_NameSelection].TilePlayerID(mouseEvent);
|
||||
if (_SelectedProfileID != Guid.Empty)
|
||||
{
|
||||
if (!CBase.Profiles.IsProfileIDValid(_SelectedProfileID))
|
||||
return true;
|
||||
@@ -491,7 +492,7 @@ namespace VocaluxeLib.Menu
|
||||
if (_SelectSlides[_SelectSlidePlayer].Selected && _TeamList[_CurrentTeam].Count > _SelectSlides[_SelectSlidePlayer].Selection)
|
||||
{
|
||||
int currentSelection = _SelectSlides[_SelectSlidePlayer].Selection;
|
||||
int id = _TeamList[_CurrentTeam][currentSelection];
|
||||
Guid id = _TeamList[_CurrentTeam][currentSelection];
|
||||
_RemovePlayer(_CurrentTeam, id);
|
||||
_UpdatePlayerSlide();
|
||||
exit = false;
|
||||
@@ -575,9 +576,9 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
_NumTeams++;
|
||||
int[] numPlayerTeams = _NumPlayerTeams;
|
||||
List<int>[] teamList = _TeamList;
|
||||
List<Guid>[] teamList = _TeamList;
|
||||
_NumPlayerTeams = new int[_NumTeams];
|
||||
_TeamList = new List<int>[_NumTeams];
|
||||
_TeamList = new List<Guid>[_NumTeams];
|
||||
for (int i = 0; i < _NumPlayerTeams.Length; i++)
|
||||
{
|
||||
if (i < numPlayerTeams.Length)
|
||||
@@ -588,7 +589,7 @@ namespace VocaluxeLib.Menu
|
||||
else
|
||||
{
|
||||
_NumPlayerTeams[i] = _NumPlayer;
|
||||
_TeamList[i] = new List<int>();
|
||||
_TeamList[i] = new List<Guid>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -721,7 +722,7 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
}
|
||||
|
||||
private void _AddPlayer(int team, int profileID)
|
||||
private void _AddPlayer(int team, Guid profileID, bool updateElements=true)
|
||||
{
|
||||
if (_NumPlayerTeams[team] == _TeamList[team].Count && !_ChangePlayerNumDynamic)
|
||||
return;
|
||||
@@ -731,17 +732,20 @@ namespace VocaluxeLib.Menu
|
||||
_NameSelections[_NameSelection].UseProfile(profileID);
|
||||
_TeamList[team].Add(profileID);
|
||||
|
||||
_UpdatePlayerSlide();
|
||||
_UpdateNextButtonVisibility();
|
||||
if (updateElements)
|
||||
{
|
||||
_UpdatePlayerSlide();
|
||||
_UpdateNextButtonVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
private void _RemoveAllPlayer()
|
||||
{
|
||||
for (int t = 0; t < _TeamList.Length; t++)
|
||||
{
|
||||
List<int> ids = new List<int>();
|
||||
List<Guid> ids = new List<Guid>();
|
||||
ids.AddRange(_TeamList[t]);
|
||||
foreach (int id in ids)
|
||||
foreach (Guid id in ids)
|
||||
_RemovePlayer(t, id);
|
||||
}
|
||||
}
|
||||
@@ -750,7 +754,7 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
if (_TeamList[team].Count > index)
|
||||
{
|
||||
int id = _TeamList[team][index];
|
||||
Guid id = _TeamList[team][index];
|
||||
_TeamList[team].RemoveAt(index);
|
||||
_NameSelections[_NameSelection].RemoveUsedProfile(id);
|
||||
}
|
||||
@@ -758,7 +762,7 @@ namespace VocaluxeLib.Menu
|
||||
_UpdateNextButtonVisibility();
|
||||
}
|
||||
|
||||
private void _RemovePlayer(int team, int profileID)
|
||||
private void _RemovePlayer(int team, Guid profileID)
|
||||
{
|
||||
_TeamList[team].Remove(profileID);
|
||||
_NameSelections[_NameSelection].RemoveUsedProfile(profileID);
|
||||
@@ -773,11 +777,14 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
for (int p = 0; p < _NumPlayerTeams[t]; p++)
|
||||
{
|
||||
int profileID = _NameSelections[_NameSelection].GetRandomUnusedProfile();
|
||||
if(profileID >= 0) //only add valid profiles
|
||||
Guid profileID = _NameSelections[_NameSelection].GetRandomUnusedProfile();
|
||||
if(profileID != Guid.Empty)
|
||||
_AddPlayer(t, profileID);
|
||||
}
|
||||
}
|
||||
|
||||
_UpdatePlayerSlide();
|
||||
_UpdateButtonVisibility();
|
||||
}
|
||||
|
||||
private void _UpdateNextButtonVisibility()
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Serialization;
|
||||
@@ -59,11 +60,11 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
private class CTile
|
||||
{
|
||||
public int ProfileID;
|
||||
public Guid ProfileID;
|
||||
public readonly CStatic Avatar;
|
||||
public readonly CText Name;
|
||||
|
||||
public CTile(CStatic av, CText tex, int pID)
|
||||
public CTile(CStatic av, CText tex, Guid pID)
|
||||
{
|
||||
Avatar = av;
|
||||
Name = tex;
|
||||
@@ -95,12 +96,12 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public int Offset;
|
||||
private int _ActualSelection = -1;
|
||||
public int Selection = -1;
|
||||
public Guid SelectedID = Guid.Empty;
|
||||
|
||||
private int _Player = -1;
|
||||
|
||||
private readonly List<int> _VisibleProfiles;
|
||||
private readonly List<int> _UsedProfiles;
|
||||
private readonly List<Guid> _VisibleProfiles;
|
||||
private readonly List<Guid> _UsedProfiles;
|
||||
|
||||
private CStatic _PlayerSelector;
|
||||
|
||||
@@ -121,8 +122,8 @@ namespace VocaluxeLib.Menu
|
||||
_Theme = new SThemeNameSelection {Tiles = new SThemeNameSelectionTiles {Name = new SThemeNameSelectionName()}};
|
||||
|
||||
_Tiles = new List<CTile>();
|
||||
_VisibleProfiles = new List<int>();
|
||||
_UsedProfiles = new List<int>();
|
||||
_VisibleProfiles = new List<Guid>();
|
||||
_UsedProfiles = new List<Guid>();
|
||||
}
|
||||
|
||||
public CNameSelection(SThemeNameSelection theme, int partyModeID)
|
||||
@@ -131,8 +132,8 @@ namespace VocaluxeLib.Menu
|
||||
_Theme = theme;
|
||||
|
||||
_Tiles = new List<CTile>();
|
||||
_VisibleProfiles = new List<int>();
|
||||
_UsedProfiles = new List<int>();
|
||||
_VisibleProfiles = new List<Guid>();
|
||||
_UsedProfiles = new List<Guid>();
|
||||
|
||||
ThemeLoaded = true;
|
||||
}
|
||||
@@ -185,7 +186,7 @@ namespace VocaluxeLib.Menu
|
||||
case Keys.Right:
|
||||
if (_ActualSelection + 1 < _Tiles.Count)
|
||||
{
|
||||
if (_Tiles[_ActualSelection + 1].ProfileID != -1)
|
||||
if (_Tiles[_ActualSelection + 1].ProfileID != Guid.Empty)
|
||||
_ActualSelection++;
|
||||
}
|
||||
else
|
||||
@@ -219,7 +220,7 @@ namespace VocaluxeLib.Menu
|
||||
case Keys.Down:
|
||||
if (_ActualSelection + _Theme.Tiles.NumW < _Tiles.Count)
|
||||
{
|
||||
if (_Tiles[_ActualSelection + _Theme.Tiles.NumW].ProfileID != -1)
|
||||
if (_Tiles[_ActualSelection + _Theme.Tiles.NumW].ProfileID != Guid.Empty)
|
||||
_ActualSelection += _Theme.Tiles.NumW;
|
||||
}
|
||||
else
|
||||
@@ -227,10 +228,10 @@ namespace VocaluxeLib.Menu
|
||||
int offset = Offset;
|
||||
UpdateList(Offset + 1);
|
||||
}
|
||||
if (_Tiles[_ActualSelection].ProfileID == -1)
|
||||
if (_Tiles[_ActualSelection].ProfileID == Guid.Empty)
|
||||
{
|
||||
_ActualSelection = _Tiles.Count - _Theme.Tiles.NumW;
|
||||
while(_Tiles[_ActualSelection + 1].ProfileID != -1)
|
||||
while(_Tiles[_ActualSelection + 1].ProfileID != Guid.Empty)
|
||||
{
|
||||
_ActualSelection++;
|
||||
}
|
||||
@@ -239,23 +240,23 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
|
||||
if (Offset * _Theme.Tiles.NumW + _ActualSelection < _VisibleProfiles.Count)
|
||||
Selection = _VisibleProfiles[Offset * _Theme.Tiles.NumW + _ActualSelection];
|
||||
SelectedID = _VisibleProfiles.ElementAt(Offset * _Theme.Tiles.NumW + _ActualSelection);
|
||||
else
|
||||
Selection = -1;
|
||||
SelectedID = Guid.Empty;
|
||||
}
|
||||
|
||||
public void HandleMouse(SMouseEvent mevent)
|
||||
{
|
||||
for (int i = 0; i < _Tiles.Count; i++)
|
||||
{
|
||||
if (CHelper.IsInBounds(_Tiles[i].Avatar.Rect, mevent) && _Tiles[i].ProfileID != -1)
|
||||
if (CHelper.IsInBounds(_Tiles[i].Avatar.Rect, mevent) && _Tiles[i].ProfileID != Guid.Empty)
|
||||
{
|
||||
_ActualSelection = i;
|
||||
|
||||
if (Offset * _Theme.Tiles.NumW + _ActualSelection < _VisibleProfiles.Count)
|
||||
Selection = _VisibleProfiles[Offset * _Theme.Tiles.NumW + _ActualSelection];
|
||||
SelectedID = _VisibleProfiles.ElementAt(Offset * _Theme.Tiles.NumW + _ActualSelection);
|
||||
else
|
||||
Selection = -1;
|
||||
SelectedID = Guid.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -263,7 +264,7 @@ namespace VocaluxeLib.Menu
|
||||
public void FastSelection(bool active, int player)
|
||||
{
|
||||
//Overwrite player-selection; Same profile, but other player
|
||||
if (active && Selection != -1)
|
||||
if (active && SelectedID != Guid.Empty)
|
||||
{
|
||||
_Player = player;
|
||||
_PlayerSelector.Color = CBase.Themes.GetPlayerColor(player);
|
||||
@@ -271,7 +272,7 @@ namespace VocaluxeLib.Menu
|
||||
//Normal activation
|
||||
else if (active)
|
||||
{
|
||||
Selection = 0;
|
||||
SelectedID = _VisibleProfiles.ElementAt(0);
|
||||
_ActualSelection = 0;
|
||||
_Player = player;
|
||||
_PlayerSelector.Color = CBase.Themes.GetPlayerColor(player);
|
||||
@@ -280,7 +281,7 @@ namespace VocaluxeLib.Menu
|
||||
//Deactivate
|
||||
else
|
||||
{
|
||||
Selection = -1;
|
||||
SelectedID = Guid.Empty;
|
||||
_ActualSelection = -1;
|
||||
_Player = -1;
|
||||
_PlayerSelector.Visible = false;
|
||||
@@ -307,14 +308,14 @@ namespace VocaluxeLib.Menu
|
||||
_Tiles[i].Avatar.Texture = CBase.Profiles.GetAvatar(_VisibleProfiles[i + offset * _Theme.Tiles.NumW]);
|
||||
_Tiles[i].Avatar.Color = new SColorF(1, 1, 1, 1);
|
||||
_Tiles[i].Name.Text = CBase.Profiles.GetPlayerName(_VisibleProfiles[i + offset * _Theme.Tiles.NumW]);
|
||||
_Tiles[i].ProfileID = _VisibleProfiles[i + offset * _Theme.Tiles.NumW];
|
||||
_Tiles[i].ProfileID = _VisibleProfiles.ElementAt(i + offset * _Theme.Tiles.NumW);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Tiles[i].Avatar.Texture = _TextureEmptyTile;
|
||||
_Tiles[i].Avatar.Color = _ColorEmptyTile;
|
||||
_Tiles[i].Name.Text = "";
|
||||
_Tiles[i].ProfileID = -1;
|
||||
_Tiles[i].ProfileID = Guid.Empty;
|
||||
}
|
||||
}
|
||||
Offset = offset;
|
||||
@@ -331,7 +332,7 @@ namespace VocaluxeLib.Menu
|
||||
return isOver;
|
||||
}
|
||||
|
||||
public int TilePlayerNr(SMouseEvent mevent)
|
||||
public Guid TilePlayerID(SMouseEvent mevent)
|
||||
{
|
||||
foreach (CTile tile in _Tiles)
|
||||
{
|
||||
@@ -339,7 +340,7 @@ namespace VocaluxeLib.Menu
|
||||
return tile.ProfileID;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return Guid.Empty;
|
||||
}
|
||||
|
||||
public CStatic TilePlayerAvatar(SMouseEvent mevent)
|
||||
@@ -374,9 +375,9 @@ namespace VocaluxeLib.Menu
|
||||
_PrepareTiles();
|
||||
}
|
||||
|
||||
public void UseProfile(int id)
|
||||
public void UseProfile(Guid id)
|
||||
{
|
||||
if (id > -1)
|
||||
if (id != Guid.Empty)
|
||||
{
|
||||
if (!_UsedProfiles.Contains(id) && CBase.Profiles.IsProfileIDValid(id) && !CBase.Profiles.IsGuest(id))
|
||||
{
|
||||
@@ -386,22 +387,34 @@ namespace VocaluxeLib.Menu
|
||||
}
|
||||
}
|
||||
|
||||
public void RemoveUsedProfile(int id)
|
||||
public void RemoveUsedProfile(Guid id)
|
||||
{
|
||||
if (id > -1)
|
||||
if (id != Guid.Empty)
|
||||
{
|
||||
_UsedProfiles.Remove(id);
|
||||
UpdateList();
|
||||
}
|
||||
}
|
||||
|
||||
public int GetRandomUnusedProfile()
|
||||
public Guid GetRandomUnusedProfile()
|
||||
{
|
||||
if (_VisibleProfiles.Count == 0)
|
||||
return -1;
|
||||
Guid id = Guid.Empty;
|
||||
|
||||
int rand = CBase.Game.GetRandom(_VisibleProfiles.Count);
|
||||
return _VisibleProfiles[rand];
|
||||
if (_VisibleProfiles.Count == 0)
|
||||
return id;
|
||||
|
||||
if (_VisibleProfiles.Count == _UsedProfiles.Count)
|
||||
return id;
|
||||
|
||||
while (id == Guid.Empty)
|
||||
{
|
||||
int rand = CBase.Game.GetRandom(_VisibleProfiles.Count);
|
||||
if (_UsedProfiles.Contains(_VisibleProfiles[rand]))
|
||||
continue;
|
||||
id = _VisibleProfiles.ElementAt(rand);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
private void _PrepareTiles()
|
||||
@@ -416,7 +429,7 @@ namespace VocaluxeLib.Menu
|
||||
var tileStatic = new CStatic(_PartyModeID, _TextureEmptyTile, _ColorEmptyTile, rect) {Aspect = EAspect.Crop};
|
||||
var tileText = new CText(rect.X + rect.W / 2, rect.Y + rect.H + _Theme.Tiles.Name.Space, rect.Z, _Theme.Tiles.Name.Height, rect.W, EAlignment.Center,
|
||||
_Theme.Tiles.Name.Style, _Theme.Tiles.Name.Font, _ColorNameTile, "");
|
||||
_Tiles.Add(new CTile(tileStatic, tileText, -1));
|
||||
_Tiles.Add(new CTile(tileStatic, tileText, Guid.Empty));
|
||||
}
|
||||
}
|
||||
_Rect.X = MaxRect.X;
|
||||
|
||||
@@ -469,6 +469,7 @@ namespace VocaluxeLib.Menu
|
||||
Text = new CText(0, 0, 0, _TextH, _MaxW, EAlignment.Center, _Theme.TextStyle, _Theme.TextFont, _TextColor, "T", _PartyModeID),
|
||||
Img = new CStatic(_PartyModeID)
|
||||
};
|
||||
el.Img.Aspect = EAspect.Crop;
|
||||
_VisibleElements.Add(el);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace VocaluxeLib.Profile
|
||||
#pragma warning restore 649
|
||||
}
|
||||
|
||||
[XmlIgnore] public int ID;
|
||||
[DefaultValue(null)] public Guid ID;
|
||||
|
||||
public string PlayerName;
|
||||
[XmlIgnore] public string FilePath;
|
||||
@@ -67,12 +67,13 @@ namespace VocaluxeLib.Profile
|
||||
{
|
||||
Avatar = CBase.Profiles.GetAvatarByFilename(value);
|
||||
if (Avatar == null)
|
||||
throw new Exception("Avatar '" + value + "' not found");
|
||||
CBase.Log.LogError("Avatar '" + value + "' not found");
|
||||
}
|
||||
}
|
||||
|
||||
public CProfile()
|
||||
{
|
||||
ID = Guid.NewGuid();
|
||||
PlayerName = String.Empty;
|
||||
Difficulty = EGameDifficulty.TR_CONFIG_EASY;
|
||||
UserRole = EUserRole.TR_USERROLE_NORMAL;
|
||||
@@ -92,6 +93,12 @@ namespace VocaluxeLib.Profile
|
||||
try
|
||||
{
|
||||
xml.Deserialize(FilePath, this);
|
||||
//If ID couldn't be loaded, generate a new one and save it
|
||||
if (ID == Guid.Empty)
|
||||
{
|
||||
ID = Guid.NewGuid();
|
||||
SaveProfile();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -112,7 +119,10 @@ namespace VocaluxeLib.Profile
|
||||
var old = xml.Deserialize<SOldXmlProfile>(FilePath);
|
||||
string newXml = ser.Serialize(old.Info);
|
||||
xml.DeserializeString(newXml, this);
|
||||
if (ID == null)
|
||||
ID = Guid.NewGuid();
|
||||
ser.Serialize(FilePath, this);
|
||||
|
||||
}
|
||||
catch (Exception e2)
|
||||
{
|
||||
|
||||
@@ -341,7 +341,7 @@ namespace VocaluxeLib
|
||||
#region Game
|
||||
public struct SPlayer
|
||||
{
|
||||
public int ProfileID;
|
||||
public Guid ProfileID;
|
||||
public double Points;
|
||||
public double PointsLineBonus;
|
||||
public double PointsGoldenNotes;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">DebugWin</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@@ -10,11 +10,12 @@
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>VocaluxeLib</RootNamespace>
|
||||
<AssemblyName>VocaluxeLib</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugWin|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -27,6 +28,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<CodeAnalysisRuleSet>..\CheckingRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -38,6 +40,7 @@
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<DefineConstants>WIN</DefineConstants>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugLinux|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -49,6 +52,7 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseLinux|AnyCPU'">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@@ -60,6 +64,7 @@
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<DefineConstants>LINUX</DefineConstants>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InstallerWin|AnyCPU'">
|
||||
<OutputPath>..\Output\libs\managed</OutputPath>
|
||||
@@ -70,6 +75,7 @@
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>ManagedMinimumRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
|
||||
@@ -213,6 +213,8 @@ namespace VocaluxeLib.Xml
|
||||
return value;
|
||||
}
|
||||
}
|
||||
if (type == typeof(Guid))
|
||||
return Guid.Parse(node.InnerText);
|
||||
if (type == typeof(string))
|
||||
return node == null ? null : node.InnerText;
|
||||
if (type.IsPrimitive)
|
||||
|
||||
@@ -96,6 +96,10 @@ namespace VocaluxeLib.Xml
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
}
|
||||
else if (type == typeof(Guid))
|
||||
{
|
||||
writer.WriteElementString(name, value.ToString());
|
||||
}
|
||||
else if (type.IsNullable())
|
||||
_WriteValue(writer, name, type.GetGenericArguments()[0], value, isAttribute, arrayItemName, nameAttribute);
|
||||
else if (type.IsList() || type.IsArray)
|
||||
|
||||
Reference in new issue
Block a user