1 /**************************************************************************
2 Ghosts Overboard - a game for Maemo 5
4 Copyright (C) 2011 Heli Hyvättinen
6 This file is part of Ghosts Overboard
8 Ghosts Overboard is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 **************************************************************************/
23 #include "mainwindow.h"
29 #include <QMessageBox>
30 #include <QApplication>
32 #include <QPushButton>
33 #include <QVBoxLayout>
37 MainWindow::MainWindow(QWidget *parent)
40 setWindowIcon(QIcon(":/pix/laiva_3aave.png"));
41 setWindowTitle("Ghosts Overboard");
43 pScene_ = new SeaScene ();
44 connect(pScene_,SIGNAL(allGhostsPicked()),pScene_,SLOT(nextLevel()));
46 pView_ = new SeaView ();
49 pView_->setScene(pScene_);
50 setCentralWidget(pView_);
52 connect(pView_,SIGNAL(screenTapped()),pScene_,SLOT(handleScreenTapped()));
53 connect(pView_,SIGNAL(goingBackgroung()),pScene_,SLOT(forcePause()));
54 connect(pView_,SIGNAL(goingForeground()),pScene_,SLOT(softContinue()));
60 //the boundaries of the scene are set to match the size of the view window, which is not
61 //available in the constructor --> timer needed
62 QTimer::singleShot(100,this,SLOT(initializeBoundaries()));
67 MainWindow::~MainWindow()
72 void MainWindow::initializeBoundaries()
74 //the boundaries of the scene are set to match the size of the view window, and
75 //the view is set to show exactly the whole scene area
77 //this occasionally gives a tiny scene, so using a fixed size fit for N900/Maemo5 until a fix is found
79 // QPoint topleft (0,0);
80 // QSize windowsize = pView_->size();
81 // QRectF rectangle (topleft,windowsize);
83 QRectF rectangle(0,0,800,480);
85 pScene_->setSceneRect(rectangle);
86 pView_->setSceneRect(rectangle);
88 // qDebug() << "Initialized boundaries" << rectangle.right() << rectangle.bottom() << pView_->width() << pView_->height();
90 pScene_->restartLevel();