Merge branch '138-toggle-free-look-with-hotkey' into main/gingo-test
[ryzomcore.git] / ryzom / client / src / interface_v3 / people_interraction.h
bloba5130e07a5ad3ff64cda9779c389b424015da268
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2020 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef CL_PEOPLE_INTERRACTION_H
21 #define CL_PEOPLE_INTERRACTION_H
23 #include "people_list.h"
24 #include "chat_filter.h"
26 #include "nel/misc/smart_ptr.h"
29 class CChatWindow;
30 class CFilteredChatSummary;
31 class CFilteredDynChatSummary;
33 // ***************************************************************************
34 #define TEAM_DB_PATH "SERVER:GROUP"
37 // ***************************************************************************
38 // max number of people in the team
39 const uint MaxNumPeopleInTeam = 8;
41 // max number of user chats
42 const uint MaxNumUserChats = 5;
45 // ***************************************************************************
46 /** Infos about a party chat
48 struct CPartyChatInfo
50 uint32 ID;
51 CChatWindow *Window;
52 NLMISC::CSmartPtr<CChatInputFilter> Filter;
56 // ***************************************************************************
57 // a chat filter and the associated window
58 class CFilteredChat
60 public:
61 CChatWindow *Window;
62 CChatTargetFilter Filter;
63 public:
64 CFilteredChat() : Window(NULL) {}
65 ~CFilteredChat()
67 if (Window)
69 nlwarning("window not released");
72 void release()
74 if (Window)
76 CChatWindowManager &cwm = getChatWndMgr();
77 cwm.removeChatWindow(Window);
78 Window = NULL;
84 // ***************************************************************************
85 /** Standard inputs for the chat
87 class CChatStdInput
89 public:
90 CChatInputFilter AroundMe;
91 CChatInputFilter Region;
92 CChatInputFilter Team;
93 CChatInputFilter Guild;
94 CChatInputFilter SystemInfo;
95 CChatInputFilter Universe;
97 CChatInputFilter Tell;
99 CChatInputFilter DebugInfo;
101 // Dynamic Chat. A fixed number of chat that can be assign
102 CChatInputFilter DynamicChat[CChatGroup::MaxDynChanPerPlayer];
104 public:
105 void registerListeningWindow(CChatWindow *cw);
107 CChatStdInput()
109 AroundMe.FilterType = CChatGroup::arround;
110 Region.FilterType = CChatGroup::region;
111 Team.FilterType = CChatGroup::team;
112 Guild.FilterType = CChatGroup::guild;
113 SystemInfo.FilterType = CChatGroup::system;
114 Tell.FilterType = CChatGroup::tell;
115 Universe.FilterType = CChatGroup::universe;
116 for(uint i=0;i<CChatGroup::MaxDynChanPerPlayer;i++)
118 DynamicChat[i].FilterType= CChatGroup::dyn_chat;
119 DynamicChat[i].DynamicChatDbIndex= i;
127 // ***************************************************************************
128 /** Class that manages interractions with other people.
130 class CPeopleInterraction
132 public:
133 // the various people lists
134 CPeopleList TeamList;
135 CPeopleList FriendList; // in contact_list
136 CPeopleList IgnoreList; // in contact_list
137 // Shortcut to chat windows (also available in the chat window manager
138 CChatWindow *Region;
139 CChatWindow *Universe;
140 CChatWindow *TeamChat;
141 CChatWindow *GuildChat;
142 CChatWindow *SystemInfo;
143 CChatWindow *TellWindow;
144 CChatWindow *DebugInfo;
145 // Special dynamic chat
146 CChatWindow *DynamicChat[CChatGroup::MaxDynChanPerPlayer];
148 // List of all created party chat
149 std::vector<CPartyChatInfo> PartyChats;
150 uint32 CurrPartyChatID;
152 CChatStdInput ChatInput;
154 //CFilteredChat MainChat;
155 CFilteredChat ChatGroup;
156 CFilteredChat AroundMe;
157 CFilteredChat DebugConsole;
158 // additionnal user chats
159 CFilteredChat UserChat[MaxNumUserChats];
160 CFilteredChat TheUserChat;
161 // Id of last people who talked
162 std::string LastSenderName;
164 // system message
165 struct CSysMsg
167 std::string Str;
168 std::string Cat;
170 // system message buffer
171 std::vector<CSysMsg> SystemMessageBuffer;
173 public:
174 // ctor
175 CPeopleInterraction();
177 void init(); // init the people lists, create basic chats
179 void initAfterLoad(); // must call after load time to reset prompt color, default channel etc...
181 void release(); // removes every people list & chat windows
183 /** from a group container ID, returns a pointer on the people list and a people index
184 * \return false is the id was invalid
186 bool getPeopleFromContainerID(const std::string &id, CPeopleList *&peopleList, uint &index);
187 /** Get the people list & index that triggered the current menu.
189 bool getPeopleFromCurrentMenu(CPeopleList *&peopleList, uint &index);
190 /** Get the people list that triggered the current menu
192 CPeopleList *getPeopleListFromCurrentMenu();
193 /** Get a people list from its container id
195 CPeopleList *getPeopleListFromContainerID(const std::string &id);
197 /** From a window, get the associated filtered chat (or NULL if none)
199 CFilteredChat *getFilteredChatFromChatWindow(CChatWindow *cw);
201 bool testValidPartyChatName(const std::string &name);
202 bool removePartyChat(CChatWindow *window);
203 void removeAllPartyChat();
205 * create a named party chat.
207 bool createNewPartyChat(const std::string &title);
209 static void assignPartyChatMenu(CChatWindow *partyChat);
211 /// \name CONTACT LIST
212 // @{
213 // ask the server to add/move/remove a contact
214 void askAddContact(const std::string &contactName, CPeopleList *pl);
215 void askMoveContact(uint peopleIndexInSrc, CPeopleList *plSRC, CPeopleList *plDST);
216 void askRemoveContact(uint peopleIndex, CPeopleList *pl);
218 // init contact list (from server typically)
219 void initContactLists( const std::vector<uint32> &vFriendListName,
220 const std::vector<TCharConnectionState> &vFriendListOnline,
221 const std::vector<ucstring> &vIgnoreListName ); // TODO: UTF-8 (serial)
222 // Friend list == 0 // Ignore list == 1
223 void addContactInList(uint32 contactId, uint32 nameID, TCharConnectionState Online, uint8 nList);
224 void addContactInList(uint32 contactId, const std::string &name, TCharConnectionState Online, uint8 nList);
225 bool isContactInList(const std::string &name, uint8 nList) const;
226 bool isContactOnline(const std::string &nameIn) const;
227 // Called each frame to receive name from IOS
228 void updateWaitingContacts();
229 // server decide to remove a contact (if it does not exists anymore)
230 void removeContactFromList(uint32 contactId, uint8 nList);
231 // server update the online status
232 void updateContactInList(uint32 contactId, TCharConnectionState online, uint nList);
233 // @}
235 // save info about user chats
236 bool saveUserChatsInfos(NLMISC::IStream &f);
237 // restore infos about user chats
238 bool loadUserChatsInfos(NLMISC::IStream &f);
240 // save info about user dyn chats
241 bool saveUserDynChatsInfos(NLMISC::IStream &f);
242 // restore info about user dyn chats
243 bool loadUserDynChatsInfos(NLMISC::IStream &f);
245 // remove all the user chats
246 void removeAllUserChats();
248 // refrech the 'active' state of user chats : useful when a virtual desktop change occurs
249 void refreshActiveUserChats();
251 // Create a user chat at the given index. The target user chat must be empty
252 void createUserChat(uint index);
254 // Test if the given chat is a user chat (this includes the main chat)
255 bool isUserChat(CChatWindow *cw) const;
257 void talkInDynamicChannel(uint32 channelNb,std::string sentence);
259 CChatGroupWindow *getChatGroupWindow() const;
261 void updateAllFreeTellerHeaders();
262 void removeAllFreeTellers();
264 static void displayTellInMainChat(const std::string &playerName);
265 private:
266 // create various chat & people lists
267 void createTeamChat();
268 void createTeamList();
269 void createFriendList();
270 void createIgnoreList();
272 void createSystemInfo();
273 void createAroundMeWindow();
274 void createRegionWindow();
275 void createUniverseWindow();
276 void createTellWindow();
277 void createGuildChat();
278 void createDebugInfo();
279 void createChatGroup(); // Create chat group containing all other chat
280 void createTheUserChat();
281 void createDynamicChats();
283 void initStdInputs();
285 // build summary about a filtered chat
286 void buildFilteredChatSummary(const CFilteredChat &src, CFilteredChatSummary &dest);
287 void buildFilteredDynChatSummary(const CFilteredChat &src, CFilteredDynChatSummary &dest);
288 void saveFilteredChat(NLMISC::IStream &f, const CFilteredChat &src);
289 void saveFilteredDynChat(NLMISC::IStream &f, const CFilteredChat &src);
290 // setup a user chat from its summary
291 void setupUserChatFromSummary(const CFilteredChatSummary &summary, CFilteredChat &dest);
292 void setupUserDynChatFromSummary(const CFilteredDynChatSummary &summary, CFilteredChat &dest);
293 private:
294 // Contact waiting their name (received by string_manager) to be added
295 struct SWaitingContact
297 uint32 ContactId;
298 uint32 NameId;
299 uint8 List;
300 TCharConnectionState Online;
302 std::vector<SWaitingContact> WaitingContacts;
305 // instance of class that manage people lists
306 extern CPeopleInterraction PeopleInterraction;
308 #endif