Debian Codegraph @

src/game/timingoverlay.hpp

raw symbols SCIP
1 // This file is part of Dust Racing 2D.
2 // Copyright (C) 2012 Jussi Lind <[email protected]>
3 //
4 // Dust Racing 2D is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 // Dust Racing 2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>.
15
16 #ifndef TIMINGOVERLAY_HPP
17 #define TIMINGOVERLAY_HPP
18
19 #include "carstatusview.hpp"
20 #include "overlaybase.hpp"
21
22 #include <QObject>
23
24 #include <memory>
25 #include <string>
26 #include <vector>
27
28 #include <MCTextureText>
29
30 class Car;
31 class MCTextureFontManager;
32 class MCTextureFont;
33 class Race;
34 class Timing;
35
36 //! Renders the main information overlay on top of the game scene.
37 class TimingOverlay : public QObject, public OverlayBase
38 {
39 Q_OBJECT
40
41 public:
42 TimingOverlay();
43
44 //! \reimp
45 virtual void render() override;
46
47 //! \reimp
48 virtual bool update() override;
49
50 //! Show timing for the given car.
51 void setCarToFollow(const Car & car);
52
53 using RaceS = std::shared_ptr<Race>;
54 void setRace(RaceS race);
55
56 public slots:
57
58 //! Blink car status view if followed car matches the argument.
59 void blinkCarStatus(const Car &);
60
61 private slots:
62
63 void setLapRecord(int msecs);
64 void setRaceRecord(int msecs);
65
66 void blinkLapRecord();
67 void blinkRaceRecord();
68 void blinkCarStatus();
69
70 private:
71 void renderCarStatusView();
72 void renderCurrentLap();
73 void renderCurrentLapTime();
74 void renderLastLapTime();
75 void renderPosition();
76 void renderRaceTime();
77 void renderRecordLapTime();
78 void renderSpeed();
79
80 MCTextureFontManager & m_fontManager;
81 MCTextureFont & m_font;
82 MCTextureText m_text;
83
84 const Car * m_car = nullptr;
85 RaceS m_race;
86
87 std::vector<std::wstring> m_posTexts;
88
89 bool m_showLapRecordTime = true;
90 bool m_showRaceTime = true;
91 bool m_showCarStatus = true;
92
93 CarStatusView m_carStatusView;
94 };
95
96 #endif // TIMINGOVERLAY_HPP