Diffstat (limited to 'noncore/games/zsame/ZSameWidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/games/zsame/ZSameWidget.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/games/zsame/ZSameWidget.cpp b/noncore/games/zsame/ZSameWidget.cpp index 4fab0f6..04ad825 100644 --- a/noncore/games/zsame/ZSameWidget.cpp +++ b/noncore/games/zsame/ZSameWidget.cpp | |||
@@ -64,181 +64,181 @@ ZSameWidget::ZSameWidget( QWidget* parent, const char* name, WFlags fl ) | |||
64 | a->addTo( tb ); | 64 | a->addTo( tb ); |
65 | connect(a, SIGNAL(activated()), this, SLOT(m_new())); | 65 | connect(a, SIGNAL(activated()), this, SLOT(m_new())); |
66 | 66 | ||
67 | a = new QAction(tr("Restart This Board"), Resource::loadIconSet("redo"), | 67 | a = new QAction(tr("Restart This Board"), Resource::loadIconSet("redo"), |
68 | QString::null, 0, this, "restart_board" ); | 68 | QString::null, 0, this, "restart_board" ); |
69 | a->addTo( fileMenu ); | 69 | a->addTo( fileMenu ); |
70 | connect( a, SIGNAL(activated()), this, SLOT(m_restart())); | 70 | connect( a, SIGNAL(activated()), this, SLOT(m_restart())); |
71 | restart = a; | 71 | restart = a; |
72 | 72 | ||
73 | a = new QAction( tr("Undo"), Resource::loadIconSet("undo"), | 73 | a = new QAction( tr("Undo"), Resource::loadIconSet("undo"), |
74 | QString::null, 0, this, "undo_action" ); | 74 | QString::null, 0, this, "undo_action" ); |
75 | a->addTo( fileMenu ); | 75 | a->addTo( fileMenu ); |
76 | a->addTo( tb ); | 76 | a->addTo( tb ); |
77 | connect( a, SIGNAL(activated()), this, SLOT(m_undo())); | 77 | connect( a, SIGNAL(activated()), this, SLOT(m_undo())); |
78 | 78 | ||
79 | a = new QAction(tr("Quit"), Resource::loadIconSet("quit_icon"), | 79 | a = new QAction(tr("Quit"), Resource::loadIconSet("quit_icon"), |
80 | QString::null, 0, this, "quit_action"); | 80 | QString::null, 0, this, "quit_action"); |
81 | a->addTo( fileMenu ); | 81 | a->addTo( fileMenu ); |
82 | a->addTo( tb ); | 82 | a->addTo( tb ); |
83 | connect(a, SIGNAL(activated()), this, SLOT(m_quit())); | 83 | connect(a, SIGNAL(activated()), this, SLOT(m_quit())); |
84 | 84 | ||
85 | mb->insertItem(tr("Game" ), fileMenu ); | 85 | mb->insertItem(tr("Game" ), fileMenu ); |
86 | 86 | ||
87 | int foo[2]; | 87 | int foo[2]; |
88 | desktop_widget(foo); | 88 | desktop_widget(foo); |
89 | stone = new StoneWidget(this,foo[0],foo[1]); | 89 | stone = new StoneWidget(this,foo[0],foo[1]); |
90 | 90 | ||
91 | connect( stone, SIGNAL(s_gameover()), this, SLOT(gameover())); | 91 | connect( stone, SIGNAL(s_gameover()), this, SLOT(gameover())); |
92 | 92 | ||
93 | connect( stone, SIGNAL(s_colors(int)), this, SLOT(setColors(int))); | 93 | connect( stone, SIGNAL(s_colors(int)), this, SLOT(setColors(int))); |
94 | connect( stone, SIGNAL(s_board(int)), this, SLOT(setBoard(int))); | 94 | connect( stone, SIGNAL(s_board(int)), this, SLOT(setBoard(int))); |
95 | connect( stone, SIGNAL(s_marked(int)), this, SLOT(setMarked(int))); | 95 | connect( stone, SIGNAL(s_marked(int)), this, SLOT(setMarked(int))); |
96 | connect( stone, SIGNAL(s_score(int)), this, SLOT(setScore(int))); | 96 | connect( stone, SIGNAL(s_score(int)), this, SLOT(setScore(int))); |
97 | connect( stone, SIGNAL(s_remove(int,int)), this, SLOT(stonesRemoved(int,int))); | 97 | connect( stone, SIGNAL(s_remove(int,int)), this, SLOT(stonesRemoved(int,int))); |
98 | 98 | ||
99 | connect(stone, SIGNAL(s_sizechanged()), this, SLOT(sizeChanged())); | 99 | connect(stone, SIGNAL(s_sizechanged()), this, SLOT(sizeChanged())); |
100 | 100 | ||
101 | sizeChanged(); | 101 | sizeChanged(); |
102 | setCentralWidget(stone); | 102 | setCentralWidget(stone); |
103 | 103 | ||
104 | 104 | ||
105 | setScore(0); | 105 | setScore(0); |
106 | } | 106 | } |
107 | 107 | ||
108 | ZSameWidget::~ZSameWidget() { | 108 | ZSameWidget::~ZSameWidget() { |
109 | 109 | ||
110 | } | 110 | } |
111 | 111 | ||
112 | void ZSameWidget::readProperties(Config *conf) { | 112 | void ZSameWidget::readProperties(Config *) { |
113 | /* | 113 | /* |
114 | Q_ASSERT(conf); | 114 | Q_ASSERT(conf); |
115 | stone->readProperties(conf); | 115 | stone->readProperties(conf); |
116 | */ | 116 | */ |
117 | } | 117 | } |
118 | 118 | ||
119 | void ZSameWidget::saveProperties(Config *conf) { | 119 | void ZSameWidget::saveProperties(Config *) { |
120 | /* | 120 | /* |
121 | Q_ASSERT(conf); | 121 | Q_ASSERT(conf); |
122 | stone->saveProperties(conf); | 122 | stone->saveProperties(conf); |
123 | conf->sync(); | 123 | conf->sync(); |
124 | */ | 124 | */ |
125 | } | 125 | } |
126 | 126 | ||
127 | void ZSameWidget::sizeChanged() { | 127 | void ZSameWidget::sizeChanged() { |
128 | //stone->setFixedSize(stone->sizeHint()); | 128 | //stone->setFixedSize(stone->sizeHint()); |
129 | } | 129 | } |
130 | 130 | ||
131 | void ZSameWidget::newGame(unsigned int board,int colors) { | 131 | void ZSameWidget::newGame(unsigned int board,int colors) { |
132 | while (board>=1000000) board-=1000000; | 132 | while (board>=1000000) board-=1000000; |
133 | // kdDebug() << "newgame board " << board << " colors " << colors << endl; | 133 | // kdDebug() << "newgame board " << board << " colors " << colors << endl; |
134 | stone->newGame(board,colors); | 134 | stone->newGame(board,colors); |
135 | setScore(0); | 135 | setScore(0); |
136 | } | 136 | } |
137 | 137 | ||
138 | bool ZSameWidget::confirmAbort() { | 138 | bool ZSameWidget::confirmAbort() { |
139 | return stone->isGameover() || | 139 | return stone->isGameover() || |
140 | stone->isOriginalBoard() || | 140 | stone->isOriginalBoard() || |
141 | (QMessageBox::warning(this, i18n("Resign"), i18n("<qt>Do you want to resign?</qt>"), | 141 | (QMessageBox::warning(this, i18n("Resign"), i18n("<qt>Do you want to resign?</qt>"), |
142 | QMessageBox::Yes, | 142 | QMessageBox::Yes, |
143 | QMessageBox::No|QMessageBox::Default|QMessageBox::Escape, 0) == QMessageBox::Yes ); | 143 | QMessageBox::No|QMessageBox::Default|QMessageBox::Escape, 0) == QMessageBox::Yes ); |
144 | } | 144 | } |
145 | 145 | ||
146 | void ZSameWidget::m_new() { | 146 | void ZSameWidget::m_new() { |
147 | if (confirmAbort()) | 147 | if (confirmAbort()) |
148 | newGame(_random(),default_colors); | 148 | newGame(_random(),default_colors); |
149 | 149 | ||
150 | } | 150 | } |
151 | 151 | ||
152 | void ZSameWidget::m_restart() { | 152 | void ZSameWidget::m_restart() { |
153 | if (confirmAbort()) | 153 | if (confirmAbort()) |
154 | newGame(stone->board(),default_colors); | 154 | newGame(stone->board(),default_colors); |
155 | } | 155 | } |
156 | 156 | ||
157 | void ZSameWidget::m_load() { | 157 | void ZSameWidget::m_load() { |
158 | // kdDebug() << "menu load not supported" << endl; | 158 | // kdDebug() << "menu load not supported" << endl; |
159 | } | 159 | } |
160 | 160 | ||
161 | void ZSameWidget::m_save() { | 161 | void ZSameWidget::m_save() { |
162 | // kdDebug() << "menu save not supported" << endl; | 162 | // kdDebug() << "menu save not supported" << endl; |
163 | } | 163 | } |
164 | 164 | ||
165 | void ZSameWidget::m_undo() { | 165 | void ZSameWidget::m_undo() { |
166 | //Q_ASSERT(stone); | 166 | //Q_ASSERT(stone); |
167 | stone->undo(); | 167 | stone->undo(); |
168 | } | 168 | } |
169 | 169 | ||
170 | 170 | ||
171 | void ZSameWidget::m_showhs() { | 171 | void ZSameWidget::m_showhs() { |
172 | /* Q_ASSERT(stone); | 172 | /* Q_ASSERT(stone); |
173 | stone->unmark(); | 173 | stone->unmark(); |
174 | KScoreDialog d(KScoreDialog::Name | KScoreDialog::Score, this); | 174 | KScoreDialog d(KScoreDialog::Name | KScoreDialog::Score, this); |
175 | d.addField(Board, i18n("Board"), "Board"); | 175 | d.addField(Board, i18n("Board"), "Board"); |
176 | d.exec(); | 176 | d.exec(); |
177 | */ | 177 | */ |
178 | } | 178 | } |
179 | 179 | ||
180 | void ZSameWidget::m_quit() { | 180 | void ZSameWidget::m_quit() { |
181 | // Q_ASSERT(stone); | 181 | // Q_ASSERT(stone); |
182 | stone->unmark(); | 182 | stone->unmark(); |
183 | qApp->quit(); | 183 | qApp->quit(); |
184 | // delete this; | 184 | // delete this; |
185 | } | 185 | } |
186 | 186 | ||
187 | void ZSameWidget::m_tglboard() { | 187 | void ZSameWidget::m_tglboard() { |
188 | //kdDebug() << "toggled" << endl; | 188 | //kdDebug() << "toggled" << endl; |
189 | } | 189 | } |
190 | 190 | ||
191 | 191 | ||
192 | void ZSameWidget::setColors(int colors) { | 192 | void ZSameWidget::setColors(int ) { |
193 | //status->changeItem(i18n("%1 Colors").arg(colors),1); | 193 | //status->changeItem(i18n("%1 Colors").arg(colors),1); |
194 | } | 194 | } |
195 | 195 | ||
196 | void ZSameWidget::setBoard(int board) { | 196 | void ZSameWidget::setBoard(int ) { |
197 | //status->changeItem(i18n("Board: %1").arg(board, 6), 2); | 197 | //status->changeItem(i18n("Board: %1").arg(board, 6), 2); |
198 | } | 198 | } |
199 | 199 | ||
200 | void ZSameWidget::setMarked(int m) { | 200 | void ZSameWidget::setMarked(int ) { |
201 | // status->changeItem(i18n("Marked: %1").arg(m, 6),3); | 201 | // status->changeItem(i18n("Marked: %1").arg(m, 6),3); |
202 | } | 202 | } |
203 | 203 | ||
204 | void ZSameWidget::stonesRemoved(int,int) { | 204 | void ZSameWidget::stonesRemoved(int,int) { |
205 | //KNotifyClient::event("stones removed", | 205 | //KNotifyClient::event("stones removed", |
206 | // i18n("%1 stones removed.").arg(stone->marked())); | 206 | // i18n("%1 stones removed.").arg(stone->marked())); |
207 | } | 207 | } |
208 | 208 | ||
209 | void ZSameWidget::setScore(int score) { | 209 | void ZSameWidget::setScore(int ) { |
210 | // status->changeItem(i18n("Score: %1").arg(score, 6),4); | 210 | // status->changeItem(i18n("Score: %1").arg(score, 6),4); |
211 | // undo->setEnabled(stone->undoPossible()); | 211 | // undo->setEnabled(stone->undoPossible()); |
212 | // restart->setEnabled(!stone->isOriginalBoard()); | 212 | // restart->setEnabled(!stone->isOriginalBoard()); |
213 | } | 213 | } |
214 | 214 | ||
215 | void ZSameWidget::gameover() { | 215 | void ZSameWidget::gameover() { |
216 | // kdDebug() << "GameOver" << endl; | 216 | // kdDebug() << "GameOver" << endl; |
217 | if (stone->hasBonus()) { | 217 | if (stone->hasBonus()) { |
218 | QMessageBox::information(this,i18n("Game won"), | 218 | QMessageBox::information(this,i18n("Game won"), |
219 | i18n("<qt>You even removed the last stone, great job! " | 219 | i18n("<qt>You even removed the last stone, great job! " |
220 | "This gave you a score of %1 in total.</qt>").arg(stone->score())); | 220 | "This gave you a score of %1 in total.</qt>").arg(stone->score())); |
221 | } else { | 221 | } else { |
222 | QMessageBox::information(this,i18n("Game over"), | 222 | QMessageBox::information(this,i18n("Game over"), |
223 | i18n("<qt>There are no more removeable stones. " | 223 | i18n("<qt>There are no more removeable stones. " |
224 | "You got a score of %1 in total.</qt>").arg(stone->score())); | 224 | "You got a score of %1 in total.</qt>").arg(stone->score())); |
225 | } | 225 | } |
226 | stone->unmark(); | 226 | stone->unmark(); |
227 | } | 227 | } |
228 | 228 | ||
229 | void ZSameWidget::desktop_widget(int *f)const{ | 229 | void ZSameWidget::desktop_widget(int *f)const{ |
230 | 230 | ||
231 | QWidget* wid = QApplication::desktop(); | 231 | QWidget* wid = QApplication::desktop(); |
232 | /* width > height landscape mode */ | 232 | /* width > height landscape mode */ |
233 | if ( wid->width() > wid->height() ) { | 233 | if ( wid->width() > wid->height() ) { |
234 | f[0]=15; | 234 | f[0]=15; |
235 | f[1]=9; | 235 | f[1]=9; |
236 | } | 236 | } |
237 | /* normal */ | 237 | /* normal */ |
238 | else{ | 238 | else{ |
239 | f[0]=12; | 239 | f[0]=12; |
240 | f[1]=13; | 240 | f[1]=13; |
241 | } | 241 | } |
242 | } | 242 | } |
243 | 243 | ||
244 | 244 | ||