@@ -616,109 +616,106 @@ public:
616616 // FPS Counter
617617 if (GetD3DX9_43DLL ())
618618 {
619- if (pMenuTab)
619+ static ID3DXFont* pFPSFont = nullptr ;
620+
621+ FusionFix::onBeforeReset () += []()
620622 {
621- static ID3DXFont* pFPSFont = nullptr ;
622-
623- FusionFix::onBeforeReset () += []()
624- {
625- if (pFPSFont)
626- pFPSFont->Release ();
627- pFPSFont = nullptr ;
628- };
629-
630- FusionFix::onEndScene () += []()
623+ if (pFPSFont)
624+ pFPSFont->Release ();
625+ pFPSFont = nullptr ;
626+ };
627+
628+ FusionFix::onEndScene () += []()
629+ {
630+ static auto fpsc = FusionFixSettings.GetRef (" PREF_FPSCOUNTER" );
631+ if (pMenuTab && *pMenuTab == 8 || *pMenuTab == 49 || fpsc->get ())
631632 {
632- static auto fpsc = FusionFixSettings.GetRef (" PREF_FPSCOUNTER" );
633- if (*pMenuTab == 8 || *pMenuTab == 49 || fpsc->get ())
633+ static std::list<int > m_times;
634+
635+ auto pDevice = *RageDirect3DDevice9::m_pRealDevice;
636+
637+ LARGE_INTEGER frequency;
638+ LARGE_INTEGER time;
639+ QueryPerformanceFrequency (&frequency);
640+ QueryPerformanceCounter (&time);
641+
642+ if (m_times.size () == 50 )
643+ m_times.pop_front ();
644+ m_times.push_back (static_cast <int >(time.QuadPart ));
645+
646+ uint32_t fps = 0 ;
647+ if (m_times.size () >= 2 )
648+ fps = static_cast <uint32_t >(0 .5f + (static_cast <double >(m_times.size () - 1 ) * static_cast <double >(frequency.QuadPart )) / static_cast <double >(m_times.back () - m_times.front ()));
649+
650+ if (!pFPSFont)
634651 {
635- static std::list<int > m_times;
636-
637- auto pDevice = *RageDirect3DDevice9::m_pRealDevice;
638-
639- LARGE_INTEGER frequency;
640- LARGE_INTEGER time;
641- QueryPerformanceFrequency (&frequency);
642- QueryPerformanceCounter (&time);
643-
644- if (m_times.size () == 50 )
645- m_times.pop_front ();
646- m_times.push_back (static_cast <int >(time.QuadPart ));
647-
648- uint32_t fps = 0 ;
649- if (m_times.size () >= 2 )
650- fps = static_cast <uint32_t >(0 .5f + (static_cast <double >(m_times.size () - 1 ) * static_cast <double >(frequency.QuadPart )) / static_cast <double >(m_times.back () - m_times.front ()));
651-
652- if (!pFPSFont)
653- {
654- D3DDEVICE_CREATION_PARAMETERS cparams;
655- RECT rect;
656- pDevice->GetCreationParameters (&cparams);
657- GetClientRect (cparams.hFocusWindow , &rect);
658-
659- D3DXFONT_DESC fps_font;
660- ZeroMemory (&fps_font, sizeof (D3DXFONT_DESC));
661- fps_font.Height = rect.bottom / 20 ;
662- fps_font.Width = 0 ;
663- fps_font.Weight = 400 ;
664- fps_font.MipLevels = 0 ;
665- fps_font.Italic = 0 ;
666- fps_font.CharSet = DEFAULT_CHARSET;
667- fps_font.OutputPrecision = OUT_DEFAULT_PRECIS;
668- fps_font.Quality = ANTIALIASED_QUALITY;
669- fps_font.PitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
670- wchar_t FaceName[] = L" Arial" ;
671- memcpy (&fps_font.FaceName , &FaceName, sizeof (FaceName));
672-
673- if (D3DXCreateFontIndirectW (pDevice, &fps_font, &pFPSFont) != D3D_OK)
674- return ;
675- }
676- else
652+ D3DDEVICE_CREATION_PARAMETERS cparams;
653+ RECT rect;
654+ pDevice->GetCreationParameters (&cparams);
655+ GetClientRect (cparams.hFocusWindow , &rect);
656+
657+ D3DXFONT_DESC fps_font;
658+ ZeroMemory (&fps_font, sizeof (D3DXFONT_DESC));
659+ fps_font.Height = rect.bottom / 20 ;
660+ fps_font.Width = 0 ;
661+ fps_font.Weight = 400 ;
662+ fps_font.MipLevels = 0 ;
663+ fps_font.Italic = 0 ;
664+ fps_font.CharSet = DEFAULT_CHARSET;
665+ fps_font.OutputPrecision = OUT_DEFAULT_PRECIS;
666+ fps_font.Quality = ANTIALIASED_QUALITY;
667+ fps_font.PitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
668+ wchar_t FaceName[] = L" Arial" ;
669+ memcpy (&fps_font.FaceName , &FaceName, sizeof (FaceName));
670+
671+ if (D3DXCreateFontIndirectW (pDevice, &fps_font, &pFPSFont) != D3D_OK)
672+ return ;
673+ }
674+ else
675+ {
676+ auto DrawTextOutline = [](ID3DXFont* pFont, FLOAT X, FLOAT Y, D3DXCOLOR dColor, CONST PCHAR cString, ...)
677677 {
678- auto DrawTextOutline = [](ID3DXFont* pFont, FLOAT X, FLOAT Y, D3DXCOLOR dColor, CONST PCHAR cString, ...)
678+ const D3DXCOLOR BLACK (D3DCOLOR_XRGB (0 , 0 , 0 ));
679+ CHAR cBuffer[101 ] = " " ;
680+
681+ va_list oArgs;
682+ va_start (oArgs, cString);
683+ _vsnprintf ((cBuffer + strlen (cBuffer)), (sizeof (cBuffer) - strlen (cBuffer)), cString, oArgs);
684+ va_end (oArgs);
685+
686+ RECT Rect[5 ] =
679687 {
680- const D3DXCOLOR BLACK (D3DCOLOR_XRGB (0 , 0 , 0 ));
681- CHAR cBuffer[101 ] = " " ;
682-
683- va_list oArgs;
684- va_start (oArgs, cString);
685- _vsnprintf ((cBuffer + strlen (cBuffer)), (sizeof (cBuffer) - strlen (cBuffer)), cString, oArgs);
686- va_end (oArgs);
687-
688- RECT Rect[5 ] =
689- {
690- { LONG (X - 1 ), LONG (Y), LONG (X + 500 .0f ), LONG (Y + 50 .0f ) },
691- { LONG (X), LONG (Y - 1 ), LONG (X + 500 .0f ), LONG (Y + 50 .0f ) },
692- { LONG (X + 1 ), LONG (Y), LONG (X + 500 .0f ), LONG (Y + 50 .0f ) },
693- { LONG (X), LONG (Y + 1 ), LONG (X + 500 .0f ), LONG (Y + 50 .0f ) },
694- { LONG (X), LONG (Y), LONG (X + 500 .0f ), LONG (Y + 50 .0f )},
695- };
696-
697- if (dColor != BLACK)
698- {
699- for (auto i = 0 ; i < 4 ; i++)
700- pFont->DrawTextA (NULL , cBuffer, -1 , &Rect[i], DT_NOCLIP, BLACK);
701- }
702-
703- pFont->DrawTextA (NULL , cBuffer, -1 , &Rect[4 ], DT_NOCLIP, dColor);
688+ { LONG (X - 1 ), LONG (Y), LONG (X + 500 .0f ), LONG (Y + 50 .0f ) },
689+ { LONG (X), LONG (Y - 1 ), LONG (X + 500 .0f ), LONG (Y + 50 .0f ) },
690+ { LONG (X + 1 ), LONG (Y), LONG (X + 500 .0f ), LONG (Y + 50 .0f ) },
691+ { LONG (X), LONG (Y + 1 ), LONG (X + 500 .0f ), LONG (Y + 50 .0f ) },
692+ { LONG (X), LONG (Y), LONG (X + 500 .0f ), LONG (Y + 50 .0f )},
704693 };
705- auto curEp = _dwCurrentEpisode ? *_dwCurrentEpisode : 0 ;
706- static char str_format_fps[] = " %02d" ;
707- static const D3DXCOLOR TBOGT (D3DCOLOR_XRGB (0xD7 , 0x11 , 0x6E ));
708- static const D3DXCOLOR TLAD (D3DCOLOR_XRGB (0x6F , 0x0D , 0x0F ));
709- static const D3DXCOLOR IV (D3DCOLOR_XRGB (0xF0 , 0xA0 , 0x00 ));
710- DrawTextOutline (pFPSFont, 10 , 10 , (curEp == 2 ) ? TBOGT : ((curEp == 1 ) ? TLAD : IV), str_format_fps, fps);
711- }
694+
695+ if (dColor != BLACK)
696+ {
697+ for (auto i = 0 ; i < 4 ; i++)
698+ pFont->DrawTextA (NULL , cBuffer, -1 , &Rect[i], DT_NOCLIP, BLACK);
699+ }
700+
701+ pFont->DrawTextA (NULL , cBuffer, -1 , &Rect[4 ], DT_NOCLIP, dColor);
702+ };
703+ auto curEp = _dwCurrentEpisode ? *_dwCurrentEpisode : 0 ;
704+ static char str_format_fps[] = " %02d" ;
705+ static const D3DXCOLOR TBOGT (D3DCOLOR_XRGB (0xD7 , 0x11 , 0x6E ));
706+ static const D3DXCOLOR TLAD (D3DCOLOR_XRGB (0x6F , 0x0D , 0x0F ));
707+ static const D3DXCOLOR IV (D3DCOLOR_XRGB (0xF0 , 0xA0 , 0x00 ));
708+ DrawTextOutline (pFPSFont, 10 , 10 , (curEp == 2 ) ? TBOGT : ((curEp == 1 ) ? TLAD : IV), str_format_fps, fps);
712709 }
713- };
714-
715- FusionFix::onShutdownEvent () += []()
716- {
717- if (pFPSFont)
718- pFPSFont-> Release ();
719- pFPSFont = nullptr ;
720- } ;
721- }
710+ }
711+ };
712+
713+ FusionFix::onShutdownEvent () += []()
714+ {
715+ if (pFPSFont)
716+ pFPSFont-> Release () ;
717+ pFPSFont = nullptr ;
718+ };
722719 }
723720 }
724721} Settings;
0 commit comments