Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / client / src / interface_v3 / group_compas.h
blob804c36cb90657ac7e1e987e5ebf620ebbb78d636
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2015 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 //
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program 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 Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef CL_GROUP_COMPAS_HELP_H
25 #define CL_GROUP_COMPAS_HELP_H
27 #include "nel/misc/types_nl.h"
28 #include "nel/misc/vector_2f.h"
29 #include "nel/gui/group_container.h"
30 #include "nel/gui/group_menu.h"
31 #include "animal_position_state.h"
33 class CViewRadar;
35 // time for the compass to blink (to indicate that player has clicked on it)
36 const float COMPASS_BLINK_TIME = 0.3f;
38 /**
39 * Target of a compass
40 * \author Nicolas Vizerie
41 * \author Nevrax France
42 * \date 2003
45 class CCompassTarget
47 public:
48 enum TType { North = 0, Selection, Home, Respawn, ContinentLandMark, UserLandMark, PosTracker, NumTypes };
49 NLMISC::CVector2f Pos; // Used for static target (ie not the current selection, a team member ...)
50 std::string Name;
51 CCompassTarget();
52 TType getType() const { return _Type; }
53 void setType(TType type) { if (type == _Type) return; setPositionState(NULL); _Type = type; }
54 // returns position tracker (if type is 'PosTracker')
55 CPositionState *getPositionState() { return _PositionState; }
56 void setPositionState(CPositionState *ps) {if (ps != _PositionState) _PositionState = ps; if (ps) _Type = PosTracker; }
58 void serial(NLMISC::IStream &f);
59 private:
60 TType _Type;
61 NLMISC::CSmartPtr<CPositionState> _PositionState; // use smart pointer for copy/dtor convenience
65 // helper function to build compass targets
66 bool buildCompassTargetFromTeamMember(CCompassTarget &ct, uint teamMemberId);
67 bool buildCompassTargetFromAnimalMember(CCompassTarget &ct, uint animalMemberId);
70 /**
71 * Compas group
73 * Default target is north
75 * \author Cyril 'Hulud' Corvazier
76 * \author Nevrax France
77 * \date 2003
79 class CGroupCompas : public CGroupContainer
81 friend class CHandlerChangeCompas;
82 public:
85 // Constructor
86 CGroupCompas(const TCtorParam &param);
87 ~CGroupCompas();
89 // From CInterfaceElement
90 virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
91 virtual void updateCoords();
92 virtual void draw();
93 virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
95 void setTarget(const CCompassTarget &target);
96 const CCompassTarget &getTarget() const { return _Target; }
98 // force the compass to blink (for example to indicate that a new target has been selected)
99 void blink();
102 virtual bool wantSerialConfig() const;
103 // config serialization will save the current compass direction
104 virtual void serialConfig(NLMISC::IStream &f);
106 bool isSavedTargetValid() const { return _SavedTargetValid; }
107 CCompassTarget &getSavedTarget() { return _SavedTarget; }
109 private:
110 // The arrow shape
111 class CInterface3DShape *_ArrowShape;
112 CCompassTarget _Target;
113 bool _TargetSetOnce;
114 CCompassTarget _SavedTarget;
115 bool _SavedTargetValid;
117 NLMISC::CCDBNodeLeaf *_DynamicTargetPos;
118 uint32 _LastDynamicTargetPos;
120 // Color for each type of target
121 NLMISC::CRGBA _TargetTypeColor[CCompassTarget::NumTypes];
123 // Color when a new target has been selected
124 NLMISC::CRGBA _NewTargetSelectedColor;
126 bool _Blinking;
127 double _StartBlinkTime;
128 std::string _CurrTargetName;
130 // The dist text
131 CViewText *_DistView;
132 std::string _DistViewText;
134 CViewRadar *_RadarView;
135 CViewText *_RadarRangeView;
136 uint32 _RadarPos;
138 NLMISC::CVector2f getNorthPos(const NLMISC::CVector2f &userPos) const;
140 class CDBUseCameraObs : public NLMISC::ICDBNode::IPropertyObserver
142 public:
143 CDBUseCameraObs():_useCamera(false),_changed(false)
145 virtual void update( NLMISC::ICDBNode *node);
146 bool _useCamera;
147 bool _changed;
149 CDBUseCameraObs _UseCameraObs;
153 * Compas menu group
154 * \author Cyril 'Hulud' Corvazier
155 * \author Nevrax France
156 * \date 2003
158 class CGroupCompasMenu : public CGroupMenu
160 public:
162 // Constructor
163 CGroupCompasMenu(const TCtorParam &param);
164 ~CGroupCompasMenu();
166 // parse
167 virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parent=NULL);
169 // From CInterfaceElement
170 virtual void setActive (bool state);
172 // name of the target compass for that menu
173 std::string _TargetCompass;
175 // current locations for displayed menu
176 std::vector<CCompassTarget> Targets;
180 * singleton used to store dialog compass targets
181 * \author Nicolas Brigand
182 * \author Nevrax France
183 * \date 2005
185 class CCompassDialogsManager
187 public:
188 /// entry in the dialog
189 struct CCompassDialogsEntry
191 CCompassDialogsEntry(sint32 x,sint32 y, uint32 text )
192 :X(x), Y(y), Text(text){}
194 sint32 X;
195 sint32 Y;
196 uint32 Text;
198 static CCompassDialogsManager & getInstance()
200 if ( _Instance == NULL )
201 _Instance = new CCompassDialogsManager;
202 return *_Instance;
205 const std::vector<CCompassDialogsEntry> & getEntries() { return _Entries; }
207 void addEntry( sint32 x, sint32 y, uint32 text )
209 _Entries.push_back( CCompassDialogsEntry(x,y,text) );
212 void removeEntry(uint32 text);
215 private:
216 friend class CCompassDialogsStringCallback;
218 CCompassDialogsManager(){}
219 ~CCompassDialogsManager(){}
221 static CCompassDialogsManager * _Instance;
222 std::vector<CCompassDialogsEntry> _Entries;
225 #endif // CL_GROUP_COMPAS_HELP_H