Changeset 9671 for code/branches/libs/src/libraries
- Timestamp:
- Sep 8, 2013, 7:30:20 PM (11 years ago)
- Location:
- code/branches/libs/src/libraries/core
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/libs/src/libraries/core/GUIManager.cc
r9670 r9671 230 230 if (id == Ogre::RENDER_QUEUE_OVERLAY && invocation.empty()) 231 231 { 232 #if CEGUI_VERSION >= 0x000800 233 CEGUI::System::getSingleton().renderAllGUIContexts(); 234 #else 232 235 CEGUI::System::getSingleton().renderGUI(); 236 #endif 233 237 234 238 // Important workaround! (at least required by CEGUI 0.7.5) … … 354 358 355 359 // Align CEGUI mouse with OIS mouse 360 #if CEGUI_VERSION >= 0x000800 361 guiSystem_->getDefaultGUIContext().injectMousePosition((float)mousePosition.first, (float)mousePosition.second); 362 #else 356 363 guiSystem_->injectMousePosition((float)mousePosition.first, (float)mousePosition.second); 364 #endif 357 365 358 366 // Initialise the Lua framework and load the schemes … … 366 374 this->menuRootWindow_ = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "MenuRootWindow"); 367 375 // And connect them 376 #if CEGUI_VERSION >= 0x000800 377 CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(this->rootWindow_); 378 this->rootWindow_->addChild(this->hudRootWindow_); 379 this->rootWindow_->addChild(this->menuRootWindow_); 380 #else 368 381 CEGUI::System::getSingleton().setGUISheet(this->rootWindow_); 369 382 this->rootWindow_->addChildWindow(this->hudRootWindow_); 370 383 this->rootWindow_->addChildWindow(this->menuRootWindow_); 384 #endif 371 385 372 386 // No background to start with (sets the alpha value to 0) … … 435 449 { 436 450 assert(guiSystem_); 437 this->protectedC all(boost::bind(&CEGUI::System::injectTimePulse, _1, time.getDeltaTime()));451 this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectTimePulse, _1, time.getDeltaTime())); 438 452 } 439 453 … … 610 624 void GUIManager::buttonPressed(const KeyEvent& evt) 611 625 { 612 this->protectedCall(boost::bind(&CEGUI::System::injectKeyDown, _1, evt.getKeyCode())); 613 this->protectedCall(boost::bind(&CEGUI::System::injectChar, _1, evt.getText())); 626 #if CEGUI_VERSION >= 0x000800 627 this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectKeyDown, _1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work? 628 this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectChar, _1, evt.getText())); 629 #else 630 this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectKeyDown, _1, evt.getKeyCode())); 631 this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectChar, _1, evt.getText())); 632 #endif 614 633 } 615 634 616 635 void GUIManager::buttonReleased(const KeyEvent& evt) 617 636 { 618 this->protectedCall(boost::bind(&CEGUI::System::injectKeyUp, _1, evt.getKeyCode())); 637 #if CEGUI_VERSION >= 0x000800 638 this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectKeyUp, _1, (CEGUI::Key::Scan) evt.getKeyCode())); // TODO: will this cast always work? 639 #else 640 this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectKeyUp, _1, evt.getKeyCode())); 641 #endif 619 642 } 620 643 … … 630 653 void GUIManager::buttonPressed(MouseButtonCode::ByEnum id) 631 654 { 632 this->protectedCall(boost::bind(&CEGUI::System::injectMouseButtonDown, _1, convertButton(id))); 655 #if CEGUI_VERSION >= 0x000800 656 this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseButtonDown, _1, convertButton(id))); 657 #else 658 this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseButtonDown, _1, convertButton(id))); 659 #endif 633 660 } 634 661 … … 644 671 void GUIManager::buttonReleased(MouseButtonCode::ByEnum id) 645 672 { 646 this->protectedCall(boost::bind(&CEGUI::System::injectMouseButtonUp, _1, convertButton(id))); 673 #if CEGUI_VERSION >= 0x000800 674 this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseButtonUp, _1, convertButton(id))); 675 #else 676 this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseButtonUp, _1, convertButton(id))); 677 #endif 647 678 } 648 679 649 680 void GUIManager::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) 650 681 { 651 this->protectedCall(boost::bind(&CEGUI::System::injectMousePosition, _1, (float)abs.x, (float)abs.y)); 682 #if CEGUI_VERSION >= 0x000800 683 this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMousePosition, _1, (float)abs.x, (float)abs.y)); 684 #else 685 this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMousePosition, _1, (float)abs.x, (float)abs.y)); 686 #endif 652 687 } 653 688 654 689 void GUIManager::mouseScrolled(int abs, int rel) 655 690 { 656 this->protectedCall(boost::bind(&CEGUI::System::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_)); 691 #if CEGUI_VERSION >= 0x000800 692 this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_)); 693 #else 694 this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseWheelChange, _1, (float)sgn(rel) * this->numScrollLines_)); 695 #endif 657 696 } 658 697 … … 662 701 void GUIManager::mouseLeft() 663 702 { 664 this->protectedCall(boost::bind(&CEGUI::System::injectMouseLeaves, _1)); 703 #if CEGUI_VERSION >= 0x000800 704 this->protectedCeguiContextCall(boost::bind(&CEGUI::GUIContext::injectMouseLeaves, _1)); 705 #else 706 this->protectedCeguiSystemCall(boost::bind(&CEGUI::System::injectMouseLeaves, _1)); 707 #endif 665 708 } 666 709 … … 714 757 True if input was handled, false otherwise. A caught exception yields true. 715 758 */ 716 template <typename FunctionType >717 bool GUIManager::protectedCall(FunctionType function )759 template <typename FunctionType, typename ObjectType> 760 bool GUIManager::protectedCall(FunctionType function, ObjectType object) 718 761 { 719 762 try 720 763 { 721 return function( this->guiSystem_);764 return function(object); 722 765 } 723 766 catch (CEGUI::ScriptException& ex) … … 728 771 } 729 772 } 773 774 template <typename FunctionType> 775 bool GUIManager::protectedCeguiSystemCall(FunctionType function) 776 { 777 return this->protectedCall(function, this->guiSystem_); 778 } 779 780 #if CEGUI_VERSION >= 0x000800 781 template <typename FunctionType> 782 bool GUIManager::protectedCeguiContextCall(FunctionType function) 783 { 784 return this->protectedCall(function, this->guiSystem_->getDefaultGUIContext()); 785 } 786 #endif 730 787 731 788 /** … … 784 841 void GUIManager::windowResized(unsigned int newWidth, unsigned int newHeight) 785 842 { 843 #if CEGUI_VERSION >= 0x000800 844 this->guiRenderer_->setDisplaySize(CEGUI::Sizef((float)newWidth, (float)newHeight)); 845 #else 786 846 this->guiRenderer_->setDisplaySize(CEGUI::Size((float)newWidth, (float)newHeight)); 847 #endif 787 848 } 788 849 … … 834 895 return; 835 896 897 #if CEGUI_VERSION >= 0x000800 898 CEGUI::FontManager::getSingleton().createFreeTypeFont(name, (float)size, true, fontName, "", CEGUI::ASM_Both, CEGUI::Sizef(800.0f, 600.0f)); 899 #else 836 900 CEGUI::FontManager::getSingleton().createFreeTypeFont(name, (float)size, true, fontName, "", true, 800.0f, 600.0f); 901 #endif 837 902 #endif 838 903 } -
code/branches/libs/src/libraries/core/GUIManager.h
r9670 r9671 156 156 void executeCode(const std::string& str); 157 157 158 template <typename FunctionType, typename ObjectType> 159 bool protectedCall(FunctionType function, ObjectType object); 160 158 161 template <typename FunctionType> 159 bool protectedCall(FunctionType function); 162 bool protectedCeguiSystemCall(FunctionType function); 163 164 #if CEGUI_VERSION >= 0x000800 165 template <typename FunctionType> 166 bool protectedCeguiContextCall(FunctionType function); 167 #endif 160 168 161 169 void changedCeguiOutputLevel();
Note: See TracChangeset
for help on using the changeset viewer.