Resolve "Toggle Free Look with Hotkey"
[ryzomcore.git] / ryzom / client / src / interfaces_manager / brick_control.cpp
blobf13d8a9e38e053d53542bb123cefa0942a39875f
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/>.
19 #include "stdpch.h"
21 // Client
22 #include "brick_control.h"
23 #include "interfaces_manager.h"
24 #include "time_client.h"
25 // 3D Interface.
26 #include "nel/3d/u_text_context.h"
30 ////////////////
31 // Namespaces //
32 ////////////////
33 using namespace NL3D;
36 /////////////
37 // Externs //
38 /////////////
39 extern UTextContext *TextContext;
40 extern sint64 T1; // Time for the current frame.
43 //-----------------------------------------------
44 // constructor :
45 //-----------------------------------------------
46 CBrickControl::CBrickControl(uint id)
48 init();
49 } // constructor //
53 //-----------------------------------------------
54 // copy constructor :
55 //-----------------------------------------------
56 CBrickControl::CBrickControl( const CBrickControl &b)
58 _AssociatedBrick = b._AssociatedBrick;
59 _RGBA = b._RGBA;
60 _NumFuncOn = b._NumFuncOn;
62 /// TO DO !!!
63 } // copy constructor //
67 //-----------------------------------------------
68 // constructor :
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);
74 } // constructor //
76 //-----------------------------------------------
77 // constructor :
78 //-----------------------------------------------
79 void CBrickControl::init(uint numFuncOn, uint numFuncR)
81 _AssociatedBrick = NULL;
82 _RGBA = CRGBA(255,255,255,255);
83 _NumFuncOn = numFuncOn;
84 _NumFuncR = numFuncR;
85 } // constructor //
89 //-----------------------------------------------
90 // display :
91 //-----------------------------------------------
92 void CBrickControl::display()
93 { // If the control is hide -> return
94 if(!_Show)
95 return;
97 if (_AssociatedBrick == NULL)
98 return;
100 if (_AssociatedBrick->getTexture() == NULL)
102 Driver->drawQuad(_X_Display, _Y_Display, _W_Display, _H_Display, _RGBA);
104 else
106 // Draw the Bitmap.
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));
113 else
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) );
125 else
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) );
134 } // display //
138 //-----------------------------------------------
139 // click :
140 // manage left mouse button click
141 //-----------------------------------------------
142 void CBrickControl::click(float x, float y, bool &taken)
144 if(!taken)
146 // test click ccordinates
147 if(x>=_X_Display && x<=(_X_Display+_W_Display) && y>=_Y_Display && y<=(_Y_Display+_H_Display))
149 if (_NumFuncOn != 0)
151 CInterfMngr::runFuncCtrl(_NumFuncOn, id(), this);
152 taken = true;
156 }// click //
159 //-----------------------------------------------
160 // clickRight :
161 // manage right mouse button click
162 //-----------------------------------------------
163 void CBrickControl::clickRight(float x, float y, bool &taken)
165 if(!taken)
167 // test click ccordinates
168 if( x>=_X_Display && x<=(_X_Display+_W_Display) && y>=_Y_Display && y<=(_Y_Display+_H_Display) )
170 if (_NumFuncR != 0)
172 CInterfMngr::runFuncCtrl(_NumFuncR, id(), this);
173 taken = true;
177 }// clickRight //