Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: Mikael on April 08, 2007, 03:04:22 PM

Title: Custom menu screen problems
Post by: Mikael on April 08, 2007, 03:04:22 PM
Again, I feel quite stupid. However, it's clear that I am not the only one having this problem, which gives me the courage to ask.

I want to bring up a custom menu screen when the escape key is pressed. I've borrowed a code snippet from the Mystic Triddle demo (see below).

When I paste the code into the game script everything works PERFECTLY FINE, except that when I am in the menu scene, and press escape again, it reloads the menu scene, instead of resuming the game. What makes this especially annoying is that when the menu scene has been reloaded, "Resume game" does not work, since it goes back to the previous scene, in this case the previous occurence of the menu scene.

In the Mystic Triddle demo, pressing escape when in the menu resumes game, BUT, in the Beyond the Threshold demo, in which the same method is used, the exact same problem occurs, that is when pressing escape in the menu, the menu reloads, and the game can't be resumed after that.

This is the code I've used:

Code: [Select]
////////////////////////////////////////////////////////////////////////////////
on "Keypress"
{
  // on Esc or F1 key
  if(Keyboard.KeyCode==VK_ESCAPE || Keyboard.KeyCode==VK_F1)
  {

  if(Scene.name == "menu")
  {
     if(Game.PrevSceneFilename == "")
      ;
     else
      {
  Game.ChangeScene(Game.PrevSceneFilename); // Go back to game - acts like resume game
  }
  }
  else
  {
  if(Game.SelectedItem!=null) // deselect Items if active
  Game.SelectedItem = null;
 
  //Game.ScreenshotEx("saves\temp.bmp",200,150);   // when we want to store a screenshot manually
  Game.ChangeScene("scenes\menu\menu.scene");      // load and display the main menu window
  }
   
  }
}

Thanks for any help!

Regards,

Mikael
Title: Re: Custom menu screen problems
Post by: Mnemonic on April 08, 2007, 03:11:54 PM
"Scene.name" should be Scene.Name. WME scripts are case-sensitive.
Title: Re: Custom menu screen problems
Post by: Mikael on April 08, 2007, 03:25:15 PM
Oh, thanks. Now it works fine.

Mikael