1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2015 Winch Gate Property Limited
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>
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"
35 // time for the compass to blink (to indicate that player has clicked on it)
36 const float COMPASS_BLINK_TIME
= 0.3f
;
40 * \author Nicolas Vizerie
41 * \author Nevrax France
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 ...)
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
);
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
);
73 * Default target is north
75 * \author Cyril 'Hulud' Corvazier
76 * \author Nevrax France
79 class CGroupCompas
: public CGroupContainer
81 friend class CHandlerChangeCompas
;
86 CGroupCompas(const TCtorParam
¶m
);
89 // From CInterfaceElement
90 virtual bool parse (xmlNodePtr cur
, CInterfaceGroup
*parentGroup
);
91 virtual void updateCoords();
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)
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
; }
111 class CInterface3DShape
*_ArrowShape
;
112 CCompassTarget _Target
;
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
;
127 double _StartBlinkTime
;
128 std::string _CurrTargetName
;
131 CViewText
*_DistView
;
132 std::string _DistViewText
;
134 CViewRadar
*_RadarView
;
135 CViewText
*_RadarRangeView
;
138 NLMISC::CVector2f
getNorthPos(const NLMISC::CVector2f
&userPos
) const;
140 class CDBUseCameraObs
: public NLMISC::ICDBNode::IPropertyObserver
143 CDBUseCameraObs():_useCamera(false),_changed(false)
145 virtual void update( NLMISC::ICDBNode
*node
);
149 CDBUseCameraObs _UseCameraObs
;
154 * \author Cyril 'Hulud' Corvazier
155 * \author Nevrax France
158 class CGroupCompasMenu
: public CGroupMenu
163 CGroupCompasMenu(const TCtorParam
¶m
);
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
185 class CCompassDialogsManager
188 /// entry in the dialog
189 struct CCompassDialogsEntry
191 CCompassDialogsEntry(sint32 x
,sint32 y
, uint32 text
)
192 :X(x
), Y(y
), Text(text
){}
198 static CCompassDialogsManager
& getInstance()
200 if ( _Instance
== NULL
)
201 _Instance
= new CCompassDialogsManager
;
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
);
216 friend class CCompassDialogsStringCallback
;
218 CCompassDialogsManager(){}
219 ~CCompassDialogsManager(){}
221 static CCompassDialogsManager
* _Instance
;
222 std::vector
<CCompassDialogsEntry
> _Entries
;
225 #endif // CL_GROUP_COMPAS_HELP_H