Y-axis pop-down UI disappears when clicked

Started by Babar, Sat 15/09/2018 18:49:34

Previous topic - Next topic

Babar

Hi!
So I'm using the default Y-axis pop-down GUI that AGS provides (I don't remember what it was called, the description now says "Visibility: When mouse moves to top of screen"), and the problem is that whenever I click a button in it, the GUI disappears, and I need to move my mouse up the screen again. Most cases I guess this would make sense, but I want to use it for inventory and scrolling through inventory.
Example:
[imgzoom]http://ags.pics/XFv5.gif[/imgzoom]
Is the only solution going to be "Code your own Y-axis pop-down GUI"?
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Slasher

Does the gui (gIconebar) only disappear when you click the buttons?

is its Clickable=true?

otherwise it is a strange behavior..


Babar

It is clickable true, and it disappears when I click the buttons, yes. I'm assuming this is normal behaviour, it's just that it doesn't work well for my case.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Slasher


Babar

Nothing in the buttons that would do anything like that. The left one just has "InventoryWindow1.ScrollUp();", and the right one just has "InventoryWindow1.ScrollDown();".

Your question gave me the idea to add "gInventory.Visible=true;" after each of these lines, but that didn't help with anything.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Slasher

Just to illuminate it... have you got gui's should 'Display as normal ' in general settings?

Babar

I'm not sure which option you are talking about. I can't find anything in General Settings with as you say. The closest I find is:
"When player interface is disabled, GUIs should", and that is set to "Grey out all their controls", NOT "Display Normally". But I don't see how that setting would be relevant to my situation.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Slasher


VampireWombat

#8
I checked for myself and yeah, that seems to be the behavior when I clicked a button. I've always used the BASS template when having such a GUI. So maybe you could just adapt that bit of script.

Edit: I did a bit of research and tested for myself. Apparently the gui will disappear if you make any click on the GUI.

Where I found the info.

Crimson Wizard

This is indeed the default behavior for "Y popup" GUI style, emulating Sierra games, because the only purpose of iconbar is to choose 1 icon by clicking on it and then make next click on the room.

Babar

Oh well, I guess I'll do it manually, then. Thanks!
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Babar

I realised my game wouldn't have more than 5 items at a time, so I figured I'd just stick with my current implementation, but I ran into yet another problem.
I want to be able to click one of the inventory items and then have it become the active inventory and the current mouse mode become UseInv and be able to use it. Absolutely typical inventory behaviour. Except...there doesn't seem to be any way to implement it. When I click any inventory item in the inventory window...nothing happens.
I always just had inventory stuff work, so I'm a bit confused :D. I don't have inventory handling done in script, and the GUI is set to clickable.

Here is my on_mouse_click code, which is the only thing I could think of that is affecting it. I suspected it might be the "if (IsGamePaused()==1) section right at the start (since my gui pauses the game), but uncommenting the line I have there made no difference, and besides the quit button on the right of the menu gets triggered fine.
Code: ags
function on_mouse_click(MouseButton button) // called when a mouse button is clicked. button is either LEFT or RIGHT
{
  if (IsGamePaused() == 1) // Game is paused, so do nothing (ie. don't allow mouse click)
  {
		//if (gInventory.Visible) Room.ProcessClick(mouse.x, mouse.y, eModePointer); //also tried eModeInteract
  }
  else if (button == eMouseLeft) 
  {
    if  (GetLocationType(mouse.x, mouse.y)==eLocationNothing) 
		{
			if (canwalk) player.Walk(mouse.x, mouse.y, eNoBlock);
		}
		else Room.ProcessClick(mouse.x,mouse.y, eModeLookat);
  }
  else if (button==eMouseRight)// right-click, so cycle cursor
  {
		if  (GetLocationType(mouse.x, mouse.y)==eLocationNothing) 
		{
			if (canwalk) player.Walk(mouse.x, mouse.y, eNoBlock);
		}
		else Room.ProcessClick(mouse.x,mouse.y, eModeInteract);

  }

}
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Babar

Okay, perhaps I am misunderstanding how the default inventory system is supposed to work? What am I supposed to code, and what works on its own?
I created a completely new project, created a y-pop up gui gInv, added an inventory window, added inventory items, and still...nothing happens when I click them.
I can see them there, but clicking on them does nothing.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

Khris

My guess is that built-in inventory click handling was hard coded to work with the standard Sierra interface.
Just use custom handling and eMouseLeftInv.

morganw

I think this can probably be raised as a bug (unintended behaviour), if clicking on an inventory item does nothing and clicking on buttons does something.

Crimson Wizard

#15
Quote from: morganw on Fri 21/09/2018 22:57:26
I think this can probably be raised as a bug (unintended behaviour), if clicking on an inventory item does nothing and clicking on buttons does something.

Popup GUIs are supposed to be hidden after click regardless of what the click was on.

But my impression was that by "nothing happens" Babar meant that inventory item is not selected, not that literally nothing changes.


Quote from: Khris on Fri 21/09/2018 18:42:37
My guess is that built-in inventory click handling was hard coded to work with the standard Sierra interface.

I made a test, and it works for any InventoryWindow control too. The built-in rules are:
1) Item gets selected into cursor if you left click with "Interact" mode only.
2) Right mouse click always triggers "Look at" interaction.
3) If nothing from above, then current interaction mode runs.

@Babar, you have to choose whether you want to script inventory interaction yourself or use built-in one. Don't forget to set "Override built-in inventory click handling" in General Settings correspondingly.
If you are going with custom script, the script you posted above has nothing related to inventory handling at the moment. Room.ProcessClick only works on room and its contents (objects & characters). There is a GUI.ProcessClick counterpart (but not necessarily useful in your case). Important thing is, as Khris said, to catch clicks on inventory items you need to check (button == eMouseLeftInv). You may get the last clicked item either with "InventoryItem.GetAtScreenXY" or "inventory[game.inv_activated]".
I think BASS template may have an example of custom inventory script.

Babar

Quote from: Crimson Wizard on Sat 22/09/2018 01:04:24
But my impression was that by "nothing happens" Babar meant that inventory item is not selected, not that literally nothing changes.
Nor was anything triggered for looking at inventory or interacting with inventory.

I wanted to use the default inventory handling behaviour and not code my own, as I assumed that would be simpler. Still, I figured out the problem and was able to use it.

I found out that inventory selection can only be done using the eModeInteract. My UI had nothing that changed the inventory mode, so it stayed whatever it is at start (probably walk?). So I set it to eModeInteract at the start, and back to eModeInteract after any eModeUseInv is done, and it worked.
The ultimate Professional Amateur

Now, with his very own game: Alien Time Zone

SMF spam blocked by CleanTalk