Hi.
I am working on a port of the video game progressquest (
http://progressquest.com/ ) to lazarus. I never seriously used pascal, delphi or lazarus before, and my questions may be noobish.
There is an issue with the game (skip this if you are not interested in the game): after playing for around 10 years the size of main hero's backpack gets huge, and he may be carrying tens or hundreds of thousands of items. Backpack is a list of item-quantity. When the hero gets a next trophy, it is added to the backpack, and the hero looks through the whole backpack to see of he already has this type of item, then he increases quantity, else he adds new item in the end of the list. And when the hero goes to market, he repeatedly sells the second element in the list, removing it, until there is only the first item left, which cannot be sold because it is his wallet with gold.
So to make the game efficient I implemented the backpack as a custom data structure, and it displays through TListView with OwnerData:=True, and OnData refers to my data structure.
My current problem is: when a new item is won, and it is added in the end of the list, I update the display by running ListView.Items.Count := 1+ListView.Items.Count. Then for some weird reason the listview resets its position (scrolls to top), and if an item was selected, the selection is lost too.
Is there a way to make updates smoother, preserve the scrolling position, and/or selection?