summaryrefslogtreecommitdiff
path: root/noncore/games
authordrw <drw>2004-12-20 14:49:49 (UTC)
committer drw <drw>2004-12-20 14:49:49 (UTC)
commit29b27cf61a7cb862a0236c8b319ff1843669142c (patch) (side-by-side diff)
treea2dee12e4241103259840385020ae317c8814d69 /noncore/games
parent480a3ae1b4ed502fbd75e345c41ad4c469eff140 (diff)
downloadopie-29b27cf61a7cb862a0236c8b319ff1843669142c.zip
opie-29b27cf61a7cb862a0236c8b319ff1843669142c.tar.gz
opie-29b27cf61a7cb862a0236c8b319ff1843669142c.tar.bz2
Reapply fix for bug #1017 - Tetrix on high resolution screens
Diffstat (limited to 'noncore/games') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/tetrix/qtetrix.cpp58
-rw-r--r--noncore/games/tetrix/qtetrix.h8
-rw-r--r--noncore/games/tetrix/qtetrixb.cpp4
3 files changed, 58 insertions, 12 deletions
diff --git a/noncore/games/tetrix/qtetrix.cpp b/noncore/games/tetrix/qtetrix.cpp
index 20cf1a7..a6a5f34 100644
--- a/noncore/games/tetrix/qtetrix.cpp
+++ b/noncore/games/tetrix/qtetrix.cpp
@@ -28,2 +28,3 @@
#include <qlayout.h>
+#include <qtimer.h>
@@ -109,2 +110,4 @@ QTetrix::QTetrix( QWidget *parent, const char *name, WFlags f )
QGridLayout *gl = new QGridLayout( gameArea, 5, 3, 8 );
+ gl->setColStretch( 1, 5 );
+ gl->setColStretch( 2, 10 );
@@ -132,7 +135,3 @@ QTetrix::QTetrix( QWidget *parent, const char *name, WFlags f )
board->setBackgroundColor(QColor(0,0,0));
- board->setFixedWidth( 124 );
gl->addMultiCellWidget( board, 0, 4, 2, 2 );
- gl->addColSpacing( 2, 100 );
- gl->addColSpacing( 1, 35 );
- gl->addRowSpacing( 0, 35 );
@@ -144,11 +143,8 @@ QTetrix::QTetrix( QWidget *parent, const char *name, WFlags f )
connect( board, SIGNAL(gameOverSignal()), SLOT(gameOver()) );
- connect( board, SIGNAL(drawNextSquareSignal(int,int,QColor*)), showNext,
- SLOT(drawNextSquare(int,int,QColor*)) );
+ connect( board, SIGNAL(drawNextSquareSignal(int,int,QColor*)), this,
+ SLOT(setNext(int,int,QColor*)) );
connect( showNext, SIGNAL(update()), board, SLOT(updateNext()) );
- connect( board, SIGNAL(updateScoreSignal(int)), showScore,
- SLOT(setNum(int)) );
- connect( board, SIGNAL(updateLevelSignal(int)), showLevel,
- SLOT(setNum(int)));
- connect( board, SIGNAL(updateRemovedSignal(int)), showLines,
- SLOT(setNum(int)));
+ connect( board, SIGNAL(updateScoreSignal(int)), showScore, SLOT(setNum(int)) );
+ connect( board, SIGNAL(updateLevelSignal(int)), showLevel, SLOT(setNum(int)) );
+ connect( board, SIGNAL(updateRemovedSignal(int)), showLines, SLOT(setNum(int)) );
@@ -159,2 +155,9 @@ QTetrix::QTetrix( QWidget *parent, const char *name, WFlags f )
board->setFocusPolicy( StrongFocus );
+
+ QTimer::singleShot( -1, this, SLOT(setup()) );
+}
+
+void QTetrix::setup()
+{
+ resizeEvent( 0x0 );
}
@@ -174 +177,32 @@ void QTetrix::quit()
}
+
+void QTetrix::setNext( int x, int y, QColor *color )
+{
+ resizeEvent( 0x0 );
+ showNext->drawNextSquare( x, y, color );
+}
+
+void QTetrix::resizeEvent( QResizeEvent * )
+{
+ // Set size of board
+ int widthFactor = board->QFrame::width() / board->boardWidth();
+ if ( widthFactor < 1 )
+ widthFactor = 1;
+ int heightFactor = board->QFrame::height() / board->boardHeight();
+ if ( heightFactor < 1 )
+ heightFactor = 1;
+ widthFactor > heightFactor ? board->resize( heightFactor * board->boardWidth() + 2,
+ heightFactor * board->boardHeight() + 2 )
+ : board->resize( widthFactor * board->boardWidth() + 2,
+ widthFactor * board->boardHeight() + 2 );
+
+ // Set size of preview widget
+ widthFactor = showNext->width() / 5;
+ if ( widthFactor < 1 )
+ widthFactor = 1;
+ heightFactor = showNext->height() / 6;
+ if ( heightFactor < 1 )
+ heightFactor = 1;
+ widthFactor > heightFactor ? showNext->resize( heightFactor * 5 + 2, heightFactor * 6 + 2 )
+ : showNext->resize( widthFactor * 5 + 2, widthFactor * 6 + 2 );
+}
diff --git a/noncore/games/tetrix/qtetrix.h b/noncore/games/tetrix/qtetrix.h
index c8959c5..8c44b77 100644
--- a/noncore/games/tetrix/qtetrix.h
+++ b/noncore/games/tetrix/qtetrix.h
@@ -59,6 +59,14 @@ public:
public slots:
+ void setup();
void gameOver();
void quit();
+
+ void setNext( int x, int y, QColor *color );
+// void setScore( int score );
+// void setLevel( int level );
+// void setLines( int lines );
+
private:
void keyPressEvent( QKeyEvent *e ) { board->keyPressEvent(e); }
+ void resizeEvent( QResizeEvent * );
diff --git a/noncore/games/tetrix/qtetrixb.cpp b/noncore/games/tetrix/qtetrixb.cpp
index 3c179df..8c41fb2 100644
--- a/noncore/games/tetrix/qtetrixb.cpp
+++ b/noncore/games/tetrix/qtetrixb.cpp
@@ -58,2 +58,3 @@ void QTetrixBoard::startGame(int gameType,int fillRandomLines)
noGame = FALSE;
+
GenericTetrix::startGame( gameType, fillRandomLines );
@@ -208,4 +209,7 @@ void QTetrixBoard::resizeEvent(QResizeEvent *e)
QSize sz = e->size();
+
blockWidth = (sz.width() - 2)/10;
blockHeight = (sz.height() - 2)/22;
+/* blockWidth > blockHeight ? blockWidth = blockHeight
+ : blockHeight = blockWidth;*/
xOffset = 1;