void CFolderGame::OnFocus(LTBOOL bFocus) { CGameSettings *pSettings = g_pInterfaceMgr->GetSettings(); if (bFocus) { m_bGore = pSettings->Gore(); m_nDifficulty = g_pGameClientShell->GetDifficulty(); m_bFadeBodies = g_pGameClientShell->GetFadeBodies(); m_nSubtitles = (int)g_vtSubtitles.GetFloat(); m_bAlwaysRun = pSettings->RunLock(); m_nLayout = (int)g_vtHUDLayout.GetFloat(); m_nHeadBob = (int)(10.0f * GetConsoleFloat("HeadBob",1.0f)); m_nWeaponSway = (int)(10.0f * GetConsoleFloat("WeaponSway",1.0f)); m_nPickupMsgDur = (int)(2.0f * GetConsoleFloat("PickupMessageDuration",5.0f)); m_bObjMessages = ( GetConsoleInt("ObjectiveMessages",1) > 0 ); UpdateData(LTFALSE); } else { UpdateData(); pSettings->SetBoolVar("Gore",m_bGore); g_vtSubtitles.WriteFloat((LTFLOAT)m_nSubtitles); g_vtHUDLayout.WriteFloat((LTFLOAT)m_nLayout); WriteConsoleInt("Difficulty",m_nDifficulty); g_pGameClientShell->SetDifficulty((GameDifficulty)m_nDifficulty); WriteConsoleInt("FadeBodies",(int)m_bFadeBodies); g_pGameClientShell->SetFadeBodies(m_bFadeBodies); pSettings->SetBoolVar("RunLock",m_bAlwaysRun); WriteConsoleFloat("HeadBob",((LTFLOAT)m_nHeadBob / 10.0f)); WriteConsoleFloat("WeaponSway",((LTFLOAT)m_nWeaponSway / 10.0f)); WriteConsoleFloat("PickupMessageDuration",((LTFLOAT)m_nPickupMsgDur / 2.0f)); WriteConsoleInt("ObjectiveMessages",m_bObjMessages); g_pLTClient->WriteConfigFile("autoexec.cfg"); } CBaseFolder::OnFocus(bFocus); }
// Change in focus void CFolderControls::OnFocus(LTBOOL bFocus) { CGameSettings *pSettings = g_pInterfaceMgr->GetSettings(); if (bFocus) { // Load the folder options from the console m_bUseJoystick=pSettings->UseJoystick(); CFolderJoystick *pJoy = (CFolderJoystick *)m_pFolderMgr->GetFolderFromID(FOLDER_ID_JOYSTICK); if (!pJoy->IsJoystickConfigured()) m_bUseJoystick = LTFALSE; m_pJoystickCtrl->Enable(m_bUseJoystick); UpdateData(LTFALSE); } else { UpdateData(); CGameSettings *pSettings = g_pInterfaceMgr->GetSettings(); pSettings->SetBoolVar("UseJoystick",m_bUseJoystick); if (m_bUseJoystick) { char strJoystick[128]; memset (strJoystick, 0, 128); LTRESULT result = g_pLTClient->GetDeviceName (DEVICETYPE_JOYSTICK, strJoystick, 127); if (result == LT_OK) { char strConsole[256]; sprintf (strConsole, "EnableDevice \"%s\"", strJoystick); g_pLTClient->RunConsoleString (strConsole); } else { pSettings->SetBoolVar("UseJoystick",LTFALSE); } } // Just to be safe save the config incase anything changed... g_pLTClient->WriteConfigFile("autoexec.cfg"); } CBaseFolder::OnFocus(bFocus); }
// Called when the folder gains or focus void CFolderDisplay::OnFocus(LTBOOL bFocus) { CGameSettings *pSettings = g_pInterfaceMgr->GetSettings(); if (bFocus) { m_bEscape = LTFALSE; m_bHardwareCursor = (GetConsoleInt("HardwareCursor",0) > 0 && GetConsoleInt("DisableHardwareCursor",0) == 0); m_pHardwareCursor->Enable(GetConsoleInt("DisableHardwareCursor",0) == 0); // The current render mode RMode currentMode; g_pLTClient->GetRenderMode(¤tMode); // Set the renderer controls so that they match the currently selected renderer unsigned int n; for (n=0; n < m_rendererArray.GetSize(); n++) { unsigned int i; for (i=0; i < m_rendererArray[n].m_resolutionArray.GetSize(); i++) { RMode mode=GetRendererModeStruct(n, i); if (IsRendererEqual(¤tMode, &mode)) { // Set the renderer index m_pRendererCtrl->SetSelIndex(n); // Setup the resolution control SetupResolutionCtrl(); // Set the resolution index m_pResolutionCtrl->SetSelIndex(i); } } } m_bTexture32 = pSettings->GetBoolVar("32BitTextures"); UpdateData(LTFALSE); SetSelection(1); } else { UpdateData(); if (m_bEscape) { LTBOOL bTexture32 = pSettings->GetBoolVar("32BitTextures"); WriteConsoleInt("HardwareCursor",(int)m_bHardwareCursor); pSettings->SetBoolVar("32BitTextures",m_bTexture32); LTBOOL bRebind = (bTexture32 != m_bTexture32); // Set the render mode if we are losing focus if (m_pRendererCtrl && m_pResolutionCtrl) { int oldMO = (int)pSettings->GetFloatVar("MipmapOffset"); LTBOOL bSet = SetRenderer(m_pRendererCtrl->GetSelIndex(), m_pResolutionCtrl->GetSelIndex()); // If we didn't switch resolutions and the mipmap offset changed, rebind textures. if(!bSet) { int curMO = (int)pSettings->GetFloatVar("MipmapOffset"); if(curMO != oldMO) { bRebind = LTTRUE; } } } if (bRebind) { g_pLTClient->Start3D(); g_pLTClient->StartOptimized2D(); g_pInterfaceResMgr->DrawMessage(GetSmallFont(),IDS_REBINDING_TEXTURES); g_pLTClient->EndOptimized2D(); g_pLTClient->End3D(); g_pLTClient->FlipScreen(0); g_pLTClient->RunConsoleString("RebindTextures"); } } if (GetConsoleInt("BitDepth",16) == 16) WriteConsoleInt("DrawPortals",0); else if ((GetConsoleInt("BitDepth",16) == 32) && (GetConsoleInt("PerformanceLevel",1) == 2)) WriteConsoleInt("DrawPortals",1); g_pLTClient->WriteConfigFile("autoexec.cfg"); } CBaseFolder::OnFocus(bFocus); }