Changeset View
Changeset View
Standalone View
Standalone View
src/gui/welcomescreen.cpp
Show First 20 Lines • Show All 137 Lines • ▼ Show 20 Line(s) | 137 | void WelcomeScreen::configureVariant() { | |||
---|---|---|---|---|---|
138 | GameVariant* variant = selectedVariant(); | 138 | GameVariant* variant = selectedVariant(); | ||
139 | if(!variant) return; | 139 | if(!variant) return; | ||
140 | 140 | | |||
141 | variant->configure(); | 141 | variant->configure(); | ||
142 | } | 142 | } | ||
143 | 143 | | |||
144 | void WelcomeScreen::startEmptyGame() { | 144 | void WelcomeScreen::startEmptyGame() { | ||
145 | GameVariant* variant = selectedVariant(); | 145 | GameVariant* variant = selectedVariant(); | ||
146 | if(!variant) return; | 146 | if(!variant) { | ||
147 | KMessageBox::sorry(this, i18n("Please select a puzzle variant."), i18n("Unable to start puzzle")); | ||||
148 | return; | ||||
149 | } | ||||
147 | 150 | | |||
148 | Game game = variant->startEmpty(); | 151 | Game game = variant->startEmpty(); | ||
149 | if (! game.isValid()) return; | 152 | if (! game.isValid()) { | ||
153 | KMessageBox::sorry(this, i18n("Unable to create an empty puzzle of the chosen variant; please try another."), i18n("Unable to start puzzle")); | ||||
154 | return; | ||||
155 | } | ||||
150 | 156 | | |||
151 | emit newGameStarted(game, variant); | 157 | emit newGameStarted(game, variant); | ||
152 | } | 158 | } | ||
153 | 159 | | |||
154 | void WelcomeScreen::playVariant() { | 160 | void WelcomeScreen::playVariant() { | ||
155 | return; // Disable old game-creation code. | 161 | return; // Disable old game-creation code. | ||
156 | GameVariant* variant = selectedVariant(); | 162 | GameVariant* variant = selectedVariant(); | ||
157 | if(!variant) return; | 163 | if(!variant) { | ||
164 | KMessageBox::sorry(this, i18n("Please select a puzzle variant."), i18n("Unable to start puzzle")); | ||||
165 | return; | ||||
166 | } | ||||
158 | 167 | | |||
159 | Game game = variant->createGame(difficulty(), 0); | 168 | Game game = variant->createGame(difficulty(), 0); | ||
169 | if(!game.isValid()) { | ||||
170 | KMessageBox::sorry(this, i18n("Unable to start a puzzle of the chosen variant; please try another."), i18n("Unable to start puzzle")); | ||||
171 | return; | ||||
172 | } | ||||
160 | 173 | | |||
161 | emit newGameStarted(game, variant); | 174 | emit newGameStarted(game, variant); | ||
162 | } | 175 | } | ||
163 | 176 | | |||
164 | void WelcomeScreen::generatePuzzle() { | 177 | void WelcomeScreen::generatePuzzle() { | ||
165 | GameVariant* variant = selectedVariant(); | 178 | GameVariant* variant = selectedVariant(); | ||
166 | if(!variant) return; | 179 | if(!variant) { | ||
180 | KMessageBox::sorry(this, i18n("Please select a puzzle variant."), i18n("Unable to start puzzle")); | ||||
181 | return; | ||||
182 | } | ||||
167 | 183 | | |||
168 | Game game = variant->createGame(difficulty(), symmetry()); | 184 | Game game = variant->createGame(difficulty(), symmetry()); | ||
185 | if(!game.isValid()) { | ||||
186 | KMessageBox::sorry(this, i18n("Unable to generate a puzzle of the chosen variant; please try another."), i18n("Unable to start puzzle")); | ||||
187 | return; | ||||
188 | } | ||||
169 | 189 | | |||
170 | // Save the selected puzzle configuration. | 190 | // Save the selected puzzle configuration. | ||
171 | QModelIndex index = gameListWidget->currentIndex(); | 191 | QModelIndex index = gameListWidget->currentIndex(); | ||
172 | m_selectedPuzzle = index.row(); | 192 | m_selectedPuzzle = index.row(); | ||
173 | 193 | | |||
174 | KConfigGroup gameGroup (KSharedConfig::openConfig(), "KSudokuGame"); | 194 | KConfigGroup gameGroup (KSharedConfig::openConfig(), "KSudokuGame"); | ||
175 | gameGroup.writeEntry("SelectedPuzzle", m_selectedPuzzle); | 195 | gameGroup.writeEntry("SelectedPuzzle", m_selectedPuzzle); | ||
176 | gameGroup.writeEntry("Difficulty", m_difficulty); | 196 | gameGroup.writeEntry("Difficulty", m_difficulty); | ||
Show All 13 Lines |