1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 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/>.
23 #ifndef NL_CHAT_DISPLAYER_H
24 #define NL_CHAT_DISPLAYER_H
26 #include "nel/misc/displayer.h"
27 #include "nel/gui/group_list.h"
28 #include "interface_manager.h"
30 #include "nel/misc/mutex.h"
33 * class used to display console text commands in the chat window
34 * \author Nicolas Brigand
35 * \author Nevrax France
38 class CChatDisplayer
: public NLMISC::IDisplayer
45 CInterfaceManager::TSystemInfoMode Mode
;
48 // To make it thread safe
49 NLMISC::CSynchronized
< std::vector
<SDispString
> > StringToDisplay
;
53 IDisplayer( "ChatDisplayer" ),
54 StringToDisplay("StringToDisplay")
58 /// Display the string to the chat window
59 virtual void doDisplay ( const NLMISC::CLog::TDisplayInfo
& args
, const char *message
)
61 std::string temp
= message
;
63 CInterfaceManager::TSystemInfoMode mode
;
64 if (args
.LogType
== NLMISC::CLog::LOG_ERROR
)
67 mode
= CInterfaceManager::ErrorMsg
;
69 else if (args
.LogType
== NLMISC::CLog::LOG_WARNING
)
72 mode
= CInterfaceManager::WarningMsg
;
77 mode
= CInterfaceManager::InfoMsg
;
80 str
+= temp
.substr(0, temp
.size()-1);
82 { // create a new scope for the access
83 // get an access to the value
84 NLMISC::CSynchronized
<std::vector
<SDispString
> >::CAccessor
acces(&StringToDisplay
);
85 // now, you have a thread safe access until the end of the scope, so you can do whatever you want. for example, change the value
89 acces
.value ().push_back(toAdd
);
90 } // end of the access
97 NLMISC::CSynchronized
<std::vector
<SDispString
> >::CAccessor
acces(&StringToDisplay
);
98 std::vector
<SDispString
> &rVal
= acces
.value ();
99 for (uint i
= 0; i
< rVal
.size(); ++i
)
101 CInterfaceManager::getInstance()->displayDebugInfo(rVal
[i
].Str
, rVal
[i
].Mode
);
108 #endif // NL_CHAT_DISPLAYER_H
110 /* End of chat_displayer.h */