Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: bx83 on Sat 07/08/2021 03:37:21

Title: How to scroll up/down multiple rows in inventory?
Post by: bx83 on Sat 07/08/2021 03:37:21
I've previously used the MouseWheelNorth/South buttons to do this, in which it scrolls 1 page at a time.

Using the same command (invCustomInv.ScrollDown()/Up()) with a key (I'm using eKeyPageUp/Down) it only scrolls 1 row at a time (out of the 4 visible rows).

Is there any way to have the invWindow scroll up/down multiple rows?
Title: Re: How to scroll up/down multiple rows in inventory?
Post by: Crimson Wizard on Sat 07/08/2021 04:20:31
Quote from: bx83 on Sat 07/08/2021 03:37:21
Is there any way to have the invWindow scroll up/down multiple rows?

Formally speaking, you may just call the scroll function multiple times.

Not sure what you are trying to accomplish though. Do you want it to scroll all the way down, or scroll exactly X times every time a key is pressed?
Title: Re: How to scroll up/down multiple rows in inventory?
Post by: bx83 on Sat 07/08/2021 07:06:26
Exactly 4 lines per scroll, as this is a 'page' of the inventory.

All good, fixed :)

Code for the uninitiated:
function on_key_press(eKeyCode keycode)
{
...
//scroll through inventory using page-up/down
  if (keycode == eKeyPageUp && gInventory.Visible) {
    invCustomInv.ScrollUp();
    invCustomInv.ScrollUp();
    invCustomInv.ScrollUp();
    invCustomInv.ScrollUp();
  }
  if (keycode == eKeyPageDown && gInventory.Visible) {
    invCustomInv.ScrollDown();
    invCustomInv.ScrollDown();
    invCustomInv.ScrollDown();
    invCustomInv.ScrollDown();
  }
...
}
Title: Re: How to scroll up/down multiple rows in inventory?
Post by: Crimson Wizard on Sat 07/08/2021 11:28:38
You could probably also do

Code (ags) Select

invCustomInv.TopItem += invCustomInv.ItemsPerRow * 4;