Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Mikael on February 05, 2012, 04:19:02 PM

Title: Small inventory scrolling quirk
Post by: Mikael on February 05, 2012, 04:19:02 PM
This is not a big problem, but if it could be fixed easily, it would be nice.

In my game, a total of 15 inventory items can be seen at once. In this first picture, I have 18 items, and the inventory has been scrolled all the way to the right, using the right arrow (not visible in the screencap, since no more right scrolling is possible). That means that 3 items are "hidden" to the left. Nothing strange this far.

http://www.mdna-games.com/priv/inv_1.jpg

Shortly after this scene, 4 items disappear from the inventory for various reasons. During that period, I don't have to access any of the 3 "hidden" items. That is, I don't have to scroll to the left. This leaves me with an inventory looking like this:

http://www.mdna-games.com/priv/inv_2.jpg

Is there any way to automatically fill the maximum number of blank spaces in the inventory?
Title: Re: Small inventory scrolling quirk
Post by: metamorphium on February 05, 2012, 05:16:15 PM
Something like this?

Code: WME Script
Title: Re: Small inventory scrolling quirk
Post by: Mikael on February 05, 2012, 06:03:42 PM
Still same result ... I guess that it's of no crucial importance how or where i place the code?

Edit:
I think I see now... But it requires that the code is added everytime an object is removed from the inventory, and there's a potential risk for an "unwanted" blank?
Title: Re: Small inventory scrolling quirk
Post by: metamorphium on February 05, 2012, 08:06:45 PM
not really. you can override the Game.DeleteItem and calculate the position based on current amount of inventory items.

in game.script something like:

Code: WME Script
  1.  
  2. method DeleteItem(item)
  3. {
  4.     var numberOfSlots = 8; // how many slots are there in upper inventory
  5.  
  6.     Game.DeleteItem(item);
  7.    
  8.     var endPosition = Game.InventoryScrollOffset + numberOfSlots - 1;
  9.    
  10.     if (endPosition > Game.NumItems)
  11.     {
  12.          endPosition = Game.NumItems - numberOfSlots;
  13.          if (endPosition < 0) endPosition = 0;
  14.          Game.InventoryScrollOffset = endPosition;
  15.     }
  16.  
  17. }
  18.  

It's untested so if it doesn't work, skype me. :)))