Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Kangourou pas sympa on Mon 23/03/2009 18:55:51

Title: Smooth scroll in inventory ?
Post by: Kangourou pas sympa on Mon 23/03/2009 18:55:51
Hello, I searched on the forum but I found nothing.
I'm trying to make an horizontal inventory, and I want to know if it's possible to smooth the scroll ?
Maybe you know a module, or a script ?
I prefer to tell you I'm totally noob in scripting, I'm an "illustrator", and I try to make my GUI before to continue my drawings.
In advance, thank you.
Title: Re: Smooth scroll in inventory ?
Post by: Khris on Mon 23/03/2009 20:17:28
This is possible, but only with semi-advanced scripting:
-create a screenshot, crop it to invwindow + additional row height
-draw additional item row
-use a second DynamicSprite to display a cropped version of the first one on an additional GUI, moving the section down
-in the background scroll the actual invwindow by one row, then change the GUI back to being not visible
Title: Re: Smooth scroll in inventory ?
Post by: Kangourou pas sympa on Tue 24/03/2009 09:26:45
Hello,
I thank you for your answer,
But I'll be honest, I understood nothing.
Maybe it's because of my english wich sucks,
But most probably, I wanted to be faster than my knowledges allowed me.
So, I repeat, thank you, I'll keep this topic in my memory and in my bookmarks, and I'll come back later, when I'll be able to understand.
Title: Re: Smooth scroll in inventory ?
Post by: magintz on Tue 24/03/2009 10:55:15
You can't have a smooth scrolling inventory. You have to work around it by having a smooth scrolling image of the inventory. Obviously the inventory will be changing every time a player takes or loses an item so to keep it up to date you take a screenshot, within the game using an AGS function (read the manual). This screenshot can then be edited and modified so it is just a screenshot covering the inventory window which you should now be able to make scroll smoothly using DynamicSprite (again, best place for this is to check the manual).
Title: Re: Smooth scroll in inventory ?
Post by: Kangourou pas sympa on Tue 24/03/2009 11:39:42
Thanks for your answer,
So if I understand and please tell me if I'm wrong,
It wont be possible to stop the scroll in the middle of a column ?
Thanks for your help, I think I'm starting to understand the theory ;)
Title: Re: Smooth scroll in inventory ?
Post by: SSH on Tue 24/03/2009 13:32:29
Another way to do it would be to have the invetory hidden behind another GUI (or GUI control) which sits over the edges of it. Then you can adjust the X/Y co-ordinates of the inv gui to do the scroll, then once in the new position you jump to the next inv position and move the gui back to its original co-ordinates.
Title: Re: Smooth scroll in inventory ?
Post by: Kangourou pas sympa on Tue 24/03/2009 15:58:31
Hi,
Thank you for this another way, but if I have understood, it won't work in my project,
Because my inventory is transparent.
Here a picture:
(http://img24.imageshack.us/img24/526/inventairerzm.jpg)
So item will be superposed with the inventory icon, no ?
Title: Re: Smooth scroll in inventory ?
Post by: SSH on Tue 24/03/2009 17:22:51
Well, you can also use the GUI clipping to avoid that problem. Here's a quick bit of code:


function goInvUp_OnClick(GUIControl *control, MouseButton button)
{
    if (goInv.TopItem>0) {
      goInv.TopItem--;
      goInv.X= -goInv.ItemWidth;
      while (goInv.X<0) {
        goInv.X++;
        Wait(1);
      }
    }
}



function goInvDown_OnClick(GUIControl *control, MouseButton button)
{
    if (goInv.TopItem<(goInv.ItemCount-1)) {
      //goInv.ScrollUp();
      goInv.X=0;
      while (goInv.X> -goInv.ItemWidth) {
        goInv.X--;
        Wait(1);
      }
      goInv.TopItem++;
      goInv.X=0;
    }
}


You can download the example AGS project here (http://ssh.me.uk/dev/smoothinv.zip). If you prefer a vertical scroll, it just means changing width/height and X/Y and making the inv window two inv items deep instead of two wide as in my example. I assume you're only showing one inv item at one time based on your picture. More than one may require some more effort, but the principle should be similar.

Oh, and its now a module (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=37277)
Title: Re: Smooth scroll in inventory ?
Post by: Kangourou pas sympa on Thu 26/03/2009 16:55:49
Oh my,
Thank you a lot,
I'm trying to adapt this to my project (with no need to clic to scroll),
I'll show you if I get it. :)