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/>.
22 #include "brick_control.h"
23 #include "interfaces_manager.h"
24 #include "time_client.h"
26 #include "nel/3d/u_text_context.h"
39 extern UTextContext
*TextContext
;
40 extern sint64 T1
; // Time for the current frame.
43 //-----------------------------------------------
45 //-----------------------------------------------
46 CBrickControl::CBrickControl(uint id
)
53 //-----------------------------------------------
55 //-----------------------------------------------
56 CBrickControl::CBrickControl( const CBrickControl &b)
58 _AssociatedBrick = b._AssociatedBrick;
60 _NumFuncOn = b._NumFuncOn;
63 } // copy constructor //
67 //-----------------------------------------------
69 //-----------------------------------------------
70 CBrickControl::CBrickControl(uint id
, float x
, float y
, float x_pixel
, float y_pixel
, float w
, float h
, float w_pixel
, float h_pixel
, uint numFuncOn
, uint numFuncR
)
71 :CControl( id
, x
, y
, x_pixel
, y_pixel
, w
, h
, w_pixel
, h_pixel
)
73 init(numFuncOn
, numFuncR
);
76 //-----------------------------------------------
78 //-----------------------------------------------
79 void CBrickControl::init(uint numFuncOn
, uint numFuncR
)
81 _AssociatedBrick
= NULL
;
82 _RGBA
= CRGBA(255,255,255,255);
83 _NumFuncOn
= numFuncOn
;
89 //-----------------------------------------------
91 //-----------------------------------------------
92 void CBrickControl::display()
93 { // If the control is hide -> return
97 if (_AssociatedBrick
== NULL
)
100 if (_AssociatedBrick
->getTexture() == NULL
)
102 Driver
->drawQuad(_X_Display
, _Y_Display
, _W_Display
, _H_Display
, _RGBA
);
108 //if brick is latent, grey the bitmap
109 if ( _AssociatedBrick
->LatencyEndDate
> T1
)
111 Driver
->drawBitmap(_X_Display
, _Y_Display
, _W_Display
, _H_Display
, *CInterfMngr::getTexture(_AssociatedBrick
->getTexture()), true, CRGBA(128,128,128,255));
115 Driver
->drawBitmap(_X_Display
, _Y_Display
, _W_Display
, _H_Display
, *CInterfMngr::getTexture(_AssociatedBrick
->getTexture()), true, _RGBA
);
119 // write the Text of the brick on the lower right corner of the bitmap
120 TextContext
->setShaded( false );
121 if ( _AssociatedBrick
->LatencyEndDate
> T1
)
123 TextContext
->setColor( CRGBA(128,128,128,255) );
127 TextContext
->setColor( CRGBA(255,255,255,255) );
130 TextContext
->setFontSize( 12 );
131 TextContext
->setHotSpot(UTextContext::BottomRight
);
132 TextContext
->printAt( _X_Display
+ _W_Display
, _Y_Display
, ucstring(_AssociatedBrick
->Text
) );
133 // TextContext->printAt( _X_Display + _W_Display/2, _Y_Display + _H_Display/2, ucstring(_AssociatedBrick->Text) );
138 //-----------------------------------------------
140 // manage left mouse button click
141 //-----------------------------------------------
142 void CBrickControl::click(float x
, float y
, bool &taken
)
146 // test click ccordinates
147 if(x
>=_X_Display
&& x
<=(_X_Display
+_W_Display
) && y
>=_Y_Display
&& y
<=(_Y_Display
+_H_Display
))
151 CInterfMngr::runFuncCtrl(_NumFuncOn
, id(), this);
159 //-----------------------------------------------
161 // manage right mouse button click
162 //-----------------------------------------------
163 void CBrickControl::clickRight(float x
, float y
, bool &taken
)
167 // test click ccordinates
168 if( x
>=_X_Display
&& x
<=(_X_Display
+_W_Display
) && y
>=_Y_Display
&& y
<=(_Y_Display
+_H_Display
) )
172 CInterfMngr::runFuncCtrl(_NumFuncR
, id(), this);