Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / client / src / interface_v3 / chat_displayer.h
blobb42ff339a780529cdcdb7115d41bef0987fd9f44
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) 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/>.
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"
32 /**
33 * class used to display console text commands in the chat window
34 * \author Nicolas Brigand
35 * \author Nevrax France
36 * \date 2002
38 class CChatDisplayer : public NLMISC::IDisplayer
40 public:
42 struct SDispString
44 std::string Str;
45 CInterfaceManager::TSystemInfoMode Mode;
48 // To make it thread safe
49 NLMISC::CSynchronized< std::vector<SDispString> > StringToDisplay;
51 /// Constructor
52 CChatDisplayer() :
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;
62 std::string str;
63 CInterfaceManager::TSystemInfoMode mode;
64 if (args.LogType == NLMISC::CLog::LOG_ERROR)
66 str = "ERR: ";
67 mode = CInterfaceManager::ErrorMsg;
69 else if (args.LogType == NLMISC::CLog::LOG_WARNING)
71 str = "WRN: ";
72 mode = CInterfaceManager::WarningMsg;
74 else
76 str.clear();
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
86 SDispString toAdd;
87 toAdd.Str = str;
88 toAdd.Mode = mode;
89 acces.value ().push_back(toAdd);
90 } // end of the access
94 // Called each frames
95 void update ()
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);
103 rVal.clear();
108 #endif // NL_CHAT_DISPLAYER_H
110 /* End of chat_displayer.h */