diff --git a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs index df912434..1c6fa0d8 100644 --- a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs +++ b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs @@ -533,15 +533,7 @@ namespace VocaluxeLib.PartyModes.Challenge private void _SetTeamNames() { - CProfile[] profiles = CBase.Profiles.GetProfiles(); - - if (profiles == null) - { - _ScreenSongOptions.Selection.TeamNames = new string[] {"foo", "bar"}; - return; - } - - if (_GameData.NumPlayerAtOnce < 1 || _GameData.ProfileIDs.Count < _GameData.NumPlayerAtOnce || profiles.Length < _GameData.NumPlayerAtOnce) + if (_GameData.NumPlayerAtOnce < 1 || _GameData.ProfileIDs.Count < _GameData.NumPlayerAtOnce) { _ScreenSongOptions.Selection.TeamNames = new string[] {"foo", "bar"}; return; @@ -554,10 +546,7 @@ namespace VocaluxeLib.PartyModes.Challenge { if (c != null) { - if (_GameData.ProfileIDs[c.Player[i]] < profiles.Length) - _ScreenSongOptions.Selection.TeamNames[i] = profiles[_GameData.ProfileIDs[c.Player[i]]].PlayerName; - else - _ScreenSongOptions.Selection.TeamNames[i] = "foobar"; + _ScreenSongOptions.Selection.TeamNames[i] = CBase.Profiles.GetPlayerName(_GameData.ProfileIDs[c.Player[i]]); } else _ScreenSongOptions.Selection.TeamNames[i] = "foobar"; diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs index d78d9740..60a8bd86 100644 --- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs +++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs @@ -380,12 +380,11 @@ namespace VocaluxeLib.PartyModes.Challenge if (_GameState.CurrentRoundNr <= _GameState.Combs.Count) { _Texts[_TextNextPlayerMessage].Visible = true; - CProfile[] profiles = CBase.Profiles.GetProfiles(); for (int i = 0; i < _GameState.NumPlayerAtOnce; i++) { - int pid = _GameState.Combs[_GameState.CurrentRoundNr - 1].Player[i]; - _NextPlayerStatics[i].Texture = profiles[_GameState.ProfileIDs[pid]].Avatar.Texture; - _NextPlayerTexts[i].Text = profiles[_GameState.ProfileIDs[pid]].PlayerName; + int id = _GameState.ProfileIDs[_GameState.Combs[_GameState.CurrentRoundNr - 1].Player[i]]; + _NextPlayerStatics[i].Texture = CBase.Profiles.GetAvatar(id); + _NextPlayerTexts[i].Text = CBase.Profiles.GetPlayerName(id); _NextPlayerTexts[i].Color = CBase.Theme.GetPlayerColor(i + 1); } } @@ -492,7 +491,6 @@ namespace VocaluxeLib.PartyModes.Challenge private void _UpdateRoundsTable() { - CProfile[] profile = CBase.Profiles.GetProfiles(); for (int i = 0; i < _RoundsTable.Count; i++) { for (int p = 0; p < _RoundsTable[i].TextPlayer.Count; p++) @@ -503,8 +501,7 @@ namespace VocaluxeLib.PartyModes.Challenge _RoundsTable[i].TextPlayer[p].Visible = true; _RoundsTable[i].TextScores[p].Visible = true; _RoundsTable[i].Number.Text = (i + 1 + _RoundsTableOffset) + ")"; - int pID = _GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]]; - _RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName; + _RoundsTable[i].TextPlayer[p].Text = CBase.Profiles.GetPlayerName(_GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]]); // ReSharper disable ConvertIfStatementToConditionalTernaryExpression if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset) // ReSharper restore ConvertIfStatementToConditionalTernaryExpression @@ -586,8 +583,6 @@ namespace VocaluxeLib.PartyModes.Challenge private void _UpdatePlayerTable() { - CProfile[] profiles = CBase.Profiles.GetProfiles(); - for (int i = 0; i < _PlayerTable.Count; i++) { STableRow row = _PlayerTable[i]; @@ -602,7 +597,7 @@ namespace VocaluxeLib.PartyModes.Challenge row.GamePoints.Visible = true; row.Pos.Text = _GameState.ResultTable[i + _PlayerTableOffset].Position + "."; - row.Name.Text = profiles[_GameState.ResultTable[i + _PlayerTableOffset].PlayerID].PlayerName; + row.Name.Text = CBase.Profiles.GetPlayerName(_GameState.ResultTable[i + _PlayerTableOffset].PlayerID); row.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumPlayed.ToString(); row.Won.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumWon.ToString(); row.SingPoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumSingPoints.ToString(); @@ -658,7 +653,6 @@ namespace VocaluxeLib.PartyModes.Challenge private string _GetPlayerWinString() { string s = ""; - CProfile[] profiles = CBase.Profiles.GetProfiles(); for (int i = 0; i < _GameState.ResultTable.Count; i++) { @@ -666,7 +660,7 @@ namespace VocaluxeLib.PartyModes.Challenge { if (i > 0) s += ", "; - s += profiles[_GameState.ResultTable[i].PlayerID].PlayerName; + s += CBase.Profiles.GetPlayerName(_GameState.ResultTable[i].PlayerID); } else break; diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs index 08bf3f0d..289f7a6d 100644 --- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs +++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeNames.cs @@ -62,7 +62,6 @@ namespace VocaluxeLib.PartyModes.Challenge private bool _SelectingMouseActive; private int _OldMouseX; private int _OldMouseY; - private int _SelectedPlayerNr = -1; private bool _ButtonsAdded; private int _NumPlayer = 4; @@ -148,34 +147,6 @@ namespace VocaluxeLib.PartyModes.Challenge { base.HandleMouse(mouseEvent); - /* - //Check if LeftButton is hold and Select-Mode inactive - if (MouseEvent.LBH && !SelectingMouseActive) - { - //Save mouse-coords - OldMouseX = MouseEvent.X; - OldMouseY = MouseEvent.Y; - //Check if mouse if over tile - for (int i = 0; i < PlayerChooseButtons.Count; i++) - { - if (PlayerChooseButtons[i].Button.Selected) - { - SelectedPlayerNr = PlayerChooseButtons[i].ProfileID; - if (SelectedPlayerNr != -1) - { - //Activate mouse-selecting - SelectingMouseActive = true; - //Update of Drag/Drop-Texture - chooseAvatarStatic.Visible = true; - chooseAvatarStatic.Rect = PlayerChooseButtons[i].Button.Rect; - chooseAvatarStatic.Rect.Z = -100; - chooseAvatarStatic.Color = new SColorF(1, 1, 1, 1); - chooseAvatarStatic.Texture = CBase.Profiles.GetProfiles()[SelectedPlayerNr].Avatar.Texture; - } - } - } - }*/ - //Check if LeftButton is hold and Select-Mode active if (mouseEvent.LBH && _SelectingMouseActive) { @@ -188,44 +159,6 @@ namespace VocaluxeLib.PartyModes.Challenge // LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar else if (_SelectingMouseActive) { - //Check if really a player was selected - if (_SelectedPlayerNr != -1) - { - //Foreach Drop-Area - for (int i = 0; i < _PlayerDestinationButtons.Count; i++) - { - //Check first, if area is "active" - if (_PlayerDestinationButtons[i].Visible) - { - //Check if Mouse is in area - if (CHelper.IsInBounds(_PlayerDestinationButtons[i].Rect, mouseEvent)) - { - int added = -1; - //Add Player-ID to list. - if (_Data.ScreenNames.ProfileIDs.Count < (i + 1)) - { - _Data.ScreenNames.ProfileIDs.Add(_SelectedPlayerNr); - added = _Data.ScreenNames.ProfileIDs.Count - 1; - } - else if (_Data.ScreenNames.ProfileIDs.Count >= (i + 1)) - { - _Data.ScreenNames.ProfileIDs[i] = _SelectedPlayerNr; - added = i; - } - _UpdateButtonNext(); - //Update texture and name - _PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); - _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); - _PlayerDestinationButtons[added].Texture = _ChooseAvatarStatic.Texture; - _PlayerDestinationButtons[added].SelTexture = _ChooseAvatarStatic.Texture; - _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_SelectedPlayerNr].PlayerName; - //Update Tiles-List - _UpdateButtonPlayerChoose(); - } - } - } - _SelectedPlayerNr = -1; - } //Reset variables _SelectingMouseActive = false; _ChooseAvatarStatic.Visible = false; @@ -350,12 +283,11 @@ namespace VocaluxeLib.PartyModes.Challenge { if ((i + offset * numButtonPlayerChoose) < _PlayerChooseButtonsVisibleProfiles.Count) { - _PlayerChooseButtons[i].ProfileID = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]; - _PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].PlayerName; - _PlayerChooseButtons[i].Button.Texture = - CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture; - _PlayerChooseButtons[i].Button.SelTexture = - CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture; + int id = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]; + _PlayerChooseButtons[i].ProfileID = id; + _PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetPlayerName(id); + _PlayerChooseButtons[i].Button.Texture = CBase.Profiles.GetAvatar(id); + _PlayerChooseButtons[i].Button.SelTexture = CBase.Profiles.GetAvatar(id); _PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f); _PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1); _PlayerChooseButtons[i].Button.Enabled = true; @@ -377,14 +309,15 @@ namespace VocaluxeLib.PartyModes.Challenge private void _UpdateVisibleProfiles() { _PlayerChooseButtonsVisibleProfiles.Clear(); - for (int i = 0; i < CBase.Profiles.GetProfiles().Length; i++) + Profile.CProfile[] profiles = CBase.Profiles.GetProfiles(); + for (int i = 0; i < profiles.Length; i++) { bool visible = false; //Show profile only if active - if (CBase.Profiles.GetProfiles()[i].Active == EOffOn.TR_CONFIG_ON) - visible = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != i); + if (profiles[i].Active == EOffOn.TR_CONFIG_ON) + visible = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != profiles[i].ID); if (visible) - _PlayerChooseButtonsVisibleProfiles.Add(i); + _PlayerChooseButtonsVisibleProfiles.Add(profiles[i].ID); } } @@ -409,11 +342,12 @@ namespace VocaluxeLib.PartyModes.Challenge { if (_Data.ScreenNames.ProfileIDs[i] != -1) { + int id = _Data.ScreenNames.ProfileIDs[i]; _PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[i].SelColor = new SColorF(1, 1, 1, 1); - _PlayerDestinationButtons[i].Texture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].Avatar.Texture; - _PlayerDestinationButtons[i].SelTexture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].Avatar.Texture; - _PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].PlayerName; + _PlayerDestinationButtons[i].Texture = CBase.Profiles.GetAvatar(id); + _PlayerDestinationButtons[i].SelTexture = CBase.Profiles.GetAvatar(id); + _PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetPlayerName(id); _PlayerDestinationButtons[i].Enabled = true; } } @@ -444,17 +378,18 @@ namespace VocaluxeLib.PartyModes.Challenge { foreach (CPlayerChooseButton button in _PlayerChooseButtons) { - if (!button.Button.Selected || button.ProfileID == -1 || _Data.ScreenNames.ProfileIDs.Count >= _NumPlayer) + int id = button.ProfileID; + if (!button.Button.Selected || id == -1 || _Data.ScreenNames.ProfileIDs.Count >= _NumPlayer) continue; - _Data.ScreenNames.ProfileIDs.Add(button.ProfileID); + _Data.ScreenNames.ProfileIDs.Add(id); int added = _Data.ScreenNames.ProfileIDs.Count - 1; _UpdateButtonNext(); //Update texture and name _PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); - _PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[button.ProfileID].Avatar.Texture; - _PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[button.ProfileID].Avatar.Texture; - _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[button.ProfileID].PlayerName; + _PlayerDestinationButtons[added].Texture = CBase.Profiles.GetAvatar(id); + _PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetAvatar(id); + _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetPlayerName(id); _PlayerDestinationButtons[added].Enabled = true; //Update Tiles-List _UpdateButtonPlayerChoose(); diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index cd0ad057..61a997ea 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -561,6 +561,11 @@ namespace Vocaluxe.Base { return CProfiles.GetPlayerName(profileID, playerNum); } + + public CTexture GetAvatar(int profileID) + { + return CProfiles.GetAvatarTextureFromProfile(profileID); + } } class CBrecord : IRecording diff --git a/VocaluxeLib/IBasic.cs b/VocaluxeLib/IBasic.cs index 54860c5b..2c85ba9d 100644 --- a/VocaluxeLib/IBasic.cs +++ b/VocaluxeLib/IBasic.cs @@ -197,6 +197,7 @@ namespace VocaluxeLib CProfile[] GetProfiles(); EGameDifficulty GetDifficulty(int profileID); string GetPlayerName(int profileID, int playerNum = 0); + CTexture GetAvatar(int profileID); } public interface ISongs