From ddee8f5fae1bae7796d94fb9ec2a276134c2e6a7 Mon Sep 17 00:00:00 2001 From: Florian Kuepper Date: Thu, 12 Apr 2012 11:42:48 +0200 Subject: [PATCH] Change behavior on ScreenNames: Only show active profiles, you could select every profile only one time, except guest-profiles. --- Vocaluxe/Menu/CNameSelection.cs | 55 +++++++++++++++++++++++++++++--- Vocaluxe/Screens/CScreenNames.cs | 20 +++++++++--- 2 files changed, 66 insertions(+), 9 deletions(-) diff --git a/Vocaluxe/Menu/CNameSelection.cs b/Vocaluxe/Menu/CNameSelection.cs index 526e9277..46da60e4 100644 --- a/Vocaluxe/Menu/CNameSelection.cs +++ b/Vocaluxe/Menu/CNameSelection.cs @@ -73,6 +73,8 @@ namespace Vocaluxe.Menu int _player = -1; + private List VisibleProfiles; + public CNameSelection() { @@ -81,6 +83,8 @@ namespace Vocaluxe.Menu _TextureEmptyTile = CTheme.GetSkinTexture(_Theme.TextureEmptyTileName); _Tiles = new List(); + + VisibleProfiles = new List(); } public void Init() @@ -97,6 +101,8 @@ namespace Vocaluxe.Menu } } + UpdateVisibleProfiles(); + UpdateList(0); } @@ -361,22 +367,35 @@ namespace Vocaluxe.Menu } } + public void UpdateList() + { + UpdateVisibleProfiles(); + if (_Tiles.Count * (_Offset + 1) - VisibleProfiles.Count >= _Tiles.Count * _Offset) + { + UpdateList(_Offset - 1); + } + else + { + UpdateList(_Offset); + } + } + public void UpdateList(int offset) { if (offset < 0) offset = 0; - if ( _Tiles.Count * (offset + 1) - CProfiles.Profiles.Length < _Tiles.Count) + if ( _Tiles.Count * (offset + 1) - VisibleProfiles.Count < _Tiles.Count) { for (int i = 0; i < _Tiles.Count; i++) { - if ((i + offset * _Tiles.Count) < CProfiles.Profiles.Length) + if ((i + offset * _Tiles.Count) < VisibleProfiles.Count) { - _Tiles[i].Avatar.Texture = CProfiles.Profiles[i + offset * _Tiles.Count].Avatar.Texture; + _Tiles[i].Avatar.Texture = CProfiles.Profiles[VisibleProfiles[i + offset * _Tiles.Count]].Avatar.Texture; _Tiles[i].Avatar.Color = new SColorF(1, 1, 1, 1); - _Tiles[i].Name.Text = CProfiles.Profiles[i + offset * _Tiles.Count].PlayerName; - _Tiles[i].PlayerNr = i + offset * _Tiles.Count; + _Tiles[i].Name.Text = CProfiles.Profiles[VisibleProfiles[i + offset * _Tiles.Count]].PlayerName; + _Tiles[i].PlayerNr = VisibleProfiles[i + offset * _Tiles.Count]; } else { @@ -449,6 +468,32 @@ namespace Vocaluxe.Menu LoadTextures(); } + private void UpdateVisibleProfiles() + { + VisibleProfiles.Clear(); + for (int i = 0; i < CProfiles.Profiles.Length; i++) + { + bool visible = false; + //Show profile only if active + if (CProfiles.Profiles[i].Active == EOffOn.TR_CONFIG_ON) + { + visible = true; + } + for (int p = 0; p < CGame.NumPlayer; p++) + { + //Don't show profile if is selected, but if selected and guest + if (CGame.Player[p].ProfileID == i && CProfiles.Profiles[i].GuestProfile == EOffOn.TR_CONFIG_OFF) + { + visible = false; + } + } + if (visible) + { + VisibleProfiles.Add(i); + } + } + } + #region ThemeEdit public void MoveElement(int stepX, int stepY) { diff --git a/Vocaluxe/Screens/CScreenNames.cs b/Vocaluxe/Screens/CScreenNames.cs index 9f61948c..56aeafa6 100644 --- a/Vocaluxe/Screens/CScreenNames.cs +++ b/Vocaluxe/Screens/CScreenNames.cs @@ -111,18 +111,20 @@ namespace Vocaluxe.Screens case Keys.Add: if (CConfig.NumPlayer + 1 <= CSettings.MaxNumPlayer) { - CConfig.NumPlayer++; - SelectSlides[htSelectSlides(SelectSlidePlayerNumber)].Selection = CConfig.NumPlayer - 1; + SelectSlides[htSelectSlides(SelectSlidePlayerNumber)].Selection = CConfig.NumPlayer; UpdatePlayerNumber(); + //Update Tiles-List + NameSelections[htNameSelections(NameSelection)].UpdateList(); } break; case Keys.Subtract: if (CConfig.NumPlayer - 1 > 0) { - CConfig.NumPlayer--; - SelectSlides[htSelectSlides(SelectSlidePlayerNumber)].Selection = CConfig.NumPlayer - 1; + SelectSlides[htSelectSlides(SelectSlidePlayerNumber)].Selection = CConfig.NumPlayer - 2; UpdatePlayerNumber(); + //Update Tiles-List + NameSelections[htNameSelections(NameSelection)].UpdateList(); } break; } @@ -150,6 +152,8 @@ namespace Vocaluxe.Screens Texts[htTexts(TextPlayer[selectingKeyboardPlayerNr-1])].Text = CProfiles.Profiles[SelectedPlayerNr].PlayerName; //Update profile-warning CheckPlayers(); + //Update Tiles-List + NameSelections[htNameSelections(NameSelection)].UpdateList(); } //Reset all values selectingKeyboardPlayerNr = 0; @@ -271,6 +275,8 @@ namespace Vocaluxe.Screens selectingKeyboardPlayerNr = 0; selectingKeyboardActive = false; NameSelections[htNameSelections(NameSelection)].KeyboardSelection(false, -1); + //Update Tiles-List + NameSelections[htNameSelections(NameSelection)].UpdateList(); break; } @@ -414,6 +420,8 @@ namespace Vocaluxe.Screens Texts[htTexts(TextPlayer[i])].Text = CProfiles.Profiles[SelectedPlayerNr].PlayerName; //Update profile-warning CheckPlayers(); + //Update Tiles-List + NameSelections[htNameSelections(NameSelection)].UpdateList(); } } } @@ -447,6 +455,8 @@ namespace Vocaluxe.Screens if (!processed) UpdatePlayerNumber(); + //Update Tiles-List + NameSelections[htNameSelections(NameSelection)].UpdateList(); } if (MouseEvent.RB) @@ -469,6 +479,8 @@ namespace Vocaluxe.Screens Texts[htTexts(TextPlayer[i])].Text = CLanguage.Translate("TR_SCREENNAMES_PLAYER") + " " + (i+1).ToString(); //Update profile-warning CheckPlayers(); + //Update Tiles-List + NameSelections[htNameSelections(NameSelection)].UpdateList(); exit = false; } }