void Application::initialiseResources() { CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider()); rp->setResourceGroupDirectory("schemes", "data/gui/schemes"); rp->setResourceGroupDirectory("imagesets", "data/gui/imagesets"); rp->setResourceGroupDirectory("fonts", "data/gui/fonts"); rp->setResourceGroupDirectory("layouts", "data/gui/layouts"); rp->setResourceGroupDirectory("looknfeels", "data/gui/looknfeel"); rp->setResourceGroupDirectory("lua_scripts", "data/gui/lua_scripts"); rp->setResourceGroupDirectory("schemas", "data/gui/xml_schemas"); rp->setResourceGroupDirectory("animations", "data/gui/animations"); CEGUI::ImageManager::setImagesetDefaultResourceGroup("imagesets"); CEGUI::Font::setDefaultResourceGroup("fonts"); CEGUI::Scheme::setDefaultResourceGroup("schemes"); CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels"); CEGUI::WindowManager::setDefaultResourceGroup("layouts"); CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts"); CEGUI::AnimationManager::setDefaultResourceGroup("animations"); CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser(); if (parser->isPropertyPresent("SchemaDefaultResourceGroup")) { parser->setProperty("SchemaDefaultResourceGroup", "schemas"); } }
bool CGUIDriverGL::Init( GUI::TWindowContextPtr windowContext ) { if ( !m_ceGuiInitialized ) { try { CEGUI::Sizef displaySize( (float) windowContext->GetWidth(), (float) windowContext->GetHeight() ); m_guiRenderer = &CEGUI::OpenGL3Renderer::create( displaySize );//, CEGUI::OpenGLRenderer::TTT_AUTO ); m_guiSystem = &CEGUI::System::create( *m_guiRenderer, &m_vfsResourceProvider, &m_xmlParserAdapter, m_imageCodecAdapter ); // setup default group for validation schemas CEGUI::XMLParser* parser = m_guiSystem->getXMLParser(); if ( nullptr != parser && parser->isPropertyPresent( "SchemaDefaultResourceGroup" ) ) parser->setProperty( "SchemaDefaultResourceGroup", m_schemasResourceGroup ); // Load the fonts CEGUI::FontManager::getSingleton().createAll( m_defaultFont, CEGUI::Font::getDefaultResourceGroup() ); // Load the scheme try { CEGUI::SchemeManager::getSingleton().createFromFile( "Generic.scheme" ); } catch ( CEGUI::Exception& e ) { CORE::CString info = e.getMessage() + " - at - " + e.getFileName() + ":" + e.getFunctionName() + ":" + CORE::UInt32ToString( e.getLine() ).STL_String(); GUCEF_EXCEPTION_LOG( CORE::LOGLEVEL_IMPORTANT, "Unhandled exception during CEGUI initialization: " + info ); } CEGUI::SchemeManager::getSingleton().createFromFile( m_schemeToUse ); // Set the defaults CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultFont( m_defaultFont ); CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage( m_defaultCursorImage ); CEGUI::Window* rootWindow = CEGUI::WindowManager::getSingleton().createWindow( "DefaultWindow", "root" ); CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow( rootWindow ); // clearing this queue actually makes sure it's created(!) CEGUI::System::getSingleton().getDefaultGUIContext().clearGeometry( CEGUI::RQ_OVERLAY ); m_ceGuiInitialized = true; } catch ( CEGUI::Exception& e ) { CORE::CString info = e.getMessage() + " - at - " + e.getFileName() + ":" + e.getFunctionName() + ":" + CORE::UInt32ToString( e.getLine() ).STL_String(); GUCEF_EXCEPTION_LOG( CORE::LOGLEVEL_IMPORTANT, "Unhandled exception during CEGUI initialization: " + info ); m_ceGuiInitialized = false; } } return m_ceGuiInitialized; }
void CEGUITestApplication::initialiseDefaultResourceGroups() { // set the default resource groups to be used CEGUI::ImageManager::setImagesetDefaultResourceGroup("imagesets"); CEGUI::Font::setDefaultResourceGroup("fonts"); CEGUI::Scheme::setDefaultResourceGroup("schemes"); CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels"); CEGUI::WindowManager::setDefaultResourceGroup("layouts"); CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts"); CEGUI::AnimationManager::setDefaultResourceGroup("animations"); // setup default group for validation schemas CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser(); if (parser->isPropertyPresent("SchemaDefaultResourceGroup")) parser->setProperty("SchemaDefaultResourceGroup", "schemas"); }
RenderWindow::RenderWindow(int width, int height, std::string name) : sf::RenderWindow(sf::VideoMode(width, height), name, sf::Style::Close | sf::Style::Titlebar) { elapsedclock = new sf::Clock; inpMan = new InputManager; glEnable(GL_TEXTURE_2D); CEGUI::OpenGLRenderer& renderer = CEGUI::OpenGLRenderer::bootstrapSystem(); CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider()); rp->setResourceGroupDirectory("schemes", GameManager::getGameFolderName() + "gui/schemes/"); rp->setResourceGroupDirectory("imagesets", GameManager::getGameFolderName() + "gui/imagesets/"); rp->setResourceGroupDirectory("fonts", GameManager::getGameFolderName() + "gui/fonts/"); rp->setResourceGroupDirectory("layouts", GameManager::getGameFolderName() + "gui/layouts/"); rp->setResourceGroupDirectory("looknfeels", GameManager::getGameFolderName() + "gui/looknfeel/"); rp->setResourceGroupDirectory("lua_scripts", GameManager::getGameFolderName() + "gui/lua_scripts/"); rp->setResourceGroupDirectory("falcon_scripts", GameManager::getGameFolderName() + "gui/falcon_scripts/"); rp->setResourceGroupDirectory("schemas", GameManager::getGameFolderName() + "gui/xml_schemas/"); CEGUI::ImageManager::setImagesetDefaultResourceGroup("imagesets"); CEGUI::Font::setDefaultResourceGroup("fonts"); CEGUI::Scheme::setDefaultResourceGroup("schemes"); CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels"); CEGUI::WindowManager::setDefaultResourceGroup("layouts"); CEGUI::ScriptModule::setDefaultResourceGroup("falcon_scripts"); CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser(); if(parser->isPropertyPresent("SchemaDefaultResourceGroup")) parser->setProperty("SchemaDefaultResourceGroup", "schemas"); #ifdef FALCON1 #else CEGUI::System::getSingleton().setScriptingModule(FalconScriptingModule::create()); #endif CEGUI::System::getSingleton().executeScriptFile("gui", "falcon_scripts"); this->setVerticalSyncEnabled(true); this->setFramerateLimit(60); // Remove and put to script ASAP loadScheme("TaharezLook"); loadFont("Inconsolata-14"); setArrowandTooltipScheme("TaharezLook"); // --END-- setupMap(); }
void GUIManager::init() { if (!mpGUIRenderer) { mpGUIRenderer = &CEGUI::OgreRenderer::bootstrapSystem(); #ifdef _DEBUG CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative); #endif // set the default resource groups to be used CEGUI::Imageset::setDefaultResourceGroup("imagesets"); CEGUI::Font::setDefaultResourceGroup("fonts"); CEGUI::Scheme::setDefaultResourceGroup("schemes"); CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeel"); CEGUI::WindowManager::setDefaultResourceGroup("layouts"); CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts"); // setup default group for validation schemas CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser(); if (parser->isPropertyPresent("SchemaDefaultResourceGroup")) parser->setProperty("SchemaDefaultResourceGroup", "schemas"); CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme"); // 加载GUI主题并设置默认参数 CEGUI::SchemeManager::getSingleton().create("VanillaSkin.scheme"); CEGUI::SchemeManager::getSingleton().create("WindowsLook.scheme"); //CEGUI::SchemeManager::getSingleton().create("TankWar.scheme"); CEGUI::SchemeManager::getSingleton().create("OgreTray.scheme"); CEGUI::System &sys = CEGUI::System::getSingleton(); //sys.setDefaultFont("BlueHighway-10"); sys.setDefaultTooltip("WindowsLook/Tooltip"); sys.setDefaultMouseCursor("TaharezLook","MouseArrow"); //setCursorType(CURSOR_NORMAL); showGUICursor(true); } }
void set_CEGUI_paths() { //Initialises the required directories for the DefaultResourceProvider: CEGUI::DefaultResourceProvider & defaultResProvider = * static_cast<CEGUI::DefaultResourceProvider*> ( CEGUI::System::getSingleton().getResourceProvider()) ; const string CEGUIInstallSharePath = CEGUIInstallBasePath + "/share/CEGUI/" ; //For each resource type, sets a corresponding resource group directory: cout << "Using scheme directory '" << CEGUIInstallSharePath + "schemes/" << "'" << endl ; defaultResProvider.setResourceGroupDirectory( "schemes", CEGUIInstallSharePath + "schemes/") ; defaultResProvider.setResourceGroupDirectory( "imagesets", CEGUIInstallSharePath + "imagesets/") ; defaultResProvider.setResourceGroupDirectory( "fonts", CEGUIInstallSharePath + "fonts/") ; defaultResProvider.setResourceGroupDirectory( "layouts", CEGUIInstallSharePath + "layouts/") ; defaultResProvider.setResourceGroupDirectory( "looknfeels", CEGUIInstallSharePath + "looknfeel/") ; defaultResProvider.setResourceGroupDirectory( "lua_scripts", CEGUIInstallSharePath + "lua_scripts/") ; defaultResProvider.setResourceGroupDirectory( "schemas", CEGUIInstallSharePath + "xml_schemas/") ; defaultResProvider.setResourceGroupDirectory( "animations", CEGUIInstallSharePath + "animations/") ; //Sets the default resource groups to be used: CEGUI::Imageset::setDefaultResourceGroup( "imagesets") ; CEGUI::Font::setDefaultResourceGroup( "fonts") ; CEGUI::Scheme::setDefaultResourceGroup( "schemes") ; CEGUI::WidgetLookManager::setDefaultResourceGroup( "looknfeels") ; CEGUI::WindowManager::setDefaultResourceGroup( "layouts") ; CEGUI::ScriptModule::setDefaultResourceGroup( "lua_scripts") ; CEGUI::AnimationManager::setDefaultResourceGroup( "animations") ; //Set-up default group for validation schemas: CEGUI::XMLParser * parser = CEGUI::System::getSingleton().getXMLParser() ; if ( parser->isPropertyPresent( "SchemaDefaultResourceGroup")) parser->setProperty( "SchemaDefaultResourceGroup", "schemas") ; }
void GUISystem::LoadResources() { // initialise the required dirs for the DefaultResourceProvider CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider()); rp->setResourceGroupDirectory("schemes", "./Data/Resources/UI/schemes/"); rp->setResourceGroupDirectory("imagesets", "./Data/Resources/UI/imagesets/"); rp->setResourceGroupDirectory("fonts", "./Data/Resources/UI/fonts/"); rp->setResourceGroupDirectory("layouts", "./Data/Resources/UI/layouts/"); rp->setResourceGroupDirectory("looknfeels", "./Data/Resources/UI/looknfeel/"); rp->setResourceGroupDirectory("lua_scripts", "./Data/Resources/UI/lua_scripts/"); rp->setResourceGroupDirectory("schemas", "./Data/Resources/UI/xml_schemas/"); //Initialize resources groups CEGUI::Imageset::setDefaultResourceGroup("imagesets"); CEGUI::Font::setDefaultResourceGroup("fonts"); CEGUI::Scheme::setDefaultResourceGroup("schemes"); CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels"); CEGUI::WindowManager::setDefaultResourceGroup("layouts"); CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser(); if (parser->isPropertyPresent("SchemaDefaultResourceGroup")) parser->setProperty("SchemaDefaultResourceGroup", "schemas"); }
void gameEngine::Init() { atexit(SDL_Quit); if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { fprintf( stderr, "Unable to init SDL: %s\n", SDL_GetError() ); exit( 1 ); } SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); // Attempt to create a window with the specified height and width. // If we fail, return error. if (FULLSCREEN) { if (!SDL_SetVideoMode(SCRWIDTH, SCRHEIGHT, 32, SDL_OPENGL | SDL_FULLSCREEN)) { fprintf(stderr, "Unable to set up video: %s\n", SDL_GetError()); exit(1); } } else { if (!SDL_SetVideoMode(SCRWIDTH, SCRHEIGHT, 32, SDL_OPENGL)) { fprintf(stderr, "Unable to set up video: %s\n", SDL_GetError()); exit(1); } } glShadeModel(GL_SMOOTH); glClearColor(0.1, 0.1, 0.1, 1); glViewport(0,0,SCRWIDTH,SCRHEIGHT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glDisable(GL_DEPTH_TEST); CEGUI::OpenGLRenderer::bootstrapSystem(CEGUI::Size(800,600), CEGUI::OpenGLRenderer::TTT_AUTO); CEGUI::DefaultResourceProvider * rp = (CEGUI::DefaultResourceProvider *)CEGUI::System::getSingleton().getResourceProvider(); rp->setResourceGroupDirectory("schemes", "/home/owen/Downloads/CEGUI-0.7.5/datafiles/schemes/"); rp->setResourceGroupDirectory("imagesets", "/home/owen/Downloads/CEGUI-0.7.5/datafiles/imagesets/"); rp->setResourceGroupDirectory("fonts", "/home/owen/Downloads/CEGUI-0.7.5/datafiles/fonts/"); rp->setResourceGroupDirectory("layouts", "/home/owen/Downloads/CEGUI-0.7.5/datafiles/layouts/"); rp->setResourceGroupDirectory("looknfeels", "/home/owen/Downloads/CEGUI-0.7.5/datafiles/looknfeel/"); rp->setResourceGroupDirectory("lua_scripts", "/home/owen/Downloads/CEGUI-0.7.5/datafiles/lua_scripts/"); rp->setResourceGroupDirectory("schemas", "/home/owen/Downloads/CEGUI-0.7.5/datafiles/xml_schemas/"); CEGUI::Imageset::setDefaultResourceGroup("imagesets"); CEGUI::Font::setDefaultResourceGroup("fonts"); CEGUI::Scheme::setDefaultResourceGroup("schemes"); CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels"); CEGUI::WindowManager::setDefaultResourceGroup("layouts"); CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts"); CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser(); if (parser->isPropertyPresent("SchemaDefaultResourceGroup")) parser->setProperty("SchemaDefaultResourceGroup", "schemas"); CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme"); CEGUI::System& sr = CEGUI::System::getSingleton(); sr.setDefaultMouseCursor("TaharezLook", "MouseArrow"); sr.setDefaultFont("DejaVuSans-10"); sr.setDefaultTooltip("TaharezLook/Tooltip"); SDL_ShowCursor(SDL_DISABLE); SDL_EnableUNICODE(1); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL); m_bQuit = false; }
void CEGUIManager::init() { CEGUI::OpenGLRenderer &m_renderer = CEGUI::OpenGLRenderer::bootstrapSystem(); { // initialise the required dirs for the DefaultResourceProvider CEGUI::DefaultResourceProvider *resourceProvider = static_cast<CEGUI::DefaultResourceProvider*> (CEGUI::System::getSingleton().getResourceProvider()); // set resource group directories. { CEGUI::DefaultResourceProvider* rp = resourceProvider; rp->setResourceGroupDirectory("schemes", "datafiles/schemes/"); rp->setResourceGroupDirectory("imagesets", "datafiles/imagesets/"); rp->setResourceGroupDirectory("fonts", "datafiles/fonts/"); rp->setResourceGroupDirectory("layouts", "datafiles/layouts/"); rp->setResourceGroupDirectory("looknfeels", "datafiles/looknfeel/"); rp->setResourceGroupDirectory("lua_scripts", "datafiles/lua_scripts/"); } // set default resource groups. { CEGUI::ImageManager::setImagesetDefaultResourceGroup("imagesets"); CEGUI::Font::setDefaultResourceGroup("fonts"); CEGUI::Scheme::setDefaultResourceGroup("schemes"); CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels"); CEGUI::WindowManager::setDefaultResourceGroup("layouts"); CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts"); // setup default group for validation schemas CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser(); if (parser->isPropertyPresent("SchemaDefaultResourceGroup")) parser->setProperty("SchemaDefaultResourceGroup", "schemas"); CEGUI::SchemeManager::getSingleton().createFromFile("TaharezLook.scheme"); CEGUI::SchemeManager::getSingleton().createFromFile("GameMenu.scheme"); CEGUI::SchemeManager::getSingleton().createFromFile("Generic.scheme"); CEGUI::SchemeManager::getSingleton().createFromFile("HUDDemo.scheme"); CEGUI::SchemeManager::getSingleton().createFromFile("WindowsLook.scheme"); CEGUI::SchemeManager::getSingleton().createFromFile("TestA.scheme"); } // Register custom objects with CEGUI: { // register custom objects with CEGUI. CEGUI::WindowFactoryManager::addFactory<CEGUI::TplWindowFactory<CEGUI::InventoryReceiver>>(); CEGUI::WindowFactoryManager::addFactory<CEGUI::TplWindowFactory<CEGUI::InventoryItem>>(); CEGUI::WindowRendererManager::addFactory<CEGUI::TplWindowRendererFactory<CEGUI::InventoryItemRenderer>>(); // load looknfeel for custom inventory components (needs TaharezLook images) CEGUI::WidgetLookManager::getSingleton().parseLookNFeelSpecificationFromFile("InventoryComponents.looknfeel"); // create mapping for the item type // This is the equivalent to the following entry in a scheme xml file: // <FalagardMapping WindowType="TaharezLook/InventoryItem" TargetType="InventoryItem" LookNFeel="TaharezLook/InventoryItem" Renderer="InventoryItemRenderer" /> CEGUI::WindowFactoryManager::getSingleton().addFalagardWindowMapping( "TaharezLook/InventoryItem", // type to create "InventoryItem", // 'base' widget type "TaharezLook/InventoryItem", // WidgetLook to use. "InventoryItemRenderer"); // WindowRenderer to use. } } CEGUI::System::getSingleton().getDefaultGUIContext(). getMouseCursor().setDefaultImage("TaharezLook/MouseArrow"); // Create windows { CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton(); CEGUI::Window* root = CEGUI::WindowManager::getSingleton().loadLayoutFromFile("test2.layout"); // test.layout CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(root); //CEGUI::Window *dragContainerTemplate = CEGUI::WindowManager::getSingleton().loadLayoutFromString(CEGUI::String( // "<Window type = \"Generic/Image\" name = \"Image\" >" // " <Property name = \"Area\" value = \"{{0,0},{0,0},{0,64},{0,128}}\" / >" // " <Property name = \"Image\" value = \"TestA2/MadBug\" / >" // " <Property name = \"MaxSize\" value = \"{{1,0},{1,0}}\" / >" // " <Property name = \"ClippedByParent\" value = \"false\" / >" // " <Property name = \"VerticalAlignment\" value = \"Centre\" / >" // " <Property name = \"HorizontalAlignment\" value = \"Centre\" / >" // " <Property name = \"MousePassThroughEnabled\" value = \"true\" / >" // "< / Window>")); //for (int i = 0; i < 10; ++i) { //} //// create a script module. //CEGUI::LuaScriptModule& scriptmod(CEGUI::LuaScriptModule::create()); //// tell CEGUI to use this scripting module //CEGUI::System::getSingleton().setScriptingModule(&scriptmod); //CEGUI::System::getSingleton().executeScriptFile("test2.lua"); // Inventory testing: { // Create Backpack window CEGUI::Window *inventoryImageWindow = root->getChild("Inventory"); CEGUI::Window* wnd = inventoryImageWindow;//wmgr.createWindow("TaharezLook/FrameWindow"); //root->addChild(wnd); /*wnd->setPosition(CEGUI::UVector2(CEGUI::UDim(0.1f, 0), CEGUI::UDim(0.1f, 0))); wnd->setSize(CEGUI::USize(CEGUI::UDim(0.2f, 0), CEGUI::UDim(0.4f, 0)));*/ wnd->setText("Backpack"); CEGUI::InventoryReceiver& receiver1 = dynamic_cast<CEGUI::InventoryReceiver&>(*wmgr.createWindow("InventoryReceiver")); wnd->addChild(&receiver1); receiver1.setPosition(CEGUI::UVector2(cegui_reldim(0.0f), cegui_reldim(0.0f))); receiver1.setSize(CEGUI::USize(cegui_reldim(1.0f), cegui_reldim(1.0f))); receiver1.setContentSize(20, 2); receiver1.setUserString("BlockImage", "TestA2/InventorySlot"); // Create vault window CEGUI::Window* wnd2 = wmgr.createWindow("TestA2/InventoryWindow"); root->addChild(wnd2); wnd2->setPosition(CEGUI::UVector2(CEGUI::UDim(0.48f, 0), CEGUI::UDim(0.2f, 0))); wnd2->setSize(CEGUI::USize(CEGUI::UDim(0.5f, 0), CEGUI::UDim(0.5f, 0))); wnd2->setText("Bank Vault"); CEGUI::InventoryReceiver& receiver2 = dynamic_cast<CEGUI::InventoryReceiver&>(*wmgr.createWindow("InventoryReceiver")); wnd2->addChild(&receiver2); receiver2.setPosition(CEGUI::UVector2(cegui_reldim(0.0f), cegui_reldim(0.0f))); receiver2.setSize(CEGUI::USize(cegui_reldim(1.0f), cegui_reldim(1.0f))); receiver2.setContentSize(10, 10); receiver2.setUserString("BlockImage", "TestA2/InventorySlot"); // create some items and add them to the vault. CEGUI::InventoryItem& item1 = dynamic_cast<CEGUI::InventoryItem&>(*wmgr.createWindow("TaharezLook/InventoryItem")); item1.setContentSize(2, 2); receiver2.addItemAtLocation(item1, 0, 0); item1.setProperty("Image", "TaharezLook/MouseArrow"); CEGUI::InventoryItem& item2 = dynamic_cast<CEGUI::InventoryItem&>(*wmgr.createWindow("TaharezLook/InventoryItem")); item2.setContentSize(1, 2); receiver2.addItemAtLocation(item2, 1, 3); item2.setProperty("Image", "TestA2/MadBug"); CEGUI::InventoryItem& item3 = dynamic_cast<CEGUI::InventoryItem&>(*wmgr.createWindow("InventoryItem")); item3.setUserString("BlockImage", "TaharezLook/GenericBrush"); item3.setContentSize(1, 4); receiver2.addItemAtLocation(item3, 5, 2); CEGUI::InventoryItem& item4 = dynamic_cast<CEGUI::InventoryItem&>(*wmgr.createWindow("InventoryItem")); item4.setUserString("BlockImage", "TaharezLook/GenericBrush"); item4.setContentSize(1, 1); receiver2.addItemAtLocation(item4, 8, 6); CEGUI::InventoryItem& item5 = dynamic_cast<CEGUI::InventoryItem&>(*wmgr.createWindow("InventoryItem")); item5.setUserString("BlockImage", "TaharezLook/GenericBrush"); item5.setContentSize(2, 3); } } }
Gui::Gui(OIS::Mouse * m) { num = 0; CEGUI::OgreRenderer & myRenderer = CEGUI::OgreRenderer::create(); sys = CEGUI::System::getSingletonPtr(); sys->create( myRenderer ); myRendererPtr = & myRenderer; rp = static_cast<CEGUI::DefaultResourceProvider*> (CEGUI::System::getSingleton().getResourceProvider()); rp->setResourceGroupDirectory("schemes", "CEGUIdatafiles/schemes/"); rp->setResourceGroupDirectory("imagesets", "CEGUIdatafiles/imagesets/"); rp->setResourceGroupDirectory("fonts", "CEGUIdatafiles/fonts/"); rp->setResourceGroupDirectory("layouts", "CEGUIdatafiles/layouts/"); rp->setResourceGroupDirectory("looknfeels", "CEGUIdatafiles/looknfeel/"); rp->setResourceGroupDirectory("lua_scripts", "CEGUIdatafiles/lua_scripts/"); CEGUI::Imageset::setDefaultResourceGroup("imagesets"); CEGUI::Font::setDefaultResourceGroup("fonts"); CEGUI::Scheme::setDefaultResourceGroup("schemes"); CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels"); CEGUI::WindowManager::setDefaultResourceGroup("layouts"); CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts"); CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser(); if (parser->isPropertyPresent("SchemaDefaultResourceGroup")) { parser->setProperty("SchemaDefaultResourceGroup", "schemas"); } rp->setResourceGroupDirectory("schemas", "CEGUIdatafiles/xml_schemas/"); CEGUI::FontManager::getSingleton().create( "DejaVuSans-10.font" ); CEGUI::System::getSingleton().setDefaultFont( "DejaVuSans-10" ); CEGUI::ImagesetManager::getSingleton().createFromImageFile("map_preview", "menu_solo.png"); CEGUI::SchemeManager::getSingleton().create( "menu.scheme" ); CEGUI::System::getSingleton().setDefaultMouseCursor( "menu", "puntero" ); CEGUI::Size s = CEGUI::Size(20,25); CEGUI::MouseCursor::getSingleton().setExplicitRenderSize(s); CEGUI::System::getSingleton().setDefaultTooltip("Menu/Tooltip" ); CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton(); wMgrPtr = &wmgr; mouse = m; menu2 = false; presionado = false; principal = 0; w = myRendererPtr->getDisplaySize().d_width; h = myRendererPtr->getDisplaySize().d_height; menuPrincipal = new MainGui(wMgrPtr, "pruebaMenu.layout", true); }
bool CCEGUIDriver::LoadConfig( const CORE::CDataNode& treeroot ) {GUCEF_TRACE; const CORE::CDataNode* ceguiConfig = treeroot.Find( "CEGUI" ); if ( nullptr == ceguiConfig ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "CGUIDriver:LoadConfig: Cannot find CEGUI config and as such will not be able to initialize" ); return false; } m_schemeToUse = ceguiConfig->GetAttributeValueOrChildValueByName( "Scheme" ); m_defaultFont = ceguiConfig->GetAttributeValueOrChildValueByName( "DefaultFont" ); m_defaultCursorImage = ceguiConfig->GetAttributeValueOrChildValueByName( "DefaultCursorImage" ); // the default is the fallback resource group if none is passed to the adapter CORE::CString defaultResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "DefaultResourceGroup" ); if ( defaultResourceGroup.IsNULLOrEmpty() ) defaultResourceGroup = "CEGUI"; m_vfsResourceProvider.setDefaultResourceGroup( defaultResourceGroup ); CORE::CString imageSetsResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "ImageSetsResourceGroup" ); CORE::CString fontsResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "FontsResourceGroup" ); CORE::CString schemesResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "SchemesResourceGroup" ); CORE::CString lookNFeelResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "LookNFeelsResourceGroup" ); CORE::CString layoutsResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "LayoutsResourceGroup" ); CORE::CString animationsResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "AnimationsResourceGroup" ); CORE::CString scriptsResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "ScriptsResourceGroup" ); m_schemasResourceGroup = ceguiConfig->GetAttributeValueOrChildValueByName( "SchemasResourceGroup" ); // set the default resource groups to be used CEGUI::ImageManager::setImagesetDefaultResourceGroup( imageSetsResourceGroup ); CEGUI::Font::setDefaultResourceGroup( fontsResourceGroup ); CEGUI::Scheme::setDefaultResourceGroup( schemesResourceGroup ); CEGUI::WidgetLookManager::setDefaultResourceGroup( lookNFeelResourceGroup ); CEGUI::WindowManager::setDefaultResourceGroup( layoutsResourceGroup ); CEGUI::AnimationManager::setDefaultResourceGroup( animationsResourceGroup ); CEGUI::ScriptModule::setDefaultResourceGroup( scriptsResourceGroup ); // setup default group for validation schemas CEGUI::System* ceguiSystem = CEGUI::System::getSingletonPtr(); if ( nullptr != ceguiSystem ) { CEGUI::XMLParser* parser = ceguiSystem->getXMLParser(); if ( nullptr != parser && parser->isPropertyPresent( "SchemaDefaultResourceGroup" ) ) parser->setProperty( "SchemaDefaultResourceGroup", m_schemasResourceGroup ); } const CORE::CDataNode* ceguiVfsConfig = treeroot.Search( "CEGUI/VFSAdapter", '/', false ); if ( nullptr != ceguiVfsConfig ) { CORE::CDataNode::TConstDataNodeSet grpNodes = ceguiVfsConfig->FindChildrenOfType( "ResourceGroup" ); CORE::CDataNode::TConstDataNodeSet::iterator i = grpNodes.begin(); while ( i != grpNodes.end() ) { CORE::CString groupName = (*i)->GetAttributeValueOrChildValueByName( "Name" ); CORE::CString vfsPath = (*i)->GetAttributeValueOrChildValueByName( "Path" ); m_vfsResourceProvider.setResourceGroupDirectory( groupName, vfsPath ); ++i; } } return true; }
bool CGUIDriverOgre::Init( GUI::TWindowContextPtr windowContext ) { if ( !m_ceGuiInitialized ) { try { Ogre::RenderTarget* renderTarget = nullptr; CORE::CString renderTargetPtrStr = windowContext->GetProperty( "Ogre::RenderTarget" ); if ( !renderTargetPtrStr.IsNULLOrEmpty() ) { renderTarget = static_cast< Ogre::RenderTarget* >( CORE::StringToPointer( renderTargetPtrStr ) ); if ( NULL == renderTarget ) return false; } Ogre::SceneManager* sceneManager = nullptr; CORE::CString sceneManagerPtrStr = windowContext->GetProperty( "Ogre::SceneManager" ); if ( !sceneManagerPtrStr.IsNULLOrEmpty() ) { sceneManager = static_cast< Ogre::SceneManager* >( CORE::StringToPointer( sceneManagerPtrStr ) ); if ( NULL == sceneManager ) return false; } // Auto-create a viewport here if none exists yet unsigned short viewportCount = renderTarget->getNumViewports(); if ( 0 == viewportCount ) { Ogre::Camera* camera = sceneManager->createCamera( "CEGUI" ); camera->setPosition( Ogre::Vector3( 0, 0, 500 ) ); camera->lookAt( Ogre::Vector3( 0, 0, -300 ) ); camera->setNearClipDistance( 5 ); // Create a viewport covering whole window Ogre::Viewport* viewport = renderTarget->addViewport( camera ); viewport->setBackgroundColour( Ogre::ColourValue( 0.0f, 0.0f, 0.0f, 0.0f ) ); viewport->setOverlaysEnabled( true ); // Update the camera aspect ratio to that of the viewport camera->setAspectRatio( Ogre::Real( viewport->getActualWidth() ) / Ogre::Real( viewport->getActualHeight() ) ); } CEGUI::Sizef displaySize( (float) windowContext->GetWidth(), (float) windowContext->GetHeight() ); m_guiRenderer = &CEGUI::OgreRenderer::create( *renderTarget );// displaySize );//, CEGUI::OpenGLRenderer::TTT_AUTO ); m_guiRenderer->setDefaultRootRenderTarget( *renderTarget ); m_guiSystem = &CEGUI::System::create( *m_guiRenderer, &m_vfsResourceProvider, &m_xmlParserAdapter, m_imageCodecAdapter ); // setup default group for validation schemas CEGUI::XMLParser* parser = m_guiSystem->getXMLParser(); if ( nullptr != parser && parser->isPropertyPresent( "SchemaDefaultResourceGroup" ) ) parser->setProperty( "SchemaDefaultResourceGroup", m_schemasResourceGroup ); // Load the fonts CEGUI::FontManager::getSingleton().createAll( m_defaultFont, CEGUI::Font::getDefaultResourceGroup() ); // Load the scheme try { CEGUI::SchemeManager::getSingleton().createFromFile( "Generic.scheme" ); } catch ( CEGUI::Exception& e ) { CORE::CString info = e.getMessage() + " - at - " + e.getFileName() + ":" + e.getFunctionName() + ":" + CORE::UInt32ToString( e.getLine() ).STL_String(); GUCEF_EXCEPTION_LOG( CORE::LOGLEVEL_IMPORTANT, "Unhandled exception during CEGUI initialization: " + info ); } CEGUI::SchemeManager::getSingleton().createFromFile( m_schemeToUse ); // Set the defaults CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultFont( m_defaultFont ); CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage( m_defaultCursorImage ); CEGUI::Window* rootWindow = CEGUI::WindowManager::getSingleton().createWindow( "DefaultWindow", "root" ); CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow( rootWindow ); // clearing this queue actually makes sure it's created(!) CEGUI::System::getSingleton().getDefaultGUIContext().clearGeometry( CEGUI::RQ_OVERLAY ); m_ceGuiInitialized = true; } catch ( CEGUI::Exception& e ) { CORE::CString info = e.getMessage() + " - at - " + e.getFileName() + ":" + e.getFunctionName() + ":" + CORE::UInt32ToString( e.getLine() ).STL_String(); GUCEF_EXCEPTION_LOG( CORE::LOGLEVEL_IMPORTANT, "Unhandled exception during CEGUI initialization: " + info ); m_ceGuiInitialized = false; } } return m_ceGuiInitialized; }