summaryrefslogtreecommitdiff
Unidiff
Diffstat (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 @@
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qtimer.h>
29 30
@@ -109,2 +110,4 @@ QTetrix::QTetrix( QWidget *parent, const char *name, WFlags f )
109 QGridLayout *gl = new QGridLayout( gameArea, 5, 3, 8 ); 110 QGridLayout *gl = new QGridLayout( gameArea, 5, 3, 8 );
111 gl->setColStretch( 1, 5 );
112 gl->setColStretch( 2, 10 );
110 113
@@ -132,7 +135,3 @@ QTetrix::QTetrix( QWidget *parent, const char *name, WFlags f )
132 board->setBackgroundColor(QColor(0,0,0)); 135 board->setBackgroundColor(QColor(0,0,0));
133 board->setFixedWidth( 124 );
134 gl->addMultiCellWidget( board, 0, 4, 2, 2 ); 136 gl->addMultiCellWidget( board, 0, 4, 2, 2 );
135 gl->addColSpacing( 2, 100 );
136 gl->addColSpacing( 1, 35 );
137 gl->addRowSpacing( 0, 35 );
138 137
@@ -144,11 +143,8 @@ QTetrix::QTetrix( QWidget *parent, const char *name, WFlags f )
144 connect( board, SIGNAL(gameOverSignal()), SLOT(gameOver()) ); 143 connect( board, SIGNAL(gameOverSignal()), SLOT(gameOver()) );
145 connect( board, SIGNAL(drawNextSquareSignal(int,int,QColor*)), showNext, 144 connect( board, SIGNAL(drawNextSquareSignal(int,int,QColor*)), this,
146 SLOT(drawNextSquare(int,int,QColor*)) ); 145 SLOT(setNext(int,int,QColor*)) );
147 connect( showNext, SIGNAL(update()), board, SLOT(updateNext()) ); 146 connect( showNext, SIGNAL(update()), board, SLOT(updateNext()) );
148 connect( board, SIGNAL(updateScoreSignal(int)), showScore, 147 connect( board, SIGNAL(updateScoreSignal(int)), showScore, SLOT(setNum(int)) );
149 SLOT(setNum(int)) ); 148 connect( board, SIGNAL(updateLevelSignal(int)), showLevel, SLOT(setNum(int)) );
150 connect( board, SIGNAL(updateLevelSignal(int)), showLevel, 149 connect( board, SIGNAL(updateRemovedSignal(int)), showLines, SLOT(setNum(int)) );
151 SLOT(setNum(int)));
152 connect( board, SIGNAL(updateRemovedSignal(int)), showLines,
153 SLOT(setNum(int)));
154 150
@@ -159,2 +155,9 @@ QTetrix::QTetrix( QWidget *parent, const char *name, WFlags f )
159 board->setFocusPolicy( StrongFocus ); 155 board->setFocusPolicy( StrongFocus );
156
157 QTimer::singleShot( -1, this, SLOT(setup()) );
158}
159
160void QTetrix::setup()
161{
162 resizeEvent( 0x0 );
160} 163}
@@ -174 +177,32 @@ void QTetrix::quit()
174} 177}
178
179void QTetrix::setNext( int x, int y, QColor *color )
180{
181 resizeEvent( 0x0 );
182 showNext->drawNextSquare( x, y, color );
183}
184
185void QTetrix::resizeEvent( QResizeEvent * )
186{
187 // Set size of board
188 int widthFactor = board->QFrame::width() / board->boardWidth();
189 if ( widthFactor < 1 )
190 widthFactor = 1;
191 int heightFactor = board->QFrame::height() / board->boardHeight();
192 if ( heightFactor < 1 )
193 heightFactor = 1;
194 widthFactor > heightFactor ? board->resize( heightFactor * board->boardWidth() + 2,
195 heightFactor * board->boardHeight() + 2 )
196 : board->resize( widthFactor * board->boardWidth() + 2,
197 widthFactor * board->boardHeight() + 2 );
198
199 // Set size of preview widget
200 widthFactor = showNext->width() / 5;
201 if ( widthFactor < 1 )
202 widthFactor = 1;
203 heightFactor = showNext->height() / 6;
204 if ( heightFactor < 1 )
205 heightFactor = 1;
206 widthFactor > heightFactor ? showNext->resize( heightFactor * 5 + 2, heightFactor * 6 + 2 )
207 : showNext->resize( widthFactor * 5 + 2, widthFactor * 6 + 2 );
208}
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:
59public slots: 59public slots:
60 void setup();
60 void gameOver(); 61 void gameOver();
61 void quit(); 62 void quit();
63
64 void setNext( int x, int y, QColor *color );
65// void setScore( int score );
66// void setLevel( int level );
67// void setLines( int lines );
68
62private: 69private:
63 void keyPressEvent( QKeyEvent *e ) { board->keyPressEvent(e); } 70 void keyPressEvent( QKeyEvent *e ) { board->keyPressEvent(e); }
71 void resizeEvent( QResizeEvent * );
64 72
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)
58 noGame = FALSE; 58 noGame = FALSE;
59
59 GenericTetrix::startGame( gameType, fillRandomLines ); 60 GenericTetrix::startGame( gameType, fillRandomLines );
@@ -208,4 +209,7 @@ void QTetrixBoard::resizeEvent(QResizeEvent *e)
208 QSize sz = e->size(); 209 QSize sz = e->size();
210
209 blockWidth = (sz.width() - 2)/10; 211 blockWidth = (sz.width() - 2)/10;
210 blockHeight = (sz.height() - 2)/22; 212 blockHeight = (sz.height() - 2)/22;
213/* blockWidth > blockHeight ? blockWidth = blockHeight
214 : blockHeight = blockWidth;*/
211 xOffset = 1; 215 xOffset = 1;