Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Slasher on Wed 27/11/2013 07:32:52

Title: GUI.GetAtScreenXY
Post by: Slasher on Wed 27/11/2013 07:32:52
Hi,

I am trying to incorporate an action for 2 Gui's for the cursor to show arrow and then return mode when off the Gui's.

This script works as it should:

Code (ags) Select

// WHEN CURSOR OVER STATUSLINE GUI

  GUI* theGui = GUI.GetAtScreenXY(mouse.x, mouse.y);
  if (theGui == gStatusline  && mouse.Mode != eModePointer)
{
    old_mode=mouse.Mode;
    mouse.ChangeModeGraphic (eModePointer, 2061);
    mouse.Mode = eModePointer;
  }
if (theGui != gStatusline && mouse.Mode == eModePointer && mouse.GetModeGraphic(eModePointer) == 2061)
{
    mouse.Mode=old_mode;



Now, I also have another Gui (130 x 240 in middle of Room) that shows in a Room along with gStatusline which is named gPasswordGUI.

What I have been trying to do is to incorporate it so that its actions are as per gStatusline: that is the cursor changes to pointer whilst over gPasswordGUI and returns mode when off.

Would you please assist me.

cheers




Title: Re: GUI.GetAtScreenXY
Post by: Gilbert on Wed 27/11/2013 07:53:16
(Not tested) Wouldn't the codes below work? (Parentheses added for clarity)

Code (ags) Select

// WHEN CURSOR OVER STATUSLINE GUI

  GUI* theGui = GUI.GetAtScreenXY(mouse.x, mouse.y);
  if ((theGui == gStatusline||theGui ==  gStatusline) && mouse.Mode != eModePointer)
{
    old_mode=mouse.Mode;
    mouse.ChangeModeGraphic (eModePointer, 2061);
    mouse.Mode = eModePointer;
  }
if ((theGui != gStatusline&heGui ==  gStatusline) && mouse.Mode == eModePointer && mouse.GetModeGraphic(eModePointer) == 2061)
{
    mouse.Mode=old_mode;



if you find that too many logical comparison in the same if-clause confusing you can break them down at those && part for easier reading.
Title: Re: GUI.GetAtScreenXY
Post by: Slasher on Wed 27/11/2013 08:01:37
Hi Iceboty V7000a,

I've got the script to work using the below script. I don't know if it is the 'coder's' way but it does work.
Code (ags) Select

// WHEN CURSOR OVER STATUSLINE OR PASSWORD GUI

  GUI* theGui = GUI.GetAtScreenXY(mouse.x, mouse.y);
  if (theGui == gStatusline  && mouse.Mode != eModePointer)
  {
    old_mode=mouse.Mode;
    mouse.ChangeModeGraphic (eModePointer, 2061);
    mouse.Mode = eModePointer;
    }
  if (theGui == gPasswordGUI && mouse.Mode != eModePointer)
  {
    old_mode=mouse.Mode;
    mouse.ChangeModeGraphic (eModePointer, 2061);
    mouse.Mode = eModePointer;
    }
  if (theGui != gStatusline && mouse.Mode == eModePointer && mouse.GetModeGraphic(eModePointer) == 2061)
  if (theGui != gPasswordGUI && mouse.Mode == eModePointer && mouse.GetModeGraphic(eModePointer) == 2061)
  {
    mouse.Mode=old_mode;


So, although this is solved I am open to other ways to adopt.

cheers



Title: Re: GUI.GetAtScreenXY
Post by: Khris on Wed 27/11/2013 16:40:55
This is what I would do:
Code (ags) Select
// above rep_exe
GUI *prevGui;

// inside
 
  GUI *theGui = GUI.GetAtScreenXY(mouse.x, mouse.y);
 
  if ((theGui == gStatusline || theGui == gPasswordGUI) && prevGui == null) {
    old_mode = mouse.Mode;
    mouse.ChangeModeGraphic(eModePointer, 2061);
    mouse.Mode = eModePointer;
  }

  if ((prevGui == gStatusline || prevGui == gPasswordGUI) && theGui == null) {
    mouse.Mode = old_mode;
  }

  prevGui = theGui;
Title: Re: GUI.GetAtScreenXY
Post by: Slasher on Wed 27/11/2013 17:24:52
Cheers Khris,

I will adopt (nod)

cheers

slasher