From bdca0554e4be408e7a49c3a290c79f473044653b Mon Sep 17 00:00:00 2001 From: Flamefire Date: Thu, 25 Apr 2013 18:27:59 +0200 Subject: [PATCH] Changed players->Profile handling (no redundant entries) --- .../PartyModeChallenge/CPartyModeChallenge.cs | 21 +-- .../CPartyModeChallengeMedley.cs | 19 +-- .../PartyModeTicTacToe/CPartyModeTicTacToe.cs | 10 +- Vocaluxe/Base/CConfig.cs | 6 +- Vocaluxe/Base/CDataBase.cs | 56 +++----- Vocaluxe/Base/CGame.cs | 98 ++++++------- Vocaluxe/Base/CMain.cs | 14 +- Vocaluxe/Base/CProfiles.cs | 129 +++++++++--------- Vocaluxe/Program.cs | 2 +- Vocaluxe/Screens/CScreenNames.cs | 92 +++++-------- Vocaluxe/Screens/CScreenParty.cs | 8 +- Vocaluxe/Screens/CScreenScore.cs | 26 ++-- Vocaluxe/Screens/CScreenSing.cs | 38 +++--- VocaluxeLib/Menu/CNameSelection.cs | 13 +- VocaluxeLib/Menu/CPoints.cs | 4 - VocaluxeLib/Menu/IMenu.cs | 4 +- VocaluxeLib/Menu/SingNotes/CSingNotes.cs | 13 +- VocaluxeLib/Menu/Structs.cs | 2 - 18 files changed, 232 insertions(+), 323 deletions(-) diff --git a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs index e1e74466..5782df18 100644 --- a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs +++ b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs @@ -459,33 +459,22 @@ namespace VocaluxeLib.PartyModes.Challenge CBase.Game.AddSong(songID, gm); CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce); - SPlayer[] player = CBase.Game.GetPlayer(); + SPlayer[] player = CBase.Game.GetPlayers(); if (player == null) return; if (player.Length < _GameData.NumPlayerAtOnce) return; - SProfile[] profiles = CBase.Profiles.GetProfiles(); CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1); for (int i = 0; i < _GameData.NumPlayerAtOnce; i++) { - //default values - player[i].Name = "foobar"; - player[i].Difficulty = EGameDifficulty.TR_CONFIG_EASY; - player[i].ProfileID = -1; - //try to fill with the right data if (c != null) - { - if (_GameData.ProfileIDs[c.Player[i]] < profiles.Length) - { - player[i].Name = profiles[_GameData.ProfileIDs[c.Player[i]]].PlayerName; - player[i].Difficulty = profiles[_GameData.ProfileIDs[c.Player[i]]].Difficulty; - player[i].ProfileID = _GameData.ProfileIDs[c.Player[i]]; - } - } + player[i].ProfileID = _GameData.ProfileIDs[c.Player[i]]; + else + player[i].ProfileID = -1; } CBase.Songs.AddPartySongSung(songID); @@ -593,7 +582,7 @@ namespace VocaluxeLib.PartyModes.Challenge } else { - SPlayer[] results = CBase.Game.GetPlayer(); + SPlayer[] results = CBase.Game.GetPlayers(); if (results == null) return; diff --git a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs index 409ee742..e733ddb3 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs @@ -482,33 +482,22 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley #region PlayerNames CBase.Game.SetNumPlayer(_GameData.NumPlayerAtOnce); - SPlayer[] player = CBase.Game.GetPlayer(); + SPlayer[] player = CBase.Game.GetPlayers(); if (player == null) return false; if (player.Length < _GameData.NumPlayerAtOnce) return false; - SProfile[] profiles = CBase.Profiles.GetProfiles(); CCombination c = _GameData.Rounds.GetRound(_GameData.CurrentRoundNr - 1); for (int i = 0; i < _GameData.NumPlayerAtOnce; i++) { - //default values - player[i].Name = "foobar"; - player[i].Difficulty = EGameDifficulty.TR_CONFIG_EASY; - player[i].ProfileID = -1; - //try to fill with the right data if (c != null) - { - if (_GameData.ProfileIDs[c.Player[i]] < profiles.Length) - { - player[i].Name = profiles[_GameData.ProfileIDs[c.Player[i]]].PlayerName; - player[i].Difficulty = profiles[_GameData.ProfileIDs[c.Player[i]]].Difficulty; - player[i].ProfileID = _GameData.ProfileIDs[c.Player[i]]; - } - } + player[i].ProfileID = _GameData.ProfileIDs[c.Player[i]]; + else + player[i].ProfileID = -1; } #endregion PlayerNames diff --git a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs index d403d7cb..4dc7e99f 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs @@ -718,7 +718,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe CBase.Game.SetNumPlayer(2); - SPlayer[] player = CBase.Game.GetPlayer(); + SPlayer[] player = CBase.Game.GetPlayers(); if (player == null) return; @@ -732,8 +732,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe for (int i = 0; i < 2; i++) { //default values - player[i].Name = "foobar"; - player[i].Difficulty = EGameDifficulty.TR_CONFIG_EASY; player[i].ProfileID = -1; } @@ -742,16 +740,12 @@ namespace VocaluxeLib.PartyModes.TicTacToe { if (_GameData.ProfileIDsTeam1[r.SingerTeam1] < profiles.Length) { - player[0].Name = profiles[_GameData.ProfileIDsTeam1[r.SingerTeam1]].PlayerName; - player[0].Difficulty = profiles[_GameData.ProfileIDsTeam1[r.SingerTeam1]].Difficulty; player[0].ProfileID = _GameData.ProfileIDsTeam1[r.SingerTeam1]; if (isDuet) player[0].LineNr = 0; } if (_GameData.ProfileIDsTeam2[r.SingerTeam2] < profiles.Length) { - player[1].Name = profiles[_GameData.ProfileIDsTeam2[r.SingerTeam2]].PlayerName; - player[1].Difficulty = profiles[_GameData.ProfileIDsTeam2[r.SingerTeam2]].Difficulty; player[1].ProfileID = _GameData.ProfileIDsTeam2[r.SingerTeam2]; if (isDuet) player[1].LineNr = 1; @@ -792,7 +786,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe if (!_GameData.Rounds[_GameData.SingRoundNr].Finished) _GameData.CurrentRoundNr++; - SPlayer[] results = CBase.Game.GetPlayer(); + SPlayer[] results = CBase.Game.GetPlayers(); if (results == null) return; diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index 6e8484f4..5e72062f 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -842,13 +842,11 @@ namespace Vocaluxe.Base if (Path.GetFileName(CProfiles.Profiles[i].ProfileFile) == Players[j] && CProfiles.Profiles[i].Active == EOffOn.TR_CONFIG_ON) { //Update Game-infos with player - CGame.Player[j].Name = CProfiles.Profiles[i].PlayerName; - CGame.Player[j].Difficulty = CProfiles.Profiles[i].Difficulty; - CGame.Player[j].ProfileID = i; + CGame.Players[j].ProfileID = i; } } else - CGame.Player[j].ProfileID = -1; + CGame.Players[j].ProfileID = -1; } } } diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index a06ea759..3cd2d400 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -70,21 +70,9 @@ namespace Vocaluxe.Base } #region Highscores - public static int AddScore(string playerName, int score, int lineNr, long date, int medley, int duet, int shortSong, int diff, + public static int AddScore(string playerName, int score, int lineNr, long date, int medley, int duet, int shortSong, int difficulty, string artist, string title, int numPlayed, string filePath) { - SPlayer player = new SPlayer - { - Name = playerName, - Points = score, - LineNr = lineNr, - DateTicks = date, - Medley = medley == 1, - Duet = duet == 1, - ShortSong = shortSong == 1, - Difficulty = (EGameDifficulty)diff - }; - using (SQLiteConnection connection = new SQLiteConnection()) { connection.ConnectionString = "Data Source=" + filePath; @@ -101,7 +89,7 @@ namespace Vocaluxe.Base using (SQLiteCommand command = new SQLiteCommand(connection)) { int dataBaseSongID = _GetDataBaseSongID(artist, title, numPlayed, command); - int result = _AddScore(player, command, dataBaseSongID); + int result = _AddScore(playerName, score, lineNr, date, medley, duet, shortSong, difficulty, dataBaseSongID, command); return result; } } @@ -125,42 +113,30 @@ namespace Vocaluxe.Base using (SQLiteCommand command = new SQLiteCommand(connection)) { int dataBaseSongID = _GetDataBaseSongID(player, command); - int result = _AddScore(player, command, dataBaseSongID); - - return result; + return _AddScore(CProfiles.GetPlayerName(player.ProfileID), (int)Math.Round(player.Points), player.LineNr, player.DateTicks, player.Medley ? 1 : 0, + player.Duet ? 1 : 0, player.ShortSong ? 1 : 0, (int)CProfiles.GetDifficulty(player.ProfileID), dataBaseSongID, command); } } } - private static int _AddScore(SPlayer player, SQLiteCommand command, int dataBaseSongID) + private static int _AddScore(string playerName, int score, int lineNr, long date, int medley, int duet, int shortSong, int difficulty, + int dataBaseSongID, SQLiteCommand command) { int lastInsertID = -1; if (dataBaseSongID >= 0) { - int medley = 0; - if (player.Medley) - medley = 1; - - int duet = 0; - if (player.Duet) - duet = 1; - - int shortSong = 0; - if (player.ShortSong) - shortSong = 1; - command.CommandText = "SELECT id FROM Scores WHERE SongID = @SongID AND PlayerName = @PlayerName AND Score = @Score AND " + "LineNr = @LineNr AND Date = @Date AND Medley = @Medley AND Duet = @Duet AND ShortSong = @ShortSong AND Difficulty = @Difficulty"; command.Parameters.Add("@SongID", DbType.Int32, 0).Value = dataBaseSongID; - command.Parameters.Add("@PlayerName", DbType.String, 0).Value = player.Name; - command.Parameters.Add("@Score", DbType.Int32, 0).Value = (int)Math.Round(player.Points); - command.Parameters.Add("@LineNr", DbType.Int32, 0).Value = player.LineNr; - command.Parameters.Add("@Date", DbType.Int64, 0).Value = player.DateTicks; + command.Parameters.Add("@PlayerName", DbType.String, 0).Value = playerName; + command.Parameters.Add("@Score", DbType.Int32, 0).Value = score; + command.Parameters.Add("@LineNr", DbType.Int32, 0).Value = lineNr; + command.Parameters.Add("@Date", DbType.Int64, 0).Value = date; command.Parameters.Add("@Medley", DbType.Int32, 0).Value = medley; command.Parameters.Add("@Duet", DbType.Int32, 0).Value = duet; command.Parameters.Add("@ShortSong", DbType.Int32, 0).Value = shortSong; - command.Parameters.Add("@Difficulty", DbType.Int32, 0).Value = (int)player.Difficulty; + command.Parameters.Add("@Difficulty", DbType.Int32, 0).Value = difficulty; SQLiteDataReader reader = null; try @@ -181,14 +157,14 @@ namespace Vocaluxe.Base command.CommandText = "INSERT INTO Scores (SongID, PlayerName, Score, LineNr, Date, Medley, Duet, ShortSong, Difficulty) " + "VALUES (@SongID, @PlayerName, @Score, @LineNr, @Date, @Medley, @Duet, @ShortSong, @Difficulty)"; command.Parameters.Add("@SongID", DbType.Int32, 0).Value = dataBaseSongID; - command.Parameters.Add("@PlayerName", DbType.String, 0).Value = player.Name; - command.Parameters.Add("@Score", DbType.Int32, 0).Value = (int)Math.Round(player.Points); - command.Parameters.Add("@LineNr", DbType.Int32, 0).Value = player.LineNr; - command.Parameters.Add("@Date", DbType.Int64, 0).Value = player.DateTicks; + command.Parameters.Add("@PlayerName", DbType.String, 0).Value = playerName; + command.Parameters.Add("@Score", DbType.Int32, 0).Value = score; + command.Parameters.Add("@LineNr", DbType.Int32, 0).Value = lineNr; + command.Parameters.Add("@Date", DbType.Int64, 0).Value = date; command.Parameters.Add("@Medley", DbType.Int32, 0).Value = medley; command.Parameters.Add("@Duet", DbType.Int32, 0).Value = duet; command.Parameters.Add("@ShortSong", DbType.Int32, 0).Value = shortSong; - command.Parameters.Add("@Difficulty", DbType.Int32, 0).Value = (int)player.Difficulty; + command.Parameters.Add("@Difficulty", DbType.Int32, 0).Value = difficulty; command.ExecuteNonQuery(); //Read last insert line diff --git a/Vocaluxe/Base/CGame.cs b/Vocaluxe/Base/CGame.cs index 6e83dbed..5c9fb87a 100644 --- a/Vocaluxe/Base/CGame.cs +++ b/Vocaluxe/Base/CGame.cs @@ -60,13 +60,13 @@ namespace Vocaluxe.Base public static int ActBeatD { get; private set; } - public static SPlayer[] Player { get; private set; } + public static SPlayer[] Players { get; private set; } public static void Init() { _GameMode = new CGameModeNormal(); _GameMode.Init(); - Player = new SPlayer[CSettings.MaxNumPlayer]; + Players = new SPlayer[CSettings.MaxNumPlayer]; ResetPlayer(); CConfig.UsePlayers(); @@ -115,12 +115,12 @@ namespace Vocaluxe.Base public static void Start() { - _GameMode.Start(Player); + _GameMode.Start(Players); } public static void NextRound() { - _GameMode.NextRound(Player); + _GameMode.NextRound(Players); } public static bool IsFinished() @@ -175,22 +175,22 @@ namespace Vocaluxe.Base public static void ResetPlayer() { - for (int i = 0; i < Player.Length; i++) + for (int i = 0; i < Players.Length; i++) { - Player[i].Points = 0f; - Player[i].PointsLineBonus = 0f; - Player[i].PointsGoldenNotes = 0f; - Player[i].LineNr = 0; - Player[i].NoteDiff = 0; - Player[i].SingLine = new List(); - Player[i].CurrentLine = -1; - Player[i].CurrentNote = -1; - Player[i].SongID = -1; - Player[i].Medley = false; - Player[i].Duet = false; - Player[i].ShortSong = false; - Player[i].DateTicks = DateTime.Now.Ticks; - Player[i].SongFinished = false; + Players[i].Points = 0f; + Players[i].PointsLineBonus = 0f; + Players[i].PointsGoldenNotes = 0f; + Players[i].LineNr = 0; + Players[i].NoteDiff = 0; + Players[i].SingLine = new List(); + Players[i].CurrentLine = -1; + Players[i].CurrentNote = -1; + Players[i].SongID = -1; + Players[i].Medley = false; + Players[i].Duet = false; + Players[i].ShortSong = false; + Players[i].DateTicks = DateTime.Now.Ticks; + Players[i].SongFinished = false; } _OldBeatD = -100; Beat = -100; @@ -227,9 +227,9 @@ namespace Vocaluxe.Base { if ((_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_MEDLEY && song.Medley.EndBeat == beat) || (_GameMode.GetCurrentGameMode() == EGameMode.TR_GAMEMODE_SHORTSONG && song.ShortEnd == beat)) - Player[p].SongFinished = true; + Players[p].SongFinished = true; - CLine[] lines = song.Notes.GetLines(Player[p].LineNr).Line; + CLine[] lines = song.Notes.GetLines(Players[p].LineNr).Line; int line = -1; for (int j = 0; j < lines.Length; j++) @@ -243,13 +243,13 @@ namespace Vocaluxe.Base if (line < 0) continue; - if (line != Player[p].CurrentLine) - Player[p].CurrentNote = -1; + if (line != Players[p].CurrentLine) + Players[p].CurrentNote = -1; - Player[p].CurrentLine = line; + Players[p].CurrentLine = line; - while (Player[p].SingLine.Count <= line) - Player[p].SingLine.Add(new CLine()); + while (Players[p].SingLine.Count <= line) + Players[p].SingLine.Add(new CLine()); CNote[] notes = lines[line].Notes; int note = -1; @@ -264,14 +264,14 @@ namespace Vocaluxe.Base if (note >= 0) { - Player[p].CurrentNote = note; + Players[p].CurrentNote = note; if (line == lines.Length - 1) { if (note == lines[line].NoteCount - 1) { if (notes[note].EndBeat == beat) - Player[p].SongFinished = true; + Players[p].SongFinished = true; } } @@ -286,56 +286,56 @@ namespace Vocaluxe.Base while (tonePlayer - tone < -6) tonePlayer += 12; - Player[p].NoteDiff = Math.Abs(tone - tonePlayer); - bool hit = Player[p].NoteDiff <= (2 - (int)Player[p].Difficulty); + Players[p].NoteDiff = Math.Abs(tone - tonePlayer); + bool hit = Players[p].NoteDiff <= (2 - (int)CProfiles.GetDifficulty(Players[p].ProfileID)); if (hit) { // valid //CSound.RecordSetTone(p, Tone); double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[note].PointsForBeat / - song.Notes.GetLines(Player[p].LineNr).Points; + song.Notes.GetLines(Players[p].LineNr).Points; if (notes[note].NoteType == ENoteType.Golden) - Player[p].PointsGoldenNotes += points; + Players[p].PointsGoldenNotes += points; - Player[p].Points += points; + Players[p].Points += points; // update player notes (sung notes) - if (Player[p].SingLine[line].NoteCount > 0) + if (Players[p].SingLine[line].NoteCount > 0) { - CNote nt = Player[p].SingLine[line].LastNote; + CNote nt = Players[p].SingLine[line].LastNote; if (notes[note].StartBeat == beat || nt.EndBeat + 1 != beat || nt.Tone != tone || !nt.Hit) - Player[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType)); + Players[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType)); else - Player[p].SingLine[line].IncLastNoteLength(); + Players[p].SingLine[line].IncLastNoteLength(); } else - Player[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType)); + Players[p].SingLine[line].AddNote(new CNote(beat, 1, tone, String.Empty, true, notes[note].NoteType)); - Player[p].SingLine[line].LastNote.IsPerfect(notes[note]); - Player[p].SingLine[line].IsPerfect(lines[line]); + Players[p].SingLine[line].LastNote.IsPerfect(notes[note]); + Players[p].SingLine[line].IsPerfect(lines[line]); } else { - if (Player[p].SingLine[line].NoteCount > 0) + if (Players[p].SingLine[line].NoteCount > 0) { - CNote nt = Player[p].SingLine[line].LastNote; + CNote nt = Players[p].SingLine[line].LastNote; if (nt.Tone == tonePlayer && nt.EndBeat + 1 == beat && !nt.Hit) - Player[p].SingLine[line].IncLastNoteLength(); + Players[p].SingLine[line].IncLastNoteLength(); else - Player[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle)); + Players[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle)); } else - Player[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle)); + Players[p].SingLine[line].AddNote(new CNote(beat, 1, tonePlayer, String.Empty, false, ENoteType.Freestyle)); } } // Line Bonus - int numLinesWithPoints = song.Notes.GetNumLinesWithPoints(Player[p].LineNr); + int numLinesWithPoints = song.Notes.GetNumLinesWithPoints(Players[p].LineNr); if (note == lines[line].NoteCount - 1 && numLinesWithPoints > 0) { if (notes[note].EndBeat == beat && lines[line].Points > 0f) { - double factor = Player[p].SingLine[line].Points / (double)lines[line].Points; + double factor = Players[p].SingLine[line].Points / (double)lines[line].Points; if (factor < 0.4) factor = 0.0; else if (factor > 0.9) @@ -348,8 +348,8 @@ namespace Vocaluxe.Base } double points = CSettings.LinebonusScore * factor * 1f / numLinesWithPoints; - Player[p].Points += points; - Player[p].PointsLineBonus += points; + Players[p].Points += points; + Players[p].PointsLineBonus += points; } } } diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 47d6c0f3..014d439c 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -478,9 +478,9 @@ namespace Vocaluxe.Base CGame.NumPlayer = numPlayer; } - public SPlayer[] GetPlayer() + public SPlayer[] GetPlayers() { - return CGame.Player; + return CGame.Players; } public CPoints GetPoints() @@ -540,6 +540,16 @@ namespace Vocaluxe.Base { return CProfiles.Profiles; } + + public EGameDifficulty GetDifficulty(int profileID) + { + return CProfiles.GetDifficulty(profileID); + } + + public string GetPlayerName(int profileID, int playerNum = 0) + { + return CProfiles.GetPlayerName(profileID, playerNum); + } } class CBrecord : IRecording diff --git a/Vocaluxe/Base/CProfiles.cs b/Vocaluxe/Base/CProfiles.cs index 655cf08c..71bcedd9 100644 --- a/Vocaluxe/Base/CProfiles.cs +++ b/Vocaluxe/Base/CProfiles.cs @@ -62,12 +62,14 @@ namespace Vocaluxe.Base LoadProfiles(); } - public static int NewProfile() + public static string GetPlayerName(int profileID, int playerNum = 0) { - return NewProfile(String.Empty); + if (IsProfileIDValid(profileID)) + return _Profiles[profileID].PlayerName; + return (playerNum > 0) ? "Player " + playerNum : "Player"; } - public static int NewProfile(string fileName) + public static int NewProfile(string fileName = "") { SProfile profile = new SProfile { @@ -132,125 +134,119 @@ namespace Vocaluxe.Base } } - public static string AddGetPlayerName(int profileNr, char chr) + public static string AddGetPlayerName(int profileID, char chr) { - if (profileNr < 0 || profileNr >= _Profiles.Count) + if (IsProfileIDValid(profileID)) return String.Empty; - SProfile profile = _Profiles[profileNr]; + SProfile profile = _Profiles[profileID]; profile.PlayerName += chr; - _Profiles[profileNr] = profile; + _Profiles[profileID] = profile; return profile.PlayerName; } - public static string GetPlayerName(int profileNr) + public static string GetDeleteCharInPlayerName(int profileID) { - if (profileNr < 0 || profileNr >= _Profiles.Count) + if (IsProfileIDValid(profileID)) return String.Empty; - return _Profiles[profileNr].PlayerName; - } - - public static string GetDeleteCharInPlayerName(int profileNr) - { - if (profileNr < 0 || profileNr >= _Profiles.Count) - return String.Empty; - - SProfile profile = _Profiles[profileNr]; + SProfile profile = _Profiles[profileID]; if (profile.PlayerName != "") profile.PlayerName = profile.PlayerName.Remove(profile.PlayerName.Length - 1); - _Profiles[profileNr] = profile; + _Profiles[profileID] = profile; return profile.PlayerName; } - public static EGameDifficulty GetDifficulty(int profileNr) + public static bool IsProfileIDValid(int profileID) { - if (profileNr < 0 || profileNr >= _Profiles.Count) - return EGameDifficulty.TR_CONFIG_NORMAL; - - return _Profiles[profileNr].Difficulty; + return profileID < 0 || profileID >= _Profiles.Count; } - public static void SetDifficulty(int profileNr, EGameDifficulty difficulty) + public static EGameDifficulty GetDifficulty(int profileID) { - if (profileNr < 0 || profileNr >= _Profiles.Count) + return IsProfileIDValid(profileID) ? EGameDifficulty.TR_CONFIG_NORMAL : _Profiles[profileID].Difficulty; + } + + public static void SetDifficulty(int profileID, EGameDifficulty difficulty) + { + if (IsProfileIDValid(profileID)) return; - SProfile profile = _Profiles[profileNr]; + SProfile profile = _Profiles[profileID]; profile.Difficulty = difficulty; - _Profiles[profileNr] = profile; + _Profiles[profileID] = profile; } - public static EOffOn GetGuestProfile(int profileNr) + public static EOffOn GetGuestProfile(int profileID) { - if (profileNr < 0 || profileNr >= _Profiles.Count) + if (IsProfileIDValid(profileID)) return EOffOn.TR_CONFIG_OFF; - return _Profiles[profileNr].GuestProfile; + return _Profiles[profileID].GuestProfile; } - public static EOffOn GetActive(int profileNr) + public static EOffOn GetActive(int profileID) { - if (profileNr < 0 || profileNr >= _Profiles.Count) + if (IsProfileIDValid(profileID)) return EOffOn.TR_CONFIG_OFF; - return _Profiles[profileNr].Active; + return _Profiles[profileID].Active; } - public static void SetGuestProfile(int profileNr, EOffOn option) + public static void SetGuestProfile(int profileID, EOffOn option) { - if (profileNr < 0 || profileNr >= _Profiles.Count) + if (IsProfileIDValid(profileID)) return; - SProfile profile = _Profiles[profileNr]; + SProfile profile = _Profiles[profileID]; profile.GuestProfile = option; - _Profiles[profileNr] = profile; + _Profiles[profileID] = profile; } - public static void SetActive(int profileNr, EOffOn option) + public static void SetActive(int profileID, EOffOn option) { - if (profileNr < 0 || profileNr >= _Profiles.Count) + if (IsProfileIDValid(profileID)) return; - SProfile profile = _Profiles[profileNr]; + SProfile profile = _Profiles[profileID]; profile.Active = option; - _Profiles[profileNr] = profile; + _Profiles[profileID] = profile; } - public static bool IsGuestProfile(int profileNr) + public static bool IsGuestProfile(int profileID) { - if (profileNr < 0 || profileNr >= _Profiles.Count) + if (IsProfileIDValid(profileID)) return true; // this will prevent from saving dummy profiles to highscore db - return _Profiles[profileNr].GuestProfile == EOffOn.TR_CONFIG_ON; + return _Profiles[profileID].GuestProfile == EOffOn.TR_CONFIG_ON; } - public static bool IsActive(int profileNr) + public static bool IsActive(int profileID) { - if (profileNr < 0 || profileNr >= _Profiles.Count) + if (IsProfileIDValid(profileID)) return false; - return _Profiles[profileNr].Active == EOffOn.TR_CONFIG_ON; + return _Profiles[profileID].Active == EOffOn.TR_CONFIG_ON; } - public static void SetAvatar(int profileNr, int avatarNr) + public static void SetAvatar(int profileID, int avatarNr) { - if (profileNr < 0 || profileNr >= _Profiles.Count || avatarNr < 0 || avatarNr >= _Avatars.Count) + if (IsProfileIDValid(profileID) || avatarNr < 0 || avatarNr >= _Avatars.Count) return; - SProfile profile = _Profiles[profileNr]; + SProfile profile = _Profiles[profileID]; profile.Avatar = _Avatars[avatarNr]; - _Profiles[profileNr] = profile; + _Profiles[profileID] = profile; } - public static int GetAvatarNr(int profileNr) + public static int GetAvatarNr(int profileID) { - if (profileNr < 0 || profileNr >= _Profiles.Count) + if (IsProfileIDValid(profileID)) return 0; for (int i = 0; i < _Avatars.Count; i++) { - if (_Profiles[profileNr].Avatar.FileName == _Avatars[i].FileName) + if (_Profiles[profileID].Avatar.FileName == _Avatars[i].FileName) return i; } @@ -259,19 +255,18 @@ namespace Vocaluxe.Base public static void DeleteProfile(int profileID) { - if (profileID < 0 || profileID >= _Profiles.Count) + if (IsProfileIDValid(profileID)) return; - if (_Profiles[profileID].ProfileFile != "") + if (_Profiles[profileID].ProfileFile == "") + return; + try { - try - { - File.Delete(_Profiles[profileID].ProfileFile); - _Profiles.RemoveAt(profileID); - } - catch (Exception) - { - CLog.LogError("Can't delete Profile File " + _Profiles[profileID].ProfileFile + ".xml"); - } + File.Delete(_Profiles[profileID].ProfileFile); + _Profiles.RemoveAt(profileID); + } + catch (Exception) + { + CLog.LogError("Can't delete Profile File " + _Profiles[profileID].ProfileFile + ".xml"); } } @@ -298,7 +293,7 @@ namespace Vocaluxe.Base private static void _SaveProfile(int profileID) { - if (profileID < 0 || profileID >= _Profiles.Count) + if (IsProfileIDValid(profileID)) return; if (_Profiles[profileID].ProfileFile == "") diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index 539c2b3d..34c5f627 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -258,7 +258,7 @@ namespace Vocaluxe #endif #if ARCH_X64 - string path="x64"; + string path = "x64"; #endif path = Path.Combine(path, arr[0] + ".dll"); try diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs index 68e1b218..22e54dca 100644 --- a/Vocaluxe/Screens/CScreenNames.cs +++ b/Vocaluxe/Screens/CScreenNames.cs @@ -55,7 +55,6 @@ namespace Vocaluxe.Screens {"SelectSlideDuetPlayer1", "SelectSlideDuetPlayer2", "SelectSlideDuetPlayer3", "SelectSlideDuetPlayer4", "SelectSlideDuetPlayer5", "SelectSlideDuetPlayer6"}; private readonly STexture[] _OriginalPlayerAvatarTextures = new STexture[CSettings.MaxNumPlayer]; - private bool _SelectingMouseActive; private bool _SelectingKeyboardActive; private bool _SelectingKeyboardUnendless; private int _SelectingKeyboardPlayerNr; @@ -173,9 +172,7 @@ namespace Vocaluxe.Screens { _SelectedPlayerNr = _NameSelections[_NameSelection].Selection; //Update Game-infos with new player - CGame.Player[_SelectingKeyboardPlayerNr - 1].Name = CProfiles.Profiles[_SelectedPlayerNr].PlayerName; - CGame.Player[_SelectingKeyboardPlayerNr - 1].Difficulty = CProfiles.Profiles[_SelectedPlayerNr].Difficulty; - CGame.Player[_SelectingKeyboardPlayerNr - 1].ProfileID = _SelectedPlayerNr; + CGame.Players[_SelectingKeyboardPlayerNr - 1].ProfileID = _SelectedPlayerNr; //Update config for default players. CConfig.Players[_SelectingKeyboardPlayerNr - 1] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile; CConfig.SaveConfig(); @@ -320,9 +317,7 @@ namespace Vocaluxe.Screens case Keys.Delete: //Delete profile-selection - CGame.Player[_SelectingKeyboardPlayerNr - 1].ProfileID = -1; - CGame.Player[_SelectingKeyboardPlayerNr - 1].Name = String.Empty; - CGame.Player[_SelectingKeyboardPlayerNr - 1].Difficulty = EGameDifficulty.TR_CONFIG_EASY; + CGame.Players[_SelectingKeyboardPlayerNr - 1].ProfileID = -1; //Update config for default players. CConfig.Players[_SelectingKeyboardPlayerNr - 1] = String.Empty; CConfig.SaveConfig(); @@ -432,7 +427,7 @@ namespace Vocaluxe.Screens base.HandleMouse(mouseEvent); //Check if LeftButton is hold and Select-Mode inactive - if (mouseEvent.LBH && !_SelectingMouseActive) + if (mouseEvent.LBH && _SelectedPlayerNr < 0) { //Save mouse-coords _OldMouseX = mouseEvent.X; @@ -444,9 +439,6 @@ namespace Vocaluxe.Screens _SelectedPlayerNr = _NameSelections[_NameSelection].TilePlayerNr(mouseEvent); if (_SelectedPlayerNr != -1) { - //Activate mouse-selecting - _SelectingMouseActive = true; - //Update of Drag/Drop-Texture CStatic selectedPlayer = _NameSelections[_NameSelection].TilePlayerAvatar(mouseEvent); _ChooseAvatarStatic.Visible = true; @@ -459,7 +451,7 @@ namespace Vocaluxe.Screens } //Check if LeftButton is hold and Select-Mode active - if (mouseEvent.LBH && _SelectingMouseActive) + if (mouseEvent.LBH && _SelectedPlayerNr >= 0) { //Update coords for Drag/Drop-Texture _ChooseAvatarStatic.Rect.X += mouseEvent.X - _OldMouseX; @@ -468,41 +460,33 @@ namespace Vocaluxe.Screens _OldMouseY = mouseEvent.Y; } // LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar - else if (_SelectingMouseActive) + else if (_SelectedPlayerNr >= 0) { - //Check if really a player was selected - if (_SelectedPlayerNr != -1) + //Foreach Drop-Area + for (int i = 0; i < _StaticPlayer.Length; i++) { - //Foreach Drop-Area - for (int i = 0; i < _StaticPlayer.Length; i++) + //Check first, if area is "Active" + if (!_Statics[_StaticPlayer[i]].Visible) + continue; + //Check if Mouse is in area + if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent)) { - //Check first, if area is "Active" - if (_Statics[_StaticPlayer[i]].Visible) - { - //Check if Mouse is in area - if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent)) - { - //Update Game-infos with new player - CGame.Player[i].Name = CProfiles.Profiles[_SelectedPlayerNr].PlayerName; - CGame.Player[i].Difficulty = CProfiles.Profiles[_SelectedPlayerNr].Difficulty; - CGame.Player[i].ProfileID = _SelectedPlayerNr; - //Update config for default players. - CConfig.Players[i] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile; - CConfig.SaveConfig(); - //Update texture and name - _Statics[_StaticPlayerAvatar[i]].Texture = _ChooseAvatarStatic.Texture; - _Texts[_TextPlayer[i]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName; - //Update profile-warning - _CheckPlayers(); - //Update Tiles-List - _NameSelections[_NameSelection].UpdateList(); - } - } + //Update Game-infos with new player + CGame.Players[i].ProfileID = _SelectedPlayerNr; + //Update config for default players. + CConfig.Players[i] = CProfiles.Profiles[_SelectedPlayerNr].ProfileFile; + CConfig.SaveConfig(); + //Update texture and name + _Statics[_StaticPlayerAvatar[i]].Texture = _ChooseAvatarStatic.Texture; + _Texts[_TextPlayer[i]].Text = CProfiles.Profiles[_SelectedPlayerNr].PlayerName; + //Update profile-warning + _CheckPlayers(); + //Update Tiles-List + _NameSelections[_NameSelection].UpdateList(); } - _SelectedPlayerNr = -1; } + _SelectedPlayerNr = -1; //Reset variables - _SelectingMouseActive = false; _ChooseAvatarStatic.Visible = false; } @@ -528,9 +512,7 @@ namespace Vocaluxe.Screens { if (CHelper.IsInBounds(_Statics[_StaticPlayer[i]].Rect, mouseEvent)) { - CGame.Player[i].ProfileID = -1; - CGame.Player[i].Name = String.Empty; - CGame.Player[i].Difficulty = EGameDifficulty.TR_CONFIG_EASY; + CGame.Players[i].ProfileID = -1; //Update config for default players. CConfig.Players[i] = String.Empty; CConfig.SaveConfig(); @@ -587,10 +569,10 @@ namespace Vocaluxe.Screens //Update texture and name if (CConfig.Players[i] != "") { - if (CGame.Player[i].ProfileID > -1 && CProfiles.NumProfiles > CGame.Player[i].ProfileID) + if (CProfiles.IsProfileIDValid(CGame.Players[i].ProfileID)) { - _Statics[_StaticPlayerAvatar[i]].Texture = CProfiles.Profiles[CGame.Player[i].ProfileID].Avatar.Texture; - _Texts[_TextPlayer[i]].Text = CProfiles.Profiles[CGame.Player[i].ProfileID].PlayerName; + _Statics[_StaticPlayerAvatar[i]].Texture = CProfiles.Profiles[CGame.Players[i].ProfileID].Avatar.Texture; + _Texts[_TextPlayer[i]].Text = CProfiles.GetPlayerName(CGame.Players[i].ProfileID); } } if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet) @@ -629,20 +611,8 @@ namespace Vocaluxe.Screens { for (int i = 0; i < CGame.NumPlayer; i++) { - if (CGame.Player[i].ProfileID < 0) - { - CGame.Player[i].Name = "Player " + (i + 1); - CGame.Player[i].Difficulty = EGameDifficulty.TR_CONFIG_EASY; - CGame.Player[i].ProfileID = -1; - } - else - { - //Just a work-around for not crashing the game - if (CGame.Player[i].Name == null) - CGame.Player[i].Name = ""; - } if (CGame.GetNumSongs() == 1 && CGame.GetSong(1).IsDuet) - CGame.Player[i].LineNr = _SelectSlides[_SelectSlideDuetPlayer[i]].Selection; + CGame.Players[i].LineNr = _SelectSlides[_SelectSlideDuetPlayer[i]].Selection; } CGraphics.FadeTo(EScreens.ScreenSing); @@ -730,7 +700,7 @@ namespace Vocaluxe.Screens List playerWithoutProfile = new List(); for (int player = 0; player < CConfig.NumPlayer; player++) { - if (CGame.Player[player].ProfileID < 0) + if (CGame.Players[player].ProfileID < 0) playerWithoutProfile.Add(player + 1); } diff --git a/Vocaluxe/Screens/CScreenParty.cs b/Vocaluxe/Screens/CScreenParty.cs index 46df559b..f6e37116 100644 --- a/Vocaluxe/Screens/CScreenParty.cs +++ b/Vocaluxe/Screens/CScreenParty.cs @@ -198,12 +198,8 @@ namespace Vocaluxe.Screens if (CConfig.GetMaxNumMics() == 0) return; //TODO: Add message! - if (_PartyModeInfos[index].Playable) - { - CParty.SetPartyMode(_PartyModeInfos[index].PartyModeID); - CGraphics.FadeTo(EScreens.ScreenPartyDummy); - } - //TODO: else Message! + CParty.SetPartyMode(_PartyModeInfos[index].PartyModeID); + CGraphics.FadeTo(EScreens.ScreenPartyDummy); } } } \ No newline at end of file diff --git a/Vocaluxe/Screens/CScreenScore.cs b/Vocaluxe/Screens/CScreenScore.cs index b15df9b5..e02f912c 100644 --- a/Vocaluxe/Screens/CScreenScore.cs +++ b/Vocaluxe/Screens/CScreenScore.cs @@ -281,11 +281,7 @@ namespace Vocaluxe.Screens for (int p = 0; p < player.Length; p++) { if (i < 1) - { player[p].ProfileID = points[p].ProfileID; - player[p].Name = points[p].Name; - player[p].Difficulty = points[p].Difficulty; - } player[p].Points += points[p].Points; } } @@ -295,19 +291,15 @@ namespace Vocaluxe.Screens for (int p = 0; p < player.Length; p++) { - if (song != null) + string name = CProfiles.GetPlayerName(player[p].ProfileID, p); + if (song != null && song.IsDuet) { - if (!song.IsDuet) - _Texts[_TextNames[p, CGame.NumPlayer - 1]].Text = player[p].Name; - else if (player[p].LineNr == 0 && song.DuetPart1 != "Part 1") - _Texts[_TextNames[p, CGame.NumPlayer - 1]].Text = player[p].Name + " (" + song.DuetPart1 + ")"; + if (player[p].LineNr == 0 && song.DuetPart1 != "Part 1") + name += " (" + song.DuetPart1 + ")"; else if (player[p].LineNr == 1 && song.DuetPart2 != "Part 2") - _Texts[_TextNames[p, CGame.NumPlayer - 1]].Text = player[p].Name + " (" + song.DuetPart2 + ")"; - else - _Texts[_TextNames[p, CGame.NumPlayer - 1]].Text = player[p].Name; + name += " (" + song.DuetPart2 + ")"; } - else - _Texts[_TextNames[p, CGame.NumPlayer - 1]].Text = player[p].Name; + _Texts[_TextNames[p, CGame.NumPlayer - 1]].Text = name; if (CGame.NumPlayer < (int)_ScreenSettings[_ScreenSettingShortScore].GetValue()) _Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = ((int)Math.Round(player[p].Points)).ToString("0000") + " " + CLanguage.Translate("TR_SCREENSCORE_POINTS"); @@ -316,10 +308,10 @@ namespace Vocaluxe.Screens if (CGame.NumPlayer < (int)_ScreenSettings[_ScreenSettingShortDifficulty].GetValue()) { _Texts[_TextDifficulty[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_GAMEDIFFICULTY") + ": " + - CLanguage.Translate(player[p].Difficulty.ToString()); + CLanguage.Translate(CProfiles.GetDifficulty(player[p].ProfileID).ToString()); } else - _Texts[_TextDifficulty[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(player[p].Difficulty.ToString()); + _Texts[_TextDifficulty[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate(CProfiles.GetDifficulty(player[p].ProfileID).ToString()); if (CGame.NumPlayer < (int)_ScreenSettings[_ScreenSettingShortRating].GetValue()) { _Texts[_TextRatings[p, CGame.NumPlayer - 1]].Text = CLanguage.Translate("TR_SCREENSCORE_RATING") + ": " + @@ -339,7 +331,7 @@ namespace Vocaluxe.Screens _Statics[_StaticPointsBarBG[p, CGame.NumPlayer - 1]].Rect.Y - _Statics[_StaticPointsBar[p, CGame.NumPlayer - 1]].Rect.H; } - if (player[p].ProfileID >= 0 && player[p].ProfileID < CProfiles.NumProfiles) + if (CProfiles.IsProfileIDValid(player[p].ProfileID)) _Statics[_StaticAvatar[p, CGame.NumPlayer - 1]].Texture = CProfiles.Profiles[player[p].ProfileID].Avatar.Texture; } diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index d507ab2f..92a1665b 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -347,18 +347,18 @@ namespace Vocaluxe.Screens for (int p = 0; p < CGame.NumPlayer; p++) { - _SingNotes[_SingBars].SetAlpha(_NoteLines[p], alpha[CGame.Player[p].LineNr * 2]); + _SingNotes[_SingBars].SetAlpha(_NoteLines[p], alpha[CGame.Players[p].LineNr * 2]); if (CConfig.FadePlayerInfo == EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_INFO || CConfig.FadePlayerInfo == EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_ALL) { - _Statics[_StaticAvatars[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Player[p].LineNr * 2]; - _Texts[_TextNames[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Player[p].LineNr * 2]; + _Statics[_StaticAvatars[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].LineNr * 2]; + _Texts[_TextNames[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].LineNr * 2]; } if (CConfig.FadePlayerInfo == EFadePlayerInfo.TR_CONFIG_FADEPLAYERINFO_ALL) { - _Statics[_StaticScores[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Player[p].LineNr * 2]; - _Statics[_StaticAvatars[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Player[p].LineNr * 2]; - _Texts[_TextNames[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Player[p].LineNr * 2]; - _Texts[_TextScores[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Player[p].LineNr * 2]; + _Statics[_StaticScores[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].LineNr * 2]; + _Statics[_StaticAvatars[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].LineNr * 2]; + _Texts[_TextNames[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].LineNr * 2]; + _Texts[_TextScores[p, CGame.NumPlayer - 1]].Alpha = alpha[CGame.Players[p].LineNr * 2]; } } @@ -381,10 +381,10 @@ namespace Vocaluxe.Screens for (int p = 0; p < CGame.NumPlayer; p++) { - if (CGame.Player[p].Points < 10000) - _Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = CGame.Player[p].Points.ToString("0000"); + if (CGame.Players[p].Points < 10000) + _Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = CGame.Players[p].Points.ToString("0000"); else - _Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = CGame.Player[p].Points.ToString("00000"); + _Texts[_TextScores[p, CGame.NumPlayer - 1]].Text = CGame.Players[p].Points.ToString("00000"); } if (_CurrentVideo != -1 && !_FadeOut && CConfig.VideosInSongs == EOffOn.TR_CONFIG_ON) @@ -508,7 +508,7 @@ namespace Vocaluxe.Screens for (int i = 0; i < CGame.NumPlayer; i++) - _SingNotes[_SingBars].Draw(_NoteLines[i], CGame.Player[i].SingLine, i); + _SingNotes[_SingBars].Draw(_NoteLines[i], CGame.Players[i].SingLine, i); _DrawLyricHelper(); @@ -602,7 +602,7 @@ namespace Vocaluxe.Screens { //Save duet-assignment before resetting for (int i = 0; i < duetPlayer.Length; i++) - duetPlayer[i] = CGame.Player[i].LineNr; + duetPlayer[i] = CGame.Players[i].LineNr; } CGame.ResetPlayer(); @@ -631,12 +631,12 @@ namespace Vocaluxe.Screens if (CGame.GetNumSongs() > 1) { for (int i = 0; i < CGame.NumPlayer; i++) - CGame.Player[i].LineNr = (i + 1) % 2; + CGame.Players[i].LineNr = (i + 1) % 2; } else { for (int i = 0; i < CGame.NumPlayer; i++) - CGame.Player[i].LineNr = duetPlayer[i]; + CGame.Players[i].LineNr = duetPlayer[i]; } } _SetDuetLyricsVisibility(song.IsDuet); @@ -764,7 +764,7 @@ namespace Vocaluxe.Screens { for (int j = 0; j < CGame.NumPlayer; j++) { - if (CGame.Player[j].LineNr == i) + if (CGame.Players[j].LineNr == i) _SingNotes[_SingBars].AddLine(_NoteLines[j], line, nr); } @@ -1336,8 +1336,8 @@ namespace Vocaluxe.Screens { for (int i = 0; i < CGame.NumPlayer; i++) { - if (CGame.Player[i].ProfileID > -1 && CProfiles.NumProfiles > CGame.Player[i].ProfileID) - _Statics[_StaticAvatars[i, CGame.NumPlayer - 1]].Texture = CProfiles.Profiles[CGame.Player[i].ProfileID].Avatar.Texture; + if (CProfiles.IsProfileIDValid(CGame.Players[i].ProfileID)) + _Statics[_StaticAvatars[i, CGame.NumPlayer - 1]].Texture = CProfiles.Profiles[CGame.Players[i].ProfileID].Avatar.Texture; else _Statics[_StaticAvatars[i, CGame.NumPlayer - 1]].Visible = false; } @@ -1347,8 +1347,8 @@ namespace Vocaluxe.Screens { for (int i = 0; i < CGame.NumPlayer; i++) { - if (CGame.Player[i].ProfileID > -1 && CProfiles.NumProfiles > CGame.Player[i].ProfileID) - _Texts[_TextNames[i, CGame.NumPlayer - 1]].Text = CProfiles.Profiles[CGame.Player[i].ProfileID].PlayerName; + if (CProfiles.IsProfileIDValid(CGame.Players[i].ProfileID)) + _Texts[_TextNames[i, CGame.NumPlayer - 1]].Text = CProfiles.Profiles[CGame.Players[i].ProfileID].PlayerName; else _Texts[_TextNames[i, CGame.NumPlayer - 1]].Visible = false; } diff --git a/VocaluxeLib/Menu/CNameSelection.cs b/VocaluxeLib/Menu/CNameSelection.cs index 29a2e73e..589cb3d5 100644 --- a/VocaluxeLib/Menu/CNameSelection.cs +++ b/VocaluxeLib/Menu/CNameSelection.cs @@ -484,12 +484,15 @@ namespace VocaluxeLib.Menu for (int i = 0; i < CBase.Profiles.GetProfiles().Length; i++) { bool visible = CBase.Profiles.GetProfiles()[i].Active == EOffOn.TR_CONFIG_ON; - //Show profile only if active - for (int p = 0; p < CBase.Game.GetNumPlayer(); p++) + if (visible) { - //Don't show profile if is selected, but if selected and guest - if (CBase.Game.GetPlayer()[p].ProfileID == i && CBase.Profiles.GetProfiles()[i].GuestProfile == EOffOn.TR_CONFIG_OFF) - visible = false; + //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) + visible = false; + } } if (visible) _VisibleProfiles.Add(i); diff --git a/VocaluxeLib/Menu/CPoints.cs b/VocaluxeLib/Menu/CPoints.cs index 84dab764..b9ff4b41 100644 --- a/VocaluxeLib/Menu/CPoints.cs +++ b/VocaluxeLib/Menu/CPoints.cs @@ -34,8 +34,6 @@ namespace VocaluxeLib.Menu for (int player = 0; player < players.Length; player++) { _Rounds[round, player].ProfileID = players[player].ProfileID; - _Rounds[round, player].Name = players[player].Name; - _Rounds[round, player].Difficulty = players[player].Difficulty; _Rounds[round, player].Points = 0f; _Rounds[round, player].PointsGoldenNotes = 0f; _Rounds[round, player].PointsLineBonus = 0f; @@ -86,13 +84,11 @@ namespace VocaluxeLib.Menu for (int p = 0; p < player.Length; p++) { - player[p].Name = _Rounds[round, p].Name; player[p].Points = _Rounds[round, p].Points; player[p].PointsGoldenNotes = _Rounds[round, p].PointsGoldenNotes; player[p].PointsLineBonus = _Rounds[round, p].PointsLineBonus; player[p].SongID = _Rounds[round, p].SongID; player[p].LineNr = _Rounds[round, p].LineNr; - player[p].Difficulty = _Rounds[round, p].Difficulty; player[p].Medley = _Rounds[round, p].Medley; player[p].Duet = _Rounds[round, p].Duet; player[p].ShortSong = _Rounds[round, p].ShortSong; diff --git a/VocaluxeLib/Menu/IMenu.cs b/VocaluxeLib/Menu/IMenu.cs index 28b278f7..31c3d287 100644 --- a/VocaluxeLib/Menu/IMenu.cs +++ b/VocaluxeLib/Menu/IMenu.cs @@ -209,7 +209,7 @@ namespace VocaluxeLib.Menu { int GetNumPlayer(); void SetNumPlayer(int numPlayer); - SPlayer[] GetPlayer(); + SPlayer[] GetPlayers(); CPoints GetPoints(); float GetMidBeatD(); int GetCurrentBeatD(); @@ -233,6 +233,8 @@ namespace VocaluxeLib.Menu public interface IProfiles { SProfile[] GetProfiles(); + EGameDifficulty GetDifficulty(int profileID); + string GetPlayerName(int profileID, int playerNum = 0); } public interface ISongs diff --git a/VocaluxeLib/Menu/SingNotes/CSingNotes.cs b/VocaluxeLib/Menu/SingNotes/CSingNotes.cs index 573e11b8..03b1a249 100644 --- a/VocaluxeLib/Menu/SingNotes/CSingNotes.cs +++ b/VocaluxeLib/Menu/SingNotes/CSingNotes.cs @@ -301,7 +301,8 @@ namespace VocaluxeLib.Menu.SingNotes float w = _PlayerNotes[n].Rect.W; float h = _PlayerNotes[n].Rect.H; - float dh = h / CBase.Settings.GetNumNoteLines() * (2f - (int)CBase.Game.GetPlayer()[_PlayerNotes[n].PlayerNr].Difficulty) / 4f; + int profileID = CBase.Game.GetPlayers()[_PlayerNotes[n].PlayerNr].ProfileID; + float dh = h / CBase.Settings.GetNumNoteLines() * (2f - (int)CBase.Profiles.GetDifficulty(profileID)) / 4f; float beats = line.LastNoteBeat - line.FirstNoteBeat + 1; @@ -356,7 +357,7 @@ namespace VocaluxeLib.Menu.SingNotes foreach (CParticleEffect perfline in _PlayerNotes[n].PerfectLineTwinkle) perfline.Draw(); - if (singLine == null || singLine.Count == 0 || CBase.Game.GetPlayer()[player].CurrentLine == -1 || singLine.Count <= CBase.Game.GetPlayer()[player].CurrentLine) + if (singLine == null || singLine.Count == 0 || CBase.Game.GetPlayers()[player].CurrentLine == -1 || singLine.Count <= CBase.Game.GetPlayers()[player].CurrentLine) { foreach (CParticleEffect stars in _PlayerNotes[n].GoldenStars) { @@ -366,7 +367,7 @@ namespace VocaluxeLib.Menu.SingNotes return; } - foreach (CNote note in singLine[CBase.Game.GetPlayer()[player].CurrentLine].Notes) + foreach (CNote note in singLine[CBase.Game.GetPlayers()[player].CurrentLine].Notes) { if (note.StartBeat >= line.FirstNoteBeat && note.EndBeat <= line.LastNoteBeat) { @@ -403,13 +404,13 @@ namespace VocaluxeLib.Menu.SingNotes } } - int currentLine = CBase.Game.GetPlayer()[player].SingLine.Count - 1; + int currentLine = CBase.Game.GetPlayers()[player].SingLine.Count - 1; if (currentLine > 0) { - if (CBase.Game.GetPlayer()[player].SingLine[currentLine - 1].PerfectLine) + if (CBase.Game.GetPlayers()[player].SingLine[currentLine - 1].PerfectLine) { _AddPerfectLine(n); - CBase.Game.GetPlayer()[player].SingLine[currentLine - 1].PerfectLine = false; + CBase.Game.GetPlayers()[player].SingLine[currentLine - 1].PerfectLine = false; } } diff --git a/VocaluxeLib/Menu/Structs.cs b/VocaluxeLib/Menu/Structs.cs index 6d0fefbe..76dbc466 100644 --- a/VocaluxeLib/Menu/Structs.cs +++ b/VocaluxeLib/Menu/Structs.cs @@ -242,8 +242,6 @@ namespace VocaluxeLib.Menu public struct SPlayer { public int ProfileID; - public string Name; - public EGameDifficulty Difficulty; public double Points; public double PointsLineBonus; public double PointsGoldenNotes;