Scrolling gui selection?

I was wondering if anyone knew the best way about going about doing this. Right now I have 3 gui textures loaded on the screen and want to create an array for scrolling through my different players abilities. So I want to maybe create an array of 5 different gui textures and the first 3 in the array appear on the screen. Then when you scroll through left or right it changes the abilities on screen. so if you have it displayed as 1,2,3,4,5 and go left it would be ordered 2,3,4,5,1 so now the gui images would be show on screen are 2,3,4.

Another example could be how the game “monster hunter” scroll system works.

You have 3 slots on the screen, and 5 items in the inventory. You can define a function:

DrawItemInSlot (int which_item, int which_slot)

which does all the internal GUI stuff. Now you need a way to control it. First, define a new variable:

int leftmost_index;

Use it to keep information about which item is currently displayed in the leftmost slot. Pushing “right” or left" should tigger this:

leftmost_index++;
if (leftmost_index == 5)
    leftmost_index = 0;

and this:

leftmost_index--;
if (leftmost_index == -1)
    leftmost_index = 4;

respectively.
Now, the loop that actually controls your display:

int i;
int index = leftmost_index;
for (i = 0; i < 3; i++)  // 3 slots
{
    DrawItemInSlot (index, i);
    index++;
    if (index == 5)
        index = 0;
}

Note how index is a local variable, and leftmost_index doesn’t change, unless you push “right” or “left”.

It wouldn’t hurt to use constants instead of literal numbers, in case you decide that you want a different number of slots or items in the future.