Annoying GUI Issue

Started by DazJ, Fri 01/08/2008 11:17:28

Previous topic - Next topic

DazJ

When the player presses ESC he is greeted with the gPanel but also the Quit GUI. All I want is the gPanel to display, NOT the Quit GUI.

Is it something to do with ZOrder? I've put the Quit GUI to the back and to the front but it still doesn't work. All it does it brings it to the back or front of the gPanel.

Like I say, when the player presses ESC all I want is for the gPanel GUI to appear - NOT the QuitGUI.

Anybody any ideas how to fix this?

Mazoliin

#1
Code: ags

bool quit;

function repeatedly_execute_always(){
  if (IsTimerExpired(20)){
    quit = true;
  }
}

function on_key_press(int keycode){
if (keycode == 27){ //Esc
  if (gPanel.Visible == true){
    quit = false;
    SetTimer(20, 5);
    gPanel.Visible = false;
  }
  else if (quit == true){
    QuitGame(0);
  }
}


Edit:
Woops! Should read more carefully

Khris

Quote from: DazJ on Fri 01/08/2008 11:17:28Is it something to do with ZOrder? I've put the Quit GUI to the back and to the front but it still doesn't work. All it does it brings it to the back or front of the gPanel.
Exactly. That's all ZOrder does.

Looking at the default on_key_press and testing it, as expected, I only get the Panel on pressing esc.

Are you using custom code somewhere? If that's the case, why didn't you post it?

DazJ

Quote from: KhrisMUC on Fri 01/08/2008 11:37:37
Quote from: DazJ on Fri 01/08/2008 11:17:28Is it something to do with ZOrder? I've put the Quit GUI to the back and to the front but it still doesn't work. All it does it brings it to the back or front of the gPanel.
Exactly. That's all ZOrder does.

Looking at the default on_key_press and testing it, as expected, I only get the Panel on pressing esc.

Are you using custom code somewhere? If that's the case, why didn't you post it?

Code: ags

function on_key_press(int keycode) {
  // The following is called before "if game is paused keycode=0", so
  // it'll happen even when the game is paused.
  
  if (keycode==27 && gRestartYN.Visible) {
    //Use ESC to cancel restart.
    gRestartYN.Visible = false; 
    QuitGUI.Visible=false;
    gIconbar.Visible = true;
    // If the panel's not ON, then the player must have gotten here by tapping F9,
    // therefore his cursor needs restoring. If the panel IS on, then it doesn't,
    // because it's already a pointer. Get used to thinking like this!!
    if (!gPanel.Visible) mouse.UseDefaultGraphic(); 
    return;
  }
  if (keycode==27 && gPanel.Visible) {
    // Use ESC to turn the panel off.
    gPanel.Visible = false; 
    QuitGUI.Visible=false;
    mouse.UseDefaultGraphic();
    gIconbar.Visible = true;
    return;
  }
  if (keycode==13) { 
    // ENTER, in this case merely confirms restart
    if (gRestartYN.Visible) RestartGame();
  }

  if (IsGamePaused() == 1) keycode=0;  // game paused, so don't react to keypresses

  // FUNCTION KEYS AND SYSTEM SHORTCUTS
  if (keycode==27) {
    // ESC
    QuitGUI.Visible=false;
    gPanel.Visible = true;
    gIconbar.Visible = false;
    mouse.UseModeGraphic(eModePointer);
  }
  if (keycode==17)  gPanel.Visible=false; PlaySound(1); QuitGUI.Visible = true;   // Ctrl-Q
  if (keycode==363) SaveGameDialog();   // F5
  if (keycode==365) RestoreGameDialog();  // F7
  if (keycode==367) {
    // F9, asks the player to confirm restarting (so much better to always confirm first)
    gRestartYN.Visible = true;  
    gIconbar.Visible = false;
    mouse.UseModeGraphic(eModePointer);
  }
  if (keycode==434) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode==9)   show_inventory_window();  // Tab, show inventory

  // GAME COMMAND SHORTCUTS
  if (keycode == 'W') mouse.Mode=eModeWalkto; //Notice this alternate way to indicate keycodes.
  if (keycode == 'L') mouse.Mode=eModeLookat; //Note that all we do here is set modes.
  if (keycode == 'U') mouse.Mode=eModeInteract; //If you want something else to happen, such as GUI buttons highlighting,
  if (keycode == 'T') mouse.Mode=eModeTalkto; //you'll need some more scripting done.
  if (keycode == 'I') mouse.Mode=eModeUseinv; //But this will, as-is, give you some standard keyboard shortcuts your players will very much appreciate.

  // For extra cursor modes, such as pick up, feel free to add as you will.
  // Uncomment the line below if you use the "Pick Up" mode.
  //if (keycode == 'P' || keycode == 'G') mouse.Mode=eModePickup; 

  // DEBUG FUNCTIONS
  if (keycode==19)  Debug(0,0);  // Ctrl-S, give all inventory
  if (keycode==22)  Debug(1,0);  // Ctrl-V, version
  if (keycode==1)   Debug(2,0);  // Ctrl-A, show walkable areas
  if (keycode==24)  Debug(3,0);  // Ctrl-X, teleport to room
  if (keycode==23 && game.debug_mode) player.PlaceOnWalkableArea(); //Ctrl-W, move to walkable area 
}

SMF spam blocked by CleanTalk