HoverRace  2.0
Counter.h
Go to the documentation of this file.
1 
2 // Counter.h
3 //
4 // Copyright (c) 2013-2015 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 #include "HudDecor.h"
25 
26 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
27 # ifdef MR_ENGINE
28 # define MR_DllDeclare __declspec( dllexport )
29 # else
30 # define MR_DllDeclare __declspec( dllimport )
31 # endif
32 #else
33 # define MR_DllDeclare
34 #endif
35 
36 namespace HoverRace {
37  namespace Display {
38  class ActiveText;
39  class Display;
40  class FillBox;
41  class Label;
42  }
43 }
44 
45 namespace HoverRace {
46 namespace Display {
47 
53 {
54  using SUPER = HudDecor;
55 
56 private:
57  static const double NO_TOTAL;
58 
59 public:
60  Counter(Display &display, const std::string &title, double initValue,
61  double total = NO_TOTAL);
62  virtual ~Counter() { }
63 
64 protected:
65  void OnHudRescaled(const Vec2 &hudScale) override;
66 
67 public:
69  double GetValue() const { return value; }
70  void SetValue(double value);
71 
77  double GetTotal() const { return total; }
78  void SetTotal(double total);
79 
80  bool IsTotalHidden() const;
81  void HideTotal();
82 
83 protected:
84  void Layout() override;
85 public:
86  void Advance(Util::OS::timestamp_t tick) override;
87 
88 private:
89  double value;
90  double total;
92  std::shared_ptr<FillBox> bg;
93  std::shared_ptr<Label> titleLbl;
94  std::shared_ptr<ActiveText> valueLbl;
95 };
96 
97 } // namespace Display
98 } // namespace HoverRace
99 
100 #undef MR_DllDeclare
std::shared_ptr< Label > titleLbl
Definition: Counter.h:93
Base class for UI (2D) components.
Definition: UiViewModel.h:56
std::shared_ptr< ActiveText > valueLbl
Definition: Counter.h:94
static const double NO_TOTAL
Indicator that the total should not be displayed.
Definition: Counter.h:57
double value
Definition: Counter.h:89
Definition: Vec.h:38
std::shared_ptr< FillBox > bg
Definition: Counter.h:92
Base class for display managers.
Definition: Display.h:73
double total
Definition: Counter.h:90
virtual ~Counter()
Definition: Counter.h:62
Base view model for elements of the heads-up display.
Definition: HudDecor.h:58
HUD lap / score / whatever counter.
Definition: Counter.h:52
bool valueChanged
Definition: Counter.h:91
double GetTotal() const
Retrieve the total value.
Definition: Counter.h:77
Definition: Announcement.h:24
#define MR_DllDeclare
Definition: Counter.h:33
MR_Int64 timestamp_t
Definition: OS.h:55
double GetValue() const
Retrieve the current value.
Definition: Counter.h:69