Y / N key press activation with Popup Modal GUI (SOLVED)

Started by Husky, Sat 07/10/2006 16:12:38

Previous topic - Next topic

Husky

Ã,  Ã,  Ã, I have a custom Yes / No GUI for Quit Game, and Restart Game.Ã,  So far the words "Yes" and "No" are buttons which you click to answer.Ã,  However, how can I enable the game to additionally respond to the key presses “Y” and “N”?
Ã,  Ã,  Ã, My GUI is Popup Modal GUI, which sort of pauses the game, so the basic IsKeyPressed command will not work.Ã,  Is there a work around to activate key presses when a Popup Modal GUI is up?
Ã,  Ã,  Ã, I've done something similar to enable the “Enter” button for my Popup Modal Restore GUI.
This I've worked on this method in this post:
http://americangirlscouts.org/bbc.com/yabb/index.php?topic=27365.0
This method is also referred to the bottom of this post:
http://americangirlscouts.org/bbc.com/yabb/index.php?topic=27365.0
Ã,  Ã,  Ã, However, these methods use a special situation to enable “Enter” that is exclusive to the Enter key.Ã,  Basically you create an invisible text box in the GUI and use the Activate command.
Code: ags

#sectionstart tboxLoad_ActivateÃ,  // DO NOT EDIT OR REMOVE THIS LINE
function tboxLoad_Activate(GUIControl *control) {
Ã,  btnRestoreRestore_Click(btnRestoreRestore, eMouseLeft);Ã,  //Pressing enter triggers Restore game button
}
#sectionend tboxLoad_ActivateÃ,  // DO NOT EDIT OR REMOVE THIS LINE

Ã,  Ã,  Ã, However, as stated, this method seems to be exclusive to the Enter key.Ã,  If anybody has thoughts on enabling Y / N key press activation withÃ,  a Popup Modal GUI I'd be grateful to here about it.
Ã,  Ã,  Ã, Thank you in advance.

Ashen

You could try using repeatedly_execute_always. If you haven't created it already, paste this code somewhere in your global script:
Code: ags

function repeatedly_execute_always () {
  if (gInventory.Visible == true) { // Replace with script-name of your GUI, e.g gRestore
    if (IsKeyPressed('Y')) {
      Display("Yes");
      // Or whatever you actually want to happen
    }
    else if (IsKeyPressed('N')) {
      Display("No");
      // Or whatever you actually want to happen
    }	
  }
}


If you already have a rep_ex_always, just copy the relevant parts. If you place the function after the GUIControl functions, you can probably call the appropriate Button function when you press a key, as you have with tboxLoad_Activate and btnRestoreRestore_Click in the code sample you posted.
I know what you're thinking ... Don't think that.

Husky

It works PERFECT.Ã,  Thanks Ashen.Ã,  I didn't realize that repeatedly_execute_always truly works always, including when the game is paused with a Popup Modal GUI.

mishels

it works for me also in the repeatedly_execute function with an Esc button hiding pop up gui and space bar showing and hiding pause gui.

SMF spam blocked by CleanTalk