Exemplo n.º 1
0
//----------------------------------------------------------------------------//
void CEGuiBaseApplication::initialiseResourceGroupDirectories()
{
    // initialise the required dirs for the DefaultResourceProvider
    CEGUI::DefaultResourceProvider* rp =
        static_cast<CEGUI::DefaultResourceProvider*>
            (CEGUI::System::getSingleton().getResourceProvider());

    const char* dataPathPrefix = getDataPathPrefix();
    char resourcePath[PATH_MAX];

    // for each resource type, set a resource group directory
    sprintf(resourcePath, "%s/%s", dataPathPrefix, "schemes/");
    rp->setResourceGroupDirectory("schemes", resourcePath);
    sprintf(resourcePath, "%s/%s", dataPathPrefix, "imagesets/");
    rp->setResourceGroupDirectory("imagesets", resourcePath);
    sprintf(resourcePath, "%s/%s", dataPathPrefix, "fonts/");
    rp->setResourceGroupDirectory("fonts", resourcePath);
    sprintf(resourcePath, "%s/%s", dataPathPrefix, "layouts/");
    rp->setResourceGroupDirectory("layouts", resourcePath);
    sprintf(resourcePath, "%s/%s", dataPathPrefix, "looknfeel/");
    rp->setResourceGroupDirectory("looknfeels", resourcePath);
    sprintf(resourcePath, "%s/%s", dataPathPrefix, "lua_scripts/");
    rp->setResourceGroupDirectory("lua_scripts", resourcePath);
    sprintf(resourcePath, "%s/%s", dataPathPrefix, "xml_schemas/");
    rp->setResourceGroupDirectory("schemas", resourcePath);   
    sprintf(resourcePath, "%s/%s", dataPathPrefix, "animations/");
    rp->setResourceGroupDirectory("animations", resourcePath); 
}
//----------------------------------------------------------------------------//
void CEGuiBaseApplication::initialiseResourceGroupDirectories
  (const CEGUI::String& dataPathPrefixOverride)
{
    // initialise the required dirs for the DefaultResourceProvider
    CEGUI::DefaultResourceProvider* rp =
        static_cast<CEGUI::DefaultResourceProvider*>
            (CEGUI::System::getSingleton().getResourceProvider());
    initDataPathPrefix(dataPathPrefixOverride);
    CEGUI::String dataPathPrefix(getDataPathPrefix());

    /* for each resource type, set a resource group directory. We cast strings
       to "const CEGUI::utf8*" in order to support general Unicode strings,
       rather than only ASCII strings (even though currently they're all ASCII).
       */
    rp->setResourceGroupDirectory("schemes",
      dataPathPrefix + "/schemes/");
    rp->setResourceGroupDirectory("imagesets",
      dataPathPrefix + "/imagesets/");
    rp->setResourceGroupDirectory("fonts",
      dataPathPrefix + "/fonts/");
    rp->setResourceGroupDirectory("layouts",
      dataPathPrefix + "/layouts/");
    rp->setResourceGroupDirectory("looknfeels",
      dataPathPrefix + "/looknfeel/");
    rp->setResourceGroupDirectory("lua_scripts",
      dataPathPrefix + "/lua_scripts/");
    rp->setResourceGroupDirectory("schemas",
      dataPathPrefix + "/xml_schemas/");
    rp->setResourceGroupDirectory("animations",
      dataPathPrefix + "/animations/");
}
Exemplo n.º 3
0
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");
	}
}
Exemplo n.º 4
0
//--------------------------------------------------------------------------------
void DialogResourceGroups::OnOkClick( wxCommandEvent& event )
{
    // dump the grid values into a map
    ResourceGroupsMap newGroups;
    int sz = m_groupsGrid->GetNumberRows();

    for ( int i = 0; i < sz; ++i )
        newGroups[ m_groupsGrid->GetCellValue( i, 0 ) ] =
            m_groupsGrid->GetCellValue( i, 1 );

    // build a list of deleted groups
    wxArrayString deletedGroups;
    ResourceGroupsMap::iterator iter = m_resourceGroups.begin();
    while ( iter != m_resourceGroups.end() )
    {
        if ( newGroups.count( iter->first ) == 0 )
            deletedGroups.Add( iter->first );

        ++iter;
    }

    // set our map to equal the new set of defined groups
    m_resourceGroups = newGroups;

    // get the resource provier from CEGUI::System
    CEGUI::DefaultResourceProvider* rp =
        static_cast<CEGUI::DefaultResourceProvider*>(
            CEGUI::System::getSingleton().getResourceProvider() );

    // erase groups that were deleted
    for ( size_t j = 0; j < deletedGroups.size(); ++j )
        rp->clearResourceGroupDirectory( CEGUIHelper::ToCEGUIString( deletedGroups[ j ] ) );

    // update all groups according to our map
    iter = m_resourceGroups.begin();
    while ( iter != m_resourceGroups.end() )
    {
        rp->setResourceGroupDirectory(
            CEGUIHelper::ToCEGUIString( iter->first ),
            CEGUIHelper::ToCEGUIString( iter->second ) );

        ++iter;
    }

    // Set the default resource group
    rp->setDefaultResourceGroup(
        CEGUIHelper::ToCEGUIString( m_defaultGroupName ) );

    // wipe out backup info incase some strangeness happens
    m_backupResourceGroups.clear();
    m_backupDefaultGroupName.clear();

    event.Skip();
}
Exemplo n.º 5
0
 void GUI::Init(const std::string& _resourceDirectory)
 {
   // Check if the renderer and system were not already initialized
   if (m_renderer == nullptr)
   {
     m_renderer = &CEGUI::OpenGL3Renderer::bootstrapSystem();
   }
   //set up the resource group directories
   CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider());
   rp->setResourceGroupDirectory("imagesets", _resourceDirectory + "/imagesets/");
   rp->setResourceGroupDirectory("schemes", _resourceDirectory + "/schemes/");
   rp->setResourceGroupDirectory("fonts", _resourceDirectory + "/fonts/");
   rp->setResourceGroupDirectory("layouts", _resourceDirectory + "/layouts/");
   rp->setResourceGroupDirectory("looknfeels", _resourceDirectory + "/looknfeel/");
   rp->setResourceGroupDirectory("lua_scripts", _resourceDirectory + "/lua_scripts/");
   //set the default resource groups
   CEGUI::ImageManager::setImagesetDefaultResourceGroup("imagesets");
   CEGUI::Scheme::setDefaultResourceGroup("schemes");
   CEGUI::Font::setDefaultResourceGroup("fonts");
   CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
   CEGUI::WindowManager::setDefaultResourceGroup("layouts");
   CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts");
   //set up the context
   m_context = &CEGUI::System::getSingleton().createGUIContext(m_renderer->getDefaultRenderTarget());
   m_root = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "root");
   m_context->setRootWindow(m_root);
 }
Exemplo n.º 6
0
void GUI::init(std::string resourcePath)
{
    if (renderer == nullptr)
    {
        renderer = &CEGUI::OpenGL3Renderer::bootstrapSystem();

        CEGUI::DefaultResourceProvider *resourceProvider =  static_cast<CEGUI::DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider());

        resourceProvider->setResourceGroupDirectory("imagesets", resourcePath + "/imagesets/");
        resourceProvider->setResourceGroupDirectory("schemes", resourcePath + "/schemes/");
        resourceProvider->setResourceGroupDirectory("fonts", resourcePath + "/fonts/");
        resourceProvider->setResourceGroupDirectory("layouts", resourcePath + "/layouts/");
        resourceProvider->setResourceGroupDirectory("looknfeels", resourcePath + "/looknfeel/");
        resourceProvider->setResourceGroupDirectory("lua_scripts", resourcePath + "/lua_scripts/");

        CEGUI::ImageManager::setImagesetDefaultResourceGroup("imagesets");
        CEGUI::Scheme::setDefaultResourceGroup("schemes");
        CEGUI::Font::setDefaultResourceGroup("fonts");
        CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
        CEGUI::WindowManager::setDefaultResourceGroup("layouts");
        CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts");
    }

    context = &CEGUI::System::getSingleton().createGUIContext(renderer->getDefaultRenderTarget());
    root = CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "root");
    context->setRootWindow(root);
}
Exemplo n.º 7
0
//-----------------------------------------------------------------------
wxString EditorDocument::getDefaultResourceGroupRelativePath( const wxString& filename ) const
{
    wxString resourcePath( wxT( "./" ) );
    wxFileName filespec( filename );

    CEGUI::DefaultResourceProvider* rp =
        static_cast<CEGUI::DefaultResourceProvider*>(
            CEGUI::System::getSingleton().getResourceProvider() );

    CEGUI::String defResGrp = rp->getDefaultResourceGroup();

    if ( !defResGrp.empty() )
        resourcePath = CEGUIHelper::ToWXString(
            rp->getResourceGroupDirectory( defResGrp ) );

    filespec.MakeRelativeTo( resourcePath );
    return filespec.GetFullPath();
}
Exemplo n.º 8
0
//===========================================================================//
void GlobalHandler::initializeGlobal()
{
    // Bootstrap CEGUI::System with an OpenGLRenderer object that uses the
    // current GL viewport, the DefaultResourceProvider, and the default
    // ImageCodec.
    //
    // NB: Your OpenGL context must already be initialised when you call this; CEGUI
    // will not create the OpenGL context itself.
    mRenderer = &CEGUI::OpenGLRenderer::bootstrapSystem();
    mRenderer->enableExtraStateSettings(true);
    mSystem = CEGUI::System::getSingletonPtr();

    // TODO: Find a generic way to specify these.
    // initialize the required dirs for the DefaultResourceProvider
    CEGUI::DefaultResourceProvider* resourceProvider =
            static_cast<CEGUI::DefaultResourceProvider*>(
                    mSystem->getResourceProvider());
    const std::string baseDir = core::DATA_PATH + "/../share/cegui-0/";
    resourceProvider->setResourceGroupDirectory("schemes",
                                                baseDir + "schemes/");
    resourceProvider->setResourceGroupDirectory("imagesets",
                                                baseDir + "imagesets/");
    resourceProvider->setResourceGroupDirectory("fonts",
                                                baseDir + "fonts/");
    resourceProvider->setResourceGroupDirectory("layouts",
                                                baseDir + "layouts/");
    resourceProvider->setResourceGroupDirectory("looknfeels",
                                                baseDir + "looknfeel/");
    resourceProvider->setResourceGroupDirectory("lua_scripts",
                                                baseDir + "lua_scripts/");

    // 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");

    // create (load) the TaharezLook scheme file
    // (this auto-loads the TaharezLook looknfeel and imageset files)
    CEGUI::SchemeManager::getSingleton().createFromFile(mScheme + ".scheme");

    // create (load) a font.
    // The first font loaded automatically becomes the default font, but note
    // that the scheme might have already loaded a font, so there may already
    // be a default set - if we want the "DejaVuSans-10" font to definitely
    // be the default, we should set the default explicitly afterwards.
    CEGUI::FontManager::getSingleton().createFromFile("DejaVuSans-14-NoScale.font");

    CEGUI::GUIContext& context = mSystem->getDefaultGUIContext();
    context.setDefaultFont("DejaVuSans-14-NoScale");
    //context.getMouseCursor().setDefaultImage(mScheme + "/MouseArrow");
    context.setDefaultTooltipType(mScheme + "/Tooltip");

    mWindowManager = CEGUI::WindowManager::getSingletonPtr();
    mRoot = mWindowManager->createWindow("DefaultWindow", "root");
    context.setRootWindow(mRoot);
}
Exemplo n.º 9
0
int main (int argc, char **argv) 
{
	SDL_Surface * screen;
	atexit (SDL_Quit);
	SDL_Init (SDL_INIT_VIDEO);
	screen = SDL_SetVideoMode (600, 480, 0, SDL_OPENGL);
	if (screen == NULL) {
		/* Se ainda n?o der, desiste! */ 
		fprintf (stderr, "Imposs¨ªvel ajustar ao v¨ªdeo: %s\n", SDL_GetError ());
		exit (1);
	}
	//renderer = new CEGUI::OpenGLRenderer (0, 600, 480);
	renderer = &CEGUI::OpenGLRenderer::create();
	CEGUI::System::create(*renderer);
	SDL_ShowCursor (SDL_DISABLE);
	SDL_EnableUNICODE (1);
	SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);

	// initialise the required dirs for the DefaultResourceProvider
	CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>
		(CEGUI::System::getSingleton().getResourceProvider());

	rp->setResourceGroupDirectory("schemes", "../../cegui/CEGUI-SDK-0.7.5-vc8/datafiles/schemes/");
	rp->setResourceGroupDirectory("imagesets", "../../cegui/CEGUI-SDK-0.7.5-vc8/datafiles/imagesets/");
	rp->setResourceGroupDirectory("fonts", "../../cegui/CEGUI-SDK-0.7.5-vc8/datafiles/fonts/");
	rp->setResourceGroupDirectory("layouts", "../../cegui/CEGUI-SDK-0.7.5-vc8/datafiles/layouts/");
	rp->setResourceGroupDirectory("looknfeels", "../../cegui/CEGUI-SDK-0.7.5-vc8/datafiles/looknfeel/");
	rp->setResourceGroupDirectory("lua_scripts", "../../cegui/CEGUI-SDK-0.7.5-vc8/datafiles/lua_scripts/");

	// set 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");

    // Get window manager which we wil use for a few jobs here.
    WindowManager& winMgr = WindowManager::getSingleton();
    // Load the scheme to initialse the VanillaSkin which we use in this sample
    SchemeManager::getSingleton().create("VanillaSkin.scheme");
    // set default mouse image
    System::getSingleton().setDefaultMouseCursor("Vanilla-Images", "MouseArrow");

    FontManager::getSingleton().create("DejaVuSans-10.font");

	Window *root = winMgr.loadWindowLayout("VanillaWindows.layout");
	Window *console = winMgr.loadWindowLayout("VanillaConsole.layout", "Demo");
	root->addChildWindow(console);

	// install this as the root GUI sheet
    System::getSingleton().setGUISheet(root);



	main_loop();

	return 0;
}
Exemplo n.º 10
0
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();
}
Exemplo n.º 11
0
	bool CServer::initCEGUI()
	{
		CEGUI::OgreRenderer& CEGUIRenderer = CEGUI::OgreRenderer::create(*_renderWindow);

		_luaModule = &CEGUI::LuaScriptModule::create(ScriptManager::CServer::getSingletonPtr()->getLuaState());
		CEGUI::System::create(CEGUIRenderer, NULL, NULL, NULL, _luaModule, "media/gui/configs/CEGUIConfig.xml"); 

		_GUISystem = CEGUI::System::getSingletonPtr();

		// Inicializamos los directorios necesarios para el Resource Provider,
		// así cuando creemos un recurso no tenemos que dar una ruta completa.
		CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>(
			CEGUI::System::getSingleton().getResourceProvider());

		rp->setResourceGroupDirectory("fonts", "media/gui/fonts/");
		rp->setResourceGroupDirectory("imagesets", "media/gui/imagesets/");
		rp->setResourceGroupDirectory("layouts", "media/gui/layouts");
		rp->setResourceGroupDirectory("looknfeels", "media/gui/looknfeel/");
		rp->setResourceGroupDirectory("schemes", "media/gui/schemes/");

		// Definimos los grupos de recursos que usaremos
		CEGUI::Font::setDefaultResourceGroup("fonts");
		CEGUI::Imageset::setDefaultResourceGroup("imagesets");
		CEGUI::WindowManager::setDefaultResourceGroup("layouts");
		CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
		CEGUI::Scheme::setDefaultResourceGroup("schemes");

		return true;

	} // initCEGUI
Exemplo n.º 12
0
void GUI::initializeResourceGroups()
{
	CEGUI::DefaultResourceProvider* rp;
	rp = static_cast<CEGUI::DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider());
	std::string rootPath = "GUIData/";
    rp->setResourceGroupDirectory("schemes", rootPath + "schemes/");
    rp->setResourceGroupDirectory("imagesets", rootPath + "imagesets/");
    rp->setResourceGroupDirectory("fonts", rootPath + "fonts/");
    rp->setResourceGroupDirectory("layouts", rootPath + "layouts/");
    rp->setResourceGroupDirectory("looknfeel", rootPath + "looknfeel/");
    rp->setResourceGroupDirectory("lua_scripts", rootPath + "lua_scripts/");
    rp->setResourceGroupDirectory("schemas", rootPath + "schemas/");
    rp->setResourceGroupDirectory("animations", rootPath + "animations/");

    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");
    CEGUI::AnimationManager::setDefaultResourceGroup("animations");
}
Exemplo n.º 13
0
void UIMng::create_cegui_system()
{
	LOG_ENTER;

	void * pD3DDevice = SINGLETON(Render).GetDevice();

	// 创建cegui
	CEGUI::Direct3D9Renderer& renderer(CEGUI::Direct3D9Renderer::create((LPDIRECT3DDEVICE9)pD3DDevice));
	LOG_TRACE("Create Direct3D9Renderer ok");

	CEGUI::DefaultResourceProvider* rp = new CEGUI::DefaultResourceProvider();
	CEGUI::System::create(renderer, rp);
	LOG_TRACE("Create System ok");

	// 设置资源
	rp->setResourceGroupDirectory("schemes", "ui/schemes/");
	rp->setResourceGroupDirectory("imagesets", "ui/imagesets/");
	rp->setResourceGroupDirectory("fonts", "ui/fonts/");
	rp->setResourceGroupDirectory("layouts", "ui/layouts/");
	rp->setResourceGroupDirectory("looknfeels", "ui/looknfeel/");
	rp->setResourceGroupDirectory("lua_scripts", "ui/lua_scripts/");
	rp->setResourceGroupDirectory("schemas", "ui/xml_schemas/");   
	rp->setResourceGroupDirectory("animations", "ui/animations/"); 

	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");
	LOG_TRACE("setDefaultResourceGroup ok");

	CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);

	LOG_LEAVE;
}
Exemplo n.º 14
0
GuiMgr::GuiMgr()
{
    CEGUI::OpenGLRenderer::bootstrapSystem();

    std::string folder = "media/cegui/";
    // Initialise the required dirs for the DefaultResourceProvider
    CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>
        (CEGUI::System::getSingleton().getResourceProvider());

    rp->setResourceGroupDirectory("schemes",     folder + "schemes/");
    rp->setResourceGroupDirectory("imagesets",   folder + "imagesets/");
    rp->setResourceGroupDirectory("fonts",       folder + "fonts/");
    rp->setResourceGroupDirectory("layouts",     folder + "layouts/");
    rp->setResourceGroupDirectory("looknfeels",  folder + "looknfeel/");
    rp->setResourceGroupDirectory("lua_scripts", folder + "lua_scripts/");

    // Set 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");

    // Load the scheme
    CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme");
    CEGUI::SchemeManager::getSingleton().create("VanillaSkin.scheme");

    // Set the defaults
    CEGUI::System::getSingleton().setDefaultFont("DejaVuSans-10");
    //CEGUI::System::getSingleton().setDefaultMouseCursor("Vanilla-Images", "MouseArrow");

    CEGUI::Window* myRoot =
        CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "_MasterRoot");

    CEGUI::System::getSingleton().setGUISheet(myRoot);

    std::clog << "GuiMgr created\n";

    // Add Console window to gui
    Console *c = new Console;
    CEGUI::System::getSingleton().getGUISheet()->addChildWindow(c->getWindow());

    c->setVisible(false);
}
Exemplo n.º 15
0
void CeguiDrawable::init() const
{
    if (m_initDone)
        return;
    CEGUI::OpenGL3Renderer::bootstrapSystem();

    CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider());

    rp->setResourceGroupDirectory("schemes", "./cegui/schemes/");
    rp->setResourceGroupDirectory("imagesets", "./cegui/imagesets/");
    rp->setResourceGroupDirectory("fonts", "./cegui/fonts/");
    rp->setResourceGroupDirectory("looknfeels", "./cegui/looknfeel/");
    rp->setResourceGroupDirectory("layouts", "./cegui/layouts/");
    rp->setResourceGroupDirectory("anims", "./cegui/animations/");

    CEGUI::ImageManager::setImagesetDefaultResourceGroup("imagesets");
    CEGUI::Font::setDefaultResourceGroup("fonts");
    CEGUI::Scheme::setDefaultResourceGroup("schemes");
    CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
    CEGUI::WindowManager::setDefaultResourceGroup("layouts");
    CEGUI::AnimationManager::setDefaultResourceGroup("anims");

    CEGUI::SchemeManager::getSingleton().createFromFile("Generic.scheme");

    CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("TaharezLook/MouseArrow");
    //CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultFont("DejaVuSans-12");
    //CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultTooltipType("TaharezLook/Tooltip");

    using namespace CEGUI;
    Window* myRoot = WindowManager::getSingleton().loadLayoutFromFile("futurella.xml");
    System::getSingleton().getDefaultGUIContext().setRootWindow(myRoot);

    //AnimationManager::getSingleton().loadAnimationsFromXML("example.anims");

    /// HACKS, hacks hacks all around...
    // well, what else can you do here, i have no idea.

    CeguiDrawable* self = const_cast<CeguiDrawable*>(this);
    self->setEventCallback(new GlobalEventHandler(m_guiApp));
    self->setUpdateCallback(new TickEvents);
    self->m_guiApp->registerEvents();

    m_initDone = true;
}
Exemplo n.º 16
0
	bool CServer::initCEGUI()
	{
		CEGUI::OgreRenderer& CEGUIRenderer =
				 CEGUI::OgreRenderer::create(*_renderWindow);

		//Creamos un objeto lua script module que luego le pasaremos al system cuando lo creemos
		//Le pasamos el interprete de Lua que queremos que modifique con las funciones de CEGUI
		CEGUI::LuaScriptModule &luaModule = CEGUI::LuaScriptModule::create(LUA::CScriptManager::GetPtrSingleton()->getNativeInterpreter());

		//Le pasamos el lua al crear CEGUI
		CEGUI::System::create(CEGUIRenderer, nullptr, nullptr, nullptr, &luaModule);

		//Aqui creamos el sistema de CEGUI
		_GUISystem = CEGUI::System::getSingletonPtr();

		// Inicializamos los directorios necesarios para el Resource Provider,
		// así cuando creemos un recurso no tenemos que dar una ruta completa.
		CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>(
			_GUISystem->getResourceProvider());

		//Aqui creamos cada uno de los grupos, asociando un nombre con una ruta de cada recurso
		rp->setResourceGroupDirectory("fonts", "media/gui/fonts/");
		rp->setResourceGroupDirectory("imagesets", "media/gui/imagesets/");
		rp->setResourceGroupDirectory("layouts", "media/gui/layouts");
		rp->setResourceGroupDirectory("looknfeels", "media/gui/looknfeel/");
		rp->setResourceGroupDirectory("schemes", "media/gui/schemes/");
		rp->setResourceGroupDirectory("xml_schemas", "media/gui/xml_schemas/");   

		//Definimos el tipo por defecto 
		CEGUI::Font::setDefaultResourceGroup("fonts");
		CEGUI::ImageManager::setImagesetDefaultResourceGroup("imagesets");
		CEGUI::WindowManager::setDefaultResourceGroup("layouts");
		CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
		CEGUI::Scheme::setDefaultResourceGroup("schemes");

		// setup default group for validation schemas
		_parser = _GUISystem->getXMLParser();
		if (_parser->isPropertyPresent("SchemaDefaultResourceGroup"))
			_parser->setProperty("SchemaDefaultResourceGroup", "xml_schemas");
			
		return true;

	} // initCEGUI
Exemplo n.º 17
0
GameDesktop::GameDesktop(sf::RenderWindow &screen)
  : screen_(screen),
    renderer_(CEGUI::OpenGLRenderer::bootstrapSystem())
{
  // Set up default resource groups
  CEGUI::DefaultResourceProvider *rp = static_cast<CEGUI::DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider());

  rp->setResourceGroupDirectory("schemes", "/usr/share/cegui-0/schemes/"); 
  rp->setResourceGroupDirectory("imagesets", "/usr/share/cegui-0/imagesets/");
  rp->setResourceGroupDirectory("fonts", "/usr/share/cegui-0/fonts/");
  rp->setResourceGroupDirectory("layouts", "/usr/share/cegui-0/layouts/");
  rp->setResourceGroupDirectory("looknfeels", "/usr/share/cegui-0/looknfeel");
  rp->setResourceGroupDirectory("lua_scripts", "/usr/share/cegui-0/lua_scripts/");

  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");

  // Set up the GUI
  CEGUI::SchemeManager::getSingleton().createFromFile("WindowsLook.scheme");
  CEGUI::FontManager::getSingleton().createFromFile("DejaVuSans-10.font");

  CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("WindowsLook/MouseArrow");

  CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
  CEGUI::Window *root = wmgr.createWindow("DefaultWindow", "root");
  root->setProperty("MousePassThroughEnabled", "True");
  CEGUI::System::getSingleton().getDefaultGUIContext().setRootWindow(root);

  CEGUI::FrameWindow *fw = static_cast<CEGUI::FrameWindow*>(wmgr.createWindow("WindowsLook/FrameWindow", "testWindow"));

  root->addChild(fw);
  fw->setText("Hello World!");

  // Initialize SFML-to-CEGUI key mapping
  initializeKeyMap();
  screen_.setView(view_);
}
Exemplo n.º 18
0
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");
}
Exemplo n.º 19
0
static void init_sdlgui(char * skin_layout,int fullscreen)
{
	SDL_Surface * screen;
// 	atexit (SDL_Quit);
	SDL_Init (SDL_INIT_VIDEO);
	int videoFlags;
	const SDL_VideoInfo *videoInfo;
	videoInfo = SDL_GetVideoInfo( );

	if ( !videoInfo )
	{
	    fprintf( stderr, "Video query failed: %s\n",
		     SDL_GetError( ) );
	}

	/* the flags to pass to SDL_SetVideoMode */
	videoFlags  = SDL_OPENGL;          /* Enable OpenGL in SDL */
	videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
	videoFlags |= SDL_HWPALETTE;       /* Store the palette in hardware */
	videoFlags |= SDL_RESIZABLE;       /* Enable window resizing */
	
	/* This checks to see if surfaces can be stored in memory */
	if ( videoInfo->hw_available )
		videoFlags |= SDL_HWSURFACE;
	else
		videoFlags |= SDL_SWSURFACE;
	
	/* This checks if hardware blits can be done */
	if ( videoInfo->blit_hw )
		videoFlags |= SDL_HWACCEL;
	
	/* Sets up OpenGL double buffering */
	SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );

	SDL_WM_SetCaption("NavIt - The OpenSource vector based navigation engine", NULL);

	/* get a SDL surface */
	screen = SDL_SetVideoMode( XRES, YRES, 32,
					videoFlags );

	if (screen == NULL) {
		fprintf (stderr, "Can't set SDL: %s\n", SDL_GetError ());
		exit (1);
	}
	if(fullscreen){
		SDL_WM_ToggleFullScreen(screen);
	}
	SDL_ShowCursor (SDL_ENABLE);
	SDL_EnableUNICODE (1);
	SDL_EnableKeyRepeat (SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);

	init_GL();
	
// 	sdl_audio_init();

	try
	{
		renderer = new CEGUI::OpenGLRenderer(0,XRES,YRES);
		new CEGUI::System(renderer);

		using namespace CEGUI;

		SDL_ShowCursor(SDL_ENABLE);
		SDL_EnableUNICODE(1);
		SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
		
		CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>
		(System::getSingleton().getResourceProvider());
		

		// FIXME This should maybe move to navit.xml
		static char *datafiles_path[]={
			"./gui/sdl/datafiles",
			"/usr/share/navit/datafiles",
			"/usr/local/share/navit/datafiles",
			NULL,
		};

		char **filename=datafiles_path;

		while (*filename) {	
			if (FILE * file = fopen(*filename, "r"))
			{
				fclose(file);
				break;
			}
			filename++;
		}

		if(*filename==NULL){
			// FIXME Elaborate the possible solutions
			printf("Can't find the datafiles directory for CEGUI files. Navit will probably crash :)\n");
		} else {
			printf("Loading SDL datafiles from %s\n",*filename);
		}

		rp->setResourceGroupDirectory("schemes", g_strdup_printf("%s/schemes/",*filename));
		rp->setResourceGroupDirectory("imagesets", g_strdup_printf("%s/imagesets/",*filename));
		rp->setResourceGroupDirectory("fonts", g_strdup_printf("%s/fonts/",*filename));
		rp->setResourceGroupDirectory("layouts", g_strdup_printf("%s/layouts/",*filename));
		rp->setResourceGroupDirectory("looknfeels", g_strdup_printf("%s/looknfeel/",*filename));
		rp->setResourceGroupDirectory("lua_scripts", g_strdup_printf("%s/lua_scripts/",*filename));


		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");

		char buffer [50];
		sprintf (buffer, "%s.scheme", skin_layout);
		dbg(1,"Loading scheme : %s\n",buffer);

		CEGUI::SchemeManager::getSingleton().loadScheme(buffer);

		CEGUI::FontManager::getSingleton().createFont("DejaVuSans-10.font");
		CEGUI::FontManager::getSingleton().createFont("DejaVuSans-14.font");

		CEGUI::System::getSingleton().setDefaultFont("DejaVuSans-10");

		CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();

		dbg(1,"Loading layout : %s\n",buffer);

		sprintf (buffer, "%s.layout", skin_layout);

		myRoot = CEGUI::WindowManager::getSingleton().loadWindowLayout(buffer);

 		CEGUI::System::getSingleton().setGUISheet(myRoot);

		try {

		CEGUI::WindowManager::getSingleton().getWindow("OSD/Quit")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(ButtonQuit));
// 		CEGUI::WindowManager::getSingleton().getWindow("OSD/Quit")->setText(_("Quit"));

		CEGUI::WindowManager::getSingleton().getWindow("ZoomInButton")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(ZoomIn));
// 		CEGUI::WindowManager::getSingleton().getWindow("ZoomInButton")->setText(_("ZoomIn"));

		CEGUI::WindowManager::getSingleton().getWindow("ZoomOutButton")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(ZoomOut));
// 		CEGUI::WindowManager::getSingleton().getWindow("ZoomOutButton")->setText(_("ZoomOut"));

		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/CountryEditbox")->subscribeEvent(Window::EventKeyUp, Event::Subscriber(DestinationEntryChange));
 		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/CountryEditbox")->subscribeEvent(Window::EventMouseButtonDown, Event::Subscriber(handleMouseEnters));
		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/TownEditbox")->subscribeEvent(Window::EventKeyUp, Event::Subscriber(DestinationEntryChange));
 		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/TownEditbox")->subscribeEvent(Window::EventMouseButtonDown, Event::Subscriber(handleMouseEnters));
		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/StreetEditbox")->subscribeEvent(Window::EventKeyUp, Event::Subscriber(DestinationEntryChange));
 		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/StreetEditbox")->subscribeEvent(Window::EventMouseButtonDown, Event::Subscriber(handleMouseEnters));

		CEGUI::WindowManager::getSingleton().getWindow("DestinationButton")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(DialogWindowSwitch));

		CEGUI::WindowManager::getSingleton().getWindow("OSD/ViewMode")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(ToggleView));

		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/GO")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(ButtonGo));
		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/KB")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(ShowKeyboard));

		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/Listbox")->subscribeEvent(MultiColumnList::EventSelectionChanged, Event::Subscriber(ItemSelect));


		// Translation for StaticTexts (labels)
		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/Country")->setText(_("Country"));
		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/Town")->setText(_("City"));
		CEGUI::WindowManager::getSingleton().getWindow("DestinationWindow/Street")->setText(_("Street"));

 		MultiColumnList* mcl = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("DestinationWindow/Listbox"));

		mcl->setSelectionMode(MultiColumnList::RowSingle) ;
		mcl->addColumn("Value", 0, cegui_absdim(200.0));
		mcl->addColumn("ID", 1, cegui_absdim(70.0));
		mcl->addColumn("Assoc", 2, cegui_absdim(70.0));
		mcl->addColumn("x", 3, cegui_absdim(70.0));
		mcl->addColumn("y", 4, cegui_absdim(70.0));

 		MultiColumnList* mcl2 = static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("Roadbook"));

		mcl2->setSelectionMode(MultiColumnList::RowSingle) ;
		mcl2->addColumn("Instructions", 0, cegui_absdim(700.0));

 		BuildKeyboard();

		CEGUI::WindowManager::getSingleton().getWindow("OSD/Scrollbar1")->subscribeEvent(Scrollbar::EventScrollPositionChanged, Event::Subscriber(MoveCamera));

		CEGUI::WindowManager::getSingleton().getWindow("OSD/RoadbookButton")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(RoadBookSwitch));
		CEGUI::WindowManager::getSingleton().getWindow("OSD/RoadbookButton")->setText(_("RoadBook"));

		CEGUI::WindowManager::getSingleton().getWindow("OSD/nGhostButton")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(Switch_to_nGhost));
		// this one is maybe not needed anymore
		CEGUI::WindowManager::getSingleton().getWindow("OSD/RoadbookButton2")->subscribeEvent(PushButton::EventClicked, Event::Subscriber(RoadBookSwitch));

		}
		catch (CEGUI::Exception& e)
		{
			fprintf(stderr,"CEGUI Exception occured: \n%s\n", e.getMessage().c_str());
			printf("Missing control!...\n");
		}

	}
	catch (CEGUI::Exception& e)
	{
		fprintf(stderr,"CEGUI Exception occured: \n%s\n", e.getMessage().c_str());
		printf("quiting...\n");
		exit(1);
	}
	
}
//----------------------------------------------------------------------------//
CEGuiD3D10BaseApplication::CEGuiD3D10BaseApplication() :
    pimpl(new CEGuiBaseApplicationImpl),
    d_lastTime(GetTickCount()),
    d_frames(0),
    d_FPS(0)
{
    if (pimpl->d_window = Win32AppHelper::createApplicationWindow(800, 600))
    {
        if (initialiseDirect3D(800, 600, true))
        {
            // set the swap chain ptr into window data so we can get access
            // later.  This is a bit of a hack, but saved us redesigning the
            // entire framework just for this.
            SetWindowLongPtr(pimpl->d_window,
                             GWLP_USERDATA,
                             (LONG_PTR)pimpl->d_swapChain);

            if (Win32AppHelper::initialiseDirectInput(pimpl->d_window,
                                                      pimpl->d_directInput))
            {
                pimpl->d_renderer =
                    new CEGUI::DirectX10Renderer(pimpl->d_device, 0);

                // initialise the gui system
                new CEGUI::System(pimpl->d_renderer);

                // initialise the required dirs for the DefaultResourceProvider
                CEGUI::DefaultResourceProvider* rp =
                    static_cast<CEGUI::DefaultResourceProvider*>
                        (CEGUI::System::getSingleton().getResourceProvider());

                const char* dataPathPrefix = getDataPathPrefix();
                char resourcePath[PATH_MAX];

                // for each resource type, set a resource group directory
                sprintf(resourcePath, "%s/%s", dataPathPrefix, "schemes/");
                rp->setResourceGroupDirectory("schemes", resourcePath);
                sprintf(resourcePath, "%s/%s", dataPathPrefix, "imagesets/");
                rp->setResourceGroupDirectory("imagesets", resourcePath);
                sprintf(resourcePath, "%s/%s", dataPathPrefix, "fonts/");
                rp->setResourceGroupDirectory("fonts", resourcePath);
                sprintf(resourcePath, "%s/%s", dataPathPrefix, "layouts/");
                rp->setResourceGroupDirectory("layouts", resourcePath);
                sprintf(resourcePath, "%s/%s", dataPathPrefix, "looknfeel/");
                rp->setResourceGroupDirectory("looknfeels", resourcePath);
                sprintf(resourcePath, "%s/%s", dataPathPrefix, "lua_scripts/");
                rp->setResourceGroupDirectory("lua_scripts", resourcePath);
                #if defined(CEGUI_WITH_XERCES) && (CEGUI_DEFAULT_XMLPARSER == XercesParser)
                    sprintf(resourcePath, "%s/%s", dataPathPrefix, "XMLRefSchema/");
                    rp->setResourceGroupDirectory("schemas", resourcePath);
                #endif

                CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);

                return;
            }

            cleanupDirect3D();
        }

        DestroyWindow(pimpl->d_window);
    }
    else
    {
        MessageBox(0, Win32AppHelper::CREATE_WINDOW_ERROR,
                   Win32AppHelper::APPLICATION_NAME, MB_ICONERROR|MB_OK);
    }

    throw std::runtime_error("Windows Direct3D 10 application failed to "
                             "initialise.");
}
Exemplo n.º 21
0
void CEGUIDrawable::drawImplementation( osg::RenderInfo& renderInfo ) const
{
    unsigned int contextID = renderInfo.getContextID();
    
    if ( !_initialized )
    {

        OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);

        if ( !_initialized )
        {
        CEGUI::OpenGLRenderer::bootstrapSystem( CEGUI::OpenGLRenderer::TTT_NONE );
        if ( !CEGUI::System::getSingletonPtr() ) return;

        CEGUI::DefaultResourceProvider* resource =
            static_cast<CEGUI::DefaultResourceProvider*>( CEGUI::System::getSingleton().getResourceProvider() );
        resource->setResourceGroupDirectory( "schemes", "./datafiles/schemes/" );
        resource->setResourceGroupDirectory( "imagesets", "./datafiles/imagesets/" );
        resource->setResourceGroupDirectory( "fonts", "./datafiles/fonts/" );
        resource->setResourceGroupDirectory( "layouts", "./datafiles/layouts/" );
        resource->setResourceGroupDirectory( "looknfeels", "./datafiles/looknfeel/" );
        resource->setResourceGroupDirectory( "lua_scripts", "./datafiles/lua_scripts/" );

        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" );

         ready_for_init_signal_();
        _activeContextID = contextID;
        _initialized = true;
        }
   }
    else if ( contextID==_activeContextID )
    {
        osg::State* state = renderInfo.getState();
        state->disableAllVertexArrays();
        state->disableTexCoordPointer( 0 );
        auto tex_unit = state->getActiveTextureUnit();
		state->setActiveTextureUnit(0);
        
		glPushMatrix();
        glPushAttrib( GL_ALL_ATTRIB_BITS );

        CEGUI::OpenGLRenderer* renderer = static_cast<CEGUI::OpenGLRenderer*>(
            CEGUI::System::getSingleton().getRenderer() );
        osg::Viewport* viewport = renderInfo.getCurrentCamera()->getViewport();
        if ( renderer && viewport )
        {
            const CEGUI::Sizef& size = renderer->getDisplaySize();
            if ( size.d_width!=viewport->width() || size.d_height!=viewport->height() )
            {
                CEGUI::System::getSingleton().notifyDisplaySizeChanged(
                    CEGUI::Sizef(viewport->width(), viewport->height()) );
            }
        }

        double currentTime = (state->getFrameStamp() ? state->getFrameStamp()->getSimulationTime() : 0.0);
        CEGUI::System::getSingleton().injectTimePulse( (currentTime - _lastSimulationTime)/1000.0 );
        CEGUI::System::getSingleton().renderAllGUIContexts();
        _lastSimulationTime = currentTime;

        glPopAttrib();
        glPopMatrix();

        state->setActiveTextureUnit(tex_unit);
    }

}
Exemplo n.º 22
0
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);
		}

	}

}
Exemplo n.º 24
0
GUI::GUI()
    : m_root(0)
{
    WineWindow& win(WineWindow::module());
    
    // Register the module for events and drawing
    win.add_event_subscriber(this, WineWindow::event_subscription_max_priority);
    win.add_draw_subscriber(this, WineWindow::draw_subscription_max_priority);

    {   // Unrepresentable keys conversion from X11 (X11/keysymdef.h) to CEGUI
#define MAP_CEGUI_SCAN(sym, scan) m_keyscans[sym] = CEGUI::Key::scan
        MAP_CEGUI_SCAN(XK_BackSpace, Backspace);
        MAP_CEGUI_SCAN(XK_Tab, Tab);
        MAP_CEGUI_SCAN(XK_Linefeed, Return);
        //XK_Clear 
        MAP_CEGUI_SCAN(XK_Return, Return);
        MAP_CEGUI_SCAN(XK_Pause, Pause);
        MAP_CEGUI_SCAN(XK_Scroll_Lock, ScrollLock);
        MAP_CEGUI_SCAN(XK_Sys_Req, SysRq);
        MAP_CEGUI_SCAN(XK_Escape, Escape);
        MAP_CEGUI_SCAN(XK_Delete, Delete);
        MAP_CEGUI_SCAN(0x007f, Delete); // Pressing Delete gives 0x007f and not XK_Delete for me (benoit.g)
        MAP_CEGUI_SCAN(XK_Home, Home);
        MAP_CEGUI_SCAN(XK_Left, ArrowLeft);
        MAP_CEGUI_SCAN(XK_Up, ArrowUp);
        MAP_CEGUI_SCAN(XK_Right, ArrowRight);
        MAP_CEGUI_SCAN(XK_Down, ArrowDown);
        //XK_Prior
        MAP_CEGUI_SCAN(XK_Page_Up, PageUp);
        //XK_Next
        MAP_CEGUI_SCAN(XK_Page_Down, PageDown);
        MAP_CEGUI_SCAN(XK_End, End);
        MAP_CEGUI_SCAN(XK_Begin, Home);
        //XK_Select
        //XK_Print
        //XK_Execute
        MAP_CEGUI_SCAN(XK_Insert, Insert);
        //XK_Undo
        //XK_Redo
        //XK_Menu
        //XK_Find
        //XK_Cancel
        //XK_Help
        //XK_Break
        //XK_Mode_switch
        MAP_CEGUI_SCAN(XK_Num_Lock, NumLock);
        MAP_CEGUI_SCAN(XK_KP_Enter, NumpadEnter);
        MAP_CEGUI_SCAN(XK_F1, F1);
        MAP_CEGUI_SCAN(XK_F2, F2);
        MAP_CEGUI_SCAN(XK_F3, F3);
        MAP_CEGUI_SCAN(XK_F4, F4);
        MAP_CEGUI_SCAN(XK_F5, F5);
        MAP_CEGUI_SCAN(XK_F6, F6);
        MAP_CEGUI_SCAN(XK_F7, F7);
        MAP_CEGUI_SCAN(XK_F8, F8);
        MAP_CEGUI_SCAN(XK_F9, F9);
        MAP_CEGUI_SCAN(XK_F10, F10);
        MAP_CEGUI_SCAN(XK_F11, F11);
        MAP_CEGUI_SCAN(XK_F12, F12);
        MAP_CEGUI_SCAN(XK_F13, F13);
        MAP_CEGUI_SCAN(XK_F14, F14);
        MAP_CEGUI_SCAN(XK_F15, F15);
        MAP_CEGUI_SCAN(XK_Shift_L, LeftShift);
        MAP_CEGUI_SCAN(XK_Shift_R, RightShift);
        MAP_CEGUI_SCAN(XK_Control_L, LeftControl);
        MAP_CEGUI_SCAN(XK_Control_R, RightControl);
        MAP_CEGUI_SCAN(XK_Alt_L, LeftAlt);
        MAP_CEGUI_SCAN(XK_Alt_R, RightAlt);
        MAP_CEGUI_SCAN(XK_Super_L, LeftWindows);
        MAP_CEGUI_SCAN(XK_Super_R, RightWindows);
#undef MAP_CEGUI_SCAN
    }

    {   // CEGUI setup begin
        win.enter();    // CEGUI expects its opengl context to be current
        
        CEGUI::MouseCursor::setInitialMousePosition(CEGUI::Point(-1.0f, -1.0f));
        CEGUI::OpenGLRenderer::bootstrapSystem();

        {   // Specify the default resources' folders
            CEGUI::DefaultResourceProvider* rp;

            rp = static_cast<CEGUI::DefaultResourceProvider*>(CEGUI::System::getSingleton().getResourceProvider());
            rp->setResourceGroupDirectory("schemes", "/usr/local/share/CEGUI/schemes/");
            rp->setResourceGroupDirectory("imagesets", "/usr/local/share/CEGUI/imagesets/");
            rp->setResourceGroupDirectory("fonts", "/usr/local/share/CEGUI/fonts/");
            rp->setResourceGroupDirectory("layouts", "/usr/local/share/CEGUI/layouts/");
            rp->setResourceGroupDirectory("looknfeels", "/usr/local/share/CEGUI/looknfeel/");
            rp->setResourceGroupDirectory("lua_scripts", "/usr/local/share/CEGUI/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");
        }

        {   // Choose the default style and the default font
            CEGUI::SchemeManager::getSingleton().create("TaharezLook.scheme");
            CEGUI::FontManager::getSingleton().create("DejaVuSans-10.font");
        }

        {   // Setup the GUI sheet root window
            CEGUI::System& sys(CEGUI::System::getSingleton());
            CEGUI::WindowManager& winmgr(CEGUI::WindowManager::getSingleton());
            
            m_root = static_cast<CEGUI::Window*>(winmgr.createWindow("DefaultWindow", "root"));
            m_root->setPosition(CEGUI::UVector2(CEGUI::UDim(.0f, .0f), CEGUI::UDim(.0f, .0f)));
            m_root->setMousePassThroughEnabled(true);
            sys.setGUISheet(m_root);
/*
            // Additional widgets
            CEGUI::FrameWindow* fWnd;
            
            fWnd = static_cast<CEGUI::FrameWindow*>(winmgr.createWindow("TaharezLook/FrameWindow", "hello"));
            root->addChildWindow(fWnd);
            fWnd->setPosition(CEGUI::UVector2(CEGUI::UDim(.25f, .0f), CEGUI::UDim(0.25f, 0)));
            fWnd->setSize(CEGUI::UVector2(CEGUI::UDim(.5f, .0f), CEGUI::UDim(.5f, 0)));
            fWnd->setText("Hello World!");

            CEGUI::MultiLineEditbox* test;

            test = static_cast<CEGUI::MultiLineEditbox*>(winmgr.createWindow("TaharezLook/MultiLineEditbox", "test"));
            fWnd->addChildWindow(test);
            test->setPosition(CEGUI::UVector2(CEGUI::UDim(.25f, .0f), CEGUI::UDim(0.25f, 0)));
            test->setSize(CEGUI::UVector2(CEGUI::UDim(.5f, .0f), CEGUI::UDim(.5f, 0)));
            test->setText("this is a\nmultiMOTHERFUCKINGline\neditbox widget!");
        */
        }
        win.leave();    // Restore the game's opengl context
    }   // CEGUI setup end
}
/*************************************************************************
    Constructor.
*************************************************************************/
CEGuiOpenGLBaseApplication::CEGuiOpenGLBaseApplication()
{
    // fake args for glutInit
    int argc = 1;
    const char* argv = "SampleApp";

    // Do GLUT init
    glutInit(&argc, (char**)&argv);
    glutInitDisplayMode(GLUT_DEPTH|GLUT_DOUBLE|GLUT_RGBA);
    glutInitWindowSize(800, 600);
    glutInitWindowPosition(100, 100);
    glutCreateWindow("Crazy Eddie's GUI Mk-2 - Sample Application");
    glutSetCursor(GLUT_CURSOR_NONE);

    d_renderer = new CEGUI::OpenGLRenderer(1024);
    new CEGUI::System(d_renderer);

    glutDisplayFunc(&CEGuiOpenGLBaseApplication::drawFrame);
    glutReshapeFunc(&CEGuiOpenGLBaseApplication::reshape);
    glutMotionFunc(&CEGuiOpenGLBaseApplication::mouseMotion);
    glutPassiveMotionFunc(&CEGuiOpenGLBaseApplication::mouseMotion);
    glutMouseFunc(&CEGuiOpenGLBaseApplication::mouseButton);
    glutKeyboardFunc(&CEGuiOpenGLBaseApplication::keyChar);
    glutSpecialFunc(&CEGuiOpenGLBaseApplication::keySpecial);

    #ifdef __FREEGLUT_EXT_H__
        glutMouseWheelFunc(&CEGuiOpenGLBaseApplication::handleMouseWheel_freeglut);
    #endif

    // Set the clear color
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

    // initialise the required dirs for the DefaultResourceProvider
    CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>
        (CEGUI::System::getSingleton().getResourceProvider());

#ifndef __APPLE__
    const char* dataPathPrefix = getDataPathPrefix();
    char resourcePath[PATH_MAX];

    // for each resource type, set a resource group directory
    sprintf(resourcePath, "%s/%s", dataPathPrefix, "schemes/");
    rp->setResourceGroupDirectory("schemes", resourcePath);
    sprintf(resourcePath, "%s/%s", dataPathPrefix, "imagesets/");
    rp->setResourceGroupDirectory("imagesets", resourcePath);
    sprintf(resourcePath, "%s/%s", dataPathPrefix, "fonts/");
    rp->setResourceGroupDirectory("fonts", resourcePath);
    sprintf(resourcePath, "%s/%s", dataPathPrefix, "layouts/");
    rp->setResourceGroupDirectory("layouts", resourcePath);
    sprintf(resourcePath, "%s/%s", dataPathPrefix, "looknfeel/");
    rp->setResourceGroupDirectory("looknfeels", resourcePath);
    sprintf(resourcePath, "%s/%s", dataPathPrefix, "lua_scripts/");
    rp->setResourceGroupDirectory("lua_scripts", resourcePath);
    #if defined(CEGUI_WITH_XERCES) && (CEGUI_DEFAULT_XMLPARSER == XercesParser)
        sprintf(resourcePath, "%s/%s", dataPathPrefix, "XMLRefSchema/");
        rp->setResourceGroupDirectory("schemas", resourcePath);
    #endif
#else
    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/");
    #if defined(CEGUI_WITH_XERCES) && (CEGUI_DEFAULT_XMLPARSER == XercesParser)
        rp->setResourceGroupDirectory("schemas", "XMLRefSchema/");
    #endif
#endif
}
Exemplo n.º 26
0
/***********************************************************
initialize function
***********************************************************/
void GuiHandler::Initialize(const std::string &clientversion,
							LbaNetEngine * engine)
{
	_engine = engine;

	try
	{
		_gui_renderer =  &CEGUI::OpenGLRenderer::create();
		_gui_renderer->enableExtraStateSettings(true);
		CEGUI::System::create( *_gui_renderer );


		// initialise the required dirs for the DefaultResourceProvider
		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/");

		// set 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");



		// load in the scheme file, which auto-loads the TaharezLook imageset
		CEGUI::SchemeManager::getSingleton().create( "TaharezLook.scheme" );

		//! load font file
		CEGUI::FontManager::getSingleton().create( "abbey_m1-9.font" );


		ReloadFontSize();

		CEGUI::System::getSingleton().setDefaultMouseCursor( "TaharezLook", "MouseArrow" );
		CEGUI::System::getSingleton().setDefaultTooltip( "TaharezLook/Tooltip" );

		// Load the Imageset that has the pictures for our button.
		CEGUI::ImagesetManager::getSingleton().create( "LogoBig.imageset" );
		CEGUI::ImagesetManager::getSingleton().create( "LogoCenter.imageset" );
		CEGUI::ImagesetManager::getSingleton().create( "lbaNetB.imageset" );
		CEGUI::ImagesetManager::getSingleton().create( "chatbutton.imageset" );
		CEGUI::ImagesetManager::getSingleton().create( "TeleportButton.imageset" );
		CEGUI::ImagesetManager::getSingleton().create( "HeadInterface.imageset" );
		CEGUI::ImagesetManager::getSingleton().create( "optionsbutton.imageset" );
		CEGUI::ImagesetManager::getSingleton().create( "soundbutton.imageset" );
		CEGUI::ImagesetManager::getSingleton().create( "changeworldbutton.imageset" );
		CEGUI::ImagesetManager::getSingleton().create( "quitbutton.imageset" );
		CEGUI::ImagesetManager::getSingleton().create( "MenuChar.imageset" );
		CEGUI::ImagesetManager::getSingleton().create( "tunic.imageset" );
		CEGUI::ImagesetManager::getSingleton().create( "quest.imageset" );
		CEGUI::ImagesetManager::getSingleton().create( "weapon.imageset" );

		CEGUI::ImagesetManager::getSingleton().create( "contourfont.imageset" );
		CEGUI::FontManager::getSingleton().create( "ContourFont.font" );

		// loading the smileys
		{
			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_biggrin", "smileys/biggrin.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_bloated", "smileys/bloated.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_confused", "smileys/confused.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_cool", "smileys/cool.png");
			ims.setAutoScalingEnabled(false);
			}
			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_dinofly", "smileys/dinofly.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_eek", "smileys/eek.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_embarrassment", "smileys/embarrassment.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_evil", "smileys/evil.png");
			ims.setAutoScalingEnabled(false);
			}
			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_evilwink", "smileys/evilwink.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_frown", "smileys/frown.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_funfrock", "smileys/funfrock.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_hmpf", "smileys/hmpf.png");
			ims.setAutoScalingEnabled(false);
			}
			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_hmz", "smileys/hmz.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_kiss", "smileys/kiss.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_lol", "smileys/lol.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_mad", "smileys/mad.png");
			ims.setAutoScalingEnabled(false);
			}
			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_proud", "smileys/proud.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_rabibunny", "smileys/rabibunny.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_rolleyes", "smileys/rolleyes.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_sad", "smileys/sad.png");
			ims.setAutoScalingEnabled(false);
			}
			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_sigh", "smileys/sigh.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_smilie", "smileys/smilie.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_stupid", "smileys/stupid.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_tdown", "smileys/tdown.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_tup", "smileys/tup.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_wink", "smileys/wink.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_zoe", "smileys/zoe.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_zombie", "smileys/zombie.png");
			ims.setAutoScalingEnabled(false);
			}

			{
			CEGUI::Imageset &ims = CEGUI::ImagesetManager::getSingleton().createFromImageFile("sm_tongue", "smileys/tongue.png");
			ims.setAutoScalingEnabled(false);
			}
			
		}
	}
	catch(CEGUI::Exception &ex)
	{
		LogHandler::getInstance()->LogToFile(std::string("Exception init gui: ") + ex.getMessage().c_str());
	}

	//initialize the login gui
	_login_gui = new LoginGUI();
	_login_gui->Initialize(clientversion);
	_guis.push_back(_login_gui);

	ChooseWorldGUI * cwG = new ChooseWorldGUI();
	cwG->Initialize();
	_guis.push_back(cwG);

	std::vector<WorldDesc> list;
	DataLoader::getInstance()->GetAvailableWorlds(list);
	cwG->SetWorldList(list);

	_game_gui = new GameGUI();
	_game_gui->Initialize();
	_guis.push_back(_game_gui);

	MenuGUI * menuG = new MenuGUI();
	menuG->Initialize();
	_guis.push_back(menuG);

	_option_gui = new OptionsGUI();
	_option_gui->Initialize();
	_guis.push_back(_option_gui);


	SwitchGUI(0);


    // clearing this queue actually makes sure it's created(!)
    //_gui_renderer->getDefaultRenderingRoot().clearGeometry(CEGUI::RQ_OVERLAY);

    // subscribe handler to render overlay items
    //_gui_renderer->getDefaultRenderingRoot().
    //    subscribeEvent(CEGUI::RenderingSurface::EventRenderQueueStarted,
    //        CEGUI::Event::Subscriber(&GuiHandler::overlayHandler, this));
}
Exemplo n.º 27
0
bool MenuSourceConfig::SetupResourceGroups(const flowvr::xml::TiXmlHandle &rgRoot )
{
    CEGUI::DefaultResourceProvider* rp = static_cast<CEGUI::DefaultResourceProvider*>
        (m_system->getResourceProvider());

    if(!rp)
    	return false;

    flowvr::xml::TiXmlHandle dp = rgRoot.FirstChild("datapath");
    if( !dp.Element() )
    	return false;

    const char *dataPathPrefix = dp.Element()->Attribute("value");
    if(!dataPathPrefix)
    	return false;

    flowvr::xml::TiXmlHandle rg  = rgRoot.FirstChild("resourcegroups");
    flowvr::xml::TiXmlHandle rgs = rg.FirstChild( "resourcegroup" );

    flowvr::xml::TiXmlElement *child;
    for(child = rgs.Element(); child; child = child->NextSiblingElement("resourcegroup") )
    {
    	const char *pcName  = child->Attribute("name");
    	const char *pcValue = child->Attribute("value");

    	if(!pcName || !pcValue)
    	{
    		char buffer[256];
    		sprintf(buffer, "%d", child->Row());

    		CEGUI::Logger::getSingleton().logEvent(
    				"resource group @ "
    				+ std::string(buffer)
    				+ "does not contain 'name' or 'value' attribute. skipping.",
    				CEGUI::Errors);
    		continue;
    	}

		std::string _uses(pcValue);
		if( *(_uses.end()-1) != '/' )
			_uses +=  "/";

    	std::string resourcePath = std::string(dataPathPrefix)
    	                         + "/"
    	                         + _uses;
    	rp->setResourceGroupDirectory(pcName, resourcePath);
    	CEGUI::Logger::getSingleton().logEvent(
    			"setting resource group ["
    			+ std::string(pcName)
    			+ "] to path ["
    			+ resourcePath
    			+ "]", CEGUI::Informative );
    }

    // ok, create defaults for different known groups

    flowvr::xml::TiXmlHandle df = rgRoot.FirstChild("defaults");

//    setDefaultGroup<CEGUI::Imageset>( df, "Imageset", "imagesets" );
//    setDefaultGroup<CEGUI::Font>(df, "Font", "fonts" );
//    setDefaultGroup<CEGUI::Scheme>(df, "Scheme", "schemes");
//    setDefaultGroup<CEGUI::WindowManager>(df, "WindowManager", "layouts");
//    setDefaultGroup<CEGUI::ScriptModule>(df, "ScriptModule", "lua_scripts");
//    setDefaultGroup<CEGUI::WidgetLookManager>(df,"WidgetLookManager", "looknfeels");

	return true;
}