Diffstat (limited to 'noncore/games/buzzword/buzzword.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/buzzword/buzzword.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/games/buzzword/buzzword.cpp b/noncore/games/buzzword/buzzword.cpp index 13eb481..b7f2573 100644 --- a/noncore/games/buzzword/buzzword.cpp +++ b/noncore/games/buzzword/buzzword.cpp | |||
@@ -66,97 +66,97 @@ void BuzzItem::flip() | |||
66 | label->setBackgroundColor(label->colorGroup().highlight()); | 66 | label->setBackgroundColor(label->colorGroup().highlight()); |
67 | emit clicked(_row, _column); | 67 | emit clicked(_row, _column); |
68 | } | 68 | } |
69 | 69 | ||
70 | BuzzWord::BuzzWord(QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) | 70 | BuzzWord::BuzzWord(QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) |
71 | { | 71 | { |
72 | setCaption(tr("buZzword")); | 72 | setCaption(tr("buZzword")); |
73 | 73 | ||
74 | menu = menuBar(); | 74 | menu = menuBar(); |
75 | game = new QPopupMenu; | 75 | game = new QPopupMenu; |
76 | game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N ); | 76 | game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N ); |
77 | menu->insertItem( tr("&Game"), game ); | 77 | menu->insertItem( tr("&Game"), game ); |
78 | 78 | ||
79 | gridVal = 4; | 79 | gridVal = 4; |
80 | grid = NULL; | 80 | grid = NULL; |
81 | gameOver = false; | 81 | gameOver = false; |
82 | newGame(); | 82 | newGame(); |
83 | } | 83 | } |
84 | 84 | ||
85 | void BuzzWord::drawGrid() | 85 | void BuzzWord::drawGrid() |
86 | { | 86 | { |
87 | QStringList l; | 87 | QStringList l; |
88 | 88 | ||
89 | QString path = QPEApplication::qpeDir()+"share/buzzword/"; | 89 | QString path = QPEApplication::qpeDir()+"share/buzzword/"; |
90 | QFile f( path + "buzzwords" ); | 90 | QFile f( path + "buzzwords" ); |
91 | if ( !f.open( IO_ReadOnly ) ) | 91 | if ( !f.open( IO_ReadOnly ) ) |
92 | return; | 92 | return; |
93 | 93 | ||
94 | QTextStream t( &f ); | 94 | QTextStream t( &f ); |
95 | 95 | ||
96 | while (!t.atEnd()) | 96 | while (!t.atEnd()) |
97 | { | 97 | { |
98 | l << t.readLine(); | 98 | l << t.readLine(); |
99 | } | 99 | } |
100 | 100 | ||
101 | f.close(); | 101 | f.close(); |
102 | 102 | ||
103 | grid = new QGrid(gridVal, this); | 103 | grid = new QGrid(gridVal, this); |
104 | //grid->setFixedSize( 480, 480 ); | 104 | //grid->setFixedSize( 480, 480 ); |
105 | 105 | ||
106 | for( int c = 0 ; c < gridVal ; c++ ) | 106 | for( int c = 0 ; c < gridVal ; c++ ) |
107 | { | 107 | { |
108 | for( int r = 0 ; r < gridVal ; r++ ) | 108 | for( int r = 0 ; r < gridVal ; r++ ) |
109 | { | 109 | { |
110 | uint pos = rand() % l. count(); | 110 | uint pos = rand() % l. count(); |
111 | 111 | ||
112 | QString word = QStringList::split(" ", l[pos]).join("\n"); | 112 | QString word = QStringList::split(" ", l[pos]).join("\n"); |
113 | BuzzItem* bi = new BuzzItem( c, r, word, grid ); | 113 | BuzzItem* bi = new BuzzItem( c, r, word, grid ); |
114 | connect( bi, SIGNAL(clicked(int, int)), this, SLOT(clicked(int,int)) ); | 114 | connect( bi, SIGNAL(clicked(int,int)), this, SLOT(clicked(int,int)) ); |
115 | map[c][r] = 0; | 115 | map[c][r] = 0; |
116 | 116 | ||
117 | l.remove( l.at( pos )); | 117 | l.remove( l.at( pos )); |
118 | } | 118 | } |
119 | } | 119 | } |
120 | } | 120 | } |
121 | 121 | ||
122 | void BuzzWord::clicked(int row, int column) | 122 | void BuzzWord::clicked(int row, int column) |
123 | { | 123 | { |
124 | if ( ! gameOver ) | 124 | if ( ! gameOver ) |
125 | { | 125 | { |
126 | int rowTotal = 0; | 126 | int rowTotal = 0; |
127 | int columnTotal = 0; | 127 | int columnTotal = 0; |
128 | 128 | ||
129 | map[column][row] = 1; | 129 | map[column][row] = 1; |
130 | 130 | ||
131 | for( int c = 0 ; c < gridVal ; c++ ) | 131 | for( int c = 0 ; c < gridVal ; c++ ) |
132 | { | 132 | { |
133 | for( int r = 0 ; r < gridVal ; r++ ) | 133 | for( int r = 0 ; r < gridVal ; r++ ) |
134 | { | 134 | { |
135 | if ( map[c][r] == 1 ) | 135 | if ( map[c][r] == 1 ) |
136 | rowTotal++; | 136 | rowTotal++; |
137 | 137 | ||
138 | if ( rowTotal == 4 ) | 138 | if ( rowTotal == 4 ) |
139 | { | 139 | { |
140 | bingo(); | 140 | bingo(); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | rowTotal = 0; | 143 | rowTotal = 0; |
144 | } | 144 | } |
145 | 145 | ||
146 | for( int r = 0 ; r < gridVal ; r++ ) | 146 | for( int r = 0 ; r < gridVal ; r++ ) |
147 | { | 147 | { |
148 | for( int c = 0 ; c < gridVal ; c++ ) | 148 | for( int c = 0 ; c < gridVal ; c++ ) |
149 | { | 149 | { |
150 | if ( map[c][r] == 1 ) | 150 | if ( map[c][r] == 1 ) |
151 | columnTotal++; | 151 | columnTotal++; |
152 | 152 | ||
153 | if ( columnTotal == 4 ) | 153 | if ( columnTotal == 4 ) |
154 | { | 154 | { |
155 | bingo(); | 155 | bingo(); |
156 | } | 156 | } |
157 | } | 157 | } |
158 | columnTotal = 0; | 158 | columnTotal = 0; |
159 | } | 159 | } |
160 | 160 | ||
161 | if ( map[0][0] && map[1][1] && map[2][2] && map[3][3] ) | 161 | if ( map[0][0] && map[1][1] && map[2][2] && map[3][3] ) |
162 | bingo(); | 162 | bingo(); |