1111#include " helpers/toString.h"
1212#include " ogl/FontStyle.h"
1313#include " ogl/glArchivItem_Bitmap.h"
14+ #include < RescaleWindowProp.h>
1415#include < limits>
1516
1617// Set to highest possible so it is drawn last
1718const unsigned Desktop::fpsDisplayId = std::numeric_limits<unsigned >::max();
19+ constexpr DrawPoint fpsDisplayPos (800 , 0 );
1820
19- /* *
20- * Konstruktor für einen Spieldesktop
21- *
22- * @param[in] background Hintergrund des Desktops
23- */
2421Desktop::Desktop (glArchivItem_Bitmap* background)
2522 : Window(nullptr , 0 , DrawPoint::all(0 ), VIDEODRIVER.GetRenderSize()), background(background), lastFPS_(0 )
2623{
@@ -36,12 +33,6 @@ Desktop::Desktop(glArchivItem_Bitmap* background)
3633
3734Desktop::~Desktop () = default ;
3835
39- /* *
40- * Zeichenmethode zum Zeichnen des Desktops
41- * und der ggf. enthaltenen Steuerelemente.
42- *
43- * @return @p true bei Erfolg, @p false bei Fehler
44- */
4536void Desktop::Draw_ ()
4637{
4738 unsigned curFPS = VIDEODRIVER.GetFPS ();
@@ -54,14 +45,14 @@ void Desktop::Draw_()
5445 Window::Draw_ ();
5546}
5647
57- /* *
58- * Reagiert auf Spielfenstergrößenänderung
59- */
6048void Desktop::Msg_ScreenResize (const ScreenResizeEvent& sr)
6149{
6250 Window::Msg_ScreenResize (sr);
6351 // Resize to new screen size
6452 Resize (sr.newSize );
53+ auto * fpsDisplay = GetCtrl<ctrlText>(fpsDisplayId);
54+ if (fpsDisplay)
55+ fpsDisplay->SetPos (Scale (fpsDisplayPos));
6556}
6657
6758void Desktop::SetFpsDisplay (bool show)
@@ -70,7 +61,7 @@ void Desktop::SetFpsDisplay(bool show)
7061 DeleteCtrl (fpsDisplayId);
7162 else if (!GetCtrl<ctrlText>(fpsDisplayId) && SmallFont)
7263 {
73- AddText (fpsDisplayId, DrawPoint ( 800 , 0 ) , helpers::toString (lastFPS_) + " fps" , COLOR_YELLOW, FontStyle::RIGHT,
64+ AddText (fpsDisplayId, fpsDisplayPos , helpers::toString (lastFPS_) + " fps" , COLOR_YELLOW, FontStyle::RIGHT,
7465 SmallFont);
7566 }
7667}
0 commit comments