Find currently displayed row on invMain?

Started by DrLilo, Tue 12/11/2024 10:55:04

Previous topic - Next topic

DrLilo

Hi guys. I'm using the default Inventory window from Tumbleweed, but I find that if I make gMain.Visible false and then true later, the inventory automatically returns to the first row. This gets quite annoying for the player, when gMain is hidden during every bit of dialogue (including using LookAt on an item deep into the inventory).

What I'd like to know is if there's a way to check which row is currently displayed at the top of visible GUI so that I can store that before gMain becomes invisible and then use invMain.ScrollDown() to advance back to whereever the user left off?

I've experimented with manually incrementing a variable every time the use clicks btnInvScrollDown but that solution falls over when items are Added or Lost elsewhere in code, unpredictably causing the visible row to shift organically.


Crimson Wizard

#2
Quote from: DrLilo on Tue 12/11/2024 10:55:04Hi guys. I'm using the default Inventory window from Tumbleweed, but I find that if I make gMain.Visible false and then true later, the inventory automatically returns to the first row.

That's very unexpected, I do not think this is supposed to happen at all. There are other UI styles, where inventory window is on a popping-down bar, for example, and GUI becomes visible and invisible whenever player moves the mouse. If the inventory would reset position every time, it would become unusable.
InventoryWindow.TopItem is a logical state of the control, like size, text or color, that should not have any connection to gui visibility.

Something is off here.

EDIT:
I just quickly tested 2 templates, filling with random inventory items, and scrolling, then toggling inventory window invisible,
in BASS template the inventory position stays
in Tumbleweed it is reset.

Khris

Calling UpdateInventory() reorders the items in the window, it might also reset the top item.
@DrLilo Can you show the actual code you're using?

Crimson Wizard

#4
Here you go, this is from Tumbleweed template, VerbGUI.asc:

Code: ags
if (InventoryItem.GetAtScreenXY(verbsData.guiMain.X + invMain.X + 1, verbsData.guiMain.Y + invMain.Y + 1) == null)
  invMain.TopItem -= invMain.ItemsPerRow;

This checks if there's any item found under certain coordinates on screen, and if not, then scrolls it one row up.

This seems like a nasty way to do whatever it was intended for...
not only inventory window may be invisible, but also this breaks if any GUI covers the inventory window.

EDIT:
should not this be simply
Code: ags
if (invMain.TopItem >= invMain.ItemCount)
  invMain.TopItem -= invMain.ItemsPerRow;
?

Crimson Wizard

Okay, I tested this, and following solution works:

@DrLilo,
open the script Tumbleweed -> VerbGui

find line 392 that looks like this:
Code: ags
if (InventoryItem.GetAtScreenXY(verbsData.guiMain.X + invMain.X + 1, verbsData.guiMain.Y + invMain.Y + 1) == null) invMain.TopItem -= invMain.ItemsPerRow;

Comment that out and replace with this:
Code: ags
if (invMain.TopItem >= invMain.ItemCount) invMain.TopItem -= invMain.ItemsPerRow;

That produces same effect, but does not rely on inventory window being visible.

SMF spam blocked by CleanTalk