1 #ifndef _MapWnd_h_
2 #define _MapWnd_h_
3 
4 #include <GG/GGFwd.h>
5 #include <GG/GLClientAndServerBuffer.h>
6 
7 #include "CUIWnd.h"
8 #include "CUISlider.h"
9 #include "../universe/EnumsFwd.h"
10 #include "../universe/Fleet.h"
11 #include "FleetButton.h"
12 
13 #include <boost/functional/hash.hpp>
14 
15 #include <chrono>
16 #include <unordered_map>
17 #include <unordered_set>
18 #include <vector>
19 
20 
21 class FleetWnd;
22 class MapWndPopup;
23 class DesignWnd;
24 class ProductionWnd;
25 class ResearchWnd;
26 class EncyclopediaDetailPanel;
27 class CombatReportWnd;
28 class ObjectListWnd;
29 class ModeratorActionsWnd;
30 struct SaveGameUIData;
31 class SidePanel;
32 class SitRepPanel;
33 class SystemIcon;
34 class FieldIcon;
35 class StatisticIcon;
36 class CUIToolBar;
37 class UniverseObject;
38 struct MovePathNode;
39 class ShaderProgram;
40 
41 /* Start and end points in universe coordinates as seen in MapWnd.  Lanes are drawn to
42  * and from a circle surrounding system icons, note the centre of the system icon. The
43  * location of these start ane endpoints is used for rendering the starlane and for
44  * positioning fleet buttons that are moving along the starlane. */
45 struct LaneEndpoints {
46     LaneEndpoints();
LaneEndpointsLaneEndpoints47     LaneEndpoints(float x1, float y1, float x2, float y2) :
48         X1(x1),
49         Y1(y1),
50         X2(x2),
51         Y2(y2)
52     {}
53     float X1, Y1, X2, Y2;
54 };
55 
56 
57 /** This class is a window that graphically displays everything in the universe */
58 class MapWnd : public GG::Wnd {
59 public:
60     //! \name Structors //!@{
61     MapWnd();
62 
63     ~MapWnd();
64     //!@}
65 
66     void CompleteConstruction() override;
67 
68     //! \name Accessors //!@{
69     GG::Pt ClientUpperLeft() const override;
70 
71     double                      ZoomFactor() const;
72     int                         SystemIconSize() const;
73     int                         SystemNamePts() const;
74     double                      SystemHaloScaleFactor() const;
75 
76     /** returns what size type (tiny, small, large) fleet buttons on this map
77       * are shown at */
78     FleetButton::SizeType       FleetButtonSizeType() const;
79 
80     /** populates the relevant UI state that should be restored after a
81       * save-and-load cycle */
82     void                        GetSaveGameUIData(SaveGameUIData& data) const;
83 
84     /** returns true if MapWnd is visible and usable behind a production window.
85      * MapWnd interactions are restricted to those appropriate to the production window */
86     bool                        InProductionViewMode() const;
87 
88     /** returns true if MapWnd is visible and usable behind a research window.
89      * MapWnd interactions are restricted to those appropriate to the research window.
90      * Currently, there are no interactions with the MapWnd while the research window
91      * is visible because although the MapWnd is visible the research window is opaque
92      * and on top.*/
93     bool                        InResearchViewMode() const;
94 
95     /** returns true if MapWnd is visible and usable behind a design window.
96      * MapWnd interactions are restricted to those appropriate to the design window
97      * Currently, there are no interactions with the MapWnd while the design window
98      * is visible because although the MapWnd is visible the design window is opaque
99      * and on top.*/
100     bool                        InDesignViewMode() const;
101 
102     /** returns the currently set moderator action in this MapWnd's
103       * ModeratorActionsWnd. */
104     ModeratorActionSetting      GetModeratorActionSetting() const;
105 
106     bool                        AutoEndTurnEnabled() const;
107 
108     /** returns the position on the screen that corresponds to the specified
109       * universe X and Y coordinates. */
110     GG::Pt                      ScreenCoordsFromUniversePosition(double universe_x, double universe_y) const;
111     /** returns the universe position (X and Y in pair) that corresponds to
112       * the specified screen coordinates. */
113     std::pair<double, double>   UniversePositionFromScreenCoords(GG::Pt screen_coords) const;
114 
115     /** Returns the id of the currently-selected planet, or
116       * INVALID_OBJECT_ID if no planet is selected */
117     int                         SelectedPlanetID() const;
118     //!@}
119 
120     //! \name Mutators //!@{
121     void PreRender() override;
122     void Render() override;
123     void LButtonDown(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) override;
124     void LDrag(const GG::Pt& pt, const GG::Pt& move, GG::Flags<GG::ModKey> mod_keys) override;
125     void LButtonUp(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) override;
126     void LClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) override;
127     void RClick(const GG::Pt& pt, GG::Flags<GG::ModKey> mod_keys) override;
128     void MouseWheel(const GG::Pt& pt, int move, GG::Flags<GG::ModKey> mod_keys) override;
129     void KeyPress(GG::Key key, std::uint32_t key_code_point, GG::Flags<GG::ModKey> mod_keys) override;
130     void KeyRelease(GG::Key key, std::uint32_t key_code_point, GG::Flags<GG::ModKey> mod_keys) override;
131     void TimerFiring(unsigned int ticks, GG::Timer* timer) override;
132 
133     void DoLayout();
134 
135     void RegisterWindows();                                      //!< registers owned wnds with the GUI (also registers message & player list wnds)
136     void RemoveWindows();                                        //!< removes owned wnds from the GUI (also removes message & player list wnds)
137 
138     void EnableOrderIssuing(bool enable = true);                 //!< enables or disables order issuing and pressing the turn button.
139 
140     void InitTurn();                                             //!< called at the start of each turn
141     void MidTurnUpdate();                                        //!< called after receiving updated Universe during turn processing, but not when the full turn update is received
142 
143     void RestoreFromSaveData(const SaveGameUIData& data);        //!< restores the UI state that was saved in an earlier call to GetSaveGameUIData().
144     void ShowSystemNames();                                      //!< enables the system name text
145     void HideSystemNames();                                      //!< disables the system name text
146 
147     mutable boost::signals2::signal<void (int)>    SystemLeftClickedSignal;
148     mutable boost::signals2::signal<void (int)>    SystemRightClickedSignal;
149     mutable boost::signals2::signal<void (int)>    SystemBrowsedSignal;
150     mutable boost::signals2::signal<void (double)> ZoomedSignal;
151 
152     void CenterOnMapCoord(double x, double y);                   //!< centers the map on map position (x, y)
153     void CenterOnObject(int id);                                 //!< centers the map on object with id \a id
154 
155     /** Centers the map on object \a id. */
156     void CenterOnObject(std::shared_ptr<const UniverseObject> obj);
157 
158     void ShowPlanet(int planet_id);                              //!< brings up encyclopedia panel and displays info about the planet
159     void ShowCombatLog(int log_id);                              //!< brings up encyclopedia panel and displays info about the combat
160     void ShowTech(const std::string& tech_name);                 //!< brings up the research screen and centers the tech tree on \a tech_name
161     void ShowBuildingType(const std::string& building_type_name);//!< brings up the production screen and displays info about the buildtype \a type_name
162 
163     //! Brings up the production screen and displays info about
164     //! the ShipPart @a ship_part_name.
165     void ShowShipPart(const std::string& ship_part_name);
166 
167     //! Brings up the production screen and displays info about the ShipHull
168     //! @p ship_hull_name
169     void ShowShipHull(const std::string& ship_hull_name);
170 
171     void ShowShipDesign(int design_id);                          //!< brings up the production screen and displays info about the buildtype \a type_name
172     void ShowSpecial(const std::string& special_name);           //!< brings up encyclopedia panel and displays info about the special with name \a special_name
173     void ShowSpecies(const std::string& species_name);           //!< brings up encyclopedia panel and displays info about the species with name \a species_name
174     void ShowFieldType(const std::string& field_type_name);      //!< brings up encyclopedia panel and displays info about the field type with name \a field_type_name
175     void ShowEmpire(int empire_id);                              //!< brings up encyclopedia panel and displays info about the empire with id \a empire_id
176     void ShowMeterTypeArticle(const std::string& meter_string);  //!< brings up encyclopedia panel and displays info about the MeterType @a meter_type
177     void ShowEncyclopediaEntry(const std::string& str);          //!< brings up encyclopedia panel and displays info about the specified string \a str
178 
179     void SelectSystem(int systemID); //!< programatically selects systems on map, sidepanel, and production screen.  catches signals from these when the user changes the selected system
180     void ReselectLastSystem();       //!< re-selects the most recently selected system, if a valid one exists
181     void SelectPlanet(int planetID); //!< programatically selects planets on sidepanels.  catches signals from production wnd or sidepanel for when the user changes the selected planet
182     void SelectFleet(int fleetID);   //!< programatically selects fleets by ID
183 
184     /** Programatically selects fleets. */
185     void SelectFleet(std::shared_ptr<Fleet> fleet);
186 
187     void ReselectLastFleet();                    //!< re-selects the most recent selected fleet, if a valid one exists
188 
189     void RemoveFleet(int fleet_id); //!< removes specified fleet.
190     void SetFleetMovementLine(int fleet_id);     //!< creates fleet movement line for a single fleet.  Move lines originate from the fleet's button location.
191 
192     /* creates specially-coloured projected fleet movement line for specified
193      * fleet following the specified route.  Move line originates from the
194      * fleet's button location. */
195     void SetProjectedFleetMovementLine(int fleet_id, const std::list<int>& travel_route);
196     /* creates specially-coloured projected fleet movement lines for specified
197      * fleets following the specified route.  Move lines originates from the
198      * fleets' button locations. */
199     void SetProjectedFleetMovementLines(const std::vector<int>& fleet_ids, const std::list<int>& travel_route);
200 
201     void ClearProjectedFleetMovementLines();     //!< removes all projected fleet movement lines
202 
203     /** Forget object with \p id.  Used for sensor ghosts. */
204     void ForgetObject(int id);
205 
206     void ResetEmpireShown();                     //!< auto-resets the shown empire in any contained Wnds, to the current client's empire (if any)
207 
208     void RegisterPopup(const std::shared_ptr<MapWndPopup>& popup);              //!< registers a MapWndPopup, which can be cleaned up with a call to DeleteAllPopups( )
209     void RemovePopup(MapWndPopup* popup);        //!< removes a MapWndPopup from the list cleaned up on a call to DeleteAllPopups( )
210     void Sanitize();                             //!< sanitizes the MapWnd after a game
211     void ResetTimeoutClock(int timeout);         //!< start count down \a timeout seconds
212     //!@}
213 
214     void SetFleetExploring(const int fleet_id);
215     void StopFleetExploring(const int fleet_id);
216     bool IsFleetExploring(const int fleet_id);
217     void DispatchFleetsExploring();              //!< called at each turn begin and when a fleet start/stop exploring to redispatch everyone.
218 
219 
220 private:
221     void RefreshTurnButtonTooltip();
222 
223     void RefreshTradeResourceIndicator();
224     void RefreshFleetResourceIndicator();
225     void RefreshResearchResourceIndicator();
226     void RefreshIndustryResourceIndicator();
227     void RefreshPopulationIndicator();
228     void RefreshDetectionIndicator();
229 
230     /** update meter estimates for objects contained within the current system
231       * shown in the sidepanel, or all objects if there is no system shown */
232     void UpdateSidePanelSystemObjectMetersAndResourcePools();
233     /** recalculates production and predicted changes of player's empire's
234       * resource and population pools */
235     void UpdateEmpireResourcePools();
236 
237     /** contains information necessary to render a single fleet movement line
238       * on the main map. also contains cached infromation */
239     struct MovementLineData {
240         struct Vertex;  // apparent universe positions of move line points, derived from actual universe positions contained in MovePathNodes
241         MovementLineData();
242         MovementLineData(const std::list<MovePathNode>& path_,
243                          const std::map<std::pair<int, int>, LaneEndpoints>& lane_end_points_map,
244                          GG::Clr colour_ = GG::CLR_WHITE, int empireID = ALL_EMPIRES);
245 
246         std::list<MovePathNode> path;       // raw path data from which line rendering is determined
247         GG::Clr                 colour;     // colour of line
248         std::vector<Vertex>     vertices;   // cached apparent universe positions of starts and ends of line segments drawn to represent move path
249     };
250 
251     class MapScaleLine;
252 
253     void            InitializeWindows();
254 
255     void            Zoom(int delta);                            //!< changes the zoom level of the main map by zoom step size to the power of \a delta (adds delta to the current zoom exponent)
256     void            Zoom(int delta, const GG::Pt& position);    //!< changes the zoom level of the main map by zoom step size to the power of \a delta (adds delta to the current zoom exponent) Keeps the screen position \a position in the same place after zooming
257     void            SetZoom(double steps_in, bool update_slide);//!< sets zoom level of the main map to zoom step size to the power of \a steps_in and updates zoom slider position if \a update_slide is true
258     void            SetZoom(double steps_in, bool update_slide, const GG::Pt& position);//!< sets zoom level of the main map to zoom step size to the power of \a steps_in and updates zoom slider position if \a update_slide is true. Keeps the screen position \a position in the same place after zooming
259 
260     void            Pan(const GG::Pt& delta);                   //!< pans map
261     bool            PanX(GG::X x = GG::X(50));
262     bool            PanY(GG::Y y = GG::Y(50));
263 
264     /** Mark all fleet buttons for a refresh. */
265     void            RefreshFleetButtons();
266     /** Removes old / existing and create new fleet buttons. Only called once
267       * per render interval.*/
268     void            DeferredRefreshFleetButtons();
269 
270     /** Use the vectors of fleet ids from \p fleets_map to create fleet buttons
271       * in \p type_fleet_buttons and record the fleet buttons in
272       * \p m_fleet_buttons.*/
273     template <typename FleetButtonMap, typename FleetsMap>
274     void CreateFleetButtonsOfType (
275         FleetButtonMap& type_fleet_buttons,
276         const FleetsMap &fleets_map,
277         const FleetButton::SizeType & fleet_button_size);
278 
279     /** Delete all fleet buttons.*/
280     void DeleteFleetButtons();
281 
282     void RefreshFleetButtonSelectionIndicators();    //!< marks (only) selected fleets' buttons as selected
283 
284     void DoFleetButtonsLayout();                     //!< does layout of fleet buttons
285 
286     /** Return fleets ids of all fleet buttons containing or overlapping the
287         fleet button for \p fleet_id. */
288     std::vector<int> FleetIDsOfFleetButtonsOverlapping(int fleet_id) const;
289     /** Return fleets ids of all fleet buttons containing or overlapping \p fleet_btn. */
290     std::vector<int> FleetIDsOfFleetButtonsOverlapping(const FleetButton& fleet_btn) const;
291 
292     /** Returns position on map where a moving fleet should be displayed.  This
293         is different from the fleet's actual universe position due to the
294         squishing of fleets moving along a lane into the space between the
295         system circles at the ends of the lane.  Return boost::none if the
296         fleet has no valid screen position. */
297     boost::optional<std::pair<double, double>> MovingFleetMapPositionOnLane(std::shared_ptr<const Fleet> fleet) const;
298 
299     void DoSystemIconsLayout();          //!< does layout of system icons
300     void DoFieldIconsLayout();           //!< does layout of field icons
301 
302     void RefreshSliders();               //!< shows or hides sliders on map
303 
304     void InitTurnRendering();            //!< sets up rendering of system icons, galaxy gas, starlanes at start of turn
305     void InitSystemRenderingBuffers();   //!< initializes or refreshes buffers for rendering of system icons and galaxy gas
306     void ClearSystemRenderingBuffers();
307     void InitStarlaneRenderingBuffers(); //!< initializes or refreshes buffers for rendering of starlanes
308     void ClearStarlaneRenderingBuffers();
309     void InitFieldRenderingBuffers();
310     void ClearFieldRenderingBuffers();
311     void InitVisibilityRadiiRenderingBuffers();
312     void ClearVisibilityRadiiRenderingBuffers();
313     void InitScaleCircleRenderingBuffer();
314     void ClearScaleCircleRenderingBuffer();
315     void ClearStarfieldRenderingBuffers();
316 
317     void RenderStarfields();     //!< renders the background starfiends
318     void RenderGalaxyGas();      //!< renders gassy substance to make shape of galaxy
319     void RenderSystemOverlays(); //!< renders textures "overlayed" on systems by effects
320     void RenderSystems();        //!< renders stars and halos
321     void RenderStarlanes();      //!< renders the starlanes between the systems
322     void RenderStarlanes(GG::GL2DVertexBuffer& vertices,
323                          GG::GLRGBAColorBuffer& colours,
324                          double thickness, bool coloured, bool do_base_render);
325     void RenderFields();         //!< renders field objects
326 
327     /* renders the dashed lines indicating where each fleet is going */
328     void RenderFleetMovementLines();
329 
330     /* renders a single fleet movement line. if \a clr is GG::CLR_ZERO, the lane
331      * is rendered with the .colour attribute of \a move_line. assumes that the
332      * move dot texture has already been bound. */
333     void RenderMovementLine(const MapWnd::MovementLineData& move_line, float dot_size, float dot_spacing, float dot_shift,
334                             GG::Clr clr = GG::CLR_ZERO);
335 
336     /* renders ETA indicators at end-of-turn positions for a single fleet movement
337      * line.  if \a clr is GG::CLR_ZERO, the indicators are filled with the .colour
338      * attribute of \a move_line */
339     void RenderMovementLineETAIndicators(const MapWnd::MovementLineData& move_line, GG::Clr clr = GG::CLR_ZERO);
340 
341     /* renders circles around objects' locations indicating distance they have
342      * visibility */
343     void RenderVisibilityRadii();
344 
345     /* renders scale circle around selected system. */
346     void RenderScaleCircle();
347 
348     void CorrectMapPosition(GG::Pt& move_to_pt);     //!< constrains \a move_to_pt so that if the map is repositioned to that location, it will not be problematically positioned, so that galaxy contents remain visible
349 
350     void FieldRightClicked(int field_id);
351 
352     void SystemDoubleClicked(int system_id);
353     void SystemLeftClicked(int system_id);
354     void SystemRightClicked(int system_id, GG::Flags< GG::ModKey > mod_keys);
355     void MouseEnteringSystem(int system_id, GG::Flags< GG::ModKey > mod_keys);
356     void MouseLeavingSystem(int system_id);
357 
358     void PlanetDoubleClicked(int planet_id);
359     void PlanetRightClicked(int planet_id);
360     void BuildingRightClicked(int building_id);
361 
362     void ReplotProjectedFleetMovement(bool append); //!< Find any projected movement plots and replots them with the current append state
363     void PlotFleetMovement(int system_id, bool execute_move, bool append);   //!< issues fleet move orders to appropriate fleets in active FleetWnd
364 
365     void FleetButtonLeftClicked(const FleetButton* fleet_btn);
366     void FleetButtonRightClicked(const FleetButton* fleet_btn);
367     void FleetRightClicked(int fleet_id);
368     void FleetsRightClicked(const std::vector<int>& fleet_ids);
369 
370     void ShipRightClicked(int fleet_id);
371     void ShipsRightClicked(const std::vector<int>& fleet_ids);
372 
373     void UniverseObjectDeleted(std::shared_ptr<const UniverseObject> obj);
374 
375     void PushWndStack(std::shared_ptr<GG::Wnd> wnd);
376     void RemoveFromWndStack(std::shared_ptr<GG::Wnd> wnd);
377     bool ReturnToMap();
378 
379     bool EndTurn();
380     void ToggleAutoEndTurn();
381 
382     bool ToggleModeratorActions();
383     void ShowModeratorActions();
384     void HideModeratorActions();
385 
386     bool ToggleMessages();
387     void ShowMessages();
388     void HideMessages();
389 
390     bool ToggleSitRep();
391     void ShowSitRep();
392     void HideSitRep();
393 
394     bool ToggleEmpires();
395     void ShowEmpires();
396     void HideEmpires();
397 
398     bool ToggleObjects();
399     void ShowObjects();
400     void HideObjects();
401 
402     bool TogglePedia();
403     void ShowPedia();
404     void HidePedia();
405 
406     bool ShowGraphs();
407 
408     void HideSidePanel();
409     void RestoreSidePanel(); //!< restores side panel, sends to server changes made in other windows
410 
411     bool ToggleResearch();
412     void ShowResearch();
413     void HideResearch();
414 
415     bool ToggleProduction();
416     void ShowProduction();
417     void HideProduction();
418 
419     bool ToggleDesign();
420     void ShowDesign();
421     void HideDesign();
422 
423     bool ShowMenu();
424 
425     bool CloseSystemView(); //!< closes off the current system view
426 
427     bool KeyboardZoomIn();
428     bool KeyboardZoomOut();
429 
430     bool ZoomToHomeSystem();
431     bool ZoomToPrevOwnedSystem();
432     bool ZoomToNextOwnedSystem();
433     bool ZoomToPrevSystem();
434     bool ZoomToNextSystem();
435     bool ZoomToPrevIdleFleet();
436     bool ZoomToNextIdleFleet();
437     bool ZoomToPrevFleet();
438     bool ZoomToNextFleet();
439     bool ZoomToSystemWithWastedPP();
440 
441     void ConnectKeyboardAcceleratorSignals();   //!< connects signals from keyboard accelerators to various GUI responses
442 
443     void CloseAllPopups();
444     void HideAllPopups();
445     void ShowAllPopups();
446 
447     void SelectedFleetsChanged();
448     void SelectedShipsChanged();
449 
450     std::set<int>                               m_selected_fleet_ids;
451     std::set<int>                               m_selected_ship_ids;
452 
453     double                                      m_zoom_steps_in = 1.0;      //!< number of zoom steps in.  each 1.0 step increases display scaling by the same zoom step factor
454     std::shared_ptr<SidePanel>                  m_side_panel;               //!< planet view panel on the side of the main map
455     std::unordered_map<int, std::shared_ptr<SystemIcon>> m_system_icons;    //!< system icons in the main map, indexed by system id
456     std::map<int, std::shared_ptr<FieldIcon>>   m_field_icons;              //!< field icons in the main map, indexed by field id
457     std::shared_ptr<SitRepPanel>                m_sitrep_panel;             //!< sitrep panel
458     std::shared_ptr<ResearchWnd>                m_research_wnd;             //!< research screen
459     std::shared_ptr<ProductionWnd>              m_production_wnd;           //!< production screen
460     std::shared_ptr<DesignWnd>                  m_design_wnd;               //!< design screen
461     std::shared_ptr<EncyclopediaDetailPanel>    m_pedia_panel;              //!< encyclpedia panel
462     std::shared_ptr<ObjectListWnd>              m_object_list_wnd;          //!< filterable list of objects in universe
463     std::shared_ptr<ModeratorActionsWnd>        m_moderator_wnd;            //!< buttons to select moderator actions
464     std::shared_ptr<CombatReportWnd>            m_combat_report_wnd;        //!< shows graphical reports of combats
465 
466     std::vector<std::weak_ptr<GG::Wnd>>         m_wnd_stack;                //!< stack of open windows, to allow closing them with escape in a LIFO order
467 
468     std::map<std::pair<int, int>, LaneEndpoints>m_starlane_endpoints;       //!< map from starlane start and end system IDs (stored in pair in increasing order) to the universe coordiates at which to draw the starlane ends
469 
470     /** Icons representing fleets at a system that are not departing, indexed
471         by system. */
472     std::unordered_map<int, std::unordered_set<std::shared_ptr<FleetButton>>>
473         m_stationary_fleet_buttons;
474 
475     /** Icons representing fleets at a system that are departing, indexed by
476         system. */
477     std::unordered_map<int, std::unordered_set<std::shared_ptr<FleetButton>>>
478         m_departing_fleet_buttons;
479 
480     /** Sets of fleet ids of fleets moving on a starlane, keyed by starlane end
481         system ids. */
482     std::unordered_map<std::pair<int, int>,
483                        std::vector<int>,
484                        boost::hash<std::pair<int, int>>>
485         m_moving_fleets;
486 
487     /** Icons representing fleets moving on a starlane, keyed by starlane end
488         system ids. */
489     std::unordered_map<std::pair<int, int>,
490                        std::unordered_set<std::shared_ptr<FleetButton>>,
491                        boost::hash<std::pair<int, int>>>
492         m_moving_fleet_buttons;
493 
494     /** Icons representing fleets moving and not on a starlane, indexed by
495         (x,y) location. */
496     std::unordered_map<std::pair<double, double>,
497                        std::unordered_set<std::shared_ptr<FleetButton>>,
498                        boost::hash<std::pair<double, double>>>
499         m_offroad_fleet_buttons;
500 
501     std::unordered_map<int, std::shared_ptr<FleetButton>>
502         m_fleet_buttons;                        //!< fleet icons, index by fleet
503 
504     std::unordered_map<int, boost::signals2::connection>
505         m_fleet_state_change_signals;
506     std::unordered_map<int, std::vector<boost::signals2::connection>>
507         m_system_fleet_insert_remove_signals;
508 
509     std::map<int, MovementLineData> m_fleet_lines;                  //!< lines used for moving fleets in the main map
510     std::map<int, MovementLineData> m_projected_fleet_lines;        //!< lines that show the projected path of the active fleet in the FleetWnd
511 
512     std::pair<int, int>             m_line_between_systems = {INVALID_OBJECT_ID, INVALID_OBJECT_ID};//!< set when map should render line connecting 2 systems
513 
514     std::map<std::shared_ptr<GG::Texture>, GG::GL2DVertexBuffer> m_star_core_quad_vertices;
515     std::map<std::shared_ptr<GG::Texture>, GG::GL2DVertexBuffer> m_star_halo_quad_vertices;
516     GG::GL2DVertexBuffer            m_galaxy_gas_quad_vertices;
517     GG::GLTexCoordBuffer            m_galaxy_gas_texture_coords;
518     GG::GLTexCoordBuffer            m_star_texture_coords;
519     GG::GL2DVertexBuffer            m_star_circle_vertices;
520 
521     GG::GL2DVertexBuffer            m_starlane_vertices;
522     GG::GLRGBAColorBuffer           m_starlane_colors;
523     GG::GL2DVertexBuffer            m_RC_starlane_vertices;
524     GG::GLRGBAColorBuffer           m_RC_starlane_colors;
525 
526     /** First buffer is visible fields, second buffer is not visible (scanlined)
527         fields for each texture. */
528     std::map<std::shared_ptr<GG::Texture>,
529              std::pair<GG::GL2DVertexBuffer, GG::GL2DVertexBuffer>>
530                                     m_field_vertices;
531 
532     GG::GL2DVertexBuffer            m_field_scanline_circles;
533     GG::GLTexCoordBuffer            m_field_texture_coords;
534 
535     GG::GL2DVertexBuffer            m_visibility_radii_vertices;
536     GG::GLRGBAColorBuffer           m_visibility_radii_colors;
537     GG::GL2DVertexBuffer            m_visibility_radii_border_vertices;
538     GG::GLRGBAColorBuffer           m_visibility_radii_border_colors;
539     std::vector<std::pair<std::pair<std::size_t, std::size_t>,
540                           std::pair<std::size_t, std::size_t>>>
541                                     m_radii_radii_vertices_indices_runs;
542 
543     GG::GL2DVertexBuffer            m_scale_circle_vertices;
544 
545     GG::GL3DVertexBuffer            m_starfield_verts;
546     GG::GLRGBAColorBuffer           m_starfield_colours;
547 
548     ScanlineRenderer                m_scanline_shader;
549 
550     GG::Pt                          m_drag_offset = {-GG::X1, -GG::Y1}; //!< distance the cursor is from the upper-left corner of the window during a drag ((-1, -1) if no drag is occurring)
551     bool                            m_dragged = false;          //!< tracks whether or not a drag occurs during a left button down sequence of events
552 
553     std::shared_ptr<GG::Button>     m_btn_turn;                 //!< button that updates player's turn;
554     std::shared_ptr<GG::Button>     m_btn_auto_turn;            //!< button that toggles whether to automatically end turns;
555     bool                            m_auto_end_turn = false;    //!< should turns be ended automatically by this client?
556     bool                            m_ready_turn = false;       //!< is turn orders are ready and sent to server?
557     std::shared_ptr<GG::Label>      m_timeout_remain;           //!< label to show remaining time
558     GG::Timer                       m_timeout_clock{1000};      //!< clock to update remaining time
559     std::list<std::weak_ptr<MapWndPopup>> m_popups;             //!< list of currently active popup windows
560     bool                            m_menu_showing = false;     //!< set during ShowMenu() to prevent reentrency
561     int                             m_current_owned_system = INVALID_OBJECT_ID;
562     int                             m_current_fleet_id = INVALID_OBJECT_ID;
563     bool                            m_in_production_view_mode = false;
564 
565     bool                            m_sidepanel_open_before_showing_other = false;  //!< was the sidepanel open before switching to production, research or design screens?  If so, it should be restored when leaving them.
566 
567     std::shared_ptr<CUIToolBar>     m_toolbar;
568     std::shared_ptr<StatisticIcon>  m_trade, m_population, m_research,
569                                     m_industry, m_stockpile, m_detection,
570                                     m_fleet;
571     std::shared_ptr<GG::Button>     m_industry_wasted, m_research_wasted,
572                                     m_btn_moderator, m_btn_messages, m_btn_empires,
573                                     m_btn_siterep, m_btn_research, m_btn_production,
574                                     m_btn_design, m_btn_pedia, m_btn_graphs,
575                                     m_btn_objects, m_btn_menu;
576     std::shared_ptr<GG::Label>      m_FPS;
577 
578     std::shared_ptr<MapScaleLine>       m_scale_line;   //!< indicates the on-screen distance that reprensents an in-universe distance
579     std::shared_ptr<GG::Slider<double>> m_zoom_slider;  //!< allows user to set zoom level;
580 
581     std::set<int>                   m_fleets_exploring;
582 
583     /// indicates that refresh fleet button work should be done before rendering.
584     bool                            m_deferred_refresh_fleet_buttons = false;
585 
586     std::chrono::time_point<std::chrono::high_resolution_clock>
587                                     m_timeout_time;
588 
589     friend struct IntroMenu;
590     friend struct WaitingForGameStart;
591     friend struct PlayingTurn;
592     friend struct PlayingGame;
593 };
594 
595 
596 /** Derive any window from this class to have it managed by MapWnd. */
597 class MapWndPopup : public CUIWnd {
598 public:
599     MapWndPopup(const std::string& t, GG::X default_x, GG::Y default_y, GG::X default_w, GG::Y default_h,
600                 GG::Flags<GG::WndFlag> flags, const std::string& config_name = "");
601 
602     MapWndPopup(const std::string& t, GG::Flags<GG::WndFlag> flags, const std::string& config_name = "");
603 
604     void CompleteConstruction() override;
605 
606     virtual ~MapWndPopup();
607 
608     void CloseClicked() override;
609 
610     void    Close();
611 };
612 
613 #endif // _MapWnd_h_
614