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/>.
26 #include "nel/misc/path.h"
28 #include "nel/3d/u_driver.h"
34 #include "radio_button.h"
35 #include "radio_controller.h"
37 #include "interfaces_manager.h"
38 #include "interf_list.h"
39 #include "multi_list.h"
40 #include "interf_script.h"
41 #include "chat_control.h"
42 #include "chat_input.h"
43 #include "choice_list.h"
44 #include "candidate_list.h"
45 #include "horizontal_list.h"
46 #include "control_list.h"
47 #include "spell_list.h"
48 #include "progress_bar.h"
49 #include "casting_bar.h"
50 #include "brick_control.h"
58 using namespace NLMISC
;
66 extern UDriver
*Driver
;
67 extern UTextContext
*TextContext
;
70 static std::list
< uint16
> elts
;
76 // Macro pour toute la partie commune de lecture des scripts pour les controls.
77 #define CONTROL_SCRIPT_MACRO(UserScript) \
79 CControl::THotSpot hs = CControl::HS_MM; \
80 CControl::THotSpot origin = CControl::HS_MM;\
92 char delimiter[] = "[] \t"; \
93 char *ptr = strtok(NULL, delimiter); \
96 if(strcmp(ptr, "HotSpot:") == 0) \
98 else if(strcmp(ptr, "Origin:") == 0) \
99 origin = getHotSpot(); \
100 else if(strcmp(ptr, "Parent:") == 0) \
101 idParent = getInt(); \
102 else if(strcmp(ptr, "X:") == 0) \
104 else if(strcmp(ptr, "Y:") == 0) \
106 else if(strcmp(ptr, "X_Pixel:") == 0) \
107 xPixel = getFloat(); \
108 else if(strcmp(ptr, "Y_Pixel:") == 0) \
109 yPixel = getFloat(); \
110 else if(strcmp(ptr, "W:") == 0) \
112 else if(strcmp(ptr, "H:") == 0) \
114 else if(strcmp(ptr, "W_Pixel:") == 0) \
115 wPixel = getFloat(); \
116 else if(strcmp(ptr, "H_Pixel:") == 0) \
117 hPixel = getFloat(); \
121 ptr = strtok(NULL, delimiter); \
127 //-----------------------------------------------
130 //-----------------------------------------------
131 COSD::COSD(bool popUp
)
133 // Common init for all constructors.
134 init(0, 0.f
, 0.f
, 0.f
, 0.f
, 1.f
, 1.f
, 0.f
, 0.f
, 0.0f
, 0.0f
, popUp
);
137 //-----------------------------------------------
140 //-----------------------------------------------
141 COSD::COSD(uint id
, float x
, float y
, float x_pixel
, float y_pixel
, float w
, float h
, float w_pixel
, float h_pixel
, float minWidth
, float minHeight
, bool popUp
)
143 // Common init for all constructors.
144 init(id
, x
, y
, x_pixel
, y_pixel
, w
, h
, w_pixel
, h_pixel
, minWidth
, minHeight
, popUp
);
148 //-----------------------------------------------
150 // Initialize the OSD (1 function called for all constructors -> easier).
151 //-----------------------------------------------
152 void COSD::init(uint id
, float x
, float y
, float x_pixel
, float y_pixel
, float w
, float h
, float w_pixel
, float h_pixel
, float minWidth
, float minHeight
, bool popUp
)
157 // pop up are never resizable
159 _OSD_Mode
= TMode::locked
;
161 // Default is OSD visible.
164 _W_Min
= minWidth
; // minimal width of the OSD
165 _H_Min
= minHeight
; // minimal height of the OSD
167 _X
= x
; // Position X of the OSD (between 0-1).
168 _Y
= y
; // Position Y of the OSD (between 0-1).
169 _X_Pixel
= x_pixel
; // Position X of the OSD (in Pixel).
170 _Y_Pixel
= y_pixel
; // Position Y of the OSD (in Pixel).
172 _W
= w
; // Width of the OSD (between 0-1).
173 _H
= h
; // Height of the OSD (between 0-1).
174 _W_Pixel
= w_pixel
; // Width of the OSD (in Pixel).
175 _H_Pixel
= h_pixel
; // Height of the OSD (in Pixel).
177 // How to display the OSD.
180 _OSD_Name
= ucstring("");
187 // Height of the move zone.
189 // Pen for the OSD Name.
190 _TB_Pen
= CPen(15, CRGBA(255,0,150,255), true);
192 // HighLight size in pixel.
196 _RS_Mode
= no_resize
;
197 // Color of the Move zone.
198 _RS_Color
= CRGBA(200,200,200,128);
199 // Width of the resize zone.
202 // NO update Function.
203 _OSD_Update_Func
= 0;
205 // Calculate others variables.
206 // calculateDisplay(); // done into the 'resize' method, called by the 'open' method
210 //-----------------------------------------------
213 //-----------------------------------------------
216 // Get all the controls and destroy them.
217 for(TMapControls::iterator it
= _Controls
.begin(); it
!= _Controls
.end(); it
++)
219 // Delete the control if still allocated.
220 if((*it
).second
!= NULL
)
222 delete ((*it
).second
);
227 // Clear all the control.
233 //-----------------------------------------------
236 //-----------------------------------------------
239 // Is the OSD is not visible -> return;
243 // Draw the background
246 // Backup scissor and change scissor to clip the list correctly.
247 CScissor oldScissor
= Driver
->getScissor();
249 scissor
.init(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
250 Driver
->setScissor(scissor
);
252 // Draw controls in the OSD.
253 for(TListControl::reverse_iterator it
= _Children
.rbegin(); it
!= _Children
.rend(); it
++)
257 Driver
->setScissor(oldScissor
);
259 // How to display the OSD.
265 drawBorders(_HL_W
, _HL_H
, _X_Display
, _Y_Display
, _X_Display
+_W_Display
, _Y_Display
+_H_Display
, _HL_Color
);
268 // OSD with a Border to resize.
271 drawBorders(_RS_W
, _RS_H
, _X_Display
, _Y_Display
, _X_Display
+_W_Display
, _Y_Display
+_H_Display
, _RS_Color
);
274 // OSD with a Border and an Area to move the OSD.
276 // Draw the Title Bar.
280 drawBorders(_RS_W
, _RS_H
, _X_Display
, _Y_Display
, _X_Display
+_W_Display
, _Y_Display
+_H_Display
, _RS_Color
);
281 // Draw the OSD Name -> if the text is not empty.
282 if(!_OSD_Name
.empty())
283 drawText(_X_Display
+_W_Display
/2, _Y_Display
+_H_Display
-_RS_H
-_TB_H_Display
/2, _OSD_Name
, _TB_Pen
);
289 //-----------------------------------------------
291 // Function to draw the background according to the mode.
292 //-----------------------------------------------
295 // Display the Background.
298 // Backgroung is only made by 1 color (RGBA).
300 Driver
->drawQuad(_X_Display
, _Y_Display
, _X_Display
+_W_Display
, _Y_Display
+_H_Display
, _BG_Color
);
303 // Background is stretch at the OSD size.
305 Driver
->drawBitmap(_X_Display
, _Y_Display
, _W_Display
, _H_Display
, *CInterfMngr::getTexture(_BG
), true, _BG_Color
);
314 //-----------------------------------------------
316 // Function to draw the Title Bar according to the mode.
317 //-----------------------------------------------
320 // Display Title Bar.
323 // Backgroung is only made by 1 color (RGBA).
325 Driver
->drawQuad(_X_Display
+_RS_W
, _Y_Display
+_H_Display
-_RS_H
-_TB_H_Display
, _X_Display
+_W_Display
-_RS_W
, _Y_Display
+_H_Display
-_RS_H
, _TB_Color
);
328 // Background is stretch at the OSD size.
330 Driver
->drawBitmap(_X_Display
+_RS_W
, _Y_Display
+_H_Display
-_RS_H
-_TB_H_Display
, _W_Display
-2*_RS_W
, _TB_H_Display
, *CInterfMngr::getTexture(_TB
), true, _TB_Color
);
340 //-----------------------------------------------
342 // Draw the resize borders.
343 //-----------------------------------------------
344 void COSD::drawBorders(float bSizeW
, float bSizeH
, float x0
, float y0
, float x1
, float y1
, const CRGBA
&color
)
346 Driver
->drawQuad(x0
, y0
, x0
+bSizeW
, y1
, color
);
347 Driver
->drawQuad(x1
-bSizeW
, y0
, x1
, y1
, color
);
348 Driver
->drawQuad(x0
, y0
, x1
, y0
+bSizeH
, color
);
349 Driver
->drawQuad(x0
, y1
-bSizeH
, x1
, y1
, color
);
352 //-----------------------------------------------
354 // Draw a text with all information needed.
355 //-----------------------------------------------
356 void COSD::drawText(float x
, float y
, const ucstring
&text
, const CPen
&pen
)
358 TextContext
->setHotSpot(UTextContext::MiddleMiddle
);
359 TextContext
->setColor(pen
.color());
360 TextContext
->setFontSize(pen
.fontSize());
361 TextContext
->setShaded(pen
.shadow());
362 TextContext
->printAt(x
, y
, text
);
366 //-----------------------------------------------
368 // The OSD size has changed -> resize controls.
369 //-----------------------------------------------
370 void COSD::resize(uint32 width
, uint32 height
)
372 // Update variables because of the resize.
375 // resize the other controls.
376 for(TMapControls::iterator it
= _Controls
.begin(); it
!= _Controls
.end(); it
++)
378 // If the control as a reference different than the OSD -> the Reference will resize this control.
379 if((*it
).second
->parent() == 0)
382 (*it
).second
->resize(width
, height
);
383 calculatePos(x
, y
, (*it
).second
->origin());
384 (*it
).second
->ref(x
, y
, _W_Display
, _H_Display
);
389 //-----------------------------------------------
391 // Update the OSD (for timer, etc.).
392 //-----------------------------------------------
393 bool COSD::update(float x
, float y
, bool fullUse
)
398 // Function called every frame.
399 CInterfMngr::runFuncCtrl(_OSD_Update_Func
, 0);
404 if(_RS_Mode
!= no_resize
)
406 // Get the window size.
408 CInterfMngr::getWindowSize(w
, h
);
410 // Resize correctly the OSD.
413 // Resize Bottom OSD Border.
416 // Resize -> resize cursor.
417 _Cursor
= Cur_Resize_B
;
419 // Resize Top OSD Border.
422 // Resize -> resize cursor.
423 _Cursor
= Cur_Resize_T
;
425 // Resize Left OSD Border.
428 // Resize -> resize cursor.
429 _Cursor
= Cur_Resize_L
;
431 // Resize Right OSD Border.
434 // Resize -> resize cursor.
435 _Cursor
= Cur_Resize_R
;
437 // Resize Bottom Left OSD Border.
441 // Resize -> resize cursor.
442 _Cursor
= Cur_Resize_BL
;
444 // Resize Top Left OSD Border.
448 // Resize -> resize cursor.
449 _Cursor
= Cur_Resize_TL
;
451 // Resize Bottom Right OSD Border.
455 // Resize -> resize cursor.
456 _Cursor
= Cur_Resize_BR
;
458 // Resize Top Right OSD Border.
462 // Resize -> resize cursor.
463 _Cursor
= Cur_Resize_TR
;
468 // Move -> move cursor.
477 // Give the new OSD size to controls.
478 for(TMapControls::iterator it
= _Controls
.begin(); it
!= _Controls
.end(); it
++)
480 if((*it
).second
->parent() == 0)
483 calculatePos(x
, y
, (*it
).second
->origin());
484 (*it
).second
->ref(x
, y
, _W_Display
, _H_Display
);
495 // In Locked mode, the OSD mode can't change.
497 // OSD locked -> no cursor needed by the OSD.
501 // Else the OSD mode changes according to the mouse position.
503 // Check the cursor is inside the OSD.
504 if(x
>=_X_Display
&& x
<_X_Display
+_W_Display
&& y
>=_Y_Display
&& y
<_Y_Display
+_H_Display
)
506 // Change the cursor look according to its position.
507 // Get the window size.
509 CInterfMngr::getWindowSize(w
, h
);
511 float cornerSizeX
= _RS_W
+_TB_H
/(float)w
;
512 float cornerSizeY
= _RS_H
+_TB_H
/(float)h
;
535 // X POSITION in the OSD.
536 // X is in the right part of the OSD (move, resize right, or resize right corners)
537 if(x
>= _X_Display
+_W_Display
-cornerSizeX
)
539 // Resize right or right corners.
540 if(x
>= _X_Display
+_W_Display
-_RS_W
)
542 // Move or resize right corners.
546 // X is in the left part of the OSD (move, resize left, or resize left corners)
547 else if(x
< _X_Display
+cornerSizeX
)
549 // Resize left or left corners.
550 if(x
< _X_Display
+_RS_W
)
552 // Move or resize left corners.
556 // X is in the middle part of the OSD (move, resize top or bottom).
562 // Y POSITION in the OSD.
563 // Y is in the Top part of the OSD (move, resize top, or resize top corners)
564 if(y
>= _Y_Display
+_H_Display
-cornerSizeY
)
566 // Resize top or top corners.
567 if(y
>= _Y_Display
+_H_Display
-_RS_H
)
569 // Move or resize top corners.
573 // Y is in the bottom part of the OSD (move, resize bottom, or resize bottom corners)
574 else if(y
< _Y_Display
+cornerSizeY
)
576 // Resize bottom or bottm corners.
577 if(y
< _Y_Display
+_RS_H
)
579 // Move or resize bottom corners.
583 // Y is in the middle part of the OSD (move, resize left or right).
588 // Determine the Resize Mode.
589 switch(x_State
| y_State
)
591 // Left Bottom corner
595 _Cursor
= Cur_Resize_BL
;
599 _Cursor
= Cur_Resize_L
;
605 _Cursor
= Cur_Resize_TL
;
609 _Cursor
= Cur_Resize_T
;
615 _Cursor
= Cur_Resize_TR
;
619 _Cursor
= Cur_Resize_R
;
621 // Right Bottom Corner.
625 _Cursor
= Cur_Resize_BR
;
629 _Cursor
= Cur_Resize_B
;
644 // Change the display of the OSD according to the cursor position.
645 testMode(x
, y
, _X_Display
+_RS_W
*2, _Y_Display
+_RS_H
*2, _X_Display
+_W_Display
-_RS_W
*2, _Y_Display
+_H_Display
-_TB_H_Display
-_RS_H
*2);
652 // Cursor outside the OSD -> no cursor needed by the OSD.
661 // Manage the OSD mode when the OSD do not have the Focus.
664 // In locked mode the mode do not change.
668 // Else the OSD mode changes to "none".
674 // OSD do not have any interaction -> no cursor.
679 // call the mouseMove() method on every child control
680 TListControl::iterator itControl
;
681 const TListControl::iterator itControlEnd
= _Children
.end();
683 for (itControl
= _Children
.begin() ; itControl
!= itControlEnd
; ++itControl
)
685 nlassert(*itControl
);
686 // only send the mouse move event to controls with show = true
687 if ( (*itControl
)->show() )
688 (*itControl
)->mouseMove( x
, y
);
692 // Return if the OSD as react.
697 //-----------------------------------------------
699 // Return the cursor used by the OSD at the moment.
700 // \return ECursor : 'Cur_None' if no cursor needed for the OSD.
701 // \warning This method should be called after the update one to be up to date.
702 //-----------------------------------------------
703 COSD::ECursor
COSD::cursor()
705 // Is the OSD is not visible -> no cursor needed;
709 // Return the cursor used for the OSD at the moment.
714 //-----------------------------------------------
716 // Manage the mouse click.
717 //-----------------------------------------------
718 void COSD::click(float x
, float y
, bool &taken
)
720 // Is the OSD is not visible -> return;
724 // if pop_up and cick was outside the window bounds: destroy that window
727 if ( (x
< _X_Display
) || (x
>= _X_Display
+ _W_Display
) || (y
< _Y_Display
) || (y
>= _Y_Display
+ _H_Display
) )
729 CInterfMngr::deleteOSD( this->_Id
);
734 _OffsetX
= x
-_X_Display
;
735 _OffsetY
= y
-_Y_Display
;
736 _OffsetW
= x
-(_X_Display
+_W_Display
);
737 _OffsetH
= y
-(_Y_Display
+_H_Display
);
739 // If some resize operations are in progress -> Stop resize.
740 if(_RS_Mode
!= no_resize
)
742 _RS_Mode
= no_resize
;
748 // Look if the OSD will be resized.
751 // In some _OSD_Mode the aspect OSD can change -> test if it changes.
754 // Select the right resize mode -> mode != no_resize -> click = true.
755 if(resizeMode(x
, y
) != TResize::no_resize
)
761 // Dispatch the click in the controls.
762 const TListControl::iterator itE
= _Children
.end();
763 for(TListControl::iterator it
= _Children
.begin(); it
!= itE
; ++it
)
765 // only send the click event to controls with show = true
767 (*it
)->click(x
, y
, taken
);
776 //-----------------------------------------------
778 // Manage the mouse right click.
779 //-----------------------------------------------
780 void COSD::clickRight(float x
, float y
, bool &taken
)
782 // Is the OSD is not visible -> return;
786 // if pop_up and cick was outside the window bounds: destroy that window
787 if ( _PopUp
&& ( (x
< _X_Display
) || (x
>= _X_Display
+ _W_Display
) || (y
< _Y_Display
) || (y
>= _Y_Display
+ _H_Display
) ) )
789 CInterfMngr::deleteOSD( this->_Id
);
793 _OffsetX
= x
-_X_Display
;
794 _OffsetY
= y
-_Y_Display
;
795 _OffsetW
= x
-(_X_Display
+_W_Display
);
796 _OffsetH
= y
-(_Y_Display
+_H_Display
);
798 // If some resize operations are in progress -> Stop resize.
799 if(_RS_Mode
!= no_resize
)
801 _RS_Mode
= no_resize
;
806 // Dispatch the click in the controls.
807 const TListControl::iterator itE
= _Children
.end();
808 for(TListControl::iterator it
= _Children
.begin(); it
!= itE
; ++it
)
810 // only send the click event to controls with show = true
812 (*it
)->clickRight(x
, y
, taken
);
815 // Lock/Unlock the OSD
818 // Check that the cursor is in the OSD.
819 if((x
>= _X_Display
) && (x
< _X_Display
+ _W_Display
) && (y
>= _Y_Display
) && (y
< _Y_Display
+ _H_Display
) )
821 if(_OSD_Mode
!= locked
)
835 //-----------------------------------------------
837 // Resize the Left border of the OSD.
838 //-----------------------------------------------
839 void COSD::resizeL(float x
, float y
)
841 uint32 width
, height
;
842 CInterfMngr::getWindowSize(width
, height
);
844 const float wMin
= _W_Min
/ width
;
846 float xTmp
= _X_Display
+ _W_Display
;
848 _X_Display
= x
- _OffsetX
;
850 if( _X_Display
> xTmp
- wMin
)
851 _X_Display
= xTmp
- wMin
;
854 _W_Display
= xTmp
- _X_Display
;
855 _W_Pixel
= _W_Display
*width
;
858 //-----------------------------------------------
860 // Resize the Right border of the OSD.
861 //-----------------------------------------------
862 void COSD::resizeR(float x
, float y
)
864 uint32 width
, height
;
865 CInterfMngr::getWindowSize(width
, height
);
867 const float wMin
= _W_Min
/ width
;
869 _W_Display
= x
- _OffsetW
- _X_Display
;
870 if(_W_Display
< wMin
)
873 _W_Pixel
= _W_Display
*width
;
876 //-----------------------------------------------
878 // Resize the Bottom border of the OSD.
879 //-----------------------------------------------
880 void COSD::resizeB(float x
, float y
)
882 uint32 width
, height
;
883 CInterfMngr::getWindowSize(width
, height
);
885 const float hMin
= _H_Min
/ height
;
887 float yTmp
= _Y_Display
+ _H_Display
;
888 _Y_Display
= y
-_OffsetY
;
889 if(_Y_Display
> yTmp
- hMin
)
890 _Y_Display
= yTmp
- hMin
;
893 _H_Display
= yTmp
- _Y_Display
;
894 _H_Pixel
= _H_Display
*height
;
897 //-----------------------------------------------
899 // Resize the Top border of the OSD.
900 //-----------------------------------------------
901 void COSD::resizeT(float x
, float y
)
903 uint32 width
, height
;
904 CInterfMngr::getWindowSize(width
, height
);
906 const float hMin
= _H_Min
/ height
;
908 _H_Display
= y
- _OffsetH
- _Y_Display
;
909 if(_H_Display
< hMin
)
912 _H_Pixel
= _H_Display
*height
;
915 //-----------------------------------------------
918 //-----------------------------------------------
919 void COSD::move(float x
, float y
)
921 _X_Display
= x
-_OffsetX
;
922 _Y_Display
= y
-_OffsetY
;
931 //-----------------------------------------------
933 // Test the mode of the OSD.
934 //-----------------------------------------------
935 void COSD::testMode(float x
, float y
, float rectX0
, float rectY0
, float rectX1
, float rectY1
)
941 if(x
< rectX0
|| x
> rectX1
|| y
< rectY0
)
942 _OSD_Mode
= resizable
;
944 _OSD_Mode
= selected
;
952 //-----------------------------------------------
954 // Change the OSD Position.
955 //-----------------------------------------------
956 void COSD::osdSetPosition(float x
, float y
)
961 // resize the other controls.
962 for(TMapControls::iterator it
= _Controls
.begin(); it
!= _Controls
.end(); it
++)
964 // If the control as a reference different than the OSD -> the Reference will resize this control.
965 if((*it
).second
->parent() == 0)
968 calculatePos(x0
, y0
, (*it
).second
->origin());
969 (*it
).second
->ref(x0
, y0
, _W_Display
, _H_Display
);
972 }// osdSetPosition //
974 //-----------------------------------------------
976 // Return the OSD Position.
977 //-----------------------------------------------
978 void COSD::osdGetPosition(float &x
, float &y
) const
982 }// osdGetPosition //
984 //-----------------------------------------------
986 // Change the OSD Size (between 0-1).
987 //-----------------------------------------------
988 void COSD::osdSetSize(float w
, float h
)
990 uint32 width
, height
;
991 CInterfMngr::getWindowSize(width
, height
);
995 _W_Pixel
= _W_Display
*width
;
996 _H_Pixel
= _H_Display
*height
;
998 // resize the other controls.
999 for(TMapControls::iterator it
= _Controls
.begin(); it
!= _Controls
.end(); it
++)
1001 // If the control as a reference different than the OSD -> the Reference will resize this control.
1002 if((*it
).second
->parent() == 0)
1005 calculatePos(x0
, y0
, (*it
).second
->origin());
1006 (*it
).second
->ref(x0
, y0
, _W_Display
, _H_Display
);
1011 //-----------------------------------------------
1013 // Return the OSD Size (between 0-1).
1014 //-----------------------------------------------
1015 void COSD::osdGetSize(float &w
, float &h
) const
1021 //-----------------------------------------------
1023 // Change the OSD Mode (locked, resize, selected, etc.)
1024 //-----------------------------------------------
1025 void COSD::osdMode(TMode osdMode
)
1027 _OSD_Mode
= osdMode
;
1030 //-----------------------------------------------
1032 // Return the current OSD Mode.
1033 //-----------------------------------------------
1034 COSD::TMode
COSD::osdMode() const
1039 //-----------------------------------------------
1041 // Change the OSD Name.
1042 //-----------------------------------------------
1043 void COSD::osdName(const ucstring
&osdName
)
1045 _OSD_Name
= osdName
;
1048 //-----------------------------------------------
1050 // Return the OSD Name.
1051 //-----------------------------------------------
1052 ucstring
COSD::osdName() const
1057 //-----------------------------------------------
1059 // Set the update Function.
1060 //-----------------------------------------------
1061 void COSD::osdUpdateFunc(uint updateFunc
)
1063 _OSD_Update_Func
= osdUpdateFunc
;
1066 //-----------------------------------------------
1068 // Get the update Function.
1069 //-----------------------------------------------
1070 uint
COSD::osdUpdateFunc() const
1072 return _OSD_Update_Func
;
1078 //-----------------------------------------------
1080 // Set the Background display mode.
1081 void COSD::bgMode(TBG mode
)
1082 //-----------------------------------------------
1087 //-----------------------------------------------
1089 // Get the Background display mode.
1090 //-----------------------------------------------
1091 COSD::TBG
COSD::bgMode() const
1096 //-----------------------------------------------
1098 // Set the texture Id for the Background.
1099 //-----------------------------------------------
1100 void COSD::bg(uint b
)
1105 //-----------------------------------------------
1107 // Get background Id.
1108 //-----------------------------------------------
1109 uint
COSD::bg() const
1114 //-----------------------------------------------
1116 // Set the Background RGBA.
1117 //-----------------------------------------------
1118 void COSD::bgColor(const CRGBA
&bRGBA
)
1123 //-----------------------------------------------
1125 // Get the background RGBA.
1126 //-----------------------------------------------
1127 CRGBA
COSD::bgColor() const
1135 //-----------------------------------------------
1137 // Set the Title Bar display mode.
1138 //-----------------------------------------------
1139 void COSD::tbMode(TTB mode
)
1144 //-----------------------------------------------
1146 // Get the Title Bar display mode.
1147 //-----------------------------------------------
1148 COSD::TTB
COSD::tbMode() const
1153 //-----------------------------------------------
1155 // Set the texture Id for the Title Bar.
1156 //-----------------------------------------------
1157 void COSD::tb(uint t
)
1162 //-----------------------------------------------
1164 // Get Title Bar Id.
1165 //-----------------------------------------------
1166 uint
COSD::tb() const
1171 //-----------------------------------------------
1173 // Set the Title Bar RGBA.
1174 //-----------------------------------------------
1175 void COSD::tbColor(const CRGBA
&tRGBA
)
1180 //-----------------------------------------------
1182 // Get the Title Bar RGBA.
1183 //-----------------------------------------------
1184 CRGBA
COSD::tbColor() const
1189 //-----------------------------------------------
1191 // Set Title Bar Height (in Pixel)
1192 //-----------------------------------------------
1193 void COSD::tbHeight(float height
)
1196 CInterfMngr::getWindowSize(w
, h
);
1199 // Calculate the Title Bar height for Display.
1200 _TB_H_Display
= _TB_H
/h
;
1204 //-----------------------------------------------
1206 // Get Title Bar Height (in Pixel)
1207 //-----------------------------------------------
1208 float COSD::tbHeight() const
1213 //-----------------------------------------------
1215 // Set the Pen for the Title Bar.
1216 //-----------------------------------------------
1217 void COSD::tbPen(const CPen
&pen
)
1222 //-----------------------------------------------
1224 // Get the Pen of the Title Bar.
1225 //-----------------------------------------------
1226 CPen
COSD::tbPen() const
1234 //-----------------------------------------------
1236 // Set the HighLight Color.
1237 //-----------------------------------------------
1238 void COSD::hlColor(const CRGBA
&hlColor
)
1240 _HL_Color
= hlColor
;
1243 //-----------------------------------------------
1245 // Get the HighLight Color.
1246 //-----------------------------------------------
1247 CRGBA
COSD::hlColor() const
1252 //-----------------------------------------------
1254 // Set the HighLight Size (in Pixel).
1255 //-----------------------------------------------
1256 void COSD::hlSize(float hlSize
)
1259 CInterfMngr::getWindowSize(w
, h
);
1262 // Calculate borders for the HighLight.
1263 _HL_W
= _HL_Size
/w
; // Left and Right.
1264 _HL_H
= _HL_Size
/h
; // Bottom and Top.
1267 //-----------------------------------------------
1269 // Get the HighLight Size (in Pixel).
1270 //-----------------------------------------------
1271 float COSD::hlSize() const
1279 //-----------------------------------------------
1281 // Set the Resize Mode.
1282 //-----------------------------------------------
1283 void COSD::rsMode(TResize rsMode
)
1288 //-----------------------------------------------
1290 // Get the Resize Mode.
1291 //-----------------------------------------------
1292 COSD::TResize
COSD::rsMode() const
1297 //-----------------------------------------------
1299 // Set Resize borders Color
1300 //-----------------------------------------------
1301 void COSD::rsColor(CRGBA rsColor
)
1303 _RS_Color
= rsColor
;
1306 //-----------------------------------------------
1308 // Get Resize borders Color
1309 //-----------------------------------------------
1310 CRGBA
COSD::rsColor() const
1315 //-----------------------------------------------
1317 // Set Resize size (in pixel).
1318 //-----------------------------------------------
1319 void COSD::rsSize(float rsSize
)
1322 CInterfMngr::getWindowSize(w
, h
);
1325 // Calculate borders for the Resize.
1326 _RS_W
= _RS_Size
/w
; // Left and Right.
1327 _RS_H
= _RS_Size
/h
; // Bottom and Top.
1330 //-----------------------------------------------
1332 // Get Resize size (in pixel).
1333 //-----------------------------------------------
1334 float COSD::rsSize() const
1343 //-----------------------------------------------
1345 // Return the pointer of the control "id".
1346 //-----------------------------------------------
1347 CControl
* COSD::getCtrl(uint id
)
1349 TMapControls::iterator it
= _Controls
.find(id
);
1351 if(it
!= _Controls
.end())
1352 return (*it
).second
;
1358 //-----------------------------------------------
1361 //-----------------------------------------------
1362 void COSD::addChild(uint idCtrl
, CControl
*ctrl
)
1365 _Controls
.insert(TMapControls::value_type(idCtrl
, ctrl
));
1366 // The list of control in order to display.
1367 _Children
.push_front(ctrl
);
1371 //-----------------------------------------------
1373 // Delete a control by the Id.
1374 //-----------------------------------------------
1375 void COSD::delChild(uint idCtrl
)
1377 TMapControls::iterator it
= _Controls
.find(idCtrl
);
1378 if(it
!= _Controls
.end())
1380 CControl
*ctrl
= (*it
).second
;
1383 _Controls
.erase(it
);
1384 // Check if the control is allocated.
1388 for(TListControl::iterator itChild
= _Children
.begin(); itChild
!= _Children
.end(); ++itChild
)
1390 if((*itChild
) == ctrl
)
1392 _Children
.erase(itChild
);
1407 //-----------------------------------------------
1408 // removeFromChildren :
1410 //-----------------------------------------------
1411 void COSD::removeFromChildren(uint idCtrl
)
1413 TMapControls::iterator it
= _Controls
.find(idCtrl
);
1414 if(it
!= _Controls
.end())
1416 CControl
*ctrl
= (*it
).second
;
1418 // Check if the control is allocated.
1422 for(TListControl::iterator itChild
= _Children
.begin(); itChild
!= _Children
.end(); ++itChild
)
1424 if((*itChild
) == ctrl
)
1426 _Children
.erase(itChild
);
1432 }// removeFromChildren //
1435 //-----------------------------------------------
1437 // Calculate a position according to the origin.
1438 //-----------------------------------------------
1439 void COSD::calculatePos(float &x
, float &y
, CControl::THotSpot origin
)
1443 case CControl::HS_TL
:
1445 y
= _Y_Display
+_H_Display
;
1447 case CControl::HS_TM
:
1448 x
= _X_Display
+_W_Display
/2.f
;
1449 y
= _Y_Display
+_H_Display
;
1451 case CControl::HS_TR
:
1452 x
= _X_Display
+_W_Display
;
1453 y
= _Y_Display
+_H_Display
;
1456 case CControl::HS_ML
:
1458 y
= _Y_Display
+_H_Display
/2.f
;
1460 case CControl::HS_MM
:
1461 x
= _X_Display
+_W_Display
/2.f
;
1462 y
= _Y_Display
+_H_Display
/2.f
;
1464 case CControl::HS_MR
:
1465 x
= _X_Display
+_W_Display
;
1466 y
= _Y_Display
+_H_Display
/2.f
;
1469 case CControl::HS_BL
:
1473 case CControl::HS_BM
:
1474 x
= _X_Display
+_W_Display
/2.f
;
1477 case CControl::HS_BR
:
1478 x
= _X_Display
+_W_Display
;
1485 //-----------------------------------------------
1486 // calculateDisplay :
1487 // Calculate the Display X, Y, Width, Height.
1488 //-----------------------------------------------
1489 void COSD::calculateDisplay()
1492 CInterfMngr::getWindowSize(w
, h
);
1495 // Calculate the Title Bar height for Display.
1496 _TB_H_Display
= _TB_H
/h
;
1497 // Calculate borders for the Resize.
1498 _RS_W
= _RS_Size
/w
; // Left and Right.
1499 _RS_H
= _RS_Size
/h
; // Bottom and Top.
1500 // Calculate borders for the HighLight.
1501 _HL_W
= _HL_Size
/w
; // Left and Right.
1502 _HL_H
= _HL_Size
/h
; // Bottom and Top.
1504 // Calculate the display Width and Height.
1506 _W_Display
= _W_Pixel
/w
; //_W*_W_Ref + _W_Pixel/w;
1508 _W_Display
= 0.f
; //_W*_W_Ref;
1511 _H_Display
= _H_Pixel
/h
; //_H*_H_Ref + _H_Pixel/h;
1513 _H_Display
= 0.f
; //_H*_H_Ref;
1515 // // Calculate the HotSpot.
1518 _X_Display
= _X
; //_X_Ref + _X*_W_Ref + _X_Pixel/w + _X_HotSpot;
1519 _Y_Display
= _Y
; //_Y_Ref + _Y*_H_Ref + _Y_Pixel/h + _Y_HotSpot;
1520 }// calculateDisplay //
1525 ///////////////////////////
1526 // OPERATIONS ON THE OSD //
1527 ///////////////////////////
1528 //-----------------------------------------------
1530 // Function to test if a coordinate is in the rect.
1531 //-----------------------------------------------
1532 bool COSD::testInRect(float x
, float y
, float rectX0
, float rectY0
, float rectX1
, float rectY1
)
1534 if(x
>=rectX0
&& x
<rectX1
&& y
>=rectY0
&& y
<rectY1
)
1540 //-----------------------------------------------
1542 // Determine the Resize Mode.
1543 //-----------------------------------------------
1544 bool COSD::resizeMode(float x
, float y
)
1546 // Get the window size.
1548 CInterfMngr::getWindowSize(w
, h
);
1550 float cornerSizeX
= _RS_W
+_TB_H
/(float)w
;
1551 float cornerSizeY
= _RS_H
+_TB_H
/(float)h
;
1574 // X POSITION in the OSD.
1575 // X is in the right part of the OSD (move, resize right, or resize right corners)
1576 if(x
>= _X_Display
+_W_Display
-cornerSizeX
)
1578 // Resize right or right corners.
1579 if(x
>= _X_Display
+_W_Display
-_RS_W
)
1581 // Move or resize right corners.
1585 // X is in the left part of the OSD (move, resize left, or resize left corners)
1586 else if(x
< _X_Display
+cornerSizeX
)
1588 // Resize left or left corners.
1589 if(x
< _X_Display
+_RS_W
)
1591 // Move or resize left corners.
1595 // X is in the middle part of the OSD (move, resize top or bottom).
1601 // Y POSITION in the OSD.
1602 // Y is in the Top part of the OSD (move, resize top, or resize top corners)
1603 if(y
>= _Y_Display
+_H_Display
-cornerSizeY
)
1605 // Resize top or top corners.
1606 if(y
>= _Y_Display
+_H_Display
-_RS_H
)
1608 // Move or resize top corners.
1612 // Y is in the bottom part of the OSD (move, resize bottom, or resize bottom corners)
1613 else if(y
< _Y_Display
+cornerSizeY
)
1615 // Resize bottom or bottm corners.
1616 if(y
< _Y_Display
+_RS_H
)
1618 // Move or resize bottom corners.
1622 // Y is in the middle part of the OSD (move, resize left or right).
1628 // Determine the Resize Mode.
1629 switch(x_State
| y_State
)
1631 // Left Bottom corner
1635 _RS_Mode
= resize_BL
;
1639 _RS_Mode
= resize_L
;
1645 _RS_Mode
= resize_TL
;
1649 _RS_Mode
= resize_T
;
1651 // Right Top Corner.
1655 _RS_Mode
= resize_TR
;
1659 _RS_Mode
= resize_R
;
1661 // Right Bottom Corner.
1665 _RS_Mode
= resize_BR
;
1669 _RS_Mode
= resize_B
;
1675 _RS_Mode
= resize_move
;
1679 _RS_Mode
= no_resize
;
1692 //-----------------------------------------------
1695 //-----------------------------------------------
1696 void COSD::getText(uint idCtrl
)
1701 // Lecture de la partie commune du script de control.
1702 CONTROL_SCRIPT_MACRO
1705 else if(strcmp(ptr
, "Text:") == 0)
1708 else if(strcmp(ptr
, "Pen:") == 0)
1713 CText
*text
= new CText(idCtrl
, x
, y
, xPixel
, yPixel
, CInterfMngr::getText(idTxt
), CInterfMngr::getPen(idPen
));
1716 text
->origin(origin
);
1718 text
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
1722 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
1725 parent
->addChild(text
);
1726 text
->parent(parent
);
1730 addChild(idCtrl
, text
);
1734 //-----------------------------------------------
1737 //-----------------------------------------------
1738 void COSD::getCapture(uint idCtrl
)
1741 CRGBA
rgba(255,255,255,128);
1746 // Lecture de la partie commune du script de control.
1747 CONTROL_SCRIPT_MACRO
1749 // Get the Function.
1750 else if(strcmp(ptr
, "Function:") == 0)
1753 else if(strcmp(ptr
, "Pen:") == 0)
1756 else if(strcmp(ptr
, "Prompt:") == 0)
1757 idPrompt
= getInt();
1761 CCapture
*capture
= new CCapture(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, numFunc
, CInterfMngr::getPen(idPen
));
1764 capture
->origin(origin
);
1765 capture
->hotSpot(hs
);
1766 capture
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
1767 capture
->setPrompt( CInterfMngr::getText(idPrompt
) );
1771 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
1774 parent
->addChild(capture
);
1775 capture
->parent(parent
);
1779 addChild(idCtrl
, capture
);
1784 //-----------------------------------------------
1787 //-----------------------------------------------
1788 void COSD::getButton(uint idCtrl
)
1797 // Lecture de la partie commune du script de control.
1798 CONTROL_SCRIPT_MACRO
1800 // Get the Function for left click
1801 else if(strcmp(ptr
, "Function:") == 0)
1804 // Get the Function for Right click
1805 else if(strcmp(ptr
, "FunctionRight:") == 0)
1806 numFuncR
= getInt();
1808 // Get the Function for double click
1809 else if(strcmp(ptr
, "FunctionDouble:") == 0)
1810 numFuncD
= getInt();
1813 else if(strcmp(ptr
, "Text:") == 0)
1817 else if(strcmp(ptr
, "Pen:") == 0)
1821 // Create the button.
1822 CButton
*button
= new CButton(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, numFunc
, numFuncR
, numFuncD
, CInterfMngr::getButton(idCtrl
));
1825 button
->origin(origin
);
1826 button
->hotSpot(hs
);
1827 button
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
1828 button
->pen(CInterfMngr::getPen(idPen
));
1830 button
->text(CInterfMngr::getText(idTxt
));
1834 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
1837 parent
->addChild(button
);
1838 button
->parent(parent
);
1841 addChild(idCtrl
, button
);
1846 //-----------------------------------------------
1849 //-----------------------------------------------
1850 void COSD::getRadioButton(uint idCtrl
)
1859 // Lecture de la partie commune du script de control.
1860 CONTROL_SCRIPT_MACRO
1862 // Get the Function for left click
1863 else if(strcmp(ptr
, "Function:") == 0)
1866 // Get the Function for Right click
1867 else if(strcmp(ptr
, "FunctionRight:") == 0)
1868 numFuncR
= getInt();
1870 // Get the Function for double click
1871 else if(strcmp(ptr
, "FunctionDouble:") == 0)
1872 numFuncD
= getInt();
1875 else if(strcmp(ptr
, "Text:") == 0)
1879 else if(strcmp(ptr
, "Pen:") == 0)
1883 // Create the button.
1884 CRadioButton
*button
= new CRadioButton(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, numFunc
, numFuncR
, numFuncD
, CInterfMngr::getButton(idCtrl
));
1887 button
->origin(origin
);
1888 button
->hotSpot(hs
);
1889 button
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
1890 button
->pen(CInterfMngr::getPen(idPen
));
1892 button
->text(CInterfMngr::getText(idTxt
));
1896 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
1899 parent
->addChild(button
);
1900 button
->parent(parent
);
1903 addChild(idCtrl
, button
);
1905 }// getRadioButton //
1908 //-----------------------------------------------
1909 // getRadioController :
1911 //-----------------------------------------------
1912 void COSD::getRadioController(uint idCtrl
)
1914 char delimiter
[] = "[] \t";
1916 // Create the radio controller.
1917 CRadioController
*radioController
= new CRadioController(idCtrl
);
1921 TMapControls::iterator it
;
1923 char *ptr
= strtok(NULL
, delimiter
);
1927 if(strcmp(ptr
, "Buttons:") == 0)
1929 ptr
= strtok(NULL
, delimiter
);
1930 while((ptr
!= NULL
) && (strcmp(ptr
, "End")!=0))
1932 buttonId
= atoi(ptr
);
1933 it
= _Controls
.find(buttonId
);
1934 if(it
!= _Controls
.end())
1936 if(radioController
->add(dynamic_cast<CRadioButton
*>((*it
).second
)) == false)
1938 nlerror("Interface Error : control %d can't be add in the radio button %d", buttonId
, idCtrl
);
1943 ptr
= strtok(NULL
, delimiter
);
1948 ptr
= strtok(NULL
, delimiter
);
1951 // Test if there is at least 1 button)
1952 if( radioController
->size() > 0)
1954 // Insert the radio controller in the control list.
1955 addChild(idCtrl
, radioController
);
1957 // No Button -> Destroy Radio Button.
1960 delete radioController
;
1961 radioController
= 0;
1964 }// getRadioController //
1966 //-----------------------------------------------
1969 //-----------------------------------------------
1970 void COSD::getBitmap(uint idCtrl
)
1976 // Lecture de la partie commune du script de control.
1977 CONTROL_SCRIPT_MACRO
1980 else if(strcmp(ptr
, "Texture:") == 0)
1981 idtexture
= getInt();
1983 else if(strcmp(ptr
, "RGBA:") == 0)
1985 // tiled or stretched
1986 else if(strcmp(ptr
, "Tiled:") == 0)
1994 CBitm
*bitmap
= new CBitm(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, idtexture
, rgba
);
1997 bitmap
->tiled( tiled
);
1998 bitmap
->origin(origin
);
1999 bitmap
->hotSpot(hs
);
2000 bitmap
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
2004 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
2007 parent
->addChild(bitmap
);
2008 bitmap
->parent(parent
);
2012 addChild(idCtrl
, bitmap
);
2016 //-----------------------------------------------
2019 //-----------------------------------------------
2020 void COSD::getList(uint idCtrl
)
2025 uint downTexture
= 0;
2026 uint scrollBarTexture
= 0;
2027 CRGBA
scrollBarRgba(255,255,255,255);
2029 // Lecture de la partie commune du script de control.
2030 CONTROL_SCRIPT_MACRO
2033 else if(strcmp(ptr
, "Pen:") == 0)
2035 // Get the Texture for the 'up' arrow
2036 else if(strcmp(ptr
, "UpTexture:") == 0)
2037 upTexture
= getInt();
2038 // Get the Texture for the 'down' arrow
2039 else if(strcmp(ptr
, "DownTexture:") == 0)
2040 downTexture
= getInt();
2041 // Get the Texture for the scroll bar body
2042 else if(strcmp(ptr
, "ScrollBarTexture:") == 0)
2043 scrollBarTexture
= getInt();
2044 // Get the RGBA for the scroll bar
2045 else if(strcmp(ptr
, "ScrollBarRGBA:") == 0)
2046 scrollBarRgba
= getRGBA();
2050 CList
*list
= new CList(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, CInterfMngr::getPen(idPen
));
2053 list
->origin(origin
);
2055 list
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
2057 CScrollBar
*scroll
= list
->getVScroll();
2060 scroll
->setDownArrowTextureOn( downTexture
);
2061 scroll
->setUpArrowTextureOn( upTexture
);
2062 scroll
->textureOn( scrollBarTexture
);
2063 scroll
->setDownArrowTextureOff( downTexture
);
2064 scroll
->setUpArrowTextureOff( upTexture
);
2065 scroll
->textureDisable( scrollBarTexture
);
2066 scroll
->colorOn( scrollBarRgba
);
2067 scroll
->enable(true);
2072 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
2075 parent
->addChild(list
);
2076 list
->parent(parent
);
2080 addChild(idCtrl
, list
);
2085 //-----------------------------------------------
2088 //-----------------------------------------------
2089 void COSD::getMultiList(uint idCtrl
)
2093 uint downTexture
= 0;
2094 uint scrollBarTexture
= 0;
2097 uint16 lineHeight
= 0;
2099 std::vector
<float> colSize
;
2101 CRGBA
rgba(255,255,255,255);
2102 CRGBA
scrollBarRgba(255,255,255,255);
2106 // Lecture de la partie commune du script de control.
2107 CONTROL_SCRIPT_MACRO
2109 // Get the number of columns
2110 else if(strcmp(ptr
, "NbColumns:") == 0)
2113 // Get the columns size.
2114 else if(strcmp(ptr
, "ColSize:") == 0)
2115 colSize
= getVectorOfFloat(nbCol
);
2118 else if(strcmp(ptr
, "Pen:") == 0)
2122 else if(strcmp(ptr
, "Spacing:") == 0)
2125 // Get the specified Line Height.
2126 else if(strcmp(ptr
, "LineHeight:") == 0)
2127 lineHeight
= getInt();
2129 // Get the Texture for the 'up' arrow
2130 else if(strcmp(ptr
, "UpTexture:") == 0)
2131 upTexture
= getInt();
2132 // Get the Texture for the 'down' arrow
2133 else if(strcmp(ptr
, "DownTexture:") == 0)
2134 downTexture
= getInt();
2135 // Get the Texture for the scroll bar body
2136 else if(strcmp(ptr
, "ScrollBarTexture:") == 0)
2137 scrollBarTexture
= getInt();
2138 // Get the RGBA for the scroll bar
2139 else if(strcmp(ptr
, "ScrollBarRGBA:") == 0)
2140 scrollBarRgba
= getRGBA();
2144 CMultiList
*list
= new CMultiList(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, CInterfMngr::getPen(idPen
), nbCol
);
2147 list
->origin(origin
);
2149 list
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
2151 if ( nbCol
== colSize
.size() )
2152 list
->setColSize( colSize
);
2154 list
->setSpacing( spacing
);
2155 list
->setLineHeight( lineHeight
);
2157 CScrollBar
*scroll
= list
->getVScroll();
2160 scroll
->setDownArrowTextureOn( downTexture
);
2161 scroll
->setUpArrowTextureOn( upTexture
);
2162 scroll
->textureOn( scrollBarTexture
);
2163 scroll
->setDownArrowTextureOff( downTexture
);
2164 scroll
->setUpArrowTextureOff( upTexture
);
2165 scroll
->textureDisable( scrollBarTexture
);
2166 scroll
->colorOn( scrollBarRgba
);
2167 scroll
->enable(true);
2172 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
2175 parent
->addChild(list
);
2176 list
->parent(parent
);
2180 addChild(idCtrl
, list
);
2186 //-----------------------------------------------
2189 //-----------------------------------------------
2190 void COSD::getChatBox(uint idCtrl
)
2194 uint downTexture
= 0;
2195 uint scrollBarTexture
= 0;
2196 CRGBA
rgba(255,255,255,255);
2197 CRGBA
scrollBarRgba(255,255,255,255);
2202 // Lecture de la partie commune du script de control.
2203 CONTROL_SCRIPT_MACRO
2206 else if(strcmp(ptr
, "Pen:") == 0)
2209 // Get the function to execute on left click on player name
2210 else if(strcmp(ptr
, "LeftClickFunction:") == 0)
2211 leftFunc
= getInt();
2213 // Get the function to execute on left click on player name
2214 else if(strcmp(ptr
, "RightClickFunction:") == 0)
2215 rightFunc
= getInt();
2216 // Get the Texture for the 'up' arrow
2217 else if(strcmp(ptr
, "UpTexture:") == 0)
2218 upTexture
= getInt();
2219 // Get the Texture for the 'down' arrow
2220 else if(strcmp(ptr
, "DownTexture:") == 0)
2221 downTexture
= getInt();
2222 // Get the Texture for the scroll bar body
2223 else if(strcmp(ptr
, "ScrollBarTexture:") == 0)
2224 scrollBarTexture
= getInt();
2225 // Get the RGBA for the scroll bar
2226 else if(strcmp(ptr
, "ScrollBarRGBA:") == 0)
2227 scrollBarRgba
= getRGBA();
2231 CChatControl
*chat
= new CChatControl(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, leftFunc
, rightFunc
, CInterfMngr::getPen(idPen
));
2234 chat
->origin(origin
);
2236 chat
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
2238 CScrollBar
*scroll
= chat
->getVScroll();
2241 scroll
->setDownArrowTextureOn( downTexture
);
2242 scroll
->setUpArrowTextureOn( upTexture
);
2243 scroll
->textureOn( scrollBarTexture
);
2244 scroll
->setDownArrowTextureOff( downTexture
);
2245 scroll
->setUpArrowTextureOff( upTexture
);
2246 scroll
->textureDisable( scrollBarTexture
);
2247 scroll
->colorOn( scrollBarRgba
);
2248 scroll
->enable(true);
2254 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
2257 parent
->addChild(chat
);
2258 chat
->parent(parent
);
2262 addChild(idCtrl
, chat
);
2267 //-----------------------------------------------
2268 // getCandidateList :
2270 //-----------------------------------------------
2271 void COSD::getCandidateList(uint idCtrl
)
2275 uint downTexture
= 0;
2276 uint scrollBarTexture
= 0;
2278 uint lineHeight
= 0;
2281 std::vector
<float> colSize
;
2283 CRGBA
rgba(255,255,255,255);
2284 CRGBA
selRgba(0,0,0,255);
2285 CRGBA
scrollBarRgba(255,255,255,255);
2289 // Lecture de la partie commune du script de control.
2290 CONTROL_SCRIPT_MACRO
2292 // Get the columns size.
2293 else if(strcmp(ptr
, "ColSize:") == 0)
2294 colSize
= getVectorOfFloat(2);
2297 else if(strcmp(ptr
, "Pen:") == 0)
2301 else if(strcmp(ptr
, "Spacing:") == 0)
2304 // Get the function to execute on left click on candidate name
2305 else if(strcmp(ptr
, "LeftClickFunction:") == 0)
2306 leftFunc
= getInt();
2308 // Get the function to execute on left click on candidate name
2309 else if(strcmp(ptr
, "RightClickFunction:") == 0)
2310 rightFunc
= getInt();
2312 // Get the specified Line Height.
2313 else if(strcmp(ptr
, "LineHeight:") == 0)
2314 lineHeight
= getInt();
2316 // Get the Texture for the 'up' arrow
2317 else if(strcmp(ptr
, "UpTexture:") == 0)
2318 upTexture
= getInt();
2319 // Get the Texture for the 'down' arrow
2320 else if(strcmp(ptr
, "DownTexture:") == 0)
2321 downTexture
= getInt();
2322 // Get the Texture for the scroll bar body
2323 else if(strcmp(ptr
, "ScrollBarTexture:") == 0)
2324 scrollBarTexture
= getInt();
2325 // Get the RGBA for the scroll bar
2326 else if(strcmp(ptr
, "ScrollBarRGBA:") == 0)
2327 scrollBarRgba
= getRGBA();
2329 // Get the RGBA for the selection box
2330 else if(strcmp(ptr
, "SelectionRGBA:") == 0)
2331 selRgba
= getRGBA();
2335 CCandidateList
*list
= new CCandidateList(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, CInterfMngr::getPen(idPen
));
2338 list
->origin(origin
);
2340 list
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
2342 if( 2 == colSize
.size() )
2343 list
->setColSize( colSize
);
2345 list
->setSpacing( spacing
);
2346 list
->setLineHeight( lineHeight
);
2347 list
->setSelectedColor( selRgba
);
2348 list
->setLeftClickFunction( leftFunc
);
2349 list
->setRightClickFunction( rightFunc
);
2352 CScrollBar
*scroll
= list
->getVScroll();
2355 scroll
->setDownArrowTextureOn( downTexture
);
2356 scroll
->setUpArrowTextureOn( upTexture
);
2357 scroll
->textureOn( scrollBarTexture
);
2358 scroll
->setDownArrowTextureOff( downTexture
);
2359 scroll
->setUpArrowTextureOff( upTexture
);
2360 scroll
->textureDisable( scrollBarTexture
);
2361 scroll
->colorOn( scrollBarRgba
);
2362 scroll
->enable(true);
2367 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
2370 parent
->addChild(list
);
2371 list
->parent(parent
);
2375 addChild(idCtrl
, list
);
2377 }// getCandidateList //
2379 //-----------------------------------------------
2382 //-----------------------------------------------
2383 void COSD::getChatInput(uint idCtrl
)
2390 // Lecture de la partie commune du script de control.
2391 CONTROL_SCRIPT_MACRO
2393 // Get the Function.
2394 else if(strcmp(ptr
, "Function:") == 0)
2397 else if(strcmp(ptr
, "Pen:") == 0)
2401 // Create the chat input
2402 CChatInput
*chat
= new CChatInput(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, numFunc
, CInterfMngr::getPen(idPen
));
2405 chat
->origin(origin
);
2407 chat
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
2411 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
2414 parent
->addChild(chat
);
2415 chat
->parent(parent
);
2419 addChild(idCtrl
, chat
);
2424 //-----------------------------------------------
2427 //-----------------------------------------------
2428 void COSD::getChoiceList(uint idCtrl
)
2433 uint downTexture
= 0;
2434 uint scrollBarTexture
= 0;
2435 CRGBA
scrollBarRgba(255,255,255,255);
2438 // Lecture de la partie commune du script de control.
2439 CONTROL_SCRIPT_MACRO
2442 else if(strcmp(ptr
, "Pen:") == 0)
2444 // Get the Texture for the 'up' arrow
2445 else if(strcmp(ptr
, "UpTexture:") == 0)
2446 upTexture
= getInt();
2447 // Get the Texture for the 'down' arrow
2448 else if(strcmp(ptr
, "DownTexture:") == 0)
2449 downTexture
= getInt();
2450 // Get the Texture for the scroll bar body
2451 else if(strcmp(ptr
, "ScrollBarTexture:") == 0)
2452 scrollBarTexture
= getInt();
2453 // Get the RGBA for the scroll bar
2454 else if(strcmp(ptr
, "ScrollBarRGBA:") == 0)
2455 scrollBarRgba
= getRGBA();
2458 // Create the chat input
2459 CChoiceList
*choiceList
= new CChoiceList(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, CInterfMngr::getPen(idPen
));
2462 choiceList
->origin(origin
);
2463 choiceList
->hotSpot(hs
);
2464 choiceList
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
2466 CScrollBar
*scroll
= choiceList
->getVScroll();
2469 scroll
->setDownArrowTextureOn( downTexture
);
2470 scroll
->setUpArrowTextureOn( upTexture
);
2471 scroll
->textureOn( scrollBarTexture
);
2472 scroll
->setDownArrowTextureOff( downTexture
);
2473 scroll
->setUpArrowTextureOff( upTexture
);
2474 scroll
->textureDisable( scrollBarTexture
);
2475 scroll
->colorOn( scrollBarRgba
);
2476 scroll
->enable(true);
2481 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
2484 parent
->addChild(choiceList
);
2485 choiceList
->parent(parent
);
2489 addChild(idCtrl
, choiceList
);
2494 //-----------------------------------------------
2495 // getHorizontalList :
2497 //-----------------------------------------------
2498 void COSD::getHorizontalList(uint idCtrl
)
2501 uint scrollLeftId
= 0;
2502 uint scrollRightId
= 0;
2504 CRGBA
rgba(255,255,255,255);
2507 // Lecture de la partie commune du script de control.
2508 CONTROL_SCRIPT_MACRO
2511 else if(strcmp(ptr
, "Spacing:") == 0)
2514 else if(strcmp(ptr
, "ScrollLeft:") == 0)
2515 scrollLeftId
= getInt();
2517 else if(strcmp(ptr
, "ScrollRight:") == 0)
2518 scrollRightId
= getInt();
2520 else if(strcmp(ptr
, "Controls:") == 0)
2522 ptr
= strtok(NULL
, delimiter
);
2523 while((ptr
!= NULL
) && (strcmp(ptr
, "End")!=0))
2525 elts
.push_back( atoi(ptr
) );
2526 ptr
= strtok(NULL
, delimiter
);
2531 else if(strcmp(ptr
, "Texture:") == 0)
2532 idtexture
= getInt();
2534 else if(strcmp(ptr
, "RGBA:") == 0)
2536 else if(strcmp(ptr
, "Tiled:") == 0)
2538 if ( getInt() == 1 )
2544 CHorizontalList
*list
= new CHorizontalList(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, spacing
, idtexture
, rgba
);
2547 list
->tiled( tiled
);
2549 std::list
< uint16
>::iterator itElts
, itEltsEnd
= elts
.end();
2550 TMapControls::iterator it
;
2552 for (itElts
= elts
.begin() ; itElts
!= itEltsEnd
; ++itElts
)
2554 it
= _Controls
.find( *itElts
);
2555 if(it
!= _Controls
.end())
2557 CControl
*ctrl
= (*it
).second
;
2559 _Controls
.erase(it
);
2560 // Check if the control is allocated.
2563 // add control to the list
2567 for(TListControl::iterator itChild
= _Children
.begin(); itChild
!= _Children
.end(); ++itChild
)
2569 if((*itChild
) == ctrl
)
2571 _Children
.erase(itChild
);
2579 // get left scroll bitmap
2580 if (scrollLeftId
!= 0)
2582 it
= _Controls
.find( scrollLeftId
);
2583 if(it
!= _Controls
.end())
2585 CControl
*ctrl
= (*it
).second
;
2587 //_Controls.erase(it);
2590 // add control to the list
2591 list
->setLeftScrollBitmap( safe_cast
<CBitm
*> (ctrl
) );
2594 for(TListControl::iterator itChild
= _Children
.begin(); itChild
!= _Children
.end(); ++itChild
)
2596 if((*itChild
) == ctrl
)
2598 _Children
.erase(itChild
);
2605 // get right scroll bitmap
2606 if (scrollRightId
!= 0)
2608 it
= _Controls
.find( scrollRightId
);
2609 if(it
!= _Controls
.end())
2611 CControl
*ctrl
= (*it
).second
;
2613 //_Controls.erase(it);
2616 // add control to the list
2617 list
->setRightScrollBitmap( safe_cast
<CBitm
*> (ctrl
) );
2620 for(TListControl::iterator itChild
= _Children
.begin(); itChild
!= _Children
.end(); ++itChild
)
2622 if((*itChild
) == ctrl
)
2624 _Children
.erase(itChild
);
2632 list
->origin(origin
);
2634 list
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
2638 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
2641 parent
->addChild(list
);
2642 list
->parent(parent
);
2646 addChild(idCtrl
, list
);
2648 }// getHorizontalList //
2651 //-----------------------------------------------
2654 //-----------------------------------------------
2655 void COSD::getControlList(uint idCtrl
)
2659 uint downTexture
= 0;
2660 uint scrollBarTexture
= 0;
2661 CRGBA
scrollBarRgba(255,255,255,255);
2663 // Lecture de la partie commune du script de control.
2664 CONTROL_SCRIPT_MACRO
2667 else if(strcmp(ptr
, "Spacing:") == 0)
2670 else if(strcmp(ptr
, "Controls:") == 0)
2672 ptr
= strtok(NULL
, delimiter
);
2673 while((ptr
!= NULL
) && (strcmp(ptr
, "End")!=0))
2675 elts
.push_back( atoi(ptr
) );
2676 ptr
= strtok(NULL
, delimiter
);
2679 // Get the Texture for the 'up' arrow
2680 else if(strcmp(ptr
, "UpTexture:") == 0)
2681 upTexture
= getInt();
2682 // Get the Texture for the 'down' arrow
2683 else if(strcmp(ptr
, "DownTexture:") == 0)
2684 downTexture
= getInt();
2685 // Get the Texture for the scroll bar body
2686 else if(strcmp(ptr
, "ScrollBarTexture:") == 0)
2687 scrollBarTexture
= getInt();
2688 // Get the RGBA for the scroll bar
2689 else if(strcmp(ptr
, "ScrollBarRGBA:") == 0)
2690 scrollBarRgba
= getRGBA();
2695 CControlList
*list
= new CControlList(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, spacing
);
2698 CScrollBar
*scroll
= list
->getVScroll();
2701 scroll
->setDownArrowTextureOn( downTexture
);
2702 scroll
->setUpArrowTextureOn( upTexture
);
2703 scroll
->textureOn( scrollBarTexture
);
2704 scroll
->setDownArrowTextureOff( downTexture
);
2705 scroll
->setUpArrowTextureOff( upTexture
);
2706 scroll
->textureDisable( scrollBarTexture
);
2707 scroll
->colorOn( scrollBarRgba
);
2708 scroll
->enable(true);
2711 std::list
< uint16
>::iterator itElts
, itEltsEnd
= elts
.end();
2712 TMapControls::iterator it
;
2714 for (itElts
= elts
.begin() ; itElts
!= itEltsEnd
; ++itElts
)
2716 it
= _Controls
.find( *itElts
);
2717 if(it
!= _Controls
.end())
2719 CControl
*ctrl
= (*it
).second
;
2721 //_Controls.erase(it);
2722 // Check if the control is allocated.
2725 // add control to the list
2729 for(TListControl::iterator itChild
= _Children
.begin(); itChild
!= _Children
.end(); ++itChild
)
2731 if((*itChild
) == ctrl
)
2733 _Children
.erase(itChild
);
2740 list
->origin(origin
);
2742 list
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
2746 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
2749 parent
->addChild(list
);
2750 list
->parent(parent
);
2754 addChild(idCtrl
, list
);
2756 }// getControlList //
2759 //-----------------------------------------------
2762 //-----------------------------------------------
2763 void COSD::getSpellList(uint idCtrl
)
2766 uint idSpellPen
= 0 ;
2767 uint idCommentPen
= 0 ;
2773 float line_H_Pixel
= 0;
2775 uint downTexture
= 0;
2776 uint scrollBarTexture
= 0;
2777 CRGBA
scrollBarRgba(255,255,255,255);
2779 // Lecture de la partie commune du script de control.
2780 CONTROL_SCRIPT_MACRO
2783 else if(strcmp(ptr
, "Spacing:") == 0)
2786 else if(strcmp(ptr
, "SpellPen:") == 0)
2787 idSpellPen
= getInt();
2789 else if(strcmp(ptr
, "CommentPen:") == 0)
2790 idCommentPen
= getInt();
2791 // Get the button width
2792 else if(strcmp(ptr
, "ButtonW:") == 0)
2793 buttonW
= getFloat();
2794 // Get the button width
2795 else if(strcmp(ptr
, "ButtonH:") == 0)
2796 buttonH
= getFloat();
2797 // Get the function to execute on left click on candidate name
2798 else if(strcmp(ptr
, "LeftClickFunction:") == 0)
2799 leftFunc
= getInt();
2800 // Get the function to execute on left click on candidate name
2801 else if(strcmp(ptr
, "RightClickFunction:") == 0)
2802 rightFunc
= getInt();
2803 // Get the height of a line in the control (relative to the size of the list)
2804 else if(strcmp(ptr
, "Line_H:") == 0)
2805 line_H
= getFloat();
2806 // Get the height of a line in the control (in pixels)
2807 else if(strcmp(ptr
, "Line_H_Pixel:") == 0)
2808 line_H_Pixel
= getFloat();
2809 // Get the Texture for the 'up' arrow
2810 else if(strcmp(ptr
, "UpTexture:") == 0)
2811 upTexture
= getInt();
2812 // Get the Texture for the 'down' arrow
2813 else if(strcmp(ptr
, "DownTexture:") == 0)
2814 downTexture
= getInt();
2815 // Get the Texture for the scroll bar body
2816 else if(strcmp(ptr
, "ScrollBarTexture:") == 0)
2817 scrollBarTexture
= getInt();
2818 // Get the RGBA for the scroll bar
2819 else if(strcmp(ptr
, "ScrollBarRGBA:") == 0)
2820 scrollBarRgba
= getRGBA();
2824 CSpellList
*list
= new CSpellList(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, spacing
, leftFunc
, rightFunc
);
2828 CScrollBar
*scroll
= list
->getVScroll();
2831 scroll
->setDownArrowTextureOn( downTexture
);
2832 scroll
->setUpArrowTextureOn( upTexture
);
2833 scroll
->textureOn( scrollBarTexture
);
2834 scroll
->setDownArrowTextureOff( downTexture
);
2835 scroll
->setUpArrowTextureOff( upTexture
);
2836 scroll
->textureDisable( scrollBarTexture
);
2837 scroll
->colorOn( scrollBarRgba
);
2838 scroll
->enable(true);
2841 list
->setLineHeight( line_H
, line_H_Pixel
);
2842 list
->setButtonParam( buttonW
, buttonH
, CInterfMngr::getButton(idCtrl
) );
2844 list
->setCommentPen( CInterfMngr::getPen(idCommentPen
) );
2845 list
->setSpellPen( CInterfMngr::getPen(idSpellPen
) );
2847 list
->origin(origin
);
2849 list
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
2853 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
2856 parent
->addChild(list
);
2857 list
->parent(parent
);
2861 addChild(idCtrl
, list
);
2867 //-----------------------------------------------
2869 //-----------------------------------------------
2870 void COSD::getProgressBar(uint idCtrl
)
2872 uint bkgTexture
= 0;
2873 uint barTexture
= 0;
2881 CRGBA
bkgRgba(255,255,255,255);
2882 CRGBA
barRgba(255,255,255,255);
2884 // Lecture de la partie commune du script de control.
2885 CONTROL_SCRIPT_MACRO
2887 // Get the Texture for the progress bar
2888 else if(strcmp(ptr
, "BarTexture:") == 0)
2889 barTexture
= getInt();
2890 // Get the Texture for the background
2891 else if(strcmp(ptr
, "BackgroundTexture:") == 0)
2892 bkgTexture
= getInt();
2893 // Get the RGBA for the progress bar
2894 else if(strcmp(ptr
, "BarRGBA:") == 0)
2895 barRgba
= getRGBA();
2896 // Get the RGBA for the background
2897 else if(strcmp(ptr
, "BackgroundRGBA:") == 0)
2898 bkgRgba
= getRGBA();
2900 else if(strcmp(ptr
, "Range:") == 0)
2903 else if(strcmp(ptr
, "Step:") == 0)
2906 else if(strcmp(ptr
, "Pen:") == 0)
2909 else if (strcmp(ptr
, "Text:") == 0)
2914 // Create the control
2915 CProgressBar
*ctrl
= new CProgressBar(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, range
);
2919 ctrl
->origin(origin
);
2921 ctrl
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
2923 ctrl
->setStep( step
);
2924 ctrl
->setBackgroundColor( bkgRgba
);
2925 ctrl
->setBackgroundTexture( bkgTexture
);
2926 ctrl
->setProgressBarColor( barRgba
);
2927 ctrl
->setProgressBarTexture( barTexture
);
2929 CPen pen
= CInterfMngr::getPen(idPen
);
2930 ctrl
->shadow( pen
.shadow() );
2931 ctrl
->fontSize( pen
.fontSize() );
2932 ctrl
->color( pen
.color() );
2934 ctrl
->setText( CInterfMngr::getText(idText
).toString() );
2938 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
2941 parent
->addChild(ctrl
);
2942 ctrl
->parent(parent
);
2946 addChild(idCtrl
, ctrl
);
2948 }// getProgressBar //
2953 //-----------------------------------------------
2955 //-----------------------------------------------
2956 void COSD::getCastingBar(uint idCtrl
)
2958 uint bkgTexture
= 0;
2959 uint barTexture
= 0;
2967 CRGBA
bkgRgba(255,255,255,255);
2968 CRGBA
barRgba(255,255,255,255);
2970 // Lecture de la partie commune du script de control.
2971 CONTROL_SCRIPT_MACRO
2973 // Get the Texture for the progress bar
2974 else if(strcmp(ptr
, "BarTexture:") == 0)
2975 barTexture
= getInt();
2976 // Get the Texture for the background
2977 else if(strcmp(ptr
, "BackgroundTexture:") == 0)
2978 bkgTexture
= getInt();
2979 // Get the RGBA for the progress bar
2980 else if(strcmp(ptr
, "BarRGBA:") == 0)
2981 barRgba
= getRGBA();
2982 // Get the RGBA for the background
2983 else if(strcmp(ptr
, "BackgroundRGBA:") == 0)
2984 bkgRgba
= getRGBA();
2986 else if(strcmp(ptr
, "Range:") == 0)
2989 else if(strcmp(ptr
, "Step:") == 0)
2992 else if(strcmp(ptr
, "Pen:") == 0)
2995 else if (strcmp(ptr
, "Text:") == 0)
3000 // Create the control
3001 CCastingBar
*ctrl
= new CCastingBar(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, range
);
3005 ctrl
->origin(origin
);
3007 ctrl
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
3009 ctrl
->setStep( step
);
3010 ctrl
->setBackgroundColor( bkgRgba
);
3011 ctrl
->setBackgroundTexture( bkgTexture
);
3012 ctrl
->setProgressBarColor( barRgba
);
3013 ctrl
->setProgressBarTexture( barTexture
);
3015 CPen pen
= CInterfMngr::getPen(idPen
);
3016 ctrl
->shadow( pen
.shadow() );
3017 ctrl
->fontSize( pen
.fontSize() );
3018 ctrl
->color( pen
.color() );
3020 ctrl
->setText( CInterfMngr::getText(idText
).toString() );
3024 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
3027 parent
->addChild(ctrl
);
3028 ctrl
->parent(parent
);
3032 addChild(idCtrl
, ctrl
);
3034 }// getCastingBar //
3038 //-----------------------------------------------
3039 // getBrickControl :
3041 //-----------------------------------------------
3042 void COSD::getBrickControl(uint idCtrl
)
3051 // Lecture de la partie commune du script de control.
3052 CONTROL_SCRIPT_MACRO
3055 else if(strcmp(ptr
, "Texture:") == 0)
3056 idtexture
= getInt();
3058 else if(strcmp(ptr
, "RGBA:") == 0)
3061 /* // Get the function to execute on left click
3062 else if(strcmp(ptr, "LeftClickFunction:") == 0)
3063 leftFunc = getInt();
3064 // Get the function to execute on left click
3065 else if(strcmp(ptr, "RightClickFunction:") == 0)
3066 rightFunc = getInt();
3068 // tiled or stretched
3069 else if(strcmp(ptr, "Tiled:") == 0)
3077 // Create the control.
3078 CBrickControl
*brick
= new CBrickControl(idCtrl
, x
, y
, xPixel
, yPixel
, w
, h
, wPixel
, hPixel
, leftFunc
, rightFunc
);
3081 brick
->origin(origin
);
3083 brick
->ref(_X_Display
, _Y_Display
, _W_Display
, _H_Display
);
3087 CControl
*parent
= CInterfMngr::getCtrl(idParent
);
3090 parent
->addChild(brick
);
3091 brick
->parent(parent
);
3097 addChild(idCtrl
, brick
);
3099 }// getBrickControl //
3105 //-----------------------------------------------
3108 //-----------------------------------------------
3109 void COSD::open(ifstream
&file
)
3111 char tmpBuff
[_MAX_LINE_SIZE
];
3112 char delimiter
[] = "[] \t";
3115 // While it's not the end of the file.
3118 file
.getline(tmpBuff
, _MAX_LINE_SIZE
);
3121 char *key
= strtok(tmpBuff
, delimiter
);
3123 // if the first char is a / then this is a comment line, skip it and go to next line
3124 if ((key
!= NULL
) && (*key
) != '/' )
3127 uint idCtrl
= atoi(key
);
3128 switch(CInterfMngr::getType(idCtrl
))
3130 // The control is a Text.
3131 case CInterfMngr::CtrlText
:
3135 // The control is a Capture.
3136 case CInterfMngr::CtrlCapture
:
3140 // The control is a Button.
3141 case CInterfMngr::CtrlButton
:
3145 // The control is a Radio Button.
3146 case CInterfMngr::CtrlRadioButton
:
3147 getRadioButton(idCtrl
);
3150 // The control is a Radio Controller
3151 case CInterfMngr::CtrlRadioController
:
3152 getRadioController(idCtrl
);
3155 // The control is a Bitmap.
3156 case CInterfMngr::CtrlBitmap
:
3160 // The control is a List.
3161 case CInterfMngr::CtrlList
:
3165 // The control is a MultiList.
3166 case CInterfMngr::CtrlMultiList
:
3167 getMultiList(idCtrl
);
3170 // The control is a ChatBox.
3171 case CInterfMngr::CtrlChat
:
3175 // The control is a ChatInput.
3176 case CInterfMngr::CtrlChatInput
:
3177 getChatInput(idCtrl
);
3180 // The control is a ChoiceList
3181 case CInterfMngr::CtrlChoiceList
:
3182 getChoiceList(idCtrl
);
3185 // The control is a CandidateList
3186 case CInterfMngr::CtrlCandidateList
:
3187 getCandidateList(idCtrl
);
3190 // The control is an HorizontalList
3191 case CInterfMngr::CtrlHorizontalList
:
3192 getHorizontalList(idCtrl
);
3195 // The control is an ControlList
3196 case CInterfMngr::CtrlControlList
:
3197 getControlList(idCtrl
);
3200 // The control is an SpellList
3201 case CInterfMngr::CtrlSpellList
:
3202 getSpellList(idCtrl
);
3205 // The control is an ProgressBar
3206 case CInterfMngr::CtrlProgressBar
:
3207 getProgressBar(idCtrl
);
3210 // The control is an CastingBar
3211 case CInterfMngr::CtrlCastingBar
:
3212 getCastingBar(idCtrl
);
3215 // The control is a brick control
3216 case CInterfMngr::CtrlBrick
:
3217 getBrickControl(idCtrl
);
3220 // The control is a Unknown.
3222 nlerror("Line %d : ID %d is undeclared in \"ctrls.txt\" OR the type is unknown !!", line
, idCtrl
);
3228 uint32 width
, height
;
3229 CInterfMngr::getWindowSize(width
, height
);
3230 resize(width
, height
);