void CWin32WindowContext::OnNotify( CORE::CNotifier* notifier , const CORE::CEvent& eventID , CORE::CICloneable* evenData ) {GUCEF_TRACE; if ( ( eventID == CORE::CPulseGenerator::PulseEvent ) || ( eventID == CORE::CMsWin32Window::WindowPaintEvent ) ) { // Notify that we are going to redraw the window NotifyObservers( WindowContextRedrawEvent ); } else if ( eventID == CORE::CMsWin32Window::WindowResizeEvent ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "Win32WindowContext: Window resize event received" ); NotifyObservers( WindowContextSizeEvent ); } else if ( eventID == CORE::CMsWin32Window::WindowActivationEvent ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "Win32WindowContext: Window activation event received" ); NotifyObservers( WindowContextActivateEvent ); } else if ( ( eventID == CORE::CMsWin32Window::WindowCloseEvent ) || ( eventID == CORE::CMsWin32Window::WindowDestroyEvent ) ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "Win32WindowContext: Window close/destroy event received" ); Shutdown(); } }
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; }
bool CFormBackendImp::LoadLayout( GUCEF::CORE::CIOAccess& layoutStorage ) {GUCE_TRACE; CEGUI::Window* rootWindow = NULL; CEGUI::WindowManager* wmgr = CEGUI::WindowManager::getSingletonPtr(); GUCEF_DEBUG_LOG( 0, "Starting layout load for a GUI Form" ); try { // provide hacky access to the given data m_dummyArchive->AddResource( layoutStorage, "currentFile" ); // Now we can load the window layout from the given storage // Note that if CEGUI ever provides an interface to do this directly // clean up this mess !!! rootWindow = wmgr->loadWindowLayout( "currentFile" , m_widgetNamePrefix.C_String() , m_resourceGroupName.C_String() ); m_dummyArchive->ClearResourceList(); } catch ( Ogre::Exception& e ) { GUCEF_ERROR_LOG( 0, CString( "Ogre Exception while attempting to load form layout: " ) + e.getFullDescription().c_str() ); 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 CEGUI::Window* globalRootWindow = wmgr->getWindow( "root" ); if ( NULL != globalRootWindow ) { globalRootWindow->addChildWindow( 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 loaded a GUI Form layout" ); return false; }
void CInputAdapter::OnMouseEvent( INPUT::CMouse* mouse , const CORE::CEvent& eventid , CORE::CICloneable* eventdata ) {GUCEF_TRACE; if ( eventid == INPUT::CMouse::MouseButtonEvent ) { // send when a mouse button is pressed or released INPUT::CMouseButtonEventData* mouseEventData = static_cast< INPUT::CMouseButtonEventData* >( eventdata ); if ( m_inputContext->GetID() == mouseEventData->GetContextId() ) { if ( mouseEventData->GetPressedState() ) { m_rocketContext->ProcessMouseButtonDown( mouseEventData->GetButtonIndex(), m_lastKeyModifierState ); GUCEF_DEBUG_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "GUIDRIVERROCKET::CInputAdapter: injected mouse button down buttonIndex=" + CORE::Int32ToString( mouseEventData->GetButtonIndex() ) + " key modifier states=" + CORE::Int32ToString( m_lastKeyModifierState ) ); } else { m_rocketContext->ProcessMouseButtonUp( mouseEventData->GetButtonIndex(), m_lastKeyModifierState ); } } } else if ( eventid == INPUT::CMouse::MouseMovedEvent ) { // send when the mouse moved INPUT::CMouseMovedEventData* mouseEventData = static_cast< INPUT::CMouseMovedEventData* >( eventdata ); if ( m_inputContext->GetID() == mouseEventData->GetContextId() ) { m_rocketContext->ProcessMouseMove( mouseEventData->GetXPos(), mouseEventData->GetYPos(), m_lastKeyModifierState ); GUCEF_DEBUG_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "GUIDRIVERROCKET::CInputAdapter: injected mouse move x=" + CORE::Int32ToString( mouseEventData->GetXPos() ) + " y=" + CORE::Int32ToString( mouseEventData->GetYPos() ) + " key modifier states=" + CORE::UInt32ToString( m_lastKeyModifierState ) ); } } else if ( eventid == INPUT::CMouse::MouseClickedEvent ) { // send when a mouse button is clicked and released within a set interval } else if ( eventid == INPUT::CMouse::MouseDoubleClickedEvent ) { // send when a mouse button is clicked and released twice within a set interval } else if ( eventid == INPUT::CMouse::MouseTrippleClickedEvent ) { // send when a mouse button is clicked and released trice within a set interval } }
void CHTTPURLHandler::Deactivate( CORE::CURL& url ) {GUCEF_TRACE; GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CHTTPURLHandler(" + CORE::PointerToString( this ) + "): Deactivating" ); if ( NULL != m_httpClient ) { m_httpClient->Close(); } }
bool CPatchEngine::ProcessRecievedPatchList( void ) {GUCEF_TRACE; GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CPatchEngine: Processing patch list" ); // Now we must process the raw patch set data to turn it into something we can use // Get the required codec for the current raw patch set data type CORE::CDStoreCodecRegistry::TDStoreCodecPtr codecPtr = CORE::CCoreGlobal::Instance()->GetDStoreCodecRegistry().Lookup( m_config.GetPatchListCodec() ); if ( NULL != codecPtr ) { // Prepare vars for the decoding process CORE::CDataNode rootNode; CORE::CMFileAccess dataAccess( m_listDataBuffer.GetConstBufferPtr() , m_listDataBuffer.GetDataSize() ); // decode the data in our buffer into a data tree if ( codecPtr->BuildDataTree( &rootNode , &dataAccess ) ) { // Now we have to parse the data tree into something more familiar CPatchListParser::TPatchList patchList; CPatchListParser listParser; listParser.ParsePatchList( rootNode , patchList ); // Now that the raw data has been processed into a real patch list we can commence // with the patching process for this patch list return m_patchListEngine->Start( patchList , m_config.GetLocalRootDir() , m_config.GetLocalTempStorageRootDir() , m_config.GetStopOnFileReplacementFailure() ); } } GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CPatchEngine: Error while processing patch list" ); // If we get here then we failed to decode the raw data into a patch set NotifyObservers( PatchListDecodingFailedEvent ); return false; }
void CMouse::SetButtonState( const Int32 contextId , const UInt32 buttonIndex , const bool pressedState ) {GUCEF_TRACE; m_buttonStates[ buttonIndex ] = pressedState; GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "Setting state of button " + CORE::Int32ToString( buttonIndex ) + " to " + CORE::BoolToString( pressedState ) + " on mouse " + CORE::Int32ToString( m_deviceID ) ); CMouseButtonEventData eData( contextId, m_deviceID, buttonIndex, pressedState, m_xPos, m_yPos ); NotifyObservers( MouseButtonEvent, &eData ); }
void CPatchEngine::Stop( void ) {GUCEF_TRACE; GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CPatchEngine: Stopping" ); if ( !m_stopSignalGiven && m_isActive ) { m_stopSignalGiven = true; m_url.Deactivate(); m_patchListEngine->Stop(); } }
bool CHTTPURLHandler::Activate( CORE::CURL& url ) {GUCEF_TRACE; GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CHTTPURLHandler(" + CORE::PointerToString( this ) + "): Activating using URL: " + url.GetURL() ); m_transferFinished = false; delete m_httpClient; m_httpClient = new CHTTPClient( url.GetPulseGenerator() ); SubscribeTo( m_httpClient ); return m_httpClient->Get( url.GetURL() ); }
void COgreWindowContext::OnNotify( CORE::CNotifier* notifier , const CORE::CEvent& eventID , CORE::CICloneable* evenData ) {GUCEF_TRACE; if ( ( eventID == CORE::CPulseGenerator::PulseEvent ) || ( eventID == CORE::COSWindow::WindowPaintEvent ) ) { // Notify that we are going to redraw the window NotifyObservers( WindowContextRedrawEvent ); } else if ( eventID == CORE::COSWindow::WindowResizeEvent ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "OgreWindowContext: Window resize event received" ); if ( nullptr != m_renderWindow ) m_renderWindow->windowMovedOrResized(); NotifyObservers( WindowContextSizeEvent ); } else if ( eventID == CORE::COSWindow::WindowActivationEvent ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "OgreWindowContext: Window activation event received" ); NotifyObservers( WindowContextActivateEvent ); } else if ( ( eventID == CORE::COSWindow::WindowCloseEvent ) || ( eventID == CORE::COSWindow::WindowDestroyEvent ) ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "OgreWindowContext: Window close/destroy event received" ); if ( nullptr != m_renderWindow ) m_renderWindow->destroy(); // cleanup and call DestroyWindow Shutdown(); } }
void CHTTPURLHandler::OnNotify( CORE::CNotifier* notifier , const CORE::CEvent& eventid , CORE::CICloneable* eventdata /* = NULL */ ) {GUCEF_TRACE; // We only accept events from our own HTTP client if ( notifier == m_httpClient ) { if ( ( eventid == CHTTPClient::HTTPErrorEvent ) || ( eventid == CHTTPClient::ConnectionErrorEvent ) ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CHTTPURLHandler(" + CORE::PointerToString( this ) + "): Data retrieval error" ); NotifyObservers( CIURLEvents::URLDataRetrievalErrorEvent ); return; } if ( eventid == CHTTPClient::HTTPDataRecievedEvent ) { // pass on the eventdata since it's a cloneable buffer it will sort itself out GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CHTTPURLHandler(" + CORE::PointerToString( this ) + "): Data received" ); NotifyObservers( CIURLEvents::URLDataRecievedEvent, eventdata ); return; } if ( eventid == CHTTPClient::HTTPTransferFinishedEvent ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CHTTPURLHandler(" + CORE::PointerToString( this ) + "): Transfer finished" ); m_transferFinished = true; NotifyObservers( CIURLEvents::URLAllDataRecievedEvent ); return; } if ( eventid == CHTTPClient::ConnectingEvent ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CHTTPURLHandler(" + CORE::PointerToString( this ) + "): Connecting" ); NotifyObservers( CIURLEvents::URLActivateEvent ); return; } if ( eventid == CHTTPClient::DisconnectedEvent ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CHTTPURLHandler(" + CORE::PointerToString( this ) + "): Disconnected" ); // Check if the transfer has already been completed. If so then the URLAllDataRecievedEvent event was the // final event and we don't have to send anything. If we where still expecting data then we will send the // URLDeactivateEvent event to notify that we deactivated prematurely. if ( !m_transferFinished ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CHTTPURLHandler(" + CORE::PointerToString( this ) + "): The transfer was not finished when we where disconnected!" ); NotifyObservers( CIURLEvents::URLDeactivateEvent ); } return; } } }
bool CPatchEngine::Start( void ) {GUCEF_TRACE; GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CPatchEngine: Starting" ); // The user should explicitly stop first if we are already busy if ( !m_isActive ) { // configuration sanity check if ( ( m_config.GetPatchListURL().Length() > 0 ) && ( m_config.GetPatchListCodec().Length() > 0 ) && ( m_config.GetLocalRootDir().Length() > 0 ) ) { m_isActive = true; m_stopSignalGiven = false; m_listDataBuffer.Clear(); NotifyObservers( PatchProcessStartedEvent ); // We must obtain the patch list before we can use it,.. // Set the URL for the list location if ( m_url.SetURL( m_config.GetPatchListURL() ) ) { // Now we try and obtain it NotifyObservers( PatchListRetrievalStartedEvent ); if ( !m_url.Activate() ) { NotifyObservers( PatchListRetrievalFailedEvent ); NotifyObservers( PatchProcessFailedEvent ); return false; } // Now we wait return true; } } } NotifyObservers( PatchProcessFailedEvent ); return false; }
bool CXWinGLWindowContext::Initialize( const GUI::CString& title , const GUI::CVideoSettings& videoSettings ) {GUCEF_TRACE; // Do not initialize twice Shutdown(); // First get access to the display ::Display* display = CORE::CX11EventDispatcher::Instance()->GetDisplay(); if ( NULL == display ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: Could not open display" ); return false; } // Now proceed with setting up the OpenGL specifics int dummy = 0; if ( 0 == glXQueryExtension( display, &dummy, &dummy ) ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: X server has no OpenGL GLX extension" ); Shutdown(); return false; } // find an OpenGL-capable Color Index visual with depth buffer static int attributes[] = {GLX_RGBA, GLX_DOUBLEBUFFER, None}; //static int attributes[] = {GLX_DEPTH_SIZE, 16, GLX_DOUBLEBUFFER, None}; XVisualInfo* vi = glXChooseVisual( display, DefaultScreen( display ), attributes ); if ( NULL == vi ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: Could not get visual info for display" ); Shutdown(); return false; } // create an OpenGL rendering context GLXContext cx = glXCreateContext( display, vi, None, GL_TRUE ); if ( NULL == cx ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: Could not create rendering context" ); XFree( vi ); Shutdown(); return false; } GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: Created GL context using GLX" ); // create an X colormap since probably not using default visual ::Colormap cmap = ::XCreateColormap( display, RootWindow( display, vi->screen), vi->visual, AllocNone); ::XSetWindowAttributes swa; swa.colormap = cmap; swa.border_pixel = 0; swa.event_mask = ExposureMask | EnterWindowMask | StructureNotifyMask | SubstructureNotifyMask; ::Window glwin = ::XCreateWindow(display, RootWindow(display, vi->screen), 0, 0, videoSettings.GetResolutionWidthInPixels(), videoSettings.GetResolutionHeightInPixels(), 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &swa); if ( 0 == glwin ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: Failed to create X11 window" ); ::XFree( vi ); Shutdown(); return false; } GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: Created X11 Window" ); // ::XSetStandardProperties(display, glwin, "xogl", "xogl", None, 0, // 0, NULL); glXMakeCurrent( display, glwin, cx ); // Set up the default GL state. glClearColor(0, 0, 0, 1); //glEnableClientState( GL_VERTEX_ARRAY ); //glEnableClientState( GL_COLOR_ARRAY ); //glEnable( GL_BLEND ); //glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( 0, GetWidth(), GetHeight(), 0, -1, 1 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); // Hook up our window object to re-use its eventing capabilities m_window.SetDisplay( display ); m_window.SetScreen( vi->screen ); m_window.SetWindow( glwin ); m_window.SetText( title ); // cleanup ::XFree( vi ); // Display the new window m_window.Show(); m_window.SendToForegound(); //m_window.GrabFocus(); // Grab the main app pulse generator and set the update interval for the context to the desired refresh rate CORE::CPulseGenerator& pulseGenerator = CORE::CCoreGlobal::Instance()->GetPulseGenerator(); pulseGenerator.RequestPeriodicPulses( this, 1000 / videoSettings.GetFrequency() ); SubscribeTo( &pulseGenerator, CORE::CPulseGenerator::PulseEvent ); GUCEF_SYSTEM_LOG( CORE::LOGLEVEL_NORMAL, "CXWinGLWindowContext: Succesfully created OpenGL rendering context" ); return true; }
void CPatchEngine::OnNotify( CORE::CNotifier* notifier , const CORE::CEvent& eventid , CORE::CICloneable* eventdata /* = NULL */ ) {GUCEF_TRACE; if ( !m_stopSignalGiven && m_isActive ) { // Call base-class version CORE::CForwardingNotifier::OnNotify( notifier , eventid , eventdata ); if ( notifier == m_patchListEngine ) { if ( eventid == PatchListProcessingCompletedEvent ) { // YIHA,.. We are finished m_stopSignalGiven = false; m_isActive = false; NotifyObservers( PatchProcessCompletedEvent ); } else if ( eventid == PatchListProcessingFailedEvent ) { // Cascade failure m_stopSignalGiven = false; m_isActive = false; NotifyObservers( PatchProcessFailedEvent ); } } else if ( notifier == &m_url ) { if ( eventid == CORE::CURL::URLDataRecievedEvent ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CPatchEngine: Patch list data received" ); // Translate event data const CORE::CDynamicBuffer& buffer = ( static_cast< CORE::CURL::TURLDataRecievedEventData* >( eventdata ) )->GetData(); // Append the data to our buffer m_listDataBuffer.Append( buffer.GetConstBufferPtr() , buffer.GetDataSize() ); NotifyObservers( PatchListDataReceivedEvent ); } else if ( eventid == CORE::CURL::URLAllDataRecievedEvent ) { // The retrieval process of the patch list has been completed NotifyObservers( PatchListRetrievalCompletedEvent ); // Now we must process the received patch list if ( !ProcessRecievedPatchList() ) { NotifyObservers( PatchProcessFailedEvent ); } } else if ( eventid == CORE::CURL::URLDeactivateEvent ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CPatchEngine: Aborting patch list retrieval" ); // Someone has called Stop() while we where busy with our data retrieval m_stopSignalGiven = false; m_isActive = false; NotifyObservers( PatchProcessAbortedEvent ); } else if ( eventid == CORE::CURL::URLDataRetrievalErrorEvent ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "CPatchEngine: Patch list data retrieval error" ); // We failed to obtain the patch list data using the URL m_stopSignalGiven = false; m_isActive = false; NotifyObservers( PatchListRetrievalFailedEvent ); NotifyObservers( PatchProcessFailedEvent ); } } } else { if ( m_stopSignalGiven && m_isActive ) { m_stopSignalGiven = false; m_isActive = false; NotifyObservers( PatchProcessAbortedEvent ); } else if ( ( eventid != CORE::CNotifier::DestructionEvent ) && ( eventid != CORE::CNotifier::UnsubscribeEvent ) && ( eventid != CORE::CNotifier::SubscribeEvent ) ) { if ( m_config.HasEngineStartTriggerEvent( eventid ) ) { Start(); } else if ( m_config.HasEngineStopTriggerEvent( eventid ) ) { Stop(); } } } }
bool CResArchive::LoadIndex( void ) {GUCEF_TRACE; GUCEF_DEBUG_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "CResArchive:LoadIndex: Starting index load" ); CORE::CFileAccess file; if ( file.Open( m_idxPath, "rb" ) ) { CORE::UInt32 fileSize = file.GetSize(); GUCEF_DEBUG_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "CResArchive:LoadIndex: Successfully opened index file of " + CORE::UInt32ToString( fileSize ) + " bytes" ); if ( 1 != file.Read( &m_index.recordType, 2, 1 ) ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "Failed to read index header at position " + CORE::UInt32ToString( file.Tell() ) ); file.Close(); return false; } // Get the nr of index entries plus do a sanity check CORE::UInt32 nrOfEntries = fileSize - 2; if ( 0 != nrOfEntries % 8 ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "CResArchive:LoadIndex: The number of bytes in the index is not what we expected, the data will probably be corrupt" ); } nrOfEntries /= 8; // read all the index entries for ( CORE::UInt32 i=0; i<nrOfEntries; ++i ) { IdxRecord idxRecord; if ( 1 != file.Read( &idxRecord.resourceNr, 4, 1 ) ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "Failed to read index entry at pos in index " + CORE::UInt32ToString( file.Tell() ) + " Entry " + CORE::UInt32ToString( i+1 ) + "/" + CORE::UInt32ToString( nrOfEntries ) ); file.Close(); return false; } if ( 1 != file.Read( &idxRecord.offset, 4, 1 ) ) { GUCEF_ERROR_LOG( CORE::LOGLEVEL_IMPORTANT, "Failed to read index entry at pos in index " + CORE::UInt32ToString( file.Tell() ) + " Entry " + CORE::UInt32ToString( i+1 ) + "/" + CORE::UInt32ToString( nrOfEntries ) ); file.Close(); return false; } GUCEF_DEBUG_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "Read index entry: id " + CORE::Int32ToString( idxRecord.resourceNr ) + ", offset " + CORE::Int32ToString( idxRecord.offset ) + ". Pos in index " + CORE::UInt32ToString( file.Tell() ) + " Entry " + CORE::UInt32ToString( i+1 ) + "/" + CORE::UInt32ToString( nrOfEntries ) ); m_index.index.push_back( idxRecord ); } file.Close(); } GUCEF_DEBUG_LOG( CORE::LOGLEVEL_BELOW_NORMAL, "CResArchive:LoadIndex: Successfully loaded " + CORE::UInt32ToString( m_index.index.size() ) + " entries from index" ); return true; }
bool CGUIManager::Init( CORE::TWindowContextPtr& windowContext ) {GUCE_TRACE; if ( !m_initialized ) { GUCEF_SYSTEM_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Initializing GUI system" ); // Apply the loaded configuration (if any exists) if ( LoadConfig( m_guiConfig ) ) { if ( m_drivers.size() == 0 ) { GUCEF_ERROR_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Cannot initialize GUI system because no driver is available" ); return false; } if ( m_selectedDriverName.Length() == 0 ) { GUCEF_SYSTEM_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: No GUI driver specified in config: Using first available driver" ); m_selectedDriverName = (*m_drivers.begin()).first; } TDriverMap::iterator i = m_drivers.find( m_selectedDriverName ); if ( i != m_drivers.end() ) { GUCEF_DEBUG_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Using driver with name " + m_selectedDriverName ); CIGUIDriver* driver = (*i).second; if ( driver->LoadConfig( m_guiConfig ) ) { if ( driver->Initialize( windowContext ) ) { m_initialized = true; GUCEF_SYSTEM_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Successfully initialized the GUI system" ); TGUIInitializedEventData eData( windowContext ); NotifyObservers( GUIInitializedEvent, &eData ); return true; } else { GUCEF_ERROR_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Failed to initialize the GUI system driver" ); } } else { GUCEF_ERROR_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Failed to load the GUI system driver config" ); } } else { GUCEF_ERROR_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Failed to locate the configured GUI system driver" ); } } else { GUCEF_ERROR_LOG( GUCEF::CORE::LOGLEVEL_NORMAL, "CGUIManager: Failed to load the GUI system config" ); return false; } } return true; }
GUCEF::GUI::CWidget* CFormBackendImp::CreateAndHookWrapperForWindow( CEGUI::Window* window ) {GUCEF_TRACE; GUCEF::GUI::CWidget* widgetWrapper = NULL; CString typeName( CString( window->getType().c_str() ).SubstrToChar( '/', false ) ); //if ( "Button" == typeName ) //{ // widgetWrapper = new CButtonImp(); // static_cast< CButtonImp* >( widgetWrapper )->Hook( static_cast< CEGUI::PushButton* >( window ) ); //} //else //if ( "Editbox" == typeName ) //{ // widgetWrapper = new CEditboxImp(); // static_cast< CEditboxImp* >( widgetWrapper )->Hook( static_cast< CEGUI::Editbox* >( window ) ); //} //else //if ( "Listbox" == typeName ) //{ // widgetWrapper = new CListboxImp(); // static_cast< CListboxImp* >( widgetWrapper )->Hook( static_cast< CEGUI::Listbox* >( window ) ); //} //else //if ( "StaticImage" == typeName ) //{ // CString widgetName( CString( window->getName().c_str() ).SubstrToChar( '/', false ) ); // // if ( widgetName == "RenderContext" ) // { // widgetWrapper = new CRenderContextImp(); // static_cast< CRenderContextImp* >( widgetWrapper )->Hook( window ); // } // else // { // widgetWrapper = new CImageFrameImp(); // static_cast< CImageFrameImp* >( widgetWrapper )->Hook( window ); // } //} //else //if ( "StaticText" == typeName ) //{ // widgetWrapper = new CLabelImp(); // static_cast< CLabelImp* >( widgetWrapper )->Hook( window ); //} //else //if ( "Checkbox" == typeName ) //{ // widgetWrapper = new CCheckboxImp(); // static_cast< CCheckboxImp* >( widgetWrapper )->Hook( static_cast< CEGUI::Checkbox* >( window ) ); //} //else //if ( "Combobox" == typeName ) //{ // widgetWrapper = new CComboboxImp(); // static_cast< CComboboxImp* >( widgetWrapper )->Hook( static_cast< CEGUI::Combobox* >( window ) ); //} //if ( "TabControl" == typeName ) //{ // widgetWrapper = new CTabControlImp(); // static_cast< CTabControlImp* >( widgetWrapper )->Hook( static_cast< CEGUI::TabControl* >( window ) ); //} //else //if ( "TabContentPane" == typeName ) //{ // widgetWrapper = new CTabContentPaneImp(); // static_cast< CTabContentPaneImp* >( widgetWrapper )->Hook( window ); //} //else if ( "FrameWindow" == typeName ) { widgetWrapper = new CWindowImp(); static_cast< CWindowImp* >( widgetWrapper )->Hook( static_cast< CEGUI::FrameWindow* >( window ) ); } //else //if ( "MultiColumnList" == typeName ) //{ // widgetWrapper = new CGridViewImp(); // static_cast< CGridViewImp* >( widgetWrapper )->Hook( static_cast< CEGUI::MultiColumnList* >( window ) ); //} //else //if ( "Spinner" == typeName ) //{ // widgetWrapper = new CSpinnerImp(); // static_cast< CSpinnerImp* >( widgetWrapper )->Hook( static_cast< CEGUI::Spinner* >( window ) ); //} //else //if ( "DefaultWindow" == typeName ) //{ // widgetWrapper = new TBasicWidgetImp(); // static_cast< TBasicWidgetImp* >( widgetWrapper )->Hook( window ); //} GUCEF_DEBUG_LOG( 0, "Wrapped and hooked GUI widget for CEGUI widget of type " + typeName ); return widgetWrapper; }
CEGUI::Texture* ImageCodecAdapter::load( const CEGUI::RawDataContainer& data , CEGUI::Texture* result ) {GUCEF_TRACE; if ( NULL == result ) { GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "ImageCodecAdapter:load: Unable to load texture since no texture object was provided" ); return NULL; } CORE::CString imgType = CORE::ExtractFileExtention( result->getName() ); if ( imgType.IsNULLOrEmpty() ) { if ( NULL != m_vfsResourceProvider ) { VfsResourceProvider::DataContainerInfoPtr containerInfo = m_vfsResourceProvider->GetInfoOnLoadedContainer( data ); if ( !containerInfo.IsNULL() ) { imgType = CORE::ExtractFileExtention( containerInfo->requestFilename ); } } } if ( imgType.IsNULLOrEmpty() ) { GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "ImageCodecAdapter:load: Unable to load texture since no image type could be derived from the the texture name" ); return NULL; } IMAGE::CImageCodecRegistry& codecRegistry = IMAGE::CImageGlobal::Instance()->GetImageCodecRegistry(); IMAGE::CImageCodecRegistry::TImageCodecPtr codec; if ( !codecRegistry.TryLookup( imgType, codec ) ) { GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "ImageCodecAdapter:load: Unable to load texture since no image codec could be found for type: " + imgType ); return NULL; } CORE::CDynamicBufferAccess bufferAccess; bufferAccess.LinkTo( data.getDataPtr(), data.getSize() ); IMAGE::CImage image; if ( !codec->Decode( bufferAccess, image ) ) { GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "ImageCodecAdapter:load: Unable to load texture since the image codec decoding failed for type: " + imgType ); return NULL; } IMAGE::TPixelMapPtr pixelMap; if ( !image.TryGetPixelMap( 0, 0, pixelMap ) ) { GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "ImageCodecAdapter:load: Unable to get the pixel map from the image" ); return NULL; } // CEGUI does not support single channel formats if ( pixelMap->GetNumberOfChannelsPerPixel() < 3 ) { GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "ImageCodecAdapter:load: CEGUI cannot handle images with less than 3 channels per pixels" ); return NULL; } // CEGUI only supports a subset of formats, convert as needed IMAGE::TPixelStorageFormat sourceFormat = pixelMap->GetPixelStorageFormat(); switch ( sourceFormat ) { case IMAGE::PSF_BGR: { IMAGE::TPixelMapPtr newPixelMap; if ( !pixelMap->ConvertFormatTo( IMAGE::PSF_RGB, MT::DATATYPE_UINT8, newPixelMap ) ) { GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "ImageCodecAdapter:load: CEGUI cannot handle BGR images and we were unable to convert" ); return NULL; } if ( newPixelMap ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "ImageCodecAdapter:load: CEGUI cannot handle BGR images, we successfully converted the image" ); pixelMap = newPixelMap; } break; } case IMAGE::PSF_BGRA: { IMAGE::TPixelMapPtr newPixelMap; if ( !pixelMap->ConvertFormatTo( IMAGE::PSF_RGBA, MT::DATATYPE_UINT8, newPixelMap ) ) { GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "ImageCodecAdapter:load: CEGUI cannot handle BGRA images and we were unable to convert" ); return NULL; } if ( newPixelMap ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "ImageCodecAdapter:load: CEGUI cannot handle BGRA images, we sucecssfully converted the image" ); pixelMap = newPixelMap; } break; } } // CEGUI only supports a subset of channel sizes, convert as needed // If we get here then the pixels are stored in a supported format either due to conversion or they were already // However the channelsize can still be wrong in the latter case CORE::UInt32 channelSize = pixelMap->GetPixelChannelSize(); if ( channelSize > 1 ) { IMAGE::TPixelStorageFormat sourceFormat = pixelMap->GetPixelStorageFormat(); IMAGE::TPixelMapPtr newPixelMap; if ( !pixelMap->ConvertFormatTo( sourceFormat, MT::DATATYPE_UINT8, newPixelMap ) ) { GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "ImageCodecAdapter:load: CEGUI cannot handle images with multi-byte channels and we were unable to convert" ); return NULL; } if ( newPixelMap ) { GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "ImageCodecAdapter:load: CEGUI cannot handle images with multi-byte channels, we sucecssfully converted the image to single byte" ); pixelMap = newPixelMap; } channelSize = pixelMap->GetPixelChannelSize(); } // Now that we have the image in a format we know CEGUI can handle,.. convert the type enum CEGUI::Texture::PixelFormat ceguiPixelFormat; if ( !TryConvertPixelFormat( pixelMap->GetPixelStorageFormat(), channelSize, ceguiPixelFormat ) ) { GUCEF_WARNING_LOG( CORE::LOGLEVEL_NORMAL, "ImageCodecAdapter:load: Failed to map pixel storage format to a CEGUI supported type" ); return NULL; } CEGUI::Sizef imageSizeInPixels( (float) pixelMap->GetWidthInPixels(), (float) pixelMap->GetHeightInPixels() ); result->loadFromMemory( pixelMap->GetDataPtr(), imageSizeInPixels, ceguiPixelFormat ); GUCEF_DEBUG_LOG( CORE::LOGLEVEL_NORMAL, "ImageCodecAdapter:load: Successfully loaded image into texture obj" ); return result; }