Fix css style order when using external css files
[ryzomcore.git] / ryzom / client / src / interface_v3 / people_interraction.h
blob8181c1705fcdf8c59c468576eae436026cd947b3
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef CL_PEOPLE_INTERRACTION_H
18 #define CL_PEOPLE_INTERRACTION_H
20 #include "people_list.h"
21 #include "chat_filter.h"
23 #include "nel/misc/smart_ptr.h"
26 class CChatWindow;
27 class CFilteredChatSummary;
28 class CFilteredDynChatSummary;
30 // ***************************************************************************
31 #define TEAM_DB_PATH "SERVER:GROUP"
34 // ***************************************************************************
35 // max number of people in the team
36 const uint MaxNumPeopleInTeam = 8;
38 // max number of user chats
39 const uint MaxNumUserChats = 5;
42 // ***************************************************************************
43 /** Infos about a party chat
45 struct CPartyChatInfo
47 uint32 ID;
48 CChatWindow *Window;
49 NLMISC::CSmartPtr<CChatInputFilter> Filter;
53 // ***************************************************************************
54 // a chat filter and the associated window
55 class CFilteredChat
57 public:
58 CChatWindow *Window;
59 CChatTargetFilter Filter;
60 public:
61 CFilteredChat() : Window(NULL) {}
62 ~CFilteredChat()
64 if (Window)
66 nlwarning("window not released");
69 void release()
71 if (Window)
73 CChatWindowManager &cwm = getChatWndMgr();
74 cwm.removeChatWindow(Window);
75 Window = NULL;
81 // ***************************************************************************
82 /** Standard inputs for the chat
84 class CChatStdInput
86 public:
87 CChatInputFilter AroundMe;
88 CChatInputFilter Region;
89 CChatInputFilter Team;
90 CChatInputFilter Guild;
91 CChatInputFilter SystemInfo;
92 CChatInputFilter Universe;
94 CChatInputFilter Tell;
96 CChatInputFilter DebugInfo;
98 // Dynamic Chat. A fixed number of chat that can be assign
99 CChatInputFilter DynamicChat[CChatGroup::MaxDynChanPerPlayer];
101 public:
102 void registerListeningWindow(CChatWindow *cw);
104 CChatStdInput()
106 AroundMe.FilterType = CChatGroup::arround;
107 Region.FilterType = CChatGroup::region;
108 Team.FilterType = CChatGroup::team;
109 Guild.FilterType = CChatGroup::guild;
110 SystemInfo.FilterType = CChatGroup::system;
111 Tell.FilterType = CChatGroup::tell;
112 Universe.FilterType = CChatGroup::universe;
113 for(uint i=0;i<CChatGroup::MaxDynChanPerPlayer;i++)
115 DynamicChat[i].FilterType= CChatGroup::dyn_chat;
116 DynamicChat[i].DynamicChatDbIndex= i;
124 // ***************************************************************************
125 /** Class that manages interractions with other people.
127 class CPeopleInterraction
129 public:
130 // the various people lists
131 CPeopleList TeamList;
132 CPeopleList FriendList; // in contact_list
133 CPeopleList IgnoreList; // in contact_list
134 // Shortcut to chat windows (also available in the chat window manager
135 CChatWindow *Region;
136 CChatWindow *Universe;
137 CChatWindow *TeamChat;
138 CChatWindow *GuildChat;
139 CChatWindow *SystemInfo;
140 CChatWindow *TellWindow;
141 CChatWindow *DebugInfo;
142 // Special dynamic chat
143 CChatWindow *DynamicChat[CChatGroup::MaxDynChanPerPlayer];
145 // List of all created party chat
146 std::vector<CPartyChatInfo> PartyChats;
147 uint32 CurrPartyChatID;
149 CChatStdInput ChatInput;
151 //CFilteredChat MainChat;
152 CFilteredChat ChatGroup;
153 CFilteredChat AroundMe;
154 CFilteredChat DebugConsole;
155 // additionnal user chats
156 CFilteredChat UserChat[MaxNumUserChats];
157 CFilteredChat TheUserChat;
158 // Id of last people who talked
159 std::string LastSenderName;
161 // system message
162 struct CSysMsg
164 std::string Str;
165 std::string Cat;
167 // system message buffer
168 std::vector<CSysMsg> SystemMessageBuffer;
170 public:
171 // ctor
172 CPeopleInterraction();
174 void init(); // init the people lists, create basic chats
176 void initAfterLoad(); // must call after load time to reset prompt color, default channel etc...
178 void release(); // removes every people list & chat windows
180 /** from a group container ID, returns a pointer on the people list and a people index
181 * \return false is the id was invalid
183 bool getPeopleFromContainerID(const std::string &id, CPeopleList *&peopleList, uint &index);
184 /** Get the people list & index that triggered the current menu.
186 bool getPeopleFromCurrentMenu(CPeopleList *&peopleList, uint &index);
187 /** Get the people list that triggered the current menu
189 CPeopleList *getPeopleListFromCurrentMenu();
190 /** Get a people list from its container id
192 CPeopleList *getPeopleListFromContainerID(const std::string &id);
194 /** From a window, get the associated filtered chat (or NULL if none)
196 CFilteredChat *getFilteredChatFromChatWindow(CChatWindow *cw);
198 bool testValidPartyChatName(const std::string &name);
199 bool removePartyChat(CChatWindow *window);
200 void removeAllPartyChat();
202 * create a named party chat.
204 bool createNewPartyChat(const std::string &title);
206 static void assignPartyChatMenu(CChatWindow *partyChat);
208 /// \name CONTACT LIST
209 // @{
210 // ask the server to add/move/remove a contact
211 void askAddContact(const std::string &contactName, CPeopleList *pl);
212 void askMoveContact(uint peopleIndexInSrc, CPeopleList *plSRC, CPeopleList *plDST);
213 void askRemoveContact(uint peopleIndex, CPeopleList *pl);
215 // init contact list (from server typically)
216 void initContactLists( const std::vector<uint32> &vFriendListName,
217 const std::vector<TCharConnectionState> &vFriendListOnline,
218 const std::vector<ucstring> &vIgnoreListName ); // TODO: UTF-8 (serial)
219 // Friend list == 0 // Ignore list == 1
220 void addContactInList(uint32 contactId, uint32 nameID, TCharConnectionState Online, uint8 nList);
221 void addContactInList(uint32 contactId, const std::string &name, TCharConnectionState Online, uint8 nList);
222 bool isContactInList(const std::string &name, uint8 nList) const;
223 // Called each frame to receive name from IOS
224 void updateWaitingContacts();
225 // server decide to remove a contact (if it does not exists anymore)
226 void removeContactFromList(uint32 contactId, uint8 nList);
227 // server update the online status
228 void updateContactInList(uint32 contactId, TCharConnectionState online, uint nList);
229 // @}
231 // save info about user chats
232 bool saveUserChatsInfos(NLMISC::IStream &f);
233 // restore infos about user chats
234 bool loadUserChatsInfos(NLMISC::IStream &f);
236 // save info about user dyn chats
237 bool saveUserDynChatsInfos(NLMISC::IStream &f);
238 // restore info about user dyn chats
239 bool loadUserDynChatsInfos(NLMISC::IStream &f);
241 // remove all the user chats
242 void removeAllUserChats();
244 // refrech the 'active' state of user chats : useful when a virtual desktop change occurs
245 void refreshActiveUserChats();
247 // Create a user chat at the given index. The target user chat must be empty
248 void createUserChat(uint index);
250 // Test if the given chat is a user chat (this includes the main chat)
251 bool isUserChat(CChatWindow *cw) const;
253 void talkInDynamicChannel(uint32 channelNb,std::string sentence);
255 CChatGroupWindow *getChatGroupWindow() const;
257 void updateAllFreeTellerHeaders();
258 void removeAllFreeTellers();
260 static void displayTellInMainChat(const std::string &playerName);
261 private:
262 // create various chat & people lists
263 void createTeamChat();
264 void createTeamList();
265 void createFriendList();
266 void createIgnoreList();
268 void createSystemInfo();
269 void createAroundMeWindow();
270 void createRegionWindow();
271 void createUniverseWindow();
272 void createTellWindow();
273 void createGuildChat();
274 void createDebugInfo();
275 void createChatGroup(); // Create chat group containing all other chat
276 void createTheUserChat();
277 void createDynamicChats();
279 void initStdInputs();
281 // build summary about a filtered chat
282 void buildFilteredChatSummary(const CFilteredChat &src, CFilteredChatSummary &dest);
283 void buildFilteredDynChatSummary(const CFilteredChat &src, CFilteredDynChatSummary &dest);
284 void saveFilteredChat(NLMISC::IStream &f, const CFilteredChat &src);
285 void saveFilteredDynChat(NLMISC::IStream &f, const CFilteredChat &src);
286 // setup a user chat from its summary
287 void setupUserChatFromSummary(const CFilteredChatSummary &summary, CFilteredChat &dest);
288 void setupUserDynChatFromSummary(const CFilteredDynChatSummary &summary, CFilteredChat &dest);
289 private:
290 // Contact waiting their name (received by string_manager) to be added
291 struct SWaitingContact
293 uint32 ContactId;
294 uint32 NameId;
295 uint8 List;
296 TCharConnectionState Online;
298 std::vector<SWaitingContact> WaitingContacts;
301 // instance of class that manage people lists
302 extern CPeopleInterraction PeopleInterraction;
304 #endif