Ejemplo n.º 1
0
    void LoadingScreen::loadingOn()
    {
        mLoadingOnTime = mTimer.time_m();
        // Early-out if already on
        if (mMainWidget->getVisible())
            return;

        if (mViewer->getIncrementalCompileOperation())
        {
            mViewer->getIncrementalCompileOperation()->setMaximumNumOfObjectsToCompilePerFrame(100);
            mViewer->getIncrementalCompileOperation()->setTargetFrameRate(getTargetFrameRate());
        }

        // Assign dummy bounding sphere callback to avoid the bounding sphere of the entire scene being recomputed after each frame of loading
        // We are already using node masks to avoid the scene from being updated/rendered, but node masks don't work for computeBound()
        mViewer->getSceneData()->setComputeBoundingSphereCallback(new DontComputeBoundCallback);

        mShowWallpaper = (MWBase::Environment::get().getStateManager()->getState()
                == MWBase::StateManager::State_NoGame);

        setVisible(true);

        if (mShowWallpaper)
        {
            changeWallpaper();
        }

        MWBase::Environment::get().getWindowManager()->pushGuiMode(mShowWallpaper ? GM_LoadingWallpaper : GM_Loading);
    }
Ejemplo n.º 2
0
    void LoadingScreen::loadingOn()
    {
        mLoadingOnTime = mTimer.time_m();
        // Early-out if already on
        if (mMainWidget->getVisible())
            return;

        if (mViewer->getIncrementalCompileOperation())
        {
            mViewer->getIncrementalCompileOperation()->setMaximumNumOfObjectsToCompilePerFrame(100);
            mViewer->getIncrementalCompileOperation()->setTargetFrameRate(mTargetFrameRate);
        }

        bool showWallpaper = (MWBase::Environment::get().getStateManager()->getState()
                == MWBase::StateManager::State_NoGame);

        if (!showWallpaper)
        {
            // Copy the current framebuffer onto a texture and display that texture as the background image
            // Note, we could also set the camera to disable clearing and have the background image transparent,
            // but then we get shaking effects on buffer swaps.

            if (!mTexture)
            {
                mTexture = new osg::Texture2D;
                mTexture->setInternalFormat(GL_RGB);
                mTexture->setResizeNonPowerOfTwoHint(false);
            }

            int width = mViewer->getCamera()->getViewport()->width();
            int height = mViewer->getCamera()->getViewport()->height();
            mViewer->getCamera()->setInitialDrawCallback(new CopyFramebufferToTextureCallback(mTexture, width, height));

            if (!mGuiTexture.get())
            {
                mGuiTexture.reset(new osgMyGUI::OSGTexture(mTexture));
            }

            mBackgroundImage->setBackgroundImage("");

            mBackgroundImage->setRenderItemTexture(mGuiTexture.get());
            mBackgroundImage->getSubWidgetMain()->_setUVSet(MyGUI::FloatRect(0.f, 1.f, 1.f, 0.f));
        }

        setVisible(true);

        if (showWallpaper)
        {
            changeWallpaper();
        }

        MWBase::Environment::get().getWindowManager()->pushGuiMode(showWallpaper ? GM_LoadingWallpaper : GM_Loading);
    }
Ejemplo n.º 3
0
    void LoadingScreen::loadingOn()
    {
        setVisible(true);
        mLoadingOn = true;

        if (mFirstLoad)
        {
            changeWallpaper();

            mWindowManager.pushGuiMode(GM_LoadingWallpaper);
        }
        else
        {
            mBackgroundImage->setImageTexture("");
            mWindowManager.pushGuiMode(GM_Loading);
        }
    }
Ejemplo n.º 4
0
    void LoadingScreen::loadingOn()
    {
        setVisible(true);
        mLoadingOn = true;

        if (mFirstLoad)
        {
            changeWallpaper();

            MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_LoadingWallpaper);
        }
        else
        {
            mBackgroundImage->setImageTexture("");
            MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Loading);
        }
    }
Ejemplo n.º 5
0
    void LoadingScreen::draw()
    {
        if (!needToDrawLoadingScreen())
            return;

        if (mShowWallpaper && mTimer.time_m() > mLastWallpaperChangeTime + 5000*1)
        {
            mLastWallpaperChangeTime = mTimer.time_m();
            changeWallpaper();
        }

        if (!mShowWallpaper && mLastRenderTime < mLoadingOnTime)
        {
            setupCopyFramebufferToTextureCallback();
        }

        // Turn off rendering except the GUI
        int oldUpdateMask = mViewer->getUpdateVisitor()->getTraversalMask();
        int oldCullMask = mViewer->getCamera()->getCullMask();
        mViewer->getUpdateVisitor()->setTraversalMask(MWRender::Mask_GUI|MWRender::Mask_PreCompile);
        mViewer->getCamera()->setCullMask(MWRender::Mask_GUI|MWRender::Mask_PreCompile);

        MWBase::Environment::get().getInputManager()->update(0, true, true);

        //osg::Timer timer;
        // at the time this function is called we are in the middle of a frame,
        // so out of order calls are necessary to get a correct frameNumber for the next frame.
        // refer to the advance() and frame() order in Engine::go()
        mViewer->eventTraversal();
        mViewer->updateTraversal();
        mViewer->renderingTraversals();
        mViewer->advance(mViewer->getFrameStamp()->getSimulationTime());
        //std::cout << "frame took " << timer.time_m() << std::endl;

        //if (mViewer->getIncrementalCompileOperation())
            //std::cout << "num to compile " << mViewer->getIncrementalCompileOperation()->getToCompile().size() << std::endl;

        // resume 3d rendering
        mViewer->getUpdateVisitor()->setTraversalMask(oldUpdateMask);
        mViewer->getCamera()->setCullMask(oldCullMask);

        mLastRenderTime = mTimer.time_m();
    }
Ejemplo n.º 6
0
    void LoadingScreen::loadingOn()
    {
        // Temporarily turn off VSync, we want to do actual loading rather than waiting for the screen to sync.
        // Threaded loading would be even better, of course - especially because some drivers force VSync to on and we can't change it.
        // In Ogre 1.8, the swapBuffers argument is useless and setVSyncEnabled is bugged with GLX, nothing we can do :/
        mVSyncWasEnabled = mWindow->isVSyncEnabled();
        #if OGRE_VERSION >= (1 << 16 | 9 << 8 | 0)
        mWindow->setVSyncEnabled(false);
        #endif

        setVisible(true);

        if (mFirstLoad)
        {
            changeWallpaper();
        }
        else
        {
            mBackgroundImage->setImageTexture("");
        }

        MWBase::Environment::get().getWindowManager()->pushGuiMode(mFirstLoad ? GM_LoadingWallpaper : GM_Loading);
    }
Ejemplo n.º 7
0
void WallpaperChooser::wallSelected(QListWidgetItem *i) // When the user click on an image, inform the desktop to show this wall
{
    emit changeWallpaper(m_URLList.at(wallpaperList->row(i)));
}
Ejemplo n.º 8
0
void IconView::init()
{
    KConfig config;
    KConfigGroup generalGroup( &config, "General" );
    m_wallpaper = generalGroup.readEntry( "Wallpaper", DEFAULT_WALLPAPER );

    delete m_pixmap;
    m_pixmap = new QPixmap( m_wallpaper );
    QPalette p;
    p.setBrush( QPalette::Base, QBrush( *m_pixmap ) );
    setPalette( p );

    m_model = new KDirModel( this );
    KDirLister* lister = new KDirLister( this );
    lister->openUrl( KUrl( QDir::homePath() ) );
    m_model->setDirLister( lister );

    m_delegate = new KFileItemDelegate( this );
    m_delegate->setMaximumSize( QSize( 64, 64 ) );
    m_delegate->setShadowOffset( QPointF( 1, 1 ) );
    m_delegate->setShadowColor( QColor( 0xff, 0xff, 0xff ) );
    m_delegate->setShadowBlur( 1 );
    m_delegate->setWrapMode( QTextOption::WrapAtWordBoundaryOrAnywhere );

    m_proxyModel = new KDirSortFilterProxyModel( this );
    m_proxyModel->setSourceModel( m_model );

    setModel( m_proxyModel );
    setItemDelegate( m_delegate );

    m_selectionModel = new QItemSelectionModel( m_proxyModel );
    setSelectionModel( m_selectionModel );

    /// create actions
    KAction* cut = KStandardAction::cut( this, SLOT(cut()), this );
    KAction* copy = KStandardAction::copy( this, SLOT(copy()), this );

    KIO::FileUndoManager* manager = KIO::FileUndoManager::self();
    KAction* undo = KStandardAction::undo( manager, SLOT(undo()), this );
    connect( manager, SIGNAL(undoAvailable(bool)), undo, SLOT(setEnabled(bool)) );
    connect( manager, SIGNAL(undoTextChanged(const QString&)), SLOT(undoTextChanged(const QString&)) );
    undo->setEnabled( manager->undoAvailable() );

    KAction* paste = KStandardAction::paste( this, SLOT(paste()), this );
    KAction* pasteTo = KStandardAction::paste( this, SLOT(pasteTo()), this );
    pasteTo->setEnabled( false ); // Only enabled during popupMenu()

    QString actionText = KIO::pasteActionText();
    if ( !actionText.isEmpty() )
        paste->setText( actionText );
    else
        paste->setEnabled( false );

    KAction* refresh = new KAction(KIcon("user-desktop"), i18n("&Refresh Desktop"), this);
    connect( refresh, SIGNAL(triggered()), this, SLOT(refresh()) );

    KAction* wallpaper = new KAction(KIcon("tools-wizard"), i18n("&Change Wallpaper..."), this);
    connect( wallpaper, SIGNAL(triggered()), this, SLOT(changeWallpaper()) );

    KAction* rename = new KAction(KIcon("edit-rename"), i18n("&Rename"), this);
    rename->setShortcut( Qt::Key_F2 );
    connect( rename, SIGNAL(triggered()), SLOT(rename()) );

    KAction* trash = new KAction(KIcon("user-trash"), i18n("&Move to Trash"), this);
    trash->setShortcut( Qt::Key_Delete );
    connect( trash, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)),
             this, SLOT(moveToTrash(Qt::MouseButtons, Qt::KeyboardModifiers)) );

    KAction* del = new KAction(KIcon("edit-delete"), i18n("&Delete"), this);
    del->setShortcut( Qt::SHIFT + Qt::Key_Delete );
    connect( del, SIGNAL(triggered()), this, SLOT(deleteSelectedItems()) );

    KAction* emptyTrash = new KAction(KIcon("trash-empty"), i18n("&Empty Trash Bin"), this);
    KConfig trashConfig( "trashrc", KConfig::SimpleConfig );
    emptyTrash->setEnabled( !trashConfig.group( "Status" ).readEntry( "Empty", true ) );
    connect( emptyTrash, SIGNAL(triggered()), this, SLOT(emptyTrashBin()) );

    // Create the new menu
    m_newMenu = new KNewFileMenu(&m_actionCollection, "new_menu", this);
    connect( m_newMenu->menu(), SIGNAL(aboutToShow()), this, SLOT(aboutToShowCreateNew()) );

    m_actionCollection.addAction( "undo", undo );
    m_actionCollection.addAction( "cut", cut );
    m_actionCollection.addAction( "copy", copy );
    m_actionCollection.addAction( "paste", paste );
    m_actionCollection.addAction( "pasteto", pasteTo );
    m_actionCollection.addAction( "refresh", refresh );
    m_actionCollection.addAction( "wallpaper", wallpaper );
    m_actionCollection.addAction( "rename", rename );
    m_actionCollection.addAction( "trash", trash );
    m_actionCollection.addAction( "del", del );
    m_actionCollection.addAction( "empty_trash", emptyTrash );
}
Ejemplo n.º 9
0
    void LoadingScreen::draw()
    {
        const float loadingScreenFps = 20.f;

        if (mTimer.getMilliseconds () > mLastRenderTime + (1.f/loadingScreenFps) * 1000.f)
        {
            mLastRenderTime = mTimer.getMilliseconds ();

            if (mFirstLoad && mTimer.getMilliseconds () > mLastWallpaperChangeTime + 5000*1)
            {
                mLastWallpaperChangeTime = mTimer.getMilliseconds ();
                changeWallpaper();
            }

            // Turn off rendering except the GUI
            mSceneMgr->clearSpecialCaseRenderQueues();
            // SCRQM_INCLUDE with RENDER_QUEUE_OVERLAY does not work.
            for (int i = 0; i < Ogre::RENDER_QUEUE_MAX; ++i)
            {
                if (i > 0 && i < 96)
                    mSceneMgr->addSpecialCaseRenderQueue(i);
            }
            mSceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE);

            MWBase::Environment::get().getInputManager()->update(0, true);

            Ogre::CompositorChain* chain = Ogre::CompositorManager::getSingleton().getCompositorChain(mWindow->getViewport(0));

            bool hasCompositor = chain->getCompositor ("gbufferFinalizer");


            if (!hasCompositor)
            {
                mWindow->getViewport(0)->setClearEveryFrame(false);
            }
            else
            {
                if (!mFirstLoad)
                {
                    mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(chain->getCompositor ("gbufferFinalizer")->getTextureInstance ("no_mrt_output", 0)->getName());
                    mRectangle->setVisible(true);
                }

                for (unsigned int i = 0; i<chain->getNumCompositors(); ++i)
                {
                    Ogre::CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), chain->getCompositor(i)->getCompositor()->getName(), false);
                }
            }

            // First, swap buffers from last draw, then, queue an update of the
            // window contents, but don't swap buffers (which would have
            // caused a sync / flush and would be expensive).
            // We're doing this so we can do some actual loading while the GPU is busy with the render.
            // This means the render is lagging a frame behind, but this is hardly noticable.
            mWindow->swapBuffers();

            mWindow->update(false);

            if (!hasCompositor)
                mWindow->getViewport(0)->setClearEveryFrame(true);
            else
            {
                for (unsigned int i = 0; i<chain->getNumCompositors(); ++i)
                {
                    Ogre::CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), chain->getCompositor(i)->getCompositor()->getName(), true);
                }
            }

            mRectangle->setVisible(false);

            // resume 3d rendering
            mSceneMgr->clearSpecialCaseRenderQueues();
            mSceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE);
        }
    }
Ejemplo n.º 10
0
    void LoadingScreen::setLoadingProgress (const std::string& stage, int depth, int current, int total)
    {
        if (!mLoadingOn)
            loadingOn();

        const int numRefLists = 20;

        if (depth == 0)
        {
            mCurrentCellLoading = current;
            mTotalCellsLoading = total;

            mCurrentRefLoading = 0;
            mCurrentRefList = 0;
        }
        else if (depth == 1)
        {
            mCurrentRefLoading = current;
            mTotalRefsLoading = total;
        }

        assert (mTotalCellsLoading != 0);

        float refProgress;
        if (mTotalRefsLoading <= 1)
            refProgress = 1;
        else
            refProgress = float(mCurrentRefLoading) / float(mTotalRefsLoading-1);
        refProgress += mCurrentRefList;
        refProgress /= numRefLists;

        assert(refProgress <= 1 && refProgress >= 0);

        if (depth == 1 && mCurrentRefLoading == mTotalRefsLoading-1)
            ++mCurrentRefList;

        float progress = (float(mCurrentCellLoading)+refProgress) / float(mTotalCellsLoading);
        assert(progress <= 1 && progress >= 0);

        mLoadingText->setCaption(stage + "... ");
        mProgressBar->setProgressPosition (static_cast<size_t>(progress * 1000));

        static float loadingScreenFps = 30.f;

        if (mTimer.getMilliseconds () > mLastRenderTime + (1.f/loadingScreenFps) * 1000.f)
        {
            mLastRenderTime = mTimer.getMilliseconds ();

            if (mFirstLoad && mTimer.getMilliseconds () > mLastWallpaperChangeTime + 3000*1)
            {
                mLastWallpaperChangeTime = mTimer.getMilliseconds ();
                changeWallpaper();
            }

            // Turn off rendering except the GUI
            mSceneMgr->clearSpecialCaseRenderQueues();
            // SCRQM_INCLUDE with RENDER_QUEUE_OVERLAY does not work.
            for (int i = 0; i < Ogre::RENDER_QUEUE_MAX; ++i)
            {
                if (i > 0 && i < 96)
                    mSceneMgr->addSpecialCaseRenderQueue(i);
            }
            mSceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE);

            // always update input before rendering something, otherwise mygui goes crazy when something was entered in the frame before
            // (e.g. when using "coc" console command, it would enter an infinite loop and crash due to overflow)
            //MWBase::Environment::get().getInputManager()->update(0, true);

            Ogre::CompositorChain* chain = Ogre::CompositorManager::getSingleton().getCompositorChain(mWindow->getViewport(0));

            bool hasCompositor = chain->getCompositor ("gbufferFinalizer");


            if (!hasCompositor)
            {
                mWindow->getViewport(0)->setClearEveryFrame(false);
            }
            else
            {
                if (!mFirstLoad)
                {
                    mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(chain->getCompositor ("gbufferFinalizer")->getTextureInstance ("no_mrt_output", 0)->getName());
                    mRectangle->setVisible(true);
                }

                for (unsigned int i = 0; i<chain->getNumCompositors(); ++i)
                {
                    Ogre::CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), chain->getCompositor(i)->getCompositor()->getName(), false);
                }
            }

            mWindow->update();

            if (!hasCompositor)
                mWindow->getViewport(0)->setClearEveryFrame(true);
            else
            {
                for (unsigned int i = 0; i<chain->getNumCompositors(); ++i)
                {
                    Ogre::CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), chain->getCompositor(i)->getCompositor()->getName(), true);
                }
            }

            mRectangle->setVisible(false);

            // resume 3d rendering
            mSceneMgr->clearSpecialCaseRenderQueues();
            mSceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_EXCLUDE);
        }
    }