[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bgluon=5D_player=3A_KDE_Extended_Player=3A_Add_rende?=
From:       Laszlo Papp <djszapi () archlinux ! us>
Date:       2011-02-06 22:19:34
Message-ID: 20110206221934.8EA53A60BE () git ! kde ! org
[Download RAW message or body]

Git commit af927bcb65018577c439ad69c2ca7064df6fb477 by Laszlo Papp.
Committed on 06/02/11 at 23:20.
Pushed by lpapp into branch 'master'.

KDE Extended Player: Add renderwidget and other neccesary calls.

M  +39   -5    player/kdeext/mainwindow.cpp     
M  +2    -0    player/kdeext/mainwindow.h     

http://commits.kde.org/gluon/af927bcb65018577c439ad69c2ca7064df6fb477

diff --git a/player/kdeext/mainwindow.cpp b/player/kdeext/mainwindow.cpp
index a2c3dbf..5901707 100644
--- a/player/kdeext/mainwindow.cpp
+++ b/player/kdeext/mainwindow.cpp
@@ -19,6 +19,8 @@
 
 #include "mainwindow.h"
 
+#include "input/inputmanager.h"
+
 #include <core/debughelper.h>
 #include <engine/game.h>
 #include <engine/gameproject.h>
@@ -130,6 +132,18 @@ void MainWindow::setupActions()
 
 void MainWindow::startGame( )
 {
+    GluonCore::GluonObjectFactory::instance()->loadPlugins();
+
+    m_project->loadFromFile( m_gameFileName );
+
+    setWindowFilePath( m_gameFileName );
+    d->title = windowTitle();
+
+    GluonEngine::Game::instance()->setGameProject( m_project );
+    GluonEngine::Game::instance()->setCurrentScene( m_project->entryPoint() );
+
+    setFocus();
+
     // if( GluonEngine::Game::instance()->isRunning() )
     // {
         // GluonEngine::Game::instance()->setPause( false );
@@ -148,7 +162,7 @@ void MainWindow::startGame( )
         //Start the game loop
         //Note that this starts an infinite loop in Game
         GluonEngine::Game::instance()->runGame();
-
+        QApplication::instance()->exit();
         //This happens after we exit the game loop
         // stateChanged( "playing", StateReverse );
 
@@ -293,14 +307,14 @@ void MainWindow::openProject()
         return;
     }
 
-    // GluonCore::GluonObjectFactory::instance()->loadPlugins();
     d->widget = new GluonGraphics::RenderWidget( this );
     setCentralWidget( d->widget );
 
-    m_project->loadFromFile( m_gameFileName );
-    GluonEngine::Game::instance()->setGameProject( m_project );
-    GluonEngine::Game::instance()->setCurrentScene( m_project->entryPoint() );
+    connect( GluonEngine::Game::instance(), SIGNAL( painted( int ) ), d->widget, SLOT( updateGL() ) );
+    connect( GluonEngine::Game::instance(), SIGNAL( painted( int ) ), SLOT( countFrames( int ) ) );
+    connect( GluonEngine::Game::instance(), SIGNAL( updated( int ) ), SLOT( updateTitle( int ) ) );
 
+    GluonInput::InputManager::instance()->setFilteredObject(d->widget);
     QTimer::singleShot( 1000, this, SLOT( startGame() ) );
 }
 
@@ -311,3 +325,23 @@ void MainWindow::activated( QModelIndex index )
     }
 }
 
+void MainWindow::updateTitle( int msec )
+{
+    d->msecElapsed += msec;
+
+    static int fps = 0;
+    if( d->msecElapsed > 1000 )
+    {
+        fps = d->frameCount;
+        d->frameCount = 0;
+        d->msecElapsed = 0;
+    }
+
+    setWindowTitle( d->title + QString( " (%1 FPS)" ).arg( fps ) );
+}
+
+void MainWindow::countFrames( int /* time */ )
+{
+    d->frameCount++;
+}
+
diff --git a/player/kdeext/mainwindow.h b/player/kdeext/mainwindow.h
index 9ca1e6f..07234ef 100644
--- a/player/kdeext/mainwindow.h
+++ b/player/kdeext/mainwindow.h
@@ -78,6 +78,8 @@ namespace GluonKDEPlayer {
             void showGames();
             void showGameDetails( const QModelIndex& index );
             void activated( QModelIndex index );
+            void countFrames( int );
+            void updateTitle( int msec );
 
         private:
             void setupActions();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic