public class ChromeMenuMissionSummary extends ChromeMenuWindow
{
    void SetEpisode(String sDescription)
    {
        if (sDescription != null)
        {
            ((UIStatic)GetElem("ID_EPISODE")).Show();
            ((UIStatic)GetElem("ID_EPISODE")).SetText(sDescription);
        }
        else
        {
            ((UIStatic)GetElem("ID_EPISODE")).Hide();
        }
    }
    
    void SetMissionState(String sDescription)
    {
        if (sDescription != null)
        {
            ((UIStatic)GetElem("ID_SUCC")).Show();
            ((UIStatic)GetElem("ID_SUCC")).SetText(sDescription);
        }
        else
        {
            ((UIStatic)GetElem("ID_SUCC")).Hide();
        }
    }
    
    void SetMissionStateComment(String sDescription)
    {
        if (sDescription != null)
        {
            ((UIStatic)GetElem("ID_SUCC_COMMENT")).Show();
            ((UIStatic)GetElem("ID_SUCC_COMMENT")).SetText(sDescription);
        }
        else
        {
            ((UIStatic)GetElem("ID_SUCC_COMMENT")).Hide();
        }
    }
    
    public void SetLoadingText(String sDescription)
    {
        if (sDescription != null)
        {
            ((UIStatic)GetElem("ID_PLEASE_WAIT")).Show();
            ((UIStatic)GetElem("ID_PLEASE_WAIT")).SetText(sDescription);
        }
        else
        {
            ((UIStatic)GetElem("ID_PLEASE_WAIT")).Hide();
        }
    }
    
    public void OnInit()
    {
        super.OnInit();
    }
    
    public void Show()
    {
        super.Show();
        
        ChromeMenuModule cMod = (ChromeMenuModule)GetModule();
        if(cMod.cGameInitInfo != null)
        {
            String sTitle = Text.Get(cMod.cGameInitInfo.cLevels.GetCurrent().sDescriptionTitleLevel);
            int nIndex = sTitle.indexOf('\n');
            if(nIndex > 0)
                sTitle = sTitle.substring(0, nIndex);
            SetEpisode(sTitle);
            
            
            String sMissionResult = null;
            String sMissionResultComment = null;
            if(cMod.ActiveLevelModule instanceof ChromeModuleSingle)
            {
                if(((ChromeModuleSingle)cMod.ActiveLevelModule).bMissionSuccessful)
                {
                    if(((ChromeModuleSingle)cMod.ActiveLevelModule).bMissiontoBeContinued)
                    {
                        sMissionResult = "&MISSION_TO_BE_CONTINUE&";
                        sMissionResultComment = "&MISSION_TO_BE_CONTINUE_COMMENT&";
                    }
                    else
                    {
                        sMissionResult = "&MISSION_SUCCESS&";
                        sMissionResultComment = "&MISSION_SUCCESS_COMMENT&";
                    }
                }
            }
            SetMissionState(sMissionResult);
            SetMissionStateComment(sMissionResultComment);
        }
        
        SetLoadingText(Text.Get("&PRESS_SPACE_TO_CONTINUE&"));
        
        cMod.RegisterKeyRequest();
    }
    
    public void NextLevel()
    {
        SetLoadingText(Text.Get("&MENU_MAIN_PLEASE_WAIT&"));
        ChromeMenuModule cMod = (ChromeMenuModule)GetModule();
        
        float fFadeTime = 1.f;
        cMod.FadeOutMusic(fFadeTime);
        CallMethodIn("DelayedNextLevel", fFadeTime);
    }
    
    public void DelayedNextLevel()
    {
        ChromeMenuModule cMod = (ChromeMenuModule)GetModule();
        cMod.MusicFadeForceStop();
        
        cMod.LevelFinished();
    }
}
