Name Selection Improvements
Fix: Infinite scroll bug with mousewheel Change: Offset by row instead of page
This commit is contained in:
1 parent
9e0f715fce
commit
d810aa8ca4
1 file changed
+20
-28
@@ -15,6 +15,7 @@
|
||||
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Serialization;
|
||||
@@ -192,7 +193,7 @@ namespace VocaluxeLib.Menu
|
||||
int offset = Offset;
|
||||
UpdateList(Offset + 1);
|
||||
if (offset != Offset)
|
||||
_ActualSelection = 0;
|
||||
_ActualSelection -= _Theme.Tiles.NumW - 1;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -202,7 +203,7 @@ namespace VocaluxeLib.Menu
|
||||
else if (Offset > 0)
|
||||
{
|
||||
UpdateList(Offset - 1);
|
||||
_ActualSelection = _Tiles.Count - 1;
|
||||
_ActualSelection += _Theme.Tiles.NumW - 1;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -212,7 +213,6 @@ namespace VocaluxeLib.Menu
|
||||
else if (Offset > 0)
|
||||
{
|
||||
UpdateList(Offset - 1);
|
||||
_ActualSelection += _Tiles.Count - _Theme.Tiles.NumW;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -226,27 +226,20 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
int offset = Offset;
|
||||
UpdateList(Offset + 1);
|
||||
if (offset != Offset)
|
||||
}
|
||||
if (_Tiles[_ActualSelection].ProfileID == -1)
|
||||
{
|
||||
_ActualSelection = _Tiles.Count - _Theme.Tiles.NumW;
|
||||
while(_Tiles[_ActualSelection + 1].ProfileID != -1)
|
||||
{
|
||||
_ActualSelection = _ActualSelection - _Tiles.Count + _Theme.Tiles.NumW;
|
||||
if (_Tiles[_ActualSelection].ProfileID == -1)
|
||||
{
|
||||
for (int i = _Tiles.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (_Tiles[i].ProfileID != -1)
|
||||
{
|
||||
_ActualSelection = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ActualSelection++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (Offset * _Tiles.Count + _ActualSelection < _VisibleProfiles.Count)
|
||||
Selection = _VisibleProfiles[Offset * _Tiles.Count + _ActualSelection];
|
||||
if (Offset * _Theme.Tiles.NumW + _ActualSelection < _VisibleProfiles.Count)
|
||||
Selection = _VisibleProfiles[Offset * _Theme.Tiles.NumW + _ActualSelection];
|
||||
else
|
||||
Selection = -1;
|
||||
}
|
||||
@@ -255,12 +248,12 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
for (int i = 0; i < _Tiles.Count; i++)
|
||||
{
|
||||
if (CHelper.IsInBounds(_Tiles[i].Avatar.Rect, mevent))
|
||||
if (CHelper.IsInBounds(_Tiles[i].Avatar.Rect, mevent) && _Tiles[i].ProfileID != -1)
|
||||
{
|
||||
_ActualSelection = i;
|
||||
|
||||
if (Offset * _Tiles.Count + _ActualSelection < _VisibleProfiles.Count)
|
||||
Selection = _VisibleProfiles[Offset * _Tiles.Count + _ActualSelection];
|
||||
if (Offset * _Theme.Tiles.NumW + _ActualSelection < _VisibleProfiles.Count)
|
||||
Selection = _VisibleProfiles[Offset * _Theme.Tiles.NumW + _ActualSelection];
|
||||
else
|
||||
Selection = -1;
|
||||
}
|
||||
@@ -297,7 +290,7 @@ namespace VocaluxeLib.Menu
|
||||
public void UpdateList()
|
||||
{
|
||||
_UpdateVisibleProfiles();
|
||||
if (_Tiles.Count * (Offset + 1) - _VisibleProfiles.Count >= _Tiles.Count * Offset)
|
||||
if (_Theme.Tiles.NumW * (Offset + 1) - _VisibleProfiles.Count >= _Theme.Tiles.NumW * Offset)
|
||||
UpdateList(Offset - 1);
|
||||
else
|
||||
UpdateList(Offset);
|
||||
@@ -305,17 +298,16 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public void UpdateList(int offset)
|
||||
{
|
||||
if (offset < 0)
|
||||
offset = 0;
|
||||
offset = offset.Clamp(0, (int)Math.Ceiling((decimal)(_VisibleProfiles.Count - _Tiles.Count) / _Theme.Tiles.NumW));
|
||||
|
||||
for (int i = 0; i < _Tiles.Count; i++)
|
||||
{
|
||||
if ((i + offset * _Tiles.Count) < _VisibleProfiles.Count)
|
||||
if ((i + offset * _Theme.Tiles.NumW) < _VisibleProfiles.Count)
|
||||
{
|
||||
_Tiles[i].Avatar.Texture = CBase.Profiles.GetAvatar(_VisibleProfiles[i + offset * _Tiles.Count]);
|
||||
_Tiles[i].Avatar.Texture = CBase.Profiles.GetAvatar(_VisibleProfiles[i + offset * _Theme.Tiles.NumW]);
|
||||
_Tiles[i].Avatar.Color = new SColorF(1, 1, 1, 1);
|
||||
_Tiles[i].Name.Text = CBase.Profiles.GetPlayerName(_VisibleProfiles[i + offset * _Tiles.Count]);
|
||||
_Tiles[i].ProfileID = _VisibleProfiles[i + offset * _Tiles.Count];
|
||||
_Tiles[i].Name.Text = CBase.Profiles.GetPlayerName(_VisibleProfiles[i + offset * _Theme.Tiles.NumW]);
|
||||
_Tiles[i].ProfileID = _VisibleProfiles[i + offset * _Theme.Tiles.NumW];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user