[SOLVED]Inventory window stays open when using item on hotspot/object ?

Started by Rik_Vargard, Wed 11/12/2024 20:10:38

Previous topic - Next topic

Rik_Vargard

I don't know if this a 3.6.1 version thing or if I more likely did something to my game, but when I select an item in the inventory window and then use it on a hotspot without closing the window first, the code goes on like I want but the GUI window stays open.

So I returned to my previous game to check that out (v3.5) , and when I try to use an item while the GUI is still open, I have to close it first.
That's what I need.

I do remember that I imported the GUI from my previous game, deleted the default one and renamed the new one "gInventory2" so there might be some code missing.

I also use the gGUI.Visible = true/false and not the open/close_gui thingy.

What do you think I should do to fix this?

Thanks!  :)

Crimson Wizard

Please give more details, how do you have inventory window organized, is it on a popup bar, or inside a "window" that opens and closes? How do you open and close the gui which has inventory window on?

Khris

Sounds like the GUI's visibility changed from "pause game when shown" to "normal" maybe?

Rik_Vargard

Thank you both for your replies . (nod)

The player opens the Inv GUI by clicking on the icon in the Iconbar on the top.
The GUI is the default one when you start a new game with the LukasArt template.

Back then I wanted the Inv GUI and the Iconbar to not Pause object animations (like the rain) when opening it.
So I used this code given to me in repeatedly_execute_always:

Code: ags
GUI* g = gIconbar; // set GUI
g.Visible = mouse.y < 75;

The reason it's in repeatedly_execute_always is that it is the only way it always shows up. Because sometimes it didn't.

I hope this is useful?

Both the INV GUI and the Iconbar are set on normal pop-up

Khris

Those two lines don't affect the inventory GUI, just the iconbar one.
Anyway, an icon bar up top is typical of the Default / Sierra template, not the 9-Verb / LucasArts / Tumbleweed one.

So assuming you used the Sierra template (which doesn't have a permanently visible inventory at the bottom of the screen but uses a separate window), check the inventory GUI's PopupStyle setting. Since you didn't want the GUI to stop animations, you most likely have that set to "Normal", which means the game keeps running in the background and the player can still click on hotspots without closing the inv window first.
The quick fix is to change the PopupStyle to "Pause game when shown", but this will most likely stop background animations.

So the proper fix is to block mouse clicks while the GUI is open. An easy way is to simply insert this into on_mouse_click as the first line:
Code: ags
  if (gInventory.Visible) return;
(If you're using modules that also handle mouse clicks, you should create a new script at the top of the list and prevent clicks there by also calling ClaimEvent(); )

The proper, proper fix is to add a screen-sized, (semi-)transparent background to the GUI's background graphic sprite so the inventory GUI actually covers the entire screen, if not necessarily visibly so.

Rik_Vargard

Quote from: Khris on Fri 13/12/2024 11:19:24The proper, proper fix is to add a screen-sized, (semi-)transparent background to the GUI's background graphic sprite so the inventory GUI actually covers the entire screen, if not necessarily visibly so.
Quote from: Khris on Fri 13/12/2024 11:19:24if (gInventory.Visible) return;

Yay that one is a great idea; it could also add something to the visuals.
Thank you so much for your help!  (laugh)

Cheers!

SMF spam blocked by CleanTalk