forked from freeorion/freeorion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SidePanel.h
143 lines (104 loc) · 5.95 KB
/
SidePanel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// -*- C++ -*-
#ifndef _SidePanel_h_
#define _SidePanel_h_
#include "CUIControls.h"
#include "CUIWnd.h"
#include "../universe/ResourceCenter.h"
#include "../universe/Planet.h"
#include "../universe/System.h"
#include <GG/DynamicGraphic.h>
#include <GG/SignalsAndSlots.h>
#include <GG/Texture.h>
#include <vector>
class CUIDropDownList;
class MultiIconValueIndicator;
class SidePanel : public CUIWnd {
public:
class PlanetPanel;
/** \name Structors */ //@{
SidePanel(GG::X x, GG::Y y, GG::Y h);
~SidePanel();
//@}
/** \name Accessors */ //@{
virtual bool InWindow(const GG::Pt& pt) const;
virtual GG::Pt ClientUpperLeft() const;
/** Returns the id of the system shown in the SidePanels, or
* INVALID_OBJECT_ID if no system is shown */
static int SystemID();
/** Returns the id of the currently-selected planet, or
* INVALID_OBJECT_ID if no planet is selected */
int SelectedPlanetID() const;
/** Returns whether this SidePanel contains an object with the indicated
* \a object_id that can be selected within the SidePanel. */
bool PlanetSelectable(int id) const;
//@}
/** \name Mutators */ //@{
virtual void Render();
virtual void SizeMove(const GG::Pt& ul, const GG::Pt& lr);
/** Updates contents of sidepanel, but doesn't recreate contents or check
* that object pointers are still valid. All SidePanels' are updated */
static void Update();
/** Fully refreshes sidepanel and contents, recreating all contents from
* stored system id. All SidePanels' are refreshed. */
static void Refresh();
/** Selects the planet with id \a planet_id within the current system, if
* such a planet exists. All SidePanels' selected planets are set, if
* those panels have planet selection enabled. */
static void SelectPlanet(int planet_id);
/** Sets the system currently being viewed in all side panels */
static void SetSystem(int system_id);
/** Enables, or disables if \a enable is false, selection of planet panels
* within this SidePanel. Panels that can be selected are those which
* meet selection conditions that need to be figured out and perhaps
* made more configurable, but for now are just those planets owned by
* this client's empire. */
void EnableSelection(bool enable = true);
/** Enables, or disables if \a enable is false, issuing orders via the SidePanel. */
void EnableOrderIssuing(bool enable = true);
//@}
/** emitted when a rotating planet in the side panel is clicked by the
* user */
static boost::signals2::signal<void (int)> PlanetSelectedSignal;
/** emitted when something in the sidepanel wants to change the selected
* system, including the droplist or back/forward arrows */
static boost::signals2::signal<void (int)> SystemSelectedSignal;
/** emitted when a planet's resourcecenter has changed, including when
* focus is changed */
static boost::signals2::signal<void ()> ResourceCenterChangedSignal;
/** emitted when a planet is left double clicked*/
static boost::signals2::signal<void (int)> PlanetDoubleClickedSignal;
/** emitted when a planet is right clicked */
static boost::signals2::signal<void (int)> PlanetRightClickedSignal;
/** emitted when a building is right clicked */
static boost::signals2::signal<void (int)> BuildingRightClickedSignal;
private:
class PlanetPanelContainer;
void DoLayout();
GG::Pt ListRowSize() const;
void UpdateImpl(); ///< updates contents quickly. to be used when meters or other objects' data changes
void RefreshImpl(); ///< fully refreshes contents. to be used when objects are created, destroyed or added to system
void SelectPlanetImpl(int planet_id);///< sets selected planet in this sidepanel
void SystemSelectionChanged(GG::DropDownList::iterator it); ///< responds to user selecting a system in the droplist. may emit SystemSelectedSignal
void PrevButtonClicked(); ///< responds to user clicking next system button
void NextButtonClicked(); ///< responts to user clicking previous system button
void PlanetSelected(int planet_id); ///< responds to user selection of a planet by emitting PlanetSelectedSignal
static void FleetsInserted(const std::vector<TemporaryPtr<Fleet> >& fleets); ///< responds to insertion fleets into system during a turn. may update colonize buttons
static void FleetsRemoved(const std::vector<TemporaryPtr<Fleet> >& fleets); ///< responds to removal fleets from system during a turn. may update colonize buttons
static void FleetStateChanged(); ///< responds to fleet state changes during a turn, which may include issueing or cancelling move orders. may update colonize buttons
CUIDropDownList* m_system_name;
GG::TextControl* m_star_type_text;
GG::Button* m_button_prev;
GG::Button* m_button_next;
GG::DynamicGraphic* m_star_graphic;
std::vector<GG::SubTexture> m_fleet_icons;
PlanetPanelContainer* m_planet_panel_container;
MultiIconValueIndicator* m_system_resource_summary;
bool m_selection_enabled;
static int s_system_id;
static std::set<SidePanel*> s_side_panels;
static std::set<boost::signals2::connection> s_system_connections;
static std::map<int, boost::signals2::connection> s_fleet_state_change_signals;
};
TemporaryPtr<const Ship> ValidSelectedColonyShip(int system_id);
int AutomaticallyChosenColonyShip(int target_planet_id);
#endif // _SidePanel_h_