I've made a couple of alterations to GUIFilmstripControl.cs to allow for control over scrollOffset through skin files. This was already implemented for list and thumb control.
I didn't know where to put the validation code to check if the supplied property through the skin file is valid. Valid should be something like no more than half the number if items on screen. So i've put it on both left and right functions.
Please let me know what you thing about this feature.
Sambal.
I didn't know where to put the validation code to check if the supplied property through the skin file is valid. Valid should be something like no more than half the number if items on screen. So i've put it on both left and right functions.
Code:
[COLOR="Red"][XMLSkinElement("scrollOffset")] protected int _scrollStartOffset = 0; // this is the offset from the first or last element on screen when scrolling should start[/COLOR]
...
void OnLeft()
{
Action action = new Action();
action.wID = Action.ActionType.ACTION_MOVE_LEFT;
if (_listType == GUIListControl.ListType.CONTROL_LIST)
{
[COLOR="Red"]//If scrolloffset larger than half the nr of items make scrolloffset that nr
int maxScrollOffset = _columns / 2;
if (_scrollStartOffset > maxScrollOffset)
_scrollStartOffset = maxScrollOffset;[/COLOR]
if (_scrollingLeft)
{
_scrollCounter = 0;
_scrollingLeft = false;
_offset--;
int iPage = _offset / (_columns);
if ((_offset % (_columns)) != 0) iPage++;
if (_upDownControl != null) _upDownControl.Value = iPage + 1;
}
[COLOR="Red"] if (_cursorX > 0 && (_cursorX > _scrollStartOffset || _offset == 0))[/COLOR]
{
_cursorX--;
}
[COLOR="Red"] else if (_cursorX <= _scrollStartOffset && _offset != 0)[/COLOR]
{
_scrollCounter = _itemWidth;
_scrollingLeft = true;
}
else
{
base.OnAction(action);
}
OnSelectionChanged();
}
else if (_upDownControl != null)
{
if (_upDownControl.SelectedButton == GUISpinControl.SpinSelect.SPIN_BUTTON_DOWN)
{
_upDownControl.Focus = false;
_listType = GUIListControl.ListType.CONTROL_LIST;
this.Focus = true;
}
else
{
_upDownControl.OnAction(action);
}
if (!_upDownControl.Focus)
{
_listType = GUIListControl.ListType.CONTROL_LIST;
}
OnSelectionChanged();
}
}
...
void OnRight()
{
Action action = new Action();
action.wID = Action.ActionType.ACTION_MOVE_RIGHT;
if (_listType == GUIListControl.ListType.CONTROL_LIST)
{
[COLOR="Red"] //If scrolloffset larger than half the nr of items make scrolloffset that nr
int maxScrollOffset = _columns / 2;
if (_scrollStartOffset > maxScrollOffset)
_scrollStartOffset = maxScrollOffset;
[/COLOR]
if (_scrollingRight)
{
_scrollingRight = false;
_offset++;
int iPage = _offset / (_columns);
if ((_offset % (_columns)) != 0) iPage++;
if (_upDownControl != null) _upDownControl.Value = iPage + 1;
}
[COLOR="Red"] // If cursor offset from edge or if left space smaller than scrollStartOffset
if (_cursorX + 1 == _columns - _scrollStartOffset && _listItems.Count - (_offset + _cursorX + 1) > _scrollStartOffset)
[/COLOR] {
_offset++;
if (!ValidItem(_cursorX))
{
_offset--;
}
else
{
_offset--;
_scrollCounter = _itemWidth;
_scrollingRight = true;
}
OnSelectionChanged();
return;
}
else
{
if (ValidItem(_cursorX + 1))
{
_cursorX++;
}
OnSelectionChanged();
}
}
else if (_upDownControl != null)
{
if (_upDownControl.SelectedButton == GUISpinControl.SpinSelect.SPIN_BUTTON_UP)
{
_upDownControl.Focus = false;
_listType = GUIListControl.ListType.CONTROL_LIST;
this.Focus = true;
}
else
{
_upDownControl.OnAction(action);
if (!_upDownControl.Focus)
{
base.OnAction(action);
}
}
OnSelectionChanged();
}
}
Please let me know what you thing about this feature.
Sambal.