How to Not Show Hotspots with Cursor When Inventory Box is Open

Started by Ghostlady, Sun 06/04/2025 00:28:33

Previous topic - Next topic

Ghostlady

Hi, currently when the inventory box is open and it's sitting in the middle of the screen but on some hotspots, if I move the mouse around within the inventory box, and it rolls over a hotspot, it changes the cursor to the Interact graphic.  Here is the code I use in my global script.  How this works is that the Inventory box opens and there should be an "arrow" cursor.  When the mouse rolls over an inventory item, the cursor graphic changes to the interact pointer. I shouldn't be seeing hotspots within the inventory box.


Code: ags
  // ** CUSTOM 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);
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Ghostlady

Can anyone help me with this?  This room has multiple directional hotspots.  When a gui is open, in this case the inventory gui or the interface gui, if the mouse rolls over one of the hotspots while the gui is open, it picks up hotspot and changes the mouse cursor, disregarding the mouse for the gui.  How can I stop this from happening.  See video for an example.

https://youtu.be/R_aq8aiVV4M
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Khris

One easy way to fix this is to make the GUI as big as the screen and use a background image with a transparent border. A clickable GUI will prevent the cursor from reacting to hotspots even if the background is completely transparent.

Another way is to check if the GUI is open before changing the cursor. Is this done in repeatedly_execute code? Or are you using the built-in way (AnimateOnlyOnHotspots)?
If it's the former, you can just wrap the code in
Code: ags
  if (!gInventory.Visible && !gInterface.Visible) {
and
Code: ags
  }

Ghostlady

Interesting about the background with a transparent border.  I am going to try that.
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Ghostlady

How do I make a transparent border? I created a screensize background and layered my inventory window on top of the transparent background and then saved as a .png. It's not working though. 
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Crimson Wizard

Make a fullscreen GUI, and set its background and border color to 0, which will make it fully transparent.
Keep it Clickable = true.
Set its ZOrder to be lower than the inventory gui.
Make it show along with the inventory gui and hide when you hide inventory.

Khris

Can you describe how it's not working?

I did a test with the Sierra template.

(This template has the inv GUI set to "pause game when shown", which will prevent rep_exe code from running, so this might actually be a much easier way to solve this.)

Anyway, I added a transparent border to the background image png, changed the position and size of the GUI accordingly and moved all the controls to their proper spots.
Then I used this code to display the hotspot's name in the status bar:

Code: ags
// called on every game cycle, except when the game is blocked
function repeatedly_execute()
{
  String name = Game.GetLocationName(mouse.x, mouse.y);
  lblOverHotspot.Text = name;
}

The transparent background prevented this mechanism from displaying the hotspot's name while the GUI was open, so it worked as expected. I.e. a transparent but clickable GUI catches room clicks and GetLocationType / Game.GetLocationName.

Ghostlady

The Inventory Gui is currently set to "pause game when shown".
How did you add a transparent border to the background image?  Will the way I did it not work? (created a screensize background and layered my inventory window on top of the transparent background and then saved as a .png.)  Actually I played with this again today and it is offset.

Here are two screenshots showing how I created the Inventory Box.

This the inventory Box


This is the box inside the Inventory box which will hold all the inventory items.


I haven't tried Crimson Wizards plan yet.  That may be the easiest solution.


Code: ags
Global Repeatedly Execute:

if (GetLocationType(mouse.x,mouse.y) != eLocationNothing) {
      if(Mouse.Mode!=eModeUseinv)  {
      if (player == cWoman)  Mouse.UseModeGraphic(eModeDapHandU);
      if (player == cMan) Mouse.UseModeGraphic(eModePointer); } }
else { Mouse.UseDefaultGraphic (); }

Room multiple hotspot entryways Repeatedly Execute:

  // script for Room: Repeatedly execute
if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hrighthall) {
    if (player == cWoman)  Mouse.UseModeGraphic(eModeDapHandR); 
    else if (player == cMan)  Mouse.UseModeGraphic(eModeUsermode2); }

if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hlefthall) {
    if (player == cWoman)  Mouse.UseModeGraphic(eModeDapHandL); 
    else if (player == cMan)  Mouse.UseModeGraphic(eModeUsermode3); }

if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hdownstairs) {
    if (player == cWoman)  Mouse.UseModeGraphic(eModeDapHandD); 
    else if (player == cMan)  Mouse.UseModeGraphic(eModeUsermode5); }

My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Crimson Wizard

Quote from: Ghostlady on Yesterday at 23:25:47I haven't tried Crimson Wizards plan yet.  That may be the easiest solution.

The best solution would be to script this. The transparent gui is a "quick & dirty" solution that is easy to understand, but I recommend doing this in script.

Since you mentioned that the Inventory GUI pauses the game when shown, then you can just test for IsGamePaused() or IsInterfaceEnabled() around the code that changes cursor. Like this:

Code: ags
if ( !IsGamePaused() )
{
    // all the cursor changing code here
}

EDIT:
On another issue, I see that you have a special code for Room's "repeatedly execute". Do you have this duplicated in multiple rooms?
If you do, then I may propose to find a way to write a generic code in the global "rep exec". Usually this is possible to do if you use custom properties:
https://adventuregamestudio.github.io/ags-manual/CustomProperties.html
where you assign custom properties to your room hotspots, and then can read these in global script.
But this may be alot of extra work if your game already has a lot of rooms.

Khris

Judging from the screenshots of your inventory GUI in the editor, I don't think you've actually used the new background with the border?

For me it looks like this:

Ghostlady

Crimson Wizard - Checking for the game being paused was a good fix.  I only had a handful of rooms it needed added it. I personally prefer scripting over graphics because graphic work is not one of things I am very good at.  But I am willing if it is a solution.  Thanks for the tidbit about Custom Properties, it is good to know going forward.

Kris - Thank you for working out a gui and showing me how to do a transparent border. This is my problem. It is an older game from 2004'ish and is set at a 16 bitrate, imported into the current AGS version, and transparencies won't show transparent for any bitrate over 24. When I created my background, it went higher than the 24 bitrate so no transparency.  If I export it to png it makes it 8 bit and looks bad. It has made this game a real challenge. But, it is almost complete and I feel there has been some magic that came into play with the graphics, none that I did. :)
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

SMF spam blocked by CleanTalk