// Called when the menu loses focus void CMenuDisplay::OnFocus(DBOOL bFocus) { HCONSOLEVAR hVar; int curMO, oldMO; DBOOL bSet; // Set the render mode if we are losing focus if (!bFocus && m_pRendererCtrl && m_pResolutionCtrl) { hVar = m_pClientDE->GetConsoleVar("MipmapOffset"); oldMO = (int)m_pClientDE->GetVarValueFloat (hVar); UpdateData(); // Save the global detail setting SaveDetailSetting(); bSet = SetRenderer(m_pRendererCtrl->GetSelIndex(), m_pResolutionCtrl->GetSelIndex()); // If we didn't switch resolutions and the mipmap offset changed, rebind textures. if(!bSet) { hVar = m_pClientDE->GetConsoleVar("MipmapOffset"); curMO = (int)m_pClientDE->GetVarValueFloat (hVar); if(curMO != oldMO) { m_pClientDE->RunConsoleString("RebindTextures"); } } } else { // The current render mode RMode currentMode; m_pClientDE->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); } } } } }
// Build the folder LTBOOL CFolderDisplay::Build() { CreateTitle(IDS_TITLE_DISPLAYOPTIONS); // m_pRendererLabel = AddTextItem(IDS_DISPLAY_RENDERER, FOLDER_CMD_DISPLAY, IDS_HELP_RENDERER, LTTRUE); // if (m_pRendererLabel) // { // m_pRendererLabel->Enable(LTFALSE); // } // Build the array of renderers BuildRendererArray(); // Add the "renderer" option m_pRendererCtrl = AddCycleItem(IDS_DISPLAY_RENDERER,IDS_HELP_RENDERER,100,25,LTNULL); unsigned int i; for (i=0; i < m_rendererArray.GetSize(); i++) { // Load the renderer formating text. This is "Renderer: [%s - %s]" in English HSTRING hRendererFormat=g_pLTClient->FormatString(IDS_DMODE_RENDERER, m_rendererArray[i].m_renderDll, m_rendererArray[i].m_description); m_pRendererCtrl->AddString(hRendererFormat); g_pLTClient->FreeString(hRendererFormat); } // m_pResolutionLabel = AddTextItem(IDS_DISPLAY_RESOLUTION, FOLDER_CMD_RESOLUTION, IDS_HELP_RESOLUTION, LTTRUE); // if (m_pResolutionLabel) // { // m_pResolutionLabel->Enable(LTFALSE); // } // Add the "resolution" control m_pResolutionCtrl = AddCycleItem(IDS_DISPLAY_RESOLUTION,IDS_HELP_RESOLUTION,150,25,LTNULL, LTFALSE); // Setup the resolution control based on the currently selected renderer SetupResolutionCtrl(); CToggleCtrl *pToggle = AddToggle(IDS_DISPLAY_TEXTURE,IDS_HELP_TEXTUREDEPTH,175,&m_bTexture32); pToggle->SetOnString(IDS_DISPLAY_32BIT); pToggle->SetOffString(IDS_DISPLAY_16BIT); m_pHardwareCursor = AddToggle(IDS_HARDWARE_CURSOR,IDS_HELP_HARDWARE_CURSOR,175,&m_bHardwareCursor); m_pHardwareCursor->SetOnString(IDS_ON); m_pHardwareCursor->SetOffString(IDS_OFF); CalculateLastDrawn(); // Make sure to call the base class if (!CBaseFolder::Build()) return LTFALSE; UseBack(LTTRUE,LTTRUE); return LTTRUE; }
LTBOOL CFolderDisplay::OnRButtonUp(int x, int y) { // Get the control that the click was on int nControlIndex=0; if (GetControlUnderPoint(x, y, &nControlIndex)) { CLTGUICtrl* pCtrl = GetControl(nControlIndex); if (m_pCaptureCtrl && pCtrl != m_pCaptureCtrl) return LTFALSE; // If the mouse is over the same control now as it was when the down message was called // then send the "left" message to the control. if (nControlIndex == m_nRMouseDownItemSel) { if (pCtrl->IsEnabled()) { if (GetSelectedControl() == m_pRendererCtrl) { // Get the current resolution FolderDisplayResolution currentResolution=GetCurrentSelectedResolution(); LTBOOL handled = pCtrl->OnRButtonUp(x,y); if (handled) { SetupResolutionCtrl(); // Set the resolution for the control SetCurrentCtrlResolution(currentResolution); } return handled; } else if (pCtrl == m_pHardwareCursor) { return OnLeft(); } else { SetSelection(nControlIndex); return CBaseFolder::OnRButtonUp(x,y); } } } } else { m_nRMouseDownItemSel= kNoSelection; } return LTFALSE; }
// Override the right control void CMenuDisplay::OnRight() { // Get the current resolution MenuDisplayResolution currentResolution=GetCurrentSelectedResolution(); CMenuBase::OnRight(); // If the renderer control is selected, rebuild the resolutions control if (GetCurrentItem() == m_pRendererCtrl) { SetupResolutionCtrl(); // Set the resolution for the control SetCurrentCtrlResolution(currentResolution); } }
// Build the menu void CMenuDisplay::Build() { // Make sure to call the base class CMenuBase::Build(); CreateTitle("interface\\mainmenus\\options.pcx", IDS_MENU_TITLE_OPTIONS, m_pMainMenus->GetTitlePos()); SetOptionPos(m_pMainMenus->GetOptionsPos()); SetItemSpacing(0); SetScrollWrap(DFALSE); // Show the please wait message m_pMainMenus->ShowSyncMessage(IDS_MENU_MESSAGE_PLEASEWAIT); // Build the array of renderers BuildRendererArray(); // Add the "renderer" option m_pRendererCtrl=AddTextItemOption(DNULL, 0, m_pMainMenus->GetSmallFont()); if (!m_pRendererCtrl) { return; } unsigned int i; for (i=0; i < m_rendererArray.GetSize(); i++) { // Load the renderer formating text. This is "Renderer: [%s - %s]" in English HSTRING hRendererFormat=m_pClientDE->FormatString(IDS_MENU_DISPLAY_RENDERER, m_rendererArray[i].m_renderDll, m_rendererArray[i].m_description); m_pRendererCtrl->AddString(hRendererFormat); m_pClientDE->FreeString(hRendererFormat); } // Add the "resolution" control m_pResolutionCtrl=AddTextItemOption(DNULL, 0, m_pMainMenus->GetSmallFont()); if (!m_pResolutionCtrl) { return; } // Setup the resolution control based on the currently selected renderer SetupResolutionCtrl(); // Add the detail option CLTGUITextItemCtrl *pCtrl=AddTextItemOption(DNULL, 0, m_pMainMenus->GetSmallFont(), 1, DTRUE, &m_nDetailLevel); pCtrl->AddString(IDS_MENU_DISPLAY_DETAIL_LOW); pCtrl->AddString(IDS_MENU_DISPLAY_DETAIL_MEDIUM); pCtrl->AddString(IDS_MENU_DISPLAY_DETAIL_HIGH); // Load the detail setting HCONSOLEVAR hVar=m_pClientDE->GetConsoleVar("GlobalDetail"); if (hVar) { switch ((int)m_pClientDE->GetVarValueFloat(hVar)) { case DETAIL_LOW: { m_nDetailLevel=0; break; } case DETAIL_MEDIUM: { m_nDetailLevel=1; break; } case DETAIL_HIGH: { m_nDetailLevel=2; break; } } } else { m_nDetailLevel=2; } UpdateData(DFALSE); }
// Called when the screen gains or focus void CScreenDisplay::OnFocus(LTBOOL bFocus) { CUserProfile *pProfile = g_pProfileMgr->GetCurrentProfile(); if (bFocus) { m_bEscape = LTFALSE; pProfile->SetDisplay(); m_bHardwareCursor = pProfile->m_bHardwareCursor; m_bVSync = pProfile->m_bVSync; float gamma = pProfile->m_fGamma; m_nGamma = ConvertToSlider(gamma); 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 i; for (i=0; i < m_rendererData.m_resolutionArray.GetSize(); i++) { RMode mode=GetRendererModeStruct(i); if (IsRendererEqual(¤tMode, &mode)) { // Setup the resolution control SetupResolutionCtrl(); // Set the resolution index m_pResolutionCtrl->SetSelIndex(i); } } UpdateData(LTFALSE); } else { UpdateData(); if (m_bEscape) { pProfile->m_bHardwareCursor = m_bHardwareCursor; pProfile->m_bVSync = m_bVSync; pProfile->m_fGamma = ConvertToGamma(m_nGamma); // Set the render mode if we are losing focus if (m_pResolutionCtrl) { // Get the new renderer structure RMode newMode=GetRendererModeStruct(m_pResolutionCtrl->GetSelIndex()); pProfile->m_nScreenWidth = newMode.m_Width; pProfile->m_nScreenHeight = newMode.m_Height; pProfile->m_nScreenDepth = newMode.m_BitDepth; } pProfile->ApplyDisplay(); //display settings can affect performance sttings so update them here... g_pPerformanceMgr->GetPerformanceOptions(&pProfile->m_sPerformance); pProfile->Save(); } } CBaseScreen::OnFocus(bFocus); }
// Build the screen LTBOOL CScreenDisplay::Build() { CreateTitle(IDS_TITLE_DISPLAYOPTIONS); kGap = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_DISPLAY,"ColumnWidth"); kWidth = g_pLayoutMgr->GetScreenCustomInt(SCREEN_ID_DISPLAY,"SliderWidth"); //background frame LTRect frameRect = g_pLayoutMgr->GetScreenCustomRect(SCREEN_ID_DISPLAY,"FrameRect"); LTIntPt pos(frameRect.left,frameRect.top); int nHt = frameRect.bottom - frameRect.top; int nWd = frameRect.right - frameRect.left; char szFrame[128]; g_pLayoutMgr->GetScreenCustomString(SCREEN_ID_DISPLAY,"FrameTexture",szFrame,sizeof(szFrame)); HTEXTURE hFrame = g_pInterfaceResMgr->GetTexture(szFrame); CLTGUIFrame *pFrame = debug_new(CLTGUIFrame); pFrame->Create(hFrame,nWd,nHt+8,LTTRUE); pFrame->SetBasePos(pos); pFrame->SetBorder(2,m_SelectedColor); AddControl(pFrame); // Build the array of renderers GetRendererData(); // Add the "resolution" control m_pResolutionCtrl = AddCycle(IDS_DISPLAY_RESOLUTION,IDS_HELP_RESOLUTION,kGap); // Setup the resolution control based on the current renderer SetupResolutionCtrl(); m_pHardwareCursor = AddToggle(IDS_HARDWARE_CURSOR,IDS_HELP_HARDWARE_CURSOR,kGap,&m_bHardwareCursor); AddToggle(IDS_VSYNC,IDS_HELP_VSYNC,kGap,&m_bVSync); m_pGamma = AddSlider(IDS_GAMMA,IDS_HELP_GAMMA,kGap,kWidth,-1,&m_nGamma); m_pGamma->SetSliderRange(0,kNumSteps); m_pGamma->SetSliderIncrement(1); int nBaseGamma = ConvertToSlider(1.0f); float xoffset = (m_pGamma->CalculateSliderOffset(nBaseGamma) / m_pGamma->GetScale()); uint16 nHeight = m_pGamma->GetBarHeight(); float yoffset = ((( (float)m_pGamma->GetBaseHeight()) - (float)nHeight)) / 2.0f; pos = m_pGamma->GetBasePos(); pos.x += (int)(xoffset - 1.0f); pos.y += (int)(yoffset + 0.5f); CLTGUIFrame *pBar = debug_new(CLTGUIFrame); pBar->Create(0xBF000000,3,nHeight+1); pBar->SetBasePos(pos); pBar->SetScale(g_pInterfaceResMgr->GetXRatio()); AddControl(pBar); // Make sure to call the base class if (!CBaseScreen::Build()) return LTFALSE; UseBack(LTTRUE,LTTRUE); return LTTRUE; }
// 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); }
// Called when the screen gains or focus void CScreenDisplay::OnFocus(bool bFocus) { CUserProfile *pProfile = g_pProfileMgr->GetCurrentProfile(); if (bFocus) { // clear all warning flags m_dwFlags &= ~eFlagWarningMask; m_bEscape = false; pProfile->SetDisplay(); m_bHardwareCursor = pProfile->m_bHardwareCursor; m_bVSync = pProfile->m_bVSync; m_bRestartRenderBetweenMaps = pProfile->m_bRestartRenderBetweenMaps; m_bUseTextScaling = pProfile->m_bUseTextScaling; float gamma = pProfile->m_fGamma; m_nGamma = ConvertToSlider(gamma); // 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 i; for (i=0; i < m_rendererData.m_resolutionArray.GetSize(); i++) { RMode mode=GetRendererModeStruct(i); if (IsRendererEqual(¤tMode, &mode)) { // Setup the resolution control SetupResolutionCtrl(); // Set the resolution index m_pResolutionCtrl->SetSelIndex(i); } } UpdateData(false); if( !CPerformanceMgr::Instance().ArePerformanceCapsValid() ) { g_pInterfaceResMgr->DrawMessage("PerformanceMessage_DetectVideoMemory"); CPerformanceMgr::Instance().DetectPerformanceStats( true ); } UpdateResolutionColor(); CheckResolutionMemory(); } else { UpdateData(); if (m_bEscape) { pProfile->m_bHardwareCursor = m_bHardwareCursor; pProfile->m_bVSync = m_bVSync; pProfile->m_bRestartRenderBetweenMaps = m_bRestartRenderBetweenMaps; pProfile->m_bUseTextScaling = m_bUseTextScaling; pProfile->m_fGamma = ConvertToGamma(m_nGamma); // Set the render mode if we are losing focus if (m_pResolutionCtrl) { // Get the new renderer structure RMode newMode=GetRendererModeStruct(m_pResolutionCtrl->GetSelIndex()); pProfile->m_nScreenWidth = newMode.m_Width; pProfile->m_nScreenHeight = newMode.m_Height; pProfile->m_nScreenDepth = newMode.m_BitDepth; } pProfile->ApplyDisplay(); pProfile->Save(); } } CBaseScreen::OnFocus(bFocus); }
// Build the screen bool CScreenDisplay::Build() { CreateTitle("IDS_TITLE_DISPLAYOPTIONS"); kGap = g_pLayoutDB->GetInt32(m_hLayout,LDB_ScreenColumnWidths,0); kWidth = g_pLayoutDB->GetInt32(m_hLayout,LDB_ScreenColumnWidths,1); kTotalWidth = kGap + kWidth; m_nWarningColor = g_pLayoutDB->GetInt32(m_hLayout, LDB_ScreenAddColor, 0); //background frame CLTGUICtrl_create frameCs; TextureReference hFrame(g_pLayoutDB->GetString(m_hLayout,LDB_ScreenFrameTexture)); frameCs.rnBaseRect = g_pLayoutDB->GetRect(m_hLayout,LDB_ScreenFrameRect,0); CLTGUIFrame *pFrame = debug_new(CLTGUIFrame); pFrame->Create(hFrame, frameCs); AddControl(pFrame); // Build the array of renderers GetRendererData( m_rendererData ); // Add the "resolution" control CLTGUICycleCtrl_create ccs; ccs.nHeaderWidth = kGap; ccs.rnBaseRect.m_vMin = m_ScreenRect.m_vMin; ccs.rnBaseRect.m_vMax = m_ScreenRect.m_vMin + LTVector2n(kTotalWidth,g_pLayoutDB->GetInt32(m_hLayout,LDB_ScreenFontSize)); ccs.szHelpID = "IDS_HELP_RESOLUTION"; ccs.pCommandHandler = this; ccs.nCommandID = CMD_DISPLAY_CYCLE; m_pResolutionCtrl = AddCycle("IDS_DISPLAY_RESOLUTION",ccs); // Setup the resolution control based on the current renderer SetupResolutionCtrl(); CLTGUIToggle_create tcs; tcs.rnBaseRect.m_vMin.Init(); tcs.rnBaseRect.m_vMax = LTVector2n(kGap+kWidth,g_pLayoutDB->GetInt32(m_hLayout,LDB_ScreenFontSize)); tcs.szHelpID = "IDS_HELP_VSYNC"; tcs.pbValue = &m_bVSync; tcs.nHeaderWidth = kGap; AddToggle("IDS_VSYNC",tcs); tcs.szHelpID = "ScreenDisplay_RestartRender_Help"; tcs.pbValue = &m_bRestartRenderBetweenMaps; tcs.nHeaderWidth = kGap; AddToggle("ScreenDisplay_RestartRender",tcs); tcs.szHelpID = "ScreenDisplay_TextScaling_Help"; tcs.pbValue = &m_bUseTextScaling; tcs.nHeaderWidth = kGap; CLTGUIToggle* pTog = AddToggle("ScreenDisplay_TextScaling",tcs); pTog->SetOnString(LoadString("ScreenDisplay_TextScaling_Large")); pTog->SetOffString(LoadString("ScreenDisplay_TextScaling_Small")); CLTGUISlider_create scs; scs.rnBaseRect.m_vMin.Init(); scs.rnBaseRect.m_vMax = LTVector2n(kGap+kWidth,g_pLayoutDB->GetInt32(m_hLayout,LDB_ScreenFontSize)); scs.nBarOffset = kGap; scs.szHelpID = "IDS_HELP_GAMMA"; scs.pnValue = &m_nGamma; scs.nMin = 0; scs.nMax = kNumSteps; scs.nIncrement = 1; m_pGamma= AddSlider("IDS_GAMMA", scs ); int nBaseGamma = ConvertToSlider(kDefaultGamma); float xoffset = (m_pGamma->CalculateSliderOffset(nBaseGamma) / m_pGamma->GetScale().x); uint16 nHeight = m_pGamma->GetBarHeight(); float yoffset = ((( (float)m_pGamma->GetBaseHeight()) - (float)nHeight)) / 2.0f; LTVector2n pos = m_pGamma->GetBasePos(); pos.x += int(xoffset - 1.0f); pos.y += int(yoffset - 0.5f); CLTGUIFrame *pBar = debug_new(CLTGUIFrame); CLTGUICtrl_create cs; cs.rnBaseRect.m_vMin.Init(); cs.rnBaseRect.m_vMax = LTVector2n(3,nHeight+2); pBar->Create(0xBF000000,cs); pBar->SetBasePos(pos); pBar->SetScale(g_pInterfaceResMgr->GetScreenScale()); AddControl(pBar); CLTGUICtrl_create imageCs; hFrame.Load(g_pLayoutDB->GetString(m_hLayout,LDB_ScreenAddTex)); imageCs.rnBaseRect = g_pLayoutDB->GetRect(m_hLayout,LDB_ScreenFrameRect,1); pFrame = debug_new(CLTGUIFrame); pFrame->Create(hFrame, imageCs, true); AddControl(pFrame); uint32 nFontHeight = g_pLayoutDB->GetInt32(m_hLayout,LDB_ScreenAdditionalInt,0); cs.rnBaseRect = g_pLayoutDB->GetRect(m_hLayout,LDB_ScreenFrameRect,2); m_pWarning = AddTextItem("ScreenDisplay_ResolutionWarning",cs,true,NULL,nFontHeight); m_pWarning->SetWordWrap(true); m_pWarning->Show(false); // Make sure to call the base class if (!CBaseScreen::Build()) return false; UseBack(true,true); return true; }