Alright, so I took the suggestion to heart, and did some further testing and came to the conclusion that getStashInventory works as intended, but getStashName does not.
Each of the following tests is called from the Render() function.
Code:
public override void Render()
{
if (!GameController.Game.IngameState.ServerData.StashPanel.IsVisible)
{
return;
}
// called function from here.
}
getStashInventory test.
Code:
private void ShowItemCountOfEachNonNullTab()
{
var stashPanel = GameController.Game.IngameState.ServerData.StashPanel;
var numberOfStashes = (int) stashPanel.TotalStashes; // Why is this not an int? :thinking:
var content = "";
for (var i = 0; i < numberOfStashes; i++)
{
var stashTab = stashPanel.getStashInventory(i);
if (stashTab == null)
{
content += "stash tab no. " + i + ", is null.\n";
continue;
}
var itemCount = stashTab.ItemCount;
content += "stash tab no. " + i + ", has " + itemCount + " items in it.\n";
}
MessageBox.Show(content);
}
Result was for the most part as expected given @TehCheat and @Zafaar's comments.
Notes:
If you visit a new stash (eg. travel to a new town) the memoryaddresses no longer contain the information (getStashPanel from 0 to TotalStashes returns null) and you would have to go through each tab again.
Tab information is stored into memory one at a time (as the client views the tab, not 5):
Attachment 52823
tested by traveling to a new town and opening the stash
Side note: The first time a stash is opened in a new place, with the code above, even the first tab displays as null, but this is due to not having a delay, by simply waiting a second, and requesting the information again without doing anything in game, we get the correct result from the first stash tab (not null).
getStashName test.
Code:
private void ShowItemCountOfEachNonNullTab()
{
var stashPanel = GameController.Game.IngameState.ServerData.StashPanel;
var numberOfStashes = (int) stashPanel.TotalStashes;
var content = "";
for (var i = 0; i < numberOfStashes; i++)
{
var stashTab = stashPanel.getStashInventory(i);
if (stashTab == null)
{
content += "stash tab no. " + i + ", is null.\n";
continue;
}
var itemCount = stashTab.ItemCount;
content += "stash tab no. " + i + ", has " + itemCount + " items in it.\n";
}
MessageBox.Show(content);
}
Messagebox never get's called here, since we get the following error for each value of
i:
Code:
Method error: Render : System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
But since we are using the same index range as in the getStashInventory test this is odd, and I think it should get looken into.
UPDATE
Made a new test, that kinda works:
Attachment 52827
The code is checking if all stashes are not null, if they are, it views them all by pressing right keyboard arrow and then left back to it's original position, and then the following is executed:
Code:
for (var i = 0; i < stashPanel.TotalStashes; i++)
{
var titleElement = stashPanel.getStashTitleElement(stashPanel.getStashName(i));
var position = titleElement.GetClientRect();
Graphics.DrawText(stashPanel.getStashName(i), 20, new Vector2(position.X, position.Y));
}
UPDATE 2
Code works on Zafaar's end, dunno.