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; 
}
Ejemplo n.º 3
0
bool GUIManager::handleOptionsVisibility ( CEGUI::EventArgs const & )
{
  CEGUI::Window *dsFrame = CEGUI::WindowManager::getSingleton().getWindow(
      "Sheet/DatasetFrame");
  std::string prop = dsFrame->getProperty("Visible").c_str();
  if (prop == "False")
    dsFrame->show();
  else
    dsFrame->hide();
  return true;
}
Ejemplo n.º 4
0
/***********************************************************
refreshthe gui
***********************************************************/
void GameGUI::Refresh()
{
	_cb.Show();_cb.Show();
	_comb.Show();_comb.Show();
	_telb.Show();_telb.Show();
	_invb.Show();_invb.Show();
	_shortb.Show();_shortb.Show();

	_containerb.Refresh();
	_invb.Refresh();
	_shortb.Refresh();

	CEGUI::Window * win = CEGUI::WindowManager::getSingleton().getWindow("PlayerName");
	win->hide();
	win->show();
}
Ejemplo n.º 5
0
bool GUIManager::handleDSDeactivation ( CEGUI::EventArgs const & e )
{
  CEGUI::Window *tab =
    static_cast<CEGUI::WindowEventArgs const &>(e).window->getParent();
  CEGUI::Listbox *lb = static_cast<CEGUI::Listbox *>(tab->getChild(0));
  ListboxItem *item = static_cast<ListboxItem *>(lb->getFirstSelectedItem());
  if (item != NULL) {
    DataManager *dm = static_cast<DataManager *>(item->getUserData());
    dm->deactivate();
    // Enable global scrollbar
    CEGUI::WindowManager & wm = CEGUI::WindowManager::getSingleton();
    CEGUI::Scrollbar *sb = static_cast<CEGUI::Scrollbar *>(tab->getChild(2));
    sb = static_cast<CEGUI::Scrollbar *>(wm.getWindow("Sheet/DimensionSlider"));
    sb->disable();
    CEGUI::Window *desc = wm.getWindow("Sheet/DimensionText");
    desc->hide();
  }
  // TODO handle else-error
  return true;
}
Ejemplo n.º 6
0
// event windowClose(windowName)
bool OnWindowClose(const CEGUI::EventArgs &eventArgs)
{
	CEvents * pEvents = g_pClient->GetEvents();
	String eventName("windowClose");

	if(!pEvents->IsEventRegistered(eventName))
		return false;

	CEGUI::Window * pWindow = static_cast<const CEGUI::WindowEventArgs&>(eventArgs).window;
	CSquirrel * pScript = g_pClient->GetClientScriptManager()->GetGUIManager()->GetScript(pWindow);

	CSquirrelArguments pArguments;
	pArguments.push(pWindow->getName().c_str());

	// Event handler must return 1 to close window, otherwise, 0.
	CSquirrelArgument pReturn = pEvents->Call(eventName, &pArguments, pScript);

	if(pReturn.GetInteger())
		pWindow->hide();

	return true;
}
bool GameInputHandler::keyPressed(const OIS::KeyEvent &evt)
{
	CEGUIInputHandler::keyPressed(evt);
	
	handleCommonKeyboardEvents(evt);
	
	if (game.getSubState() != SUBST_EDITOR)
		return true;
	
	OIS::KeyCode ch = evt.key;

	if (ch == OIS::KC_P)
	{
		// Switch to player mode
		game.createPlayer(camera->getDerivedPosition());
	}
	else if (ch == OIS::KC_I)
	{
		// Blend interface in/out
		CEGUI::Window* guiPage = windowManager.getPage("Editor");
		if (guiPage->isVisible())
			guiPage->hide();
		else
			guiPage->show();
	}
	else if (ch == OIS::KC_M)
	{
		// Output camera position and orientation to log
		/*string str = "INFO:   position=\"" + StringConverter::toString(game.cameraNode->getPosition()) + "\"" +
					" yawOrientation=\"" + StringConverter::toString(game.cameraYawNode->getOrientation()) + "\"" +
					" pitchOrientation=\"" + StringConverter::toString(game.cameraPitchNode->getOrientation()) + "\"";
		*/
		string str = "INFO:   position=\"" + StringConverter::toString(game.cameraNode->getPosition()) + "\"" +
		" yaw=\"" + StringConverter::toString(game.cameraYawNode->getOrientation().getYaw(false)) + "\"" +
		" pitch=\"" + StringConverter::toString(game.cameraPitchNode->getOrientation().getPitch(false)) + "\"" +
		" roll=\"" + StringConverter::toString(game.cameraRollNode->getOrientation().getRoll(false)) + "\"";
		
		LogManager::getSingleton().logMessage(str.c_str(), LML_CRITICAL);
	}
	else if (ch == OIS::KC_E)
	{
		// Place objects
		game.spawnObject(CEGUI::EventArgs());
	}
	else if (evt.key == OIS::KC_O)
	{
		// Toggle polygon mode
		camera->setPolygonMode((PolygonMode)((camera->getPolygonMode() % 3) + 1));
		if (camera->getPolygonMode() == PM_SOLID)
			vp->setClearEveryFrame(true, FBT_DEPTH);
		else
			vp->setClearEveryFrame(true, FBT_COLOUR | FBT_DEPTH);
	}
	
	if (objectManager.getEditObjects())
	{
		if (ch == OIS::KC_G)
			objectManager.setEditMode(EDITMODE_GRAB);
		else if (ch == OIS::KC_R)
			objectManager.setEditMode(EDITMODE_ROTATE);
		else if (ch == OIS::KC_T)
			objectManager.setEditMode(EDITMODE_SCALE);
		else if (ch == OIS::KC_X)
			objectManager.setEditDirection(Vector3(1, 0, 0));
		else if (ch == OIS::KC_Y)
			objectManager.setEditDirection(Vector3(0, 1, 0));
		else if (ch == OIS::KC_Z)
			objectManager.setEditDirection(Vector3(0, 0, 1));
	}

	return true;
}