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"
30 #include "interfaces_manager.h"
31 #include "interf_script.h"
39 using namespace NLMISC
;
47 extern UDriver
*Driver
;
54 CInterfMngr::TMapCtrls
CInterfMngr::_Ctrls
;
55 CInterfMngr::TMapTexts
CInterfMngr::_Texts
;
56 CInterfMngr::TMapTextures
CInterfMngr::_Textures
;
57 CInterfMngr::TMapPens
CInterfMngr::_Pens
;
58 CPen
CInterfMngr::_DefaultPen
;
59 CInterfMngr::TMapButtons
CInterfMngr::_Buttons
;
60 CButtonBase
CInterfMngr::_DefaultButton
;
62 CInterfMngr::TMapFuncCtrl
CInterfMngr::_CtrlFunctions
;
64 CInterfMngr::TMapWindows
CInterfMngr::_Windows
;
65 CInterfMngr::TOSD
CInterfMngr::_OSD
;
66 CInterfMngr::TUint
CInterfMngr::_OSDWaitingDestruction
;
67 CInterfMngr::TOSD
CInterfMngr::_OSDWaitingInsertion
;
69 CInterfMngr::TMapOSDBase
CInterfMngr::_OSDLook
;
70 COSDBase
CInterfMngr::_DefaultOSDLook
;
72 uint32
CInterfMngr::_WindowSizeX
;
73 uint32
CInterfMngr::_WindowSizeY
;
79 //-----------------------------------------------
81 // Initialize the interfaces manager.
82 //-----------------------------------------------
83 void CInterfMngr::init(const CInterfMngr::TMapFuncCtrl
&funcCtrlMap
, uint32 width
, uint32 height
)
86 _WindowSizeY
= height
;
94 setFuncCtrl(funcCtrlMap
);
97 //-----------------------------------------------
99 // Release all the interface.
100 //-----------------------------------------------
101 void CInterfMngr::release()
104 for(TMapOSDBase::iterator itOSDLook
= _OSDLook
.begin(); itOSDLook
!= _OSDLook
.end(); ++itOSDLook
)
106 if((*itOSDLook
).second
)
108 delete (*itOSDLook
).second
;
109 (*itOSDLook
).second
= 0;
115 for(TMapWindows::iterator it
= _Windows
.begin(); it
!= _Windows
.end(); ++it
)
123 // Clear all Container
126 _OSDWaitingDestruction
.clear();
127 _OSDWaitingInsertion
.clear();
128 _CtrlFunctions
.clear();
131 //-----------------------------------------------
133 // Load the array to convert a control id into a control type.
134 //-----------------------------------------------
135 void CInterfMngr::loadCtrls()
137 string interfaceFile
= CPath::lookup("ctrls.txt");
138 ifstream
file(interfaceFile
.c_str(), ios::in
);
143 char tmpBuff
[_MAX_LINE_SIZE
];
144 char delimiterBox
[] = "[] \t";
149 file
.getline(tmpBuff
, _MAX_LINE_SIZE
);
152 char *key
= strtok(tmpBuff
, delimiterBox
);
154 // the character '/' is used to indicate comments in the controls txt file
155 if( (key
!= NULL
) && (*key
) != '/' )
158 // If the ID != 0 -> ID Valide.
161 str
= strtok(NULL
, delimiterBox
);
164 if(strcmp(str
, "TEXT") == 0)
165 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlText
));
166 else if(strcmp(str
, "CAPTURE") == 0)
167 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlCapture
));
168 else if(strcmp(str
, "BUTTON") == 0)
169 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlButton
));
170 else if(strcmp(str
, "RADIO_CONTROLLER") == 0)
171 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlRadioController
));
172 else if(strcmp(str
, "RADIO_BUTTON") == 0)
173 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlRadioButton
));
174 else if(strcmp(str
, "BITMAP") == 0)
175 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlBitmap
));
176 else if(strcmp(str
, "LIST") == 0)
177 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlList
));
178 else if(strcmp(str
, "MULTI_LIST") == 0)
179 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlMultiList
));
180 else if(strcmp(str
, "CHAT") == 0)
181 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlChat
));
182 else if(strcmp(str
, "CHAT_INPUT") == 0)
183 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlChatInput
));
184 else if(strcmp(str
, "CHOICE_LIST") == 0)
185 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlChoiceList
));
186 else if(strcmp(str
, "CANDIDATE_LIST") == 0)
187 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlCandidateList
));
188 else if(strcmp(str
, "HORIZONTAL_LIST") == 0)
189 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlHorizontalList
));
190 else if(strcmp(str
, "CONTROL_LIST") == 0)
191 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlControlList
));
192 else if(strcmp(str
, "SPELL_LIST") == 0)
193 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlSpellList
));
194 else if(strcmp(str
, "PROGRESS_BAR") == 0)
195 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlProgressBar
));
196 else if(strcmp(str
, "CASTING_BAR") == 0) // TEMP
197 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlCastingBar
));
198 else if(strcmp(str
, "BRICK_CONTROL") == 0)
199 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlBrick
));
201 _Ctrls
.insert(TMapCtrls::value_type(id
, CtrlUnknown
));
204 // ID is not Valide 0 is reserved for the OSD.
207 nlerror("\"ctrls.txt\": Line %d : 0 must not be used for a control ID !!", line
);
216 //-----------------------------------------------
218 // Load The look of OSDs.
219 //-----------------------------------------------
220 void CInterfMngr::loadOSDLook()
222 string interfaceFile
= CPath::lookup("OSDs.txt");
223 ifstream
file(interfaceFile
.c_str(), ios::in
);
228 char tmpBuff
[_MAX_LINE_SIZE
];
229 char delimiter
[] = "[] \t";
232 bool defaultCase
= false;
235 COSD::TBG bgMode
= COSD::BG_none
;
239 COSD::TTB tbMode
= COSD::TB_none
;
251 // While the end of the file is not reached.
254 // Get a line (the line should not be more than _MAX_LINE_SIZE).
255 file
.getline(tmpBuff
, _MAX_LINE_SIZE
);
258 ptr
= strtok(tmpBuff
, delimiter
);
259 // If empty line -> next line.
263 // If the id == "..." -> default case.
264 if(strcmp(ptr
, "...") == 0)
275 // Get the first token delimited by the characters in delimiter.
276 ptr
= strtok(NULL
, delimiter
);
279 // Get the Background Mode.
280 if(strcmp(ptr
, "BG_Mode:") == 0)
281 bgMode
= getBGMode();
283 else if(strcmp(ptr
, "BG_Bitmap:") == 0)
286 else if(strcmp(ptr
, "BG_Color:") == 0)
289 // Get the Title Bar Mode.
290 else if(strcmp(ptr
, "TB_Mode:") == 0)
291 tbMode
= getTBMode();
293 else if(strcmp(ptr
, "TB_Bitmap:") == 0)
296 else if(strcmp(ptr
, "TB_Color:") == 0)
299 else if(strcmp(ptr
, "TB_Pen:") == 0)
303 else if(strcmp(ptr
, "HL_Pen:") == 0)
306 else if(strcmp(ptr
, "HL_Color:") == 0)
310 else if(strcmp(ptr
, "RS_Pen:") == 0)
313 else if(strcmp(ptr
, "RS_Color:") == 0)
317 ptr
= strtok(NULL
, delimiter
);
321 // Set the Default Pen.
324 _DefaultOSDLook
._BG_Mode
= bgMode
;
325 _DefaultOSDLook
._BG
= bg
;
326 _DefaultOSDLook
._BG_Color
= bgColor
;
328 _DefaultOSDLook
._TB_Mode
= tbMode
;
329 _DefaultOSDLook
._TB
= tb
;
330 _DefaultOSDLook
._TB_Color
= tbColor
;
331 _DefaultOSDLook
._TB_Pen
= getPen(tbPen
);
333 _DefaultOSDLook
._HL_Size
= (float)hlSize
;
334 _DefaultOSDLook
._HL_Color
= hlColor
;
336 _DefaultOSDLook
._RS_Size
= (float)rsSize
;
337 _DefaultOSDLook
._RS_Color
= rsColor
;
339 // Set specific Pens.
342 COSDBase
*osdBase
= new COSDBase
;
343 osdBase
->_BG_Mode
= bgMode
;
345 osdBase
->_BG_Color
= bgColor
;
347 osdBase
->_TB_Mode
= tbMode
;
349 osdBase
->_TB_Color
= tbColor
;
350 osdBase
->_TB_Pen
= getPen(tbPen
);
352 osdBase
->_HL_Size
= (float)hlSize
;
353 osdBase
->_HL_Color
= hlColor
;
355 osdBase
->_RS_Size
= (float)rsSize
;
356 osdBase
->_RS_Color
= rsColor
;
359 _OSDLook
.insert(TMapOSDBase::value_type(id
, osdBase
));
368 //-----------------------------------------------
371 //-----------------------------------------------
372 void CInterfMngr::loadTexts()
374 string interfaceFile
= CPath::lookup("texts.txt");
375 ifstream
file(interfaceFile
.c_str(), ios::in
);
380 char tmpBuff
[_MAX_LINE_SIZE
];
381 char delimiterBox
[] = "[]";
385 file
.getline(tmpBuff
, _MAX_LINE_SIZE
);
387 char *key
= strtok( tmpBuff
, delimiterBox
);
391 str
= strtok( NULL
, delimiterBox
);
393 _Texts
.insert(TMapTexts::value_type(id
, ucstring(str
)));
400 //-----------------------------------------------
402 // Load all textures needed for the interfaces.
403 //-----------------------------------------------
404 void CInterfMngr::loadTextures()
406 /* string interfaceFile = CPath::lookup("textures.txt");
407 ifstream file(interfaceFile.c_str(), ios::in);
412 char tmpBuff[_MAX_LINE_SIZE];
413 char delimiterBox[] = "[]";
417 file.getline(tmpBuff, _MAX_LINE_SIZE);
419 char *key = strtok( tmpBuff, delimiterBox);
423 str = strtok( NULL, delimiterBox);
426 _Textures.insert(TMapTextures::value_type(id, Driver->createTextureFile(string(str))));
436 //-----------------------------------------------
438 // Load Pens from file.
439 //-----------------------------------------------
440 void CInterfMngr::loadPens()
442 string interfaceFile
= CPath::lookup("pens.txt");
443 ifstream
file(interfaceFile
.c_str(), ios::in
);
445 // Try to open the file.
448 char tmpBuff
[_MAX_LINE_SIZE
];
449 char delimiterBox
[] = "[] \t";
451 // While the end of the file is not reached.
454 // Get a line (teh line should not be more than _MAX_LINE_SIZE).
455 file
.getline(tmpBuff
, _MAX_LINE_SIZE
);
456 // Get the first token delimited by the characters in delimiterBox.
457 char *token
= strtok(tmpBuff
, delimiterBox
);
460 uint32 fontSize
= 20;
467 bool defaultCase
= false;
470 // If the id == "..." -> default case.
471 if(strcmp(token
, "...") == 0)
482 // Get the font size.
483 token
= strtok(NULL
, delimiterBox
);
485 fontSize
= atoi(token
);
487 // Get the text color
488 token
= strtok(NULL
, delimiterBox
);
491 token
= strtok(NULL
, delimiterBox
);
494 token
= strtok(NULL
, delimiterBox
);
497 token
= strtok(NULL
, delimiterBox
);
502 token
= strtok(NULL
, delimiterBox
);
512 // Set the Default Pen.
515 _DefaultPen
.color(CRGBA(r
,g
,b
,a
));
516 _DefaultPen
.fontSize(fontSize
);
517 _DefaultPen
.shadow(shadow
);
519 // Set specific Pens.
523 _Pens
.insert(TMapPens::value_type(id
, new CPen(fontSize
, CRGBA(r
,g
,b
,a
), shadow
)));
532 //-----------------------------------------------
534 // Load Buttons from file.
535 //-----------------------------------------------
536 void CInterfMngr::loadButtons()
538 string interfaceFile
= CPath::lookup("buttons.txt");
539 ifstream
file(interfaceFile
.c_str(), ios::in
);
541 // Try to open the file.
544 char tmpBuff
[_MAX_LINE_SIZE
];
545 char delimiter
[] = "[] \t";
547 // While the end of the file is not reached.
550 // Get a line (teh line should not be more than _MAX_LINE_SIZE).
551 file
.getline(tmpBuff
, _MAX_LINE_SIZE
);
552 // Get the first token delimited by the characters in delimiter.
553 char *token
= strtok(tmpBuff
, delimiter
);
560 bool defaultCase
= false;
566 CButtonBase::TBG bgOn
= CButtonBase::BG_stretch
;
567 CButtonBase::TBG bgOff
= CButtonBase::BG_stretch
;
568 CButtonBase::TBG bgDisable
= CButtonBase::BG_stretch
;
571 // If the id == "..." -> default case.
572 if(strcmp(token
, "...") == 0)
583 char *ptr
= strtok(NULL
, delimiter
);
586 if (strcmp(ptr
, "BG_Mode_On:") == 0)
588 else if(strcmp(ptr
, "BG_Mode_Off:") == 0)
589 bgOff
= getBGMode2();
590 else if(strcmp(ptr
, "BG_Mode_Dis:") == 0)
591 bgDisable
= getBGMode2();
593 else if(strcmp(ptr
, "t_On:") == 0)
595 else if(strcmp(ptr
, "t_Off:") == 0)
597 else if(strcmp(ptr
, "t_Dis:") == 0)
600 else if(strcmp(ptr
, "RGBA_On:") == 0)
602 else if(strcmp(ptr
, "RGBA_Off:") == 0)
604 else if(strcmp(ptr
, "RGBA_Dis:") == 0)
605 rgbaDisable
= getRGBA();
608 ptr
= strtok(NULL
, delimiter
);
611 // Set the Default Pen.
614 _DefaultButton
.colorOn(rgbaOn
);
615 _DefaultButton
.colorOff(rgbaOff
);
616 _DefaultButton
.colorDisable(rgbaDisable
);
617 _DefaultButton
.textureOn(tON
);
618 _DefaultButton
.textureOff(tOFF
);
619 _DefaultButton
.textureDisable(tDIS
);
620 _DefaultButton
.bgModeOn(bgOn
);
621 _DefaultButton
.bgModeOff(bgOff
);
622 _DefaultButton
.bgModeDisable(bgDisable
);
624 // Set specific Pens.
627 // Insert the button.
628 CButtonBase
*button
= new CButtonBase(tON
, tOFF
, tDIS
, rgbaOn
, rgbaOff
, rgbaDisable
);
631 button
->bgModeOn(bgOn
);
632 button
->bgModeOff(bgOff
);
633 button
->bgModeDisable(bgDisable
);
635 _Buttons
.insert(TMapButtons::value_type(id
, button
));
643 //-----------------------------------------------
645 // Pointer on an array of TFuncCtrl.
646 //-----------------------------------------------
647 void CInterfMngr::setFuncCtrl(const TMapFuncCtrl
&funcCtrlMap
)
649 _CtrlFunctions
= funcCtrlMap
;
655 //-----------------------------------------------
657 // Get the type of the control.
658 //-----------------------------------------------
659 CInterfMngr::TTypCtrl
CInterfMngr::getType(uint id
)
661 TMapCtrls::iterator it
= _Ctrls
.find(id
);
662 if(it
!= _Ctrls
.end())
668 //-----------------------------------------------
670 // Return the text corresponding to the Id.
671 //-----------------------------------------------
672 ucstring
CInterfMngr::getText(uint id
)
674 TMapTexts::iterator it
= _Texts
.find(id
);
675 if(it
!= _Texts
.end())
681 //-----------------------------------------------
683 // Return the texture file Corresponding to the id.
684 //-----------------------------------------------
685 UTextureFile
* CInterfMngr::getTexture(uint id
)
687 TMapTextures::iterator it
= _Textures
.find(id
);
688 if(it
!= _Textures
.end())
694 //-----------------------------------------------
696 // Get the right Pen for the control.
697 //-----------------------------------------------
698 CPen
CInterfMngr::getPen(uint id
)
700 TMapPens::iterator it
= _Pens
.find(id
);
701 if(it
!= _Pens
.end())
702 return *((*it
).second
);
707 //-----------------------------------------------
709 // Get the right Button for the control.
710 //-----------------------------------------------
711 CButtonBase
CInterfMngr::getButton(uint id
)
713 TMapButtons::iterator it
= _Buttons
.find(id
);
714 if(it
!= _Buttons
.end())
715 return *((*it
).second
);
717 return _DefaultButton
;
720 //-----------------------------------------------
723 //-----------------------------------------------
724 CControl
* CInterfMngr::getCtrl(uint idCtrl
)
727 TMapWindows::iterator itE
= _Windows
.end();
728 for(TMapWindows::iterator it
= _Windows
.begin(); it
!= itE
; ++it
)
730 ctrl
= ((*it
).second
)->getCtrl(idCtrl
);
735 // Return the pointer of the control "id" or 0 if the control "id" doesn't exit.
740 //-----------------------------------------------
743 //-----------------------------------------------
744 COSDBase
CInterfMngr::getOSDLook(uint id
)
746 TMapOSDBase::iterator it
= _OSDLook
.find(id
);
747 if(it
!= _OSDLook
.end())
748 return *((*it
).second
);
750 return _DefaultOSDLook
;
756 //-----------------------------------------------
758 // Create the OSD "id".
759 //-----------------------------------------------
760 COSD
* CInterfMngr::createOSD(uint id
, bool popUp
)
765 sprintf(filename
,"%d.txt", id
);
766 string interfaceFile
= CPath::lookup(filename
);
767 ifstream
file(interfaceFile
.c_str(), ios::in
);
772 char tmpBuff
[_MAX_LINE_SIZE
];
773 char delimiter
[] = "[] \t";
779 float minWidth
= 0.f
;
780 float minHeight
= 0.f
;
783 COSD::TBG bgMode
= COSD::BG_none
;
785 file
.getline(tmpBuff
, _MAX_LINE_SIZE
);
787 char *ptr
= strtok(tmpBuff
, delimiter
);
790 // Get the pos X of the OSD.
791 if(strcmp(ptr
, "X:") == 0)
793 // Get the pos Y of the OSD.
794 else if(strcmp(ptr
, "Y:") == 0)
796 // Get the Width of the OSD.
797 else if(strcmp(ptr
, "Width:") == 0)
799 // Get the Height of the OSD.
800 else if(strcmp(ptr
, "Height:") == 0)
802 // Get the MinWidth of the OSD.
803 else if(strcmp(ptr
, "MinWidth:") == 0)
804 minWidth
= getFloat();
805 // Get the MinHeight of the OSD.
806 else if(strcmp(ptr
, "MinHeight:") == 0)
807 minHeight
= getFloat();
808 // Get the function to call each frame.
809 else if(strcmp(ptr
, "Function:") == 0)
811 // Get the function to call each frame.
812 else if(strcmp(ptr
, "Name:") == 0)
814 // Get Background Mode.
815 else if(strcmp(ptr
, "BG_Mode:") == 0)
816 bgMode
= getBGMode();
819 ptr
= strtok(NULL
, delimiter
);
822 // Create the window.
823 win
= new COSD(id
, x
, y
, 0.f
, 0.f
, 0.f
, 0.f
, width
, height
, minWidth
, minHeight
, popUp
);
826 COSDBase osdLook
= getOSDLook(id
);
828 // Set the Background display mode.
829 win
->bgMode(osdLook
._BG_Mode
);
830 // Set the BG Texture.
831 win
->bg(osdLook
._BG
);
833 win
->bgColor(osdLook
._BG_Color
);
835 // Set the Title Bar display mode.
836 win
->tbMode(osdLook
._TB_Mode
);
837 // Set the TB Texture.
838 win
->tb(osdLook
._TB
);
840 win
->tbColor(osdLook
._TB_Color
);
842 win
->tbPen(osdLook
._TB_Pen
);
844 // Set the HighLight Size.
845 win
->hlSize(osdLook
._HL_Size
);
847 win
->hlColor(osdLook
._HL_Color
);
849 // Set the Resize Size.
850 win
->rsSize(osdLook
._RS_Size
);
852 win
->rsColor(osdLook
._RS_Color
);
854 // win->osdMode(COSD::locked);
855 // Change the OSD Name.
856 win
->osdName(getText(name
));
858 // Add the OSD to the OSD that are waiting insertion
859 _Windows
.insert( TMapWindows::value_type( id
, win
) );
860 _OSDWaitingInsertion
.push_back( win
);
865 // win->osdSetPosition(0.f, 0.f);
866 // win->osdSetSize(1.f,1.f);
876 //-----------------------------------------------
878 // Delete the OSD "id".
879 //-----------------------------------------------
880 void CInterfMngr::deleteOSD(uint id
)
882 // store it the list of OSD waiting destruction
883 _OSDWaitingDestruction
.push_back(id
);
888 //-----------------------------------------------
890 // The window size has changed -> resize interface.
891 //-----------------------------------------------
892 void CInterfMngr::resize(uint32 width
, uint32 height
)
894 _WindowSizeX
= width
;
895 _WindowSizeY
= height
;
897 // If the window is too small -> return;
898 if(_WindowSizeX
==0 || _WindowSizeY
==0)
901 // Update the interface.
902 for(TOSD::iterator it
= _OSD
.begin(); it
!= _OSD
.end(); it
++)
904 // Resize all controls.
905 (*it
)->resize(width
, height
);
910 //-----------------------------------------------
912 // Update Interfaces (for timer, etc.).
913 //-----------------------------------------------
914 void CInterfMngr::update(float x
, float y
)
918 // delete all the OSD waiting destruction
919 TUint::iterator itEID
= _OSDWaitingDestruction
.end();
920 TMapWindows::iterator itW
;
922 for (TUint::iterator itID
= _OSDWaitingDestruction
.begin() ; itID
!= itEID
; ++itID
)
925 itW
= _Windows
.find(*itID
);
926 if(itW
!= _Windows
.end())
929 COSD
*OSD
= (*itW
).second
;
934 // Find the OSD in the display list.
935 for(TOSD::iterator itOSD
= _OSD
.begin(); itOSD
!= _OSD
.end(); itOSD
++)
937 // if it's the right OSD -> erase.
954 _OSDWaitingDestruction
.clear();
957 // insert all OSD newly created
958 const TOSD::const_iterator itNewEnd
= _OSDWaitingInsertion
.end();
960 for (TOSD::const_iterator itNew
= _OSDWaitingInsertion
.begin() ; itNew
!= itNewEnd
; ++itNew
)
962 _OSD
.push_front((*itNew
));
965 _OSDWaitingInsertion
.clear();
967 // Update the interface.
968 // const TOSD::iterator itE = _OSD.end();
969 for(TOSD::iterator it
= _OSD
.begin(); it
!= _OSD
.end() ; ++it
)
971 if((*it
)->update(x
, y
, fullUse
))
976 //-----------------------------------------------
978 // Display the interfaces in progress.
979 //-----------------------------------------------
980 void CInterfMngr::display()
982 // If the window is too small -> return;
983 if(_WindowSizeX
==0 || _WindowSizeY
==0)
986 const TOSD::reverse_iterator itRE
= _OSD
.rend();
987 for(TOSD::reverse_iterator it
= _OSD
.rbegin(); it
!= itRE
; ++it
)
993 //-----------------------------------------------
995 // Return the cursor used by the interface at the moment.
996 // \return ECursor : 'Cur_None' if no cursor needed for the interface.
997 // \warning This method should be called after the update one to be up to date.
998 //-----------------------------------------------
999 COSD::ECursor
CInterfMngr::cursor()
1001 // If the window is too small -> return;
1002 if(_WindowSizeX
==0 || _WindowSizeY
==0)
1003 return COSD::Cur_None
;
1005 for(TOSD::iterator it
= _OSD
.begin(); it
!= _OSD
.end() ; ++it
)
1007 COSD::ECursor curs
= (*it
)->cursor();
1008 if(curs
!= COSD::Cur_None
)
1012 return COSD::Cur_None
;
1015 //-----------------------------------------------
1017 // Manage the mouse click.
1018 //-----------------------------------------------
1019 bool CInterfMngr::click(float x
, float y
)
1021 // If the window is too small -> return;
1022 if(_WindowSizeX
==0 || _WindowSizeY
==0)
1028 const TOSD::iterator itE
= _OSD
.end();
1029 TOSD::iterator itFrontOSD
= itE
;
1031 for(TOSD::iterator it
= _OSD
.begin(); it
!= itE
; ++it
)
1033 (*it
)->click(x
, y
, taken
);
1034 if( taken
&& (!focus
) )
1041 if (itFrontOSD
!= itE
)
1043 _OSD
.push_front(*itFrontOSD
);
1044 _OSD
.erase(itFrontOSD
);
1047 // Return if the click is taken by the interface.
1053 //-----------------------------------------------
1055 // Manage the mouse right click.
1056 //-----------------------------------------------
1057 bool CInterfMngr::clickRight(float x
, float y
)
1059 // If the window is too small -> return;
1060 if(_WindowSizeX
==0 || _WindowSizeY
==0)
1066 const TOSD::iterator itE
= _OSD
.end();
1067 TOSD::iterator itFrontOSD
= itE
;
1069 for(TOSD::iterator it
= _OSD
.begin(); it
!= itE
; ++it
)
1071 (*it
)->clickRight(x
, y
, taken
);
1072 if( taken
&& (!focus
) )
1079 if (itFrontOSD
!= itE
)
1081 _OSD
.push_front(*itFrontOSD
);
1082 _OSD
.erase(itFrontOSD
);
1085 // Return if the click is taken by the interface.
1090 //-----------------------------------------------
1092 // get the specified OSD adress
1093 //-----------------------------------------------
1094 COSD
* CInterfMngr::getOSD( uint id
)
1096 TMapWindows::const_iterator it
, itE
= _Windows
.end();
1098 it
= _Windows
.find( id
);
1101 return (*it
).second
;