From 148e92a416147ac93886eb5cde64d127c2136d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Fri, 11 Jan 2013 13:44:05 +0100 Subject: [PATCH] Fixed crash on names-screen. --- VocaluxeLib/Menu/CNameSelection.cs | 37 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/VocaluxeLib/Menu/CNameSelection.cs b/VocaluxeLib/Menu/CNameSelection.cs index 69ad43f5..4ca22c33 100644 --- a/VocaluxeLib/Menu/CNameSelection.cs +++ b/VocaluxeLib/Menu/CNameSelection.cs @@ -360,7 +360,10 @@ namespace Vocaluxe.Menu break; } - Selection = VisibleProfiles[_Offset * _Tiles.Count + _actualSelection]; + if (_Offset * _Tiles.Count + _actualSelection < VisibleProfiles.Count) + Selection = VisibleProfiles[_Offset * _Tiles.Count + _actualSelection]; + else + Selection = -1; } public void KeyboardSelection(bool active, int player) @@ -408,28 +411,24 @@ namespace Vocaluxe.Menu if (offset < 0) offset = 0; - if ( _Tiles.Count * (offset + 1) - VisibleProfiles.Count < _Tiles.Count) + for (int i = 0; i < _Tiles.Count; i++) { - - for (int i = 0; i < _Tiles.Count; i++) + if ((i + offset * _Tiles.Count) < VisibleProfiles.Count) { - if ((i + offset * _Tiles.Count) < VisibleProfiles.Count) - { - _Tiles[i].Avatar.Texture = _Base.Profiles.GetProfiles()[VisibleProfiles[i + offset * _Tiles.Count]].Avatar.Texture; - _Tiles[i].Avatar.Color = new SColorF(1, 1, 1, 1); - _Tiles[i].Name.Text = _Base.Profiles.GetProfiles()[VisibleProfiles[i + offset * _Tiles.Count]].PlayerName; - _Tiles[i].PlayerNr = VisibleProfiles[i + offset * _Tiles.Count]; - } - else - { - _Tiles[i].Avatar.Texture = _TextureEmptyTile; - _Tiles[i].Avatar.Color = ColorEmptyTile; - _Tiles[i].Name.Text = ""; - _Tiles[i].PlayerNr = -1; - } + _Tiles[i].Avatar.Texture = _Base.Profiles.GetProfiles()[VisibleProfiles[i + offset * _Tiles.Count]].Avatar.Texture; + _Tiles[i].Avatar.Color = new SColorF(1, 1, 1, 1); + _Tiles[i].Name.Text = _Base.Profiles.GetProfiles()[VisibleProfiles[i + offset * _Tiles.Count]].PlayerName; + _Tiles[i].PlayerNr = VisibleProfiles[i + offset * _Tiles.Count]; + } + else + { + _Tiles[i].Avatar.Texture = _TextureEmptyTile; + _Tiles[i].Avatar.Color = ColorEmptyTile; + _Tiles[i].Name.Text = ""; + _Tiles[i].PlayerNr = -1; } - _Offset = offset; } + _Offset = offset; } public bool isOverTile(MouseEvent mevent)