summaryrefslogtreecommitdiff
path: root/noncore/games/parashoot/interface.cpp
Unidiff
Diffstat (limited to 'noncore/games/parashoot/interface.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/parashoot/interface.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/noncore/games/parashoot/interface.cpp b/noncore/games/parashoot/interface.cpp
index 5c9b0ef..8ec7032 100644
--- a/noncore/games/parashoot/interface.cpp
+++ b/noncore/games/parashoot/interface.cpp
@@ -1,106 +1,108 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "interface.h" 21#include "interface.h"
22#include "man.h" 22#include "man.h"
23 23
24#include <opie2/oresource.h>
25
24#include <qtopia/qpeapplication.h> 26#include <qtopia/qpeapplication.h>
25#include <qtopia/resource.h>
26 27
27#include <qtoolbar.h> 28#include <qtoolbar.h>
28#include <qtoolbutton.h> 29#include <qtoolbutton.h>
29 30
30ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) : 31ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) :
31 QMainWindow(parent,name,f), 32 QMainWindow(parent,name,f),
32 canvas( 232, 258 ), 33 canvas( 232, 258 ),
33 cannon(NULL), 34 cannon(NULL),
34 base(NULL), 35 base(NULL),
35 gamestopped( true ), 36 gamestopped( true ),
36 waitover( false ), 37 waitover( false ),
37 fanfare("level_up"), 38 fanfare("level_up"),
38 score(0) 39 score(0)
39{ 40{
40 QPEApplication::grabKeyboard(); 41 QPEApplication::grabKeyboard();
41 QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff ); 42 QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff );
42 43
43 updatespeed = 80; 44 updatespeed = 80;
44 canvas.setAdvancePeriod(80); 45 canvas.setAdvancePeriod(80);
45 46
46 pb = new QCanvasView(&canvas, this); 47 pb = new QCanvasView(&canvas, this);
47 pb->setFocus(); 48 pb->setFocus();
48 49
49 setToolBarsMovable( FALSE ); 50 setToolBarsMovable( FALSE );
50 51
51 QToolBar* toolbar = new QToolBar(this); 52 QToolBar* toolbar = new QToolBar(this);
52 toolbar->setHorizontalStretchable( TRUE ); 53 toolbar->setHorizontalStretchable( TRUE );
53 54
54 setCaption( tr("ParaShoot") ); 55 setCaption( tr("ParaShoot") );
55 new QToolButton( Resource::loadIconSet("new"), tr("New Game"), 0, 56 QToolButton *btn = new QToolButton( Opie::Core::OResource::loadPixmap("new", Opie::Core::OResource::SmallIcon),
56 this, SLOT(newGame()), toolbar, "New Game"); 57 tr("New Game"), 0, this, SLOT(newGame()), toolbar, "New Game");
58 btn->setUsesBigPixmap( qApp->desktop()->size().width() > 330 );
57 59
58 levelscore = new QLabel(toolbar); 60 levelscore = new QLabel(toolbar);
59 levelscore->setBackgroundMode( PaletteButton ); 61 levelscore->setBackgroundMode( PaletteButton );
60 levelscore->setAlignment( AlignRight | AlignVCenter | ExpandTabs ); 62 levelscore->setAlignment( AlignRight | AlignVCenter | ExpandTabs );
61 toolbar->setStretchableWidget( levelscore ); 63 toolbar->setStretchableWidget( levelscore );
62 showScore(0,0); 64 showScore(0,0);
63 65
64 setCentralWidget(pb); 66 setCentralWidget(pb);
65 67
66 autoDropTimer = new QTimer(this); 68 autoDropTimer = new QTimer(this);
67 connect (autoDropTimer, SIGNAL(timeout()), this, SLOT(play()) ); 69 connect (autoDropTimer, SIGNAL(timeout()), this, SLOT(play()) );
68 70
69 pauseTimer = new QTimer(this); 71 pauseTimer = new QTimer(this);
70 connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) ); 72 connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) );
71 73
72 setFocusPolicy(StrongFocus); 74 setFocusPolicy(StrongFocus);
73} 75}
74 76
75 77
76void ParaShoot::resizeEvent(QResizeEvent *) 78void ParaShoot::resizeEvent(QResizeEvent *)
77{ 79{
78 QSize s = centralWidget()->size(); 80 QSize s = centralWidget()->size();
79 int fw = style().defaultFrameWidth(); 81 int fw = style().defaultFrameWidth();
80 canvas.resize( s.width() - fw - 2, s.height() - fw - 2); 82 canvas.resize( s.width() - fw - 2, s.height() - fw - 2);
81 83
82 QImage bgimage = Resource::loadImage("parashoot/sky"); 84 QImage bgimage = Opie::Core::OResource::loadImage("parashoot/sky");
83 QPixmap bgpixmap; 85 QPixmap bgpixmap;
84 86
85 bgpixmap.convertFromImage(bgimage.smoothScale(canvas.width(), 87 bgpixmap.convertFromImage(bgimage.smoothScale(canvas.width(),
86 canvas.height()), QPixmap::Auto); 88 canvas.height()), QPixmap::Auto);
87 canvas.setBackgroundPixmap(bgpixmap); 89 canvas.setBackgroundPixmap(bgpixmap);
88 90
89 if (base) { 91 if (base) {
90 base->reposition(); 92 base->reposition();
91 } 93 }
92 94
93 if (cannon) { 95 if (cannon) {
94 cannon->reposition(); 96 cannon->reposition();
95 } 97 }
96} 98}
97 99
98void ParaShoot::focusOutEvent (QFocusEvent *) 100void ParaShoot::focusOutEvent (QFocusEvent *)
99{ 101{
100 if (!gamestopped) 102 if (!gamestopped)
101 canvas.setAdvancePeriod(-1); 103 canvas.setAdvancePeriod(-1);
102} 104}
103 105
104void ParaShoot::focusInEvent (QFocusEvent *) 106void ParaShoot::focusInEvent (QFocusEvent *)
105{ 107{
106 if (!gamestopped) 108 if (!gamestopped)