예제 #1
0
파일: ScreenREC.cs 프로젝트: zwong91/Titan
    private void StartRecord()
    {
        if (!bOpenREC)
        {
            return;
        }

        if (GameLogicAPI.isMainMap(SceneManager.Instance.getCurrentMapId()))
        {
            return;
        }

        string rootPath = ViewConfigManager.DataUserPath;

        if (rootPath == "")
        {
            return;
        }

        string tempPath = rootPath + "/" + szTempPathName;

        if (!Directory.Exists(tempPath))
        {
            Directory.CreateDirectory(tempPath);
        }

        gameview_start_screenCapture data = new gameview_start_screenCapture();

        if (Application.isEditor)
        {
            data.point_x = 0;
            data.point_y = 0;
            int width, height;
            ImageSetting.GetMainMonitorSize(out width, out height);
            data.width  = width;
            data.height = height;
        }
        else
        {
            RECTAPI rect = new RECTAPI();
            GameLogicAPI.GetWindowRect(Initialize.m_WindowHwnd, ref rect);

            data.point_x = rect.left;
            data.point_y = rect.top;

            int titleHeight = GameLogicAPI.GetSystemMetrics((int)ESystemMetrics.SM_CYCAPTION);
            //int frameBorder = GameLogicAPI.GetSystemMetrics((int)ESystemMetrics.SM_CXFRAME);

            data.width  = rect.right - rect.left;
            data.height = rect.bottom - rect.top;

            if (rect.top > 0)
            {
                data.point_y += titleHeight;
                data.height  -= titleHeight;
            }
        }
        data.width  = Mathf.Abs(data.width % 2 == 0 ? data.width : data.width - 1);
        data.height = Mathf.Abs(data.height % 2 == 0 ? data.height : data.height - 1);

        data.szTempFilePath = tempPath;
        ViewEventHelper.Instance.SendCommand <gameview_start_screenCapture>(GameLogicDef.GVIEWCMD_SCREENOPEN_OPEN, ref data);

        bRECValid      = false;
        nHeroID        = 0;
        checkPointTime = 0;
        recType        = EMScreenRECType.EMSS_Invalid;
        recState       = EMRECState.EMREC_RECORD;
    }