summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (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 @@
#include <string.h>
#include "decompress.h"
#include <zlib.h>
#include <stdlib.h>
size_t UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize)
{
z_stream zstream;
memset(&zstream,sizeof(zstream),0);
zstream.next_in = compressedbuffer;
zstream.next_out = tgtbuffer;
zstream.avail_out = bsize;
zstream.avail_in = reclen;
- int keylen = 0;
-
zstream.zalloc = Z_NULL;
zstream.zfree = Z_NULL;
zstream.opaque = Z_NULL;
// printf("Initialising\n");
inflateInit(&zstream);
int err = 0;
do {
- if ( zstream.avail_in == 0 && 0 < keylen ) {
- zstream.next_in = compressedbuffer + keylen;
- zstream.avail_in = reclen - keylen;
- keylen = 0;
- }
zstream.next_out = tgtbuffer;
zstream.avail_out = bsize;
err = inflate( &zstream, Z_SYNC_FLUSH );
// //qDebug("err:%d - %u", err, zstream.avail_in);
} while ( err == Z_OK );
inflateEnd(&zstream);
return zstream.total_out;
}
#if defined(__STATIC) && defined(USENEF)
#include "Model.h"
size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t)
{
if (strcmp(_s, "PluckerDecompress3") == 0)
{
return PluckerDecompress3;
}
if (strcmp(_s, "PluckerDecompress4") == 0)
{
return PluckerDecompress4;
}
if (strcmp(_s, "RebDecompress") == 0)
{
return RebDecompress;
}
return NULL;
}
#else
#include "qfileinfo.h"
#include <dlfcn.h>
size_t (*getdecompressor(char* _s))(UInt8*, size_t, UInt8*, size_t)
{
#ifdef USEQPE
#ifdef OPIE
QString codecpath(getenv("OPIEDIR"));
#else
QString codecpath(getenv("QTDIR"));
#endif
codecpath += "/plugins/reader/support/libpluckerdecompress.so";
#else
QString codecpath(getenv("READERDIR"));
codecpath += "/support/libpluckerdecompress.so";
#endif
qDebug("Codec:%s", (const char*)codecpath);
if (QFile::exists(codecpath))
{
qDebug("Codec:%s", (const char*)codecpath);
void* handle = dlopen(codecpath, RTLD_LAZY);
if (handle == 0)
{
qDebug("Can't find codec:%s", dlerror());
return NULL;
}
return (size_t (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s);
}
return NULL;
}
#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
@@ -121,183 +121,183 @@ CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) :
setSize( cardsFaces->width(), cardsFaces->height() );
setPen( NoPen );
flipping = FALSE;
}
void CanvasCard::setCardBack(int b)
{
if ( cardBack != b ) {
cardBack = b;
if ( cardsBacks )
delete cardsBacks;
if ( qt_screen->deviceWidth() < 200 ) {
switch (cardBack) {
case 0:
cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001_small" ) ); break;
case 1:
cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0002_small" ) ); break;
case 2:
cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0003_small" ) ); break;
case 3:
cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0004_small" ) ); break;
case 4:
cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0005_small" ) ); break;
}
} else {
switch (cardBack) {
case 0:
cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0001" ) ); break;
case 1:
cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0002" ) ); break;
case 2:
cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0003" ) ); break;
case 3:
cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0004" ) ); break;
case 4:
cardsBacks = new QPixmap( Opie::Core::OResource::loadPixmap( "cards/card_back0005" ) ); break;
}
}
if ( !isFacing() )
redraw();
}
}
void CanvasCard::draw(QPainter &painter)
{
int ix = (int)x(), iy = (int)y();
QPainter *p = &painter;
QPixmap *unscaledCard = NULL;
if ((scaleX <= 0.98) || (scaleY <= 0.98))
{
p = new QPainter();
unscaledCard = new QPixmap( cardsFaces->width(), cardsFaces->height() );
p->begin(unscaledCard);
ix = 0;
iy = 0;
}
if ( isFacing() ) {
int w = cardsFaces->width(), h = cardsFaces->height();
p->setBrush( QColor( 0xFF, 0xFF, 0xFF ) );
if ( isRed() == TRUE )
p->setPen( QColor( 0xFF, 0, 0 ) );
else
p->setPen( QColor( 0, 0, 0 ) );
if ( qt_screen->deviceWidth() < 200 ) {
p->drawPixmap( ix + 0, iy + 0, *cardsFaces );
p->drawPixmap( ix + 3, iy + 3, *cardsChars, 5*(getValue()-1), 0, 5, 6 );
p->drawPixmap( ix + 11, iy + 3, *cardsSuits, 5*(getSuit()-1), 0, 5, 6 );
p->drawPixmap( ix + w-3-5, iy + h-3-6, *cardsCharsUpsideDown, 5*(12-getValue()+1), 0, 5, 6 );
p->drawPixmap( ix + w-11-5, iy + h-3-6, *cardsSuitsUpsideDown, 5*(3-getSuit()+1), 0, 5, 6 );
} else {
p->drawPixmap( ix + 0, iy + 0, *cardsFaces );
p->drawPixmap( ix + 4, iy + 4, *cardsChars, 7*(getValue()-1), 0, 7, 7 );
p->drawPixmap( ix + 12, iy + 4, *cardsSuits, 7*(getSuit()-1), 0, 7, 8 );
p->drawPixmap( ix + w-4-7, iy + h-4-7, *cardsCharsUpsideDown, 7*(12-getValue()+1), 0, 7, 7 );
p->drawPixmap( ix + w-12-7, iy + h-5-7, *cardsSuitsUpsideDown, 7*(3-getSuit()+1), 0, 7, 8 );
}
} else {
p->drawPixmap( ix, iy, *cardsBacks );
}
- if (p != &painter)
+ if (p != &painter && unscaledCard)
{
p->end();
QPixmap *scaledCard = CreateScaledPixmap( unscaledCard, scaleX, scaleY );
int xoff = scaledCard->width() / 2;
int yoff = scaledCard->height() / 2;
painter.drawPixmap( (int)x() + xOff - xoff, (int)y() + yOff - yoff, *scaledCard );
delete p;
delete unscaledCard;
delete scaledCard;
}
}
static const double flipLift = 1.5;
void CanvasCard::flipTo(int x2, int y2, int steps)
{
flipSteps = steps;
#ifdef SLOW_HARDWARE
move(x2,y2);
Card::flipTo(x2,y2,steps);
#else
int x1 = (int)x();
int y1 = (int)y();
double dx = x2 - x1;
double dy = y2 - y1;
flipping = TRUE;
destX = x2;
destY = y2;
animSteps = flipSteps;
setVelocity(dx/animSteps, dy/animSteps-flipLift);
setAnimated(TRUE);
#endif
}
void CanvasCard::advance(int stage)
{
if ( stage==1 ) {
if ( animSteps-- <= 0 ) {
scaleX = 1.0;
scaleY = 1.0;
flipping = FALSE;
setVelocity(0,0);
setAnimated(FALSE);
move(destX,destY); // exact
} else {
if ( flipping ) {
if ( animSteps > flipSteps / 2 ) {
// animSteps = flipSteps .. flipSteps/2 (flip up) -> 1..0
scaleX = ((double)animSteps/flipSteps-0.5)*2;
} else {
// animSteps = flipSteps/2 .. 0 (flip down) -> 0..1
scaleX = 1-((double)animSteps/flipSteps)*2;
}
if ( animSteps == flipSteps / 2-1 ) {
setYVelocity(yVelocity()+flipLift*2);
setFace( !isFacing() );
}
}
}
}
QCanvasRectangle::advance(stage);
}
void CanvasCard::animatedMove(int x2, int y2, int steps)
{
destX = x2;
destY = y2;
double x1 = x(), y1 = y(), dx = x2 - x1, dy = y2 - y1;
// Ensure a good speed
while ( fabs(dx/steps)+fabs(dy/steps) < 5.0 && steps > 4 )
steps--;
setAnimated(TRUE);
setVelocity(dx/steps, dy/steps);
animSteps = steps;
}
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
@@ -81,126 +81,119 @@ void OHighscore::getList()
pPlayerData->level = 0;
playerData.append( pPlayerData );
}
}
}
void OHighscore::checkIfItIsANewhighscore( int points)
{
if ( points > lowest )
isNewhighscore = true;
else
isNewhighscore = false;
}
void OHighscore::insertData( QString name , int punkte , int playerLevel )
{
Config cfg ( "tetrix" );
t_playerData * Run;
int index = 0;
int entryNumber = 1;
for ( Run=playerData.first();
Run != 0;
index ++, Run=playerData.next() ) {
if ( punkte > Run->points )
{
t_playerData* temp = new t_playerData;
temp->sName = name;
temp->points = punkte;
temp->level = playerLevel;
playerData.insert( index, temp );
//now we have to delete the last entry
playerData.remove( playerData.count() );
/////////////////////////////////////////
//this block just rewrites the highscore
for ( t_playerData * Run2=playerData.first();
Run2 != 0;
Run2=playerData.next() ) {
cfg.setGroup( QString::number( entryNumber ) );
cfg.writeEntry( "Name" , Run2->sName );
cfg.writeEntry( "Points" , Run2->points );
cfg.writeEntry( "Level" , Run2->level );
entryNumber++;
}
////////////////////////////////////////
return;
}
}
}
QString OHighscore::getName()
{
QString name;
QDialog *d = new QDialog ( this, 0, true );
d->setCaption( tr( "Enter your name!" ));
QLineEdit *ed = new QLineEdit ( d );
( new QVBoxLayout ( d, 3, 3 ))->addWidget ( ed );
ed->setFocus ( );
if ( d->exec() == QDialog::Accepted ) {
name = ed->text();
}
//delete d;
return name;
}
OHighscoreDialog::OHighscoreDialog(OHighscore *highscore, QWidget *parent, const char *name, bool modal) : QDialog(parent, name, modal)
{
hs_ = highscore;
setCaption( tr( "Highscores" ) );
vbox_layout = new QVBoxLayout( this, 4 , 4 );
list = new QListView( this );
list->setSorting( -1 );
list->addColumn( tr( "#" ));
list->addColumn( tr( "Name" ));
list->addColumn( tr( "Points" ));
list->addColumn( tr( "Level" ));
createHighscoreListView();
vbox_layout->addWidget( list );
QPEApplication::showDialog( this );
}
void OHighscoreDialog::createHighscoreListView()
{
int pos = 10;
int points_ = 0;
int level_ = 0;
- QListViewItem * Prev = 0;
for ( t_playerData * Run = hs_->playerData.first();
Run != 0;
Run=hs_->playerData.next() )
{
QListViewItem *item;
- if( Prev ) {
- // after previous
- item = new QListViewItem( list, Prev );
- Prev = item;
- } else {
- item = new QListViewItem( list );
+ item = new QListViewItem( list );
- }
item->setText( 0 , QString::number( pos ) ); //number
item->setText( 1 , Run->sName ); //name
if ( Run->points == -1 )
points_ = 0;
else points_ = Run->points;
if ( Run->level == -1 )
level_ = 0;
else level_ = Run->level;
item->setText( 2 , QString::number( points_ ) ); //points
item->setText( 3 , QString::number( level_ ) ); //level
pos--;
}
}