1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
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.
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/>.
25 #include "nel/3d/u_driver.h"
26 #include "nel/3d/u_text_context.h"
28 #include "client_cfg.h"
29 #include "chat_input.h"
30 #include "chat_control.h"
31 #include "interfaces_manager.h"
33 #include "nel/misc/command.h"
38 using namespace NLMISC
;
46 extern UDriver
*Driver
;
49 //-----------------------------------------------
52 //-----------------------------------------------
53 CChatInput::CChatInput(uint id
)
59 //-----------------------------------------------
62 //-----------------------------------------------
63 CChatInput::CChatInput(uint id
, float x
, float y
, float x_pixel
, float y_pixel
, float w
, float h
, float w_pixel
, float h_pixel
, uint numFunc
, const CPen
&pen
)
64 : CCapture(id
, x
, y
, x_pixel
, y_pixel
, w
, h
, w_pixel
, h_pixel
, numFunc
, pen
)
69 //-----------------------------------------------
72 //-----------------------------------------------
73 CChatInput::CChatInput(uint id
, float x
, float y
, float x_pixel
, float y_pixel
, float w
, float h
, float w_pixel
, float h_pixel
, uint numFunc
, uint32 fontSize
, CRGBA color
, bool shadow
)
74 : CCapture(id
, x
, y
, x_pixel
, y_pixel
, w
, h
, w_pixel
, h_pixel
, numFunc
, fontSize
, color
, shadow
)
79 //-----------------------------------------------
82 //-----------------------------------------------
83 CChatInput::~CChatInput()
85 // Remove the listener.
86 Driver
->EventServer
.removeListener(EventCharId
, this);
89 //-----------------------------------------------
91 // Initialize the button (1 function called for all constructors -> easier).
92 //-----------------------------------------------
93 void CChatInput::init()
99 //---------------------------------------------------
101 // Function that receives events.
102 //---------------------------------------------------
103 void CChatInput::operator()(const CEvent
& event
)
105 CEventChar
&ec
= (CEventChar
&)event
;
108 // RETURN : Send the chat message
122 _Str
.erase( _Str
.end()-1 );
131 if(!_Str
.empty() && _Str
[0] == '/')
133 string command
= _Str
.toString().substr(1);
134 ICommand::expand(command
);
135 _Str
= '/' + command
;
152 if(_Str
.size() < _MaxChar
)
159 //---------------------------------------------------
161 //---------------------------------------------------
162 void CChatInput::execute()
165 CInterfMngr::runFuncCtrl(_NumFunc
, id());