author | kergoth <kergoth> | 2002-06-07 18:53:14 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-06-07 18:53:14 (UTC) |
commit | 640d964cfdc7467f6cacb513087cd3acda2c04f0 (patch) (unidiff) | |
tree | 9a784686c1795f8b1f81eb344598f3b549d43467 /noncore/games/wordgame | |
parent | dfb9c76738bb68e235114c5ad43dbd26a59b98ab (diff) | |
download | opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.zip opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.gz opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.bz2 |
Backing out unintentional merge from TT branch.
-rw-r--r-- | noncore/games/wordgame/wordgame.cpp | 71 | ||||
-rw-r--r-- | noncore/games/wordgame/wordgame.h | 6 |
2 files changed, 62 insertions, 15 deletions
diff --git a/noncore/games/wordgame/wordgame.cpp b/noncore/games/wordgame/wordgame.cpp index ca4352d..16d37b3 100644 --- a/noncore/games/wordgame/wordgame.cpp +++ b/noncore/games/wordgame/wordgame.cpp | |||
@@ -59,6 +59,13 @@ enum RuleEffects { | |||
59 | Start=128 | 59 | Start=128 |
60 | }; | 60 | }; |
61 | 61 | ||
62 | static int tile_smallw = 16; | ||
63 | static int tile_smallh = 16; | ||
64 | static int tile_bigw = 22; | ||
65 | static int tile_bigh = 22; | ||
66 | static int tile_stweak = -2; | ||
67 | static int tile_btweak = -1; | ||
68 | |||
62 | static const int rack_tiles=7; | 69 | static const int rack_tiles=7; |
63 | 70 | ||
64 | const char* sampleWGR= | 71 | const char* sampleWGR= |
@@ -111,6 +118,15 @@ const char* sampleWGR= | |||
111 | WordGame::WordGame( QWidget* parent, const char* name, WFlags fl ) : | 118 | WordGame::WordGame( QWidget* parent, const char* name, WFlags fl ) : |
112 | QMainWindow(parent, name, fl) | 119 | QMainWindow(parent, name, fl) |
113 | { | 120 | { |
121 | if ( qApp->desktop()->width() < 240 ) { | ||
122 | tile_smallw = 10; | ||
123 | tile_smallh = 10; | ||
124 | tile_bigw = 16; | ||
125 | tile_bigh = 16; | ||
126 | tile_stweak = 0; | ||
127 | tile_btweak = 0; | ||
128 | } | ||
129 | |||
114 | setIcon( Resource::loadPixmap( "wordgame" ) ); | 130 | setIcon( Resource::loadPixmap( "wordgame" ) ); |
115 | setCaption( tr("Word Game") ); | 131 | setCaption( tr("Word Game") ); |
116 | 132 | ||
@@ -247,6 +263,7 @@ void WordGame::startGame(const QStringList& playerlist) | |||
247 | { | 263 | { |
248 | toolbar->show(); | 264 | toolbar->show(); |
249 | racks = new QWidgetStack(vbox); | 265 | racks = new QWidgetStack(vbox); |
266 | racks->setFixedHeight(TileItem::bigHeight()+2); | ||
250 | namelist.clear(); | 267 | namelist.clear(); |
251 | nplayers=0; | 268 | nplayers=0; |
252 | for (QStringList::ConstIterator it=playerlist.begin(); it!=playerlist.end(); ++it) | 269 | for (QStringList::ConstIterator it=playerlist.begin(); it!=playerlist.end(); ++it) |
@@ -283,7 +300,6 @@ bool WordGame::loadRules(const QString &name) | |||
283 | if ( htiles < 3 || vtiles < 3 ) | 300 | if ( htiles < 3 || vtiles < 3 ) |
284 | return FALSE; | 301 | return FALSE; |
285 | 302 | ||
286 | QPixmap bgshapes = Resource::loadPixmap(shapepixmap); | ||
287 | QString rule_shapes; | 303 | QString rule_shapes; |
288 | for (int i=0; i<vtiles; i++) { | 304 | for (int i=0; i<vtiles; i++) { |
289 | QString line; | 305 | QString line; |
@@ -297,6 +313,12 @@ bool WordGame::loadRules(const QString &name) | |||
297 | rule_effects[re] = e; | 313 | rule_effects[re] = e; |
298 | if ( re++ < 10 ) ts >> e; | 314 | if ( re++ < 10 ) ts >> e; |
299 | } | 315 | } |
316 | |||
317 | QImage shim = Resource::loadImage(shapepixmap); | ||
318 | shim = shim.smoothScale((re-1)*TileItem::smallWidth(),TileItem::smallHeight()); | ||
319 | QPixmap bgshapes; | ||
320 | bgshapes.convertFromImage(shim); | ||
321 | |||
300 | rule_effects[re++] = 100; // default bonus | 322 | rule_effects[re++] = 100; // default bonus |
301 | board = new Board(bgshapes, htiles, vtiles, vbox); | 323 | board = new Board(bgshapes, htiles, vtiles, vbox); |
302 | board->setRules(rule_shapes, rule_effects); | 324 | board->setRules(rule_shapes, rule_effects); |
@@ -681,22 +703,22 @@ qDebug("%d,%d: %s (%d) for %d",current.x(),current.y(),st.latin1(),n,s); | |||
681 | 703 | ||
682 | int TileItem::smallWidth() | 704 | int TileItem::smallWidth() |
683 | { | 705 | { |
684 | return 16; | 706 | return tile_smallw; |
685 | } | 707 | } |
686 | 708 | ||
687 | int TileItem::smallHeight() | 709 | int TileItem::smallHeight() |
688 | { | 710 | { |
689 | return 16; | 711 | return tile_smallh; |
690 | } | 712 | } |
691 | 713 | ||
692 | int TileItem::bigWidth() | 714 | int TileItem::bigWidth() |
693 | { | 715 | { |
694 | return 22; | 716 | return tile_bigw; |
695 | } | 717 | } |
696 | 718 | ||
697 | int TileItem::bigHeight() | 719 | int TileItem::bigHeight() |
698 | { | 720 | { |
699 | return 22; | 721 | return tile_bigh; |
700 | } | 722 | } |
701 | 723 | ||
702 | void TileItem::setState( State state ) | 724 | void TileItem::setState( State state ) |
@@ -720,26 +742,36 @@ void TileItem::setBig(bool b) | |||
720 | 742 | ||
721 | void TileItem::drawShape(QPainter& p) | 743 | void TileItem::drawShape(QPainter& p) |
722 | { | 744 | { |
723 | static QFont value_font("heletica",8); | 745 | static QFont *value_font=0; |
724 | static QFont big_font("smoothtimes",17); | 746 | static QFont *big_font=0; |
725 | static QFont small_font("smoothtimes",10); | 747 | static QFont *small_font=0; |
748 | if ( !value_font ) { | ||
749 | value_font = new QFont("helvetica",8); | ||
750 | if ( TileItem::bigWidth() < 20 ) { | ||
751 | big_font = new QFont("helvetica",12); | ||
752 | small_font = new QFont("helvetica",8); | ||
753 | } else { | ||
754 | big_font = new QFont("smoothtimes",17); | ||
755 | small_font = new QFont("smoothtimes",10); | ||
756 | } | ||
757 | } | ||
726 | 758 | ||
727 | QRect area(x(),y(),width(),height()); | 759 | QRect area(x(),y(),width(),height()); |
728 | p.setBrush(s == Floating ? yellow/*lightGray*/ : white); | 760 | p.setBrush(s == Floating ? yellow/*lightGray*/ : white); |
729 | p.drawRect(area); | 761 | p.drawRect(area); |
730 | if ( big ) { | 762 | if ( big ) { |
731 | p.setFont(value_font); | 763 | p.setFont(*value_font); |
732 | QString n = QString::number(t.value()); | 764 | QString n = QString::number(t.value()); |
733 | int w = p.fontMetrics().width('1'); | 765 | int w = p.fontMetrics().width('1'); |
734 | int h = p.fontMetrics().height(); | 766 | int h = p.fontMetrics().height(); |
735 | w *= n.length(); | 767 | w *= n.length(); |
736 | QRect valuearea(x()+width()-w-2,y()+height()-h+1,w,h); | 768 | QRect valuearea(x()+width()-w-1,y()+height()-h,w,h); |
737 | p.drawText(valuearea,AlignCenter,n); | 769 | p.drawText(valuearea,AlignCenter,n); |
738 | p.setFont(big_font); | 770 | p.setFont(*big_font); |
739 | area = QRect(x(),y(),width()-2,height()-1); | 771 | area = QRect(x(),y()+tile_btweak,width()-4,height()-1); |
740 | } else { | 772 | } else { |
741 | p.setFont(small_font); | 773 | p.setFont(*small_font); |
742 | area = QRect(x(),y()+2,width(),height()-2); | 774 | area = QRect(x()+1+tile_stweak,y()+1,width(),height()-3); |
743 | } | 775 | } |
744 | if ( t.value() == 0 ) | 776 | if ( t.value() == 0 ) |
745 | p.setPen(darkGray); | 777 | p.setPen(darkGray); |
@@ -750,6 +782,7 @@ Board::Board(QPixmap bgshapes, int w, int h, QWidget* parent) : | |||
750 | QCanvasView(new QCanvas(bgshapes,w,h, TileItem::smallWidth(), TileItem::smallHeight()), | 782 | QCanvasView(new QCanvas(bgshapes,w,h, TileItem::smallWidth(), TileItem::smallHeight()), |
751 | parent) | 783 | parent) |
752 | { | 784 | { |
785 | setFixedSize(w*TileItem::smallWidth(),h*TileItem::smallHeight()); | ||
753 | grid = new TileItem*[w*h]; | 786 | grid = new TileItem*[w*h]; |
754 | memset(grid,0,w*h*sizeof(TileItem*)); | 787 | memset(grid,0,w*h*sizeof(TileItem*)); |
755 | setFrameStyle(0); | 788 | setFrameStyle(0); |
@@ -764,6 +797,11 @@ Board::~Board() | |||
764 | delete canvas(); | 797 | delete canvas(); |
765 | } | 798 | } |
766 | 799 | ||
800 | QSize Board::sizeHint() const | ||
801 | { | ||
802 | return QSize(canvas()->width(),canvas()->height()); | ||
803 | } | ||
804 | |||
767 | void Board::writeConfig(Config& cfg) | 805 | void Board::writeConfig(Config& cfg) |
768 | { | 806 | { |
769 | QStringList t; | 807 | QStringList t; |
@@ -1181,6 +1219,11 @@ Rack::~Rack() | |||
1181 | delete canvas(); | 1219 | delete canvas(); |
1182 | } | 1220 | } |
1183 | 1221 | ||
1222 | QSize Rack::sizeHint() const | ||
1223 | { | ||
1224 | return QSize(-1,TileItem::bigHeight()+2); | ||
1225 | } | ||
1226 | |||
1184 | void Rack::clear() | 1227 | void Rack::clear() |
1185 | { | 1228 | { |
1186 | for (int i=0; i<n; i++) | 1229 | for (int i=0; i<n; i++) |
diff --git a/noncore/games/wordgame/wordgame.h b/noncore/games/wordgame/wordgame.h index 0ffa56a..f73c85a 100644 --- a/noncore/games/wordgame/wordgame.h +++ b/noncore/games/wordgame/wordgame.h | |||
@@ -148,6 +148,8 @@ public: | |||
148 | void setComputerization(int level) { cpu=level; } | 148 | void setComputerization(int level) { cpu=level; } |
149 | bool computerized() const { return cpu>0; } | 149 | bool computerized() const { return cpu>0; } |
150 | 150 | ||
151 | QSize sizeHint() const; | ||
152 | |||
151 | protected: | 153 | protected: |
152 | void resizeEvent(QResizeEvent*e); | 154 | void resizeEvent(QResizeEvent*e); |
153 | void contentsMousePressEvent(QMouseEvent*); | 155 | void contentsMousePressEvent(QMouseEvent*); |
@@ -211,6 +213,8 @@ public: | |||
211 | 213 | ||
212 | int turnScore() const { return turn_score; } | 214 | int turnScore() const { return turn_score; } |
213 | 215 | ||
216 | QSize sizeHint() const; | ||
217 | |||
214 | signals: | 218 | signals: |
215 | void temporaryScore(int); | 219 | void temporaryScore(int); |
216 | 220 | ||
@@ -331,7 +335,7 @@ private: | |||
331 | 335 | ||
332 | QWidgetStack *racks; | 336 | QWidgetStack *racks; |
333 | QToolBar* toolbar; | 337 | QToolBar* toolbar; |
334 | QVBox *vbox; | 338 | QWidget *vbox; |
335 | Board *board; | 339 | Board *board; |
336 | Bag *bag; | 340 | Bag *bag; |
337 | ScoreInfo *scoreinfo; | 341 | ScoreInfo *scoreinfo; |