Using Part of Iconbar as Inventory? [SOLVED!]

Started by Play_Pretend, Sat 17/05/2008 07:26:30

Previous topic - Next topic

Play_Pretend

Hey all!  We're making a big GUI that includes the inventory displayed as part of the Iconbar GUI.  It's set to pop up on mouse position like most iconbar GUIs, has the walk/look/etc buttons across the top, then has three inventory items displayed at a time, with the usual inventory arrows to scroll through your other items.

The problem is, when set to Mouse Ypos popup, it makes the whole GUI disappear if you click the arrows or items.  If I set it to Popup Modal, it stays, but you'd have to click an extra button just to close the GUI, I think, after you select an item or cursor.

So is there any way to make it pop up on Mouse Ypos, then stay on screen while you do inventory stuff, but disappear again once you move the mouse back down, so you don't have to click something extra to close it?

skuttleman

I would keep it as a pop-up and try something like this in your repeatedly_execute function in the global script:

Code: ags

if (mouse.y < 20) gIconbar.Visible = true;
else gIconbar.Visible = false;


Tweak it depending on the height of the gui.

Play_Pretend

#2
Wow, thank you so much skuttleman, that totally worked! :)

If you don't mind, I have another question...I had to do some tricky stuff to make the GUI behave properly.  It'll pop up when the mouse goes to the top of the screen, but not disappear until the mouse goes below the bottom of the GUI (it's pretty big).  The mouse changes to the pointer when the GUI comes up, and will change back to whatever cursor it was before if you close it without clicking anything (so as not to annoy the player :) ).

The problem now is that if you select an inventory item, the cursor will change to that item, which is good.  But then if you move to the bottom to close the GUI, the cursor changes back to whatever Look/Touch/etc it was before.  You can still cycle through to the item by right-clicking, but what did I do wrong?  I think the problem might be the eModeUseinv command, but I'm not sure.

Here's my current Repeatedly_Execute code, with the Iconbar set to Popup Modal.  All the Globalint mishmash is just to set the cursors when the GUI comes on or off:

Code: ags

  if (gIconbar.Visible == true) {
    if (mouse.y > 231) {
      
        if (GetGlobalInt(25) == 1) {
          mouse.Mode = eModeWalkto;
        }
        else if (GetGlobalInt(25) == 2) {
          mouse.Mode = eModeLookat;
        }
        else if (GetGlobalInt(25) == 3) {
          mouse.Mode = eModeInteract;
        }
        else if (GetGlobalInt(25) == 4) {
          mouse.Mode = eModeTalkto;
        }
        else if (GetGlobalInt(25) == 5) {
          mouse.Mode = eModeUseinv;
        }
      
      gIconbar.Visible = false;
    }
  }
  else if (gIconbar.Visible == false) {
    if (mouse.y < 13) {
      gIconbar.Visible = true;
      
        if (mouse.Mode == eModeWalkto) {
          SetGlobalInt(25, 1);
        }
        else if (mouse.Mode == eModeLookat) {
          SetGlobalInt(25, 2);
        }
        else if (mouse.Mode == eModeInteract) {
          SetGlobalInt(25, 3);
        }
        else if (mouse.Mode == eModeTalkto) {
          SetGlobalInt(25, 4);
        }
        else if (mouse.Mode == eModeUseinv) {
          SetGlobalInt(25, 5);
        }
      
      mouse.Mode = eModeInteract;
      mouse.UseModeGraphic(eModePointer);
	    
    }
  }


I also changed the Iconbar Look/Touch/etc buttons so they would Run Script like this:

Code: ags

#sectionstart IconTalk_Click  // DO NOT EDIT OR REMOVE THIS LINE
function IconTalk_Click(GUIControl *control, MouseButton button) {
  
  mouse.Mode = eModeTalkto;
  mouse.UseModeGraphic(eModeTalkto);
  gIconbar.Visible = false;
}
#sectionend IconTalk_Click  // DO NOT EDIT OR REMOVE THIS LINE


To make the GUI disappear if you just wanted to select a cursor, and wouldn't have to go to the bottom of the screen to close it.

skuttleman

I think you've made it harder than it needs to be.

Try this:

Code: ags

if (mouse.y < 13 && gIconbar.Visible == false)
{
  gIconbar.Visible = true;
  Mouse.UseModeGraphic(eModePointer);
}

if (mouse.y > 231 && gIconbar.Visible == true)
{
  gIconbar.Visible = false;
  Mouse.UseDefaultGraphic();
}


Then on the button clicks:
Code: ags

function IconTalk_Click(GUIControl *control, MouseButton button) {
  
  mouse.Mode = eModeTalkto;
  mouse.UseDefaultGraphic();
  gIconbar.Visible = false;
}


I hope that helps. You shouldn't have to use the global int. Unless something else effects the mouse cursor?

Play_Pretend

Double wow!  Yep, that worked perfectly! :)  It fixed every part of the problem, and the GUI and cursors are now working exactly as they should.

Heh, I think I'm just over-prone to using global integers to solve a lot of my problems in really roundabout ways.  Plus I wasn't really familiar with the DefaultGraphic command.  So thanks a lot for the help and the quick education!  ;D

Khris

Btw, mouse.Mode is an integer, so in your previous code, you could've done:
Code: ags
  SetGlobalInt(25, mouse.Mode);
  mouse.Mode = GetGlobalInt(25);

Play_Pretend

Sweet, I didn't know that either.  Thanks!

SMF spam blocked by CleanTalk