fixed profile handling in challenge medley

This commit is contained in:
Alexander Eckart committed 2013-06-16 14:27:06 +02:00
1 parent 622de6ec4d
commit 3e07369767
2 files changed
+55 -136

No files matched your search

@@ -380,12 +380,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
if (_GameState.CurrentRoundNr <= _GameState.Combs.Count) if (_GameState.CurrentRoundNr <= _GameState.Combs.Count)
{ {
_Texts[_TextNextPlayerMessage].Visible = true; _Texts[_TextNextPlayerMessage].Visible = true;
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _GameState.NumPlayerAtOnce; i++) for (int i = 0; i < _GameState.NumPlayerAtOnce; i++)
{ {
int pid = _GameState.Combs[_GameState.CurrentRoundNr - 1].Player[i]; int id = _GameState.ProfileIDs[_GameState.Combs[_GameState.CurrentRoundNr - 1].Player[i]];
_NextPlayerStatics[i].Texture = profiles[_GameState.ProfileIDs[pid]].Avatar.Texture; _NextPlayerStatics[i].Texture = CBase.Profiles.GetAvatar(id);
_NextPlayerTexts[i].Text = profiles[_GameState.ProfileIDs[pid]].PlayerName; _NextPlayerTexts[i].Text = CBase.Profiles.GetPlayerName(id);
_NextPlayerTexts[i].Color = CBase.Theme.GetPlayerColor(i + 1); _NextPlayerTexts[i].Color = CBase.Theme.GetPlayerColor(i + 1);
} }
} }
@@ -492,7 +491,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _UpdateRoundsTable() private void _UpdateRoundsTable()
{ {
CProfile[] profile = CBase.Profiles.GetProfiles();
for (int i = 0; i < _RoundsTable.Count; i++) for (int i = 0; i < _RoundsTable.Count; i++)
{ {
for (int p = 0; p < _RoundsTable[i].TextPlayer.Count; p++) for (int p = 0; p < _RoundsTable[i].TextPlayer.Count; p++)
@@ -503,8 +501,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_RoundsTable[i].TextPlayer[p].Visible = true; _RoundsTable[i].TextPlayer[p].Visible = true;
_RoundsTable[i].TextScores[p].Visible = true; _RoundsTable[i].TextScores[p].Visible = true;
_RoundsTable[i].Number.Text = (i + 1 + _RoundsTableOffset) + ")"; _RoundsTable[i].Number.Text = (i + 1 + _RoundsTableOffset) + ")";
int pID = _GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]]; _RoundsTable[i].TextPlayer[p].Text = CBase.Profiles.GetPlayerName(_GameState.ProfileIDs[_GameState.Combs[i + _RoundsTableOffset].Player[p]]);
_RoundsTable[i].TextPlayer[p].Text = profile[pID].PlayerName;
// ReSharper disable ConvertIfStatementToConditionalTernaryExpression // ReSharper disable ConvertIfStatementToConditionalTernaryExpression
if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset) if ((_GameState.CurrentRoundNr - 1) > i + _RoundsTableOffset)
// ReSharper restore ConvertIfStatementToConditionalTernaryExpression // ReSharper restore ConvertIfStatementToConditionalTernaryExpression
@@ -586,8 +583,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _UpdatePlayerTable() private void _UpdatePlayerTable()
{ {
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _PlayerTable.Count; i++) for (int i = 0; i < _PlayerTable.Count; i++)
{ {
STableRow row = _PlayerTable[i]; STableRow row = _PlayerTable[i];
@@ -602,7 +597,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
row.GamePoints.Visible = true; row.GamePoints.Visible = true;
row.Pos.Text = _GameState.ResultTable[i + _PlayerTableOffset].Position + "."; 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.Rounds.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumPlayed.ToString();
row.Won.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumWon.ToString(); row.Won.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumWon.ToString();
row.SingPoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumSingPoints.ToString(); row.SingPoints.Text = _GameState.ResultTable[i + _PlayerTableOffset].NumSingPoints.ToString();
@@ -658,15 +653,13 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private string _GetPlayerWinString() private string _GetPlayerWinString()
{ {
string s = ""; string s = "";
CProfile[] profiles = CBase.Profiles.GetProfiles();
for (int i = 0; i < _GameState.ResultTable.Count; i++) for (int i = 0; i < _GameState.ResultTable.Count; i++)
{ {
if (_GameState.ResultTable[i].Position == 1) if (_GameState.ResultTable[i].Position == 1)
{ {
if (i > 0) if (i > 0)
s += ", "; s += ", ";
s += profiles[_GameState.ResultTable[i].PlayerID].PlayerName; s += CBase.Profiles.GetPlayerName(_GameState.ResultTable[i].PlayerID);
} }
else else
break; break;
@@ -19,6 +19,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
@@ -61,7 +62,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private bool _SelectingMouseActive; private bool _SelectingMouseActive;
private int _OldMouseX; private int _OldMouseX;
private int _OldMouseY; private int _OldMouseY;
private int _SelectedPlayerNr = -1;
private bool _ButtonsAdded; private bool _ButtonsAdded;
private int _NumPlayer = 4; private int _NumPlayer = 4;
@@ -85,10 +85,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_Data.ScreenNames.ProfileIDs = new List<int>(); _Data.ScreenNames.ProfileIDs = new List<int>();
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose}; _ThemeButtons = new string[] { _ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose };
_Data = new SDataFromScreen(); _Data = new SDataFromScreen();
SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, ProfileIDs = new List<int>()}; SFromScreenNames names = new SFromScreenNames { FadeToConfig = false, ProfileIDs = new List<int>() };
_Data.ScreenNames = names; _Data.ScreenNames = names;
} }
@@ -114,7 +114,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
base.HandleInput(keyEvent); base.HandleInput(keyEvent);
if (keyEvent.KeyPressed) {} if (keyEvent.KeyPressed) { }
else else
{ {
switch (keyEvent.Key) switch (keyEvent.Key)
@@ -147,34 +147,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
base.HandleMouse(mouseEvent); 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 //Check if LeftButton is hold and Select-Mode active
if (mouseEvent.LBH && _SelectingMouseActive) if (mouseEvent.LBH && _SelectingMouseActive)
{ {
@@ -184,47 +156,9 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_OldMouseX = mouseEvent.X; _OldMouseX = mouseEvent.X;
_OldMouseY = mouseEvent.Y; _OldMouseY = mouseEvent.Y;
} }
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar // LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
else if (_SelectingMouseActive) 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 //Reset variables
_SelectingMouseActive = false; _SelectingMouseActive = false;
_ChooseAvatarStatic.Visible = false; _ChooseAvatarStatic.Visible = false;
@@ -313,7 +247,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]); CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]);
b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH); b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH);
b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW); b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW);
CPlayerChooseButton pcb = new CPlayerChooseButton {Button = b, ProfileID = -1}; CPlayerChooseButton pcb = new CPlayerChooseButton { Button = b, ProfileID = -1 };
_PlayerChooseButtons.Add(pcb); _PlayerChooseButtons.Add(pcb);
column++; column++;
if (column >= _PlayerChooseButtonsNumH) if (column >= _PlayerChooseButtonsNumH)
@@ -349,12 +283,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
if ((i + offset * numButtonPlayerChoose) < _PlayerChooseButtonsVisibleProfiles.Count) if ((i + offset * numButtonPlayerChoose) < _PlayerChooseButtonsVisibleProfiles.Count)
{ {
_PlayerChooseButtons[i].ProfileID = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]; int id = _PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose];
_PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].PlayerName; _PlayerChooseButtons[i].ProfileID = id;
_PlayerChooseButtons[i].Button.Texture = _PlayerChooseButtons[i].Button.Text.Text = CBase.Profiles.GetPlayerName(id);
CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture; _PlayerChooseButtons[i].Button.Texture = CBase.Profiles.GetAvatar(id);
_PlayerChooseButtons[i].Button.SelTexture = _PlayerChooseButtons[i].Button.SelTexture = CBase.Profiles.GetAvatar(id);
CBase.Profiles.GetProfiles()[_PlayerChooseButtonsVisibleProfiles[i + offset * numButtonPlayerChoose]].Avatar.Texture;
_PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f); _PlayerChooseButtons[i].Button.Color = new SColorF(1, 1, 1, 0.6f);
_PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1); _PlayerChooseButtons[i].Button.SelColor = new SColorF(1, 1, 1, 1);
_PlayerChooseButtons[i].Button.Enabled = true; _PlayerChooseButtons[i].Button.Enabled = true;
@@ -376,17 +309,15 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _UpdateVisibleProfiles() private void _UpdateVisibleProfiles()
{ {
_PlayerChooseButtonsVisibleProfiles.Clear(); _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; bool visible = false;
//Show profile only if active //Show profile only if active
if (CBase.Profiles.GetProfiles()[i].Active == EOffOn.TR_CONFIG_ON) if (profiles[i].Active == EOffOn.TR_CONFIG_ON)
{ visible = _Data.ScreenNames.ProfileIDs.All(profileID => profileID != profiles[i].ID);
//Don't show profile if is selected
visible = !_Data.ScreenNames.ProfileIDs.Contains(i);
}
if (visible) if (visible)
_PlayerChooseButtonsVisibleProfiles.Add(i); _PlayerChooseButtonsVisibleProfiles.Add(profiles[i].ID);
} }
} }
@@ -411,11 +342,12 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{ {
if (_Data.ScreenNames.ProfileIDs[i] != -1) if (_Data.ScreenNames.ProfileIDs[i] != -1)
{ {
int id = _Data.ScreenNames.ProfileIDs[i];
_PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[i].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[i].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[i].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[i].Texture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].Avatar.Texture; _PlayerDestinationButtons[i].Texture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[i].SelTexture = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].Avatar.Texture; _PlayerDestinationButtons[i].SelTexture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetProfiles()[_Data.ScreenNames.ProfileIDs[i]].PlayerName; _PlayerDestinationButtons[i].Text.Text = CBase.Profiles.GetPlayerName(id);
_PlayerDestinationButtons[i].Enabled = true; _PlayerDestinationButtons[i].Enabled = true;
} }
} }
@@ -444,50 +376,44 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private bool _OnAdd() private bool _OnAdd()
{ {
foreach (CPlayerChooseButton chooseButton in _PlayerChooseButtons) foreach (CPlayerChooseButton button in _PlayerChooseButtons)
{ {
if (chooseButton.Button.Selected && chooseButton.ProfileID != -1) int id = button.ProfileID;
{ if (!button.Button.Selected || id == -1 || _Data.ScreenNames.ProfileIDs.Count >= _NumPlayer)
if (_Data.ScreenNames.ProfileIDs.Count < _NumPlayer) continue;
{ _Data.ScreenNames.ProfileIDs.Add(id);
_Data.ScreenNames.ProfileIDs.Add(chooseButton.ProfileID); int added = _Data.ScreenNames.ProfileIDs.Count - 1;
int added = _Data.ScreenNames.ProfileIDs.Count - 1; _UpdateButtonNext();
_UpdateButtonNext(); //Update texture and name
//Update texture and name _PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f); _PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1); _PlayerDestinationButtons[added].Texture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetAvatar(id);
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture; _PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetPlayerName(id);
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].PlayerName; _PlayerDestinationButtons[added].Enabled = true;
_PlayerDestinationButtons[added].Enabled = true; //Update Tiles-List
//Update Tiles-List _UpdateButtonPlayerChoose();
_UpdateButtonPlayerChoose(); _CheckInteraction();
_CheckInteraction(); return true;
return true;
}
}
} }
return false; return false;
} }
private bool _OnRemove() private void _OnRemove()
{ {
for (int i = 0; i < _PlayerDestinationButtons.Count; i++) for (int i = 0; i < _PlayerDestinationButtons.Count; i++)
{ {
if (_PlayerDestinationButtons[i].Selected) if (!_PlayerDestinationButtons[i].Selected)
{ continue;
if ((i + 1) <= _Data.ScreenNames.ProfileIDs.Count) if ((i + 1) > _Data.ScreenNames.ProfileIDs.Count)
{ continue;
_Data.ScreenNames.ProfileIDs.RemoveAt(i); _Data.ScreenNames.ProfileIDs.RemoveAt(i);
_UpdateButtonNext(); _UpdateButtonNext();
_UpdateButtonPlayerDestination(); _UpdateButtonPlayerDestination();
_UpdateButtonPlayerChoose(); _UpdateButtonPlayerChoose();
_CheckInteraction(); _CheckInteraction();
return true; return;
}
}
} }
return false;
} }
private void _Back() private void _Back()