//--- OBJECT WRITE BEGIN ---
new GuiControl(EscapeScreen) {
   profile = "GuiDefaultProfile";
   horizSizing = "right";
   vertSizing = "bottom";
   position = "0 0";
   extent = "800 600";
   minExtent = "8 2";
   visible = "1";
   alpha = "1";

   new GuiBitmapCtrl(escapeScreen_blackBackground) {
      profile = "GuiDefaultProfile";
      horizSizing = "relative";
      vertSizing = "relative";
      position = "0 0";
      extent = "800 600";
      minExtent = "8 2";
      visible = "1";
      alpha = "0.7";
      bitmap = "./images/black.jpg";
      wrap = "0";
   };
   new GuiBitmapCtrl(EscapeScreenButtons) {
      profile = "GuiDefaultProfile";
      horizSizing = "relative";
      vertSizing = "relative";
      position = "256 84";
      extent = "288 378";
      minExtent = "8 2";
      visible = "1";
      alpha = "1";
      bitmap = "./images/smallSelectionBox";
      wrap = "0";

      new GuiBitmapButtonCtrl(escape_Journal) {
         profile = "GuiWoodButtonProfile";
         horizSizing = "relative";
         vertSizing = "relative";
         position = "23 200";
         extent = "241 53";
         minExtent = "8 2";
         visible = "1";
         command = "PG_EscapeDialog();";
         alpha = "1";
         lockMouse = "0";
         bitmap = "./images/buttons/woodButton_normal.png";
         HighlightBitmap = "./images/buttons/woodButton_hover.png";
         PressedBitmap = "./images/buttons/woodButton_down.png";
         text = lookup("Journal");
            percentWidth = "100";
            charspacing = "0.5";
            charaspect = "1";
            wrap = "0";
            fontBitmap = "./images/buttons/woodButton_font.png";
            percentHeight = "55";
      };
      new GuiBitmapButtonCtrl(escape_gameOptions) {
         profile = "GuiWoodButtonProfile";
         horizSizing = "relative";
         vertSizing = "relative";
         position = "23 142";
         extent = "241 53";
         minExtent = "8 2";
         visible = "1";
         command = "TS_showOptions();";
         alpha = "1";
         lockMouse = "0";
         bitmap = "./images/buttons/woodButton_normal.png";
         HighlightBitmap = "./images/buttons/woodButton_hover.png";
         PressedBitmap = "./images/buttons/woodButton_down.png";
         text = "Options";
            percentWidth = "100";
            charspacing = "0.5";
            charaspect = "1";
            wrap = "0";
            fontBitmap = "./images/buttons/woodButton_font.png";
            percentHeight = "55";
      };
      new GuiBitmapButtonCtrl(escape_Save) {
         profile = "GuiWoodButtonProfile";
         horizSizing = "relative";
         vertSizing = "relative";
         position = "23 84";
         extent = "241 53";
         minExtent = "8 2";
         visible = "1";
         alpha = "1";
         lockMouse = "0";
         bitmap = "./images/buttons/woodButton_normal.png";
         HighlightBitmap = "./images/buttons/woodButton_hover.png";
         PressedBitmap = "./images/buttons/woodButton_down.png";
         text = "Save Experiment";
            percentWidth = "100";
            charspacing = "0.5";
            charaspect = "1";
            wrap = "0";
            fontBitmap = "./images/buttons/woodButton_font.png";
            percentHeight = "55";
      };
      new GuiBitmapButtonCtrl(escape_resumeGame) {
         profile = "GuiWoodButtonProfile";
         horizSizing = "relative";
         vertSizing = "relative";
         position = "23 24";
         extent = "241 54";
         minExtent = "8 2";
         visible = "1";
         command = "EscapeScreen.fadeOut();";
         alpha = "1";
         lockMouse = "0";
         bitmap = "./images/buttons/woodButton_normal.png";
         HighlightBitmap = "./images/buttons/woodButton_hover.png";
         PressedBitmap = "./images/buttons/woodButton_down.png";
         text = "Return to Game";
            percentWidth = "100";
            charspacing = "0.5";
            charaspect = "1";
            wrap = "0";
            fontBitmap = "./images/buttons/woodButton_font.png";
            percentHeight = "55";
      };
      new GuiBitmapButtonCtrl(escape_Quit) {
         profile = "GuiWoodButtonProfile";
         horizSizing = "relative";
         vertSizing = "relative";
         position = "23 275";
         extent = "241 54";
         minExtent = "8 2";
         visible = "1";
         command = "PG_EscapeQuit();";
         alpha = "1";
         lockMouse = "0";
         bitmap = "./images/buttons/woodButton_normal.png";
         HighlightBitmap = "./images/buttons/woodButton_hover.png";
         PressedBitmap = "./images/buttons/woodButton_down.png";
         text = lookup("ExitGame");
            percentWidth = "100";
            charspacing = "0.5";
            charaspect = "1";
            wrap = "0";
            fontBitmap = "./images/buttons/woodButton_font.png";
            percentHeight = "55";
      };
   };
};
//--- OBJECT WRITE END ---

function EscapeScreen::fadeOut()
{
  EscapeScreen.animateAlpha(0,1,500);
  canvas.schedule(520,popDialog,escapeScreen);
}
function escape_Save::onAction()
{
 if( !catchem.isRegisteredVersion() )
   MessageBoxOk("NotRegistered",lookup("RegisterTubetwistToSave") );
 else
 {
   SaveReplay_Name.setText(MissionInfo.userName);
   SaveReplayDialog.sleepCommand = "";
   canvas.pushDialog(SaveReplayDialog);
 }
}


function EscapeScreen::onWake(%this)
{
   MoveMap.pop();
   PlayGui.enableGridCellHighlighting(false);
}


function EscapeScreen::onSleep(%this)
{
   MoveMap.push();
   PlayGui.enableGridCellHighlighting(true);
   playGui.toggleSimulationWithKeystroke_TooSoon = 0;
}
