summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/decompress.cpp7
-rw-r--r--noncore/games/solitaire/canvascard.cpp2
-rw-r--r--noncore/games/tetrix/ohighscoredlg.cpp9
3 files changed, 2 insertions, 16 deletions
diff --git a/noncore/apps/opie-reader/decompress.cpp b/noncore/apps/opie-reader/decompress.cpp
index 9bfec49..6034e01 100644
--- a/noncore/apps/opie-reader/decompress.cpp
+++ b/noncore/apps/opie-reader/decompress.cpp
@@ -1,95 +1,88 @@
1#include <string.h> 1#include <string.h>
2#include "decompress.h" 2#include "decompress.h"
3#include <zlib.h> 3#include <zlib.h>
4#include <stdlib.h> 4#include <stdlib.h>
5 5
6size_t UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) 6size_t UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize)
7{ 7{
8 z_stream zstream; 8 z_stream zstream;
9 memset(&zstream,sizeof(zstream),0); 9 memset(&zstream,sizeof(zstream),0);
10 zstream.next_in = compressedbuffer; 10 zstream.next_in = compressedbuffer;
11 zstream.next_out = tgtbuffer; 11 zstream.next_out = tgtbuffer;
12 zstream.avail_out = bsize; 12 zstream.avail_out = bsize;
13 zstream.avail_in = reclen; 13 zstream.avail_in = reclen;
14 14
15 int keylen = 0;
16
17 zstream.zalloc = Z_NULL; 15 zstream.zalloc = Z_NULL;
18 zstream.zfree = Z_NULL; 16 zstream.zfree = Z_NULL;
19 zstream.opaque = Z_NULL; 17 zstream.opaque = Z_NULL;
20 18
21 // printf("Initialising\n"); 19 // printf("Initialising\n");
22 20
23 inflateInit(&zstream); 21 inflateInit(&zstream);
24 int err = 0; 22 int err = 0;
25 do { 23 do {
26 if ( zstream.avail_in == 0 && 0 < keylen ) {
27 zstream.next_in = compressedbuffer + keylen;
28 zstream.avail_in = reclen - keylen;
29 keylen = 0;
30 }
31 zstream.next_out = tgtbuffer; 24 zstream.next_out = tgtbuffer;
32 zstream.avail_out = bsize; 25 zstream.avail_out = bsize;
33 26
34 err = inflate( &zstream, Z_SYNC_FLUSH ); 27 err = inflate( &zstream, Z_SYNC_FLUSH );
35 28
36 ////qDebug("err:%d - %u", err, zstream.avail_in); 29 ////qDebug("err:%d - %u", err, zstream.avail_in);
37 30
38 } while ( err == Z_OK ); 31 } while ( err == Z_OK );
39 32
40 inflateEnd(&zstream); 33 inflateEnd(&zstream);
41 return zstream.total_out; 34 return zstream.total_out;
42} 35}
43 36
44#if defined(__STATIC) && defined(USENEF) 37#if defined(__STATIC) && defined(USENEF)
45#include "Model.h" 38#include "Model.h"
46size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t) 39size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t)
47{ 40{
48 if (strcmp(_s, "PluckerDecompress3") == 0) 41 if (strcmp(_s, "PluckerDecompress3") == 0)
49 { 42 {
50 return PluckerDecompress3; 43 return PluckerDecompress3;
51 } 44 }
52 if (strcmp(_s, "PluckerDecompress4") == 0) 45 if (strcmp(_s, "PluckerDecompress4") == 0)
53 { 46 {
54 return PluckerDecompress4; 47 return PluckerDecompress4;
55 } 48 }
56 if (strcmp(_s, "RebDecompress") == 0) 49 if (strcmp(_s, "RebDecompress") == 0)
57 { 50 {
58 return RebDecompress; 51 return RebDecompress;
59 } 52 }
60 return NULL; 53 return NULL;
61} 54}
62#else 55#else
63 56
64#include "qfileinfo.h" 57#include "qfileinfo.h"
65 58
66#include <dlfcn.h> 59#include <dlfcn.h>
67 60
68size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t) 61size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t)
69{ 62{
70#ifdef USEQPE 63#ifdef USEQPE
71#ifdef OPIE 64#ifdef OPIE
72 QString codecpath(getenv("OPIEDIR")); 65 QString codecpath(getenv("OPIEDIR"));
73#else 66#else
74 QString codecpath(getenv("QTDIR")); 67 QString codecpath(getenv("QTDIR"));
75#endif 68#endif
76 codecpath += "/plugins/reader/support/libpluckerdecompress.so"; 69 codecpath += "/plugins/reader/support/libpluckerdecompress.so";
77#else 70#else
78 QString codecpath(getenv("READERDIR")); 71 QString codecpath(getenv("READERDIR"));
79 codecpath += "/support/libpluckerdecompress.so"; 72 codecpath += "/support/libpluckerdecompress.so";
80#endif 73#endif
81 qDebug("Codec:%s", (const char*)codecpath); 74 qDebug("Codec:%s", (const char*)codecpath);
82 if (QFile::exists(codecpath)) 75 if (QFile::exists(codecpath))
83 { 76 {
84 qDebug("Codec:%s", (const char*)codecpath); 77 qDebug("Codec:%s", (const char*)codecpath);
85 void* handle = dlopen(codecpath, RTLD_LAZY); 78 void* handle = dlopen(codecpath, RTLD_LAZY);
86 if (handle == 0) 79 if (handle == 0)
87 { 80 {
88 qDebug("Can't find codec:%s", dlerror()); 81 qDebug("Can't find codec:%s", dlerror());
89 return NULL; 82 return NULL;
90 } 83 }
91 return (size_t (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s); 84 return (size_t (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s);
92 } 85 }
93 return NULL; 86 return NULL;
94} 87}
95#endif 88#endif
diff --git a/noncore/games/solitaire/canvascard.cpp b/noncore/games/solitaire/canvascard.cpp
index cd298ef..3ed9ea0 100644
--- a/noncore/games/solitaire/canvascard.cpp
+++ b/noncore/games/solitaire/canvascard.cpp
@@ -1,303 +1,303 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of 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 "canvascard.h" 21#include "canvascard.h"
22 22
23#include <opie2/oresource.h> 23#include <opie2/oresource.h>
24 24
25#include <qgfx_qws.h> // Needed to get the device's width 25#include <qgfx_qws.h> // Needed to get the device's width
26 26
27#include <math.h> 27#include <math.h>
28 28
29#if defined( QT_QWS_CASSIOPEIA ) 29#if defined( QT_QWS_CASSIOPEIA )
30#define SLOW_HARDWARE 30#define SLOW_HARDWARE
31#endif 31#endif
32 32
33// Seems to be fast enough to me even without Transformations in the library 33// Seems to be fast enough to me even without Transformations in the library
34//#if defined( QT_NO_TRANSFORMATIONS ) && defined( QT_QWS_IPAQ ) 34//#if defined( QT_NO_TRANSFORMATIONS ) && defined( QT_QWS_IPAQ )
35//#define SLOW_HARDWARE 35//#define SLOW_HARDWARE
36//#endif 36//#endif
37 37
38 38
39QBitmap *Create180RotatedBitmap(QBitmap *srcBitmap) 39QBitmap *Create180RotatedBitmap(QBitmap *srcBitmap)
40{ 40{
41#ifdef QT_NO_TRANSFORMATIONS 41#ifdef QT_NO_TRANSFORMATIONS
42 int w = srcBitmap->width(); 42 int w = srcBitmap->width();
43 int h = srcBitmap->height(); 43 int h = srcBitmap->height();
44 QBitmap *dstBitmap = new QBitmap( w, h ); 44 QBitmap *dstBitmap = new QBitmap( w, h );
45 // ### this is very poorly implemented and probably could be much faster 45 // ### this is very poorly implemented and probably could be much faster
46 for (int i = 0; i < w; i++) 46 for (int i = 0; i < w; i++)
47 for (int j = 0; j < h; j++) 47 for (int j = 0; j < h; j++)
48 bitBlt( dstBitmap, i, j, srcBitmap, w - i - 1, h - j - 1, 1, 1 ); 48 bitBlt( dstBitmap, i, j, srcBitmap, w - i - 1, h - j - 1, 1, 1 );
49 return dstBitmap; 49 return dstBitmap;
50#else 50#else
51 QWMatrix m; 51 QWMatrix m;
52 m.rotate( 180.0 ); 52 m.rotate( 180.0 );
53 return new QBitmap( srcBitmap->xForm( m ) ); 53 return new QBitmap( srcBitmap->xForm( m ) );
54#endif 54#endif
55} 55}
56 56
57 57
58QPixmap *CreateScaledPixmap(QPixmap *srcPixmap, double scaleX, double scaleY) 58QPixmap *CreateScaledPixmap(QPixmap *srcPixmap, double scaleX, double scaleY)
59{ 59{
60#ifdef QT_NO_TRANSFORMATIONS 60#ifdef QT_NO_TRANSFORMATIONS
61 int w = srcPixmap->width(); 61 int w = srcPixmap->width();
62 int h = srcPixmap->height(); 62 int h = srcPixmap->height();
63 int newW = (int)(w * scaleX); 63 int newW = (int)(w * scaleX);
64 int newH = (int)(h * scaleY); 64 int newH = (int)(h * scaleY);
65 QPixmap *dstPixmap = new QPixmap( newW, newH ); 65 QPixmap *dstPixmap = new QPixmap( newW, newH );
66 // ### this is very poorly implemented and probably could be much faster 66 // ### this is very poorly implemented and probably could be much faster
67 for (int i = 0; i < newW; i++) { 67 for (int i = 0; i < newW; i++) {
68 int srcX = w * i / newW; 68 int srcX = w * i / newW;
69 if (newH == h) { 69 if (newH == h) {
70 // Optimise for scaleing in the X-axis only 70 // Optimise for scaleing in the X-axis only
71 bitBlt( dstPixmap, i, 0, srcPixmap, srcX, 0, 1, h ); 71 bitBlt( dstPixmap, i, 0, srcPixmap, srcX, 0, 1, h );
72 } else { 72 } else {
73 for (int j = 0; j < newH; j++) { 73 for (int j = 0; j < newH; j++) {
74 int srcY = h * j / newH; 74 int srcY = h * j / newH;
75 bitBlt( dstPixmap, i, j, srcPixmap, srcX, srcY, 1, 1 ); 75 bitBlt( dstPixmap, i, j, srcPixmap, srcX, srcY, 1, 1 );
76 } 76 }
77 } 77 }
78 } 78 }
79 return dstPixmap; 79 return dstPixmap;
80#else 80#else
81 QWMatrix s; 81 QWMatrix s;
82 s.scale( scaleX, scaleY ); 82 s.scale( scaleX, scaleY );
83 return new QPixmap( srcPixmap->xForm( s ) ); 83 return new QPixmap( srcPixmap->xForm( s ) );
84#endif 84#endif
85} 85}
86 86
87 87
88// Initialise static member variables to NULL 88// Initialise static member variables to NULL
89QPixmap *CanvasCard::cardsFaces = NULL; 89QPixmap *CanvasCard::cardsFaces = NULL;
90QPixmap *CanvasCard::cardsBacks = NULL; 90QPixmap *CanvasCard::cardsBacks = NULL;
91QBitmap *CanvasCard::cardsChars = NULL; 91QBitmap *CanvasCard::cardsChars = NULL;
92QBitmap *CanvasCard::cardsSuits = NULL; 92QBitmap *CanvasCard::cardsSuits = NULL;
93QBitmap *CanvasCard::cardsCharsUpsideDown = NULL; 93QBitmap *CanvasCard::cardsCharsUpsideDown = NULL;
94QBitmap *CanvasCard::cardsSuitsUpsideDown = NULL; 94QBitmap *CanvasCard::cardsSuitsUpsideDown = NULL;
95 95
96 96
97CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) : 97CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) :
98 Card(v, s, f), QCanvasRectangle( 0, 0, 1, 1, canvas ), cardBack(1), scaleX(1.0), scaleY(1.0) 98 Card(v, s, f), QCanvasRectangle( 0, 0, 1, 1, canvas ), cardBack(1), scaleX(1.0), scaleY(1.0)
99{ 99{
100 if ( !cardsFaces ) { 100 if ( !cardsFaces ) {
101 if ( qt_screen->deviceWidth() < 200 ) { 101 if ( qt_screen->deviceWidth() < 200 ) {
102 cardsFaces = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_face_small" ) ); 102 cardsFaces = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_face_small" ) );
103 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001_small" ) ); 103 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001_small" ) );
104 cardsChars = new QBitmap(); 104 cardsChars = new QBitmap();
105 *cardsChars = Opie::Core::OResource::loadPixmap( "cards/card_chars_small" ); 105 *cardsChars = Opie::Core::OResource::loadPixmap( "cards/card_chars_small" );
106 cardsSuits = new QBitmap(); 106 cardsSuits = new QBitmap();
107 *cardsSuits = Opie::Core::OResource::loadPixmap( "cards/card_suits_small" ); 107 *cardsSuits = Opie::Core::OResource::loadPixmap( "cards/card_suits_small" );
108 } else { 108 } else {
109 cardsFaces = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_face" ) ); 109 cardsFaces = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_face" ) );
110 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001" ) ); 110 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001" ) );
111 cardsChars = new QBitmap(); 111 cardsChars = new QBitmap();
112 *cardsChars = Opie::Core::OResource::loadPixmap( "cards/card_chars" ); 112 *cardsChars = Opie::Core::OResource::loadPixmap( "cards/card_chars" );
113 cardsSuits = new QBitmap(); 113 cardsSuits = new QBitmap();
114 *cardsSuits = Opie::Core::OResource::loadPixmap( "cards/card_suits" ); 114 *cardsSuits = Opie::Core::OResource::loadPixmap( "cards/card_suits" );
115 } 115 }
116 cardsCharsUpsideDown = Create180RotatedBitmap( cardsChars ); 116 cardsCharsUpsideDown = Create180RotatedBitmap( cardsChars );
117 cardsSuitsUpsideDown = Create180RotatedBitmap( cardsSuits ); 117 cardsSuitsUpsideDown = Create180RotatedBitmap( cardsSuits );
118 } 118 }
119 xOff = cardsFaces->width() / 2; 119 xOff = cardsFaces->width() / 2;
120 yOff = cardsFaces->height() / 2; 120 yOff = cardsFaces->height() / 2;
121 setSize( cardsFaces->width(), cardsFaces->height() ); 121 setSize( cardsFaces->width(), cardsFaces->height() );
122 setPen( NoPen ); 122 setPen( NoPen );
123 flipping = FALSE; 123 flipping = FALSE;
124} 124}
125 125
126 126
127void CanvasCard::setCardBack(int b) 127void CanvasCard::setCardBack(int b)
128{ 128{
129 if ( cardBack != b ) { 129 if ( cardBack != b ) {
130 130
131 cardBack = b; 131 cardBack = b;
132 132
133 if ( cardsBacks ) 133 if ( cardsBacks )
134 delete cardsBacks; 134 delete cardsBacks;
135 135
136 if ( qt_screen->deviceWidth() < 200 ) { 136 if ( qt_screen->deviceWidth() < 200 ) {
137 switch (cardBack) { 137 switch (cardBack) {
138 case 0: 138 case 0:
139 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001_small" ) ); break; 139 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001_small" ) ); break;
140 case 1: 140 case 1:
141 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0002_small" ) ); break; 141 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0002_small" ) ); break;
142 case 2: 142 case 2:
143 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0003_small" ) ); break; 143 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0003_small" ) ); break;
144 case 3: 144 case 3:
145 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0004_small" ) ); break; 145 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0004_small" ) ); break;
146 case 4: 146 case 4:
147 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0005_small" ) ); break; 147 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0005_small" ) ); break;
148 } 148 }
149 } else { 149 } else {
150 switch (cardBack) { 150 switch (cardBack) {
151 case 0: 151 case 0:
152 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001" ) ); break; 152 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001" ) ); break;
153 case 1: 153 case 1:
154 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0002" ) ); break; 154 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0002" ) ); break;
155 case 2: 155 case 2:
156 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0003" ) ); break; 156 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0003" ) ); break;
157 case 3: 157 case 3:
158 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0004" ) ); break; 158 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0004" ) ); break;
159 case 4: 159 case 4:
160 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0005" ) ); break; 160 cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0005" ) ); break;
161 } 161 }
162 } 162 }
163 163
164 if ( !isFacing() ) 164 if ( !isFacing() )
165 redraw(); 165 redraw();
166 } 166 }
167} 167}
168 168
169 169
170void CanvasCard::draw(QPainter &painter) 170void CanvasCard::draw(QPainter &painter)
171{ 171{
172 int ix = (int)x(), iy = (int)y(); 172 int ix = (int)x(), iy = (int)y();
173 173
174 QPainter *p = &painter; 174 QPainter *p = &painter;
175 QPixmap *unscaledCard = NULL; 175 QPixmap *unscaledCard = NULL;
176 176
177 if ((scaleX <= 0.98) || (scaleY <= 0.98)) 177 if ((scaleX <= 0.98) || (scaleY <= 0.98))
178 { 178 {
179 p = new QPainter(); 179 p = new QPainter();
180 unscaledCard = new QPixmap( cardsFaces->width(), cardsFaces->height() ); 180 unscaledCard = new QPixmap( cardsFaces->width(), cardsFaces->height() );
181 p->begin(unscaledCard); 181 p->begin(unscaledCard);
182 ix = 0; 182 ix = 0;
183 iy = 0; 183 iy = 0;
184 } 184 }
185 185
186 if ( isFacing() ) { 186 if ( isFacing() ) {
187 187
188 int w = cardsFaces->width(), h = cardsFaces->height(); 188 int w = cardsFaces->width(), h = cardsFaces->height();
189 189
190 p->setBrush( QColor( 0xFF, 0xFF, 0xFF ) ); 190 p->setBrush( QColor( 0xFF, 0xFF, 0xFF ) );
191 191
192 if ( isRed() == TRUE ) 192 if ( isRed() == TRUE )
193 p->setPen( QColor( 0xFF, 0, 0 ) ); 193 p->setPen( QColor( 0xFF, 0, 0 ) );
194 else 194 else
195 p->setPen( QColor( 0, 0, 0 ) ); 195 p->setPen( QColor( 0, 0, 0 ) );
196 196
197 if ( qt_screen->deviceWidth() < 200 ) { 197 if ( qt_screen->deviceWidth() < 200 ) {
198 p->drawPixmap( ix + 0, iy + 0, *cardsFaces ); 198 p->drawPixmap( ix + 0, iy + 0, *cardsFaces );
199 p->drawPixmap( ix + 3, iy + 3, *cardsChars, 5*(getValue()-1), 0, 5, 6 ); 199 p->drawPixmap( ix + 3, iy + 3, *cardsChars, 5*(getValue()-1), 0, 5, 6 );
200 p->drawPixmap( ix + 11, iy + 3, *cardsSuits, 5*(getSuit()-1), 0, 5, 6 ); 200 p->drawPixmap( ix + 11, iy + 3, *cardsSuits, 5*(getSuit()-1), 0, 5, 6 );
201 p->drawPixmap( ix + w-3-5, iy + h-3-6, *cardsCharsUpsideDown, 5*(12-getValue()+1), 0, 5, 6 ); 201 p->drawPixmap( ix + w-3-5, iy + h-3-6, *cardsCharsUpsideDown, 5*(12-getValue()+1), 0, 5, 6 );
202 p->drawPixmap( ix + w-11-5, iy + h-3-6, *cardsSuitsUpsideDown, 5*(3-getSuit()+1), 0, 5, 6 ); 202 p->drawPixmap( ix + w-11-5, iy + h-3-6, *cardsSuitsUpsideDown, 5*(3-getSuit()+1), 0, 5, 6 );
203 } else { 203 } else {
204 p->drawPixmap( ix + 0, iy + 0, *cardsFaces ); 204 p->drawPixmap( ix + 0, iy + 0, *cardsFaces );
205 p->drawPixmap( ix + 4, iy + 4, *cardsChars, 7*(getValue()-1), 0, 7, 7 ); 205 p->drawPixmap( ix + 4, iy + 4, *cardsChars, 7*(getValue()-1), 0, 7, 7 );
206 p->drawPixmap( ix + 12, iy + 4, *cardsSuits, 7*(getSuit()-1), 0, 7, 8 ); 206 p->drawPixmap( ix + 12, iy + 4, *cardsSuits, 7*(getSuit()-1), 0, 7, 8 );
207 p->drawPixmap( ix + w-4-7, iy + h-4-7, *cardsCharsUpsideDown, 7*(12-getValue()+1), 0, 7, 7 ); 207 p->drawPixmap( ix + w-4-7, iy + h-4-7, *cardsCharsUpsideDown, 7*(12-getValue()+1), 0, 7, 7 );
208 p->drawPixmap( ix + w-12-7, iy + h-5-7, *cardsSuitsUpsideDown, 7*(3-getSuit()+1), 0, 7, 8 ); 208 p->drawPixmap( ix + w-12-7, iy + h-5-7, *cardsSuitsUpsideDown, 7*(3-getSuit()+1), 0, 7, 8 );
209 } 209 }
210 210
211 } else { 211 } else {
212 212
213 p->drawPixmap( ix, iy, *cardsBacks ); 213 p->drawPixmap( ix, iy, *cardsBacks );
214 214
215 } 215 }
216 216
217 if (p != &painter) 217 if (p != &painter && unscaledCard)
218 { 218 {
219 p->end(); 219 p->end();
220 QPixmap *scaledCard = CreateScaledPixmap( unscaledCard, scaleX, scaleY ); 220 QPixmap *scaledCard = CreateScaledPixmap( unscaledCard, scaleX, scaleY );
221 int xoff = scaledCard->width() / 2; 221 int xoff = scaledCard->width() / 2;
222 int yoff = scaledCard->height() / 2; 222 int yoff = scaledCard->height() / 2;
223 painter.drawPixmap( (int)x() + xOff - xoff, (int)y() + yOff - yoff, *scaledCard ); 223 painter.drawPixmap( (int)x() + xOff - xoff, (int)y() + yOff - yoff, *scaledCard );
224 delete p; 224 delete p;
225 delete unscaledCard; 225 delete unscaledCard;
226 delete scaledCard; 226 delete scaledCard;
227 } 227 }
228} 228}
229 229
230 230
231static const double flipLift = 1.5; 231static const double flipLift = 1.5;
232 232
233 233
234void CanvasCard::flipTo(int x2, int y2, int steps) 234void CanvasCard::flipTo(int x2, int y2, int steps)
235{ 235{
236 flipSteps = steps; 236 flipSteps = steps;
237 237
238#ifdef SLOW_HARDWARE 238#ifdef SLOW_HARDWARE
239 move(x2,y2); 239 move(x2,y2);
240 Card::flipTo(x2,y2,steps); 240 Card::flipTo(x2,y2,steps);
241#else 241#else
242 int x1 = (int)x(); 242 int x1 = (int)x();
243 int y1 = (int)y(); 243 int y1 = (int)y();
244 double dx = x2 - x1; 244 double dx = x2 - x1;
245 double dy = y2 - y1; 245 double dy = y2 - y1;
246 246
247 flipping = TRUE; 247 flipping = TRUE;
248 destX = x2; 248 destX = x2;
249 destY = y2; 249 destY = y2;
250 animSteps = flipSteps; 250 animSteps = flipSteps;
251 setVelocity(dx/animSteps, dy/animSteps-flipLift); 251 setVelocity(dx/animSteps, dy/animSteps-flipLift);
252 setAnimated(TRUE); 252 setAnimated(TRUE);
253#endif 253#endif
254} 254}
255 255
256 256
257void CanvasCard::advance(int stage) 257void CanvasCard::advance(int stage)
258{ 258{
259 if ( stage==1 ) { 259 if ( stage==1 ) {
260 if ( animSteps-- <= 0 ) { 260 if ( animSteps-- <= 0 ) {
261 scaleX = 1.0; 261 scaleX = 1.0;
262 scaleY = 1.0; 262 scaleY = 1.0;
263 flipping = FALSE; 263 flipping = FALSE;
264 setVelocity(0,0); 264 setVelocity(0,0);
265 setAnimated(FALSE); 265 setAnimated(FALSE);
266 move(destX,destY); // exact 266 move(destX,destY); // exact
267 } else { 267 } else {
268 if ( flipping ) { 268 if ( flipping ) {
269 if ( animSteps > flipSteps / 2 ) { 269 if ( animSteps > flipSteps / 2 ) {
270 // animSteps = flipSteps .. flipSteps/2 (flip up) -> 1..0 270 // animSteps = flipSteps .. flipSteps/2 (flip up) -> 1..0
271 scaleX = ((double)animSteps/flipSteps-0.5)*2; 271 scaleX = ((double)animSteps/flipSteps-0.5)*2;
272 } else { 272 } else {
273 // animSteps = flipSteps/2 .. 0 (flip down) -> 0..1 273 // animSteps = flipSteps/2 .. 0 (flip down) -> 0..1
274 scaleX = 1-((double)animSteps/flipSteps)*2; 274 scaleX = 1-((double)animSteps/flipSteps)*2;
275 } 275 }
276 if ( animSteps == flipSteps / 2-1 ) { 276 if ( animSteps == flipSteps / 2-1 ) {
277 setYVelocity(yVelocity()+flipLift*2); 277 setYVelocity(yVelocity()+flipLift*2);
278 setFace( !isFacing() ); 278 setFace( !isFacing() );
279 } 279 }
280 } 280 }
281 } 281 }
282 } 282 }
283 QCanvasRectangle::advance(stage); 283 QCanvasRectangle::advance(stage);
284} 284}
285 285
286 286
287void CanvasCard::animatedMove(int x2, int y2, int steps) 287void CanvasCard::animatedMove(int x2, int y2, int steps)
288{ 288{
289 destX = x2; 289 destX = x2;
290 destY = y2; 290 destY = y2;
291 291
292 double x1 = x(), y1 = y(), dx = x2 - x1, dy = y2 - y1; 292 double x1 = x(), y1 = y(), dx = x2 - x1, dy = y2 - y1;
293 293
294 // Ensure a good speed 294 // Ensure a good speed
295 while ( fabs(dx/steps)+fabs(dy/steps) < 5.0 && steps > 4 ) 295 while ( fabs(dx/steps)+fabs(dy/steps) < 5.0 && steps > 4 )
296 steps--; 296 steps--;
297 297
298 setAnimated(TRUE); 298 setAnimated(TRUE);
299 setVelocity(dx/steps, dy/steps); 299 setVelocity(dx/steps, dy/steps);
300 300
301 animSteps = steps; 301 animSteps = steps;
302} 302}
303 303
diff --git a/noncore/games/tetrix/ohighscoredlg.cpp b/noncore/games/tetrix/ohighscoredlg.cpp
index 66f4917..504385f 100644
--- a/noncore/games/tetrix/ohighscoredlg.cpp
+++ b/noncore/games/tetrix/ohighscoredlg.cpp
@@ -1,206 +1,199 @@
1/*************************************************************************** 1/***************************************************************************
2 begin : January 2003 2 begin : January 2003
3 copyright : ( C ) 2003 by Carsten Niehaus 3 copyright : ( C ) 2003 by Carsten Niehaus
4 email : cniehaus@handhelds.org 4 email : cniehaus@handhelds.org
5 **************************************************************************/ 5 **************************************************************************/
6 6
7/*************************************************************************** 7/***************************************************************************
8 * * 8 * *
9 * This program is free software; you can redistribute it and/or modify * 9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by * 10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or * 11 * the Free Software Foundation; either version 2 of the License, or *
12 * ( at your option ) any later version. * 12 * ( at your option ) any later version. *
13 * * 13 * *
14 **************************************************************************/ 14 **************************************************************************/
15 15
16#include <qdialog.h> 16#include <qdialog.h>
17#include <qlayout.h> 17#include <qlayout.h>
18#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
19#include <qpe/config.h> 19#include <qpe/config.h>
20 20
21#include <qstring.h> 21#include <qstring.h>
22#include <qlist.h> 22#include <qlist.h>
23#include <qhbox.h> 23#include <qhbox.h>
24#include <qvbox.h> 24#include <qvbox.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qlistview.h> 26#include <qlistview.h>
27#include <qlineedit.h> 27#include <qlineedit.h>
28 28
29#include "ohighscoredlg.h" 29#include "ohighscoredlg.h"
30 30
31OHighscore::OHighscore( int score , int playerLevel ) : playerData() 31OHighscore::OHighscore( int score , int playerLevel ) : playerData()
32{ 32{
33 pLevel = playerLevel; 33 pLevel = playerLevel;
34 getList(); 34 getList();
35 checkIfItIsANewhighscore( score ); 35 checkIfItIsANewhighscore( score );
36 playerData.setAutoDelete( TRUE ); 36 playerData.setAutoDelete( TRUE );
37} 37}
38 38
39OHighscore::~OHighscore() 39OHighscore::~OHighscore()
40{ 40{
41} 41}
42 42
43void OHighscore::getList() 43void OHighscore::getList()
44{ 44{
45 Config cfg ( "tetrix" ); 45 Config cfg ( "tetrix" );
46 cfg.setGroup( QString::number( 1 ) ); 46 cfg.setGroup( QString::number( 1 ) );
47 lowest = cfg.readNumEntry( "Points" ); 47 lowest = cfg.readNumEntry( "Points" );
48 playerData.clear(); 48 playerData.clear();
49 49
50 int rest = 1;//for the filling up later 50 int rest = 1;//for the filling up later
51 51
52 for ( int i = 1 ; i < 11 ; i++ ) 52 for ( int i = 1 ; i < 11 ; i++ )
53 { 53 {
54 if ( cfg.hasGroup( QString::number( i ) ) ) 54 if ( cfg.hasGroup( QString::number( i ) ) )
55 { 55 {
56 cfg.setGroup( QString::number( i ) ); 56 cfg.setGroup( QString::number( i ) );
57 int temp = cfg.readNumEntry( "Points" ); 57 int temp = cfg.readNumEntry( "Points" );
58 58
59 t_playerData *pPlayerData = new t_playerData; 59 t_playerData *pPlayerData = new t_playerData;
60 pPlayerData->sName = cfg.readEntry( "Name" ); 60 pPlayerData->sName = cfg.readEntry( "Name" );
61 pPlayerData->points = temp; 61 pPlayerData->points = temp;
62 pPlayerData->level = cfg.readNumEntry( "Level" ); 62 pPlayerData->level = cfg.readNumEntry( "Level" );
63 63
64 playerData.append( pPlayerData ); 64 playerData.append( pPlayerData );
65 65
66 if ( (temp < lowest) ) lowest = temp; 66 if ( (temp < lowest) ) lowest = temp;
67 rest++; 67 rest++;
68 } 68 }
69 } 69 }
70 70
71 //now I fill up the rest of the list 71 //now I fill up the rest of the list
72 if ( rest < 11 ) //only go in this loop if there are less than 72 if ( rest < 11 ) //only go in this loop if there are less than
73 //10 highscoreentries 73 //10 highscoreentries
74 { 74 {
75 lowest = 0; 75 lowest = 0;
76 for ( ; rest < 11 ; rest++ ) 76 for ( ; rest < 11 ; rest++ )
77 { 77 {
78 t_playerData *pPlayerData = new t_playerData; 78 t_playerData *pPlayerData = new t_playerData;
79 pPlayerData->sName = tr( "empty"); 79 pPlayerData->sName = tr( "empty");
80 pPlayerData->points = 0; 80 pPlayerData->points = 0;
81 pPlayerData->level = 0; 81 pPlayerData->level = 0;
82 82
83 playerData.append( pPlayerData ); 83 playerData.append( pPlayerData );
84 } 84 }
85 } 85 }
86 86
87} 87}
88 88
89void OHighscore::checkIfItIsANewhighscore( int points) 89void OHighscore::checkIfItIsANewhighscore( int points)
90{ 90{
91 if ( points > lowest ) 91 if ( points > lowest )
92 isNewhighscore = true; 92 isNewhighscore = true;
93 else 93 else
94 isNewhighscore = false; 94 isNewhighscore = false;
95} 95}
96 96
97void OHighscore::insertData( QString name , int punkte , int playerLevel ) 97void OHighscore::insertData( QString name , int punkte , int playerLevel )
98{ 98{
99 Config cfg ( "tetrix" ); 99 Config cfg ( "tetrix" );
100 t_playerData * Run; 100 t_playerData * Run;
101 int index = 0; 101 int index = 0;
102 int entryNumber = 1; 102 int entryNumber = 1;
103 103
104 for ( Run=playerData.first(); 104 for ( Run=playerData.first();
105 Run != 0; 105 Run != 0;
106 index ++, Run=playerData.next() ) { 106 index ++, Run=playerData.next() ) {
107 107
108 if ( punkte > Run->points ) 108 if ( punkte > Run->points )
109 { 109 {
110 t_playerData* temp = new t_playerData; 110 t_playerData* temp = new t_playerData;
111 temp->sName = name; 111 temp->sName = name;
112 temp->points = punkte; 112 temp->points = punkte;
113 temp->level = playerLevel; 113 temp->level = playerLevel;
114 114
115 playerData.insert( index, temp ); 115 playerData.insert( index, temp );
116 116
117 //now we have to delete the last entry 117 //now we have to delete the last entry
118 playerData.remove( playerData.count() ); 118 playerData.remove( playerData.count() );
119 119
120 ///////////////////////////////////////// 120 /////////////////////////////////////////
121 //this block just rewrites the highscore 121 //this block just rewrites the highscore
122 for ( t_playerData * Run2=playerData.first(); 122 for ( t_playerData * Run2=playerData.first();
123 Run2 != 0; 123 Run2 != 0;
124 Run2=playerData.next() ) { 124 Run2=playerData.next() ) {
125 cfg.setGroup( QString::number( entryNumber ) ); 125 cfg.setGroup( QString::number( entryNumber ) );
126 cfg.writeEntry( "Name" , Run2->sName ); 126 cfg.writeEntry( "Name" , Run2->sName );
127 cfg.writeEntry( "Points" , Run2->points ); 127 cfg.writeEntry( "Points" , Run2->points );
128 cfg.writeEntry( "Level" , Run2->level ); 128 cfg.writeEntry( "Level" , Run2->level );
129 entryNumber++; 129 entryNumber++;
130 } 130 }
131 //////////////////////////////////////// 131 ////////////////////////////////////////
132 132
133 return; 133 return;
134 } 134 }
135 } 135 }
136} 136}
137 137
138QString OHighscore::getName() 138QString OHighscore::getName()
139{ 139{
140 QString name; 140 QString name;
141 QDialog *d = new QDialog ( this, 0, true ); 141 QDialog *d = new QDialog ( this, 0, true );
142 d->setCaption( tr( "Enter your name!" )); 142 d->setCaption( tr( "Enter your name!" ));
143 QLineEdit *ed = new QLineEdit ( d ); 143 QLineEdit *ed = new QLineEdit ( d );
144 ( new QVBoxLayout ( d, 3, 3 ))->addWidget ( ed ); 144 ( new QVBoxLayout ( d, 3, 3 ))->addWidget ( ed );
145 ed->setFocus ( ); 145 ed->setFocus ( );
146 146
147 if ( d->exec() == QDialog::Accepted ) { 147 if ( d->exec() == QDialog::Accepted ) {
148 name = ed->text(); 148 name = ed->text();
149 } 149 }
150 //delete d; 150 //delete d;
151 return name; 151 return name;
152} 152}
153 153
154OHighscoreDialog::OHighscoreDialog(OHighscore *highscore, QWidget *parent, const char *name, bool modal) : QDialog(parent, name, modal) 154OHighscoreDialog::OHighscoreDialog(OHighscore *highscore, QWidget *parent, const char *name, bool modal) : QDialog(parent, name, modal)
155{ 155{
156 hs_ = highscore; 156 hs_ = highscore;
157 setCaption( tr( "Highscores" ) ); 157 setCaption( tr( "Highscores" ) );
158 vbox_layout = new QVBoxLayout( this, 4 , 4 ); 158 vbox_layout = new QVBoxLayout( this, 4 , 4 );
159 list = new QListView( this ); 159 list = new QListView( this );
160 list->setSorting( -1 ); 160 list->setSorting( -1 );
161 list->addColumn( tr( "#" )); 161 list->addColumn( tr( "#" ));
162 list->addColumn( tr( "Name" )); 162 list->addColumn( tr( "Name" ));
163 list->addColumn( tr( "Points" )); 163 list->addColumn( tr( "Points" ));
164 list->addColumn( tr( "Level" )); 164 list->addColumn( tr( "Level" ));
165 165
166 createHighscoreListView(); 166 createHighscoreListView();
167 167
168 vbox_layout->addWidget( list ); 168 vbox_layout->addWidget( list );
169 QPEApplication::showDialog( this ); 169 QPEApplication::showDialog( this );
170} 170}
171 171
172void OHighscoreDialog::createHighscoreListView() 172void OHighscoreDialog::createHighscoreListView()
173{ 173{
174 int pos = 10; 174 int pos = 10;
175 int points_ = 0; 175 int points_ = 0;
176 int level_ = 0; 176 int level_ = 0;
177 QListViewItem * Prev = 0;
178 177
179 for ( t_playerData * Run = hs_->playerData.first(); 178 for ( t_playerData * Run = hs_->playerData.first();
180 Run != 0; 179 Run != 0;
181 Run=hs_->playerData.next() ) 180 Run=hs_->playerData.next() )
182 { 181 {
183 QListViewItem *item; 182 QListViewItem *item;
184 183
185 if( Prev ) { 184 item = new QListViewItem( list );
186 // after previous
187 item = new QListViewItem( list, Prev );
188 Prev = item;
189 } else {
190 item = new QListViewItem( list );
191 185
192 }
193 item->setText( 0 , QString::number( pos ) ); //number 186 item->setText( 0 , QString::number( pos ) ); //number
194 item->setText( 1 , Run->sName ); //name 187 item->setText( 1 , Run->sName ); //name
195 if ( Run->points == -1 ) 188 if ( Run->points == -1 )
196 points_ = 0; 189 points_ = 0;
197 else points_ = Run->points; 190 else points_ = Run->points;
198 if ( Run->level == -1 ) 191 if ( Run->level == -1 )
199 level_ = 0; 192 level_ = 0;
200 else level_ = Run->level; 193 else level_ = Run->level;
201 item->setText( 2 , QString::number( points_ ) ); //points 194 item->setText( 2 , QString::number( points_ ) ); //points
202 item->setText( 3 , QString::number( level_ ) ); //level 195 item->setText( 3 , QString::number( level_ ) ); //level
203 pos--; 196 pos--;
204 } 197 }
205} 198}
206 199