[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/games/astrododge/src
From: Rivo Laks <rivolaks () hot ! ee>
Date: 2009-08-08 17:58:02
Message-ID: 1249754282.651518.23903.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1008937 by rivol:
Menus are now handled by a separate MenuView class.
M +1 -0 CMakeLists.txt
M +2 -33 displaywidget.cpp
M +0 -7 displaywidget.h
M +7 -3 mainwindow.cpp
M +2 -0 mainwindow.h
A menuview.cpp [License: GPL (v3+)]
A menuview.h [License: GPL (v3+)]
--- trunk/playground/games/astrododge/src/CMakeLists.txt #1008936:1008937
@@ -13,6 +13,7 @@
loadingview.cpp
main.cpp
mainwindow.cpp
+ menuview.cpp
model.cpp
planet.cpp
renderinfo.cpp
--- trunk/playground/games/astrododge/src/displaywidget.cpp #1008936:1008937
@@ -26,10 +26,9 @@
#include <KDebug>
#include <KStandardDirs>
-#include <QVBoxLayout>
-#include <QPushButton>
-#include <QGraphicsProxyWidget>
#include <QTimer>
+#include <QMouseEvent>
+#include <QLayout>
using namespace KGLLib;
@@ -37,10 +36,7 @@
DisplayWidget::DisplayWidget(QWidget* parent) : HdrGLWidget(createGLFormat(), \
parent) {
mProxy = 0;
- mActiveWidget = 0;
- mMainMenu = 0;
-
setAutoExposureRange(0.4, 2.5);
setAutoExposureTarget(0.15);
}
@@ -121,9 +117,6 @@
{
KGLLib::HdrGLWidget::resizeGL(width, height);
- if (mActiveWidget) {
- mActiveWidget->setPos((width - mActiveWidget->boundingRect().width()) / 2, \
(height - mActiveWidget->boundingRect().height()) / 2);
- }
foreach (GLView* v, mViews) {
v->resize(width, height);
}
@@ -149,30 +142,6 @@
}
}
-void DisplayWidget::hideMenus()
-{
- if (mActiveWidget) {
- mActiveWidget->hide();
- }
- mActiveWidget = 0;
-}
-
-void DisplayWidget::showMainMenu()
-{
- if (!mMainMenu) {
- mMainMenu = new QWidget();
- mMainMenu->setWindowOpacity(0.8);
- mMainMenu->setLayout(new QVBoxLayout);
-
- QPushButton* startButton = new QPushButton("New game", mMainMenu);
- connect(startButton, SIGNAL(clicked(bool)), this, SIGNAL(startNewGame()));
- mMainMenu->layout()->addWidget(startButton);
- }
-
- mActiveWidget = proxy()->addWidget(mMainMenu);
-}
-
-
void DisplayWidget::showHdrConfig()
{
QWidget* hdrControlWin = mProxy->createWindow("HDR Controls");
--- trunk/playground/games/astrododge/src/displaywidget.h #1008936:1008937
@@ -46,15 +46,10 @@
void appendView(GLView* view);
void removeView(GLView* view);
- void showMainMenu();
- void hideMenus();
-
public slots:
void showHdrConfig();
signals:
- void startNewGame();
-
void signalRotateShip(int x, int y);
protected:
@@ -66,9 +61,7 @@
QString mDataDir;
KGLLib::WidgetProxy* mProxy;
- QGraphicsProxyWidget* mActiveWidget;
- QWidget* mMainMenu;
QPoint mMousePos;
QList<GLView*> mViews;
--- trunk/playground/games/astrododge/src/mainwindow.cpp #1008936:1008937
@@ -26,6 +26,7 @@
#include "gameguiview.h"
#include "loadingview.h"
#include "datastore.h"
+#include "menuview.h"
#include <kgllib/widgetproxy.h>
@@ -67,8 +68,11 @@
setupActions();
setupGUI();
- mDisplay->showMainMenu();
- connect(mDisplay, SIGNAL(startNewGame()), this, SLOT(startNewGame()));
+ mMenuView = new MenuView(mDisplay);
+ connect(mMenuView, SIGNAL(startNewGame()), this, SLOT(startNewGame()));
+ connect(mMenuView, SIGNAL(quitGame()), this, SLOT(close()));
+
+ mDisplay->appendView(mMenuView);
}
MainWindow::~MainWindow()
@@ -140,7 +144,7 @@
void MainWindow::startNewGame()
{
kDebug();
- mDisplay->hideMenus();
+ mMenuView->hide();
mWorld = new GameWorld(this, mData);
mShipLightAction->setChecked(false);
--- trunk/playground/games/astrododge/src/mainwindow.h #1008936:1008937
@@ -25,6 +25,7 @@
class DisplayWidget;
class LoadingView;
class DataStore;
+class MenuView;
class KToggleAction;
class KAction;
@@ -67,6 +68,7 @@
GameView* mView;
LoadingView* mLoadingView;
+ MenuView* mMenuView;
// TODO: belongs to GameWorld
bool mGameRunning;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic