Example #1
0
void CWebView::Initialise ()
{
    // Initialise the web session (which holds the actual settings) in in-memory mode
    CefBrowserSettings browserSettings;
    browserSettings.windowless_frame_rate = g_pCore->GetFrameRateLimit ();
    browserSettings.javascript_access_clipboard = cef_state_t::STATE_DISABLED;
    browserSettings.java = cef_state_t::STATE_DISABLED;
    browserSettings.caret_browsing = cef_state_t::STATE_ENABLED;
    browserSettings.universal_access_from_file_urls = cef_state_t::STATE_DISABLED; // Also filtered by resource interceptor, but set this nevertheless
    browserSettings.file_access_from_file_urls = cef_state_t::STATE_DISABLED;
    browserSettings.webgl = cef_state_t::STATE_ENABLED;
    browserSettings.javascript_open_windows = cef_state_t::STATE_DISABLED;

    bool bEnabledPlugins;
    CVARS_GET ( "browser_plugins", bEnabledPlugins );
    browserSettings.plugins = bEnabledPlugins ? cef_state_t::STATE_ENABLED : cef_state_t::STATE_DISABLED;
    if ( !m_bIsLocal )
    {
        bool bEnabledJavascript;
        CVARS_GET ( "browser_remote_javascript", bEnabledJavascript );
        browserSettings.javascript = bEnabledJavascript ? cef_state_t::STATE_ENABLED : cef_state_t::STATE_DISABLED;
    }

    CefWindowInfo windowInfo;
    windowInfo.SetAsWindowless ( g_pCore->GetHookedWindow (), m_bIsTransparent );
    
    CefBrowserHost::CreateBrowser ( windowInfo, this, "", browserSettings, nullptr );
}
Example #2
0
void CCommunity::Initialize ( void )
{
    CVARS_GET ( "community_username", m_strUsername );
    CVARS_GET ( "community_password", m_strPassword );

    if ( !m_strUsername.empty() && !m_strPassword.empty() )
        Login ();
}
Example #3
0
////////////////////////////////////////////////////
//
//  CMouseControl::ProcessMouseMove
//
//  Process a windows mouse movement message and turn it into control
//
////////////////////////////////////////////////////
bool CMouseControl::ProcessMouseMove ( UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    if ( uMsg != WM_MOUSEMOVE )
        return false;

    if ( g_pCore->GetGame ()->GetSystemState () != 9 )
        return false;

    // HACK:  Grab our local player, and check his vehicle
    CPed* pPed = g_pCore->GetGame ()->GetPools ()->GetPedFromRef ( (DWORD)1 );
    if ( !pPed )
        return false;

    CVehicle* pVehicle = pPed->GetVehicle ();
    if ( !pVehicle )
        return false;

    CModelInfo* pModelInfo = g_pCore->GetGame ()->GetModelInfo( pVehicle->GetModelIndex() );

    bool bVar;
    CVARS_GET ( "fly_with_mouse", bVar );
    if ( pModelInfo->IsPlane() || pModelInfo->IsHeli() && !bVar ) // Are we in a plane, but not have mouse flight enabled?
        return false;

    CVARS_GET ( "steer_with_mouse", bVar );
    if ( !bVar )  // Are we in another type of vehicle, but not have mouse steering enabled?
        return false;


    // Let's calculate our mouse movement directions
    CVector2D resolution = g_pCore->GetGUI()->GetResolution();
    int iX = LOWORD ( lParam ), iY = HIWORD ( lParam );
    float fX = (iX - resolution.fX*0.5f)/resolution.fX;

    fX *= MOUSE_CONTROL_MULTIPLIER;

    float fMouseSensitivity = g_pCore->GetGame ( )->GetSettings()->GetMouseSensitivity ();
    fX *= fMouseSensitivity;

    m_usLeftStickX += fX*128;
    m_usLeftStickX  = Clamp < const short > ( -128, m_usLeftStickX, 128 );

    // Only process Y input if we're in a vehicle that requires it
    if ( pModelInfo->IsPlane() || pModelInfo->IsHeli() || pModelInfo->IsBike() || pModelInfo->IsBmx() || pModelInfo->IsQuadBike() )
    {
        float fY = (resolution.fY*0.5f - iY)/resolution.fY;
        fY *= MOUSE_CONTROL_MULTIPLIER;
        fY *= fMouseSensitivity;

        CVARS_GET ( "invert_mouse", bVar );
        fY = bVar ? -fY : fY;

        m_usLeftStickY += fY*128;
        m_usLeftStickY  = Clamp < const short > ( -128, m_usLeftStickY, 128 );
    }

    return true;
}
Example #4
0
void CQuickConnect::LoadData ( void )
{
    std::string val;
    unsigned int uval;

    CVARS_GET ( "qc_host",      val );   m_pEditHost->SetText ( val.c_str () );

    CVARS_GET ( "qc_port",      uval );
    m_pEditPort->SetText ( SString ( "%u", uval ) );

    CVARS_GET ( "qc_password",  val );  m_pEditPass->SetText ( val.c_str () );
}
Example #5
0
// Clamp float variable
void CClientVariables::ClampValue ( const std::string& strVariable, float fMinValue, float fMaxValue  )
{
    float fTemp;
    CVARS_GET ( strVariable, fTemp );
    fTemp = Clamp ( fMinValue, fTemp, fMaxValue );
    CVARS_SET ( strVariable, fTemp );
}
Example #6
0
// Clamp int variable
void CClientVariables::ClampValue ( const std::string& strVariable, int iMinValue, int iMaxValue  )
{
    int iTemp;
    CVARS_GET ( strVariable, iTemp );
    iTemp = Clamp ( iMinValue, iTemp, iMaxValue );
    CVARS_SET ( strVariable, iTemp );
}
Example #7
0
// Clamp CVector2D variable
void CClientVariables::ClampValue ( const std::string& strVariable, CVector2D minValue, CVector2D maxValue  )
{
    CVector2D temp;
    CVARS_GET ( strVariable, temp );
    temp.fX = Clamp ( minValue.fX, temp.fX, maxValue.fX );
    temp.fY = Clamp ( minValue.fY, temp.fY, maxValue.fY );
    CVARS_SET ( strVariable, temp );
}
Example #8
0
// Clamp CColor variable
void CClientVariables::ClampValue ( const std::string& strVariable, CColor minValue, CColor maxValue  )
{
    CColor temp;
    CVARS_GET ( strVariable, temp );
    temp.R = Clamp ( minValue.R, temp.R, maxValue.R );
    temp.G = Clamp ( minValue.G, temp.G, maxValue.G );
    temp.B = Clamp ( minValue.B, temp.B, maxValue.B );
    temp.A = Clamp ( minValue.A, temp.A, maxValue.A );
    CVARS_SET ( strVariable, temp );
}
///////////////////////////////////////////////////////////////
//
// CVideoModeManager::LoadCVars
//
// Loads to current
//
///////////////////////////////////////////////////////////////
void CVideoModeManager::LoadCVars ( void )
{
    // Upgrade display_alttab_handler
    bool bAltTabHandlerWasEnabled = CVARS_GET_VALUE < bool > ( "display_alttab_handler" );
    int iFullscreenStyle = CVARS_GET_VALUE < int > ( "display_fullscreen_style" );
    if ( bAltTabHandlerWasEnabled && iFullscreenStyle == 0 )
    {
        CVARS_SET ( "display_alttab_handler", false );
        CVARS_SET ( "display_fullscreen_style", FULLSCREEN_BORDERLESS );
    }

    // Apply override
    if ( GetApplicationSettingInt( "nvhacks", "optimus-force-windowed" ) )
    {
        SetApplicationSettingInt( "nvhacks", "optimus-force-windowed", 0 );
        CVARS_SET ( "display_windowed", true );
    }

    m_iCurrentVideoMode = m_pGameSettings->GetCurrentVideoMode ();
    CVARS_GET ( "display_windowed",             m_bCurrentWindowed );
    CVARS_GET ( "display_fullscreen_style",     m_iCurrentFullscreenStyle );
    CVARS_GET ( "multimon_fullscreen_minimize", m_bCurrentFullScreenMinimize );
}
Example #10
0
bool CQuickConnect::OnConnectButtonClick ( CGUIElement* pElement )
{
    // No host specified?
    const std::string& strHost = m_pEditHost->GetText ();
    if ( strHost.length () == 0 )
    {
        CCore::GetSingleton ().ShowMessageBox ( "Error", "No host specified!", MB_BUTTON_OK | MB_ICON_INFO );
        return true;
    }

    // No/invalid port specified?
    const std::string& strPort = m_pEditPort->GetText ();
    int iPort = atoi ( strPort.c_str () );
    if ( strPort.length () == 0 )
    {
        CCore::GetSingleton ().ShowMessageBox ( "Error", "No port specified!", MB_BUTTON_OK | MB_ICON_INFO );
        return true;
    }
    else if ( iPort == 0 || iPort > 0xFFFF )
    {
        CCore::GetSingleton ().ShowMessageBox ( "Error", "Invalid port specified!", MB_BUTTON_OK | MB_ICON_INFO );
        return true;
    }

    // Valid nick?
    std::string strNick;
    CVARS_GET ( "nick", strNick );
    if ( !CCore::GetSingleton ().IsValidNick ( strNick.c_str () ) )
    {
        CCore::GetSingleton ().ShowMessageBox ( "Error", "Invalid nickname! Please go to Settings and set a new!", MB_BUTTON_OK | MB_ICON_INFO );
        return true;
    }

    // Grab the host, port, nick and password
    unsigned short usPort = static_cast < unsigned short > ( iPort );
    const std::string& strPassword = m_pEditPass->GetText ();

    // Save the connection details into the config
    CVARS_SET ( "qc_host", strHost );
    CVARS_SET ( "qc_port", usPort );
    CVARS_SET ( "qc_password", strPassword );

    // Start the connect
    CCore::GetSingleton ().GetConnectManager ()->Connect ( strHost.c_str (), usPort, strNick.c_str (), strPassword.c_str () );

    return true;
}
Example #11
0
bool CWebCore::GetPluginsEnabled ()
{
    bool bArePluginsEnabled;
    CVARS_GET ( "browser_plugins", bArePluginsEnabled );
    return bArePluginsEnabled;
}
Example #12
0
bool CWebCore::GetRemoteJavascriptEnabled ()
{
    bool bIsRemoteJavascriptEnabled;
    CVARS_GET ( "browser_remote_javascript", bIsRemoteJavascriptEnabled );
    return bIsRemoteJavascriptEnabled;
}
Example #13
0
bool CWebCore::GetRemotePagesEnabled ()
{
    bool bCanLoadRemotePages;
    CVARS_GET ( "browser_remote_websites", bCanLoadRemotePages );
    return bCanLoadRemotePages;
}
Example #14
0
////////////////////////////////////////////////////////////////
//
// CRenderItemManager::GetDxStatus
//
//
//
////////////////////////////////////////////////////////////////
void CRenderItemManager::GetDxStatus ( SDxStatus& outStatus )
{
    outStatus.testMode = m_TestMode;

    // Copy hardware settings
    outStatus.videoCard.strName = m_strVideoCardName;
    outStatus.videoCard.iInstalledMemoryKB = m_iVideoCardMemoryKBTotal;
    outStatus.videoCard.strPSVersion = m_strVideoCardPSVersion;
    outStatus.videoCard.depthBufferFormat = m_depthBufferFormat;
    outStatus.videoCard.iMaxAnisotropy = g_pDeviceState->AdapterState.MaxAnisotropicSetting;
    outStatus.videoCard.iNumSimultaneousRTs = g_pDeviceState->DeviceCaps.NumSimultaneousRTs;

    // State
    outStatus.state.iNumShadersUsingReadableDepthBuffer = m_ShadersUsingDepthBuffer.size();

    // Memory usage
    outStatus.videoMemoryKB.iFreeForMTA = m_iMemoryKBFreeForMTA;
    outStatus.videoMemoryKB.iUsedByFonts = m_iFontMemoryKBUsed;
    outStatus.videoMemoryKB.iUsedByTextures = m_iTextureMemoryKBUsed;
    outStatus.videoMemoryKB.iUsedByRenderTargets = m_iRenderTargetMemoryKBUsed;

    // Option settings
    CGameSettings* gameSettings = CCore::GetSingleton ().GetGame ()->GetSettings ();
    outStatus.settings.bWindowed = GetVideoModeManager()->IsDisplayModeWindowed();
    outStatus.settings.iFullScreenStyle = GetVideoModeManager()->GetFullScreenStyle();
    outStatus.settings.iFXQuality = gameSettings->GetFXQuality(); ;
    outStatus.settings.iDrawDistance = ( gameSettings->GetDrawDistance () - 0.925f ) / 0.8749f * 100;
    outStatus.settings.iAntiAliasing = gameSettings->GetAntiAliasing() - 1;
    outStatus.settings.bVolumetricShadows = false;
    outStatus.settings.bAllowScreenUpload = true;
    outStatus.settings.iStreamingMemory = 0;
    outStatus.settings.bGrassEffect = false;
    outStatus.settings.bHeatHaze = false;
    outStatus.settings.iAnisotropicFiltering = 0;
    outStatus.settings.aspectRatio = gameSettings->GetAspectRatio ();
    outStatus.settings.bHUDMatchAspectRatio = true;
    outStatus.settings.fFieldOfView = 70;
    outStatus.settings.bHighDetailVehicles = false;

    CVARS_GET ( "streaming_memory",     outStatus.settings.iStreamingMemory );
    CVARS_GET ( "volumetric_shadows",   outStatus.settings.bVolumetricShadows );
    CVARS_GET ( "allow_screen_upload",  outStatus.settings.bAllowScreenUpload );
    CVARS_GET ( "grass",                outStatus.settings.bGrassEffect );
    CVARS_GET ( "heat_haze",            outStatus.settings.bHeatHaze );
    CVARS_GET ( "anisotropic",          outStatus.settings.iAnisotropicFiltering );
    CVARS_GET ( "hud_match_aspect_ratio", outStatus.settings.bHUDMatchAspectRatio );
    CVARS_GET ( "fov",                  outStatus.settings.fFieldOfView );
    CVARS_GET ( "high_detail_vehicles", outStatus.settings.bHighDetailVehicles );

    if ( outStatus.settings.iFXQuality == 0 )
    {
        // These are always off with low fx quality
        outStatus.settings.bVolumetricShadows = false;
        outStatus.settings.bGrassEffect = false;
    }

    // Display color depth
    D3DFORMAT BackBufferFormat = g_pDeviceState->CreationState.PresentationParameters.BackBufferFormat;
    if ( BackBufferFormat >= D3DFMT_R5G6B5 && BackBufferFormat < D3DFMT_A8R3G3B2 )
        outStatus.settings.b32BitColor = 0;
    else
        outStatus.settings.b32BitColor = 1;

    // Modify if using test mode
    if ( m_TestMode == DX_TEST_MODE_NO_MEM )
        outStatus.videoMemoryKB.iFreeForMTA = 0;

    if ( m_TestMode == DX_TEST_MODE_LOW_MEM )
        outStatus.videoMemoryKB.iFreeForMTA = 1;

    if ( m_TestMode == DX_TEST_MODE_NO_SHADER )
        outStatus.videoCard.strPSVersion = "0";
}
Example #15
0
////////////////////////////////////////////////////////////////
//
// CPixelsManager::GetTexturePixels
//
// Copy pixels from texture
//
////////////////////////////////////////////////////////////////
bool CPixelsManager::GetTexturePixels ( IDirect3DBaseTexture9* pD3DBaseTexture, CPixels& outPixels, const RECT* pRect, uint uiSurfaceIndex )
{
    if ( !pD3DBaseTexture )
        return false;

    IDirect3DSurface9* pD3DSurface = NULL;
    CAutoReleaseMe < IDirect3DSurface9 > Thanks( pD3DSurface );

    D3DRESOURCETYPE resourceType = pD3DBaseTexture->GetType ();
    if ( resourceType == D3DRTYPE_VOLUMETEXTURE )
    {
        return GetVolumeTexturePixels ( (IDirect3DVolumeTexture9*)pD3DBaseTexture, outPixels, pRect, uiSurfaceIndex );
    }
    else
    if ( resourceType == D3DRTYPE_CUBETEXTURE )
    {
        D3DCUBEMAP_FACES FaceType = (D3DCUBEMAP_FACES)uiSurfaceIndex;
        ((IDirect3DCubeTexture9*)pD3DBaseTexture)->GetCubeMapSurface ( FaceType, 0, &pD3DSurface );
        if ( !pD3DSurface )
            return false;
    }
    else
    if ( resourceType == D3DRTYPE_TEXTURE )
    {
        ((IDirect3DTexture9*)pD3DBaseTexture)->GetSurfaceLevel ( 0, &pD3DSurface );
        if ( !pD3DSurface )
            return false;
    }



    bool bResult = false;
    D3DSURFACE_DESC Desc;
    pD3DSurface->GetDesc ( &Desc );

    if ( Desc.Usage == D3DUSAGE_RENDERTARGET )
    {
        // Check we are allowed to read the render target
        bool bAllowScreenUpload = true;
        CVARS_GET ( "allow_screen_upload", bAllowScreenUpload );
        if ( bAllowScreenUpload )
        {
            // Get pixels onto offscreen surface
            IDirect3DSurface9* pLockableSurface = GetRTLockableSurface ( pD3DSurface );

            // Then
            bResult = GetSurfacePixels ( pLockableSurface, outPixels, pRect );
        }
        else
        {
            // If not allowed, return dummy data
            uint uiPixelsWidth = 32;
            uint uiPixelsHeight = 32;
            outPixels.SetSize ( uiPixelsWidth * uiPixelsHeight * XRGB_BYTES_PER_PIXEL + SIZEOF_PLAIN_TAIL );
            memset ( outPixels.GetData (), 0xEF, outPixels.GetSize () );
            bResult = SetPlainDimensions ( outPixels, uiPixelsWidth, uiPixelsHeight );
        }
    }
    else
    if ( Desc.Usage == 0 )
    {
        if ( Desc.Format == D3DFMT_A8R8G8B8 || Desc.Format == D3DFMT_X8R8G8B8 || Desc.Format == D3DFMT_R5G6B5 )
        {
            // Direct reading will work here
            bResult = GetSurfacePixels ( pD3DSurface, outPixels, pRect );
        }
        else
        {
            // If not a simple format, use D3DX to convert
            if ( !GetMatchingOffscreenSurface ( pD3DSurface, m_pTempOffscreenSurface, D3DFMT_A8R8G8B8 ) )
                return false;

            if ( FAILED ( D3DXLoadSurfaceFromSurface ( m_pTempOffscreenSurface, NULL, NULL, pD3DSurface, NULL, NULL, D3DX_FILTER_NONE, 0 ) ) )
                return false;

            // Then
            bResult = GetSurfacePixels ( m_pTempOffscreenSurface, outPixels, pRect );
        }
    }

    return bResult;
}
void CDirect3DEvents9::OnPresent ( IDirect3DDevice9 *pDevice )
{
    TIMING_CHECKPOINT( "+OnPresent1" );
    // Start a new scene. This isn't ideal and is not really recommended by MSDN.
    // I tried disabling EndScene from GTA and just end it after this code ourselves
    // before present, but that caused graphical issues randomly with the sky.
    if ( pDevice->BeginScene() == D3D_OK )
        g_bInMTAScene = true;

    // Reset samplers on first call
    static bool bDoneReset = false;
    if ( !bDoneReset )
    {
        bDoneReset = true;
        for ( uint i = 0 ; i < 16 ; i++ )
        {
            pDevice->SetSamplerState ( i, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
            pDevice->SetSamplerState ( i, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
            pDevice->SetSamplerState ( i, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
        }
    }

    CGraphics::GetSingleton ().EnteringMTARenderZone();

    // Tell everyone that the zbuffer will need clearing before use
    CGraphics::GetSingleton ().OnZBufferModified ();

    TIMING_CHECKPOINT( "-OnPresent1" );
    // Notify core
    CCore::GetSingleton ().DoPostFramePulse ();
    TIMING_CHECKPOINT( "+OnPresent2" );

    // Restore in case script forgets
    CGraphics::GetSingleton ().GetRenderItemManager ()->RestoreDefaultRenderTarget ();

    // Draw pre-GUI primitives
    CGraphics::GetSingleton ().DrawPreGUIQueue ();

    // Maybe grab screen for upload
    CGraphics::GetSingleton ().GetScreenGrabber ()->DoPulse ();

    // Draw the GUI
    CLocalGUI::GetSingleton().Draw ();

    // Draw post-GUI primitives
    CGraphics::GetSingleton ().DrawPostGUIQueue ();

    // Redraw the mouse cursor so it will always be over other elements
    CLocalGUI::GetSingleton().DrawMouseCursor();

    CGraphics::GetSingleton().DidRenderScene();

    CGraphics::GetSingleton ().LeavingMTARenderZone();

    // End the scene that we started.
    pDevice->EndScene ();
    g_bInMTAScene = false;

    // Update incase settings changed
    int iAnisotropic;
    CVARS_GET ( "anisotropic", iAnisotropic );
    ms_RequiredAnisotropicLevel = 1 << iAnisotropic;
    ms_DiagnosticDebug = CCore::GetSingleton ().GetDiagnosticDebug ();
    CCore::GetSingleton().GetGUI ()->SetBidiEnabled ( ms_DiagnosticDebug != EDiagnosticDebug::BIDI_6778 );
    
    // Make a screenshot if needed
    CheckForScreenShot ();

    TIMING_CHECKPOINT( "-OnPresent2" );

    CGraphics::GetSingleton ().GetRenderItemManager ()->FlushNonAARenderTarget();
}