summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/unfinished/group.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/src/unfinished/group.c')
-rw-r--r--apps/plugins/puzzles/src/unfinished/group.c49
1 files changed, 23 insertions, 26 deletions
diff --git a/apps/plugins/puzzles/src/unfinished/group.c b/apps/plugins/puzzles/src/unfinished/group.c
index 4a4ad6ce53..b812b041eb 100644
--- a/apps/plugins/puzzles/src/unfinished/group.c
+++ b/apps/plugins/puzzles/src/unfinished/group.c
@@ -212,23 +212,19 @@ static config_item *game_configure(const game_params *params)
212 ret[0].name = "Grid size"; 212 ret[0].name = "Grid size";
213 ret[0].type = C_STRING; 213 ret[0].type = C_STRING;
214 sprintf(buf, "%d", params->w); 214 sprintf(buf, "%d", params->w);
215 ret[0].sval = dupstr(buf); 215 ret[0].u.string.sval = dupstr(buf);
216 ret[0].ival = 0;
217 216
218 ret[1].name = "Difficulty"; 217 ret[1].name = "Difficulty";
219 ret[1].type = C_CHOICES; 218 ret[1].type = C_CHOICES;
220 ret[1].sval = DIFFCONFIG; 219 ret[1].u.choices.choicenames = DIFFCONFIG;
221 ret[1].ival = params->diff; 220 ret[1].u.choices.selected = params->diff;
222 221
223 ret[2].name = "Show identity"; 222 ret[2].name = "Show identity";
224 ret[2].type = C_BOOLEAN; 223 ret[2].type = C_BOOLEAN;
225 ret[2].sval = NULL; 224 ret[2].u.boolean.bval = params->id;
226 ret[2].ival = params->id;
227 225
228 ret[3].name = NULL; 226 ret[3].name = NULL;
229 ret[3].type = C_END; 227 ret[3].type = C_END;
230 ret[3].sval = NULL;
231 ret[3].ival = 0;
232 228
233 return ret; 229 return ret;
234} 230}
@@ -237,14 +233,14 @@ static game_params *custom_params(const config_item *cfg)
237{ 233{
238 game_params *ret = snew(game_params); 234 game_params *ret = snew(game_params);
239 235
240 ret->w = atoi(cfg[0].sval); 236 ret->w = atoi(cfg[0].u.string.sval);
241 ret->diff = cfg[1].ival; 237 ret->diff = cfg[1].u.choices.selected;
242 ret->id = cfg[2].ival; 238 ret->id = cfg[2].u.boolean.bval;
243 239
244 return ret; 240 return ret;
245} 241}
246 242
247static char *validate_params(const game_params *params, int full) 243static const char *validate_params(const game_params *params, int full)
248{ 244{
249 if (params->w < 3 || params->w > 26) 245 if (params->w < 3 || params->w > 26)
250 return "Grid size must be between 3 and 26"; 246 return "Grid size must be between 3 and 26";
@@ -781,7 +777,7 @@ done
781 * Gameplay. 777 * Gameplay.
782 */ 778 */
783 779
784static char *validate_grid_desc(const char **pdesc, int range, int area) 780static const char *validate_grid_desc(const char **pdesc, int range, int area)
785{ 781{
786 const char *desc = *pdesc; 782 const char *desc = *pdesc;
787 int squares = 0; 783 int squares = 0;
@@ -811,7 +807,7 @@ static char *validate_grid_desc(const char **pdesc, int range, int area)
811 return NULL; 807 return NULL;
812} 808}
813 809
814static char *validate_desc(const game_params *params, const char *desc) 810static const char *validate_desc(const game_params *params, const char *desc)
815{ 811{
816 int w = params->w, a = w*w; 812 int w = params->w, a = w*w;
817 const char *p = desc; 813 const char *p = desc;
@@ -911,7 +907,7 @@ static void free_game(game_state *state)
911} 907}
912 908
913static char *solve_game(const game_state *state, const game_state *currstate, 909static char *solve_game(const game_state *state, const game_state *currstate,
914 const char *aux, char **error) 910 const char *aux, const char **error)
915{ 911{
916 int w = state->par.w, a = w*w; 912 int w = state->par.w, a = w*w;
917 int i, ret; 913 int i, ret;
@@ -1281,13 +1277,13 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1281 ui->drag |= 4; /* some movement has happened */ 1277 ui->drag |= 4; /* some movement has happened */
1282 if (tcoord >= 0 && tcoord < w) { 1278 if (tcoord >= 0 && tcoord < w) {
1283 ui->dragpos = tcoord; 1279 ui->dragpos = tcoord;
1284 return ""; 1280 return UI_UPDATE;
1285 } 1281 }
1286 } else if (IS_MOUSE_RELEASE(button)) { 1282 } else if (IS_MOUSE_RELEASE(button)) {
1287 if (ui->drag & 4) { 1283 if (ui->drag & 4) {
1288 ui->drag = 0; /* end drag */ 1284 ui->drag = 0; /* end drag */
1289 if (state->sequence[ui->dragpos] == ui->dragnum) 1285 if (state->sequence[ui->dragpos] == ui->dragnum)
1290 return ""; /* drag was a no-op overall */ 1286 return UI_UPDATE; /* drag was a no-op overall */
1291 sprintf(buf, "D%d,%d", ui->dragnum, ui->dragpos); 1287 sprintf(buf, "D%d,%d", ui->dragnum, ui->dragpos);
1292 return dupstr(buf); 1288 return dupstr(buf);
1293 } else { 1289 } else {
@@ -1298,7 +1294,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1298 state->sequence[ui->edgepos]); 1294 state->sequence[ui->edgepos]);
1299 return dupstr(buf); 1295 return dupstr(buf);
1300 } else 1296 } else
1301 return ""; /* no-op */ 1297 return UI_UPDATE; /* no-op */
1302 } 1298 }
1303 } 1299 }
1304 } else if (IS_MOUSE_DOWN(button)) { 1300 } else if (IS_MOUSE_DOWN(button)) {
@@ -1321,7 +1317,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1321 ui->hpencil = 0; 1317 ui->hpencil = 0;
1322 } 1318 }
1323 ui->hcursor = 0; 1319 ui->hcursor = 0;
1324 return ""; /* UI activity occurred */ 1320 return UI_UPDATE;
1325 } 1321 }
1326 if (button == RIGHT_BUTTON) { 1322 if (button == RIGHT_BUTTON) {
1327 /* 1323 /*
@@ -1345,20 +1341,20 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1345 ui->hshow = 0; 1341 ui->hshow = 0;
1346 } 1342 }
1347 ui->hcursor = 0; 1343 ui->hcursor = 0;
1348 return ""; /* UI activity occurred */ 1344 return UI_UPDATE;
1349 } 1345 }
1350 } else if (tx >= 0 && tx < w && ty == -1) { 1346 } else if (tx >= 0 && tx < w && ty == -1) {
1351 ui->drag = 2; 1347 ui->drag = 2;
1352 ui->dragnum = state->sequence[tx]; 1348 ui->dragnum = state->sequence[tx];
1353 ui->dragpos = tx; 1349 ui->dragpos = tx;
1354 ui->edgepos = FROMCOORD(x + TILESIZE/2); 1350 ui->edgepos = FROMCOORD(x + TILESIZE/2);
1355 return ""; 1351 return UI_UPDATE;
1356 } else if (ty >= 0 && ty < w && tx == -1) { 1352 } else if (ty >= 0 && ty < w && tx == -1) {
1357 ui->drag = 1; 1353 ui->drag = 1;
1358 ui->dragnum = state->sequence[ty]; 1354 ui->dragnum = state->sequence[ty];
1359 ui->dragpos = ty; 1355 ui->dragpos = ty;
1360 ui->edgepos = FROMCOORD(y + TILESIZE/2); 1356 ui->edgepos = FROMCOORD(y + TILESIZE/2);
1361 return ""; 1357 return UI_UPDATE;
1362 } 1358 }
1363 } else if (IS_MOUSE_DRAG(button)) { 1359 } else if (IS_MOUSE_DRAG(button)) {
1364 if (!ui->hpencil && 1360 if (!ui->hpencil &&
@@ -1371,7 +1367,7 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1371 ui->odx = ui->ody = 0; 1367 ui->odx = ui->ody = 0;
1372 ui->odn = 1; 1368 ui->odn = 1;
1373 } 1369 }
1374 return ""; 1370 return UI_UPDATE;
1375 } 1371 }
1376 1372
1377 if (IS_CURSOR_MOVE(button)) { 1373 if (IS_CURSOR_MOVE(button)) {
@@ -1381,13 +1377,13 @@ static char *interpret_move(const game_state *state, game_ui *ui,
1381 ui->hx = state->sequence[cx]; 1377 ui->hx = state->sequence[cx];
1382 ui->hy = state->sequence[cy]; 1378 ui->hy = state->sequence[cy];
1383 ui->hshow = ui->hcursor = 1; 1379 ui->hshow = ui->hcursor = 1;
1384 return ""; 1380 return UI_UPDATE;
1385 } 1381 }
1386 if (ui->hshow && 1382 if (ui->hshow &&
1387 (button == CURSOR_SELECT)) { 1383 (button == CURSOR_SELECT)) {
1388 ui->hpencil = 1 - ui->hpencil; 1384 ui->hpencil = 1 - ui->hpencil;
1389 ui->hcursor = 1; 1385 ui->hcursor = 1;
1390 return ""; 1386 return UI_UPDATE;
1391 } 1387 }
1392 1388
1393 if (ui->hshow && 1389 if (ui->hshow &&
@@ -2110,7 +2106,8 @@ int main(int argc, char **argv)
2110{ 2106{
2111 game_params *p; 2107 game_params *p;
2112 game_state *s; 2108 game_state *s;
2113 char *id = NULL, *desc, *err; 2109 char *id = NULL, *desc;
2110 const char *err;
2114 digit *grid; 2111 digit *grid;
2115 int grade = FALSE; 2112 int grade = FALSE;
2116 int ret, diff, really_show_working = FALSE; 2113 int ret, diff, really_show_working = FALSE;