Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Gurok on Wed 26/02/2014 23:40:29

Title: How do I make scrollbars not look terrible?
Post by: Gurok on Wed 26/02/2014 23:40:29
I am working on save and load GUIs at the moment and I'd like to know what other people do to avoid using those terrible built-in scrollbars. At the moment, I am thinking of doing this:

(http://i.imgur.com/Gy0uFjh.png)

But I'd like to know if somebody has implemented proper scrollbars as a module that I can just use.
Title: Re: How do I make scrollbars not look terrible?
Post by: Ghost on Thu 27/02/2014 00:09:14
Looking at your mock-up I had to smile; I am using a very similar setup in a WiP of mine:

It's really simple actually. You just need two buttons that manipulate a listbox (and the listbox must have its scrollbars hidden)- even more, all you ever do is set the list's TopItem.
The 9Verb template that comes with AGS uses the same approach, so if you are looking for specific code, it's already in your copy of AGS.

My stripped-down code for both buttons:

Top of GlobalScript:
Code (ags) Select

int iFileTracker = 0; // variable to iterate savegame box
int cMaxSaves = 100; // how many saves are allowed, at max
int cMaxFiles = 15; // mow many saves can be shown at once in the file list


Code (ags) Select

function btnFilesScrollUp_OnClick(GUIControl *control, MouseButton button)
{
lstFiles.SelectedIndex = -1;

if (iFileTracker < 5)
iFileTracker = 0;
else
iFileTracker -= 5;

lstFiles.TopItem = iFileTracker;
}

// scroll file list down
function btnFilesScrollDown_OnClick(GUIControl *control, MouseButton button)
{
lstFiles.SelectedIndex=-1;

// we advance the list by five...
iFileTracker += 5;
// then we check if there would be "empty fields" in the list
// if that is the case, we manually calculate the stopsaveitem
if (iFileTracker > cMaxSaves - cMaxFiles)
iFileTracker = cMaxSaves - cMaxFiles;
lstFiles.TopItem=iFileTracker;
}


Result:
(http://i.imgur.com/rrOqoDU.png)
Title: Re: How do I make scrollbars not look terrible?
Post by: Gurok on Thu 27/02/2014 09:15:56
Thanks for the snippet, Ghost. Now that I know, I'll just check out the 9Verb template if I get stuck. Your save GUI looks great, by the way.