//--- OBJECT WRITE BEGIN ---
new GuiControl(PauseDlg) {
   profile = "GuiDefaultProfile";
   horizSizing = "width";
   vertSizing = "height";
   position = "0 0";
   extent = "640 480";
   minExtent = "8 8";
   visible = "1";
   class = "PauseDialog";
   helpTag = "0";

   new GuiBitmapCtrl(PauseDlgBG) {
      profile = "GuiDefaultProfile";
      horizSizing = "width";
      vertSizing = "height";
      position = "0 0";
      extent = "640 480";
      bitmap = "pool/gui/images/bg_overlay";
   };
   new GuiPoolDialogCtrl(PauseDlgCtrl) {
      profile = "GuiPoolDialogProfile";
      horizSizing = "center";
      vertSizing = "center";
      position = "142 108";
      extent = "355 264";
      minExtent = "8 2";
      visible = "1";
      class = "PauseDialog";
      
      new GuiBitmapCtrl(PauseDlgIco) {
         profile = "GuiDefaultProfile";
         position = "12 11";
         extent = "16 16";
         bitmap = "pool/gui/images/ico_downRight";
      };
      new GuiMLTextCtrl(PauseText) 
      {
         text = "<just:center><color:FFFFFF><shadow:1:1><shadowcolor:00000064>" @ $Text::GamePaused;
         //text = $Text::GamePaused;
         profile = "GuiTextProfile";
         horizSizing = "right";
         vertSizing = "bottom";
         position = "6 80";
         extent = "328 30";
         minExtent = "8 8";
         visible = "1";
         lineSpacing = "2";
         allowColorChars = "0";
         maxChars = "-1";
         class = "PauseDialog";
         helpTag = "0";
      };
      new GuiButtonCtrl(gps) {
         profile = "PoolButtonProfile";
         horizSizing = "right";
         vertSizing = "top";
         position = "93 160";
         extent = "148 44";
         minExtent = "8 8";
         visible = "1";
         command = "MessageCallback(PauseDlg,PauseDlg.callback);";
         accelerator = "escape";
         text = $Text::Continue;
         groupNum = "-1";
         buttonType = "PushButton";
         shadowColor = "0 0 0 100";
         shadowOffset = "1 1";
         simpleStyle = "0";
         helpTag = "0";
      };
   };
};

function PauseDialog::onWake( %this )
{
   if( isEventPending( Gameplay.pingLegalThread ) )
      cancel( Gameplay.pingLegalThread );
   
   if( !getSimPause() )
   {
      %this.wePaused = true;
      
      Canvas.setCursor(DefaultCursor);
      
      setSimPause( true );
      EventManager.setActive( false );
   }
   
   // stripmine
   stripScreenChange( "mbPause_Open" );
}

function PauseDialog::onSleep( %this )
{
   if( %this.wePaused )
   {
      setSimPause( false );
      EventManager.setActive( true );
      
      %this.wePaused = false;
   }
   
   // unmute all sounds
   alxListenerf( AL_GAIN_LINEAR, $Pref::Audio::MasterVolume );
   
   // check autoping
   Gameplay.pingLegalThread = Gameplay.schedule( $PingDelayAfterPause, "autoPing" );
   
   // stripmine
   stripScreenChange( "mbPause_Close" );
}

//--- OBJECT WRITE END ---
