bool
CFormBackendImp::LoadLayout( GUCEF::CORE::CIOAccess& layoutStorage )
{GUCEF_TRACE;
    
    CEGUI::Window* rootWindow = NULL;
    CEGUI::WindowManager* wmgr = CEGUI::WindowManager::getSingletonPtr();
    
    GUCEF_DEBUG_LOG( 0, "Starting layout load for a GUI Form" );
    
    try
    {
        CORE::CDynamicBuffer memBuffer( layoutStorage );
        CEGUI::RawDataContainer container;

        container.setData( (CEGUI::uint8*) memBuffer.GetBufferPtr() );
        container.setSize( (size_t) memBuffer.GetDataSize() );

        rootWindow = wmgr->loadLayoutFromContainer( container );

        container.setData( (CEGUI::uint8*) NULL );
        container.setSize( (size_t) 0 );
    }
    catch ( CEGUI::Exception& e )
    {
        GUCEF_ERROR_LOG( 0, CString( "CEGUI Exception while attempting to load form layout: " ) + e.what() );
        return false;
    }
    
    // Now that we completed loading lets see what we got from CEGUI
    if ( NULL != rootWindow )
    {
        // Begin by providing a wrapper for the root window
        m_rootWindow = CreateAndHookWrapperForWindow( rootWindow );
        if ( NULL != m_rootWindow )
        {
            CString localWidgetName = m_rootWindow->GetName().SubstrToChar( '/', false );
            m_widgetMap[ localWidgetName ] = m_rootWindow;
            WrapAndHookChildWindows( rootWindow );
            
            // We will directly add the form as a child of the root for now
            // Note: This assumes that you have a GUISheet already set, otherwise this will result in a segfault!
            CEGUI::Window* globalRootWindow = CEGUI::System::getSingleton().getDefaultGUIContext().getRootWindow();
            if ( NULL != globalRootWindow )
            {
                globalRootWindow->addChild( rootWindow );
                
                GUCEF_DEBUG_LOG( 0, "Successfully loaded a GUI Form layout" );
                return true;                
            }
            else
            {
                GUCEF_ERROR_LOG( 0, "Failed to add form as a child to the global \"root\" window" );    
            }
        }
        rootWindow->hide();
    }

    GUCEF_DEBUG_LOG( 0, "Failed to load a GUI Form layout" );
    return false; 
}
void
VfsResourceProvider::loadRawDataContainer( const CEGUI::String& filename      , 
                                           CEGUI::RawDataContainer& output    , 
                                           const CEGUI::String& resourceGroup )
{GUCEF_TRACE;
    
    // everything in CEGUI works based on resource groups
    // make sure we dont use an empty one
    const CEGUI::String* rscGroup = &resourceGroup;
    if ( resourceGroup.empty() )
    {
        rscGroup = &m_defaultResourceGroup;
    }

    CORE::CString filePath;
    CORE::CString fileName = filename;
    TCEStringMap::iterator i = m_groupMap.find( *rscGroup );
    if ( i != m_groupMap.end() )
    {
        filePath = (*i).second;
    }

    filePath = CORE::CombinePath( filePath, fileName );

    VFS::CVFS& vfs = VFS::CVfsGlobal::Instance()->GetVfs();

    VFS::CVFS::CVFSHandlePtr file = vfs.GetFile( filePath, "rb", false );
    if ( !file.IsNULL() )
    {
        CORE::CIOAccess* fileAccess = file->GetAccess();
        if ( NULL != fileAccess )
        {
            CORE::CDynamicBuffer memBuffer( *fileAccess );
             
            void* buffer = NULL;
            UInt32 dataSize = 0; 
            memBuffer.RelinquishDataOwnership( buffer, dataSize );

            output.setData( (CEGUI::uint8*) buffer );
            output.setSize( dataSize );

            DataContainerInfoPtr info = new TDataContainerInfo;
            info->fileHandle = file;
            info->requestFilename = fileName;
            info->requestresourceGroup = resourceGroup;
            info->ceContainer = output;

            m_containerMap[ buffer ] = info;
        }
        else
        {
            GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VfsResourceProvider:loadRawDataContainer: Unable to load resource from path: " + filePath );
        } 
    }
}
void
VfsResourceProvider::unloadRawDataContainer( CEGUI::RawDataContainer& data )
{GUCEF_TRACE;
    
    TContainerMap::iterator i = m_containerMap.find( (void*) data.getDataPtr() );
    if ( i != m_containerMap.end() )
    {
        (*i).second->ceContainer.setData( (CEGUI::uint8*) nullptr );
        (*i).second->ceContainer.setSize( 0 );
        m_containerMap.erase( i );
    }
    
    delete[] data.getDataPtr();
    data.setData( (CEGUI::uint8*) nullptr );
    data.setSize( 0 );
}
Пример #4
0
	virtual void 	loadRawDataContainer (const CEGUI::String &filename,
		CEGUI::RawDataContainer &output, const CEGUI::String &resourceGroup)
	{

		ZFile file;
		if (file.Open(filename.c_str()))
		{
			int fn = file.GetSize();
			char *ptr = new char [fn+1];
			file.Read(ptr, fn);
			ptr[fn] = 0;
			output.setData((CEGUI::uint8*)ptr);
			output.setSize(fn);
		}

	}
void CEGUIResourceProvider::unloadRawDataContainer(CEGUI::RawDataContainer& data)
{
    data.setData(NULL);
    data.setSize(0);
}
void CEGUIResourceProvider::loadRawDataContainer(const CEGUI::String &filename,
                                              CEGUI::RawDataContainer &output,
                                              const CEGUI::String &resourceGroup)
{
    DBG(0, "%s", filename.c_str());
    if (strcmp(filename.c_str(), "TaharezLook.scheme") == 0) {
        DBG(0, "size %d", sizeof(taharez_look_schem));
         output.setData((CEGUI::uint8*)taharez_look_schem);
         output.setSize(sizeof(taharez_look_schem));
         return;
    }

    if (strcmp(filename.c_str(), "TaharezLook.imageset") == 0) {
        DBG(0, "size %d", sizeof(taharez_look_imageset));
        output.setData((CEGUI::uint8*)taharez_look_imageset);
        output.setSize(sizeof(taharez_look_imageset));
        return;
    }

    if (strcmp(filename.c_str(), "TaharezLook.tga") == 0) {
        DBG(0, "size %d", sizeof(taharez_look_tga));
        output.setData((CEGUI::uint8*)taharez_look_tga);
        output.setSize(sizeof(taharez_look_tga));
        return;
    }

    if (strcmp(filename.c_str(), "Commonwealth-10.font") == 0) {
        DBG(0, "size %d", sizeof(commonwealth_10_font));
        output.setData((CEGUI::uint8*)commonwealth_10_font);
        output.setSize(sizeof(commonwealth_10_font));
        return;
    }

    if (strcmp(filename.c_str(), "Commonv2c.ttf") == 0) {
        DBG(0, "size %d", sizeof(commonv2c_ttf));
        output.setData((CEGUI::uint8*)commonv2c_ttf);
        output.setSize(sizeof(commonv2c_ttf));
        return;
    }

    if (strcmp(filename.c_str(), "TaharezLook.looknfeel") == 0) {
        DBG(0, "size %d", sizeof(taharez_look_looknfeel));
        output.setData((CEGUI::uint8*)taharez_look_looknfeel);
        output.setSize(sizeof(taharez_look_looknfeel));
        return;
    }

    if (strcmp(filename.c_str(), "DejaVuSans-10.font") == 0) {
        DBG(0, "size %d", sizeof(dejavu_sans_10_font));
        output.setData((CEGUI::uint8*)dejavu_sans_10_font);
        output.setSize(sizeof(dejavu_sans_10_font));
        return;
    }

    if (strcmp(filename.c_str(), "DejaVuSans.ttf") == 0) {
        DBG(0, "size %d", sizeof(dejavu_sans_ttf));
        output.setData((CEGUI::uint8*)dejavu_sans_ttf);
        output.setSize(sizeof(dejavu_sans_ttf));
        return;
    }

    throw CEGUI::GenericException("failed");
}
Пример #7
0
	virtual void 	unloadRawDataContainer (CEGUI::RawDataContainer &data)
	{
		delete [] data.getDataPtr();
		data.setData(NULL);
	}