RigsofRods
Soft-body Physics Simulation
OverlayWrapper.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5  Copyright 2013-2019 Petr Ohlidal
6 
7  For more information, see http://www.rigsofrods.org/
8 
9  Rigs of Rods is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License version 3, as
11  published by the Free Software Foundation.
12 
13  Rigs of Rods is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 
26 
27 
28 #pragma once
29 
30 #include "Application.h"
31 
32 #include <Overlay/OgreTextAreaOverlayElement.h>
33 #include <OIS.h>
34 
35 namespace RoR {
36 
38 {
39  Ogre::OverlayElement *thr_element;
40  Ogre::OverlayElement *engfire_element;
41  Ogre::OverlayElement *engstart_element;
42  Ogre::TextureUnitState *rpm_texture;
43  Ogre::TextureUnitState *pitch_texture;
44  Ogre::TextureUnitState *torque_texture;
45 };
46 
48 {
49  void Setup(std::string const & elem_name, std::string const & mat_on, std::string const & mat_off);
50  void SetActive(bool value);
51 
52  Ogre::OverlayElement *element;
53  Ogre::MaterialPtr on_material;
54  Ogre::MaterialPtr off_material;
55 };
56 
58 {
59  void Setup(std::string const & up, std::string const & dn, std::string const & disp);
60  void DisplayFormat(const char* fmt, ...);
61 
62  Ogre::OverlayElement *up_button;
63  Ogre::OverlayElement *dn_button;
64  Ogre::OverlayElement *display;
65 };
66 
68 {
69  void SetThrottle(int engine, bool visible, float value);
70  void SetEngineFailed(int engine, bool value);
71  void SetEngineRpm(int engine, float pcent);
72  void SetEnginePitch(int engine, float value);
73  void SetEngineTorque(int engine, float pcent);
74  void SetIgnition(int engine, bool visible, bool ignited);
75 
77 
78  Ogre::Overlay *dash_overlay;
79  Ogre::Overlay *needles_overlay;
80 
81  Ogre::TextureUnitState *adibugstexture;
82  Ogre::TextureUnitState *aditapetexture;
83  Ogre::TextureUnitState *hsirosetexture;
84  Ogre::TextureUnitState *hsibugtexture;
85  Ogre::TextureUnitState *hsivtexture;
86  Ogre::TextureUnitState *hsihtexture;
87  Ogre::TextureUnitState *airspeedtexture;
88  Ogre::TextureUnitState *altimetertexture;
89  Ogre::TextureUnitState *vvitexture;
90  Ogre::TextureUnitState *aoatexture;
91  Ogre::TextAreaOverlayElement* alt_value_textarea;
92 
101 
106 
109 };
110 
112 {
113 public:
114 
115  OverlayWrapper();
116  ~OverlayWrapper();
117 
119  {
120  float orgScaleX = 0.f;
121  float orgScaleY = 0.f;
122  Ogre::Overlay *o = nullptr;
123  };
124 
125  void ToggleDashboardOverlays(ActorPtr actor);
126 
127  void showDashboardOverlays(bool show, ActorPtr actor);
128 
129  void windowResized();
130  void resizeOverlay(LoadedOverlay & overlay);
131 
132  bool handleMouseMoved();
133  bool handleMousePressed();
134  bool handleMouseReleased();
135 
136 
138  void update(float dt);
140  void UpdateAerialHUD(RoR::GfxActor* ga);
141  void UpdateMarineHUD(ActorPtr vehicle);
142 
143  void ShowRacingOverlay();
144  void HideRacingOverlay();
145  void UpdateRacingGui(RoR::GfxScene* gs);
146 
147  Ogre::Overlay *loadOverlay(Ogre::String name, bool autoResizeRation=true);
148 
149 protected:
150 
155  {
156  static const int RACING = BITMASK(4);
157  static const int TRUCK_TIRE_PRESSURE_OVERLAY = BITMASK(5);
158  };
159 
160  int init();
161  void resizePanel(Ogre::OverlayElement *oe);
162  void reposPanel(Ogre::OverlayElement *oe);
163  void placeNeedle(Ogre::SceneNode *node, float x, float y, float len);
164  void updateStats(bool detailed=false);
165  void showPressureOverlay(bool show);
166 
167  Ogre::OverlayElement *loadOverlayElement(Ogre::String name);
168 
169  Ogre::RenderWindow* win = nullptr;
170 
171  bool m_dashboard_visible = false;
172 
173  float mTimeUntilNextToggle = 0.f;
174 
175  // -------------------------------------------------------------
176  // Overlays
177  // -------------------------------------------------------------
178 
179  unsigned int m_visible_overlays = 0;
180 
181  Ogre::Overlay *m_truck_pressure_overlay = nullptr;
182  Ogre::Overlay *m_truck_pressure_needle_overlay = nullptr;
183 
185 
186  Ogre::Overlay *m_marine_dashboard_overlay = nullptr;
187  Ogre::Overlay *m_marine_dashboard_needles_overlay = nullptr;
188 
189  Ogre::Overlay *m_machine_dashboard_overlay = nullptr;
190 
191  // Misc
192  Ogre::Overlay *m_racing_overlay = nullptr;
193 
194  // -------------------------------------------------------------
195  // Overlay elements
196  // -------------------------------------------------------------
197 
198  // Truck
199  Ogre::OverlayElement* guiGear = nullptr;
200  Ogre::OverlayElement* guiGear3D = nullptr;
201 
202  // Marine overlay elements
203  Ogre::OverlayElement *bthro1 = nullptr;
204  Ogre::OverlayElement *bthro2 = nullptr;
205 
206  // Truck
207  Ogre::TextAreaOverlayElement* guiAuto[5] = {nullptr, nullptr, nullptr, nullptr, nullptr};
208  Ogre::TextAreaOverlayElement* guiAuto3D[5] = { nullptr, nullptr, nullptr, nullptr, nullptr };
209 
210  // Truck (racing overlay)
211  Ogre::TextAreaOverlayElement* laptime = nullptr;
212  Ogre::TextAreaOverlayElement* bestlaptime = nullptr;
213 
214  Ogre::TextAreaOverlayElement* boat_depth_value_taoe = nullptr;
215 
216  // truck
217  Ogre::TextureUnitState *speedotexture = nullptr; // Needed for dashboard prop
218  Ogre::TextureUnitState *tachotexture = nullptr; // Needed for dashboard prop
219 
220  // Marine
221  Ogre::TextureUnitState *boatspeedtexture = nullptr;
222  Ogre::TextureUnitState *boatsteertexture = nullptr;
223 
224  // Truck
225  Ogre::TextureUnitState *pressuretexture = nullptr;
226 
227  // Marine: Written in init(), read-only in simulation.
228  float thrtop = 0.f;
229  float thrheight = 0.f;
230  float throffset = 0.f;
231 
232  std::vector<LoadedOverlay> m_loaded_overlays;
233 };
234 
235 } // namespace RoR
RoR::AeroDashOverlay::gpws
AeroSwitchOverlay gpws
Definition: OverlayWrapper.h:99
RoR::AeroDashOverlay::SetIgnition
void SetIgnition(int engine, bool visible, bool ignited)
Definition: OverlayWrapper.cpp:1045
RoR::OverlayWrapper::thrtop
float thrtop
Definition: OverlayWrapper.h:228
RoR::OverlayWrapper::m_dashboard_visible
bool m_dashboard_visible
Definition: OverlayWrapper.h:171
RoR::OverlayWrapper::UpdateMarineHUD
void UpdateMarineHUD(ActorPtr vehicle)
Definition: OverlayWrapper.cpp:922
y
float y
Definition: (ValueTypes) quaternion.h:6
RoR::OverlayWrapper::guiGear3D
Ogre::OverlayElement * guiGear3D
truck
Definition: OverlayWrapper.h:200
RoR::OverlayWrapper::handleMouseMoved
bool handleMouseMoved()
Definition: OverlayWrapper.cpp:493
RoR::AeroDashOverlay::needles_overlay
Ogre::Overlay * needles_overlay
Definition: OverlayWrapper.h:79
RoR::OverlayWrapper::update
void update(float dt)
Definition: OverlayWrapper.cpp:345
RoR::OverlayWrapper::pressuretexture
Ogre::TextureUnitState * pressuretexture
Definition: OverlayWrapper.h:225
RoR::AeroDashOverlay::hdg_trim
AeroTrimOverlay hdg_trim
Definition: OverlayWrapper.h:102
RoR::OverlayWrapper::~OverlayWrapper
~OverlayWrapper()
Definition: OverlayWrapper.cpp:63
RoR::OverlayWrapper::m_loaded_overlays
std::vector< LoadedOverlay > m_loaded_overlays
Definition: OverlayWrapper.h:232
RoR::AeroDashOverlay::altimetertexture
Ogre::TextureUnitState * altimetertexture
Definition: OverlayWrapper.h:88
RoR::OverlayWrapper::m_racing_overlay
Ogre::Overlay * m_racing_overlay
Definition: OverlayWrapper.h:192
RoR::AeroDashOverlay::alt_trim
AeroTrimOverlay alt_trim
Definition: OverlayWrapper.h:103
RoR::AeroDashOverlay::thrust_track_top
float thrust_track_top
Definition: OverlayWrapper.h:107
RoR::AeroDashOverlay::hdg
AeroSwitchOverlay hdg
Definition: OverlayWrapper.h:93
RoR::AeroEngineOverlay
Definition: OverlayWrapper.h:37
RoR::OverlayWrapper::resizePanel
void resizePanel(Ogre::OverlayElement *oe)
Definition: OverlayWrapper.cpp:69
RoR::AeroTrimOverlay
Definition: OverlayWrapper.h:57
RoR::OverlayWrapper::guiAuto3D
Ogre::TextAreaOverlayElement * guiAuto3D[5]
Definition: OverlayWrapper.h:208
RoR::OverlayWrapper::laptime
Ogre::TextAreaOverlayElement * laptime
Definition: OverlayWrapper.h:211
RoR::OverlayWrapper::UpdateAerialHUD
void UpdateAerialHUD(RoR::GfxActor *ga)
Definition: OverlayWrapper.cpp:741
RoR::OverlayWrapper::UpdateRacingGui
void UpdateRacingGui(RoR::GfxScene *gs)
Definition: OverlayWrapper.cpp:965
RoR::OverlayWrapper::LoadedOverlay::orgScaleX
float orgScaleX
Definition: OverlayWrapper.h:120
RoR::OverlayWrapper::loadOverlayElement
Ogre::OverlayElement * loadOverlayElement(Ogre::String name)
Definition: OverlayWrapper.cpp:137
RoR::OverlayWrapper::boatspeedtexture
Ogre::TextureUnitState * boatspeedtexture
Definition: OverlayWrapper.h:221
RoR::OverlayWrapper::ToggleDashboardOverlays
void ToggleDashboardOverlays(ActorPtr actor)
Definition: OverlayWrapper.cpp:370
RoR::OverlayWrapper::init
int init()
Definition: OverlayWrapper.cpp:147
RoR::OverlayWrapper::m_truck_pressure_needle_overlay
Ogre::Overlay * m_truck_pressure_needle_overlay
Definition: OverlayWrapper.h:182
BITMASK
#define BITMASK(OFFSET)
Definition: BitFlags.h:10
RoR::OverlayWrapper::LoadedOverlay
Definition: OverlayWrapper.h:118
RoR::OverlayWrapper::guiAuto
Ogre::TextAreaOverlayElement * guiAuto[5]
Definition: OverlayWrapper.h:207
RoR::AeroDashOverlay
Definition: OverlayWrapper.h:67
RefCountingObjectPtr< Actor >
RoR::AeroTrimOverlay::display
Ogre::OverlayElement * display
Definition: OverlayWrapper.h:64
RoR::OverlayWrapper::bthro2
Ogre::OverlayElement * bthro2
Definition: OverlayWrapper.h:204
RoR::OverlayWrapper::m_machine_dashboard_overlay
Ogre::Overlay * m_machine_dashboard_overlay
Definition: OverlayWrapper.h:189
RoR::GfxScene
Provides a 3D graphical representation of the simulation Idea: simulation runs at it's own constant r...
Definition: GfxScene.h:45
RoR::OverlayWrapper::UpdatePressureOverlay
void UpdatePressureOverlay(RoR::GfxActor *ga)
Definition: OverlayWrapper.cpp:646
RoR::OverlayWrapper::UpdateLandVehicleHUD
void UpdateLandVehicleHUD(RoR::GfxActor *ga)
Definition: OverlayWrapper.cpp:661
RoR::OverlayWrapper::boatsteertexture
Ogre::TextureUnitState * boatsteertexture
Definition: OverlayWrapper.h:222
RoR::OverlayWrapper::throffset
float throffset
Definition: OverlayWrapper.h:230
RoR::AeroDashOverlay::airspeedtexture
Ogre::TextureUnitState * airspeedtexture
Definition: OverlayWrapper.h:87
RoR::AeroDashOverlay::dash_overlay
Ogre::Overlay * dash_overlay
Definition: OverlayWrapper.h:78
RoR::AeroDashOverlay::ias_trim
AeroTrimOverlay ias_trim
Definition: OverlayWrapper.h:105
RoR::OverlayWrapper::LoadedOverlay::o
Ogre::Overlay * o
Definition: OverlayWrapper.h:122
RoR::AeroDashOverlay::nav
AeroSwitchOverlay nav
Definition: OverlayWrapper.h:95
RoR::OverlayWrapper::LoadedOverlay::orgScaleY
float orgScaleY
Definition: OverlayWrapper.h:121
RoR::OverlayWrapper::handleMouseReleased
bool handleMouseReleased()
Definition: OverlayWrapper.cpp:641
RoR::AeroDashOverlay::wlv
AeroSwitchOverlay wlv
Definition: OverlayWrapper.h:94
RoR::OverlayWrapper::VisibleOverlays::TRUCK_TIRE_PRESSURE_OVERLAY
static const int TRUCK_TIRE_PRESSURE_OVERLAY
Definition: OverlayWrapper.h:157
RoR::OverlayWrapper::speedotexture
Ogre::TextureUnitState * speedotexture
Definition: OverlayWrapper.h:217
RoR::AeroDashOverlay::brks
AeroSwitchOverlay brks
Definition: OverlayWrapper.h:100
RoR::OverlayWrapper::guiGear
Ogre::OverlayElement * guiGear
truck
Definition: OverlayWrapper.h:199
RoR::OverlayWrapper::tachotexture
Ogre::TextureUnitState * tachotexture
Definition: OverlayWrapper.h:218
RoR::AeroDashOverlay::adibugstexture
Ogre::TextureUnitState * adibugstexture
Definition: OverlayWrapper.h:81
RoR::AeroDashOverlay::alt_value_textarea
Ogre::TextAreaOverlayElement * alt_value_textarea
Definition: OverlayWrapper.h:91
RoR::OverlayWrapper::showDashboardOverlays
void showDashboardOverlays(bool show, ActorPtr actor)
Definition: OverlayWrapper.cpp:375
RoR::OverlayWrapper::updateStats
void updateStats(bool detailed=false)
Definition: OverlayWrapper.cpp:426
RoR::AeroSwitchOverlay::SetActive
void SetActive(bool value)
Definition: OverlayWrapper.cpp:1059
RoR::AeroTrimOverlay::up_button
Ogre::OverlayElement * up_button
Definition: OverlayWrapper.h:62
Application.h
Central state/object manager and communications hub.
RoR::AeroSwitchOverlay::Setup
void Setup(std::string const &elem_name, std::string const &mat_on, std::string const &mat_off)
Definition: OverlayWrapper.cpp:1064
RoR::AeroDashOverlay::ias
AeroSwitchOverlay ias
Definition: OverlayWrapper.h:98
RoR::AeroEngineOverlay::thr_element
Ogre::OverlayElement * thr_element
Definition: OverlayWrapper.h:39
RoR::OverlayWrapper::reposPanel
void reposPanel(Ogre::OverlayElement *oe)
Definition: OverlayWrapper.cpp:77
RoR::AeroDashOverlay::alt
AeroSwitchOverlay alt
Definition: OverlayWrapper.h:96
RoR::OverlayWrapper::m_truck_pressure_overlay
Ogre::Overlay * m_truck_pressure_overlay
Definition: OverlayWrapper.h:181
RoR::OverlayWrapper::VisibleOverlays
RoR needs to temporarily hide all overlays when player enters editor.
Definition: OverlayWrapper.h:154
RoR::OverlayWrapper::mTimeUntilNextToggle
float mTimeUntilNextToggle
Definition: OverlayWrapper.h:173
RoR::AeroDashOverlay::thrust_track_height
float thrust_track_height
Definition: OverlayWrapper.h:108
RoR::AeroDashOverlay::hsibugtexture
Ogre::TextureUnitState * hsibugtexture
Definition: OverlayWrapper.h:84
RoR::OverlayWrapper::placeNeedle
void placeNeedle(Ogre::SceneNode *node, float x, float y, float len)
Definition: OverlayWrapper.cpp:84
RoR::OverlayWrapper::resizeOverlay
void resizeOverlay(LoadedOverlay &overlay)
Definition: OverlayWrapper.cpp:109
RoR::OverlayWrapper::m_marine_dashboard_overlay
Ogre::Overlay * m_marine_dashboard_overlay
Definition: OverlayWrapper.h:186
RoR::OverlayWrapper::windowResized
void windowResized()
Definition: OverlayWrapper.cpp:129
RoR::AeroSwitchOverlay::element
Ogre::OverlayElement * element
Definition: OverlayWrapper.h:52
RoR::AeroDashOverlay::vvitexture
Ogre::TextureUnitState * vvitexture
Definition: OverlayWrapper.h:89
RoR::OverlayWrapper::showPressureOverlay
void showPressureOverlay(bool show)
Definition: OverlayWrapper.cpp:351
RoR::AeroDashOverlay::aoatexture
Ogre::TextureUnitState * aoatexture
Definition: OverlayWrapper.h:90
RoR::AeroEngineOverlay::pitch_texture
Ogre::TextureUnitState * pitch_texture
Definition: OverlayWrapper.h:43
RoR::OverlayWrapper::m_visible_overlays
unsigned int m_visible_overlays
Definition: OverlayWrapper.h:179
RoR::AeroDashOverlay::aditapetexture
Ogre::TextureUnitState * aditapetexture
Definition: OverlayWrapper.h:82
RoR::AeroTrimOverlay::Setup
void Setup(std::string const &up, std::string const &dn, std::string const &disp)
Definition: OverlayWrapper.cpp:1071
RoR::AeroDashOverlay::SetThrottle
void SetThrottle(int engine, bool visible, float value)
Definition: OverlayWrapper.cpp:996
RoR::AeroDashOverlay::SetEnginePitch
void SetEnginePitch(int engine, float value)
Definition: OverlayWrapper.cpp:1028
RoR::OverlayWrapper::OverlayWrapper
OverlayWrapper()
Definition: OverlayWrapper.cpp:57
RoR::OverlayWrapper::handleMousePressed
bool handleMousePressed()
Definition: OverlayWrapper.cpp:636
RoR::AeroDashOverlay::hsihtexture
Ogre::TextureUnitState * hsihtexture
Definition: OverlayWrapper.h:86
RoR::OverlayWrapper::bestlaptime
Ogre::TextAreaOverlayElement * bestlaptime
Definition: OverlayWrapper.h:212
RoR::AeroDashOverlay::vs_trim
AeroTrimOverlay vs_trim
Definition: OverlayWrapper.h:104
RoR::AeroDashOverlay::hsirosetexture
Ogre::TextureUnitState * hsirosetexture
Definition: OverlayWrapper.h:83
RoR::OverlayWrapper::m_marine_dashboard_needles_overlay
Ogre::Overlay * m_marine_dashboard_needles_overlay
Definition: OverlayWrapper.h:187
RoR::GfxActor
Definition: GfxActor.h:52
RoR::AeroTrimOverlay::dn_button
Ogre::OverlayElement * dn_button
Definition: OverlayWrapper.h:63
RoR::AeroEngineOverlay::engstart_element
Ogre::OverlayElement * engstart_element
Definition: OverlayWrapper.h:41
RoR::AeroDashOverlay::SetEngineTorque
void SetEngineTorque(int engine, float pcent)
Definition: OverlayWrapper.cpp:1033
RoR::AeroTrimOverlay::DisplayFormat
void DisplayFormat(const char *fmt,...)
Definition: OverlayWrapper.cpp:1078
RoR::AeroEngineOverlay::rpm_texture
Ogre::TextureUnitState * rpm_texture
Definition: OverlayWrapper.h:42
RoR::AeroDashOverlay::SetEngineRpm
void SetEngineRpm(int engine, float pcent)
Definition: OverlayWrapper.cpp:1016
RoR::OverlayWrapper::HideRacingOverlay
void HideRacingOverlay()
Definition: OverlayWrapper.cpp:959
RoR::AeroSwitchOverlay::on_material
Ogre::MaterialPtr on_material
Definition: OverlayWrapper.h:53
RoR::AeroDashOverlay::hsivtexture
Ogre::TextureUnitState * hsivtexture
Definition: OverlayWrapper.h:85
RoR::OverlayWrapper::bthro1
Ogre::OverlayElement * bthro1
Definition: OverlayWrapper.h:203
RoR::AeroSwitchOverlay
Definition: OverlayWrapper.h:47
RoR::OverlayWrapper::m_aerial_dashboard
AeroDashOverlay m_aerial_dashboard
Definition: OverlayWrapper.h:184
RoR::OverlayWrapper::thrheight
float thrheight
Definition: OverlayWrapper.h:229
RoR::OverlayWrapper::boat_depth_value_taoe
Ogre::TextAreaOverlayElement * boat_depth_value_taoe
Marine.
Definition: OverlayWrapper.h:214
RoR::AeroEngineOverlay::engfire_element
Ogre::OverlayElement * engfire_element
Definition: OverlayWrapper.h:40
RoR::AeroEngineOverlay::torque_texture
Ogre::TextureUnitState * torque_texture
Definition: OverlayWrapper.h:44
RoR::OverlayWrapper::ShowRacingOverlay
void ShowRacingOverlay()
Definition: OverlayWrapper.cpp:953
RoR
Definition: AppContext.h:36
x
float x
Definition: (ValueTypes) quaternion.h:5
RoR::AeroDashOverlay::engines
AeroEngineOverlay engines[4]
Definition: OverlayWrapper.h:76
RoR::OverlayWrapper::VisibleOverlays::RACING
static const int RACING
Definition: OverlayWrapper.h:156
RoR::OverlayWrapper::loadOverlay
Ogre::Overlay * loadOverlay(Ogre::String name, bool autoResizeRation=true)
Definition: OverlayWrapper.cpp:90
RoR::AeroSwitchOverlay::off_material
Ogre::MaterialPtr off_material
Definition: OverlayWrapper.h:54
RoR::OverlayWrapper
Definition: OverlayWrapper.h:111
RoR::AeroDashOverlay::SetEngineFailed
void SetEngineFailed(int engine, bool value)
Definition: OverlayWrapper.cpp:1010
RoR::OverlayWrapper::win
Ogre::RenderWindow * win
Definition: OverlayWrapper.h:169
RoR::AeroDashOverlay::vs
AeroSwitchOverlay vs
Definition: OverlayWrapper.h:97