Pioneer
Loading...
Searching...
No Matches
SectorView.h
Go to the documentation of this file.
1// Copyright © 2008-2024 Pioneer Developers. See AUTHORS.txt for details
2// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3
4#ifndef _SECTORVIEW_H
5#define _SECTORVIEW_H
6
7#include "ConnectionTicket.h"
8#include "DeleteEmitter.h"
9#include "Input.h"
10#include "JsonFwd.h"
11
12#include "galaxy/SystemPath.h"
13#include "pigui/PiGuiView.h"
14
15#include "vector3.h"
16#include "matrix4x4.h"
17
18class Game;
19class Galaxy;
20class SectorMap;
21struct SectorMapContext;
22
23class SectorView : public PiGuiView, public DeleteEmitter {
24public:
25 SectorView(Game *game);
26 SectorView(const Json &jsonObj, Game *game);
27 ~SectorView() override;
28
29 void Update() override;
30 // void ShowAll() override;
31 void Draw3D() override;
32
33 void DrawPiGui() override;
34
35 SystemPath GetCurrent() const { return m_current; }
36 SystemPath GetHyperspaceTarget() const { return m_hyperspaceTarget; }
37 SystemPath GetSelected() const { return m_selected; }
38 SectorMap &GetMap() { return *m_map; }
39
40 void GotoCurrentSystem();
41 void GotoSelectedSystem();
43 void SwitchToPath(const SystemPath &path);
44 void SetHyperspaceTarget(const SystemPath &path);
45 void SetDrawOutRangeLabels(bool value) { m_drawOutRangeLabels = value; }
46 void SetAutomaticSystemSelection(bool value) { m_automaticSystemSelection = value; }
48 void ResetView();
49
50 void SaveToJson(Json &jsonObj) override;
51
52 // HyperJump Route Planner
53 bool MoveRouteItemUp(const std::vector<SystemPath>::size_type element);
54 bool MoveRouteItemDown(const std::vector<SystemPath>::size_type element);
55 void UpdateRouteItem(const std::vector<SystemPath>::size_type element, const SystemPath &path);
56 void AddToRoute(const SystemPath &path);
57 bool RemoveRouteItem(const std::vector<SystemPath>::size_type element);
58 void ClearRoute();
59 std::vector<SystemPath> GetRoute();
60 const std::string AutoRoute(const SystemPath &start, const SystemPath &target, std::vector<SystemPath> &outRoute) const;
61 void SetDrawRouteLines(bool value);
62
63 sigc::signal<void> onHyperspaceTargetChanged;
64
65protected:
66 void OnSwitchTo() override;
67 void OnSwitchFrom() override;
68
70 using InputFrame::InputFrame;
71
76
77 void RegisterBindings() override;
79
80private:
81
82 void InitDefaults();
83 void InitObject();
84 const SystemPath &CheckPathInRoute(const SystemPath &path);
85 void SetSelected(const SystemPath &path);
86 void SetupLines(const vector3f &playerAbsPos, const matrix4x4f &trans);
87 void GetPlayerPosAndStarSize(vector3f &playerPosOut, float &currentStarSizeOut);
88
89 class SectorMapCallbacks;
90 SectorMapContext CreateMapContext();
91
92 SystemPath m_current;
93 SystemPath m_selected;
94 SystemPath m_hyperspaceTarget;
95
96 bool m_automaticSystemSelection;
97 bool m_drawOutRangeLabels;
98 bool m_drawRouteLines;
99 bool m_inSystem;
100 bool m_setupLines;
101 float m_playerHyperspaceRange;
102 Uint8 m_detailBoxVisible;
103
104 ConnectionTicket m_onToggleSelectionFollowView;
105 ConnectionTicket m_onWarpToCurrent;
106 ConnectionTicket m_onWarpToSelected;
107 ConnectionTicket m_onViewReset;
108
109 Game &m_game;
110 std::unique_ptr<SectorMap> m_map;
111 std::vector<SystemPath> m_route;
112
113};
114
115#endif /* _SECTORVIEW_H */
nlohmann::json Json
Definition: Json.h:8
Definition: DeleteEmitter.h:16
Definition: Galaxy.h:18
Definition: Game.h:38
Definition: PiGuiView.h:11
Definition: SectorMap.h:23
Definition: SectorView.h:23
void SetHyperspaceTarget(const SystemPath &path)
Definition: SectorView.cpp:283
~SectorView() override
Definition: SectorView.cpp:33
SectorView::InputBinding InputBindings
sigc::signal< void > onHyperspaceTargetChanged
Definition: SectorView.h:63
void SetDrawRouteLines(bool value)
Definition: SectorView.cpp:176
const std::string AutoRoute(const SystemPath &start, const SystemPath &target, std::vector< SystemPath > &outRoute) const
Definition: SectorView.cpp:380
void SwitchToPath(const SystemPath &path)
Definition: SectorView.cpp:310
void DrawPiGui() override
Definition: SectorView.cpp:278
std::vector< SystemPath > GetRoute()
Definition: SectorView.cpp:375
bool MoveRouteItemDown(const std::vector< SystemPath >::size_type element)
Definition: SectorView.cpp:336
void OnSwitchFrom() override
Definition: SectorView.cpp:614
void ResetHyperspaceTarget()
Definition: SectorView.cpp:289
void UpdateRouteItem(const std::vector< SystemPath >::size_type element, const SystemPath &path)
Definition: SectorView.cpp:346
void ResetView()
Definition: SectorView.cpp:646
void Update() override
Definition: SectorView.cpp:620
void SaveToJson(Json &jsonObj) override
Definition: SectorView.cpp:203
bool MoveRouteItemUp(const std::vector< SystemPath >::size_type element)
Definition: SectorView.cpp:326
SystemPath GetCurrent() const
Definition: SectorView.h:35
void AddToRoute(const SystemPath &path)
Definition: SectorView.cpp:352
void SetAutomaticSystemSelection(bool value)
Definition: SectorView.h:46
void GotoHyperspaceTarget()
Definition: SectorView.cpp:654
void OnSwitchTo() override
Definition: SectorView.cpp:607
void GotoSelectedSystem()
Definition: SectorView.cpp:653
void GotoCurrentSystem()
Definition: SectorView.cpp:652
SectorMap & GetMap()
Definition: SectorView.h:38
SystemPath GetSelected() const
Definition: SectorView.h:37
void Draw3D() override
Definition: SectorView.cpp:229
void SetDrawOutRangeLabels(bool value)
Definition: SectorView.h:45
SystemPath GetHyperspaceTarget() const
Definition: SectorView.h:36
bool RemoveRouteItem(const std::vector< SystemPath >::size_type element)
Definition: SectorView.cpp:358
void ClearRoute()
Definition: SectorView.cpp:369
Definition: SystemPath.h:13
Definition: ConnectionTicket.h:12
Definition: InputBindings.h:144
Definition: Input.h:48
Definition: SectorMapContext.h:16
Definition: SectorView.h:69
void RegisterBindings() override
Definition: SectorView.cpp:65
Action * mapViewReset
Definition: SectorView.h:75
Action * mapWarpToSelected
Definition: SectorView.h:74
Action * mapToggleSelectionFollowView
Definition: SectorView.h:72
Action * mapWarpToCurrent
Definition: SectorView.h:73