Inventory window not showing 4th row

Started by tor.brandt, Sun 20/11/2016 21:25:48

Previous topic - Next topic

tor.brandt

I have an inventory window with height 46 and width 196.
Each item is set to have height 23 and width 28, such that there is room for two rows of 7 items at a time.
The sprites I use for the inventory items have height 22 and width 27, because I want there to be one pixel between each item.

I have scroll arrows to scroll the inventory window up and down.
The inventory window shows the first three rows of items without problems, but if the player has more than 21 items (I have 23 items total in my game at the moment), it doesn't make a fourth row.

I tried setting the item height (of the inventory window) much lower, and then it could show all the items (of course then they became overlapping).
I just thought that if the height was the problem, it should be a problem with three rows as well.
I don't understand why it becomes a problem at fourth row - and I don't understand why it's a problem at all, since the dimensions should fit ???

Any ideas what could cause this problem?
Let me know if you need to look at the code for the scroll buttons or something (don't know if that could be the cause of the problem?)...
Thanks!

Danvzare

Hmm, I can't quite see why it isn't working. If everything else is being displayed correctly, that should too. ???
Can I see the code you're using for the scroll buttons.

tor.brandt

Quote from: Danvzare on Mon 21/11/2016 11:44:18
Hmm, I can't quite see why it isn't working. If everything else is being displayed correctly, that should too. ???
Can I see the code you're using for the scroll buttons.

Thanks for your reply!

Actually, while I was copying the code for the scroll buttons, it suddenly struck me what I had done wrong.
I had this:
Code: ags
function repeatedly_execute_always() 
{
  if (invMain.TopItem > 0)
  {
    btnInvUpNA.Visible = false;
    btnInvUp.Visible = true;
  }
  else
  {
    btnInvUp.Visible = false;
    btnInvUpNA.Visible = true;
  }
  
  if ((invMain.TopItem == 0) && (invMain.ItemCount > 14))
  {
    btnInvDownNA.Visible = false;
    btnInvDown.Visible = true;
  }
  else
  {
    btnInvDown.Visible = false;
    btnInvDownNA.Visible = true;
  }
}


which I then replaced with this:
Code: ags
function repeatedly_execute_always() 
{
  if (invMain.TopItem > 0)
  {
    btnInvUpNA.Visible = false;
    btnInvUp.Visible = true;
  }
  else
  {
    btnInvUp.Visible = false;
    btnInvUpNA.Visible = true;
  }
  
  if (invMain.ItemCount > invMain.TopItem + 13)
  {
    btnInvDownNA.Visible = false;
    btnInvDown.Visible = true;
  }
  else
  {
    btnInvDownNA.Visible = true;
    btnInvDown.Visible = false;
  }
}


and now it's working as it should.

Don't know how I could overlook that total bummer (or what I was thinking when I wrote the original code)...
Thank you for helping me indirectly :-D

SMF spam blocked by CleanTalk