Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: MurrayL on Sun 08/11/2009 19:01:09

Title: [SOLVED] Inventory Mouse Pointer
Post by: MurrayL on Sun 08/11/2009 19:01:09
Hey guys, quick question;

I have an inventory bar across the top of the screen, and every time the mouse moves over it the cursor changes to the regular pointer sprite (and back again when you move out of the GUI area).

How do I make it keep whatever action cursor was in use?
Title: Re: Inventory Mouse Pointer
Post by: Matti on Sun 08/11/2009 19:11:19
In the global script should be this piece of code:


function show_inventory_window ()
{
 gInventory.Visible = true;
 // switch to the Use cursor (to select items with)
 mouse.Mode = eModeInteract;
 // But, override the appearance to look like the arrow
 mouse.UseModeGraphic(eModePointer);
}


Just erase the last line everything except the first line.
Title: Re: Inventory Mouse Pointer
Post by: MurrayL on Sun 08/11/2009 19:35:23
That section of code wasn't in there; I completely replaced the inventory GUI, so I'm guessing I took that bit of code out as well.

Obviously pasting it back in didn't do anything; how do I link it to the new GUI?
Title: Re: Inventory Mouse Pointer
Post by: MurrayL on Wed 11/11/2009 01:59:27
Sorry to bump the topic, but I really need to know how to do this.

Obviously there is some code somewhere that is able to change the mouse cursor when it rolls over the inventory GUI - I just need to know how to disable it.
Title: Re: Inventory Mouse Pointer
Post by: Lufia on Wed 11/11/2009 02:09:29
That should be in the repeatedly_execute function of the global script, or in a function called from there.
Title: Re: Inventory Mouse Pointer
Post by: Matti on Wed 11/11/2009 11:15:59
Hm.. just went through the global script of the standard empty game and couldn't find any hint on why the cursor changes to the pointer when over the iconbar on top of the screen.

It seems that the cursor automatically changes to pointer whenever your mouse is over a Popup-GUI. Sorry, can't help you here, it's been so long since I did some inventory-related cursorstuff, but I remember that I've had these problems too.
Title: Re: Inventory Mouse Pointer
Post by: Wonkyth on Wed 11/11/2009 11:54:27
Hmm, that seems to be the case.

Murray, what is the state of the Visibility property of the GUI?
It should only override the cursor when it's a pop-up GUI, I'm pretty sure.
Using Ctrl+I to bring up the default inventory window and setting the Visibility property to anything other than the auto pop-up setting, and then removing the lines Matti indicated, it would behave in a normal fashion.
Is the inventory bar in your game normally visible?
Title: Re: Inventory Mouse Pointer
Post by: MurrayL on Wed 11/11/2009 12:47:30
It's a pop-up bar at the moment, although I could make it permanently visible if it would solve the problem.

Just to clarify, this GUI isn't a modification of the default game inventory nor is it a modification of the default game pop-up bar - it is a completely new GUI which consists solely of an inventory display.

EDIT: Okay I changed it to Normal, Initially Off and now the cursor behaviour is working how it should.

I'd like to be able to 'dim' the GUI when the mouse isn't over it though - how would I go about doing this?
Title: Re: Inventory Mouse Pointer
Post by: Wonkyth on Wed 11/11/2009 12:53:46
Okay.
The problem is that as Matti pointed out, the cursor is auto-set by pop-up GUIs.
The obvious way to get around that would be to make it always visible.
However, if you can't spare the screen-space, then it shouldn't be too hard to code your own pop-up code, and then you'll be able to feed it what you want.
If that sounds a bit hard, then ask. ;)
Title: Re: Inventory Mouse Pointer
Post by: Lufia on Wed 11/11/2009 13:04:38
By "pop up", you mean the "when mouse moves to the top of screen" setting?

Anyway, the repeatedly_execute function is the answer to your problem, this time. You'd put a condition on the cursor y coordinate and then do whatever you want.

Here's a basic example:
fuction repeatedly_execute {
  if ((mouse.y < 20) && (!gInventory.Visible)) {
    gInventory.Visible = True;
    ...
  }
  else if ((mouse.y >= 20) && (gInventory.Visible)) {
    gInventory.Visible = False;
    ...
  }
}
Title: Re: Inventory Mouse Pointer
Post by: Wonkyth on Wed 11/11/2009 13:08:46
Quote from: Lufia on Wed 11/11/2009 13:04:38
By "pop up", you mean the "when mouse moves to the top of screen" setting?
Yeah, that. "pop-up " makes sense, and is easier to type. :P
Title: Re: Inventory Mouse Pointer
Post by: MurrayL on Wed 11/11/2009 14:19:26
Thanks for the help guys!

I created a new GUI called gInventoryDim which is just the same size as the regular inventory, filled with a semi-transparent black.

if ((mouse.y < 50) && (gInventoryDim.Visible)) {
    gInventoryDim.Visible = false;
  }
  else if ((mouse.y >= 50) && (!gInventoryDim.Visible)) {
    gInventoryDim.Visible = true;
}

This way the inventory GUI has the right mouse pointer (because it is always visible) but doesn't distract from the rest of the screen when it's not in use.
Title: Re: [SOLVED] Inventory Mouse Pointer
Post by: WHAM on Tue 17/11/2009 07:36:25
Am I the only one who thinks it would be great if the pop-up GUI has a setting for "when active, change cursor to default? -> true/false

The obvious use for it, in my opinion, is to use it as an inventory script and using inventory items themselves as cursor graphics in combination with this = confusion.