Mouse show hide gui

Started by Candle, Sat 05/02/2005 06:45:54

Previous topic - Next topic

Candle

What or where is the code to show hide the gui ?
I have the gui coming from the bottom but right now I have to move the mouse at the top to show the gui .
Thanks


Candle

Could you tell me how this works ?
function repeatedly_execute() {

if ((IsGUIOn(MYGUI)==0) && (mouse.y >= system.screen_height - 5)) GUIOn(MYGUI);

else GUIOff(MYGUI);

}

MYGUI the name of the gui . what way will it come from the way it is now ?
Do you change this system.screen_height ?

strazer

#3
Actually, better do this, so the GUI only hides again if you leave the GUI area:

Code: ags

function repeatedly_execute() {
  //...

  if (mouse.y >= system.viewport_height-5) GUIOn(MYGUI);
  else if (IsGUIOn(MYGUI) && mouse.y < MYGUI_Y_POSITION) GUIOff(MYGUI);

  //...
}


The GUI will popup on the bottom of the screen. But you have to adjust its Y position in the properties window first. If your resolution is 320x200 and your GUI has a height of say, 30, set its Y position to 170 (200-30) and replace MYGUI_Y_POSITION with this value as well.
The 5 is the number of pixels on the bottom of the screen that trigger the GUI popup. Increase or decrease at your discretion.

system.viewport_height is a system variable that holds the height of the screen, you don't have to change it.

Edit:

Changed system.screen_height to system.viewport_height

Candle

I can't get that to work so going to give up on the idea .

Goot

You probably have the GUI set to y-position, so that it pops up. You want it set to normal or popup model.

Candle

#6
Quote from: Goot on Sat 05/02/2005 18:09:39
You probably have the GUI set to y-position, so that it pops up. You want it set to normal or popup model.
I gave both a try and it didn't popup at all .
I see a small flash of it when the game loads and thats it . won't popup .

if (interface == COM) {
  if (button==0) SetCursorMode(MODE_WALK);
  if (button==1) SetCursorMode(MODE_LOOK);
  if (button==2) SetCursorMode(MODE_USE);
  if (button==3) SetCursorMode(5);
  if (button==4) SetCursorMode(MODE_TALK);
  if (button==5) SetCursorMode(8);
  if ((button == 7) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed))  {
      game.top_inv_item = game.top_inv_item + game.items_per_line;  }
  if ((button == 6) && (game.top_inv_item > 0))  {
      game.top_inv_item = game.top_inv_item - game.items_per_line;  }
  }

  if (interface == SET) {     // They clicked a button on the Settings Tab
    if (button == 0)  {  // save game
      GUIOff(SET);
      SaveGameDialog();}
    else if (button == 1) {  // load game
      GUIOff(SET);
      RestoreGameDialog();}
    else if (button == 2)   // restart game
      RestartGame();
    else if (button == 3) {  // quit
      GUIOff(SET);
      QuitGame(1);}
    else if (button == 4) {   // about
      Display("Adventure Game Studio v2 run-time engine[     Copyright (c) 1999-2003 Chris Jones");}
    else if (button == 5) {  // resume
      GUIOff (SET);
      SetCursorMode (MODE_WALK);
      }
    else if (button == 6) {  // volume
      SetDigitalMasterVolume (GetSliderValue (SET, 6));
      string vol;
      StrFormat (vol, "%d", GetSliderValue(SET, 6));
      SetLabelText(SET, 8, vol);   }
    else if (button == 7) {  // game speed
      SetGameSpeed (GetSliderValue (SET, 7));
      string spe;
      StrFormat (spe, "%d", GetSliderValue(SET, 7));
      SetLabelText(SET, 9, spe);   }
    }  // end if interface SET


The rest .
Code: ags
// main global script file

#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() {
  // called when the game starts, before the first room is loaded
}
#sectionend game_start  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() {
  //...

  if (mouse.y >= system.screen_height-5) GUIOn(COM);
  else if (IsGUIOn(COM) && mouse.y < 155) GUIOff(COM);

  //...
}
#sectionend repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE


function show_inventory_window () {
  // This demonstrates both types of inventory window - the first part is how to
  // show the built-in inventory window, the second part uses the custom one.
  // Un-comment one section or the other below.
  
  // ** DEFAULT INVENTORY WINDOW
  InventoryScreen();
/*  
  // ** CUSTOM INVENTORY WINDOW
  GUIOn (INVENTORY);  
  // switch to the Use cursor (to select items with)
  SetCursorMode (MODE_USE);
  // But, override the appearance to look like the arrow
  SetMouseCursor (6);
*/
}

#sectionstart on_key_press  // DO NOT EDIT OR REMOVE THIS LINE
function on_key_press(int keycode) {
  // called when a key is pressed. keycode holds the key's ASCII code
  if (IsGamePaused() == 1) keycode=0;  // game paused, so don't react to keypresses
  if (keycode==17)  QuitGame(1);   // Ctrl-Q
  if (keycode==363) SaveGameDialog();   // F5
  if (keycode==365) RestoreGameDialog();  // F7
  if (keycode==367) RestartGame();  // F9
  if (keycode==434) SaveScreenShot("scrnshot.bmp");  // F12
  if (keycode==9)   show_inventory_window();  // Tab, show inventory

  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
}
#sectionend on_key_press  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(int 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)
  }
  else if (button==LEFT) {
    ProcessClick(mouse.x, mouse.y, GetCursorMode() );
  }
  else {   // right-click, so cycle cursor
    SetNextCursorMode();
  }
}
#sectionend on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE


#sectionstart interface_click  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) {
if (interface == COM) {
  if (button==0) SetCursorMode(MODE_WALK);
  if (button==1) SetCursorMode(MODE_LOOK);
  if (button==2) SetCursorMode(MODE_USE);
  if (button==3) SetCursorMode(5);
  if (button==4) SetCursorMode(MODE_TALK);
  if (button==5) SetCursorMode(8);
  if ((button == 7) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed))  {
      game.top_inv_item = game.top_inv_item + game.items_per_line;  }
  if ((button == 6) && (game.top_inv_item > 0))  { 
      game.top_inv_item = game.top_inv_item - game.items_per_line;  }
  }

  if (interface == SET) {     // They clicked a button on the Settings Tab
    if (button == 0)  {  // save game
      GUIOff(SET);
      SaveGameDialog();}
    else if (button == 1) {  // load game
      GUIOff(SET);
      RestoreGameDialog();}
    else if (button == 2)   // restart game
      RestartGame();
    else if (button == 3) {  // quit
      GUIOff(SET);
      QuitGame(1);}
    else if (button == 4) {   // about
      Display("Adventure Game Studio v2 run-time engine[     Copyright (c) 1999-2003 Chris Jones");}
    else if (button == 5) {  // resume
      GUIOff (SET);
      SetCursorMode (MODE_WALK);
      }
    else if (button == 6) {  // volume
      SetDigitalMasterVolume (GetSliderValue (SET, 6));
      string vol;
      StrFormat (vol, "%d", GetSliderValue(SET, 6));
      SetLabelText(SET, 8, vol);   }
    else if (button == 7) {  // game speed
      SetGameSpeed (GetSliderValue (SET, 7));
      string spe;
      StrFormat (spe, "%d", GetSliderValue(SET, 7));
      SetLabelText(SET, 9, spe);   }
    }  // end if interface SET

}
#sectionend interface_click  // DO NOT EDIT OR REMOVE THIS LINE


Scorpiorus

Try replacing system.screen_height with system.viewport_height:

Code: ags
if (mouse.y >= system.viewport_height-5) GUIOn(COM);
else if (IsGUIOn(COM) && mouse.y < 155) GUIOff(COM);


The problem with system.screen_height is that checking for it may not work at resolutions higher than 320x200(240) or 400x300.

Candle

That work great now . I just have to get the inv one to popup now so it will work .
Code: ags

if (interface == COM) {
  if (button==0) SetCursorMode(MODE_WALK);
  if (button==1) SetCursorMode(MODE_LOOK);
  if (button==2) SetCursorMode(MODE_USE);
  if (button==3) SetCursorMode(5);
  if (button==4) SetCursorMode(MODE_TALK);
  if (button==5) SetCursorMode(8);
  if ((button == 7) && (game.top_inv_item < game.num_inv_items - game.num_inv_displayed))  {
      game.top_inv_item = game.top_inv_item + game.items_per_line;  }
  if ((button == 6) && (game.top_inv_item > 0))  { 
      game.top_inv_item = game.top_inv_item - game.items_per_line;  }
  }

  if (interface == SET) {     // They clicked a button on the Settings Tab
    if (button == 0)  {  // save game
      GUIOff(SET);
      SaveGameDialog();}
    else if (button == 1) {  // load game
      GUIOff(SET);
      RestoreGameDialog();}
    else if (button == 2)   // restart game
      RestartGame();
    else if (button == 3) {  // quit
      GUIOff(SET);
      QuitGame(1);}
    else if (button == 4) {   // about
      Display("Adventure Game Studio v2 run-time engine[     Copyright (c) 1999-2003 Chris Jones");}
    else if (button == 5) {  // resume
      GUIOff (SET);
      SetCursorMode (MODE_WALK);
      }
    else if (button == 6) {  // volume
      SetDigitalMasterVolume (GetSliderValue (SET, 6));
      string vol;
      StrFormat (vol, "%d", GetSliderValue(SET, 6));
      SetLabelText(SET, 8, vol);   }
    else if (button == 7) {  // game speed
      SetGameSpeed (GetSliderValue (SET, 7));
      string spe;
      StrFormat (spe, "%d", GetSliderValue(SET, 7));
      SetLabelText(SET, 9, spe);   }
    }  // end if interface SET



what it looks like .
The main window popups but the little with SQq does not popup ?

Scorpiorus

QuoteThe main window popups but the little with SQq does not popup ?
But how and when do you want it to pop up? The repeatedly_execute's code in question is about the COM GUI. Can you elaborate a bit on what you're after?

Candle

Well I kind of left it as a non popup aS i Could'nt get the little  brown sqs to popup with the rest of the gui .

Scorpiorus

Well, you can then probably just make your inventory window be part of the main GUI unless you have a certain reason to do otherwise.

SMF spam blocked by CleanTalk