2020-12-31 07:32:16 -08:00
|
|
|
// Copyright © 2008-2021 Pioneer Developers. See AUTHORS.txt for details
|
2012-09-15 17:59:15 -07:00
|
|
|
// Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
|
2012-09-12 04:38:30 -07:00
|
|
|
|
2008-06-24 03:17:31 -07:00
|
|
|
#ifndef _SECTORVIEW_H
|
|
|
|
#define _SECTORVIEW_H
|
|
|
|
|
2020-11-22 16:15:30 -08:00
|
|
|
#include "DeleteEmitter.h"
|
2020-04-06 12:37:53 -07:00
|
|
|
#include "Input.h"
|
2012-04-04 18:53:58 -07:00
|
|
|
#include "galaxy/Sector.h"
|
|
|
|
#include "galaxy/SystemPath.h"
|
2012-02-21 02:50:01 -08:00
|
|
|
#include "graphics/Drawables.h"
|
2019-01-02 08:59:07 -08:00
|
|
|
#include "gui/Gui.h"
|
2020-11-22 16:15:30 -08:00
|
|
|
#include "pigui/PiGuiView.h"
|
2014-01-26 17:26:44 -08:00
|
|
|
#include <set>
|
2019-01-02 08:59:07 -08:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2008-06-24 03:17:31 -07:00
|
|
|
|
2014-09-15 11:30:54 -07:00
|
|
|
class Game;
|
2014-09-16 10:04:53 -07:00
|
|
|
class Galaxy;
|
2014-09-15 11:30:54 -07:00
|
|
|
|
2019-02-15 15:05:44 -08:00
|
|
|
namespace Graphics {
|
|
|
|
class RenderState;
|
|
|
|
}
|
|
|
|
|
2020-11-22 16:15:30 -08:00
|
|
|
class SectorView : public PiGuiView, public DeleteEmitter {
|
2008-06-24 03:17:31 -07:00
|
|
|
public:
|
2019-01-02 08:59:07 -08:00
|
|
|
SectorView(Game *game);
|
|
|
|
SectorView(const Json &jsonObj, Game *game);
|
2020-06-26 10:43:38 -07:00
|
|
|
~SectorView() override;
|
2011-11-13 16:50:17 -08:00
|
|
|
|
2020-06-26 10:43:38 -07:00
|
|
|
void Update() override;
|
|
|
|
void ShowAll() override;
|
|
|
|
void Draw3D() override;
|
2011-08-09 15:42:07 -07:00
|
|
|
vector3f GetPosition() const { return m_pos; }
|
2017-09-02 03:44:54 -07:00
|
|
|
SystemPath GetCurrent() const { return m_current; }
|
2014-02-02 08:15:57 -08:00
|
|
|
SystemPath GetSelected() const { return m_selected; }
|
2020-06-04 10:28:18 -07:00
|
|
|
void SwitchToPath(const SystemPath &path);
|
2011-06-27 23:49:59 -07:00
|
|
|
SystemPath GetHyperspaceTarget() const { return m_hyperspaceTarget; }
|
|
|
|
void SetHyperspaceTarget(const SystemPath &path);
|
2011-07-03 15:24:16 -07:00
|
|
|
void ResetHyperspaceTarget();
|
2012-05-30 17:32:07 -07:00
|
|
|
void GotoSector(const SystemPath &path);
|
2011-06-27 17:33:37 -07:00
|
|
|
void GotoSystem(const SystemPath &path);
|
2011-08-10 04:07:08 -07:00
|
|
|
void GotoCurrentSystem() { GotoSystem(m_current); }
|
|
|
|
void GotoSelectedSystem() { GotoSystem(m_selected); }
|
|
|
|
void GotoHyperspaceTarget() { GotoSystem(m_hyperspaceTarget); }
|
2020-06-04 10:28:18 -07:00
|
|
|
bool IsCenteredOn(const SystemPath &path);
|
2020-06-26 10:43:38 -07:00
|
|
|
void SaveToJson(Json &jsonObj) override;
|
2011-06-28 15:12:06 -07:00
|
|
|
|
|
|
|
sigc::signal<void> onHyperspaceTargetChanged;
|
2017-12-28 05:55:47 -08:00
|
|
|
|
2017-09-02 03:44:54 -07:00
|
|
|
double GetZoomLevel() const;
|
|
|
|
void ZoomIn();
|
|
|
|
void ZoomOut();
|
|
|
|
vector3f GetCenterSector();
|
|
|
|
double GetCenterDistance();
|
|
|
|
void SetDrawUninhabitedLabels(bool value) { m_drawUninhabitedLabels = value; }
|
|
|
|
void SetDrawVerticalLines(bool value) { m_drawVerticalLines = value; }
|
|
|
|
void SetDrawOutRangeLabels(bool value) { m_drawOutRangeLabels = value; }
|
|
|
|
void SetAutomaticSystemSelection(bool value) { m_automaticSystemSelection = value; }
|
|
|
|
std::vector<SystemPath> GetNearbyStarSystemsByName(std::string pattern);
|
|
|
|
const std::set<const Faction *> &GetVisibleFactions() { return m_visibleFactions; }
|
|
|
|
const std::set<const Faction *> &GetHiddenFactions() { return m_hiddenFactions; }
|
|
|
|
void SetFactionVisible(const Faction *faction, bool visible);
|
2020-06-04 10:28:18 -07:00
|
|
|
void SetZoomMode(bool enable);
|
|
|
|
void SetRotateMode(bool enable);
|
|
|
|
void ResetView();
|
2017-12-28 05:55:47 -08:00
|
|
|
|
|
|
|
// HyperJump Route Planner
|
|
|
|
bool MoveRouteItemUp(const std::vector<SystemPath>::size_type element);
|
|
|
|
bool MoveRouteItemDown(const std::vector<SystemPath>::size_type element);
|
2020-06-04 10:28:18 -07:00
|
|
|
void UpdateRouteItem(const std::vector<SystemPath>::size_type element, const SystemPath &path);
|
2017-12-28 05:55:47 -08:00
|
|
|
void AddToRoute(const SystemPath &path);
|
|
|
|
bool RemoveRouteItem(const std::vector<SystemPath>::size_type element);
|
|
|
|
void ClearRoute();
|
|
|
|
std::vector<SystemPath> GetRoute();
|
2020-07-10 05:30:27 -07:00
|
|
|
const std::string AutoRoute(const SystemPath &start, const SystemPath &target, std::vector<SystemPath> &outRoute) const;
|
2017-12-28 05:55:47 -08:00
|
|
|
void SetDrawRouteLines(bool value) { m_drawRouteLines = value; }
|
|
|
|
|
Refactor to InputFrame 2.0
Significantly refactored the Input class, added Input::Manager to handle
most duties of the Input system.
Replaced the legacy KeyBindings system with the new InputBindings
(namespace subject to change) system for handling key state and key
chords - among other improvements, there is no longer a hardcoded
dependency on Pi::input anymore, as well as storing the binding state in
the binding itself, completely decoupling InputBindings from the input
system that handles input events and significantly reducing the
complexity of the binding system.
Input::Manager now is totally responsible for generating binding events,
removing the need for WorldView::HandleSDLEvent and its ilk - interested
parties can simply bind to the onPressed event and they will only be
notified when the binding in question is part of an active input frame
and nothing else has grabbed the input event, vastly simplifying control
flow.
Among other effects, this almost totally eradicates the need for
Pi::IsConsoleActive().
The lua Console widget is slightly broken as a result of this change,
it doesn't handle activation/deactivation state changes properly. The
solution to this seems to simply be a direct rewrite in PiGui, which
I don't expect to cause too many issues.
I've added a CMake option to use LLD to speed up incremental build link
times; this seems to be somewhat platform dependent and is not
implemented for windows at this time.
Serialization of key bindings to the config file is totally completed,
although support for a graphical method of binding multi-key chords is
not anticipated for this pull request.
2020-04-18 14:58:00 -07:00
|
|
|
protected:
|
|
|
|
void OnSwitchTo() override;
|
|
|
|
void OnSwitchFrom() override;
|
|
|
|
|
|
|
|
struct InputBinding : public Input::InputFrame {
|
|
|
|
using InputFrame::InputFrame;
|
2020-04-06 12:37:53 -07:00
|
|
|
|
|
|
|
Action *mapToggleSelectionFollowView;
|
|
|
|
Action *mapWarpToCurrent;
|
|
|
|
Action *mapWarpToSelected;
|
|
|
|
Action *mapViewReset;
|
|
|
|
|
2020-06-23 15:56:33 -07:00
|
|
|
Axis *mapViewMoveForward;
|
|
|
|
Axis *mapViewMoveLeft;
|
|
|
|
Axis *mapViewMoveUp;
|
2020-04-06 12:37:53 -07:00
|
|
|
Axis *mapViewYaw;
|
|
|
|
Axis *mapViewPitch;
|
|
|
|
Axis *mapViewZoom;
|
2020-11-24 23:35:33 -08:00
|
|
|
|
2020-06-26 10:43:38 -07:00
|
|
|
void RegisterBindings() override;
|
2020-04-06 12:37:53 -07:00
|
|
|
} InputBindings;
|
|
|
|
|
2008-06-24 03:17:31 -07:00
|
|
|
private:
|
2011-11-29 01:48:37 -08:00
|
|
|
void InitDefaults();
|
|
|
|
void InitObject();
|
|
|
|
|
2014-01-11 09:58:17 -08:00
|
|
|
struct DistanceIndicator {
|
|
|
|
Gui::Label *label;
|
|
|
|
Graphics::Drawables::Line3D *line;
|
|
|
|
Color okayColor;
|
|
|
|
Color unsuffFuelColor;
|
|
|
|
Color outOfRangeColor;
|
|
|
|
};
|
|
|
|
|
2011-08-10 03:20:32 -07:00
|
|
|
struct SystemLabels {
|
|
|
|
Gui::Label *systemName;
|
2014-01-11 10:01:25 -08:00
|
|
|
Gui::Label *sector;
|
2014-01-11 09:58:17 -08:00
|
|
|
DistanceIndicator distance;
|
2011-08-10 03:20:32 -07:00
|
|
|
Gui::Label *starType;
|
|
|
|
Gui::Label *shortDesc;
|
|
|
|
};
|
2012-07-04 12:13:48 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
void DrawNearSectors(const matrix4x4f &modelview);
|
2020-09-06 01:05:23 -07:00
|
|
|
void DrawNearSector(const int sx, const int sy, const int sz, const matrix4x4f &trans);
|
2014-01-25 09:57:47 -08:00
|
|
|
void PutSystemLabels(RefCountedPtr<Sector> sec, const vector3f &origin, int drawRadius);
|
2011-08-12 00:10:58 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
void DrawFarSectors(const matrix4x4f &modelview);
|
2014-01-25 09:57:47 -08:00
|
|
|
void BuildFarSector(RefCountedPtr<Sector> sec, const vector3f &origin, std::vector<vector3f> &points, std::vector<Color> &colors);
|
2012-11-24 11:00:54 -08:00
|
|
|
void PutFactionLabels(const vector3f &secPos);
|
2014-02-02 13:03:41 -08:00
|
|
|
void AddStarBillboard(const matrix4x4f &modelview, const vector3f &pos, const Color &col, float size);
|
2012-11-23 12:36:00 -08:00
|
|
|
|
2011-06-27 17:33:37 -07:00
|
|
|
void OnClickSystem(const SystemPath &path);
|
Fix some things with regards to the sector map
- clear route strings when enging the game, otherwise, when the game
restarts, a segfault occurs
- fix that the "remove jump" button continued to remove jumps even
when the route became empty
- reordered sections in the object information widget, added icons to
the names of stars in the multisystem
- it turns out that a hyper jump is possible not only to the stars, but
also to the "substellar objects", but they do not return in the method
GetStars. Since a specific body should be shown in the route planner,
implemented an additional method GetJumpable, that gets all the bodies
available for jumping (IsJumpable == true), and this is synchronized
with what you can click in the systeminfo view
- also I had to change the route check, now it’s not the star index that
is checked, but just the path (this check is performed for multisystems,
so that only the specific body that registered in the route is always
selected)
- remove method SectorView::SwapSelectedHyperspaceTarget, because it is
not used anywhere
- clang satisfaction
2020-07-04 06:19:38 -07:00
|
|
|
const SystemPath &CheckPathInRoute(const SystemPath &path);
|
2011-07-03 23:18:18 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
RefCountedPtr<Sector> GetCached(const SystemPath &loc) { return m_sectorCache->GetCached(loc); }
|
2014-02-01 04:04:09 -08:00
|
|
|
void ShrinkCache();
|
2020-06-04 10:28:18 -07:00
|
|
|
void SetSelected(const SystemPath &path);
|
2014-02-01 04:04:09 -08:00
|
|
|
|
2013-09-24 00:50:41 -07:00
|
|
|
void MouseWheel(bool up);
|
2011-08-19 01:58:35 -07:00
|
|
|
|
2014-09-16 10:04:53 -07:00
|
|
|
RefCountedPtr<Galaxy> m_galaxy;
|
2014-09-15 11:30:54 -07:00
|
|
|
|
2011-12-18 19:23:13 -08:00
|
|
|
bool m_inSystem;
|
|
|
|
|
2011-08-10 04:07:08 -07:00
|
|
|
SystemPath m_current;
|
2011-06-27 17:33:37 -07:00
|
|
|
SystemPath m_selected;
|
|
|
|
|
2011-07-18 06:27:00 -07:00
|
|
|
vector3f m_pos;
|
|
|
|
vector3f m_posMovingTo;
|
2011-08-07 23:43:54 -07:00
|
|
|
|
2011-08-15 15:30:18 -07:00
|
|
|
float m_rotXDefault, m_rotZDefault, m_zoomDefault;
|
|
|
|
|
2011-08-07 23:43:54 -07:00
|
|
|
float m_rotX, m_rotZ;
|
|
|
|
float m_rotXMovingTo, m_rotZMovingTo;
|
|
|
|
|
2011-08-15 14:49:19 -07:00
|
|
|
float m_zoom;
|
2012-11-24 11:00:54 -08:00
|
|
|
float m_zoomClamped;
|
2011-08-15 14:49:19 -07:00
|
|
|
float m_zoomMovingTo;
|
|
|
|
|
2020-06-04 10:28:18 -07:00
|
|
|
bool m_rotateWithMouseButton = false;
|
|
|
|
bool m_rotateView = false;
|
|
|
|
bool m_zoomView = false;
|
|
|
|
|
2011-06-27 23:49:59 -07:00
|
|
|
SystemPath m_hyperspaceTarget;
|
2014-03-27 13:57:00 -07:00
|
|
|
bool m_automaticSystemSelection;
|
2011-08-12 00:10:58 -07:00
|
|
|
|
2017-09-02 03:44:54 -07:00
|
|
|
bool m_drawUninhabitedLabels;
|
|
|
|
bool m_drawOutRangeLabels;
|
|
|
|
bool m_drawVerticalLines;
|
2017-12-28 05:55:47 -08:00
|
|
|
|
2013-10-29 04:44:49 -07:00
|
|
|
std::unique_ptr<Graphics::Drawables::Disk> m_disk;
|
2012-07-04 12:13:48 -07:00
|
|
|
|
2011-01-19 21:07:28 -08:00
|
|
|
Gui::LabelSet *m_clickableLabels;
|
2011-07-03 23:18:18 -07:00
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
std::set<const Faction *> m_visibleFactions;
|
|
|
|
std::set<const Faction *> m_hiddenFactions;
|
2012-11-21 12:04:55 -08:00
|
|
|
|
2012-11-23 12:36:00 -08:00
|
|
|
Uint8 m_detailBoxVisible;
|
|
|
|
|
2019-01-02 08:59:07 -08:00
|
|
|
void OnToggleFaction(Gui::ToggleButton *button, bool pressed, const Faction *faction);
|
2012-11-21 08:23:37 -08:00
|
|
|
|
2013-09-24 00:50:41 -07:00
|
|
|
sigc::connection m_onMouseWheelCon;
|
2020-06-26 10:43:38 -07:00
|
|
|
sigc::connection m_onToggleSelectionFollowView;
|
|
|
|
sigc::connection m_onWarpToCurrent;
|
|
|
|
sigc::connection m_onWarpToSelected;
|
|
|
|
sigc::connection m_onViewReset;
|
2011-06-20 03:25:49 -07:00
|
|
|
|
2014-02-01 04:04:09 -08:00
|
|
|
RefCountedPtr<SectorCache::Slave> m_sectorCache;
|
2012-05-30 17:32:07 -07:00
|
|
|
std::string m_previousSearch;
|
2011-08-15 05:36:49 -07:00
|
|
|
|
|
|
|
float m_playerHyperspaceRange;
|
2014-01-11 09:54:24 -08:00
|
|
|
Graphics::Drawables::Line3D m_selectedLine;
|
2014-01-11 10:00:28 -08:00
|
|
|
Graphics::Drawables::Line3D m_secondLine;
|
|
|
|
Graphics::Drawables::Line3D m_jumpLine;
|
2012-11-20 15:05:06 -08:00
|
|
|
|
2017-12-28 05:55:47 -08:00
|
|
|
// HyperJump Route Planner Stuff
|
|
|
|
std::vector<SystemPath> m_route;
|
2020-12-10 13:42:13 -08:00
|
|
|
Graphics::Drawables::Lines m_routeLines;
|
2017-12-28 05:55:47 -08:00
|
|
|
bool m_drawRouteLines;
|
2020-12-10 13:42:13 -08:00
|
|
|
bool m_setupRouteLines;
|
|
|
|
void DrawRouteLines(const matrix4x4f &trans);
|
|
|
|
void SetupRouteLines(const vector3f &playerAbsPos);
|
|
|
|
void GetPlayerPosAndStarSize(vector3f &playerPosOut, float ¤tStarSizeOut);
|
2017-12-28 05:55:47 -08:00
|
|
|
|
2014-01-26 17:26:44 -08:00
|
|
|
Graphics::RenderState *m_solidState;
|
|
|
|
Graphics::RenderState *m_alphaBlendState;
|
|
|
|
Graphics::RenderState *m_jumpSphereState;
|
2014-02-02 13:03:41 -08:00
|
|
|
RefCountedPtr<Graphics::Material> m_material; //flat colour
|
|
|
|
RefCountedPtr<Graphics::Material> m_starMaterial;
|
2012-11-26 11:42:58 -08:00
|
|
|
|
2012-11-20 15:05:06 -08:00
|
|
|
std::vector<vector3f> m_farstars;
|
2019-01-02 08:59:07 -08:00
|
|
|
std::vector<Color> m_farstarsColor;
|
2012-11-20 15:05:06 -08:00
|
|
|
|
2012-11-23 12:36:00 -08:00
|
|
|
vector3f m_secPosFar;
|
2019-01-02 08:59:07 -08:00
|
|
|
int m_radiusFar;
|
|
|
|
bool m_toggledFaction;
|
2012-11-27 14:21:24 -08:00
|
|
|
|
2014-02-01 04:04:09 -08:00
|
|
|
int m_cacheXMin;
|
|
|
|
int m_cacheXMax;
|
|
|
|
int m_cacheYMin;
|
|
|
|
int m_cacheYMax;
|
|
|
|
int m_cacheZMin;
|
|
|
|
int m_cacheZMax;
|
|
|
|
|
2013-10-29 04:44:49 -07:00
|
|
|
std::unique_ptr<Graphics::VertexArray> m_lineVerts;
|
|
|
|
std::unique_ptr<Graphics::VertexArray> m_secLineVerts;
|
2014-09-23 13:11:37 -07:00
|
|
|
RefCountedPtr<Graphics::Material> m_fresnelMat;
|
2013-10-29 04:44:49 -07:00
|
|
|
std::unique_ptr<Graphics::Drawables::Sphere3D> m_jumpSphere;
|
2014-02-02 13:03:41 -08:00
|
|
|
std::unique_ptr<Graphics::VertexArray> m_starVerts;
|
2015-01-02 08:50:02 -08:00
|
|
|
|
|
|
|
Graphics::Drawables::Lines m_lines;
|
|
|
|
Graphics::Drawables::Lines m_sectorlines;
|
2015-01-02 14:43:26 -08:00
|
|
|
Graphics::Drawables::Points m_farstarsPoints;
|
2008-06-24 03:17:31 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _SECTORVIEW_H */
|