RigsofRods
Soft-body Physics Simulation
GUI_SurveyMap.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-2023 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 #pragma once
23 
25 
26 #include "Application.h"
27 #include "OgreImGui.h"
28 #include "SimData.h"
29 #include "SurveyMapEntity.h"
31 
32 #include <vector>
33 
34 namespace RoR {
35 namespace GUI {
36 
48 class SurveyMap
49 {
50 public:
51 
52  const float WINDOW_PADDING = 4.f;
53  const float WINDOW_ROUNDING = 2.f;
54 
55  void CreateTerrainTextures();
56  void Draw();
57  bool IsVisible() const { return mMapMode != SurveyMapMode::NONE; }
58  bool IsHovered() const { return IsVisible() && mWindowMouseHovered; }
59  void CycleMode();
60  void ToggleMode();
61 
62 protected:
63 
64  enum class SurveyMapMode
65  {
66  NONE, // Not visible
67  SMALL,
68  BIG
69  };
70 
71  void setMapZoom(float zoom);
72  void setMapZoomRelative(float dt_sec);
73  const char* getTypeByDriveable(const ActorPtr& actor);
74  const char* getAIType(const ActorPtr& actor);
75 
77 
78  void DrawMapIcon(const SurveyMapEntity& e, ImVec2 view_pos, ImVec2 view_size, Ogre::Vector2 view_origin);
79 
80  ImVec2 DrawWaypoint(ImVec2 view_pos, ImVec2 view_size, Ogre::Vector2 view_origin,
81  std::string const& caption, int idx);
82 
83  ImVec2 CalcWaypointMapPos(ImVec2 view_pos, ImVec2 view_size, Ogre::Vector2 view_origin, int idx);
84 
85  // Window display
88  bool mWindowMouseHovered = false;
89  bool mMouseClicked = false;
90  int mWaypointNum = 0;
91 
92  // Map
93  Ogre::Vector2 mTerrainSize = Ogre::Vector2::ZERO; // Computed reference map size (in meters)
94  Ogre::Vector2 mMapCenterOffset = Ogre::Vector2::ZERO; // Displacement, in meters
95  float mMapZoom = 0.f; // Ratio: 0-1
96  Ogre::TexturePtr mMapTexture;
97 
98  // Icon cache
99  bool m_icons_cached = false;
100  Ogre::TexturePtr m_left_mouse_button;
101  Ogre::TexturePtr m_middle_mouse_button;
103  Ogre::TexturePtr m_right_mouse_button;
104  void CacheIcons();
105 
106  // Circular minimap
108  float m_circle_radius = 0.f;
109 };
110 
111 } // namespace GUI
112 } // namespace RoR
RoR::GUI::SurveyMap::mWindowMouseHovered
bool mWindowMouseHovered
Definition: GUI_SurveyMap.h:88
RoR::GUI::SurveyMap::mMapLastMode
SurveyMapMode mMapLastMode
Definition: GUI_SurveyMap.h:87
RoR::GUI::SurveyMap::SurveyMapMode
SurveyMapMode
Definition: GUI_SurveyMap.h:64
RoR::GUI::SurveyMap::DrawMapIcon
void DrawMapIcon(const SurveyMapEntity &e, ImVec2 view_pos, ImVec2 view_size, Ogre::Vector2 view_origin)
Definition: GUI_SurveyMap.cpp:552
RoR::GUI::SurveyMap::mTerrainSize
Ogre::Vector2 mTerrainSize
Definition: GUI_SurveyMap.h:93
RoR::GUI::SurveyMap::m_icons_cached
bool m_icons_cached
Definition: GUI_SurveyMap.h:99
SurveyMapEntity.h
RoR::GUI::SurveyMap::mMapZoom
float mMapZoom
Definition: GUI_SurveyMap.h:95
RoR::GUI::SurveyMap::setMapZoomRelative
void setMapZoomRelative(float dt_sec)
Definition: GUI_SurveyMap.cpp:491
OgreImGui.h
RefCountingObjectPtr< Actor >
RoR::GUI::SurveyMap::DrawWaypoint
ImVec2 DrawWaypoint(ImVec2 view_pos, ImVec2 view_size, Ogre::Vector2 view_origin, std::string const &caption, int idx)
Definition: GUI_SurveyMap.cpp:592
RoR::GUI::SurveyMap::CalcWaypointMapPos
ImVec2 CalcWaypointMapPos(ImVec2 view_pos, ImVec2 view_size, Ogre::Vector2 view_origin, int idx)
Definition: GUI_SurveyMap.cpp:656
RoR::GUI::SurveyMap::mMapMode
SurveyMapMode mMapMode
Definition: GUI_SurveyMap.h:86
RoR::GUI::SurveyMap::Draw
void Draw()
Definition: GUI_SurveyMap.cpp:46
RoR::GUI::SurveyMap::WINDOW_ROUNDING
const float WINDOW_ROUNDING
Definition: GUI_SurveyMap.h:53
RoR::GUI::SurveyMap::IsVisible
bool IsVisible() const
Definition: GUI_SurveyMap.h:57
RoR::GUI::SurveyMap::ToggleMode
void ToggleMode()
Definition: GUI_SurveyMap.cpp:547
SimData.h
Core data structures for simulation; Everything affected by by either physics, network or user intera...
RoR::GUI::SurveyMap::getTypeByDriveable
const char * getTypeByDriveable(const ActorPtr &actor)
Definition: GUI_SurveyMap.cpp:497
RoR::GUI::SurveyMap::SurveyMapMode::BIG
@ BIG
RoR::GUI::SurveyMap::mMapCenterOffset
Ogre::Vector2 mMapCenterOffset
Definition: GUI_SurveyMap.h:94
RoR::GUI::SurveyMap::mMapTexture
Ogre::TexturePtr mMapTexture
Definition: GUI_SurveyMap.h:96
RoR::GUI::SurveyMap::m_right_mouse_button
Ogre::TexturePtr m_right_mouse_button
Definition: GUI_SurveyMap.h:103
Application.h
Central state/object manager and communications hub.
RoR::GUI::SurveyMap::IsHovered
bool IsHovered() const
Definition: GUI_SurveyMap.h:58
RoR::GUI::SurveyMap::m_left_mouse_button
Ogre::TexturePtr m_left_mouse_button
Definition: GUI_SurveyMap.h:100
RoR::GUI::SurveyMap::CreateTerrainTextures
void CreateTerrainTextures()
Definition: GUI_SurveyMap.cpp:440
RoR::GUI::SurveyMap::CycleMode
void CycleMode()
Definition: GUI_SurveyMap.cpp:536
RoR::GUI::SurveyMap::WINDOW_PADDING
const float WINDOW_PADDING
Definition: GUI_SurveyMap.h:52
RoR::GUI::SurveyMap::m_middle_mouse_button
Ogre::TexturePtr m_middle_mouse_button
Definition: GUI_SurveyMap.h:101
SurveyMapTextureCreator.h
RoR::GUI::SurveyMap::m_circle_center
ImVec2 m_circle_center
Definition: GUI_SurveyMap.h:107
RoR::GUI::SurveyMap::SurveyMapMode::SMALL
@ SMALL
RoR::GUI::SurveyMap::setMapZoom
void setMapZoom(float zoom)
Definition: GUI_SurveyMap.cpp:481
RoR::GUI::SurveyMap::CacheIcons
void CacheIcons()
Definition: GUI_SurveyMap.cpp:671
RoR::GUI::SurveyMap::SurveyMapMode::NONE
@ NONE
RoR::GUI::SurveyMap::m_circle_radius
float m_circle_radius
Definition: GUI_SurveyMap.h:108
RoR::GUI::SurveyMap::m_middle_mouse_scroll_button
Ogre::TexturePtr m_middle_mouse_scroll_button
Definition: GUI_SurveyMap.h:102
RoR::GUI::SurveyMap::CacheMapIcon
void CacheMapIcon(SurveyMapEntity &e)
Definition: GUI_SurveyMap.cpp:683
RoR::SurveyMapEntity
Definition: SurveyMapEntity.h:35
RoR::GUI::SurveyMap::mWaypointNum
int mWaypointNum
Definition: GUI_SurveyMap.h:90
RoR
Definition: AppContext.h:36
RoR::GUI::SurveyMap::getAIType
const char * getAIType(const ActorPtr &actor)
Definition: GUI_SurveyMap.cpp:518
RoR::GUI::SurveyMap
In-game map widget Has 3 display modes (see SurveyMapMode), cycled using input SURVEY_MAP_TOGGLE_VIEW
Definition: GUI_SurveyMap.h:48
RoR::GUI::SurveyMap::mMouseClicked
bool mMouseClicked
Definition: GUI_SurveyMap.h:89