Stop player from any cursor modes when GUI's visible

Started by Slasher, Mon 08/10/2012 13:39:15

Previous topic - Next topic

Slasher

I'm looking for a command to stop any actions with the main character whilst some GUI's are visible.

EG  When looking at a post-it GUI I do not want the main character to

There is a close button on the post-it GUI that makes it not visible so at least one mode (arrow or hand) must be available to click the close button. Once closed the game returns and the player reacts to all cursor modes.
react to any cursor modes.
In Global repeatedly_execute_always:
Code: AGS
}
 else if (gpostit.Visible==true || gspellbook.Visible==true)
 {
   // CODE TO STOP MAIN PLAYER REACTING TO ANY CURSOR MODES.
 }


When these GUI'S are closed game returns as per normal.

What is a sure fire way of doing this?

Help appreciated.



Slasher

Unfortunately this does NOT work and does NOT pause the game and the player can still move etc Basically I would like everything non-Interactive:

Code: AGS
 
 }
  else if (gpostit.Visible==true || gspellbook.Visible==true)
 {
  PauseGame();
 }
  


As an alternative I could make a screen sized GUI with Transparency background with button of post-it note and close button.


Crimson Wizard

#3
It should though...
What else do you have in "repeatable execute always"?


E: Err... repeatable execute always??? oh.
I would also add IsGamePaused() to condition, otherwise that will happen every 1/40 of a second.

Slasher

As an alternative I could make a screen sized GUI with Transparency background with button of post-it note and close button.

This is what is in Global:

Code: AGS
function repeatedly_execute_always() {
  
  // Put anything you want to happen every game cycle, even
  // when the game is blocked inside a command like a
  // blocking Walk().
  // You cannot run blocking commands from this function.
  
  if (gPanel.Visible==true || gRestoreGame.Visible==true)
  {
  
  gsplash.Clickable=false;
  
  }
  else if (gPanel.Visible==false || gRestoreGame.Visible==false)
  {
  
  gsplash.Clickable=true;
  
  
  // GUI'S POST-IT AND SPELL BOOK
 
 }
  else if (gpostit.Visible==true || gspellbook.Visible==true)
 {
  PauseGame();
 }
  
  else if (gRestartYN.Visible==true)
 {
  gPanel.Clickable=false;
 }
 }


Sorry for any script mess  :-[

cheers


OG

Throw this in there:

mouse.UseModeGraphic(eModePointer);

And sort out your on_click display messages with buttons.

Crimson Wizard

#6
Alright, I'll admit I am clueless. Wait for Khris :).

Only thing I should note is that I won't recommend to do such things in "repeatable execute" function, but rather where you change your GUI states. For example - you make GUI visible and pause the game. You make GUI not visible and unpause the game. I think it's better than do checks every moment.


Quote from: Onker on Mon 08/10/2012 14:28:45
Throw this in there:

mouse.UseModeGraphic(eModePointer);

And sort out your on_click display messages with buttons.
That's possible, but I'd say that would lead to more extra code than ever needed for doing this simple task.

Slasher

Thanks guys.


QuoteAs an alternative I could make a screen sized GUI with Transparency background with button of post-it note and close button..
Also with spell book GUI

What I have coded:

Code: AGS
 }
  else if(spellbook==true && cELF.ActiveInventory==ispellbook)
  {
   cELF.ActiveInventory=null;
   gspellbook.Visible=true;
   mouse.UseModeGraphic(eModeInteract);
  }




This does work.

Khris

Set the GUI's visibility to "pause game when shown".
This will set the game to paused mode whenever the GUI is shown and while on_key_press and on_mouse_key are still called when the game is paused, they have code at the start to exit the function if it is.

SMF spam blocked by CleanTalk